/** * 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; }