Exemple #1
0
 /**
  * Check if the note plugin expects output. If there are no sys_note records on the given
  * pages, the extbase bootstrap doesn't have to run the complete plugin.
  * This mechanism should increase the performance of the hooked backend modules heavily.
  *
  * @param array $arguments Arguments for the extbase plugin
  * @return bool
  */
 protected function expectOutput(array $arguments = array())
 {
     // no pids set
     if (!isset($arguments['pids']) || empty($arguments['pids']) || empty($GLOBALS['BE_USER']->user['uid'])) {
         return false;
     }
     $pidList = $this->databaseConnection->cleanIntList($arguments['pids']);
     if (empty($pidList)) {
         return false;
     }
     // check if there are records
     return $this->databaseConnection->exec_SELECTcountRows('*', 'sys_note', 'pid IN (' . $pidList . ')' . BackendUtility::deleteClause('sys_note')) > 0;
 }
 /**
  * Login FE-User after creation
  *
  * @param \SLUB\Vk2\Domain\Model\User $user
  * @return void
  */
 protected function loginAfterCreate(\SLUB\Vk2\Domain\Model\User $user)
 {
     $GLOBALS['TSFE']->fe_user->checkPid = FALSE;
     $info = $GLOBALS['TSFE']->fe_user->getAuthInfoArray();
     $pids = $this->vk2Config['persistence']['storagePid'];
     $extraWhere = ' AND pid IN (' . $this->databaseConnection->cleanIntList($pids) . ')';
     $user = $GLOBALS['TSFE']->fe_user->fetchUserRecord($info['db_user'], $user->getUsername(), $extraWhere);
     //DebuggerUtility::var_dump($user);
     $GLOBALS['TSFE']->fe_user->createUserSession($user);
     $GLOBALS['TSFE']->fe_user->user = $GLOBALS['TSFE']->fe_user->fetchUserSession();
     // enforce session so we get a FE cookie, otherwise autologin does not work (TYPO3 6.2.5+)
     $GLOBALS['TSFE']->fe_user->setAndSaveSessionData('dummy', TRUE);
 }
 public function initAuth($mode, $loginData, $authInfo, $pObj)
 {
     $this->singleSignOnUtility = $this->objectManager->get('Portrino\\PxHybridAuth\\Utility\\SingleSignOnUtility');
     if (isset($_REQUEST['pid'])) {
         $this->db_user['check_pid_clause'] = ' AND pid IN (' . $this->db->cleanIntList($_REQUEST['pid']) . ')';
     }
     if (isset($_REQUEST['tx_pxhybridauth_login']['redirect_url'])) {
         $this->redirectUrl = $_REQUEST['tx_pxhybridauth_login']['redirect_url'];
     }
     if (isset($_REQUEST['tx_pxhybridauth_login']['redirect_pid'])) {
         $this->redirectPid = $_REQUEST['tx_pxhybridauth_login']['redirect_pid'];
     }
     if (isset($_REQUEST['tx_pxhybridauth_login']['provider'])) {
         $this->provider = $_REQUEST['tx_pxhybridauth_login']['provider'];
     }
     parent::initAuth($mode, $loginData, $authInfo, $pObj);
 }
    /**
     * @param \GeorgRinger\News\Domain\Model\News $news
     * @param $pidList
     * @param $sortField
     * @return array
     */
    protected function getNeighbours(\GeorgRinger\News\Domain\Model\News $news, $pidList, $sortField)
    {
        $pidList = empty($pidList) ? $news->getPid() : $pidList;
        $select = 'SELECT tx_news_domain_model_news.uid,tx_news_domain_model_news.title ';
        $from = 'FROM tx_news_domain_model_news';
        $whereClause = 'tx_news_domain_model_news.pid IN(' . $this->databaseConnection->cleanIntList($pidList) . ') ' . $this->getEnableFieldsWhereClauseForTable();
        $query = $select . $from . '
					WHERE ' . $whereClause . ' && ' . $sortField . ' >= (SELECT MAX(' . $sortField . ')
						' . $from . '
					WHERE ' . $whereClause . ' AND ' . $sortField . ' < (SELECT ' . $sortField . '
						FROM tx_news_domain_model_news
						WHERE tx_news_domain_model_news.uid = ' . $news->getUid() . '))
					ORDER BY ' . $sortField . ' ASC
					LIMIT 3';
        $query2 = $select . $from . '
			WHERE ' . $whereClause . ' AND ' . $sortField . '= (SELECT MIN(' . $sortField . ')
				FROM tx_news_domain_model_news
				WHERE ' . $whereClause . ' AND ' . $sortField . ' >
					(SELECT ' . $sortField . '
					FROM tx_news_domain_model_news
					WHERE tx_news_domain_model_news.uid = ' . $news->getUid() . '))
			';
        $res = $this->databaseConnection->sql_query($query);
        $out = array();
        while ($row = $this->databaseConnection->sql_fetch_assoc($res)) {
            $out[] = $row;
        }
        $this->databaseConnection->sql_free_result($res);
        if (count($out) === 0) {
            $res = $this->databaseConnection->sql_query($query2);
            while ($row = $this->databaseConnection->sql_fetch_assoc($res)) {
                $out[] = $row;
            }
            $this->databaseConnection->sql_free_result($res);
            return $out;
        }
        return $out;
    }
Exemple #5
0
 /**
  * Initialize fe_user object
  *
  * @param array $userdata
  *
  * @return void
  */
 protected function initFrontendEuser(array $userdata)
 {
     /** @var $feUser \TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication */
     $feUser = $this->objectManager->get(\TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication::class);
     $feUser->lockIP = $GLOBALS['TYPO3_CONF_VARS']['FE']['lockIP'];
     $feUser->checkPid = $GLOBALS['TYPO3_CONF_VARS']['FE']['checkFeUserPid'];
     $feUser->lifetime = intval($GLOBALS['TYPO3_CONF_VARS']['FE']['lifetime']);
     // List of pid's acceptable
     $feUser->checkPid_value = $this->database->cleanIntList(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('pid'));
     if ($GLOBALS['TYPO3_CONF_VARS']['FE']['dontSetCookie']) {
         $feUser->dontSetCookie = 1;
     }
     $feUser->start();
     $feUser->unpack_uc('');
     $feUser->fetchSessionData();
     $userdata[$feUser->lastLogin_column] = $GLOBALS['EXEC_TIME'];
     $userdata['is_online'] = $GLOBALS['EXEC_TIME'];
     $feUser->user = $userdata;
     $GLOBALS['TSFE']->fe_user =& $feUser;
     $this->updateLastLogin($feUser);
     $feUser->setKey('ses', 'SfRegisterAutoLoginUser', true);
     $this->signalSlotDispatcher->dispatch(__CLASS__, 'save', array('frontend' => &$GLOBALS['TSFE']));
 }
 /**
  * Returns an info array which provides additional information for auth services
  *
  * @return array
  * @internal
  * @todo Define visibility
  */
 public function getAuthInfoArray()
 {
     $authInfo = array();
     $authInfo['loginType'] = $this->loginType;
     $authInfo['refInfo'] = parse_url(GeneralUtility::getIndpEnv('HTTP_REFERER'));
     $authInfo['HTTP_HOST'] = GeneralUtility::getIndpEnv('HTTP_HOST');
     $authInfo['REMOTE_ADDR'] = GeneralUtility::getIndpEnv('REMOTE_ADDR');
     $authInfo['REMOTE_HOST'] = GeneralUtility::getIndpEnv('REMOTE_HOST');
     $authInfo['showHiddenRecords'] = $this->showHiddenRecords;
     // Can be overidden in localconf by SVCONF:
     $authInfo['db_user']['table'] = $this->user_table;
     $authInfo['db_user']['userid_column'] = $this->userid_column;
     $authInfo['db_user']['username_column'] = $this->username_column;
     $authInfo['db_user']['userident_column'] = $this->userident_column;
     $authInfo['db_user']['usergroup_column'] = $this->usergroup_column;
     $authInfo['db_user']['enable_clause'] = $this->user_where_clause();
     if ($this->checkPid && $this->checkPid_value !== NULL) {
         $authInfo['db_user']['checkPidList'] = $this->checkPid_value;
         $authInfo['db_user']['check_pid_clause'] = ' AND pid IN (' . $this->db->cleanIntList($this->checkPid_value) . ')';
     } else {
         $authInfo['db_user']['checkPidList'] = '';
         $authInfo['db_user']['check_pid_clause'] = '';
     }
     $authInfo['db_groups']['table'] = $this->usergroup_table;
     return $authInfo;
 }
 /**
  * Login FE-User after creation
  *
  * @param User $user
  * @return void
  */
 protected function loginAfterCreate($user)
 {
     if ($this->config['new.']['login'] != 1) {
         return;
     }
     $GLOBALS['TSFE']->fe_user->checkPid = FALSE;
     $info = $GLOBALS['TSFE']->fe_user->getAuthInfoArray();
     $pids = $this->allConfig['persistence']['storagePid'];
     $extraWhere = ' AND pid IN (' . $this->databaseConnection->cleanIntList($pids) . ')';
     $user = $GLOBALS['TSFE']->fe_user->fetchUserRecord($info['db_user'], $user->getUsername(), $extraWhere);
     $GLOBALS['TSFE']->fe_user->createUserSession($user);
     $GLOBALS['TSFE']->fe_user->user = $GLOBALS['TSFE']->fe_user->fetchUserSession();
     // add login flashmessage
     $this->addFlashMessage(LocalizationUtility::translate('login', 'femanager'), '', FlashMessage::NOTICE);
 }
 /**
  * @test
  *
  * @return void
  */
 public function cleanIntListReturnsCleanedString()
 {
     $str = '234,-434,4.3,0, 1';
     $result = $this->subject->cleanIntList($str);
     $this->assertSame('234,-434,4,0,1', $result);
 }
    /**
     * build the selectconf (array of query-parameters) to get the news items from the db
     *
     * @param	string		$addwhere : where-part of the query
     * @param	int		$noPeriod : if this value exists the listing starts with the given 'period start' (pS). If not the value period start needs also a value for 'period length' (pL) to display something.
     * @return	array		the selectconf for the display of a news item
     */
    function getSelectConf($addwhere, $noPeriod = 0)
    {
        if ($this->debugTimes) {
            $this->hObj->getParsetime(__METHOD__);
        }
        // Get news
        $selectConf = array();
        $selectConf['pidInList'] = $this->pid_list;
        $selectConf['where'] = '';
        $selectConf['where'] .= ' 1=1 ';
        if ($this->debugTimes) {
            $this->hObj->getParsetime(__METHOD__);
        }
        if ($this->arcExclusive) {
            if ($this->conf['enableArchiveDate'] && $this->config['datetimeDaysToArchive'] && $this->arcExclusive > 0) {
                $theTime = $this->SIM_ACCESS_TIME - intval($this->config['datetimeDaysToArchive']) * 3600 * 24;
                if (version_compare($this->conf['compatVersion'], '2.5.0') <= 0) {
                    $selectConf['where'] .= ' AND (tt_news.archivedate<' . $this->SIM_ACCESS_TIME . ' OR tt_news.datetime<' . $theTime . ')';
                } else {
                    $selectConf['where'] .= ' AND ((tt_news.archivedate > 0 AND tt_news.archivedate<' . $this->SIM_ACCESS_TIME . ') OR tt_news.datetime<' . $theTime . ')';
                }
            } else {
                if ($this->conf['enableArchiveDate']) {
                    if ($this->arcExclusive < 0) {
                        // show archived
                        $selectConf['where'] .= ' AND (tt_news.archivedate=0 OR tt_news.archivedate>' . $this->SIM_ACCESS_TIME . ')';
                    } elseif ($this->arcExclusive > 0) {
                        if (version_compare($this->conf['compatVersion'], '2.5.0') <= 0) {
                            $selectConf['where'] .= ' AND tt_news.archivedate<' . $this->SIM_ACCESS_TIME;
                        } else {
                            $selectConf['where'] .= ' AND tt_news.archivedate>0 AND tt_news.archivedate<' . $this->SIM_ACCESS_TIME;
                        }
                    }
                }
                if ($this->config['datetimeMinutesToArchive'] || $this->config['datetimeHoursToArchive'] || $this->config['datetimeDaysToArchive']) {
                    if ($this->config['datetimeMinutesToArchive']) {
                        $theTime = $this->SIM_ACCESS_TIME - intval($this->config['datetimeMinutesToArchive']) * 60;
                    } elseif ($this->config['datetimeHoursToArchive']) {
                        $theTime = $this->SIM_ACCESS_TIME - intval($this->config['datetimeHoursToArchive']) * 3600;
                    } else {
                        $theTime = $this->SIM_ACCESS_TIME - intval($this->config['datetimeDaysToArchive']) * 86400;
                    }
                    if ($this->arcExclusive < 0) {
                        $selectConf['where'] .= ' AND (tt_news.datetime=0 OR tt_news.datetime>' . $theTime . ')';
                    } elseif ($this->arcExclusive > 0) {
                        $selectConf['where'] .= ' AND tt_news.datetime<' . $theTime;
                    }
                }
            }
        }
        if ($this->debugTimes) {
            $this->hObj->getParsetime(__METHOD__);
        }
        if (!$this->externalCategorySelection) {
            // exclude LATEST and AMENU from changing their contents with the catmenu. This can be overridden by setting the TSvars 'latestWithCatSelector' or 'amenuWithCatSelector'
            if ($this->config['catSelection'] && ($this->theCode == 'LATEST' && $this->conf['latestWithCatSelector'] || $this->theCode == 'AMENU' && $this->conf['amenuWithCatSelector'] || \TYPO3\CMS\Core\Utility\GeneralUtility::inList('LIST,LIST2,LIST3,HEADER_LIST,SEARCH,XML', $this->theCode))) {
                // force 'select categories' mode if cat is given in GPvars
                $this->config['categoryMode'] = 1;
                // override category selection from other news content-elements with selection from catmenu (GPvars)
                $this->catExclusive = $this->config['catSelection'];
                $this->actuallySelectedCategories = $this->piVars_catSelection;
            }
            if ($this->catExclusive) {
                // select newsitems by their categories
                if ($this->config['categoryMode'] == 1 || $this->config['categoryMode'] == 2) {
                    // show items with selected categories
                    $tmpCatExclusive = $this->config['categoryMode'] == 2 && !$this->conf['ignoreUseSubcategoriesForAndSelection'] ? $this->actuallySelectedCategories : $this->catExclusive;
                    $selectConf['leftjoin'] = 'tt_news_cat_mm ON tt_news.uid = tt_news_cat_mm.uid_local';
                    $selectConf['where'] .= ' AND (tt_news_cat_mm.uid_foreign IN (' . ($tmpCatExclusive ? $tmpCatExclusive : 0) . '))';
                }
                // de-select newsitems by their categories
                if ($this->config['categoryMode'] == -1 || $this->config['categoryMode'] == -2) {
                    // do not show items with selected categories
                    $selectConf['leftjoin'] = 'tt_news_cat_mm ON tt_news.uid = tt_news_cat_mm.uid_local';
                    $selectConf['where'] .= ' AND (tt_news_cat_mm.uid_foreign NOT IN (' . ($this->catExclusive ? $this->catExclusive : 0) . '))';
                    $selectConf['where'] .= ' AND (tt_news_cat_mm.uid_foreign)';
                    // filter out not categorized records
                }
            } elseif ($this->config['categoryMode']) {
                // special case: if $this->catExclusive is not set but $this->config['categoryMode'] -> show only non-categorized records
                $selectConf['leftjoin'] = 'tt_news_cat_mm ON tt_news.uid = tt_news_cat_mm.uid_local';
                $selectConf['where'] .= ' AND tt_news_cat_mm.uid_foreign IS' . ($this->config['categoryMode'] > 0 ? '' : ' NOT') . ' NULL';
            }
            // if categoryMode is 'show items AND' it's required to check if the records in the result do actually have the same number of categories as in $this->catExclusive
            if ($this->catExclusive && $this->config['categoryMode'] == 2) {
                $tmpCatExclusive = $this->catExclusive;
                $res = $this->exec_getQuery('tt_news', $selectConf);
                $results = array();
                $resultsCount = array();
                while ($row = $this->db->sql_fetch_assoc($res)) {
                    $results[] = $row['uid'];
                    if (in_array($row['uid'], $results)) {
                        $resultsCount[$row['uid']]++;
                    }
                }
                $catCount = count(explode(',', $tmpCatExclusive));
                $cleanedResultsCount = array();
                foreach ($resultsCount as $uid => $hits) {
                    if ($hits == $catCount) {
                        $cleanedResultsCount[] = $uid;
                    }
                }
                $matchlist = implode(',', $cleanedResultsCount);
                if ($matchlist) {
                    $selectConf['where'] .= ' AND tt_news.uid IN (' . $matchlist . ')';
                } else {
                    $selectConf['where'] .= ' AND tt_news.uid IN (0)';
                }
            }
            // if categoryMode is 'don't show items OR' we check if each found record does not have any of the deselected categories assigned
            if ($this->catExclusive && $this->config['categoryMode'] == -2) {
                $res = $this->exec_getQuery('tt_news', $selectConf);
                $results = array();
                //				$resultsCount = array();
                while ($row = $this->db->sql_fetch_assoc($res)) {
                    $results[$row['uid']] = $row['uid'];
                }
                array_unique($results);
                foreach ($results as $uid) {
                    $currentCats = $this->getCategories($uid);
                    foreach ($currentCats as $v) {
                        if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->catExclusive, $v['catid'])) {
                            unset($results[$uid]);
                            break;
                            // break after one deselected category was found
                        }
                    }
                }
                $matchlist = implode(',', $results);
                if ($matchlist) {
                    $selectConf['where'] .= ' AND tt_news.uid IN (' . $matchlist . ')';
                } else {
                    $selectConf['where'] .= ' AND tt_news.uid IN (0)';
                }
            }
        }
        if ($this->debugTimes) {
            $this->hObj->getParsetime(__METHOD__);
        }
        if ($this->arcExclusive > 0) {
            if ($this->piVars['arc']) {
                // allow overriding of the arcExclusive parameter from GET vars
                $this->arcExclusive = intval($this->piVars['arc']);
            }
            // select news from a certain period
            if (!$noPeriod && intval($this->piVars['pS'])) {
                $selectConf['where'] .= ' AND tt_news.datetime>=' . intval($this->piVars['pS']);
                if (intval($this->piVars['pL'])) {
                    $pL = intval($this->piVars['pL']);
                    //selecting news for a certain day only
                    if (intval($this->piVars['day'])) {
                        $pL = 86400;
                        // = 24h, as pS always starts at the beginning of a day (00:00:00)
                    }
                    $selectConf['where'] .= ' AND tt_news.datetime<' . (intval($this->piVars['pS']) + $pL);
                }
            }
        }
        // filter Workspaces preview.
        // Since "enablefields" is ignored in workspace previews it's required to filter out news manually which are not visible in the live version AND the selected workspace.
        if ($this->tsfe->sys_page->versioningPreview) {
            // execute the complete query
            $wsSelectconf = $selectConf;
            $wsSelectconf['selectFields'] = 'uid,pid,tstamp,crdate,deleted,hidden,fe_group,sys_language_uid,l18n_parent,l18n_diffsource,t3ver_oid,t3ver_id,t3ver_label,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_count,t3ver_tstamp,t3_origuid';
            $wsRes = $this->exec_getQuery('tt_news', $wsSelectconf);
            $removeUids = array();
            while ($wsRow = $this->db->sql_fetch_assoc($wsRes)) {
                $orgUid = $wsRow['uid'];
                $this->tsfe->sys_page->versionOL('tt_news', $wsRow);
                if (!$wsRow['uid']) {
                    // if versionOL returns nothing the record is not visible in the selected Workspace
                    $removeUids[] = $orgUid;
                }
            }
            $removeUidList = implode(',', array_unique($removeUids));
            // add list of not visible uids to the whereclause
            if ($removeUidList) {
                $selectConf['where'] .= ' AND tt_news.uid NOT IN (' . $removeUidList . ')';
            }
        }
        if ($this->debugTimes) {
            $this->hObj->getParsetime(__METHOD__);
        }
        if ($this->conf['excludeAlreadyDisplayedNews'] && $this->theCode != 'SEARCH' && $this->theCode != 'CATMENU' && $this->theCode != 'AMENU') {
            if (!is_array($GLOBALS['T3_VAR']['displayedNews'])) {
                $GLOBALS['T3_VAR']['displayedNews'] = array();
            } else {
                $excludeUids = implode(',', $GLOBALS['T3_VAR']['displayedNews']);
                if ($excludeUids) {
                    $selectConf['where'] .= ' AND tt_news.uid NOT IN (' . $this->db->cleanIntList($excludeUids) . ')';
                }
            }
        }
        if ($this->theCode != 'AMENU') {
            if ($this->config['groupBy']) {
                $selectConf['groupBy'] = $this->config['groupBy'];
            }
            // 				else {
            // 					$selectConf['groupBy'] = 'tt_news.uid';
            // 				}
            if ($this->config['orderBy']) {
                if (strtoupper($this->config['orderBy']) == 'RANDOM') {
                    $selectConf['orderBy'] = 'RAND()';
                } else {
                    $selectConf['orderBy'] = $this->config['orderBy'] . ($this->config['ascDesc'] ? ' ' . $this->config['ascDesc'] : '');
                }
            } else {
                $selectConf['orderBy'] = 'datetime DESC';
            }
            // overwrite the groupBy value for categories
            if (!$this->catExclusive && $selectConf['groupBy'] == 'category') {
                $selectConf['leftjoin'] = 'tt_news_cat_mm ON tt_news.uid = tt_news_cat_mm.uid_local';
                $selectConf['groupBy'] = 'tt_news_cat_mm.uid_foreign';
            }
        }
        $selectConf['where'] .= $this->getLanguageWhere();
        $selectConf['where'] .= ' AND tt_news.pid > 0 ';
        // only online versions
        if ($this->theCode != 'LATEST') {
            // latest ignores search query
            $selectConf['where'] .= $addwhere;
        }
        if ($this->conf['restrictListToThisTypes'] != '') {
            $types = implode(',', \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->conf['restrictListToTheseTypes'], 1));
            $where = ' AND tt_news.type IN (' . $types . ')';
        }
        // listing related news
        if ($this->theCode == 'RELATED' && $this->relNewsUid) {
            $where = $this->addFromTable . '.uid_local=' . $this->relNewsUid . '
						AND tt_news.uid=' . $this->addFromTable . '.uid_foreign
						AND ' . $this->addFromTable . '.tablenames!=' . $this->db->fullQuoteStr('pages', $this->addFromTable);
            if ($this->conf['useBidirectionalRelations']) {
                $where = '((' . $where . ')
						OR (' . $this->addFromTable . '.uid_foreign=' . $this->relNewsUid . '
							AND tt_news.uid=' . $this->addFromTable . '.uid_local
							AND ' . $this->addFromTable . '.tablenames!=' . $this->db->fullQuoteStr('pages', $this->addFromTable) . '))';
            }
            $selectConf['where'] .= ' AND ' . $where;
        }
        // function Hook for processing the selectConf array
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tt_news']['selectConfHook'])) {
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tt_news']['selectConfHook'] as $_classRef) {
                $_procObj =& \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef);
                $selectConf = $_procObj->processSelectConfHook($this, $selectConf);
            }
        }
        //		debug($this->config['categoryMode'],'categoryMode');
        //		debug($this->catExclusive,'$this->catExclusive');
        //				debug($selectConf,'select_conf '.$this->theCode);
        if ($this->debugTimes) {
            $this->hObj->getParsetime(__METHOD__);
        }
        return $selectConf;
    }