Пример #1
0
 /**
  * @copydoc DataSet::main
  */
 protected function main()
 {
     $this->setType(self::COMPONENT_TYPE_LIST);
     $this->setBuilder(new SimpleBuilder());
     $dd = $this->createDataDescription();
     if ($dd->isEmpty()) {
         $dd->load(array('smap_id' => array('type' => FieldDescription::FIELD_TYPE_INT, 'key' => true, 'index' => 'PRI'), 'smap_name' => array('type' => FieldDescription::FIELD_TYPE_STRING), 'smap_description_rtf' => array('type' => FieldDescription::FIELD_TYPE_HTML_BLOCK)));
     }
     $this->setDataDescription($dd);
     $d = new Data();
     $query = 'SELECT
     s.smap_id,
     st.smap_name,
     st.smap_description_rtf
     FROM share_sitemap s
     LEFT JOIN share_sitemap_translation st USING (smap_id)
     WHERE (smap_id = %s) AND (lang_id = %s) LIMIT 1';
     $this->js = $this->buildJS();
     $this->addToolbar($this->loadToolbar());
     $this->setData($d);
     $d->load($this->dbh->select($query, $this->document->getID(), $this->document->getLang()));
     //Поле добавлено чтобы Data не был пустым
     $this->getData()->addField(new Field('fake'));
     $m = new AttachmentManager($this->getDataDescription(), $this->getData(), 'share_sitemap', true);
     $m->createFieldDescription();
     $m->createField('smap_id', false, $this->document->getID());
 }
 /**
  * @see Page::readParameters()
  */
 public function readParameters()
 {
     $this->wbbExists = AttachmentManager::wbbExists();
     parent::readParameters();
     if (!WCF::getUser()->userID) {
         require_once WCF_DIR . 'lib/system/exception/PermissionDeniedException.class.php';
         throw new PermissionDeniedException();
     }
     $this->am = new AttachmentManager();
     if (isset($_REQUEST['sortField'])) {
         $this->sortField = $_REQUEST['sortField'];
     }
     if (isset($_REQUEST['sortOrder'])) {
         $this->sortOrder = $_REQUEST['sortOrder'];
     }
     if (isset($_REQUEST['userID'])) {
         $this->userID = $_REQUEST['userID'];
     }
     if (isset($_POST['username'])) {
         $this->username = $_POST['username'];
     }
     if (isset($_REQUEST['showOnlyMessageType'])) {
         $this->showOnlyMessageType = $_REQUEST['showOnlyMessageType'];
     } else {
         if (WCF::getSession()->getVar('showOnlyMessageType')) {
             $this->showOnlyMessageType = WCF::getSession()->getVar('showOnlyMessageType');
         }
     }
     if (isset($_REQUEST['showOnlyFileType'])) {
         $this->showOnlyFileType = $_REQUEST['showOnlyFileType'];
     } else {
         if (WCF::getSession()->getVar('showOnlyFileType')) {
             $this->showOnlyFileType = WCF::getSession()->getVar('showOnlyFileType');
         }
     }
     if (isset($_REQUEST['showOnlyImages'])) {
         $this->showOnlyImages = $_REQUEST['showOnlyImages'];
     } else {
         if (WCF::getSession()->getVar('showOnlyImages')) {
             $this->showOnlyImages = WCF::getSession()->getVar('showOnlyImages');
         }
     }
     if ($this->wbbExists && isset($_REQUEST['showThumbnails'])) {
         $this->showThumbnails = $_REQUEST['showThumbnails'];
     } else {
         if ($this->wbbExists && WCF::getSession()->getVar('showThumbnails')) {
             $this->showThumbnails = WCF::getSession()->getVar('showThumbnails');
         }
     }
     if (isset($_POST['fDo'])) {
         if ($_POST['fDo'] == 'delete' && isset($_POST['delAttachment']) && is_array($_POST['delAttachment'])) {
             WCF::getUser()->checkPermission('admin.general.attachmentManager.canDelete');
             $ret = $this->am->deleteAttachments($this->userID, $_POST['delAttachment']);
             if ($ret['CODE'] == RET_ERROR) {
                 $this->tplError = '<p class="error">' . $ret['MSG'] . '</p>';
             } else {
                 if ($ret['CODE'] == RET_WARNING) {
                     $this->tplWarning = '<p class="warning">' . $ret['MSG'] . '</p>';
                 } else {
                     if ($ret['CODE'] == RET_INFO) {
                         $this->tplInfo = '<p class="success">' . $ret['MSG'] . '</p>';
                     }
                 }
             }
         } else {
             if ($_POST['fDo'] == 'setFilter') {
                 if (empty($_POST['showOnlyImages'])) {
                     $this->showOnlyImages = 0;
                 } else {
                     $this->showOnlyImages = 1;
                 }
                 if (!empty($this->username)) {
                     $tmp = $this->am->getUserByName($this->username);
                     if (!empty($tmp['userID'])) {
                         $this->userID = $tmp['userID'];
                         $this->username = $tmp['username'];
                     } else {
                         $this->userID = 0;
                         $this->username = '';
                     }
                 } else {
                     $this->userID = 0;
                     $this->username = '';
                 }
             } else {
                 if ($_POST['fDo'] == 'switchThumbnails') {
                     if (empty($_POST['showThumbnails'])) {
                         $this->showThumbnails = 0;
                     } else {
                         $this->showThumbnails = 1;
                     }
                 }
             }
         }
     }
     if (!empty($this->userID)) {
         $tmp = $this->am->getUserById($this->userID);
         if (!empty($tmp['userID'])) {
             $this->userID = $tmp['userID'];
             $this->username = $tmp['username'];
         }
     }
 }
Пример #3
0
    exit(0);
} else {
    $userId = $LiveUser->getProperty('auth_user_id');
    $userTmp = new User($userId);
    if (!$userTmp->exists() || !$userTmp->isAdmin()) {
        header("Location: /$ADMIN/login.php");
        exit(0);
    }
    unset($userTmp);
}

require_once('config.inc.php');
require_once($GLOBALS['g_campsiteDir']."/$ADMIN_DIR/lib_campsite.php");
require_once('classes/AttachmentManager.php');

$manager = new AttachmentManager($AMConfig);

$languageSelected = (isset($_REQUEST['language_selected']) && is_numeric($_REQUEST['language_selected']))
    ? $_REQUEST['language_selected'] : null;
$articleId = (isset($_REQUEST['article_id']) && is_numeric($_REQUEST['article_id']))
    ? $_REQUEST['article_id'] : null;

// Get the list of files and directories
$list = array();
if (!is_null($articleId)) {
    $list = $manager->getFiles($articleId, $languageSelected);
}


/**
 * Draw the files in a table.