Exemplo n.º 1
0
 /**
  * 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
  */
 function verify(&$pStoreHash)
 {
     global $gBitSystem, $gBitUser;
     // ---------- Upload store - dealt with by LibertyMime
     // Deal with the uploaded file
     // we place it in [_files_override][0] that LibertyMime knows that it has to deal with it
     if (@is_array($pStoreHash['upload'])) {
         if (!empty($pStoreHash['upload']['tmp_name']) && empty($pStoreHash['upload']['error'])) {
             $pStoreHash['_files_override'][0] = $pStoreHash['upload'];
         } else {
             $this->mErrors['upload'] = tra("There was a problem processing the uploaded file. Please try again.");
         }
     }
     // Make sure we know what to update
     if ($this->isValid()) {
         // these 2 entries will inform LibertyContent and LibertyMime that this is an update
         $pStoreHash['content_id'] = $this->mContentId;
         $pStoreHash['_files_override'][0]['attachment_id'] = $this->mInfo['attachment_id'];
     } elseif (empty($pStoreHash['_files_override'][0]['tmp_name']) || !is_file($pStoreHash['_files_override'][0]['tmp_name'])) {
         // Make sure the upload went well. If not, we break off this mellarky here.
         $this->mErrors['upload'] = tra('Uploading this file has destroyed this website - possibly even the entire internet.');
     }
     // ---------- Map store
     // make sure we have at least one gallery where we can add the file
     if (empty($pStoreHash['galleryContentIds'])) {
         $pStoreHash['galleryContentIds'][] = $this->getDefaultGalleryId();
     }
     // make sure we have the correct permissions to upload to this gallery
     foreach ($pStoreHash['galleryContentIds'] as $gcid) {
         $gallery = new TreasuryGallery(NULL, $gcid);
         if ($gallery->hasUserPermission('p_treasury_upload_item')) {
             $pStoreHash['map_store']['galleryContentIds'][] = $gcid;
         }
     }
     if (empty($pStoreHash['map_store']['galleryContentIds'])) {
         $this->mErrors['store'] = tra('No gallery available to insert uploaded files into. Please check the permissions of the gallery.');
     }
     // ---------- Content store
     // let's add a default title
     if (empty($pStoreHash['title']) && !empty($pStoreHash['upload']['name'])) {
         $pStoreHash['title'] = file_name_to_title($pStoreHash['upload']['name']);
     }
     $pStoreHash['title'] = substr($pStoreHash['title'], 0, 160);
     // sort out the description
     if ($this->isValid() && !empty($this->mInfo['data']) && empty($pStoreHash['edit'])) {
         $pStoreHash['edit'] = '';
     } elseif (empty($pStoreHash['edit'])) {
         unset($pStoreHash['edit']);
     } else {
         $pStoreHash['edit'] = $pStoreHash['edit'];
     }
     // we've done all our own permission checks
     $pStoreHash['no_perm_check'] = TRUE;
     return count($this->mErrors) == 0;
 }
Exemplo n.º 2
0
                 }
             case 'gallerycopy':
                 if (empty($destGallery)) {
                     $destGallery = new FisheyeGallery(NULL, $batchParam);
                     $destGallery->load();
                 }
                 if ($destGallery->addItem($contentId)) {
                     $feedback['success'][] = $galleryItem->getTitle() . ' ' . tra("added to") . ' ' . $destGallery->getTitle();
                 } else {
                     $feedback['error'][] = $galleryItem->getTitle() . ' ' . tra("could not be added to") . ' ' . $destGallery->getTitle();
                 }
                 break;
             case 'filenametoimagename':
                 $renameHash = array();
                 if (!empty($galleryItem->mInfo['filename'])) {
                     $renameHash['title'] = file_name_to_title($galleryItem->mInfo['filename']);
                     $galleryItem->store($renameHash);
                     // update to prevent renaming value in text input
                     $_REQUEST['image_title'][$contentId] = $renameHash['title'];
                 }
                 break;
         }
     }
 }
 if (is_object($galleryItem)) {
     if (!empty($_REQUEST['batch_security_id'])) {
     }
     // if we are reordered, that takes precident
     $newPos = preg_replace('/[^\\d\\.]/', '', !empty($newOrder[$contentId]) ? $newOrder[$contentId] : $newPos);
     if ($galleryItem->mInfo['title'] != $_REQUEST['image_title'][$contentId]) {
         $storageHash = array('title' => $_REQUEST['image_title'][$contentId]);