Пример #1
0
 /**
  * Get the last gallery created by this user. If the user hasn't created a gallery, create one
  * 
  * @param string $pNewName Name of the new gallery
  * @access public
  * @return Gallery Id of the default gallery
  */
 function getDefaultGalleryId($pNewName = NULL)
 {
     global $gBitUser, $gContent;
     // as default gallery, we pick the first one created by this user
     $gal = new TreasuryGallery();
     $getHash = array('user_id' => $gBitUser->mUserId, 'max_records' => 1, 'sort_mode' => 'created_asc');
     $upGal = $gal->getList($getHash);
     if (@BitBase::verifyId(key($upGal))) {
         $ret = key($upGal);
     } elseif ($gBitUser->hasPermission('p_treasury_create_gallery')) {
         // Since the user can create a new gallery, we simply create a new one
         if (empty($pNewName)) {
             $pNewName = $gBitUser->getDisplayName() . "'s File Gallery";
         }
         $galleryHash = array('title' => $pNewName);
         if ($gal->store($galleryHash)) {
             $ret = $gal->mContentId;
         }
     } else {
         // if we reach this section, we'll simply pick the first gallery we can find and dump all files in there
         $getHash = array('max_records' => 1, 'sort_mode' => 'created_asc');
         $upGal = $gal->getList($getHash);
         if (@BitBase::verifyId(key($upGal))) {
             $ret = key($upGal);
         } else {
             // we need to report that there is absolutely no way we can place the gallery anywhere
             $this->mErrors['no_default'] = tra('We could not find a viable gallery where we can store your upload');
         }
     }
     if (!$gContent->isValid()) {
         $gContent = new TreasuryGallery($ret);
     }
     return $ret;
 }
Пример #2
0
    }
    if (!empty($_FILES['file']['tmp_name'])) {
        $_REQUEST['upload'] = $_FILES['file'];
    }
    if ($gContent->store($_REQUEST)) {
        $feedback = $gContent->mErrors;
    }
    // give some feedback if all went well
    if (empty($feedback['error'])) {
        $feedback['success'] = tra('The settings were successfully applied.');
    }
    // now that the file has been updated, we return to the view page
    bit_redirect($gContent->mInfo['display_url']);
}
// move file back to where it was
if (!empty($_REQUEST['reprocess_upload']) && !empty($tmpfile) && is_file($tmpfile)) {
    // move file back to where it should be
    rename($tmpfile, $gContent->mInfo['source_file']);
}
// get a list of galleries this file is already part of
$galleryContentIds = $gContent->getParentGalleries();
$gBitSmarty->assign('galleryContentIds', $galleryContentIds);
$gallery = new TreasuryGallery();
$listHash['get_sub_tree'] = TRUE;
$listHash['max_records'] = -1;
$listHash['content_permission'] = 'p_treasury_upload_item';
$galleryList = $gallery->getList($listHash);
$gBitSmarty->assign('galleryList', $galleryList);
$gContent->invokeServices('content_edit_function');
$gBitSmarty->assign('feedback', !empty($feedback) ? $feedback : NULL);
$gBitSystem->display("bitpackage:treasury/edit_item.tpl", tra("Edit File"), array('display_mode' => 'edit'));