/** * 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; }
} $gBitSmarty->assign('galleryStructure', $galleryStructure); } if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'edit') { $gBitSmarty->assignByRef('galInfo', $gContent->mInfo); } if (!empty($_REQUEST['treasury_store'])) { // $rootStructure is created in edit_structure_inc.php $_REQUEST['root_structure_id'] = !empty($rootStructure->mStructureId) ? $rootStructure->mStructureId : NULL; $galleryStore = new TreasuryGallery(NULL, !empty($_REQUEST['gallery_content_id']) ? $_REQUEST['gallery_content_id'] : NULL); $galleryStore->load(); // pass thumbnail upload on to storage hash if (!empty($_FILES['icon']['tmp_name'])) { $_REQUEST['thumb'] = $_FILES['icon']; } if ($galleryStore->store($_REQUEST)) { bit_redirect($galleryStore->getDisplayUrl() . "&refresh=1"); } else { $feedback['error'] = $galleryStore->mErrors; } } if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'remove_gallery' || !empty($_REQUEST['confirm'])) { if (@BitBase::verifyId($_REQUEST['content_id'])) { if ($_REQUEST['action'] == 'remove_gallery' && !empty($_REQUEST['confirm'])) { if ($gContent->expunge(!empty($_REQUEST['force_item_delete']))) { bit_redirect(TREASURY_PKG_URL); } else { $feedback['error'] = $gContent->mErrors; } } $gBitSystem->setBrowserTitle('Confirm removal of ' . $gContent->mInfo['title']);