function fisheye_expunge_user($pObject) { global $gBitDb; if (!empty($pObject->mUserId)) { $query = "SELECT fg.`content_id` FROM `" . BIT_DB_PREFIX . "fisheye_gallery` fg INNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON(fg.`content_id`=lc.`content_id`) WHERE lc.`user_id`=?"; if ($galleries = $gBitDb->getCol($query, array($pObject->mUserId))) { foreach ($galleries as $contentId) { $delGallery = new FisheyeGallery(NULL, $contentId); if ($delGallery->load()) { $delGallery->expunge(TRUE); } } } } }
} elseif (empty($_REQUEST['confirm'])) { $formHash['delete'] = TRUE; $formHash['image_id'] = $gContent->mImageId; $gBitSystem->confirmDialog($formHash, array('warning' => tra('Are you sure you want to delete this image?') . ' (' . $gContent->getTitle() . ') ' . tra('It will be removed from all galleries to which it belongs.'), 'error' => tra('This cannot be undone!'))); } else { if ($gContent->expunge()) { $url = is_object($gGallery) ? $gGallery->getDisplayUrl() : FISHEYE_PKG_URL; header("Location: {$url}"); } } } $errors = $gContent->mErrors; $gBitSmarty->assignByRef('errors', $errors); $gContent->loadParentGalleries(); // Get a list of all existing galleries $gFisheyeGallery = new FisheyeGallery(); $getHash = array('user_id' => $gBitUser->mUserId); if ($gContent->mContentId) { $getHash['contain_item'] = $gContent->mContentId; } // modify listHash according to global preferences if ($gBitSystem->isFeatureActive('fisheye_show_all_to_admins') && $gBitUser->hasPermission('p_fisheye_admin')) { unset($getHash['user_id']); } elseif ($gBitSystem->isFeatureActive('fisheye_show_public_on_upload')) { // $getHash['show_public'] = TRUE; } $galleryTree = $gFisheyeGallery->generateList($getHash, array('name' => "gallery_id", 'id' => "gallerylist", 'item_attributes' => array('class' => 'listingtitle'), 'radio_checkbox' => TRUE), true); $gBitSmarty->assignByRef('galleryTree', $galleryTree); $gBitSmarty->assign('requested_gallery', !empty($_REQUEST['gallery_id']) ? $_REQUEST['gallery_id'] : NULL); $gContent->invokeServices('content_edit_function'); if (!empty($_REQUEST['ajax'])) {
//This holds the checkbox options for what to display on the 'list galleries' page $formGalleryGeneral = array("fisheye_menu_text" => array('label' => 'Menu Text', 'note' => '', 'type' => 'text'), "liberty_offline_thumbnailer" => array('label' => 'Background Thumbnailer', 'note' => 'Thumbnails will be queued and regenerated by a background command-line script. For more information, see ' . FISHEYE_PKG_PATH . 'thumbaniler.php or you can <a href="' . FISHEYE_PKG_URL . 'thumbnailer.php">run it manually</a>', 'type' => 'checkbox'), "fisheye_show_public_on_upload" => array('label' => 'Show Public Galleries on Upload', 'note' => 'Enable this if you want to have all public galleries visible when uploading files. This might cause problems on large sites with many public galleries.', 'type' => 'checkbox'), "fisheye_show_all_to_admins" => array('label' => 'Show all Galleries to Administrators', 'note' => 'This will allow gallery admins to upload and move around images in all galleries. This might cause problems on large sites with many galleries.', 'type' => 'checkbox')); if (!$gBitSystem->isPackageActive('gigaupload')) { $formGalleryGeneral["fisheye_extended_upload_slots"] = array('label' => 'Extended Upload Slots', 'note' => 'When you enable this, users can enter the title and description of the file when uploading them.', 'type' => 'checkbox'); } $gBitSmarty->assign('formGalleryGeneral', $formGalleryGeneral); $formGalleryListLists = array("fisheye_list_title" => array('label' => 'Gallery title', 'note' => 'List the title of the gallery.'), "fisheye_list_thumbnail" => array('label' => 'Thumbnail', 'note' => 'Display a small thumbnail associated with a gallery'), "fisheye_list_description" => array('label' => 'Description', 'note' => 'List the description of a gallery'), "fisheye_list_user" => array('label' => 'Creator', 'note' => 'List the name of the user who created the gallery'), "fisheye_list_hits" => array('label' => 'Hits', 'note' => 'List number of hits this gallery has receieved'), "fisheye_list_created" => array('label' => 'Creation date', 'note' => 'List the creation date of the gallery'), "fisheye_list_lastmodif" => array('label' => 'Last modification', 'note' => 'List date this gallery was last modified')); $gBitSmarty->assign('formGalleryListLists', $formGalleryListLists); // This holds the checkbox options for what to display on a 'view gallery' page $formGalleryLists = array("fisheye_gallery_list_title" => array('label' => 'Gallery title', 'note' => 'When viewing a gallery, display the title of the gallery'), "fisheye_gallery_list_description" => array('label' => 'Gallery description', 'note' => 'When viewing a gallery, display the description of the gallery below the title'), "fisheye_gallery_list_image_titles" => array('label' => 'Image titles', 'note' => 'Show image titles underneath each thumbnail'), "fisheye_gallery_hide_modules" => array('label' => 'Hide modules for galleries', 'note' => 'When viewing a gallery, hide the left and right module columns'), "fisheye_gallery_list_image_descriptions" => array('label' => 'Image description', 'note' => 'Show image descriptions underneath each thumbnail'), "fisheye_gallery_div_layout" => array('label' => '<div> based Layout', 'note' => 'You can use a <div> based layout, which will adjust the number of images in each row to the width of the browser. Please visit the online help for more information.', 'page' => 'FisheyePackage')); $gBitSmarty->assign('formGalleryLists', $formGalleryLists); // This holds the checkbox options for what to display on an 'image details' page $formImageLists = array("fisheye_image_list_title" => array('label' => 'Image title', 'note' => 'When viewing an image, display the title of the image'), "fisheye_image_list_description" => array('label' => 'Image description', 'note' => 'When viewing an image, display the description of the image below the title'), "fisheye_image_hide_modules" => array('label' => 'Hide modules for images', 'note' => 'When viewing an image, hide the left and right module columns'), "gallerybar_use_icons" => array('label' => 'Use icons in the gallery bar', 'note' => 'When viewing an image, show <strong>previous</strong> and <strong>next</strong> links as images instead of words'), "gallery_bar_use_thumbnails" => array('label' => 'Use Thumbnails in gallery bar', 'note' => 'When viewing an image, show previous and next <strong>thumbnails</strong> with the appropriate links.')); $gBitSmarty->assign('formImageLists', $formImageLists); require_once FISHEYE_PKG_PATH . 'FisheyeGallery.php'; $gBitSmarty->assign('galleryPaginationTypes', FisheyeGallery::getAllLayouts()); $sortOptions = array('' => tra('None'), 'lc.title_desc' => tra('Image Title') . ' - ' . tra('descending'), 'lc.title_asc' => tra('Image Title') . ' - ' . tra('ascending'), 'lc.created_desc' => tra('Date Uploaded') . ' - ' . tra('descending'), 'lc.created_asc' => tra('Date Uploaded') . ' - ' . tra('ascending'), 'lc.last_modified_desc' => tra('Last Modified') . ' - ' . tra('descending'), 'lc.last_modified_asc' => tra('Last Modified') . ' - ' . tra('ascending')); $gBitSmarty->assign('sortOptions', $sortOptions); $gBitSmarty->assign('imageSizes', get_image_size_options(FALSE)); //vd($_REQUEST); if (!empty($_REQUEST['fisheyeAdminSubmit'])) { // General Settings foreach ($formGalleryGeneral as $item => $data) { if ($data['type'] == 'checkbox') { simple_set_toggle($item, FISHEYE_PKG_NAME); } else { $gBitSystem->storeConfig($item, $_REQUEST[$item], FISHEYE_PKG_NAME); } } // Gallery List Display Settings foreach ($formGalleryListLists as $item => $data) {
$gBitSystem->verifyFeature('fisheye_rss'); require_once FISHEYE_PKG_PATH . "FisheyeImage.php"; require_once RSS_PKG_PATH . "rss_inc.php"; $rss->title = $gBitSystem->getConfig('fisheye_rss_title', $gBitSystem->getConfig('site_title') . ' - ' . tra('Image Galleries')); $rss->description = $gBitSystem->getConfig('fisheye_rss_description', $gBitSystem->getConfig('site_title') . ' - ' . tra('RSS Feed')); // check permission to view fisheye images if (!$gBitUser->hasPermission('p_fisheye_view')) { require_once RSS_PKG_PATH . "rss_error.php"; } else { $listHash = array('max_records' => $gBitSystem->getConfig('fisheye_rss_max_records', 10), 'sort_mode' => 'last_modified_desc', 'gallery_id' => !empty($_REQUEST['gallery_id']) ? $_REQUEST['gallery_id'] : NULL, 'user_id' => !empty($_REQUEST['user_id']) ? $_REQUEST['user_id'] : NULL); // check if we want to use the cache file $cacheFile = TEMP_PKG_PATH . RSS_PKG_NAME . '/' . FISHEYE_PKG_NAME . '/' . "g{$listHash['gallery_id']}u{$listHash['user_id']}" . $cacheFileTail; $rss->useCached($rss_version_name, $cacheFile, $gBitSystem->getConfig('rssfeed_cache_time')); // if we have a gallery we can work with - load it if (@BitBase::verifyId($_REQUEST['gallery_id'])) { $gallery = new FisheyeGallery($_REQUEST['gallery_id']); $gallery->load(); $rss->title .= " - {$gallery->getTitle()}"; } $fisheye = new FisheyeImage(); $feeds = $fisheye->getList($listHash); // set the rss link $rss->link = 'http://' . $_SERVER['HTTP_HOST'] . FISHEYE_PKG_URL; global $gBitSystem; // get all the data ready for the feed creator foreach ($feeds as $feed) { $item = new FeedItem(); $item->title = $feed['title']; $item->link = $feed['display_url']; $item->description = '<a href="' . $feed['display_url'] . '"><img src="' . $feed['thumbnail_url'] . '" /></a>'; $item->description .= '<p>' . $feed['data'] . '</p>';
<?php /** * @package fisheye * @subpackage functions */ global $gContent; $lookup = array(); if (!($gContent = FisheyeGallery::lookup($_REQUEST))) { $gContent = new FisheyeGallery(); $galleryId = NULL; } if (!empty($_REQUEST['gallery_path'])) { $gContent->setGalleryPath($_REQUEST['gallery_path']); } elseif ($gContent->isValid() && ($parents = $gContent->getParentGalleries())) { $gal = current($parents); $gContent->setGalleryPath('/' . $gal['gallery_id']); } $gBitSmarty->assignByRef('gContent', $gContent); $gBitSmarty->assignByRef('galleryId', $gContent->mGalleryId);
<?php /** * @version $Header$ * @package fisheye * @subpackage functions */ /** * required setup */ require_once '../kernel/setup_inc.php'; require_once FISHEYE_PKG_PATH . 'FisheyeGallery.php'; global $gBitSystem, $gBitSmarty, $gFisheyeGallery; //$gBitSystem->verifyPermission( 'p_fisheye_list_galleries' ); $gFisheyeGallery = new FisheyeGallery(); /* Get a list of galleries which matches the input parameters (default is to list every gallery in the system) */ $_REQUEST['root_only'] = TRUE; /* Process the input parameters this page accepts */ if (!empty($_REQUEST['user_id']) && is_numeric($_REQUEST['user_id'])) { if ($_REQUEST['user_id'] == $gBitUser->mUserId) { $_REQUEST['show_empty'] = TRUE; } $gBitSmarty->assignByRef('gQueryUserId', $_REQUEST['user_id']); $template = 'user_galleries.tpl'; } else { $template = 'list_galleries.tpl'; } $_REQUEST['thumbnail_size'] = $gBitSystem->getConfig('fisheye_list_thumbnail_size', 'small'); $galleryList = $gFisheyeGallery->getList($_REQUEST); $gFisheyeGallery->invokeServices('content_list_function', $_REQUEST); // Pagination Data
function addToGalleries($pGalleryArray) { global $gBitSystem; if ($this->isValid()) { $inGalleries = $this->mDb->getAssoc("SELECT `gallery_id`,`gallery_content_id` FROM `" . BIT_DB_PREFIX . "fisheye_gallery_image_map` fgim INNER JOIN `" . BIT_DB_PREFIX . "fisheye_gallery` fg ON (fgim.`gallery_content_id`=fg.`content_id`) WHERE `item_content_id` = ?", array($this->mContentId)); $galleries = array(); if (count($pGalleryArray)) { foreach ($pGalleryArray as $galleryId) { // image has been requested to be put in a new gallery if (empty($inGalleries[$galleryId])) { if (empty($galleries[$galleryId])) { $galleries[$galleryId] = FisheyeGallery::lookup(array('gallery_id' => $galleryId)); $galleries[$galleryId]->load(); } if ($galleries[$galleryId]->isValid()) { if ($galleries[$galleryId]->hasUserPermission('p_fisheye_upload', TRUE, FALSE) || $galleries[$galleryId]->isPublic()) { if ($gBitSystem->isFeatureActive('fisheye_gallery_default_sort_mode')) { $pos = NULL; } else { $query = "SELECT MAX(`item_position`)\n\t\t\t\t\t\t\t\t\t\t\t FROM `" . BIT_DB_PREFIX . "fisheye_gallery_image_map` fgim\n\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "fisheye_gallery` fg ON(fgim.`gallery_content_id`=fg.`content_id`)\n\t\t\t\t\t\t\t\t\t\t\t WHERE fg.`gallery_id`=?"; $pos = $this->mDb->getOne($query, array($galleryId)) + 10; } $galleries[$galleryId]->addItem($this->mContentId, $pos); } else { $this->mErrors[] = "You do not have permission to attach " . $this->getTitle() . " to " . $galleries[$galleryId]->getTitle(); } } } else { // image already in an existing gallery. unset($inGalleries[$galleryId]); } } } if (count($inGalleries)) { // if we have any left over in the inGalleries array, we should delete them. these were the "unchecked" boxes foreach ($inGalleries as $galleryId) { $sql = "DELETE FROM `" . BIT_DB_PREFIX . "fisheye_gallery_image_map` WHERE `gallery_content_id` = ? AND `item_content_id` = ?"; $rs = $this->mDb->query($sql, array($galleryId, $this->mContentId)); } } } }
/** * This is not in use yet. would be good if this could be updated directly from the db */ function getGalleryListMenu($pParentId = NULL) { global $gBitSystem, $gFisheyeGallery; require_once FISHEYE_PKG_PATH . 'FisheyeGallery.php'; $gFisheyeGallery = new FisheyeGallery(); $hash['root_only'] = TRUE; $hash['get_thumbnails'] = FALSE; $galleryList = $gFisheyeGallery->getList($hash); foreach ($galleryList as $key => $gal) { $itemHash['item_id'] = 'gl' . $key; $itemHash['parent_id'] = $pParentId; $itemHash['title'] = $gal['title']; $itemHash['rsrc'] = $gal['content_id']; $itemHash['rsrc_type'] = 'content_id'; $ret['gl' . $key] = $itemHash; } return $ret; }
function cmdNewAlbum($pParamHash) { global $gBitUser; $response = array(); if (empty($pParamHash['newAlbumTitle'])) { $pParamHash['newAlbumTitle'] = $gBitUser->getTitle() . "'s Gallery"; } $storeHash['title'] = !empty($pParamHash['newAlbumTitle']) ? $pParamHash['newAlbumTitle'] : ''; $storeHash['edit'] = !empty($pParamHash['newAlbumDesc']) ? $pParamHash['newAlbumDesc'] : ''; $gallery = new FisheyeGallery(); $gallery->store($storeHash); if ($pParamHash['set_albumName']) { $parentGallery = new FisheyeGallery(); if ($parentGallery = $parentGallery->lookup(array('content_id' => $pParamHash['set_albumName']))) { $parentGallery->load(); $gallery->addToGalleries(array($parentGallery->mGalleryId)); } } $response = $this->createResponse(FEG2REMOTE_SUCCESS, 'Gallery created', array('album_name' => $storeHash['title'])); return $response; }
<?php global $gQueryUser; if (!empty($moduleParams)) { extract($moduleParams); } $gFisheyeGallery = new FisheyeGallery(); /* Get a list of galleries which matches the imput paramters (default is to list every gallery in the system) */ $listHash['root_only'] = TRUE; $listHash['get_thumbnails'] = TRUE; /* Not supported in FisheyeGallery::getList if( !empty( $module_params['gallery_id'] ) && is_numeric( $module_params['gallery_id'] ) ) { $listHash['gallery_id'] = $module_params['gallery_id']; }*/ if ($gQueryUserId) { $listHash['user_id'] = $gQueryUserId; } elseif (!empty($module_params['user_id']) && BitBase::verifyId($module_params['user_id'])) { $listHash['user_id'] = $module_params['user_id']; } if (!empty($module_params['contain_item']) && BitBase::verifyId($module_params['contain_item'])) { $listHash['contain_item'] = $module_params['contain_item']; } if (!empty($module_params['sort_mode'])) { $listHash['sort_mode'] = $module_params['sort_mode']; } else { $listHash['sort_mode'] = 'created_desc'; } if (!empty($module_params['nav_bar'])) { $gBitSmarty->assign('navBar', $module_params['nav_bar']); } else { $gBitSmarty->assign('navBar', true);
global $gContent, $gGallery; if ($gContent = FisheyeImage::lookup($_REQUEST)) { // nothing to do. ::lookup will do a full load } else { $gContent = new FisheyeImage(); $imageId = NULL; } if (!empty($_REQUEST['gallery_path'])) { $_REQUEST['gallery_path'] = rtrim($_REQUEST['gallery_path'], '/'); $gContent->setGalleryPath($_REQUEST['gallery_path']); $matches = array(); $tail = strrpos($_REQUEST['gallery_path'], '/'); $_REQUEST['gallery_id'] = substr($_REQUEST['gallery_path'], $tail + 1); } if (empty($_REQUEST['gallery_id'])) { if ($parents = $gContent->getParentGalleries()) { $gal = current($parents); $gContent->setGalleryPath('/' . $gal['gallery_id']); $_REQUEST['gallery_id'] = $gal['gallery_id']; } } // the image is considered the primary content, however the gallery is useful if (!empty($_REQUEST['gallery_id']) && is_numeric($_REQUEST['gallery_id'])) { $gGallery = FisheyeGallery::lookup($_REQUEST); $gBitSmarty->assignByRef('gGallery', $gGallery); $gBitSmarty->assignByRef('galleryId', $_REQUEST['gallery_id']); } // This user does not own this gallery and they have not been granted the permission to edit this gallery $gContent->verifyViewPermission(); $gBitSmarty->assignByRef('gContent', $gContent); $gBitSmarty->assignByRef('imageId', $gContent->mImageId);
function generateMenuOptions(&$pHash, $pOptions, $pLocate, $pPrefix = '') { $ret = ''; foreach (array_keys($pHash) as $conId) { $ret .= '<option gallery_id="' . $pHash[$conId]['content']['gallery_id'] . '" value="' . $pHash[$conId]['content']['gallery_id'] . '"'; if (!empty($pOptions['item_attributes'])) { foreach ($pOptions['item_attributes'] as $key => $value) { $ret .= " {$key}=\"{$value}\" "; } } if ($pLocate && $pLocate == $pHash[$conId]['content']['gallery_id']) { $ret .= ' selected="selected" '; } $ret .= ' >' . ($pPrefix ? $pPrefix . '» ' : '') . htmlspecialchars($pHash[$conId]['content']['title']) . '</option>'; if (!empty($pHash[$conId]['children'])) { $ret .= FisheyeGallery::generateMenuOptions($pHash[$conId]['children'], $pOptions, $pLocate, $pPrefix . '-'); } } return $ret; }
function fisheye_process_ftp_directory($pProcessDir) { global $gBitSystem, $gBitUser; if (empty($_REQUEST['gallery_additions'])) { $_REQUEST['gallery_additions'] = array(); } $errors = array(); if ($archiveDir = opendir($pProcessDir)) { $order = 100; while ($fileName = readdir($archiveDir)) { $sortedNames[] = $fileName; } sort($sortedNames); $order = 100; foreach ($sortedNames as $fileName) { if (!preg_match('/^\\./', $fileName) && $fileName != 'Thumbs.db') { $scanFile = array('type' => $gBitSystem->lookupMimeType(substr($fileName, strrpos($fileName, '.') + 1)), 'name' => $fileName, 'size' => filesize("{$pProcessDir}/{$fileName}"), 'tmp_name' => "{$pProcessDir}/{$fileName}"); if (is_dir($pProcessDir . '/' . $fileName)) { // create a new gallery from directory $dirGallery = new FisheyeGallery(); $galleryHash = array('title' => str_replace('_', ' ', $fileName)); if ($dirGallery->store($galleryHash)) { $dirGallery->addToGalleries($_REQUEST['gallery_additions']); $errors = array_merge($errors, fisheye_process_directory($pProcessDir . '/' . $fileName, $dirGallery)); } else { $errors = array_merge($errors, array_values($dirGallery->mErrors)); } unset($dirGallery); } else { if (preg_match('/(^image|pdf)/i', $scanFile['type'])) { // process image $newImage = new FisheyeImage(); $imageHash = array('upload' => $scanFile); if ($newImage->store($imageHash)) { $newImage->addToGalleries($_REQUEST['gallery_additions']); // if we have a gallery to add these images to, load one of them if (!empty($_REQUEST['gallery_additions'][0]) && @(!is_object($imageGallery))) { $imageGallery = new FisheyeGallery(); $imageGallery->mGalleryId = $_REQUEST['gallery_additions'][0]; $imageGallery->load(); } if (@(!is_object($imageGallery))) { global $gBitUser; $galleryHash = array('title' => $gBitUser->getDisplayName() . "'s Gallery"); $imageGallery = new FisheyeGallery(); if ($imageGallery->store($galleryHash)) { $imageGallery->load(); } else { $errors = array_merge($errors, array_values($imageGallery->mErrors)); } } $imageGallery->addItem($newImage->mContentId); } else { $errors = array_merge($errors, array_values($newImage->mErrors)); } } else { // create a new gallery from archive $archiveGallery = new FisheyeGallery(); $galleryHash = array('title' => substr($fileName, 0, str_replace('_', ' ', strrpos($fileName, '.')))); if (!$archiveGallery->store($galleryHash)) { $errors = array_merge($errors, array_values($archiveGallery->mErrors)); } $errors = fisheye_process_archive($scanFile, $archiveGallery, TRUE); unset($archiveGallery); } } $order += 10; } } } return $errors; }
break; case 'security': $storageHash['security_id'] = $batchParam; $feedback['success'] = tra("Items security assigned"); break; case 'gallerymove': if (empty($destGallery)) { $destGallery = new FisheyeGallery(NULL, $batchParam); $destGallery->load(); } if ($batchParam != $contentId) { $gContent->removeItem($contentId); } 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'];