Ejemplo n.º 1
0
 * @version  $Revision$
 * @package  liberty
 * @subpackage functions
 */
/**
 * bit setup
 */
require_once "../kernel/setup_inc.php";
global $gBitSmarty, $gContent, $gBitUser, $gBitSystem, $gLibertySystem;
// we just want information about a single attachment
if (isset($_REQUEST['attachment_id']) && is_numeric($_REQUEST['attachment_id'])) {
    if (!$gContent) {
        $gContent = new LibertyMime();
    }
    // this is a hack to make it compatible with existing tpls for now
    $attachment = $gContent->getAttachment($_REQUEST['attachment_id']);
    $ret = array();
    $ret[$attachment['attachment_id']] = $attachment;
    $userAttachments = $ret;
    $gContent->mStorage = $userAttachments;
    $gBitSmarty->assign('gContent', $gContent);
} else {
    // we want a list of user attachments
    $listHash = $_REQUEST;
    $listHash = array('page' => @BitBase::verifyId($_REQUEST['pgnPage']) ? $_REQUEST['pgnPage'] : NULL, 'load_attached_to' => true);
    $userAttachments = $gBitUser->getUserAttachments($listHash);
    // Fake the storage assignment for edit_storage_list.tpl
    $gContent->mStorage = $userAttachments;
    $gBitSmarty->assign('gContent', $gContent);
    // pagination
    $offset = @BitBase::verifyId($_REQUEST['offset']) ? $_REQUEST['offset'] : 0;
Ejemplo n.º 2
0
if (@(!BitBase::verifyId($_REQUEST['attachment_id'])) || !($attachment = LibertyMime::getAttachment($_REQUEST['attachment_id'], $_REQUEST))) {
    $gBitSystem->fatalError(tra("The Attachment ID given is not valid"));
}
// first we need to check the permissions of the content the attachment belongs to since they inherit them
if ($gContent = LibertyBase::getLibertyObject($attachment['content_id'])) {
    $gContent->verifyViewPermission();
    if (!empty($_REQUEST['plugin_submit'])) {
        // now that we have data for a plugin, we'll simply feed it back to the update function of that plugin
        $data = !empty($_REQUEST['plugin'][$attachment['attachment_id']][$attachment['attachment_plugin_guid']]) ? $_REQUEST['plugin'][$attachment['attachment_id']][$attachment['attachment_plugin_guid']] : array();
        if ($gContent->updateAttachmentParams($attachment['attachment_id'], $attachment['attachment_plugin_guid'], $data)) {
            $feedback['success'] = tra("The data was successfully updated.");
        } else {
            $feedback['error'] = $gContent->mErrors;
        }
        // reload the attachment
        $attachment = LibertyMime::getAttachment($_REQUEST['attachment_id']);
    }
    // attachment usage filter stuff is hardcoded for now - ugly as hell but we'll survive it as long as there's no demand for more of these.
    if ($gLibertySystem->isPluginActive('filterattachment')) {
        $gBitSmarty->assign('usage', attachment_filter_get_usage($attachment['attachment_id']));
    }
    if (empty($_REQUEST['size'])) {
        $_REQUEST['size'] = 'large';
    }
    $attachment['original'] = $gContent->isOwner($attachment) || $gBitSystem->isFeatureActive('liberty_original_image');
    $gBitSmarty->assign('attachment', $attachment);
    $gBitSmarty->assign('gContent', $gContent);
    $gBitSmarty->assign('feedback', $feedback);
    // what template are we going to use to display this attachment
    $gBitSmarty->assign('view_template', $gLibertySystem->getMimeTemplate('view', $attachment['attachment_plugin_guid']));
    $gBitSmarty->assign('edit_template', $gLibertySystem->getMimeTemplate('edit', $attachment['attachment_plugin_guid']));