Exemplo n.º 1
0
 /**
  * @param int               $startPage
  * @param array             $basePages
  * @param SitemapController $obj
  *
  * @return array
  */
 public function getRecords($startPage, $basePages, SitemapController $obj)
 {
     $nodes = array();
     foreach ($basePages as $uid) {
         if ($this->currentLanguageUid) {
             $fields = $this->cObject->enableFields('pages_language_overlay');
             $overlay = $this->database->exec_SELECTgetSingleRow('uid', 'pages_language_overlay', ' pid=' . intval($uid) . ' AND sys_language_uid=' . $this->currentLanguageUid . $fields);
             if (!is_array($overlay)) {
                 continue;
             }
         }
         // Build URL
         $url = $obj->getUriBuilder()->setTargetPageUid($uid)->build();
         // can't generate a valid url
         if (!strlen($url)) {
             continue;
         }
         // Get Record
         $record = BackendUtility::getRecord('pages', $uid);
         // exclude Doctypes
         if (in_array($record['doktype'], array(4))) {
             continue;
         }
         // Check FE Access
         if ($record['fe_group'] != 0) {
             continue;
         }
         $rootLineList = $GLOBALS['TSFE']->sys_page->getRootLine($record['uid']);
         $addToNode = true;
         foreach ($rootLineList as $rootPage) {
             if ($rootPage['extendToSubpages'] == 1 && $rootPage['fe_group'] != 0) {
                 $addToNode = false;
                 break;
             }
         }
         if ($addToNode == false) {
             continue;
         }
         // Build Node
         $node = new Node();
         $node->setLoc($url);
         $node->setPriority($this->getPriority($startPage, $record));
         $node->setChangefreq(SitemapDataService::mapTimeout2Period($record['cache_timeout']));
         $node->setLastmod($this->getModifiedDate($record));
         #$geo = new Geo();
         #$geo->setFormat('kml');
         #$node->setGeo($geo);
         $nodes[] = $node;
     }
     return $nodes;
 }
Exemplo n.º 2
0
    /**
     * fetches all available children for a certain grid container
     *
     * @param int $element : The uid of the grid container
     * @param string $csvColumns : A list of available column IDs
     *
     * @return array $children: The child elements of this grid container
     */
    public function getChildren($element = 0, $csvColumns = '')
    {
        if ($element && $csvColumns !== '') {
            $where = '(tx_gridelements_container = ' . $element . $this->cObj->enableFields('tt_content') . ' AND colPos != -2
				AND pid > 0
				AND tx_gridelements_columns IN (' . $csvColumns . ')
				AND sys_language_uid IN (-1,0)
			)';
            if ($GLOBALS['TSFE']->sys_language_content > 0) {
                if ($GLOBALS['TSFE']->sys_language_contentOL) {
                    if (isset($this->cObj->data['_LOCALIZED_UID']) && $this->cObj->data['_LOCALIZED_UID'] !== 0) {
                        $element = (int) $this->cObj->data['_LOCALIZED_UID'];
                    }
                    if ($element) {
                        $where .= '  OR (
						tx_gridelements_container = ' . $element . $this->cObj->enableFields('tt_content') . ' AND sys_language_uid IN (-1,' . $GLOBALS['TSFE']->sys_language_content . ')
							AND l18n_parent = 0
					)';
                    }
                } else {
                    if ($element) {
                        $where .= '  OR (
						tx_gridelements_container = ' . $element . $this->cObj->enableFields('tt_content') . ' AND sys_language_uid IN (-1,' . $GLOBALS['TSFE']->sys_language_content . ')
					)';
                    }
                }
            }
            $res = $this->getDatabaseConnection()->exec_SELECTquery('*', 'tt_content', $where, '', 'sorting ASC');
            if (!$this->getDatabaseConnection()->sql_error()) {
                $this->cObj->data['tx_gridelements_view_children'] = array();
                while ($child = $this->getDatabaseConnection()->sql_fetch_assoc($res)) {
                    // Versioning preview:
                    $sorting = $child['sorting'];
                    $GLOBALS['TSFE']->sys_page->versionOL('tt_content', $child, true);
                    // Language overlay:
                    if (is_array($child)) {
                        $child['sorting'] = $sorting;
                        if ($GLOBALS['TSFE']->sys_language_contentOL) {
                            $child = $GLOBALS['TSFE']->sys_page->getRecordOverlay('tt_content', $child, $GLOBALS['TSFE']->sys_language_content, $GLOBALS['TSFE']->sys_language_contentOL);
                        }
                        if ($child !== false) {
                            $this->cObj->data['tx_gridelements_view_children'][] = $child;
                            unset($child);
                        }
                    }
                }
                $compareFunction = function ($child_a, $child_b) {
                    if ($child_a['sorting'] > $child_b['sorting']) {
                        return 1;
                    } elseif ($child_a['sorting'] === $child_b['sorting']) {
                        return 0;
                    } else {
                        return -1;
                    }
                };
                usort($this->cObj->data['tx_gridelements_view_children'], $compareFunction);
                $this->getDatabaseConnection()->sql_free_result($res);
            }
        }
    }
Exemplo n.º 3
0
 /**
  * Sets all parameter for langMenu
  *
  * @return array
  */
 protected function parseLanguageMenu()
 {
     $order = $this->arguments['order'] ? GeneralUtility::trimExplode(',', $this->arguments['order']) : '';
     $labelOverwrite = $this->arguments['labelOverwrite'] ? GeneralUtility::trimExplode(',', $this->arguments['labelOverwrite']) : '';
     $languageMenu = array();
     $tempArray = array();
     $tempArray[0] = array('label' => $this->arguments['defaultLanguageLabel'], 'flag' => $this->arguments['defaultIsoFlag']);
     $select = 'uid, title, flag';
     $from = 'sys_language';
     $where = '1=1' . $this->cObj->enableFields('sys_language');
     $sysLanguage = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($select, $from, $where);
     foreach ($sysLanguage as $value) {
         $tempArray[$value['uid']] = array('label' => $value['title'], 'flag' => $value['flag']);
     }
     // reorders languageMenu
     if (FALSE === empty($order)) {
         foreach ($order as $value) {
             $languageMenu[$value] = $tempArray[$value];
         }
     } else {
         $languageMenu = $tempArray;
     }
     // overwrite of label
     if (FALSE === empty($labelOverwrite)) {
         $i = 0;
         foreach ($languageMenu as $key => $value) {
             $languageMenu[$key]['label'] = $labelOverwrite[$i];
             $i++;
         }
     }
     // Select all pages_language_overlay records on the current page. Each represents a possibility for a language.
     $pageArray = array();
     $table = 'pages_language_overlay';
     $whereClause = 'pid=' . $this->getPageUid() . ' ';
     $whereClause .= $GLOBALS['TSFE']->sys_page->enableFields($table);
     $sysLang = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('DISTINCT sys_language_uid', $table, $whereClause);
     if (FALSE === empty($sysLang)) {
         foreach ($sysLang as $val) {
             $pageArray[$val['sys_language_uid']] = $val['sys_language_uid'];
         }
     }
     foreach ($languageMenu as $key => $value) {
         $current = $GLOBALS['TSFE']->sys_language_uid === (int) $key ? 1 : 0;
         $inactive = $pageArray[$key] || (int) $key === $this->defaultLangUid ? 0 : 1;
         $url = $this->getLanguageUrl($key, $inactive);
         if (TRUE === empty($url)) {
             $url = GeneralUtility::getIndpEnv('REQUEST_URI');
         }
         $languageMenu[$key]['current'] = $current;
         $languageMenu[$key]['inactive'] = $inactive;
         $languageMenu[$key]['url'] = $url;
         $languageMenu[$key]['flagSrc'] = $this->getLanguageFlagSrc($value['flag']);
         if (TRUE === (bool) $this->arguments['hideNotTranslated'] && TRUE === (bool) $inactive) {
             unset($languageMenu[$key]);
         }
     }
     return $languageMenu;
 }
 /**
  * Fetches all menuitems if special = list is set
  *
  * @param string $specialValue The value from special.value
  * @return array
  */
 protected function prepareMenuItemsForListMenu($specialValue)
 {
     $menuItems = array();
     if ($specialValue == '') {
         $specialValue = $this->id;
     }
     $skippedEnableFields = array();
     if (!empty($this->mconf['showAccessRestrictedPages'])) {
         $skippedEnableFields = array('fe_group' => 1);
     }
     /** @var RelationHandler $loadDB*/
     $loadDB = GeneralUtility::makeInstance(RelationHandler::class);
     $loadDB->setFetchAllFields(true);
     $loadDB->start($specialValue, 'pages');
     $loadDB->additionalWhere['pages'] = $this->parent_cObj->enableFields('pages', false, $skippedEnableFields);
     $loadDB->getFromDB();
     foreach ($loadDB->itemArray as $val) {
         $MP = $this->tmpl->getFromMPmap($val['id']);
         // Keep mount point?
         $mount_info = $this->sys_page->getMountPointInfo($val['id']);
         // There is a valid mount point.
         if (is_array($mount_info) && $mount_info['overlay']) {
             // Using "getPage" is OK since we need the check for enableFields
             // AND for type 2 of mount pids we DO require a doktype < 200!
             $mp_row = $this->sys_page->getPage($mount_info['mount_pid']);
             if (!empty($mp_row)) {
                 $row = $mp_row;
                 $row['_MP_PARAM'] = $mount_info['MPvar'];
                 // Overlays should already have their full MPvars calculated
                 if ($mount_info['overlay']) {
                     $MP = $this->tmpl->getFromMPmap($mount_info['mount_pid']);
                     if ($MP) {
                         unset($row['_MP_PARAM']);
                     }
                 }
             } else {
                 // If the mount point could not be fetched with respect to
                 // enableFields, unset the row so it does not become a part of the menu!
                 unset($row);
             }
         } else {
             $row = $loadDB->results['pages'][$val['id']];
         }
         // Add versioning overlay for current page (to respect workspaces)
         if (isset($row) && is_array($row)) {
             $this->sys_page->versionOL('pages', $row, true);
         }
         // Add external MP params, then the row:
         if (isset($row) && is_array($row)) {
             if ($MP) {
                 $row['_MP_PARAM'] = $MP . ($row['_MP_PARAM'] ? ',' . $row['_MP_PARAM'] : '');
             }
             $menuItems[] = $this->sys_page->getPageOverlay($row);
         }
     }
     return $menuItems;
 }
 /**
  * Gets closing time from a record
  *
  * @param    string $table Table name
  * @param    int $uid UID of the record
  * @param    \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $cObj COBJECT
  * @return    int    Closing timestamp
  */
 function getCloseTime($table, $uid, &$cObj)
 {
     $result = 0;
     $recs = $this->getDatabaseConnection()->exec_SELECTgetRows('disable_comments,comments_closetime', $table, 'uid=' . intval($uid) . $cObj->enableFields($table));
     if (count($recs)) {
         $result = $recs[0]['disable_comments'] ? 0 : ($recs[0]['comments_closetime'] ? $recs[0]['comments_closetime'] : PHP_INT_MAX);
     }
     return $result;
 }
Exemplo n.º 6
0
 /**
  * Will select all records from the "category table", $table, and return them in an array.
  *
  * @param string $table The name of the category table to select from.
  * @param int $pid The page from where to select the category records.
  * @param string $whereClause Optional additional WHERE clauses put in the end of the query. DO NOT PUT IN GROUP BY, ORDER BY or LIMIT!
  * @param string $groupBy Optional GROUP BY field(s), if none, supply blank string.
  * @param string $orderBy Optional ORDER BY field(s), if none, supply blank string.
  * @param string $limit Optional LIMIT value ([begin,]max), if none, supply blank string.
  * @return array The array with the category records in.
  */
 public function pi_getCategoryTableContents($table, $pid, $whereClause = '', $groupBy = '', $orderBy = '', $limit = '')
 {
     $res = $this->databaseConnection->exec_SELECTquery('*', $table, 'pid=' . (int) $pid . $this->cObj->enableFields($table) . ' ' . $whereClause, $groupBy, $orderBy, $limit);
     $outArr = array();
     while ($row = $this->databaseConnection->sql_fetch_assoc($res)) {
         $outArr[$row['uid']] = $row;
     }
     $this->databaseConnection->sql_free_result($res);
     return $outArr;
 }
 /**
  * Check if a translation of a page is available
  * @param $pid \int Page id
  * @param $languageUid \int Language uid
  * @return bool
  */
 protected function hasTranslation($pid, $languageUid)
 {
     $enableFieldsSql = $this->cObj->enableFields('pages_language_overlay');
     $languageSql = ' pid=' . (int) $pid . ' AND `sys_language_uid` =' . (int) $languageUid . ' ';
     $where = $languageSql . $enableFieldsSql;
     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('COUNT(uid)', 'pages_language_overlay', $where);
     $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
     $GLOBALS['TYPO3_DB']->sql_free_result($res);
     return $row[0] > 0;
 }
Exemplo n.º 8
0
 /**
  * Check if a translation of a page is available
  * @param $pid \int Page id
  * @param $languageUid \int Language uid
  * @return bool
  */
 protected function hasTranslation($pid, $languageUid)
 {
     $enableFieldsSql = $this->contentObjectRenderer->enableFields('pages_language_overlay');
     //$visibleSql  = ' deleted=0 AND t3ver_state<=0 AND hidden=0 ';
     //$startEndSql = ' AND (starttime<=' . time() . ' AND (endtime=0 OR endtime >=' . time() . ')) ';
     $languageSql = ' pid=' . (int) $pid . ' AND `sys_language_uid` =' . (int) $languageUid . ' ';
     $where = $languageSql . $enableFieldsSql;
     //$visibleSql.$startEndSql;
     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('COUNT(uid)', 'pages_language_overlay', $where);
     $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
     $GLOBALS['TYPO3_DB']->sql_free_result($res);
     return $row[0] > 0;
 }
 /**
  * Userfunc called per TS to create categories check boxes
  *
  * @param string $content
  * @param array $conf TS conf
  *
  * @return string
  */
 public function makeCheckboxes($content, $conf)
 {
     $content = '';
     $databaseConnection = $this->getDatabaseConnection();
     $pid = $this->cObj->stdWrap($conf['pid'], $conf['pid.']);
     if ($address_uid = GeneralUtility::_GP('rU')) {
         $res = $databaseConnection->exec_SELECTquery('*', 'sys_dmail_ttaddress_category_mm', 'uid_local=' . intval($address_uid));
         $subscribed_to = [];
         while ($row = $databaseConnection->sql_fetch_assoc($res)) {
             $subscribed_to[] = $row['uid_foreign'];
         }
         $subscribed_to_list = implode(',', $subscribed_to);
     }
     $res = $databaseConnection->exec_SELECTquery('*', 'sys_dmail_category', 'l18n_parent=0 AND pid=' . intval($pid) . $this->cObj->enableFields('sys_dmail_category'));
     $i = 1;
     while ($row = $databaseConnection->sql_fetch_assoc($res)) {
         $checked = GeneralUtility::inList($subscribed_to_list, $row['uid']);
         if ($theRow = $this->getTypoScriptFrontendController()->sys_page->getRecordOverlay('sys_dmail_category', $row, $this->getTypoScriptFrontendController()->sys_language_uid, $conf['hideNonTranslatedCategories'] ? 'hideNonTranslated' : '')) {
             $content .= '<label for="option-' . $i . '">' . htmlspecialchars($theRow['category']) . '</label><input id="option-' . $i . '" type="checkbox" ' . ($checked ? 'checked' : '') . ' name="FE[tt_address][module_sys_dmail_category][' . $row['uid'] . ']" value="1" /><div class="clearall"></div>';
         }
         $i++;
     }
     return $content;
 }
Exemplo n.º 10
0
 /**
  * Adds the manufacturer to the category, as simulated category
  *
  * @param int $pid Page PID for the level
  * @param int $uidPage UidPage for the level
  * @param string $tableMm Relation Table
  * @param string $tableSubMain Sub table
  * @param string $tableSubMm Sub Table Relationship
  * @param int $categoryUid Category ID
  * @param int $mDepth Menu Depth
  * @param string $path Path for fast resolving
  *
  * @return array|bool
  */
 public function getManufacturerAsCategory($pid, $uidPage, $tableMm, $tableSubMain, $tableSubMm, $categoryUid, $mDepth, $path)
 {
     $database = $this->getDatabaseConnection();
     $result = $database->exec_SELECTquery('*', 'tx_commerce_products_categories_mm', 'uid_foreign = ' . (int) $categoryUid);
     $productUids = array();
     while (($mmRow = $database->sql_fetch_assoc($result)) !== FALSE) {
         $productUids[] = (int) $mmRow['uid_local'];
     }
     if (!count($productUids)) {
         return FALSE;
     }
     $result = $database->exec_SELECTquery('uid, manufacturer_uid', 'tx_commerce_products', 'uid IN (' . implode(',', $productUids) . ')' . $this->cObj->enableFields('tx_commerce_products'));
     $outout = array();
     $firstPath = $path;
     while (($productRow = $database->sql_fetch_assoc($result)) !== FALSE) {
         if ($productRow['manufacturer_uid'] != '0') {
             /*
              * @todo not a realy good solution
              */
             $path = $this->manufacturerIdentifier . $productRow['manufacturer_uid'] . ',' . $firstPath;
             /**
              * Product
              *
              * @var Tx_Commerce_Domain_Model_Product $product
              */
             $product = GeneralUtility::makeInstance('Tx_Commerce_Domain_Model_Product', $productRow['uid']);
             $product->loadData();
             $manufacturerTitle = htmlspecialchars(strip_tags($product->getManufacturerTitle()));
             $addGet = $this->separator . $this->prefixId . '[catUid]=' . $categoryUid . $this->separator . $this->prefixId . '[manufacturer]=' . $productRow['manufacturer_uid'] . '';
             $cHash = $this->generateChash($addGet . $GLOBALS['TSFE']->linkVars);
             $addGet .= $this->separator . 'cHash=' . $cHash;
             $aLevel = array('pid' => $pid, 'uid' => $uidPage, 'title' => $manufacturerTitle, 'parent_id' => $categoryUid, 'nav_title' => $manufacturerTitle, 'hidden' => '0', 'depth' => $mDepth, 'leaf' => $this->isLeaf($categoryUid, $tableMm, $tableSubMm), 'hasSubChild' => $this->hasSubChild($categoryUid, $tableSubMm), 'subChildTable' => $tableSubMm, 'tableSubMain' => $tableSubMain, 'path' => $path, '_ADD_GETVARS' => $addGet, 'ITEM_STATE' => 'NO', 'manu' => $productRow['manufacturer_uid']);
             if ($this->gpVars['manufacturer']) {
                 $this->choosenCat = $this->manufacturerIdentifier . $this->gpVars['manufacturer'];
             }
             if ($aLevel['hasSubChild'] == 1 && $this->mConf['showProducts'] == 1) {
                 $aLevel['--subLevel--'] = $this->makeSubChildArrayPostRender($uidPage, $tableSubMain, $tableSubMm, $categoryUid, $mDepth + 1, $path, $productRow['manufacturer_uid']);
             }
             if ($this->expandAll > 0 || $this->expandAll < 0 && -$this->expandAll >= $mDepth) {
                 $aLevel['_SUB_MENU'] = $aLevel['--subLevel--'];
             }
             $outout[$this->manufacturerIdentifier . $productRow['manufacturer_uid']] = $aLevel;
         }
     }
     return $outout;
 }
 /**
  * Creates the menu in the internal variables, ready for output.
  * Basically this will read the page records needed and fill in the internal $this->menuArr
  * Based on a hash of this array and some other variables the $this->result variable will be loaded either from cache OR by calling the generate() method of the class to create the menu for real.
  *
  * @return void
  * @todo Define visibility
  */
 public function makeMenu()
 {
     if ($this->id) {
         $this->useCacheHash = FALSE;
         // Initializing showAccessRestrictedPages
         if ($this->mconf['showAccessRestrictedPages']) {
             // SAVING where_groupAccess
             $SAVED_where_groupAccess = $this->sys_page->where_groupAccess;
             // Temporarily removing fe_group checking!
             $this->sys_page->where_groupAccess = '';
         }
         // Begin production of menu:
         $temp = array();
         $altSortFieldValue = trim($this->mconf['alternativeSortingField']);
         $altSortField = $altSortFieldValue ?: 'sorting';
         // ... only for the FIRST level of a HMENU
         if ($this->menuNumber == 1 && $this->conf['special']) {
             $value = isset($this->conf['special.']['value.']) ? $this->parent_cObj->stdWrap($this->conf['special.']['value'], $this->conf['special.']['value.']) : $this->conf['special.']['value'];
             switch ($this->conf['special']) {
                 case 'userfunction':
                     $temp = $this->parent_cObj->callUserFunction($this->conf['special.']['userFunc'], array_merge($this->conf['special.'], array('_altSortField' => $altSortField)), '');
                     if (!is_array($temp)) {
                         $temp = array();
                     }
                     break;
                 case 'language':
                     $temp = array();
                     // Getting current page record NOT overlaid by any translation:
                     $currentPageWithNoOverlay = $this->sys_page->getRawRecord('pages', $GLOBALS['TSFE']->page['uid']);
                     // Traverse languages set up:
                     $languageItems = GeneralUtility::intExplode(',', $value);
                     foreach ($languageItems as $sUid) {
                         // Find overlay record:
                         if ($sUid) {
                             $lRecs = $this->sys_page->getPageOverlay($GLOBALS['TSFE']->page['uid'], $sUid);
                         } else {
                             $lRecs = array();
                         }
                         // Checking if the "disabled" state should be set.
                         if (GeneralUtility::hideIfNotTranslated($GLOBALS['TSFE']->page['l18n_cfg']) && $sUid && !count($lRecs) || $GLOBALS['TSFE']->page['l18n_cfg'] & 1 && (!$sUid || !count($lRecs)) || !$this->conf['special.']['normalWhenNoLanguage'] && $sUid && !count($lRecs)) {
                             $iState = $GLOBALS['TSFE']->sys_language_uid == $sUid ? 'USERDEF2' : 'USERDEF1';
                         } else {
                             $iState = $GLOBALS['TSFE']->sys_language_uid == $sUid ? 'ACT' : 'NO';
                         }
                         if ($this->conf['addQueryString']) {
                             $getVars = $this->parent_cObj->getQueryArguments($this->conf['addQueryString.'], array('L' => $sUid), TRUE);
                             $this->analyzeCacheHashRequirements($getVars);
                         } else {
                             $getVars = '&L=' . $sUid;
                         }
                         // Adding menu item:
                         $temp[] = array_merge(array_merge($currentPageWithNoOverlay, $lRecs), array('ITEM_STATE' => $iState, '_ADD_GETVARS' => $getVars, '_SAFE' => TRUE));
                     }
                     break;
                 case 'directory':
                     if ($value == '') {
                         $value = $GLOBALS['TSFE']->page['uid'];
                     }
                     $items = GeneralUtility::intExplode(',', $value);
                     foreach ($items as $id) {
                         $MP = $this->tmpl->getFromMPmap($id);
                         // Checking if a page is a mount page and if so, change the ID and set the MP var properly.
                         $mount_info = $this->sys_page->getMountPointInfo($id);
                         if (is_array($mount_info)) {
                             if ($mount_info['overlay']) {
                                 // Overlays should already have their full MPvars calculated:
                                 $MP = $this->tmpl->getFromMPmap($mount_info['mount_pid']);
                                 $MP = $MP ? $MP : $mount_info['MPvar'];
                             } else {
                                 $MP = ($MP ? $MP . ',' : '') . $mount_info['MPvar'];
                             }
                             $id = $mount_info['mount_pid'];
                         }
                         // Get sub-pages:
                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'pid=' . (int) $id . $this->sys_page->where_hid_del, '', $altSortField);
                         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                             $row = $this->sys_page->getPage($row['uid']);
                             $GLOBALS['TSFE']->sys_page->versionOL('pages', $row, TRUE);
                             if (!empty($row)) {
                                 // Keep mount point?
                                 $mount_info = $this->sys_page->getMountPointInfo($row['uid'], $row);
                                 // There is a valid mount point.
                                 if (is_array($mount_info) && $mount_info['overlay']) {
                                     // Using "getPage" is OK since we need the check for enableFields
                                     // AND for type 2 of mount pids we DO require a doktype < 200!
                                     $mp_row = $this->sys_page->getPage($mount_info['mount_pid']);
                                     if (count($mp_row)) {
                                         $row = $mp_row;
                                         $row['_MP_PARAM'] = $mount_info['MPvar'];
                                     } else {
                                         // If the mount point could not be fetched with respect
                                         // to enableFields, unset the row so it does not become a part of the menu!
                                         unset($row);
                                     }
                                 }
                                 // Add external MP params, then the row:
                                 if (!empty($row)) {
                                     if ($MP) {
                                         $row['_MP_PARAM'] = $MP . ($row['_MP_PARAM'] ? ',' . $row['_MP_PARAM'] : '');
                                     }
                                     $temp[$row['uid']] = $row;
                                 }
                             }
                         }
                         $GLOBALS['TYPO3_DB']->sql_free_result($res);
                     }
                     break;
                 case 'list':
                     if ($value == '') {
                         $value = $this->id;
                     }
                     $skippedEnableFields = array();
                     if (!empty($this->mconf['showAccessRestrictedPages'])) {
                         $skippedEnableFields = array('fe_group' => 1);
                     }
                     /** @var \TYPO3\CMS\Core\Database\RelationHandler $loadDB*/
                     $loadDB = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\RelationHandler');
                     $loadDB->setFetchAllFields(TRUE);
                     $loadDB->start($value, 'pages');
                     $loadDB->additionalWhere['pages'] = $this->parent_cObj->enableFields('pages', FALSE, $skippedEnableFields);
                     $loadDB->getFromDB();
                     foreach ($loadDB->itemArray as $val) {
                         $MP = $this->tmpl->getFromMPmap($val['id']);
                         // Keep mount point?
                         $mount_info = $this->sys_page->getMountPointInfo($val['id']);
                         // There is a valid mount point.
                         if (is_array($mount_info) && $mount_info['overlay']) {
                             // Using "getPage" is OK since we need the check for enableFields
                             // AND for type 2 of mount pids we DO require a doktype < 200!
                             $mp_row = $this->sys_page->getPage($mount_info['mount_pid']);
                             if (count($mp_row)) {
                                 $row = $mp_row;
                                 $row['_MP_PARAM'] = $mount_info['MPvar'];
                                 // Overlays should already have their full MPvars calculated
                                 if ($mount_info['overlay']) {
                                     $MP = $this->tmpl->getFromMPmap($mount_info['mount_pid']);
                                     if ($MP) {
                                         unset($row['_MP_PARAM']);
                                     }
                                 }
                             } else {
                                 // If the mount point could not be fetched with respect to
                                 // enableFields, unset the row so it does not become a part of the menu!
                                 unset($row);
                             }
                         } else {
                             $row = $loadDB->results['pages'][$val['id']];
                         }
                         //Add versioning overlay for current page (to respect workspaces)
                         if (is_array($row)) {
                             $this->sys_page->versionOL('pages', $row, TRUE);
                         }
                         // Add external MP params, then the row:
                         if (is_array($row)) {
                             if ($MP) {
                                 $row['_MP_PARAM'] = $MP . ($row['_MP_PARAM'] ? ',' . $row['_MP_PARAM'] : '');
                             }
                             $temp[] = $this->sys_page->getPageOverlay($row);
                         }
                     }
                     break;
                 case 'updated':
                     if ($value == '') {
                         $value = $GLOBALS['TSFE']->page['uid'];
                     }
                     $items = GeneralUtility::intExplode(',', $value);
                     if (MathUtility::canBeInterpretedAsInteger($this->conf['special.']['depth'])) {
                         $depth = MathUtility::forceIntegerInRange($this->conf['special.']['depth'], 1, 20);
                     } else {
                         $depth = 20;
                     }
                     // Max number of items
                     $limit = MathUtility::forceIntegerInRange($this->conf['special.']['limit'], 0, 100);
                     $maxAge = (int) $this->parent_cObj->calc($this->conf['special.']['maxAge']);
                     if (!$limit) {
                         $limit = 10;
                     }
                     // *'auto', 'manual', 'tstamp'
                     $mode = $this->conf['special.']['mode'];
                     // Get id's
                     $id_list_arr = array();
                     foreach ($items as $id) {
                         $bA = MathUtility::forceIntegerInRange($this->conf['special.']['beginAtLevel'], 0, 100);
                         $id_list_arr[] = $this->parent_cObj->getTreeList(-1 * $id, $depth - 1 + $bA, $bA - 1);
                     }
                     $id_list = implode(',', $id_list_arr);
                     // Get sortField (mode)
                     switch ($mode) {
                         case 'starttime':
                             $sortField = 'starttime';
                             break;
                         case 'lastUpdated':
                         case 'manual':
                             $sortField = 'lastUpdated';
                             break;
                         case 'tstamp':
                             $sortField = 'tstamp';
                             break;
                         case 'crdate':
                             $sortField = 'crdate';
                             break;
                         default:
                             $sortField = 'SYS_LASTCHANGED';
                     }
                     // Get
                     $extraWhere = ($this->conf['includeNotInMenu'] ? '' : ' AND pages.nav_hide=0') . $this->getDoktypeExcludeWhere();
                     if ($this->conf['special.']['excludeNoSearchPages']) {
                         $extraWhere .= ' AND pages.no_search=0';
                     }
                     if ($maxAge > 0) {
                         $extraWhere .= ' AND ' . $sortField . '>' . ($GLOBALS['SIM_ACCESS_TIME'] - $maxAge);
                     }
                     $res = $this->parent_cObj->exec_getQuery('pages', array('pidInList' => '0', 'uidInList' => $id_list, 'where' => $sortField . '>=0' . $extraWhere, 'orderBy' => $altSortFieldValue ? $altSortFieldValue : $sortField . ' desc', 'max' => $limit));
                     while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                         $GLOBALS['TSFE']->sys_page->versionOL('pages', $row, TRUE);
                         if (is_array($row)) {
                             $temp[$row['uid']] = $this->sys_page->getPageOverlay($row);
                         }
                     }
                     break;
                 case 'keywords':
                     list($value) = GeneralUtility::intExplode(',', $value);
                     if (!$value) {
                         $value = $GLOBALS['TSFE']->page['uid'];
                     }
                     if ($this->conf['special.']['setKeywords'] || $this->conf['special.']['setKeywords.']) {
                         $kw = isset($this->conf['special.']['setKeywords.']) ? $this->parent_cObj->stdWrap($this->conf['special.']['setKeywords'], $this->conf['special.']['setKeywords.']) : $this->conf['special.']['setKeywords'];
                     } else {
                         // The page record of the 'value'.
                         $value_rec = $this->sys_page->getPage($value);
                         $kfieldSrc = $this->conf['special.']['keywordsField.']['sourceField'] ? $this->conf['special.']['keywordsField.']['sourceField'] : 'keywords';
                         // keywords.
                         $kw = trim($this->parent_cObj->keywords($value_rec[$kfieldSrc]));
                     }
                     // *'auto', 'manual', 'tstamp'
                     $mode = $this->conf['special.']['mode'];
                     switch ($mode) {
                         case 'starttime':
                             $sortField = 'starttime';
                             break;
                         case 'lastUpdated':
                         case 'manual':
                             $sortField = 'lastUpdated';
                             break;
                         case 'tstamp':
                             $sortField = 'tstamp';
                             break;
                         case 'crdate':
                             $sortField = 'crdate';
                             break;
                         default:
                             $sortField = 'SYS_LASTCHANGED';
                     }
                     // Depth, limit, extra where
                     if (MathUtility::canBeInterpretedAsInteger($this->conf['special.']['depth'])) {
                         $depth = MathUtility::forceIntegerInRange($this->conf['special.']['depth'], 0, 20);
                     } else {
                         $depth = 20;
                     }
                     // Max number of items
                     $limit = MathUtility::forceIntegerInRange($this->conf['special.']['limit'], 0, 100);
                     $extraWhere = ' AND pages.uid<>' . $value . ($this->conf['includeNotInMenu'] ? '' : ' AND pages.nav_hide=0') . $this->getDoktypeExcludeWhere();
                     if ($this->conf['special.']['excludeNoSearchPages']) {
                         $extraWhere .= ' AND pages.no_search=0';
                     }
                     // Start point
                     $eLevel = $this->parent_cObj->getKey(isset($this->conf['special.']['entryLevel.']) ? $this->parent_cObj->stdWrap($this->conf['special.']['entryLevel'], $this->conf['special.']['entryLevel.']) : $this->conf['special.']['entryLevel'], $this->tmpl->rootLine);
                     $startUid = (int) $this->tmpl->rootLine[$eLevel]['uid'];
                     // Which field is for keywords
                     $kfield = 'keywords';
                     if ($this->conf['special.']['keywordsField']) {
                         list($kfield) = explode(' ', trim($this->conf['special.']['keywordsField']));
                     }
                     // If there are keywords and the startuid is present.
                     if ($kw && $startUid) {
                         $bA = MathUtility::forceIntegerInRange($this->conf['special.']['beginAtLevel'], 0, 100);
                         $id_list = $this->parent_cObj->getTreeList(-1 * $startUid, $depth - 1 + $bA, $bA - 1);
                         $kwArr = explode(',', $kw);
                         foreach ($kwArr as $word) {
                             $word = trim($word);
                             if ($word) {
                                 $keyWordsWhereArr[] = $kfield . ' LIKE \'%' . $GLOBALS['TYPO3_DB']->quoteStr($word, 'pages') . '%\'';
                             }
                         }
                         $res = $this->parent_cObj->exec_getQuery('pages', array('pidInList' => '0', 'uidInList' => $id_list, 'where' => '(' . implode(' OR ', $keyWordsWhereArr) . ')' . $extraWhere, 'orderBy' => $altSortFieldValue ? $altSortFieldValue : $sortField . ' desc', 'max' => $limit));
                         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                             $GLOBALS['TSFE']->sys_page->versionOL('pages', $row, TRUE);
                             if (is_array($row)) {
                                 $temp[$row['uid']] = $this->sys_page->getPageOverlay($row);
                             }
                         }
                     }
                     break;
                 case 'categories':
                     /** @var \TYPO3\CMS\Frontend\ContentObject\Menu\CategoryMenuUtility $categoryMenuUtility */
                     $categoryMenuUtility = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\Menu\\CategoryMenuUtility');
                     $temp = $categoryMenuUtility->collectPages($value, $this->conf['special.'], $this);
                     break;
                 case 'rootline':
                     $range = isset($this->conf['special.']['range.']) ? $this->parent_cObj->stdWrap($this->conf['special.']['range'], $this->conf['special.']['range.']) : $this->conf['special.']['range'];
                     $begin_end = explode('|', $range);
                     $begin_end[0] = (int) $begin_end[0];
                     if (!MathUtility::canBeInterpretedAsInteger($begin_end[1])) {
                         $begin_end[1] = -1;
                     }
                     $beginKey = $this->parent_cObj->getKey($begin_end[0], $this->tmpl->rootLine);
                     $endKey = $this->parent_cObj->getKey($begin_end[1], $this->tmpl->rootLine);
                     if ($endKey < $beginKey) {
                         $endKey = $beginKey;
                     }
                     $rl_MParray = array();
                     foreach ($this->tmpl->rootLine as $k_rl => $v_rl) {
                         // For overlaid mount points, set the variable right now:
                         if ($v_rl['_MP_PARAM'] && $v_rl['_MOUNT_OL']) {
                             $rl_MParray[] = $v_rl['_MP_PARAM'];
                         }
                         // Traverse rootline:
                         if ($k_rl >= $beginKey && $k_rl <= $endKey) {
                             $temp_key = $k_rl;
                             $temp[$temp_key] = $this->sys_page->getPage($v_rl['uid']);
                             if (count($temp[$temp_key])) {
                                 // If there are no specific target for the page, put the level specific target on.
                                 if (!$temp[$temp_key]['target']) {
                                     $temp[$temp_key]['target'] = $this->conf['special.']['targets.'][$k_rl];
                                     $temp[$temp_key]['_MP_PARAM'] = implode(',', $rl_MParray);
                                 }
                             } else {
                                 unset($temp[$temp_key]);
                             }
                         }
                         // For normal mount points, set the variable for next level.
                         if ($v_rl['_MP_PARAM'] && !$v_rl['_MOUNT_OL']) {
                             $rl_MParray[] = $v_rl['_MP_PARAM'];
                         }
                     }
                     // Reverse order of elements (e.g. "1,2,3,4" gets "4,3,2,1"):
                     if (isset($this->conf['special.']['reverseOrder']) && $this->conf['special.']['reverseOrder']) {
                         $temp = array_reverse($temp);
                         $rl_MParray = array_reverse($rl_MParray);
                     }
                     break;
                 case 'browse':
                     list($value) = GeneralUtility::intExplode(',', $value);
                     if (!$value) {
                         $value = $GLOBALS['TSFE']->page['uid'];
                     }
                     // Will not work out of rootline
                     if ($value != $this->tmpl->rootLine[0]['uid']) {
                         $recArr = array();
                         // The page record of the 'value'.
                         $value_rec = $this->sys_page->getPage($value);
                         // 'up' page cannot be outside rootline
                         if ($value_rec['pid']) {
                             // The page record of 'up'.
                             $recArr['up'] = $this->sys_page->getPage($value_rec['pid']);
                         }
                         // If the 'up' item was NOT level 0 in rootline...
                         if ($recArr['up']['pid'] && $value_rec['pid'] != $this->tmpl->rootLine[0]['uid']) {
                             // The page record of "index".
                             $recArr['index'] = $this->sys_page->getPage($recArr['up']['pid']);
                         }
                         // prev / next is found
                         $prevnext_menu = $this->removeInaccessiblePages($this->sys_page->getMenu($value_rec['pid'], '*', $altSortField));
                         $lastKey = 0;
                         $nextActive = 0;
                         foreach ($prevnext_menu as $k_b => $v_b) {
                             if ($nextActive) {
                                 $recArr['next'] = $v_b;
                                 $nextActive = 0;
                             }
                             if ($v_b['uid'] == $value) {
                                 if ($lastKey) {
                                     $recArr['prev'] = $prevnext_menu[$lastKey];
                                 }
                                 $nextActive = 1;
                             }
                             $lastKey = $k_b;
                         }
                         reset($prevnext_menu);
                         $recArr['first'] = pos($prevnext_menu);
                         end($prevnext_menu);
                         $recArr['last'] = pos($prevnext_menu);
                         // prevsection / nextsection is found
                         // You can only do this, if there is a valid page two levels up!
                         if (is_array($recArr['index'])) {
                             $prevnextsection_menu = $this->removeInaccessiblePages($this->sys_page->getMenu($recArr['index']['uid'], '*', $altSortField));
                             $lastKey = 0;
                             $nextActive = 0;
                             foreach ($prevnextsection_menu as $k_b => $v_b) {
                                 if ($nextActive) {
                                     $sectionRec_temp = $this->removeInaccessiblePages($this->sys_page->getMenu($v_b['uid'], '*', $altSortField));
                                     if (count($sectionRec_temp)) {
                                         reset($sectionRec_temp);
                                         $recArr['nextsection'] = pos($sectionRec_temp);
                                         end($sectionRec_temp);
                                         $recArr['nextsection_last'] = pos($sectionRec_temp);
                                         $nextActive = 0;
                                     }
                                 }
                                 if ($v_b['uid'] == $value_rec['pid']) {
                                     if ($lastKey) {
                                         $sectionRec_temp = $this->removeInaccessiblePages($this->sys_page->getMenu($prevnextsection_menu[$lastKey]['uid'], '*', $altSortField));
                                         if (count($sectionRec_temp)) {
                                             reset($sectionRec_temp);
                                             $recArr['prevsection'] = pos($sectionRec_temp);
                                             end($sectionRec_temp);
                                             $recArr['prevsection_last'] = pos($sectionRec_temp);
                                         }
                                     }
                                     $nextActive = 1;
                                 }
                                 $lastKey = $k_b;
                             }
                         }
                         if ($this->conf['special.']['items.']['prevnextToSection']) {
                             if (!is_array($recArr['prev']) && is_array($recArr['prevsection_last'])) {
                                 $recArr['prev'] = $recArr['prevsection_last'];
                             }
                             if (!is_array($recArr['next']) && is_array($recArr['nextsection'])) {
                                 $recArr['next'] = $recArr['nextsection'];
                             }
                         }
                         $items = explode('|', $this->conf['special.']['items']);
                         $c = 0;
                         foreach ($items as $k_b => $v_b) {
                             $v_b = strtolower(trim($v_b));
                             if ((int) $this->conf['special.'][$v_b . '.']['uid']) {
                                 $recArr[$v_b] = $this->sys_page->getPage((int) $this->conf['special.'][$v_b . '.']['uid']);
                             }
                             if (is_array($recArr[$v_b])) {
                                 $temp[$c] = $recArr[$v_b];
                                 if ($this->conf['special.'][$v_b . '.']['target']) {
                                     $temp[$c]['target'] = $this->conf['special.'][$v_b . '.']['target'];
                                 }
                                 $tmpSpecialFields = $this->conf['special.'][$v_b . '.']['fields.'];
                                 if (is_array($tmpSpecialFields)) {
                                     foreach ($tmpSpecialFields as $fk => $val) {
                                         $temp[$c][$fk] = $val;
                                     }
                                 }
                                 $c++;
                             }
                         }
                     }
                     break;
             }
             if ($this->mconf['sectionIndex']) {
                 $sectionIndexes = array();
                 foreach ($temp as $page) {
                     $sectionIndexes = $sectionIndexes + $this->sectionIndex($altSortField, $page['uid']);
                 }
                 $temp = $sectionIndexes;
             }
         } elseif (is_array($this->alternativeMenuTempArray)) {
             // Setting $temp array if not level 1.
             $temp = $this->alternativeMenuTempArray;
         } elseif ($this->mconf['sectionIndex']) {
             $temp = $this->sectionIndex($altSortField);
         } else {
             // Default:
             // gets the menu
             $temp = $this->sys_page->getMenu($this->id, '*', $altSortField);
         }
         $c = 0;
         $c_b = 0;
         $minItems = (int) ($this->mconf['minItems'] ?: $this->conf['minItems']);
         $maxItems = (int) ($this->mconf['maxItems'] ?: $this->conf['maxItems']);
         $begin = $this->parent_cObj->calc($this->mconf['begin'] ? $this->mconf['begin'] : $this->conf['begin']);
         $minItemsConf = isset($this->mconf['minItems.']) ? $this->mconf['minItems.'] : (isset($this->conf['minItems.']) ? $this->conf['minItems.'] : NULL);
         $minItems = is_array($minItemsConf) ? $this->parent_cObj->stdWrap($minItems, $minItemsConf) : $minItems;
         $maxItemsConf = isset($this->mconf['maxItems.']) ? $this->mconf['maxItems.'] : (isset($this->conf['maxItems.']) ? $this->conf['maxItems.'] : NULL);
         $maxItems = is_array($maxItemsConf) ? $this->parent_cObj->stdWrap($maxItems, $maxItemsConf) : $maxItems;
         $beginConf = isset($this->mconf['begin.']) ? $this->mconf['begin.'] : (isset($this->conf['begin.']) ? $this->conf['begin.'] : NULL);
         $begin = is_array($beginConf) ? $this->parent_cObj->stdWrap($begin, $beginConf) : $begin;
         $banUidArray = $this->getBannedUids();
         // Fill in the menuArr with elements that should go into the menu:
         $this->menuArr = array();
         foreach ($temp as $data) {
             $spacer = GeneralUtility::inList($this->spacerIDList, $data['doktype']) || $data['ITEM_STATE'] === 'SPC' ? 1 : 0;
             // if item is a spacer, $spacer is set
             if ($this->filterMenuPages($data, $banUidArray, $spacer)) {
                 $c_b++;
                 // If the beginning item has been reached.
                 if ($begin <= $c_b) {
                     $this->menuArr[$c] = $data;
                     $this->menuArr[$c]['isSpacer'] = $spacer;
                     $c++;
                     if ($maxItems && $c >= $maxItems) {
                         break;
                     }
                 }
             }
         }
         // Fill in fake items, if min-items is set.
         if ($minItems) {
             while ($c < $minItems) {
                 $this->menuArr[$c] = array('title' => '...', 'uid' => $GLOBALS['TSFE']->id);
                 $c++;
             }
         }
         //	Passing the menuArr through a user defined function:
         if ($this->mconf['itemArrayProcFunc']) {
             if (!is_array($this->parentMenuArr)) {
                 $this->parentMenuArr = array();
             }
             $this->menuArr = $this->userProcess('itemArrayProcFunc', $this->menuArr);
         }
         // Setting number of menu items
         $GLOBALS['TSFE']->register['count_menuItems'] = count($this->menuArr);
         $this->hash = md5(serialize($this->menuArr) . serialize($this->mconf) . serialize($this->tmpl->rootLine) . serialize($this->MP_array));
         // Get the cache timeout:
         if ($this->conf['cache_period']) {
             $cacheTimeout = $this->conf['cache_period'];
         } else {
             $cacheTimeout = $GLOBALS['TSFE']->get_cache_timeout();
         }
         $cache = $this->getCache();
         $cachedData = $cache->get($this->hash);
         if (!is_array($cachedData)) {
             $this->generate();
             $cache->set($this->hash, $this->result, array('ident_MENUDATA'), (int) $cacheTimeout);
         } else {
             $this->result = $cachedData;
         }
         // End showAccessRestrictedPages
         if ($this->mconf['showAccessRestrictedPages']) {
             // RESTORING where_groupAccess
             $this->sys_page->where_groupAccess = $SAVED_where_groupAccess;
         }
     }
 }
Exemplo n.º 12
0
 /**
  * @return array
  */
 protected function loadLanguageRecordsFromDatabase()
 {
     $cObj = new ContentObjectRenderer();
     $GLOBALS['TSFE'] = new TypoScriptFrontendController($GLOBALS['TYPO3_CONF_VARS'], 0, 0);
     $GLOBALS['TSFE']->sys_page = new PageRepository();
     $select = 'flag';
     $from = 'sys_language';
     $where = '1=1' . $cObj->enableFields('sys_language');
     $sysLanguages = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($select, $from, $where);
     return (array) $sysLanguages;
 }
Exemplo n.º 13
0
 /**
  * Determines whether the URL matches a domain
  * in the sys_domain databse table.
  *
  * @param string $url Absolute URL which needs to be checked
  * @return boolean Whether the URL is considered to be local
  */
 protected function isInLocalDomain($url)
 {
     $result = FALSE;
     if (\TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl($url)) {
         $parsedUrl = parse_url($url);
         if ($parsedUrl['scheme'] === 'http' || $parsedUrl['scheme'] === 'https') {
             $host = $parsedUrl['host'];
             // Removes the last path segment and slash sequences like /// (if given):
             $path = preg_replace('#/+[^/]*$#', '', $parsedUrl['path']);
             $cObj = new ContentObjectRenderer();
             $localDomains = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('domainName', 'sys_domain', '1=1' . $cObj->enableFields('sys_domain'));
             if (is_array($localDomains)) {
                 foreach ($localDomains as $localDomain) {
                     // strip trailing slashes (if given)
                     $domainName = rtrim($localDomain['domainName'], '/');
                     if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($host . $path . '/', $domainName . '/')) {
                         $result = TRUE;
                         break;
                     }
                 }
             }
         }
     }
     return $result;
 }
Exemplo n.º 14
0
 /**
  * Determines all registered users who were online since a certain point of time.
  * @author Martin Helmich <*****@*****.**>
  * @param  integer $time         The point of time, since when the users are to be counted.
  * @param  boolean $sesBackcheck Determines, of the user status is to be checked by session data.
  * @param  boolean $postCount    Determines, if the amount of posts created since $time is to be determined (can be
  *                               quite time-expensive)
  * @return array                 An array containing information on users who were online today.
  */
 function getUsersFromTime($time, $sesBackcheck = FALSE, $postCount = TRUE)
 {
     $result = array('users', 'mods', "admins", 'count');
     if (!ExtensionManagementUtility::isLoaded('sys_stat')) {
         $sesBackcheck = TRUE;
     }
     $grp_admin = array($this->getAdministratorGroup());
     $grp_mod = $this->getModeratorGroups();
     if ($sesBackcheck) {
         $res = $this->databaseHandle->exec_SELECTquery('u.usergroup, u.' . $this->tx_mmforum_pi1->getUserNameField() . ', u.uid', 'fe_users u, fe_sessions s', 's.ses_tstamp >= "' . $time . '" AND u.deleted=0 AND u.disable=0 AND u.uid=s.ses_userid ' . $this->getUserPidQuery('u'), 'ses_userid', 'username ASC');
     } else {
         $res = $this->databaseHandle->exec_SELECTquery('u.usergroup, u.' . $this->tx_mmforum_pi1->getUserNameField() . ', u.uid', 'fe_users u, sys_stat s', 's.feuser_id != "0" AND u.uid = s.feuser_id AND s.tstamp >= "' . $time . '" ' . $this->getUserPidQuery('u'), 'feuser_id');
     }
     while ($arr = $this->databaseHandle->sql_fetch_assoc($res)) {
         if ($postCount) {
             $res2 = $this->databaseHandle->exec_SELECTquery('COUNT(*)', 'tx_mmforum_posts', 'poster_id="' . $arr['uid'] . '" AND post_time >= "' . $time . '"' . $this->cObj->enableFields('tx_mmforum_posts') . ' ' . $this->getStoragePIDQuery());
             $arr2 = $this->databaseHandle->sql_fetch_row($res2);
             $arr['postCount'] = $arr2[0];
         }
         $user_groups = GeneralUtility::intExplode(',', $arr['usergroup']);
         if (count(array_intersect($user_groups, $grp_mod)) > 0) {
             $result['mods'][] = $arr;
         } elseif (count(array_intersect($user_groups, $grp_admin)) > 0) {
             $result['admins'][] = $arr;
         } else {
             $result['users'][] = $arr;
         }
     }
     $result['count'] = $this->databaseHandle->sql_num_rows($res);
     return $result;
 }
Exemplo n.º 15
0
 /**
  * Displays the form for creating a new post an answer to an existing topic.
  * @param  string $content The plugin content
  * @param  array  $conf    The plugin's configuration vars
  * @return string          The content
  */
 function new_post($content, $conf)
 {
     $loginUser = $GLOBALS['TSFE']->loginUser;
     $topicId = intval($this->piVars['tid']);
     $topicData = $this->getTopicData($topicId);
     $forumId = $topicData['forum_id'];
     if ($loginUser && $this->get_topic_is($topicId) == 0 || $loginUser && $this->getIsModOrAdmin($forumId)) {
         if (!$this->getMayWrite_topic($topicId)) {
             return $content . $this->errorMessage($conf, $this->pi_getLL('newTopic.noAccess'));
         }
         if ($this->piVars['button'] == $this->pi_getLL('newPost.save')) {
             if (!$this->piVars['message']) {
                 $content .= $this->errorMessage($this->conf, $this->pi_getLL('newTopic.noText'));
                 unset($this->piVars['button']);
                 return $this->new_post($content, $conf);
             }
             //Check CSRF Attacks
             if ($GLOBALS["TSFE"]->fe_user->getKey('ses', "token") != $this->piVars['token'] || $this->piVars['token'] == false) {
                 $content .= $this->errorMessage($this->conf, $this->pi_getLL('newPost.quote.error'));
                 unset($this->piVars['button']);
                 return $this->new_post($content, $conf);
             }
             // Checks if the current user has already written a post in a certain interval
             // from now on. If so, the write attempt is blocked for security reasons.
             $interval = $conf['spamblock_interval'];
             $time = $GLOBALS['EXEC_TIME'] - $interval;
             $res = $this->databaseHandle->exec_SELECTquery('*', 'tx_mmforum_posts', 'poster_id=' . $this->getUserID() . ' AND post_time>=' . $time . $this->cObj->enableFields('tx_mmforum_posts'));
             if ($this->databaseHandle->sql_num_rows($res) > 0) {
                 $template = $this->cObj->fileResource($conf['template.']['login_error']);
                 $template = $this->cObj->getSubpart($template, "###LOGINERROR###");
                 $marker = array();
                 $llMarker = array('###SPAMBLOCK###' => $interval);
                 $marker['###LOGINERROR_MESSAGE###'] = $this->cObj->substituteMarkerArray($this->pi_getLL('newPost.spamBlock'), $llMarker);
                 $content .= $this->cObj->substituteMarkerArrayCached($template, $marker);
                 return $content;
             }
             // Create a topic subscription if the user checked the regarding checkbox.
             if ($this->piVars['havealook']) {
                 tx_mmforum_havealook::addSubscription($this, $topicId, $this->getUserID());
             }
             // Check file upload
             if ($_FILES['tx_mmforum_pi1_attachment_1']['size'] > 0) {
                 $res = $this->performAttachmentUpload();
                 if (!is_array($res)) {
                     $content .= $res;
                     unset($this->piVars['button']);
                     return $this->new_post($content, $conf);
                 } else {
                     $attachment_ids = $res;
                 }
             } else {
                 $attachment_ids = 0;
             }
             // Instantiate postfactory class
             $postfactory = GeneralUtility::makeInstance('tx_mmforum_postfactory');
             $postfactory->init($this->conf, $this);
             if ($this->isModeratedForum() && !$this->getIsAdmin() && !$this->getIsMod($this->piVars['fid'])) {
                 // Create post using postfactory
                 $postfactory->create_post_queue($topicId, $this->getUserID(), $this->piVars['message'], $GLOBALS['EXEC_TIME'], $this->tools->ip2hex(GeneralUtility::getIndpEnv("REMOTE_ADDR")), $attachment_ids);
                 return $this->successMessage($conf, $this->pi_getLL('postqueue-success'));
             } else {
                 // Create post using postfactory
                 $postId = $postfactory->create_post($topicId, $this->getUserID(), $this->piVars['message'], $GLOBALS['EXEC_TIME'], $this->tools->ip2hex(GeneralUtility::getIndpEnv("REMOTE_ADDR")), $attachment_ids, false, $this->piVars['havealook'] == 'havealook');
                 // Redirect user to new post
                 $linkParams = array('tx_mmforum_pi1[action]' => 'list_post', 'tx_mmforum_pi1[tid]' => $topicId, 'tx_mmforum_pi1[pid]' => $postId);
                 if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['newPost_linkParams'])) {
                     foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['newPost_linkParams'] as $classRef) {
                         $procObj =& GeneralUtility::getUserObj($classRef);
                         $linkParams = $procObj->newPost_linkParams($linkParams, $this);
                     }
                 }
                 $link = $this->pi_getPageLink($GLOBALS['TSFE']->id, '', $linkParams);
                 HttpUtility::redirect($link . '#pid' . $postId);
             }
         } else {
             $this->generateToken();
             // Show post preview
             if ($this->piVars['button'] == $this->pi_getLL('newPost.preview')) {
                 $template = $this->cObj->fileResource($conf['template.']['list_post']);
                 $template = $this->cObj->getSubpart($template, '###LIST_POSTS###');
                 $template = $this->cObj->substituteSubpart($template, '###ATTACHMENT_SECTION###', '');
                 $userSignature = $this->tx_mmforum_postfunctions->marker_getUserSignature($GLOBALS['TSFE']->fe_user->user);
                 $posttext = $this->piVars['message'];
                 $posttext = $this->tx_mmforum_postparser->main($this, $conf, $posttext, 'textparser') . ($this->conf['list_posts.']['appendSignatureToPostText'] ? $userSignature : '');
                 $marker['###POSTOPTIONS###'] = '';
                 $marker['###MESSAGEMENU###'] = '';
                 $marker['###PROFILEMENU###'] = '';
                 $marker['###POSTMENU###'] = '';
                 $marker['###POSTUSER###'] = $this->ident_user($this->getUserID(), $conf);
                 $marker['###POSTTEXT###'] = $posttext;
                 $marker['###ANKER###'] = '';
                 $marker['###POSTANCHOR###'] = '';
                 $marker['###POSTDATE###'] = $this->pi_getLL('post.writtenOn') . ': ' . $this->formatDate($GLOBALS['EXEC_TIME']);
                 $marker['###POSTRATING###'] = '';
                 // Include hooks
                 if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['newPost_INpreview'])) {
                     foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['newPost_INpreview'] as $classRef) {
                         $procObj =& GeneralUtility::getUserObj($classRef);
                         $marker = $procObj->newPost_INpreview($marker, $this);
                     }
                 }
                 $previewTemplate = $this->cObj->fileResource($conf['template.']['new_post']);
                 $previewTemplate = $this->cObj->getSubpart($previewTemplate, "###PREVIEW###");
                 $previewMarker = array('###LABEL_PREVIEW###' => $this->pi_getLL('newPost.preview'), '###PREVIEW_POST###' => $this->cObj->substituteMarkerArrayCached($template, $marker));
                 // Include hooks
                 if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['newPost_preview'])) {
                     foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['newPost_preview'] as $classRef) {
                         $procObj =& GeneralUtility::getUserObj($classRef);
                         $previewMarker = $procObj->newPost_preview($previewMarker, $this);
                     }
                 }
                 $previewContent = $this->cObj->substituteMarkerArrayCached($previewTemplate, $previewMarker);
             }
             $template = $this->cObj->fileResource($conf['template.']['new_post']);
             $template = $this->cObj->getSubpart($template, stristr($template, '###NEWTOPIC###') === false ? '###NEWPOST###' : '###NEWTOPIC###');
             // compatibility: typo in template file fixed. was 'NEWTOPIC'
             $marker = array('###LABEL_SEND###' => $this->pi_getLL('newPost.save'), '###LABEL_PREVIEW###' => $this->pi_getLL('newPost.preview'), '###LABEL_RESET###' => $this->pi_getLL('newPost.reset'), '###LABEL_ATTENTION###' => $this->pi_getLL('newPost.attention'), '###LABEL_NOTECODESAMPLES###' => $this->pi_getLL('newPost.codeSamples'), '###LABEL_ATTACHMENT###' => $this->pi_getLL('newPost.attachment'), '###LABEL_SETHAVEALOOK###' => $this->pi_getLL('newTopic.setHaveALook'), '###TOKEN###' => $GLOBALS["TSFE"]->fe_user->getKey('ses', "token"));
             $marker['###POSTTITLE###'] = $this->escape($topicData['topic_title']);
             $marker['###POST_PREVIEW###'] = (string) $previewContent;
             // Remove file attachment section if file attachments are disabled
             if (!$this->conf['attachments.']['enable']) {
                 $template = $this->cObj->substituteSubpart($template, "###ATTACHMENT_SECTION###", '');
             }
             // Remove file attachment edit section
             $template = $this->cObj->substituteSubpart($template, '###ATTACHMENT_EDITSECTION###', '');
             // Add attachment input fields according to TypoScript setting
             $fieldCount = $this->conf['attachments.']['maxCount'] ? $this->conf['attachments.']['maxCount'] : 1;
             $aTemplate = $this->cObj->getSubpart($template, '###ATTACHMENT_FIELD###');
             $aContent = '';
             for ($i = 1; $i <= $fieldCount; $i++) {
                 $aMarker = array('###ATTACHMENT_NO###' => $i);
                 $aContent .= $this->cObj->substituteMarkerArray($aTemplate, $aMarker);
             }
             $template = $this->cObj->substituteSubpart($template, '###ATTACHMENT_FIELD###', $aContent);
             // Remove poll section
             $template = $this->cObj->substituteSubpart($template, '###POLL_SECTION###', '');
             // Maximum file size
             $mFileSize = $this->conf['attachments.']['maxFileSize'] . ' B';
             if ($this->conf['attachments.']['maxFileSize'] >= 1024) {
                 $mFileSize = round($this->conf['attachments.']['maxFileSize'] / 1024, 2) . ' KB';
             }
             if ($this->conf['attachments.']['maxFileSize'] >= 1024 * 1024) {
                 $mFileSize = round($this->conf['attachments.']['maxFileSize'] / (1024 * 1024), 2) . ' MB';
             }
             $marker['###MAXFILESIZE_TEXT###'] = sprintf($this->pi_getLL('newPost.maxFileSize'), $mFileSize);
             $marker['###MAXFILESIZE_TEXT###'] = $this->cObj->stdWrap($marker['###MAXFILESIZE_TEXT###'], $this->conf['attachments.']['maxFileSize_stdWrap.']);
             $marker['###MAXFILESIZE###'] = $this->conf['attachments.']['maxFileSize'];
             // Inserting predefined message
             if ($this->piVars['message']) {
                 $marker['###POSTTEXT###'] = $this->escape($this->piVars['message']);
             } else {
                 // Load post to be quoted
                 if ($this->piVars['quote']) {
                     if (!$this->getMayRead_post($this->piVars['quote'])) {
                         return $content . $this->errorMessage($conf, $this->pi_getLL('newPost.quote.error'));
                     }
                     // Get user UID of quoted user
                     $res = $this->databaseHandle->exec_SELECTquery('poster_id', 'tx_mmforum_posts', 'uid=' . intval($this->piVars['quote']));
                     list($quoteuserid) = $this->databaseHandle->sql_fetch_row($res);
                     // Get user name of quoted user
                     $quoteuser_array = tx_mmforum_tools::get_userdata($quoteuserid);
                     $quoteuser = $quoteuser_array[$this->getUserNameField()];
                     // Get text to be quoted
                     $res = $this->databaseHandle->exec_SELECTquery('post_text', 'tx_mmforum_posts_text', 'post_id=' . intval($this->piVars['quote']));
                     list($posttext) = $this->databaseHandle->sql_fetch_row($res);
                     // Insert quote into message text.
                     $marker['###POSTTEXT###'] = '[quote="' . $quoteuser . '"]' . "\r\n" . $posttext . "\r\n" . '[/quote]';
                 } else {
                     $marker['###POSTTEXT###'] = '';
                 }
             }
             $actionParams[$this->prefixId] = array('action' => 'new_post', 'tid' => $this->piVars['tid']);
             if ($this->useRealUrl()) {
                 $actionParams[$this->prefixId]['fid'] = $forumId;
             }
             $actionLink = $this->pi_getPageLink($GLOBALS['TSFE']->id, '', $actionParams);
             $bbCodeButtons_template = $this->cObj->getSubpart($template, '###BBCODEBUTTONS###');
             if (empty($conf['jQueryEditorJavaScript'])) {
                 $bbCodeButtons = $this->generateBBCodeButtons($bbCodeButtons_template);
             } else {
                 $bbCodeButtons = stristr($bbCodeButtons_template, '<td>') ? '<td></td>' : '';
             }
             $template = $this->cObj->substituteSubpart($template, '###BBCODEBUTTONS###', $bbCodeButtons);
             $marker['###SMILIES###'] = $this->show_smilie_db($conf);
             $marker['###ACTION###'] = htmlspecialchars($actionLink);
             $marker['###LABEL_CREATETOPIC###'] = $this->pi_getLL('newPost.title');
             $marker['###TOKEN###'] = $GLOBALS["TSFE"]->fe_user->getKey('ses', "token");
             $conf['slimPostList'] = 1;
             $marker['###OLDPOSTTEXT###'] = '<hr />' . $this->tx_mmforum_postfunctions->list_post('', $conf, 'DESC');
             if ($this->conf['disableRootline']) {
                 $template = $this->cObj->substituteSubpart($template, '###ROOTLINE_CONTAINER###', '');
             } else {
                 $marker['###FORUMPATH###'] = $this->get_forum_path($forumId, '');
             }
         }
     } else {
         $template = $this->cObj->fileResource($conf['template.']['login_error']);
         $template = $this->cObj->getSubpart($template, "###LOGINERROR###");
         $marker = array('###LOGINERROR_MESSAGE###' => $this->pi_getLL('newPost.noLogin'));
     }
     // Include hooks
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['newPost_formMarker'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['newPost_formMarker'] as $classRef) {
             $procObj =& GeneralUtility::getUserObj($classRef);
             $marker = $procObj->newPost_formMarker($marker, $this);
         }
     }
     $marker['###HAVEALOOK###'] = $this->piVars['havealook'] ? 'checked="checked"' : '';
     // TODO: include this via TYPO3 API
     $marker['###STARTJAVASCRIPT###'] = $this->includeEditorJavaScript();
     $content .= $this->cObj->substituteMarkerArray($template, $marker);
     return $content;
 }