/** * verify - standard API method, with a twist. It will gobble up anything in $_FILES if available, unless an array of arrays is passed in to $pParamHash['_files_override'] * * @access private * @author Christian Fowler<*****@*****.**> * @param $pParamHash * @return FALSE if errors were present, TRUE meaning object is ready to store * @deprecated deprecated since version 2.1.0-beta */ function verify(&$pParamHash) { //deprecated( "This method has been replaced by a method in LibertyMime. Please try to migrate your code." ); global $gBitSystem, $gBitUser; // check to see if we have any files to upload if (isset($pParamHash['_files_override'])) { // we have been passed in a manually stuffed files attachment, such as a custom uploader would have done. // process this, and skip over $_FILES $uploads = $pParamHash['_files_override']; } elseif (!empty($_FILES)) { // we have some _FILES hanging around we will gobble up. This is inherently dagnerous chewing up a _FILES like this as // it can cause premature storing of a _FILE if you are trying to store multiple pieces of content at once. foreach ($_FILES as $key => $file) { if (!empty($file['name'])) { $uploads[$key] = $file; } } } // don't check for p_liberty_attach_attachments permission on bitpermuser class so registration with avatar upload works if (strtolower(get_class($this)) == 'bitpermuser') { $pParamHash['no_perm_check'] = TRUE; } // check for the required permissions to upload a file to the liberty attachments area if (!empty($uploads) && empty($pParamHash['no_perm_check'])) { if (!$gBitUser->hasPermission('p_liberty_attach_attachments')) { $this->mErrors['permission'] = tra('You do not have permission to upload attachments.'); } } if (!empty($pParamHash['attachment_id']) && !$this->verifyId($pParamHash['attachment_id'])) { $this->mErrors['file'] = tra('System Error: Non-numeric storage_id.'); } if (empty($pParamHash['user_id'])) { // storage is always owned by the user that uploaded it! // er... or at least admin if somehow we have a NULL mUserId - anon uploads maybe? $pParamHash['user_id'] = @$this->verifyId($gBitUser->mUserId) ? $gBitUser->mUserId : ROOT_USER_ID; } if (empty($pParamHash['process_storage'])) { $pParamHash['process_storage'] = NULL; } if (empty($pParamHash['subdir'])) { $pParamHash['subdir'] = 'files'; } if (!empty($uploads)) { foreach (array_keys($uploads) as $f) { $this->verifyAttachment($pParamHash, $uploads[$f], $f); } } // primary attachment. Allow 'none' to clear the primary. if (!@BitBase::verifyId($pParamHash['liberty_attachments']['primary']) && (empty($pParamHash['liberty_attachments']['primary']) || $pParamHash['liberty_attachments']['primary'] != 'none')) { $pParamHash['liberty_attachments']['primary'] = NULL; } // if we have an error we get them all by checking parent classes for additional errors if (count($this->mErrors) > 0) { parent::verify($pParamHash); } return count($this->mErrors) == 0; }
/** * Create a new content object or update an existing one * * @param array Array of content data to be stored <br> * See verify for details of the values required */ function store(&$pParamHash) { global $gLibertySystem; if (LibertyContent::verify($pParamHash)) { $this->clearFromCache(); $this->StartTrans(); $table = BIT_DB_PREFIX . "liberty_content"; if (!@$this->verifyId($pParamHash['content_id'])) { // make sure some variables are stuff in case services need getObjectType, mContentId, etc... $this->mContentId = $pParamHash['content_id'] = $pParamHash['content_store']['content_id'] = $this->mDb->GenID('liberty_content_id_seq'); $this->mContentTypeGuid = $this->mInfo['content_type_guid'] = $pParamHash['content_type_guid']; $result = $this->mDb->associateInsert($table, $pParamHash['content_store']); $this->mLogs['content_store'] = "Created"; } else { if (!empty($pParamHash['content_store']['title']) && !empty($this->mInfo['title']) && $pParamHash['content_store']['title'] != $this->mInfo['title']) { $this->mLogs['rename_page'] = "Renamed from {$this->mInfo['title']} to {$pParamHash['content_store']['title']}."; } $result = $this->mDb->associateUpdate($table, $pParamHash['content_store'], array("content_id" => $pParamHash['content_id'])); $this->mLogs['content_store'] = "Updated"; } if (!empty($pParamHash['force_history']) || empty($pParamHash['minor']) && $this->getField('version') && $pParamHash['field_changed']) { if (empty($pParamHash['has_no_history'])) { $this->storeHistory(); } //$action = "Created"; //$mailEvents = 'wiki_page_changes'; } $this->storeAliases($pParamHash); $this->invokeServices('content_store_function', $pParamHash); // Call the formatter's save if (!empty($pParamHash['content_store']['data'])) { if ($func = $gLibertySystem->getPluginFunction($pParamHash['format_guid'], 'store_function')) { $ret = $func($pParamHash); } // post store filter - this is needed to deal with filters that need the content_id on the first save $this->filterData($pParamHash['content_store']['data'], $pParamHash['content_store'], 'poststore'); } LibertyContent::expungeCacheFile($pParamHash['content_id']); // store data foreach ($pParamHash['data_store'] as $dataType => $data) { $this->storeData($data, $dataType); } // store content preferences if (@is_array($pParamHash['preferences_store'])) { foreach ($pParamHash['preferences_store'] as $pref => $value) { $this->storePreference($pref, $value); } } // store hits and last hit if (!empty($pParamHash['content_store']['hits'])) { $this->setHits($pParamHash['content_store']['hits'], $pParamHash['content_store']['last_hit']); } // store any messages in the logs $this->storeActionLog($pParamHash); $this->CompleteTrans(); } return count($this->mErrors) == 0; }
function preview(&$pParamHash) { global $gBitSmarty, $gBitSystem; $this->verify($pParamHash); // This is stupid! verify does NOT work how it should. // verify should call the super class verify at all levels. LibertyContent::verify($pParamHash); $this->mInfo = array_merge($pParamHash['nlpg_store'], $pParamHash['content_store']); $this->mInfo['data'] = $pParamHash['edit']; $this->mInfo['parsed'] = $this->parseData($pParamHash['edit'], empty($pParamHash['format_guid']) ? $pParamHash['format_guid'] : $gBitSystem->getConfig('default_format')); $this->invokeServices('content_preview_function'); $gBitSmarty->assign('preview', true); }
/** * Verify content that is about to be stored * * @param array $pStoreHash hash of all data that needs to be stored in the database * @access public * @return TRUE on success, FALSE on failure - mErrors will contain reason * @todo If one of the uploaded files is an update, place the attachment_id with the upload hash in $_FILES or in _files_override */ public function verify(&$pParamHash) { global $gBitUser, $gLibertySystem; // check to see if we have any files to upload if (isset($pParamHash['_files_override'])) { // we have been passed in a manually stuffed files attachment, such as a custom uploader would have done. // process this, and skip over $_FILES $uploads = $pParamHash['_files_override']; } elseif (!empty($_FILES)) { // we have some _FILES hanging around we will gobble up. This is inherently dagnerous chewing up a _FILES like this as // it can cause premature storing of a _FILE if you are trying to store multiple pieces of content at once. foreach ($_FILES as $key => $file) { if (!empty($file['name']) || !empty($file['attachment_id'])) { $uploads[$key] = $file; } } } // verify uploads if (!empty($uploads)) { foreach (array_keys($uploads) as $file) { $pParamHash['upload_store']['files'][$file] = LibertyMime::verifyAttachment($uploads[$file]); } } // don't check for p_liberty_attach_attachments permission on bitpermuser class so registration with avatar upload works if (strtolower(get_class($this)) == 'bitpermuser') { $pParamHash['upload_store']['no_perm_check'] = TRUE; } // check for the required permissions to upload a file to the liberty attachments area if (!empty($uploads) && empty($pParamHash['no_perm_check'])) { if (!$this->hasUserPermission('p_liberty_attach_attachments')) { $this->mErrors['permission'] = tra('You do not have permission to upload attachments.'); } } // primary attachment. Allow 'none' to clear the primary. if (!@BitBase::verifyId($pParamHash['liberty_attachments']['primary']) && (empty($pParamHash['liberty_attachments']['primary']) || $pParamHash['liberty_attachments']['primary'] != 'none')) { $pParamHash['liberty_attachments']['primary'] = NULL; } // if we have an error we get them all by checking parent classes for additional errors if (count($this->mErrors) > 0) { // check errors of LibertyContent since LibertyMime means to override the parent verify LibertyContent::verify($pParamHash); } return count($this->mErrors) == 0; }