/** * returns a list of all allowed categories for the current user. * Subcategories are included, categories from "tt_newsPerms.tt_news_cat.excludeList" are excluded * * @return [type] ... */ function getAllowedTreeIDs() { $catlistWhere = tx_ttnews_div::getCatlistWhere(); $treeIDs = array(); $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'tt_news_cat', '1=1' . $catlistWhere . ' AND deleted=0'); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $treeIDs[] = $row['uid']; } $GLOBALS['TYPO3_DB']->sql_free_result($res); return $treeIDs; }
/** * [Describe function...] * * @param [type] $cmd: ... * @return [type] ... */ function renderCatTree($calledFromAjax = false) { // $tStart = microtime(true); // $this->debug['start'] = time(); if (substr($this->table, 0, 3) != 'be_') { // ignore useStoragePid if table is be_user/groups. if ($this->confArr['useStoragePid']) { if ($this->storagePidFromAjax) { $this->storagePid = $this->storagePidFromAjax; } else { $TSconfig = t3lib_BEfunc::getTCEFORM_TSconfig($this->table, $this->row); $this->storagePid = $TSconfig['_STORAGE_PID'] ? $TSconfig['_STORAGE_PID'] : intval($this->row['pid']); } $SPaddWhere = ' AND tt_news_cat.pid IN (' . $this->storagePid . ')'; if ($this->table == 'tt_news_cat' && intval($this->row['pid']) > 0 && $this->row['pid'] != $this->storagePid) { $msg = $this->printMsg('notInGRSP', 'warning2'); $notInGRSP = true; } } $catlistWhere = tx_ttnews_div::getCatlistWhere(); if ($catlistWhere) { $this->getNotAllowedItems($SPaddWhere); } } $treeOrderBy = $this->confArr['treeOrderBy'] ? $this->confArr['treeOrderBy'] : 'uid'; // instantiate tree object $treeViewObj = t3lib_div::makeInstance('tx_ttnews_tceforms_categorytree'); $treeViewObj->treeName = $this->table . '_tree'; $treeViewObj->table = 'tt_news_cat'; $treeViewObj->tceFormsTable = $this->table; $treeViewObj->tceFormsRecID = $this->recID; $treeViewObj->storagePid = $this->storagePid; $treeViewObj->useStoragePid = $this->confArr['useStoragePid']; $treeViewObj->init($SPaddWhere . $catlistWhere, $treeOrderBy); $treeViewObj->backPath = $GLOBALS['BACK_PATH']; $treeViewObj->thisScript = 'class.tx_ttnews_tceformsSelectTree.php'; $treeViewObj->fieldArray = array('uid', 'title', 'description', 'hidden', 'starttime', 'endtime', 'fe_group'); // those fields will be filled to the array $treeViewObj->tree $treeViewObj->parentField = 'parent_category'; $treeViewObj->expandable = $this->useAjax; $treeViewObj->expandAll = !$this->useAjax; $treeViewObj->useAjax = $this->useAjax; $treeViewObj->titleLen = 60; $treeViewObj->disableAll = $notInGRSP; $treeViewObj->ext_IconMode = '1'; // no context menu on icons $treeViewObj->title = $GLOBALS['LANG']->sL('LLL:EXT:tt_news/locallang_tca.xml:tt_news.treeSelect.treeTitle'); $treeViewObj->TCEforms_itemFormElName = $this->PA['itemFormElName']; if ($this->table == 'tt_news_cat') { $treeViewObj->TCEforms_nonSelectableItemsArray[] = $this->row['uid']; } /** * FIXME * making categories not-selectable with tt_newsPerms.tt_news_cat.allowedItems doesn't work anymore */ // if (tx_ttnews_div::useAllowedCategories() && !tx_ttnews_div::allowedItemsFromTreeSelector) { // // 'options.useListOfAllowedItems' is set but no category is selected --> check the 'allowedItems' list // $notAllowedItems = $this->getNotAllowedItems($SPaddWhere); // } // if (is_array($notAllowedItems) && $notAllowedItems[0]) { // foreach ($notAllowedItems as $k) { // $treeViewObj->TCEforms_nonSelectableItemsArray[] = $k; // } // } $sPageIcon = ''; // mark selected categories $treeViewObj->TCEforms_selectedItemsArray = $this->selectedItems; $treeViewObj->selectedItemsArrayParents = $this->getCatRootline($SPaddWhere); if (substr($this->table, 0, 3) == 'be_') { // if table is 'be_users' or 'be_groups' group the categories by folder. 'useStoragePid' is ignored $cf = $this->getCategoryFolders($SPaddWhere . $catlistWhere); /** * FIXME: * currently 'expandFirst' is required to prevent js errors when expanding/collapsing the tree * the problems are caused by multiple "root" records with uid=0 */ $treeViewObj->expandFirst = 1; $treeViewObj->MOUNTS = $cf; $groupByPages = TRUE; } else { if ($this->storagePid > 0) { $addWhere = ' AND pid=' . $this->storagePid; } else { // useStoragePid=0 and table != beusers/groups $addWhere = ''; } // get selected categories from be user/group without subcategories $tmpsc = tx_ttnews_div::getBeUserCatMounts(FALSE); $beUserSelCatArr = t3lib_div::intExplode(',', $tmpsc); $includeListArr = tx_ttnews_div::getIncludeCatArray(); $subcatArr = array_diff($includeListArr, $beUserSelCatArr); // get all selected category records from the current storagePid which are not 'root' categories // and add them as tree mounts. Subcategories of selected categories will be excluded. $cMounts = array(); $nonRootMounts = FALSE; foreach ($beUserSelCatArr as $catID) { $tmpR = t3lib_BEfunc::getRecord('tt_news_cat', $catID, 'parent_category,hidden', $addWhere); if (is_array($tmpR) && !in_array($catID, $subcatArr)) { if ($tmpR['parent_category'] > 0) { $nonRootMounts = TRUE; if (!$calledFromAjax) { $sPageIcon = $this->getStoragePageIcon($treeViewObj); } } $cMounts[] = $catID; } } if ($nonRootMounts) { $treeViewObj->MOUNTS = $cMounts; } } // render tree html $treeContent = $sPageIcon . $treeViewObj->getBrowsableTree($groupByPages); $this->treeObj_ajaxStatus = $treeViewObj->ajaxStatus; // if (count($treeViewObj->ids) == 0) { // $msg .= str_replace('###PID###',$this->storagePid,$this->printMsg('emptyTree','note')); // $treeContent = ''; // } return $msg . $treeContent; }
function initCategories() { if (!$this->isAdmin) { // get include/exclude items if ($excludeList = $GLOBALS['BE_USER']->getTSConfigVal('tt_newsPerms.tt_news_cat.excludeList')) { $this->excludeCats = $this->posIntExplode($excludeList); } $this->includeCats = tx_ttnews_div::getIncludeCatArray(); $this->catlistWhere = tx_ttnews_div::getCatlistWhere(); } }