/** * This function stores a set **/ function store(&$pParamHash) { if ($this->verify($pParamHash)) { $this->mDb->StartTrans(); if (parent::store($pParamHash)) { if ($this->mOverlaySetId) { $this->mDb->associateUpdate(BIT_DB_PREFIX . $this->mOverlaySetTable, $pParamHash['set_store'], array("set_id" => $pParamHash['set_id'])); // and we update the set keychain on map_id. if (isset($pParamHash['keychain_ids']['gmap_id'])) { $pParamHash['keychain_ids']['set_id'] = $pParamHash['set_id']; $this->mDb->associateUpdate(BIT_DB_PREFIX . "gmaps_sets_keychain", $pParamHash['keychain_update'], $pParamHash['keychain_ids']); } } else { $pParamHash['set_store']['content_id'] = $this->mContentId; $pParamHash['set_store']['set_id'] = $this->mDb->GenID($this->mOverlaySetSeq); $this->mDb->associateInsert(BIT_DB_PREFIX . $this->mOverlaySetTable, $pParamHash['set_store']); // and insert an entry in the set keychain and associate it with a map. if (isset($pParamHash['keychain_store']['gmap_id'])) { $pParamHash['keychain_store']['set_id'] = $pParamHash['set_store']['set_id']; $this->mDb->associateInsert(BIT_DB_PREFIX . "gmaps_sets_keychain", $pParamHash['keychain_store']); } } $this->mDb->CompleteTrans(); // re-query to confirm results $gmapId = isset($pParamHash['keychain_store']['gmap_id']) ? $pParamHash['keychain_store']['gmap_id'] : NULL; $this->load($gmapId); } else { $this->mDb->RollbackTrans(); } } return count($this->mErrors) == 0; }
function store(&$pParamHash) { //$nl_id, $name, $description, $allow_user_sub, $allow_any_sub, $unsub_msg, $validate_addr) { if ($this->verify($pParamHash)) { $this->mDb->StartTrans(); if (parent::store($pParamHash)) { if ($this->mNewsletterId) { $result = $this->mDb->associateUpdate(BIT_DB_PREFIX . "newsletters", $pParamHash['newsletter_store'], array("nl_id" => $this->mNewsletterId)); } else { $pParamHash['newsletter_store']['content_id'] = $pParamHash['content_id']; $result = $this->mDb->associateInsert(BIT_DB_PREFIX . "newsletters", $pParamHash['newsletter_store']); } $this->mDb->CompleteTrans(); } else { $this->mDb->RollbackTrans(); } } return count($this->mErrors) == 0; }
/** * TODO: This code is old and is not used by any package in the bitweaver CVS anymore. * We will clean up this code as soon as we migrated all legacy code */ function store(&$pParamHash) { //deprecated( "This method has been replaced by a method in LibertyMime. Please try to migrate your code." ); global $gLibertySystem, $gBitSystem, $gBitUser; $this->mDb->StartTrans(); if (LibertyAttachable::verify($pParamHash) && (isset($pParamHash['skip_content_store']) || LibertyContent::store($pParamHash))) { if (!empty($pParamHash['STORAGE']) && count($pParamHash['STORAGE'])) { foreach (array_keys($pParamHash['STORAGE']) as $guid) { $storeRows =& $pParamHash['STORAGE'][$guid]; // short hand variable assignment // If it is empty then nothing more to do. Avoid error in foreach. if (empty($storeRows)) { continue; } foreach ($storeRows as $key => $value) { $storeRow =& $pParamHash['STORAGE'][$guid][$key]; $storeRow['plugin_guid'] = $guid; if (!@BitBase::verifyId($pParamHash['content_id'])) { $storeRow['content_id'] = NULL; } else { $storeRow['content_id'] = $pParamHash['content_id']; // copy in content_id } if (!empty($pParamHash['user_id'])) { $storeRow['user_id'] = $pParamHash['user_id']; // copy in the user_id } else { $storeRow['user_id'] = $gBitUser->mUserId; } // do we have a verify function for this storage type, and do things verify? $verifyFunc = $gLibertySystem->getPluginFunction($guid, 'verify_function'); if ($verifyFunc && $verifyFunc($storeRow)) { // For backwards compatibility with a single upload. if (@BitBase::verifyId($pParamHash['attachment_id'])) { $storeRow['upload']['attachment_id'] = $storeRow['attachment_id'] = $pParamHash['attachment_id']; } else { if (!isset($storeRow['skip_insert'])) { if (defined('LINKED_ATTACHMENTS') && @BitBase::verifyId($pParamHash['content_id'])) { $storeRow['upload']['attachment_id'] = $storeRow['attachment_id'] = $pParamHash['content_id']; } else { $storeRow['upload']['attachment_id'] = $storeRow['attachment_id'] = defined('LINKED_ATTACHMENTS') ? $this->mDb->GenID('liberty_content_id_seq') : $this->mDb->GenID('liberty_attachments_id_seq'); } } } // if we have uploaded a file, we can take care of that generically if (!empty($storeRow['upload']) && is_array($storeRow['upload']) && !empty($storeRow['upload']['size'])) { if (empty($storeRow['upload']['type'])) { $ext = substr($storeRow['upload']['name'], strrpos($storeRow['upload']['name'], '.') + 1); $storeRow['upload']['type'] = $gBitSystem->lookupMimeType($ext); } $storeRow['upload']['dest_branch'] = $this->getStorageBranch($storeRow['attachment_id'], $storeRow['user_id'], $this->getStorageSubDirName()); if (!empty($pParamHash['thumbnail_sizes'])) { $storeRow['upload']['thumbnail_sizes'] = $pParamHash['thumbnail_sizes']; } $storagePath = liberty_process_upload($storeRow['upload']); // We're gonna store to local file system & liberty_files table if (empty($storagePath)) { $this->mErrors['file'] = tra("Could not store file") . ": " . $storeRow['upload']['name'] . '.'; $storeRow['attachment_id'] = NULL; $storeRow['upload']['attachment_id'] = NULL; } else { $storeRow['upload']['dest_file_path'] = $storagePath; } } if (@BitBase::verifyId($storeRow['attachment_id']) && ($storeFunc = $gLibertySystem->getPluginFunction($storeRow['plugin_guid'], 'store_function'))) { $this->mStorage = $storeFunc($storeRow); } // don't insert if we already have an entry with this attachment_id if (@BitBase::verifyId($storeRow['attachment_id']) && !isset($storeRow['skip_insert']) && !LibertyMime::loadAttachment($storeRow['attachment_id'])) { $sql = "INSERT INTO `" . BIT_DB_PREFIX . "liberty_attachments` ( `content_id`, `attachment_id`, `attachment_plugin_guid`, `foreign_id`, `user_id` ) VALUES ( ?, ?, ?, ?, ? )"; $rs = $this->mDb->query($sql, array($storeRow['content_id'], $storeRow['attachment_id'], $storeRow['plugin_guid'], (int) $storeRow['foreign_id'], $storeRow['user_id'])); } } } } } // set the primary attachment id $this->setPrimaryAttachment($pParamHash['liberty_attachments']['primary'], $pParamHash['content_id'], empty($pParamHash['liberty_attachments']['auto_primary']) || $pParamHash['liberty_attachments']['auto_primary'] ? TRUE : FALSE); } $this->mDb->CompleteTrans(); return count($this->mErrors) == 0; }
/** * Any method named Store inherently implies data will be written to the database * @param pParamHash be sure to pass by reference in case we need to make modifcations to the hash * This is the ONLY method that should be called in order to store ( create or update ) an nlpg record! * It is very smart and will figure out what to do for you. It should be considered a black box. * * @param array pParams hash of values that will be used to store the page * * @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why * * @access public **/ function store(&$pParamHash) { if ($this->verify($pParamHash) && LibertyContent::store($pParamHash)) { $table = BIT_DB_PREFIX . "nlpg"; $this->mDb->StartTrans(); if ($this->mNlpgId) { $result = $this->mDb->associateUpdate($table, $pParamHash['nlpg_store'], array('nlpg_id' => $pParamHash['nlpg_id'])); } else { $pParamHash['nlpg_store']['content_id'] = $pParamHash['content_id']; if (@$this->verifyId($pParamHash['nlpg_id'])) { // if pParamHash['nlpg_id'] is set, some is requesting a particular nlpg_id. Use with caution! $pParamHash['nlpg_store']['nlpg_id'] = $pParamHash['nlpg_id']; } else { $pParamHash['nlpg_store']['nlpg_id'] = $this->mDb->GenID('nlpg_id_seq'); } $this->mNlpgId = $pParamHash['nlpg_store']['nlpg_id']; $result = $this->mDb->associateInsert($table, $pParamHash['nlpg_store']); } $this->mDb->CompleteTrans(); $this->load(); } return count($this->mErrors) == 0; }
/** * This is the ONLY method that should be called in order to store (create or update) a wiki page! * It is very smart and will figure out what to do for you. It should be considered a black box. * * @param array pParams hash of values that will be used to store the page * * @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why * * @access public **/ function store(&$pParamHash) { $this->mDb->StartTrans(); if ($this->verify($pParamHash) && LibertyContent::store($pParamHash)) { $table = PHPGEDVIEW_DB_PREFIX . "gedcom"; if ($this->verifyId($this->mGEDCOMId)) { $result = $this->mDb->associateUpdate($table, $pParamHash['gedcom_store'], array("g_id" => $this->mGEDCOMId)); } else { $pParamHash['gedcom_store']['g_content_id'] = $pParamHash['content_id']; if (@$this->verifyId($pParamHash['g_id'])) { // if pParamHash['g_id'] is set, someone is requesting a particular g_id. Use with caution! $pParamHash['gedcom_store']['g_id'] = $pParamHash['g_id']; } else { $pParamHash['gedcom_store']['g_id'] = $this->mDb->GenID('gedview_id_seq'); } $this->mGEDCOMId = $pParamHash['gedcom_store']['g_id']; $result = $this->mDb->associateInsert($table, $pParamHash['gedcom_store']); } // Access new data for notifications $this->load(); } $this->mDb->CompleteTrans(); return count($this->mErrors) == 0; }
/** * GoldenRecordLoad( $data ); * Rother golden file import */ function GoldenRecordLoad(&$data) { $table = BIT_DB_PREFIX . "citizen"; $atable = BIT_DB_PREFIX . "citizen_address"; $usn = 9000000000 + $data[0]; $pDataHash['citizen_store']['content_id'] = $data[0]; $pDataHash['citizen_store']['usn'] = $usn; $pDataHash['address_store']['content_id'] = $data[0]; $pDataHash['address_store']['usn'] = $usn; $pDataHash['citizen_store']['uprn'] = $data[1]; $pDataHash['address_store']['uprn'] = $data[1]; $pDataHash['citizen_store']['prefix'] = $data[2]; $pDataHash['citizen_store']['forename'] = $data[3]; $pDataHash['citizen_store']['surname'] = $data[4]; $pDataHash['citizen_store']['organisation'] = $data[5]; $pDataHash['citizen_store']['opfl'] = $data[6]; $pDataHash['citizen_store']['nino'] = $data[7]; if ($data[8] != '') { $date = substr($data[8], 6, 4) . '-' . substr($data[8], 3, 2) . '-' . substr($data[8], 0, 2); } else { $date = NULL; } $pDataHash['citizen_store']['eighteenth'] = $date; if ($data[9] != '') { $date = substr($data[9], 6, 4) . '-' . substr($data[9], 3, 2) . '-' . substr($data[9], 0, 2); } else { $date = NULL; } $pDataHash['citizen_store']['dob'] = $date; $pDataHash['citizen_store']['ctax'] = $data[10]; $pDataHash['address_store']['organisation'] = $data[11]; $pDataHash['address_store']['sao'] = $data[12]; $pDataHash['address_store']['pao'] = $data[13]; $pDataHash['address_store']['number'] = $data[14]; $pDataHash['address_store']['street'] = $data[15]; $pDataHash['address_store']['locality'] = $data[16]; $pDataHash['address_store']['town'] = $data[17]; $pDataHash['address_store']['county'] = $data[18]; $pDataHash['address_store']['postcode'] = substr($data[19], 0, 4) . ' ' . substr($data[19], 4, 3); $pDataHash['citizen_store']['nlpg'] = $data[20]; if ($data[21] != '') { $date = substr($data[21], 6, 4) . '-' . substr($data[21], 3, 2) . '-' . substr($data[21], 0, 2); } else { $date[21] = null; } $pDataHash['citizen_store']['last_update_date'] = $date; $query_cant = "SELECT COUNT(ci.`content_id`) FROM `" . BIT_DB_PREFIX . "citizen` ci\n\t\t\t\tWHERE ci.`usn`=?"; $cant = $this->mDb->getOne($query_cant, array(9000000000 + $data[0])); if ($cant > 0) { $query_cant = "SELECT * FROM `" . BIT_DB_PREFIX . "citizen` ci\n\t\t\t\tWHERE con.`usn`=?"; $current = $this->mDb->query($query_cant, array(9000000000 + $data[0])); $cfields = $current->fetchRow(); $save = false; if ($pDataHash['citizen_store']['uprn'] != $cfields['uprn']) { $save = true; } if ($pDataHash['citizen_store']['nlpg'] != $cfields['nlpg']) { $save = true; } if ($pDataHash['citizen_store']['prefix'] != $cfields['prefix']) { $save = true; } if ($pDataHash['citizen_store']['forename'] != $cfields['forename']) { $save = true; } if ($pDataHash['citizen_store']['surname'] != $cfields['surname']) { $save = true; } if ($pDataHash['citizen_store']['organisation'] != $cfields['organisation']) { $save = true; } if ($pDataHash['citizen_store']['opfl'] != $cfields['opfl']) { $save = true; } if ($pDataHash['citizen_store']['nino'] != $cfields['nino']) { $save = true; } if ($pDataHash['citizen_store']['ctax'] != $cfields['ctax']) { $save = true; } if ($pDataHash['citizen_store']['dob'] && $pDataHash['citizen_store']['dob'] != $cfields['dob']) { $save = true; } if ($pDataHash['citizen_store']['eighteenth'] && $pDataHash['citizen_store']['eighteenth'] != $cfields['eighteenth']) { $save = true; } if ($pDataHash['citizen_store']['last_update_date'] && $pDataHash['citizen_store']['last_update_date'] != $cfields['last_update_date']) { $save = true; } if ($save) { // $pDataHash['citizen_store']['last_update_date'] = $this->mDb->now(); $result = $this->mDb->associateUpdate($table, $pDataHash['citizen_store'], array("usn" => $usn)); } $save = false; if ($pDataHash['address_store']['uprn'] != $cfields['uprn']) { $save = true; } if ($pDataHash['address_store']['organisation'] != $cfields['organisation']) { $save = true; } if ($pDataHash['address_store']['sao'] != $cfields['sao']) { $save = true; } if ($pDataHash['address_store']['pao'] != $cfields['pao']) { $save = true; } if ($pDataHash['address_store']['number'] != $cfields['number']) { $save = true; } if ($pDataHash['address_store']['street'] != $cfields['street']) { $save = true; } if ($pDataHash['address_store']['locality'] != $cfields['locality']) { $save = true; } if ($pDataHash['address_store']['town'] != $cfields['town']) { $save = true; } if ($pDataHash['address_store']['county'] != $cfields['county']) { $save = true; } if ($pDataHash['address_store']['postcode'] != $cfields['postcode']) { $save = true; } if ($save) { $result = $this->mDb->associateUpdate($atable, $pDataHash['address_store'], array("usn" => $usn)); } } else { $this->mDb->StartTrans(); $this->mContentId = 0; $pDataHash['content_id'] = 0; if (LibertyContent::store($pDataHash)) { $pDataHash['citizen_store']['content_id'] = $pDataHash['content_id']; $pDataHash['address_store']['content_id'] = $pDataHash['content_id']; $result = $this->mDb->associateInsert($table, $pDataHash['citizen_store']); $result = $this->mDb->associateInsert($atable, $pDataHash['address_store']); $this->mDb->CompleteTrans(); } else { $this->mDb->RollbackTrans(); $this->mErrors['store'] = 'Failed to store this citizen.'; } } return count($this->mErrors) == 0; }
/** * Store incident report data * @param $pParamHash contains all data to store the IR * @param $pParamHash[title] title of the new IR * @param $pParamHash[edit] description of the IR * @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why * @access public **/ function store(&$pParamHash) { if ($this->verify($pParamHash)) { // Start a transaction wrapping the whole insert into liberty $this->mDb->StartTrans(); if (LibertyContent::store($pParamHash)) { $table = BIT_DB_PREFIX . "irlist_secondary"; // mContentId will not be set until the secondary data has commited // What happened to THAT rule ??? if ($this->verifyId($this->mIRId)) { if (!empty($pParamHash['secondary_store'])) { $result = $this->mDb->associateUpdate($table, $pParamHash['secondary_store'], array("content_id" => $this->mContentId)); } } else { $pParamHash['secondary_store']['content_id'] = $pParamHash['content_id']; if (@$this->verifyId($pParamHash['secondary_store']['ir_id'])) { $pParamHash['secondary_store']['ir_id'] = $pParamHash['ir_id']; } else { $pParamHash['secondary_store']['ir_id'] = $this->mDb->GenID('ir_id_seq'); } $pParamHash['secondary_store']['parent_id'] = $pParamHash['secondary_store']['content_id']; $this->mIRId = $pParamHash['secondary_store']['ir_id']; $this->mContentId = $pParamHash['content_id']; $result = $this->mDb->associateInsert($table, $pParamHash['secondary_store']); } // load before completing transaction as firebird isolates results $this->load(); $this->mDb->CompleteTrans(); } else { $this->mDb->RollbackTrans(); } } return count($this->mErrors) == 0; }
/** * Store a new upload * * @param array $pStoreHash contains all data to store the gallery * @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why * @access public **/ public function store(&$pStoreHash) { global $gLibertySystem; // make sure all the data is in order if (LibertyMime::verify($pStoreHash) && (!empty($pStoreHash['skip_content_store']) || LibertyContent::store($pStoreHash))) { $this->StartTrans(); // files have been uploaded if (!empty($pStoreHash['upload_store']['files']) && is_array($pStoreHash['upload_store']['files'])) { foreach ($pStoreHash['upload_store']['files'] as $key => $upload) { // if we don't have an upload, we'll simply update the file settings using the mime plugins if (empty($upload['tmp_name'])) { if (@BitBase::verifyId($upload['attachment_id'])) { // since the form might have all options unchecked, we need to call the update function regardless // currently i can't think of a better way to get the plugin guid back when $pStoreHash[plugin] is // empty. - xing - Friday Jul 11, 2008 20:21:18 CEST if (!empty($this->mStorage[$upload['attachment_id']])) { $attachment = $this->mStorage[$upload['attachment_id']]; $data = array(); if (!empty($pStoreHash['plugin'][$upload['attachment_id']][$attachment['attachment_plugin_guid']])) { $data = $pStoreHash['plugin'][$upload['attachment_id']][$attachment['attachment_plugin_guid']]; } if (!$this->updateAttachmentParams($upload['attachment_id'], $attachment['attachment_plugin_guid'], $data)) { $this->mErrors['attachment_update'] = "There was a problem updating the file settings."; } } } // skip rest of process continue; } $storeRow = $pStoreHash['upload_store']; unset($storeRow['files']); // copy by reference that filetype changes are made in lookupMimeHandler() $storeRow['upload'] =& $upload; if (isset($pStoreHash['thumbnail'])) { $storeRow['upload']['thumbnail'] = $pStoreHash['thumbnail']; } // when content is created the content_id is only available after LibertyContent::store() $storeRow['content_id'] = $pStoreHash['content_id']; // let the plugin do the rest $guid = $gLibertySystem->lookupMimeHandler($upload); $this->pluginStore($storeRow, $guid, @BitBase::verifyId($upload['attachment_id'])); // finally, we need to update the original hash with the new values $pStoreHash['upload_store']['files'][$key] = $storeRow; } } // some mime plugins might not have file uploads - these plugins will tell us what mime handlers they are using if (!empty($pStoreHash['mimeplugin']) && is_array($pStoreHash['mimeplugin'])) { foreach ($pStoreHash['mimeplugin'] as $guid => $storeRow) { // check to see if we have anything worth storing in the array $plugin_store = FALSE; foreach (array_values($storeRow) as $value) { if (!empty($value)) { $plugin_store = TRUE; } } if (!empty($plugin_store)) { // when content is created the content_id is only available after LibertyContent::store() $storeRow['content_id'] = $pStoreHash['content_id']; $this->pluginStore($storeRow, $guid, @BitBase::verifyId($upload['attachment_id'])); } } } // deal with the primary attachment after we've dealt with all the files $this->setPrimaryAttachment($pStoreHash['liberty_attachments']['primary'], $pStoreHash['content_id'], empty($pStoreHash['liberty_attachments']['auto_primary']) || $pStoreHash['liberty_attachments']['auto_primary'] ? TRUE : FALSE); // Roll back if something went wrong if (empty($this->mErrors)) { $this->CompleteTrans(); } else { $this->mDb->RollbackTrans(); } } return count($this->mErrors) == 0; }
/** * Create a new stickies object or update an existing one * * @param array Array of content data to be stored (see verify for details) * @return integer Number of errors detected ( 0 if successful ) */ function store(&$pParamHash) { if ($this->verify($pParamHash)) { $this->mDb->StartTrans(); if (LibertyContent::store($pParamHash)) { if ($this->mStickyId) { $result = $this->mDb->associateUpdate(BIT_DB_PREFIX . "stickies", $pParamHash['sticky_store'], array("sticky_id" => $this->mStickyId)); } else { $pParamHash['sticky_store']['content_id'] = $pParamHash['content_id']; if (@BitBase::verifyId($pParamHash['sticky_id'])) { $pParamHash['sticky_store']['sticky_id'] = $pParamHash['sticky_id']; } else { $pParamHash['sticky_store']['sticky_id'] = $this->mDb->GenID('stickies_sticky_id_seq'); } $this->mPageId = $pParamHash['sticky_store']['sticky_id']; $result = $this->mDb->associateInsert(BIT_DB_PREFIX . "stickies", $pParamHash['sticky_store']); } $this->mDb->CompleteTrans(); } else { $this->mDb->RollbackTrans(); } } return count($this->mErrors) == 0; }
/** * Store TreasuryGallery * * @param $pParamHash contains all data to store the gallery * @param $pParamHash[title] title of the new gallery * @param $pParamHash[edit] description of the gallery * @param $pParamHash[root_structure_id] if this is set, it will add the gallery to this structure. if it's not set, a new structure / top level gallery is created * @param $pParamHash[parent_id] set the structure_id that will server as the parent in the structure * @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why * @access public **/ function store(&$pParamHash) { $this->mDb->StartTrans(); if ($this->verify($pParamHash) && LibertyContent::store($pParamHash)) { $table = BIT_DB_PREFIX . "treasury_gallery"; // this really confusing, strange order way of saving items is due to strange behaviour of GenID // probably has to do with not null default nextval('public.liberty_structures_id_seq'::text) if (!empty($pParamHash['update'])) { if (!empty($pParamHash['gallery_store'])) { $result = $this->mDb->associateUpdate($table, $pParamHash['gallery_store'], array("content_id" => $this->mContentId)); } $pParamHash['structure_location_id'] = $this->mStructureId; } else { // update the gallery_store and structure_store content_id with the one from LibertyMime::store() $pParamHash['structure_store']['content_id'] = $pParamHash['content_id']; $pParamHash['gallery_store']['content_id'] = $pParamHash['content_id']; // we need to store the new structure node now global $gStructure; // create new object if needed if (empty($gStructure)) { $gStructure = new LibertyStructure(); } $pParamHash['structure_location_id'] = $gStructure->storeNode($pParamHash['structure_store']); // get the corrent structure_id // structure_id has to be done like this since it's screwed up in the schema $pParamHash['gallery_store']['structure_id'] = $this->mDb->getOne("SELECT MAX( `structure_id` ) FROM `" . BIT_DB_PREFIX . "liberty_structures`"); $result = $this->mDb->associateInsert($table, $pParamHash['gallery_store']); } $this->mDb->CompleteTrans(); // process image upload if (empty($this->mErrors)) { // now deal with the uploaded image if (!empty($pParamHash['thumb']['tmp_name'])) { $checkFunc = liberty_get_function('can_thumbnail'); if ($checkFunc($pParamHash['thumb']['type'])) { $fileHash = $pParamHash['thumb']; $fileHash['dest_branch'] = $this->getGalleryThumbBaseUrl(); $fileHash['source_file'] = $fileHash['tmp_name']; liberty_clear_thumbnails($fileHash); liberty_generate_thumbnails($fileHash); } else { $this->mErrors['thumb'] = tra("The file you uploaded doesn't appear to be a valid image. The reported mime type is") . ": " . $pParamHash['thumb']['type']; } } } $this->load(); } return count($this->mErrors) == 0; }
/** * Imports a user record from csv file * This is a admin specific function * * @param $pParamHash an array with user data * @return TRUE if import succeed **/ function importUser(&$pParamHash) { global $gBitUser; if (!$gBitUser->hasPermission('p_users_admin')) { return FALSE; } if ($this->verifyUserImport($pParamHash)) { $this->StartTrans(); $pParamHash['content_type_guid'] = BITUSER_CONTENT_TYPE_GUID; if (!empty($pParamHash['user_store']) && count($pParamHash['user_store'])) { // lookup and asign the default role for user $defaultRoles = RolePermUser::getDefaultRole(); if (!empty($defaultRoles)) { $pParamHash['user_store']['default_role_id'] = key($defaultRoles); } if ($this->isValid()) { $userId = array("user_id" => $this->mUserId); $result = $this->mDb->associateUpdate(BIT_DB_PREFIX . 'users_users', $pParamHash['user_store'], $userId); } else { if (empty($pParamHash['user_store']['user_id'])) { $pParamHash['user_store']['user_id'] = $this->mDb->GenID('users_users_user_id_seq'); } $this->mUserId = $pParamHash['user_store']['user_id']; $result = $this->mDb->associateInsert(BIT_DB_PREFIX . 'users_users', $pParamHash['user_store']); } // make sure user is added into the default role map if (!empty($pParamHash['user_store']['default_role_id'])) { RolePermUser::addUserToRole($pParamHash['user_store']['user_id'], $pParamHash['user_store']['default_role_id']); } } // Prevent liberty from assuming ANONYMOUS_USER_ID while storing $pParamHash['user_id'] = $this->mUserId; if (LibertyContent::store($pParamHash)) { if (empty($this->mInfo['content_id']) || $pParamHash['content_id'] != $this->mInfo['content_id']) { $query = "UPDATE `" . BIT_DB_PREFIX . "users_users` SET `content_id`=? WHERE `user_id`=?"; $result = $this->mDb->query($query, array($pParamHash['content_id'], $this->mUserId)); $this->mInfo['content_id'] = $pParamHash['content_id']; } } $this->CompleteTrans(); // store any uploaded images $this->storeImages($pParamHash); $this->load(TRUE); } return count($this->mErrors) == 0; }
function store(&$pStorageHash) { if ($this->verifyGalleryData($pStorageHash)) { $this->StartTrans(); if (LibertyContent::store($pStorageHash)) { $this->mContentId = $pStorageHash['content_id']; $this->mInfo['content_id'] = $this->mContentId; if ($this->galleryExistsInDatabase()) { $query = "UPDATE `" . BIT_DB_PREFIX . "fisheye_gallery`\n\t\t\t\t\t\t\tSET `rows_per_page` = ?, `cols_per_page` = ?, `thumbnail_size` = ?\n\t\t\t\t\t\t\tWHERE `gallery_id` = ?"; $bindVars = array($pStorageHash['rows_per_page'], $pStorageHash['cols_per_page'], $pStorageHash['thumbnail_size'], $this->mGalleryId); } else { $this->mGalleryId = $this->mDb->GenID('fisheye_gallery_id_seq'); $this->mInfo['gallery_id'] = $this->mGalleryId; $query = "INSERT INTO `" . BIT_DB_PREFIX . "fisheye_gallery` (`gallery_id`, `content_id`, `rows_per_page`, `cols_per_page`, `thumbnail_size`) VALUES (?,?,?,?,?)"; $bindVars = array($this->mGalleryId, $this->mContentId, $pStorageHash['rows_per_page'], $pStorageHash['cols_per_page'], $pStorageHash['thumbnail_size']); } $rs = $this->mDb->query($query, $bindVars); $this->CompleteTrans(); } else { $this->mDb->RollbackTrans(); $this->mErrors[] = "There were errors while attempting to save this gallery"; } } else { $this->mErrors[] = "There were errors while attempting to save this gallery"; } return count($this->mErrors) == 0; }
/** * TicketRecordLoad( $data ); * Ticket file import */ function TicketRecordLoad(&$data) { $table = BIT_DB_PREFIX . "task_ticket"; $pDataHash['ticket_store']['office'] = $data[0]; $pDataHash['ticket_store']['ticket_id'] = $data[1]; $pDataHash['ticket_store']['ticket_ref'] = $data[2]; $pDataHash['ticket_store']['ticket_no'] = $data[3]; $pDataHash['ticket_store']['tags'] = $data[4]; $pDataHash['ticket_store']['clearance'] = $data[5]; $pDataHash['ticket_store']['room'] = $data[6]; if ($data[7] == '[null]') { $pDataHash['ticket_store']['note'] = ''; } else { $pDataHash['ticket_store']['note'] = $data[7]; } if ($data[8] == '[null]') { $pDataHash['ticket_store']['last'] = ''; } else { $pDataHash['ticket_store']['last'] = $data[8]; } $pDataHash['ticket_store']['staff_id'] = $data[9]; $pDataHash['ticket_store']['init_id'] = $data[10]; $pDataHash['ticket_store']['caller_id'] = $data[11]; $pDataHash['ticket_store']['appoint_id'] = $data[12]; $pDataHash['ticket_store']['applet'] = $data[13]; if ($data[14] != '[null]') { $pDataHash['ticket_store']['memo'] = $data[14]; } if ($data[15] == '[null]') { $pDataHash['ticket_store']['department'] = 0; } else { $pDataHash['ticket_store']['department'] = $data[15]; } // Create LC entry details from legacy data global $gBitSystem; $this->mDb->StartTrans(); $this->mContentId = 0; $pDataHash['content_id'] = 0; $pDataHash['user_id'] = $pDataHash['ticket_store']['init_id']; $pDataHash['modifier_user_id'] = $pDataHash['ticket_store']['staff_id']; $pDataHash['created'] = $gBitSystem->mServerTimestamp->getTimestampFromISO($pDataHash['ticket_store']['ticket_ref'], true); $pDataHash['event_time'] = $pDataHash['created']; $pDataHash['last_modified'] = $gBitSystem->mServerTimestamp->getTimestampFromISO($pDataHash['ticket_store']['last'], true); $pDataHash['title'] = $pDataHash['ticket_store']['ticket_ref'] . '-Ticket-' . $pDataHash['ticket_store']['ticket_no']; $pDataHash['content_status_id'] = 60; // Mark all records Finished - data can't be modified, so read only! if (LibertyContent::store($pDataHash)) { $pDataHash['ticket_store']['content_id'] = $pDataHash['content_id']; $result = $this->mDb->associateInsert($table, $pDataHash['ticket_store']); $this->mDb->CompleteTrans(); } else { $this->mDb->RollbackTrans(); $this->mErrors['store'] = 'Failed to store this ticket.'; } }