/**
  * [Describe function...]
  *
  * @param	[type]		$SPaddWhere: ...
  * @return	[type]		...
  */
 function getNotAllowedItems($SPaddWhere)
 {
     if ($this->row['category']) {
         $treeIDs = tx_ttnews_div::getAllowedTreeIDs();
         if (!$this->row['sys_language_uid'] && !$this->row['l18n_parent']) {
             $catvals = explode(',', $this->row['category']);
             // get categories from the current record
             $notAllowedCats = array();
             foreach ($catvals as $k) {
                 $c = explode('|', $k);
                 if ($c[0] && !in_array($c[0], $treeIDs)) {
                     $notAllowedCats[] = '<p style="padding:0px;color:red;font-weight:bold;">- ' . $c[1] . ' <span class="typo3-dimmed"><em>[' . $c[0] . ']</em></span></p>';
                 }
             }
             if (count($notAllowedCats)) {
                 $this->NA_Items = $this->printError($notAllowedCats, array());
             }
         }
     }
 }
Пример #2
0
 /**
  * initialize category related vars and add subcategories to the category selection
  *
  * @return	void
  */
 function initCategoryVars()
 {
     $storagePid = FALSE;
     if ($this->confArr['useStoragePid']) {
         $sParr = $this->tsfe->getStorageSiterootPids();
         $storagePid = $sParr['_STORAGE_PID'];
     }
     $lc = $this->conf['displayCatMenu.'];
     if ($this->theCode == 'CATMENU') {
         // init catPidList
         $catPl = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'pages', 's_misc');
         $catPl = $catPl ? $catPl : $this->cObj->stdWrap($lc['catPidList'], $lc['catPidList.']);
         $catPl = implode(',', t3lib_div::intExplode(',', $catPl));
         $recursive = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'recursive', 's_misc');
         if (!strcmp($recursive, '') || $recursive === NULL) {
             $recursive = $this->cObj->stdWrap($lc['recursive'], $lc['recursive.']);
         }
         if ($catPl) {
             $storagePid = $this->pi_getPidList($catPl, $recursive);
         }
     }
     if ($storagePid) {
         $this->SPaddWhere = ' AND tt_news_cat.pid IN (' . $storagePid . ')';
     }
     if ($this->conf['catExcludeList']) {
         $this->SPaddWhere .= ' AND tt_news_cat.uid NOT IN (' . $this->conf['catExcludeList'] . ')';
     }
     $this->enableCatFields = $this->getEnableFields('tt_news_cat');
     $addWhere = $this->SPaddWhere . $this->enableCatFields;
     $useSubCategories = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'useSubCategories', 'sDEF');
     $this->config['useSubCategories'] = strcmp($useSubCategories, '') ? $useSubCategories : $this->conf['useSubCategories'];
     // global ordering for categories, Can be overwritten later by catOrderBy for a certain content element
     $catOrderBy = trim($this->conf['catOrderBy']);
     $this->config['catOrderBy'] = $catOrderBy ? $catOrderBy : 'sorting';
     // categoryModes are: 0=display all categories, 1=display selected categories, -1=display deselected categories
     $categoryMode = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'categoryMode', 'sDEF');
     $this->config['categoryMode'] = $categoryMode ? $categoryMode : intval($this->conf['categoryMode']);
     // catselection holds only the uids of the categories selected by GETvars
     if ($this->piVars['cat']) {
         // catselection holds only the uids of the categories selected by GETvars
         $this->config['catSelection'] = $this->hObj->checkRecords($this->piVars['cat']);
         $this->piVars_catSelection = $this->config['catSelection'];
         if ($this->config['useSubCategories'] && $this->config['catSelection']) {
             // get subcategories for selection from getVars
             $subcats = tx_ttnews_div::getSubCategories($this->config['catSelection'], $addWhere);
             $this->config['catSelection'] = implode(',', array_unique(explode(',', $this->config['catSelection'] . ($subcats ? ',' . $subcats : ''))));
         }
     }
     $catExclusive = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'categorySelection', 'sDEF');
     $catExclusive = $catExclusive ? $catExclusive : trim($this->cObj->stdWrap($this->conf['categorySelection'], $this->conf['categorySelection.']));
     $this->catExclusive = $this->config['categoryMode'] ? $catExclusive : 0;
     // ignore cat selection if categoryMode isn't set
     $this->catExclusive = $this->hObj->checkRecords($this->catExclusive);
     // store the actually selected categories because we need them for the comparison in categoryMode 2 and -2
     $this->actuallySelectedCategories = $this->catExclusive;
     // get subcategories
     if ($this->config['useSubCategories'] && $this->catExclusive) {
         $subcats = tx_ttnews_div::getSubCategories($this->catExclusive, $addWhere);
         $this->catExclusive = implode(',', array_unique(explode(',', $this->catExclusive . ($subcats ? ',' . $subcats : ''))));
     }
     // get more category fields from FF or TS
     $fields = explode(',', 'catImageMode,catTextMode,catImageMaxWidth,catImageMaxHeight,maxCatImages,catTextLength,maxCatTexts');
     foreach ($fields as $key) {
         $value = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], $key, 's_category');
         $this->config[$key] = is_numeric($value) ? $value : $this->conf[$key];
     }
 }
 /**
  * [Describe function...]
  *
  * @return	[type]		...
  */
 function getIncludeCatArray()
 {
     $includeList = $GLOBALS['BE_USER']->getTSConfigVal('tt_newsPerms.tt_news_cat.includeList');
     $catmounts = tx_ttnews_div::getBeUserCatMounts();
     if ($catmounts) {
         $includeList = $catmounts;
     }
     return t3lib_div::intExplode(',', $includeList, 1);
 }
 function getNewsCountForCategory($catID)
 {
     $sum = false;
     if (isset($this->categoryCountCache[$catID])) {
         $sum = $this->categoryCountCache[$catID];
     }
     if ($sum !== false) {
         //			t3lib_div::devLog('CACHE HIT (' . __CLASS__ . '::' . __FUNCTION__ . ')', 'tt_news', - 1, array());
     } else {
         if ($this->tt_news_obj->cache_categoryCount) {
             $hash = t3lib_div::shortMD5(serialize($catID . $this->newsSelConf['pidInList'] . $this->newsSelConf['where'] . $this->tt_news_obj->enableFields . $this->clause), 30);
             $sum = $this->tt_news_obj->cache->get($hash);
         }
         if ($sum === false) {
             if ($this->tt_news_obj->writeCachingInfoToDevlog) {
                 t3lib_div::devLog('CACHE MISS (single count) (' . __CLASS__ . '::' . __FUNCTION__ . ')', 'tt_news', 2, array());
             }
             $result = array();
             $result['sum'] = 0;
             $news_clause = '';
             if (is_object($this->tt_news_obj)) {
                 $news_clause .= ' AND ' . $this->newsSelConf['where'] . $this->tt_news_obj->enableFields;
                 if ($this->newsSelConf['pidInList']) {
                     $news_clause .= ' AND tt_news.pid IN (' . $this->newsSelConf['pidInList'] . ') ';
                 }
             }
             tx_ttnews_div::getNewsCountForSubcategory($result, $catID, $news_clause, $this->clause);
             $sum = $result['sum'];
         }
         $this->categoryCountCache[$catID] = (int) $sum;
         if ($this->tt_news_obj->cache_categoryCount) {
             $this->tt_news_obj->cache->set($hash, (string) $sum, 'categoryCounts');
         }
     }
     return $sum;
 }
Пример #5
0
 /**
  * [Describe function...]
  *
  * @return	[type]		...
  */
 function initSubCategories()
 {
     if ($this->useSubCategories && $this->category) {
         $subcats = tx_ttnews_div::getSubCategories($this->category);
         $this->selectedCategories = t3lib_div::uniqueList($this->category . ($subcats ? ',' . $subcats : ''));
     } else {
         $this->selectedCategories = $this->category;
     }
 }
Пример #6
0
 /**
  * [Describe function...]
  *
  * @return	[type]		...
  */
 function initSubCategories()
 {
     if ($this->useSubCategories && $this->category) {
         $subcats = tx_ttnews_div::getSubCategories($this->category);
         $this->selectedCategories = \TYPO3\CMS\Core\Utility\GeneralUtility::uniqueList($this->category . ($subcats ? ',' . $subcats : ''));
     } else {
         $this->selectedCategories = $this->category;
     }
 }
 /**
  * This method is called by a hook in the TYPO3 Core Engine (TCEmain) when a command was executed (copy,move,delete...).
  * For tt_news it is used to disable saving of the current record if it has an editlock or if it has categories assigned that are not allowed for the current BE user.
  *
  * @param	string		$command: The TCEmain command, fx. 'delete'
  * @param	string		$table: The table TCEmain is currently processing
  * @param	string		$id: The records id (if any)
  * @param	array		$value: The new value of the field which has been changed
  * @param	object		$pObj: Reference to the parent object (TCEmain)
  * @return	void
  * @access public
  */
 function processCmdmap_preProcess($command, &$table, &$id, $value, &$pObj)
 {
     if ($table == 'tt_news' && !$GLOBALS['BE_USER']->isAdmin()) {
         $rec = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($table, $id, 'editlock');
         // get record to check if it has an editlock
         if ($rec['editlock']) {
             $pObj->log($table, $id, 2, 0, 1, "processCmdmap [editlock]: Attempt to " . $command . " a record from table '%s' which is locked by an 'editlock' (= record can only be edited by admins).", 1, array($table));
             $error = true;
         }
         if (is_int($id)) {
             // get categories from the (untranslated) record in db
             $res = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query('tt_news_cat.uid, tt_news_cat.deleted, tt_news_cat_mm.sorting AS mmsorting', 'tt_news', 'tt_news_cat_mm', 'tt_news_cat', ' AND tt_news_cat.deleted=0 AND tt_news_cat_mm.uid_local=' . (is_int($id) ? $id : 0) . \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields('tt_news_cat'));
             $categories = array();
             while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                 $categories[] = $row['uid'];
             }
             $GLOBALS['TYPO3_DB']->sql_free_result($res);
             $notAllowedItems = array();
             if ($categories[0]) {
                 // original record has no categories
                 $treeIDs = tx_ttnews_div::getAllowedTreeIDs();
                 if (count($treeIDs)) {
                     $allowedItems = $treeIDs;
                 } else {
                     $allowedItems = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $GLOBALS['BE_USER']->getTSConfigVal('tt_newsPerms.tt_news_cat.allowedItems'));
                 }
                 foreach ($categories as $k) {
                     if (!in_array($k, $allowedItems)) {
                         $notAllowedItems[] = $k;
                     }
                 }
             }
             if ($notAllowedItems[0]) {
                 $pObj->log($table, $id, 2, 0, 1, "tt_news processCmdmap: Attempt to " . $command . " a record from table '%s' without permission. Reason: the record has one or more categories assigned that are not defined in your BE usergroup (tablename.allowedItems).", 1, array($table));
                 $error = true;
             }
             if ($error) {
                 $table = '';
                 // unset table to prevent saving
             }
         }
     }
 }
Пример #8
0
 /**
  * Get categories to include for the current user
  *
  * @return array ids of categories to include
  */
 public static function getIncludeCatArray()
 {
     $includeList = $GLOBALS['BE_USER']->getTSConfigVal('tt_newsPerms.tt_news_cat.includeList');
     $catmounts = tx_ttnews_div::getBeUserCatMounts();
     if ($catmounts) {
         $includeList = $catmounts;
     }
     return \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $includeList, 1);
 }
Пример #9
0
 function buildCalendarArray()
 {
     // Define the list of pages to search (999 depth level).
     $this->search_list = $this->pi_getPidList($this->menuPid, $this->recursion);
     // Display only records that are active.
     $this->splitQuery = 'AND tx_newscalendar_state = 1';
     // If showAllRecors is active, display all records.
     if ($this->conf['show.']['allRecords']) {
         $this->splitQuery = '';
     }
     // gregory goidin - rvvn
     // Calculate the first and last date of the month.
     $currentTime = $this->time;
     $firstDate = $calendarStartMonth = strtotime($this->calendarYear . '-' . $this->calendarMonth . '-01');
     $lastDate = $calendarEndMonth = mktime(23, 59, 59, intval($this->calendarMonth), date('t', $calendarStartMonth), intval($this->calendarYear));
     switch ($this->displayType) {
         case 1:
             // CALENDAR
             if ($this->conf['calendar.']['hideIfInPast'] == 1 && $currentTime >= $calendarStartMonth && $currentTime <= $calendarEndMonth) {
                 $firstDate = $currentTime;
             } else {
                 if ($this->conf['calendar.']['hideIfInPast'] == 1 && $currentTime > $calendarEndMonth) {
                     $firstDate = 1;
                     $lastDate = 1;
                 }
             }
             break;
         case 2:
             // LISTVIEW
             if ($this->conf['listView.']['hideIfInPast'] == 1 && $currentTime >= $calendarStartMonth && $currentTime <= $calendarEndMonth) {
                 $firstDate = $currentTime;
             } else {
                 if ($this->conf['listView.']['hideIfInPast'] == 1 && $currentTime > $calendarEndMonth) {
                     $firstDate = 1;
                     $lastDate = 1;
                 }
             }
             break;
         case 3:
             // LISTINTERVAL
             if ($this->conf['listInterval.']['hideIfInPast'] == 1 && $currentTime >= $calendarStartMonth && $currentTime <= $calendarEndMonth) {
                 $firstDate = $currentTime;
             } else {
                 if ($this->conf['listInterval.']['hideIfInPast'] == 1 && $currentTime > $calendarEndMonth) {
                     $firstDate = 1;
                     $lastDate = 1;
                 }
             }
             break;
         case 4:
             // NEXTEVENTS
             if ($this->conf['nextEvents.']['relativeToCalendar'] == 1 && $currentTime <= $calendarStartMonth) {
                 $firstDate = $calendarStartMonth;
             } else {
                 $firstDate = $currentTime;
             }
             break;
     }
     // Language query setup
     if ($this->sys_language_mode == 'strict' && $GLOBALS['TSFE']->sys_language_content) {
         // Just news in the same language
         $langClause = 'tt_news.sys_language_uid = ' . $GLOBALS['TSFE']->sys_language_content;
     } else {
         // sys_language_mode != 'strict': If a certain language is requested, select only news-records in the default language. The translated articles (if they exist) will be overlayed later in the list or single function.
         $langClause = 'tt_news.sys_language_uid IN (0,-1)';
     }
     // gregory goidin - rvvn
     // New way of creating the sql query ( new display ).
     if ($this->displayType == 4) {
         $queryYearMonth = 'AND ( (tx_newssdf_calendardate=0 AND datetime >= ' . $firstDate . ' ) ' . 'OR ( tx_newssdf_calendardate_end=0 AND tx_newssdf_calendardate >= ' . $firstDate . ' ) ' . 'OR ( tx_newssdf_calendardate_end >= ' . $firstDate . ' ) )';
     } else {
         $queryYearMonth = 'AND ( (tx_newssdf_calendardate=0 AND datetime >= ' . $firstDate . ' AND datetime <= ' . $lastDate . ' ) ' . 'OR ( tx_newssdf_calendardate_end=0 AND tx_newssdf_calendardate >= ' . $firstDate . ' AND tx_newssdf_calendardate <= ' . $lastDate . ' ) ' . 'OR ( tx_newssdf_calendardate <= ' . $lastDate . ' AND tx_newssdf_calendardate_end >= ' . $firstDate . ' ) )';
     }
     $this->where = $langClause . ' ' . $queryYearMonth . ' ' . $this->splitQuery . ' ' . $this->cObj->enableFields('tt_news');
     // gregory goidin - rvvn
     // add the limit parameter to configure the browsebox if needed in the sql query
     if ($this->displayType == 2 && intval($this->conf['pageBrowser.']['show']) == 1 && intval($this->conf['pageBrowser.']['limit']) >= 1 && intval($this->conf['pageBrowser.']['maxPages']) >= 1) {
         $limit = "";
         $currentPage = 0;
         if (intval($this->piVars[$this->conf['pageBrowser.']['pointer']]) > 0) {
             $currentPage = intval($this->piVars[$this->conf['pageBrowser.']['pointer']]);
         }
         $limit = intval($this->conf['pageBrowser.']['limit']) * $currentPage . "," . intval($this->conf['pageBrowser.']['limit']);
     } else {
         if ($this->displayType == 4 && intval($this->conf['pageBrowser.']['show']) == 1 && intval($this->conf['pageBrowser.']['limit']) >= 1 && intval($this->conf['pageBrowser.']['maxPages']) >= 1) {
             $limit = "";
             $currentPage = 0;
             if (intval($this->piVars[$this->conf['pageBrowser.']['pointer']]) > 0) {
                 $currentPage = intval($this->piVars[$this->conf['pageBrowser.']['pointer']]);
             }
             $limitMax = intval($this->conf['pageBrowser.']['limit']);
             if (intval($this->conf['pageBrowser.']['limit']) * ($currentPage + 1) > intval($this->conf['nextEvents.']['maxItems'])) {
                 $limitMax = intval($this->conf['nextEvents.']['maxItems']) - intval($this->conf['pageBrowser.']['limit']) * $currentPage;
             }
             $limit = intval($this->conf['pageBrowser.']['limit']) * $currentPage . "," . $limitMax;
         } else {
             if ($this->displayType == 4 && intval($this->conf['pageBrowser.']['show']) == 0) {
                 $limit = "0," . intval($this->conf['nextEvents.']['maxItems']);
             }
         }
     }
     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tt_news.uid,
             tt_news.pid,
             tt_news.sys_language_uid,
             tt_news.title,
             tt_news.datetime,
             tt_news.tx_newssdf_calendardate_end,
             tt_news.tx_newssdf_calendardate,
             tt_news.short,
             tt_news.image,
             tt_news.imagecaption,
             tt_news.imagealttext,
             tt_news.imagetitletext,
             tt_news.bodytext,
             tt_news.page,
             tt_news.type,
             tt_news.ext_url', 'tt_news', $this->where . ' AND tt_news.pid in (' . $this->search_list . ')', '', 'tx_newssdf_calendardate, tt_news.datetime ASC', $limit);
     $this->globalRes = $res;
     //****************************************************************//
     //gregory goidin - rvvn : start : We need the total count to initialize the pageBrowser
     /**
      * If the type of view is able to have  a page browser we need to count the events again
      * so we have the total record count for the paginator.
      * We bypass the Calendar View by default.
      */
     if ($this->displayType != 1) {
         $resCount = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'tt_news', $this->where . ' AND tt_news.pid in (' . $this->search_list . ')', '', 'tx_newssdf_calendardate, tt_news.datetime ASC', "");
         $rowCount = $GLOBALS['TYPO3_DB']->sql_fetch_row($resCount);
         if ($this->displayType == 4 && $rowCount[0] > intval($this->conf['nextEvents.']['maxItems'])) {
             $rowCount[0] = intval($this->conf['nextEvents.']['maxItems']);
         }
         $this->globalResCount = $rowCount[0];
     } else {
         // For calendar view we do not use limits or paginator browser
         $this->globalResCount = $GLOBALS['TYPO3_DB']->sql_num_rows($this->globalRes);
     }
     //gregory goidin - rvvn : stop !
     //****************************************************************//
     // Prevent interval item rendering on normal and next events list views.
     // Only this will be prepared to render selected categories.
     if ($this->displayType == 1 || $this->displayType == 3) {
         // Fill array with result set.
         // CHANGED BY RICC FROM '1' to '0'
         $arrayCounter = 0;
         if ($this->categorySelection && $this->useSubCategories) {
             $this->categorySelection .= ',' . tx_ttnews_div::getSubCategories($this->categorySelection);
         }
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             /**
              * START: News category in list if applicable
              */
             if ($this->categorySelection) {
                 $exists = false;
                 $categoryArray = explode(",", $this->categorySelection);
                 foreach ($categoryArray as $selectedCatId) {
                     $exists = array_key_exists($selectedCatId, tx_ttnews::getCategories($row['uid']));
                     if ($exists) {
                         break;
                     }
                 }
                 if (!$exists) {
                     continue;
                 }
             }
             /**
              * STOP: News category in list if applicable
              */
             // News item default types
             $resultList[$arrayCounter]['type'] = $row['type'];
             $resultList[$arrayCounter]['page'] = $row['page'];
             $resultList[$arrayCounter]['ext_url'] = $row['ext_url'];
             $resultList[$arrayCounter]['image'] = $row['image'];
             $resultList[$arrayCounter]['short'] = $row['short'];
             $auxiliar_data = $resultList;
             // get the translated record if the content language is not the default language
             if ($GLOBALS['TSFE']->sys_language_content) {
                 // $OLmode = ($this->sys_language_mode == 'strict'?'hideNonTranslated':'');
                 $OLmode = $GLOBALS['TSFE']->tmpl->setup['config.']['sys_language_overlay'];
                 $row = $GLOBALS['TSFE']->sys_page->getRecordOverlay('tt_news', $row, $GLOBALS['TSFE']->sys_language_content, $OLmode);
             }
             // Choose startdate, preference for tx_newscalendardate over datetime.
             $finalStartDate = $row['tx_newssdf_calendardate'] ? $row['tx_newssdf_calendardate'] : $row['datetime'];
             if ($this->calendarYear == date('Y', $finalStartDate) && $this->calendarMonth == date('n', $finalStartDate)) {
                 $resultList[$arrayCounter]['uid'] = $row['uid'];
                 $resultList[$arrayCounter]['title'] = $row['title'];
                 $resultList[$arrayCounter]['monthday'] = date('j', $finalStartDate);
                 $resultList[$arrayCounter]['enddate'] = $row['tx_newssdf_calendardate_end'];
                 $resultList[$arrayCounter]['datetime'] = $finalStartDate;
                 $arrayCounter++;
             }
             if ($row['tx_newssdf_calendardate_end'] > 0) {
                 $startDate = date('Y-m-d', $finalStartDate);
                 $endDate = date('Y-m-d', $row['tx_newssdf_calendardate_end']);
                 $daysBetween = $this->GetDays($startDate, $endDate, $row['uid']);
                 while ($date = each($daysBetween)) {
                     if ($startDate != $date[1]) {
                         $timeDate = strtotime($date[1] . date(' H:i', $finalStartDate));
                         if ($this->calendarYear == date('Y', $timeDate) && $this->calendarMonth == date('n', $timeDate)) {
                             $resultList[$arrayCounter]['uid'] = $row['uid'];
                             $resultList[$arrayCounter]['title'] = $row['title'];
                             $resultList[$arrayCounter]['monthday'] = date('j', $timeDate);
                             $resultList[$arrayCounter]['enddate'] = 0;
                             $resultList[$arrayCounter]['datetime'] = $timeDate;
                             $resultList[$arrayCounter]['type'] = $row['type'];
                             $resultList[$arrayCounter]['page'] = $row['page'];
                             $resultList[$arrayCounter]['ext_url'] = $row['ext_url'];
                             $resultList[$arrayCounter]['image'] = $row['image'];
                             $resultList[$arrayCounter]['short'] = $row['short'];
                             /**
                              * Remove items when in a interval and "hideIfInPast" is on
                              * $this->conf['calendar.']['hideIfInPast']
                              * Thanks to Marvin Stobberingh for reporting.
                              */
                             if ($this->conf['calendar.']['hideIfInPast']) {
                                 if ($resultList[$arrayCounter]['datetime'] < time()) {
                                     unset($resultList[$arrayCounter - 1]);
                                 } else {
                                     $arrayCounter++;
                                 }
                             } else {
                                 $arrayCounter++;
                             }
                         }
                     }
                 }
             }
         }
         # sort alphabetically by name
         if (is_array($resultList)) {
             usort($resultList, array($this, 'compare_datetime'));
         }
         $this->resultListCount = count($resultList);
         $this->resultList = $resultList;
     }
     return;
 }