Ejemplo n.º 1
0
$gBitSmarty->assignByRef('feedback', $feedback);
$listHash['get_sub_tree'] = TRUE;
$listHash['max_records'] = -1;
$listHash['content_permission'] = 'p_treasury_upload_item';
$galleryList = $gContent->getList($listHash);
$gBitSmarty->assign('galleryList', $galleryList);
// if we have no gallery we can upload our stuff into and we can't create a new one, we can't upload a file
if (empty($galleryList) && !$gBitUser->hasPermission('p_treasury_create_gallery')) {
    $gBitSystem->fatalPermission('p_treasury_upload_item');
}
if (!empty($_REQUEST['content_id'])) {
    $galleryContentIds[] = $_REQUEST['content_id'];
    $gBitSmarty->assign('galleryContentIds', $galleryContentIds);
}
if (!empty($_REQUEST['treasury_store'])) {
    $treasuryItem = new TreasuryItem();
    if ($treasuryItem->batchStore($_REQUEST)) {
        bit_redirect($_REQUEST['redirect']);
    } else {
        vd($treasuryItem->mErrors);
    }
}
if ($gBitSystem->isPackageActive('gigaupload')) {
    gigaupload_smarty_setup(TREASURY_PKG_URL . 'upload.php');
} elseif ($gBitSystem->isFeatureActive('treasury_extended_upload_slots')) {
    $gBitThemes->loadAjax('mochikit');
} else {
    $gBitThemes->loadJavascript(UTIL_PKG_PATH . 'javascript/libs/multifile.js', TRUE);
}
$gContent->invokeServices('content_edit_function');
$gBitSmarty->assign('feedback', !empty($feedback) ? $feedback : NULL);
Ejemplo n.º 2
0
 /**
  * Returns HTML link to display a gallery or item
  *
  * @param string $pTitle Title of the file we want to view
  * @param array $pMixed Hash of data used to create link
  * @return Full HTML link to file
  **/
 function getDisplayLink($pTitle = NULL, $pMixed = NULL, $pStructureId = NULL)
 {
     global $gBitSystem;
     if (empty($pTitle) && !empty($this)) {
         $pTitle = $this->getTitle();
     }
     if (empty($pMixed) && !empty($this)) {
         $pMixed = $this->mInfo;
     }
     $ret = $pTitle;
     if (!empty($pTitle) && !empty($pMixed)) {
         if ($gBitSystem->isPackageActive('treasury')) {
             $ret = '<a title="' . htmlspecialchars($pTitle) . '" href="' . TreasuryItem::getDisplayUrlFromHash($pMixed['content_id'], $pMixed, $pStructureId) . '">' . htmlspecialchars($pTitle) . '</a>';
         }
     }
     return $ret;
 }
Ejemplo n.º 3
0
function data_file($pData, $pParams)
{
    global $gBitSystem, $gBitSmarty;
    $ret = ' ';
    if (@BitBase::verifyId($pParams['id']) && $gBitSystem->isPackageActive('treasury')) {
        require_once TREASURY_PKG_PATH . 'TreasuryItem.php';
        $gBitSmarty->loadPlugin('smarty_modifier_display_bytes');
        $item = new TreasuryItem();
        $item->mContentId = $item->getContentIdFromAttachmentId($pParams['id']);
        if ($item->load()) {
            // insert source url if we need the original file
            if (!empty($pParams['size']) && $pParams['size'] == 'original') {
                $thumburl = $item->getField('source_url');
            } elseif ($item->getField('thumbnail_url')) {
                $thumburl = !empty($pParams['size']) && !empty($item->mInfo['thumbnail_url'][$pParams['size']]) ? $item->mInfo['thumbnail_url'][$pParams['size']] : $item->mInfo['thumbnail_url']['medium'];
            }
            // check if we have a valid thumbnail
            if (!empty($thumburl)) {
                $wrapper = liberty_plugins_wrapper_style($pParams);
                $description = !empty($wrapper['description']) ? $wrapper['description'] : $item->getField('data', tra('Image'));
                // set up image first
                $ret = '<img' . ' alt="' . $description . '"' . ' title="' . $description . '"' . ' src="' . $thumburl . '"' . ' />';
                if ($item->getField('file_size')) {
                    $ret .= '<br />' . $item->getField('title') . "<br /><small>(" . $item->getField('mime_type') . " " . smarty_modifier_display_bytes($item->getField('file_size')) . ")</small>";
                }
                if (!empty($description) && !empty($pParams['output']) && ($pParams['output'] == 'desc' || $pParams['output'] == 'description')) {
                    $ret = $description;
                    $nowrapper = TRUE;
                } else {
                    $ret .= !empty($wrapper['description']) ? '<br />' . $wrapper['description'] : '';
                }
                // use specified link as href. insert default link to source only when
                // source not already displayed
                if (!empty($pParams['link']) && $pParams['link'] == 'false') {
                } elseif (!empty($pParams['link'])) {
                    if (strstr($pParams['link'], $_SERVER["SERVER_NAME"]) || !strstr($pParams['link'], '//')) {
                        $class = '';
                    } else {
                        $class = 'class="external"';
                    }
                    $ret = '<a ' . $class . ' href="' . trim($pParams['link']) . '">' . $ret . '</a>';
                } elseif (empty($pParams['download']) && $item->getField('display_url')) {
                    $ret = '<a href="' . trim($item->getField('display_url')) . '">' . $ret . '</a>';
                } elseif (!empty($pParams['download']) && ($pParams['download'] = 'direct')) {
                    $ret = '<a href="' . trim($item->getField('source_url')) . '">' . $ret . '</a>';
                } elseif (!empty($pParams['download']) && $item->getField('download_url')) {
                    $ret = '<a href="' . trim($item->getField('download_url')) . '">' . $ret . '</a>';
                } elseif (empty($pParams['size']) || $pParams['size'] != 'original') {
                    $ret = '<a href="' . trim($item->getField('source_url')) . '">' . $ret . '</a>';
                }
                // finally, wrap the output.
                if (empty($nowrapper)) {
                    $ret = '<!-- ~np~ --><' . $wrapper['wrapper'] . ' class="' . (isset($wrapper) && !empty($wrapper['class']) ? $wrapper['class'] : "att-plugin") . '" style="' . $wrapper['style'] . '">' . $ret . '</' . $wrapper['wrapper'] . '><!-- ~/np~ -->';
                }
            } else {
                $ret = tra("There was a problem getting an image for the file.");
            }
        } else {
            $ret = tra("The attachment id given is not valid.");
        }
    } else {
        $ret = tra("The attachment id given is not valid.");
    }
    return $ret;
}
Ejemplo n.º 4
0
<?php

/**
 * @version      $Header$
 *
 * @author       xing  <*****@*****.**>
 * @package      treasury
 * @copyright    2003-2006 bitweaver
 * @license      LGPL {@link http://www.gnu.org/licenses/lgpl.html}
 **/
/**
 * Setup
 */
global $gContent;
if (!@BitBase::verifyId($_REQUEST['content_id'])) {
    header("Location:" . TREASURY_PKG_URL);
} else {
    $gContent = new TreasuryItem(NULL, $_REQUEST['content_id']);
    $gContent->load($_REQUEST);
}
$gBitSmarty->assignByRef('gContent', $gContent);
Ejemplo n.º 5
0
 /**
  * expunge a gallery
  *
  * @param array $pParamHash
  * @access public
  * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
  */
 function expunge($pForceDeleteItems = FALSE)
 {
     $ret = FALSE;
     if ($this->isValid()) {
         $this->mDb->StartTrans();
         // get all items that are part of the sub tree
         require_once LIBERTY_PKG_PATH . 'LibertyStructure.php';
         $struct = new LibertyStructure();
         $tree = $struct->getSubTree($this->mStructureId);
         // include the current id as well - needed when there are no sub-galleries
         $galleryContentIds[] = $this->mContentId;
         foreach ($tree as $node) {
             $galleryContentIds[] = $node['content_id'];
         }
         $galleryContentIds = array_unique($galleryContentIds);
         // Create Item Object
         require_once TREASURY_PKG_PATH . 'TreasuryItem.php';
         $itemObject = new TreasuryItem();
         // Go through all galleries we want to remove
         foreach ($galleryContentIds as $gid) {
             // make sure the gallery is fully loaded
             $this->mContentId = $gid;
             $this->load();
             $itemContentIds = $this->mDb->getCol("SELECT `item_content_id` FROM `" . BIT_DB_PREFIX . "treasury_map` WHERE `gallery_content_id`=?", array($gid));
             $itemContentIds = array_unique($itemContentIds);
             // Delete items in galleries
             foreach ($itemContentIds as $iid) {
                 if ($pForceDeleteItems) {
                     // Remove item even if it exists in other galleries
                     $count = 1;
                 } else {
                     // Only delete item if it doesn't exist in other galleries
                     $count = $this->mDb->getOne("SELECT COUNT( `item_content_id` ) FROM `" . BIT_DB_PREFIX . "treasury_map` WHERE `item_content_id`=?", array($iid));
                 }
                 // Only delete item if it doesn't exist in other galleries
                 if ($count == 1) {
                     $itemObject->mContentId = $iid;
                     $itemObject->load();
                     if (!$itemObject->expunge()) {
                         $this->mErrors['expunge'][] = $itemObject->mErrors;
                     }
                 }
             }
             // Next, we remove any icons if they exist
             if ($thumbdir = $this->getGalleryThumbBaseUrl()) {
                 @unlink_r(BIT_ROOT_PATH . $thumbdir);
             }
             // Now that all the items are gone, we can start nuking gallery entries
             // remove gallery preferences
             $query = "DELETE FROM `" . BIT_DB_PREFIX . "liberty_content_prefs` WHERE `content_id`=?";
             $result = $this->mDb->query($query, array($this->mContentId));
             // Remove map entries
             $sql = "DELETE FROM `" . BIT_DB_PREFIX . "treasury_map` WHERE `gallery_content_id`=?";
             $rs = $this->mDb->query($sql, array($gid));
             // Remove gallery entry
             $sql = "DELETE FROM `" . BIT_DB_PREFIX . "treasury_gallery` WHERE `content_id`=?";
             $rs = $this->mDb->query($sql, array($gid));
             // Let liberty remove all the content entries for this gallery
             if (!LibertyContent::expunge()) {
                 $errors = TRUE;
             }
             // Finally nuke the structure in liberty_structures
             $struct->removeStructureNode($this->mStructureId, FALSE);
         }
         if (empty($errors)) {
             $this->mDb->CompleteTrans();
             $ret = TRUE;
         } else {
             $this->mDb->RollbackTrans();
             $ret = FALSE;
         }
     }
     return $ret;
 }
Ejemplo n.º 6
0
                if ($galleryItem = $gLibertySystem->getLibertyObject($contentId)) {
                    $galleryItem->load();
                    $title = $galleryItem->getTitle();
                    if ($galleryItem->expunge()) {
                        $feedback['success'] .= "<li>{$title}</li>";
                    }
                }
            }
        }
        if (!empty($feedback['success'])) {
            $feedback['success'] = tra('The following items were successfully deleted') . ':<ul>' . $feedback['success'] . '</ul>';
        }
    } else {
        $gBitSystem->setBrowserTitle('Confirm removal of ' . $gContent->mInfo['title']);
        foreach ($_REQUEST['del_content_ids'] as $cid) {
            $item = new TreasuryItem(NULL, $cid);
            $itemInfo = $item->load();
            $formHash['input'][] = '<input type="hidden" name="del_content_ids[]" value="' . $cid . '"/>' . "<strong>{$item->mInfo['title']}</strong> - {$item->mInfo['mime_type']} - {$item->mInfo['file_size']} bytes";
        }
        $formHash['action'] = 'remove';
        $formHash['structure_id'] = $_REQUEST['structure_id'];
        $msgHash = array('label' => tra('Remove Files'), 'warning' => tra('This will permanently remove these files.'));
        $gBitSystem->confirmDialog($formHash, $msgHash);
    }
}
// used to display the newly updated version of an image
if (!empty($_REQUEST['refresh'])) {
    $gBitSmarty->assign('refresh', '?refresh=' . time());
}
// services
$displayHash = array('perm_name' => 'p_treasury_view_gallery');
Ejemplo n.º 7
0
<?php

global $gQueryUser, $moduleParams;
require_once TREASURY_PKG_PATH . 'TreasuryItem.php';
$ti = new TreasuryItem();
$listHash = $_REQUEST;
if (!empty($moduleParams['module_rows'])) {
    $listHash['max_records'] = $moduleParams['module_rows'];
}
if (empty($listHash['sort_mode'])) {
    $listHash['sort_mode'] = 'random';
}
/* Get a list of user items */
if (!empty($gQueryUser) && $gQueryUser->mUserId) {
    $listHash['user_id'] = $gQueryUser->mUserId;
}
$centerItemList = $ti->getList($listHash);
$gBitSmarty->assign('centerItemList', $centerItemList);
$gBitSmarty->assign('treasury_center_params', $moduleParams['module_params']);
Ejemplo n.º 8
0
// check permission to view treasury item
if (!$gBitUser->hasPermission('p_treasury_view_item')) {
    require_once RSS_PKG_PATH . "rss_error.php";
} else {
    $listHash = array('max_records' => $gBitSystem->getConfig('treasury_rss_max_records', 10), 'sort_mode' => 'last_modified_desc', 'gallery_content_id' => !empty($_REQUEST['gallery_content_id']) ? $_REQUEST['gallery_content_id'] : NULL, 'user_id' => !empty($_REQUEST['user_id']) ? $_REQUEST['user_id'] : NULL);
    // check if we want to use the cache file
    // we'll use groups to cache rss feeds with different permissions
    $cacheFile = TEMP_PKG_PATH . RSS_PKG_NAME . '/' . TREASURY_PKG_NAME . '/' . "g{$listHash['gallery_content_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_content_id'])) {
        $gallery = new TreasuryGallery(NULL, $_REQUEST['gallery_content_id']);
        $gallery->load();
        $rss->title .= " - {$gallery->getTitle()}";
    }
    $treasury = new TreasuryItem();
    $feeds = $treasury->getList($listHash);
    // set the rss link
    $rss->link = TREASURY_PKG_URI;
    $gBitSmarty->loadPlugin('smarty_modifier_display_bytes');
    // get all the data ready for the feed creator
    foreach ($feeds as $feed) {
        $item = new FeedItem();
        $item->title = $feed->getTitle();
        $item->link = $feed->getField('display_url');
        $item->date = (int) $feed->getField('last_modified');
        $item->source = BIT_ROOT_URI;
        if (!empty($feed->mInfo['thumbnail_url']['medium'])) {
            $item->description = '<a href="' . $feed->getField('display_url') . '"><img src="' . $feed->mInfo['thumbnail_url']['medium'] . '" /></a>';
        }
        $item->description .= "<ul>";
Ejemplo n.º 9
0
<?php

/**
 * @version $Header$
 * @package fisheye
 * @subpackage modules
 */
global $gQueryUserId, $gContent;
/**
 * required setup
 */
require_once TREASURY_PKG_PATH . 'TreasuryItem.php';
// this has the stuff we need from the form
extract($moduleParams);
$item = new TreasuryItem();
$display = TRUE;
$listHash =& $module_params;
$listHash['gallery_content_id'] = !empty($module_params['content_id']) ? $module_params['content_id'] : NULL;
$listHash['max_records'] = $module_rows;
if ($gQueryUserId) {
    $listHash['user_id'] = $gQueryUserId;
} elseif (!empty($_REQUEST['user_id'])) {
    $listHash['user_id'] = $_REQUEST['user_id'];
} elseif (!empty($module_params['recent_users'])) {
    $listHash['recent_users'] = TRUE;
}
// this is needed to avoid wrong sort_modes entered resulting in db errors
$sort_options = array('hits', 'created', 'last_modified');
if (!empty($module_params['sort_mode']) && in_array($module_params['sort_mode'], $sort_options)) {
    $sort_mode = $module_params['sort_mode'] . '_desc';
} else {