/**
  * @param $uid
  * @param $parentUid
  */
 function validateParentUid($uid, $parentUid)
 {
     # Always validate for new forums.
     if ($uid == -1) {
         return;
     }
     $res = $this->databaseHandle->exec_SELECTquery('*', 'tx_mmforum_forums', 'parentID=' . intval($uid) . ' AND deleted=0 ' . $this->parent->getStoragePIDQuery());
     if ($this->databaseHandle->sql_num_rows($res) > 0 && $parentUid != 0) {
         $this->addErrorForField('parent', 'no-nested-forums', array($this->databaseHandle->sql_num_rows($res)));
     }
 }
Esempio n. 2
0
 function loadFromDB($pid = -1)
 {
     $andWhere = '';
     if ($pid + 1) {
         $andWhere = ' AND pid=' . $pid;
     }
     $res = $this->databaseHandle->exec_SELECTquery('*', $this->getTableName(), 'uid=' . $this->getUid() . ' AND deleted=0 ' . $andWhere);
     if ($this->databaseHandle->sql_num_rows($res) == 0) {
         $this->data = null;
         $this->origData = array();
     } else {
         $this->data = $this->origData = $this->databaseHandle->sql_fetch_assoc($res);
     }
     $this->loaded = true;
 }
Esempio n. 3
0
 /**
  * Fetches the speakers and returns them comma seperated
  * for displaying in Planning Module
  *
  * @param $uid int
  * @return string
  */
 public function getSpeakers($uid)
 {
     if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($uid)) {
         throw new \InvalidArgumentException('Param $uid must be an integer');
     }
     $res = $this->db->exec_SELECTquery('fe_users.username, fe_users.name', 'tx_sessions_session_record_mm
         LEFT JOIN fe_users ON tx_sessions_session_record_mm.uid_foreign = fe_users.uid', ' tx_sessions_session_record_mm.uid_local = ' . $uid . ' AND tx_sessions_session_record_mm.tablenames = \'fe_users\' ', '', ' tx_sessions_session_record_mm.sorting ASC ');
     if ($res === false) {
         return '';
     }
     $speakers = [];
     while ($row = $res->fetch_assoc()) {
         $speakers[] = empty($row['name']) ? $row['username'] : $row['name'];
     }
     return implode(', ', $speakers);
 }
 /**
  * Get a user from DB by social identifier
  *
  * @param string $identifier social identifier
  * @param string $extraWhere Additional WHERE clause: " AND ...
  * @param array $dbUserSetup User db table definition: $this->db_user
  * @return mixed User array or FALSE
  */
 public function fetchUserRecordByIdentifier($identifier, $extraWhere = '', $dbUserSetup = '')
 {
     $result = FALSE;
     $identityClassName = 'Portrino\\PxHybridAuth\\Domain\\Model\\Identity\\' . ucfirst($this->getServiceProvider()) . 'Identity';
     if (class_exists($identityClassName) && defined($identityClassName . '::EXTBASE_TYPE')) {
         $extbaseType = constant($identityClassName . '::EXTBASE_TYPE');
         $identityClause = 'deleted=0 AND hidden=0 AND identifier=' . $this->db->fullQuoteStr($identifier, 'tx_pxhybridauth_domain_model_identity') . ' AND ' . 'tx_extbase_type=' . $this->db->fullQuoteStr($extbaseType, 'tx_pxhybridauth_domain_model_identity');
         $socialIdentities = $this->db->exec_SELECTgetRows('*', 'tx_pxhybridauth_domain_model_identity', $identityClause);
         foreach ($socialIdentities as $socialIdentity) {
             if (isset($socialIdentity['fe_user'])) {
                 $dbUser = is_array($dbUserSetup) ? $dbUserSetup : $this->db_user;
                 // Look up the user by the username and/or extraWhere:
                 $dbres = $this->db->exec_SELECTquery('*', $dbUser['table'], 'uid' . '=' . $this->db->fullQuoteStr($socialIdentity['fe_user'], $dbUser['table']) . $this->db->fullQuoteStr($dbUser['check_pid_clause'], $dbUser['table']) . $dbUser['enable_clause'] . $extraWhere);
                 if ($dbres) {
                     $result = $this->db->sql_fetch_assoc($dbres);
                     $this->db->sql_free_result($dbres);
                     if ($result) {
                         break;
                     }
                 }
             }
         }
     }
     return $result;
 }
Esempio n. 5
0
 /**
  * Determines if the current user may write in a certain topic.
  * @param  mixed   $topic The topic identifier. This may either be a topic UID pointing to
  *                        a record in the tx_mmforum_topics table or an associative array
  *                        already containing this record.
  * @return boolean        TRUE, if the user that is currently logged in may write in the
  *                        specified topic, otherwise FALSE.
  * @author Martin Helmich <*****@*****.**>
  */
 function getMayWrite_topic($topic)
 {
     $userId = $this->getUserID();
     // If the $topic parameter is not an array, treat this parameter as a topic UID.
     if (!is_array($topic)) {
         $topic = intval($topic);
         // Look in the cache. In case of a hit, just return the result
         $cacheRes = $this->cache->restore('getMayWrite_topic_' . $topic . '_' . $userId);
         if ($cacheRes !== null) {
             return $cacheRes;
         }
         // Load the topic's forum UID
         $res = $this->databaseHandle->exec_SELECTquery('f.*', 'tx_mmforum_forums f, tx_mmforum_topics t', 't.uid="' . $topic . '" AND f.uid = t.forum_id');
         $arr = $this->databaseHandle->sql_fetch_assoc($res);
         $result = $this->getMayWrite_forum($arr);
         // Save the result to cache and return
         $this->cache->save('getMayWrite_topic_' . $topic . '_' . $userId, $result);
         return $result;
     } else {
         /* If the topic's forum UID is already known, just delegate to the
          * getMayWrite_forum function. Since the result of that function is
          * already being cached, there is no need to cache the result at this
          * place again. */
         return $this->getMayWrite_forum($topic['forum_id']);
     }
 }
 /**
  * Determines the user's rank by his/her post count.
  *
  * @author  Martin Helmich <*****@*****.**>
  * @version 2007-06-06
  * @param   int   $post_count The user's post count.
  * @return  array             The regarding user rank as associative array.
  */
 function getRankByPostCount($post_count)
 {
     $res = $this->databaseHandle->exec_SELECTquery('*', 'tx_mmforum_ranks', 'minPosts <= ' . $post_count . ' AND deleted=0 AND hidden=0 AND special=0', '', 'minPosts DESC');
     if ($this->databaseHandle->sql_num_rows($res) == 0) {
         return 'error';
     } else {
         return $this->databaseHandle->sql_fetch_assoc($res);
     }
 }
 /**
  *
  * Retrievs a topic's forum UID.
  *
  * @author  Martin Helmich <*****@*****.**>
  * @version 2007-07-21
  * @param   int $topic_uid The topic's UID
  * @return  int            The forum's UID
  */
 function getForumUIDByTopic($topic_uid)
 {
     $topic_uid = intval($topic_uid);
     $res = $this->databaseHandle->exec_SELECTquery('forum_id', 'tx_mmforum_topics', 'uid=' . $topic_uid . ' AND deleted=0');
     if ($this->databaseHandle->sql_num_rows($res) > 0) {
         list($forum_uid) = $this->databaseHandle->sql_fetch_row($res);
         return $forum_uid;
     } else {
         return false;
     }
 }
Esempio n. 8
0
 /**
  * Check if there are still resources left for the process with the given id
  * Used to determine timeouts and to ensure a proper cleanup if there's a timeout
  *
  * @param  string  identification string for the process
  * @return boolean determines if the process is still active / has resources
  */
 function CLI_checkIfProcessIsActive($pid)
 {
     $ret = false;
     $this->db->sql_query('BEGIN');
     $res = $this->db->exec_SELECTquery('process_id,active,ttl', 'tx_crawler_process', 'process_id = \'' . $pid . '\'  AND deleted=0', '', 'ttl', '0,1');
     if ($row = $this->db->sql_fetch_assoc($res)) {
         $ret = intVal($row['active']) == 1;
     }
     $this->db->sql_query('COMMIT');
     return $ret;
 }
Esempio n. 9
0
 /**
  * Update categories in flexforms
  *
  * @param string $pluginName
  * @param array $oldNewCategoryUidMapping
  * @param string $flexformField name of the flexform's field to look for
  * @return void
  */
 protected function updateFlexformCategories($pluginName, $oldNewCategoryUidMapping, $flexformField)
 {
     $count = 0;
     $title = 'Update flexforms categories (' . $pluginName . ':' . $flexformField . ')';
     $res = $this->databaseConnection->exec_SELECTquery('uid, pi_flexform', 'tt_content', 'CType=\'list\' AND list_type=\'' . $pluginName . '\' AND deleted=0');
     /** @var \TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools $flexformTools */
     $flexformTools = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Configuration\\FlexForm\\FlexFormTools');
     while ($row = $this->databaseConnection->sql_fetch_assoc($res)) {
         $status = null;
         $xmlArray = GeneralUtility::xml2array($row['pi_flexform']);
         if (!is_array($xmlArray) || !isset($xmlArray['data'])) {
             $status = FlashMessage::ERROR;
             $message = 'Flexform data of plugin "' . $pluginName . '" not found.';
         } elseif (!isset($xmlArray['data']['sDEF']['lDEF'])) {
             $status = FlashMessage::WARNING;
             $message = 'Flexform data of record tt_content:' . $row['uid'] . ' did not contain sheet: sDEF';
         } elseif (isset($xmlArray[$flexformField . '_updated'])) {
             $status = FlashMessage::NOTICE;
             $message = 'Flexform data of record tt_content:' . $row['uid'] . ' is already updated for ' . $flexformField . '. No update needed...';
         } else {
             // Some flexforms may have displayCond
             if (isset($xmlArray['data']['sDEF']['lDEF'][$flexformField]['vDEF'])) {
                 $updated = false;
                 $oldCategories = GeneralUtility::trimExplode(',', $xmlArray['data']['sDEF']['lDEF'][$flexformField]['vDEF'], true);
                 if (!empty($oldCategories)) {
                     $newCategories = array();
                     foreach ($oldCategories as $uid) {
                         if (isset($oldNewCategoryUidMapping[$uid])) {
                             $newCategories[] = $oldNewCategoryUidMapping[$uid];
                             $updated = true;
                         } else {
                             $status = FlashMessage::WARNING;
                             $message = 'The category ' . $uid . ' of record tt_content:' . $row['uid'] . ' was not found in sys_category records. Maybe the category was deleted before the migration? Please check manually...';
                         }
                     }
                     if ($updated) {
                         $count++;
                         $xmlArray[$flexformField . '_updated'] = 1;
                         $xmlArray['data']['sDEF']['lDEF'][$flexformField]['vDEF'] = implode(',', $newCategories);
                         $this->databaseConnection->exec_UPDATEquery('tt_content', 'uid=' . $row['uid'], array('pi_flexform' => $flexformTools->flexArray2Xml($xmlArray)));
                     }
                 }
             }
         }
         if ($status !== null) {
             $this->messageArray[] = array($status, $title, $message);
         }
     }
     $status = FlashMessage::INFO;
     $message = 'Updated ' . $count . ' tt_content flexforms for  "' . $pluginName . ':' . $flexformField . '"';
     $this->messageArray[] = array($status, $title, $message);
 }
Esempio n. 10
0
    /**
     * Gets the latest posts from all public forums.
     *
     * @author  Martin Helmich <*****@*****.**>
     * @return  array             An array containing all matching posts
     */
    function getPosts_all()
    {
        $res = $this->databaseHandle->exec_SELECTquery($this->selectFields, 'tx_mmforum_posts p
			 LEFT JOIN tx_mmforum_posts_text x ON x.post_id = p.uid
			 LEFT JOIN fe_users u ON u.uid = p.poster_id
			 LEFT JOIN tx_mmforum_topics t ON t.uid = p.topic_id
			 LEFT JOIN tx_mmforum_forums f ON t.forum_id = f.uid
			 LEFT JOIN tx_mmforum_forums c ON f.parentID = c.uid', 'p.deleted=0 AND
			 t.deleted=0 AND
			 f.deleted=0 ' . $this->pObj->getMayRead_forum_query('f') . $this->pObj->getMayRead_forum_query('c'), '', 'p.post_time DESC', $this->getPostNum());
        $results = array();
        while ($arr = $this->databaseHandle->sql_fetch_assoc($res)) {
            array_push($results, $arr);
        }
        return $results;
    }
Esempio n. 11
0
 /**
  * Get array with markers from a complete form
  *
  * @return array
  */
 protected function getFieldMarkersFromForm()
 {
     $result = array();
     $select = 'f.marker, f.uid';
     $from = 'tx_powermail_domain_model_forms fo ' . 'LEFT JOIN tx_powermail_domain_model_pages p ON p.forms = fo.uid ' . 'LEFT JOIN tx_powermail_domain_model_fields f ON f.pages = p.uid';
     $where = 'fo.uid = ' . (int) $this->formUid . ' and f.deleted = 0';
     $groupBy = '';
     $orderBy = '';
     $limit = 1000;
     $res = $this->databaseConnection->exec_SELECTquery($select, $from, $where, $groupBy, $orderBy, $limit);
     if ($res) {
         while ($row = $this->databaseConnection->sql_fetch_assoc($res)) {
             $result['_' . $row['uid']] = $row['marker'];
         }
     }
     return $result;
 }
 /**
  * Search for users and returns usernames as result
  *
  * @param string $sword search string
  * @return array Array of usernames
  */
 public function search($sword)
 {
     $result = array();
     if (!$this->is_init) {
         $this->init();
     }
     if (!$this->validateName($this->field)) {
         return $result;
     }
     /** @see https://buzz.typo3.org/teams/security/article/correct-usage-of-typo3-database-api/ */
     $sword = '"' . $this->databaseHandle->escapeStrForLike($this->databaseHandle->quoteStr($sword, 'fe_users'), 'fe_users') . '%"';
     $res = $this->databaseHandle->exec_SELECTquery($this->field, 'fe_users', 'disable=0 AND deleted=0 AND ' . $this->field . ' LIKE ' . $sword . ' AND pid=' . $this->pid . ' AND FIND_IN_SET(' . $this->group_id . ', usergroup)', '', $this->field . ' ASC', '8');
     while (list($item) = $this->databaseHandle->sql_fetch_row($res)) {
         array_push($result, $item);
     }
     return $result;
 }
 /**
  * Update existing record
  *
  * @return int uid of updated record
  */
 protected function update()
 {
     // find existing record in database
     $searchterm = $this->databaseConnection->fullQuoteStr($this->getProperty($this->getUniqueField()), $this->getTable());
     $res = $this->databaseConnection->exec_SELECTquery('uid', $this->getTable(), $this->getUniqueField() . ' = ' . $searchterm . ' and deleted = 0 ' . $this->getAdditionalWhereClause(), '', '', 1);
     if ($res) {
         $row = $this->databaseConnection->sql_fetch_assoc($res);
     }
     // if there is no existing entry, insert new one
     if (empty($row['uid'])) {
         return $this->insert();
     }
     // update existing entry (only if mode is not "none")
     if ($this->getMode() !== 'none') {
         $this->databaseConnection->exec_UPDATEquery($this->getTable(), 'uid = ' . (int) $row['uid'], $this->getProperties());
     }
     return $row['uid'];
 }
 function get($data)
 {
     if (is_int($data)) {
         /* Load record from database */
         $res = $this->databaseHandle->exec_SELECTquery('*', 'tx_mmforum_userfields', 'uid=' . intval($data));
         if ($this->databaseHandle->sql_num_rows($res) == 0) {
             return null;
         }
         $arr = $this->databaseHandle->sql_fetch_assoc($res);
     } else {
         $arr = $data;
     }
     /* Unserialize array with meta information */
     $arr['meta'] = unserialize($arr['meta']);
     /* Parse configuration TypoScript */
     $parser =& $this->userLib->getTSParser();
     $parser->setup = array();
     $parser->parse($arr['config']);
     $arr['config_parsed'] = $parser->setup;
     /* Do some corrections for backwards compatibility */
     if (!$arr['meta']['label']['default']) {
         $arr['meta']['label']['default'] = $arr['label'];
     }
     if (!$arr['meta']['type']) {
         $arr['meta']['type'] = 'custom';
     }
     if (!$arr['meta']['link'] && $arr['config_parsed']['datasource']) {
         $arr['meta']['link'] = $arr['config_parsed']['datasource'];
     }
     if (!isset($arr['meta']['required']) && isset($arr['config_parsed']['required'])) {
         $arr['meta']['required'] = $arr['config_parsed']['required'] ? true : false;
     }
     if (!$arr['meta']['text']['validate']) {
         $arr['meta']['text']['validate'] = 'none';
     }
     if (!$arr['meta']['text']['length']) {
         $arr['meta']['text']['length'] = '-1';
     }
     $this->data = $arr;
     $this->meta =& $arr['meta'];
     $this->conf =& $arr['config_parsed'];
 }
Esempio n. 15
0
 /**
  * Encrypt old bounce account passwords and preserve old default config
  *
  * @return string[]
  */
 private function getQueriesToEncryptOldBounceAccountPasswords()
 {
     // Fetch the old records - they will have a default port and an empty config.
     $rs = $this->databaseConnection->exec_SELECTquery('uid, password', 'tx_newsletter_domain_model_bounceaccount', 'port = 0 AND config = \'\'');
     $records = [];
     while ($record = $this->databaseConnection->sql_fetch_assoc($rs)) {
         $records[] = $record;
     }
     $this->databaseConnection->sql_free_result($rs);
     if (empty($records)) {
         return [];
     }
     // Keep the old config to not break old installations
     $config = Tools::encrypt("poll ###SERVER###\nproto ###PROTOCOL### \nusername \"###USERNAME###\"\npassword \"###PASSWORD###\"\n");
     $queries = [];
     foreach ($records as $record) {
         $queries[] = $this->databaseConnection->UPDATEquery('tx_newsletter_domain_model_bounceaccount', 'uid=' . intval($record['uid']), ['password' => Tools::encrypt($record['password']), 'config' => $config]);
     }
     return ['Encrypt bounce account passwords' => $queries];
 }
Esempio n. 16
0
 /**
  * DB select object by id
  *
  * @param int $uid Uid
  * @param Tx_Commerce_Dao_BasicDaoObject $object Object
  *
  * @return void
  */
 protected function dbSelectById($uid, Tx_Commerce_Dao_BasicDaoObject &$object)
 {
     $dbFields = '*';
     $dbTable = $this->dbTable;
     $dbWhere = 'uid = ' . (int) $uid;
     $dbWhere .= 'AND deleted = 0';
     // execute query
     $res = $this->database->exec_SELECTquery($dbFields, $dbTable, $dbWhere);
     // insert into object
     $model = $this->database->sql_fetch_assoc($res);
     if ($model) {
         // parse into object
         $this->parser->parseModelToObject($model, $object);
     } else {
         // no object found, empty obj and id
         $object->clear();
     }
     // free results
     $this->database->sql_free_result($res);
 }
 /**
  * Get array with related fields to a form
  *
  * @param int $uid
  * @return array
  */
 protected function getFieldsFromForm($uid)
 {
     if (ConfigurationUtility::isReplaceIrreWithElementBrowserActive()) {
         return $this->getFieldsFromFormAlternative($uid);
     }
     $result = array();
     $select = 'f.title';
     $from = 'tx_powermail_domain_model_forms fo ' . 'LEFT JOIN tx_powermail_domain_model_pages p ON p.forms = fo.uid ' . 'LEFT JOIN tx_powermail_domain_model_fields f ON f.pages = p.uid';
     $where = 'fo.uid = ' . (int) $uid . ' and p.deleted = 0 and f.deleted = 0';
     $groupBy = '';
     $orderBy = '';
     $limit = 1000;
     $res = $this->databaseConnection->exec_SELECTquery($select, $from, $where, $groupBy, $orderBy, $limit);
     if ($res) {
         while ($row = $this->databaseConnection->sql_fetch_assoc($res)) {
             $result[] = $row['title'];
         }
     }
     return $result;
 }
    /**
     * Fetches all $tablename records with DAM connections
     * Returns the item uid and pid as item_uid and item_pid
     *
     * @param string $tableName
     * @param string $ident
     *
     * @return \mysqli_result
     */
    protected function getRecordsWithDamConnections($tableName, $ident)
    {
        return $this->database->exec_SELECTquery('i.uid as item_uid,
			 i.pid as item_pid,
			 r.uid_local,
			 r.uid_foreign,
			 r.tablenames,
			 r.sorting,
			 r.ident,
			 d.uid as dam_uid,
			 d.file_name,
			 d.file_path,
			 d.l18n_diffsource', 'tx_dam_mm_ref as r
				INNER JOIN ' . $tableName . ' as i ON r.uid_foreign = i.uid
				INNER JOIN tx_dam as d ON d.uid = r.uid_local', 'r.tablenames = "' . $tableName . '"
			 AND r.ident = "' . $ident . '"
			 AND d.file_path LIKE "' . $this->storageBasePath . '%"
			 AND d.deleted = 0
			 AND i.deleted = 0');
    }
Esempio n. 19
0
 /**
  *
  * Converts a commaseperated list of record UIDs to a TCEforms-readableformat.
  * This function converts a regular list of commaseperated record UIDs
  * (like e.g. "1,2,3") to a format that can be interpreted as form input
  * field default value by the t3lib_TCEforms class (like e.g.
  * "1|Username,2|Username_two,3|Username_three").
  *
  * @param   string $list The commaseperated list
  * @param   string $table The table the records' titles are to be
  *                            loaded from
  * @param   string $fieldname The fieldname used to identify the records,
  *                            like for example the username in the
  *                            fe_users table.
  *
  * @return string
  * @author  Martin Helmich <*****@*****.**>
  * @version 2007-04-23
  */
 function convertToTCEList($list, $table, $fieldname)
 {
     $items = GeneralUtility::trimExplode(',', $list);
     if (count($items) == 0) {
         return '';
     }
     $resultItems = array();
     foreach ($items as $item) {
         if ($item == '') {
             continue;
         }
         $res = $this->databaseHandle->exec_SELECTquery($fieldname, $table, 'uid="' . $item . '"');
         list($title) = $this->databaseHandle->sql_fetch_row($res);
         $resultItems[] = "{$item}|{$title}";
     }
     if (count($resultItems) == 0) {
         return '';
     }
     return implode(',', $resultItems);
 }
Esempio n. 20
0
 /**
  * Clear the TYPO3 page cache for the given record.
  * If the record lies on a page, then we clear the cache of this page.
  * If the record has no PID column, we clear the cache of the current page as best-effort.
  *
  * Much of this functionality is taken from DataHandler::clear_cache() which unfortunately only works with logged-in BE user.
  *
  * @param string $tableName Table name of the record
  * @param int $uid UID of the record
  * @return void
  */
 protected function clearPageCache($tableName, $uid)
 {
     $frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
     if (isset($frameworkConfiguration['persistence']['enableAutomaticCacheClearing']) && $frameworkConfiguration['persistence']['enableAutomaticCacheClearing'] === '1') {
     } else {
         // if disabled, return
         return;
     }
     $pageIdsToClear = array();
     $storagePage = NULL;
     $columns = $this->databaseHandle->admin_get_fields($tableName);
     if (array_key_exists('pid', $columns)) {
         $result = $this->databaseHandle->exec_SELECTquery('pid', $tableName, 'uid=' . (int) $uid);
         if ($row = $this->databaseHandle->sql_fetch_assoc($result)) {
             $storagePage = $row['pid'];
             $pageIdsToClear[] = $storagePage;
         }
     } elseif (isset($GLOBALS['TSFE'])) {
         // No PID column - we can do a best-effort to clear the cache of the current page if in FE
         $storagePage = $GLOBALS['TSFE']->id;
         $pageIdsToClear[] = $storagePage;
     }
     if ($storagePage === NULL) {
         return;
     }
     if (!isset($this->pageTSConfigCache[$storagePage])) {
         $this->pageTSConfigCache[$storagePage] = BackendUtility::getPagesTSconfig($storagePage);
     }
     if (isset($this->pageTSConfigCache[$storagePage]['TCEMAIN.']['clearCacheCmd'])) {
         $clearCacheCommands = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', strtolower($this->pageTSConfigCache[$storagePage]['TCEMAIN.']['clearCacheCmd']), TRUE);
         $clearCacheCommands = array_unique($clearCacheCommands);
         foreach ($clearCacheCommands as $clearCacheCommand) {
             if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($clearCacheCommand)) {
                 $pageIdsToClear[] = $clearCacheCommand;
             }
         }
     }
     foreach ($pageIdsToClear as $pageIdToClear) {
         $this->cacheService->getPageIdStack()->push($pageIdToClear);
     }
 }
 /**
  * Removes all processed files and also deletes the associated physical files
  *
  * @param int|NULL $storageUid If not NULL, only the processed files of the given storage are removed
  * @return int Number of failed deletions
  */
 public function removeAll($storageUid = null)
 {
     $res = $this->databaseConnection->exec_SELECTquery('*', $this->table, 'identifier <> \'\'');
     $logger = $this->getLogger();
     $errorCount = 0;
     while ($row = $this->databaseConnection->sql_fetch_assoc($res)) {
         if ($storageUid && (int) $storageUid !== (int) $row['storage']) {
             continue;
         }
         try {
             $file = $this->createDomainObject($row);
             $file->getStorage()->setEvaluatePermissions(false);
             $file->delete(true);
         } catch (\Exception $e) {
             $logger->error('Failed to delete file "' . $row['identifier'] . '" in storage uid ' . $row['storage'] . '.', array('exception' => $e));
             ++$errorCount;
         }
     }
     $this->databaseConnection->exec_TRUNCATEquery($this->table);
     return $errorCount;
 }
 /**
  * Loads the record of an user field.
  * This function load the entire record of a custom user field. The
  * field's typoscript configuration is automatically parsed and the
  * array of metadata that is stored in the database is automatically
  * unserialized.
  *
  * @param  mixed $value Some data the record is to be initialized with.
  *                     This may be either the record's UID or the entire
  *                     record itself as array.
  * @return array       The record of the user field.
  *
  * @author  Martin Helmich <*****@*****.**>
  * @version 2009-02-16
  */
 function getUserFieldData($value)
 {
     if (is_array($value)) {
         $data = $value;
     } else {
         if (MathUtility::canBeInterpretedAsInteger($value) || intval($value) != 0) {
             $res = $this->databaseHandle->exec_SELECTquery('*', 'tx_mmforum_userfields', 'uid=' . intval($value));
             if ($this->databaseHandle->sql_num_rows($res) == 0) {
                 return null;
             }
             $data = $this->databaseHandle->sql_fetch_assoc($res);
         }
     }
     /* Parse configuration TypoScript */
     $parser = $this->getTSParser();
     $parser->parse($data['config']);
     $data['config_parsed'] = $parser->setup;
     $parser->setup = array();
     $this->initializeOldMetaArray($data);
     return $data;
 }
 /**
  * Get Forms from Database
  *
  * @param int $startPid
  * @param int $language
  * @return array
  */
 protected function getAllForms($startPid, $language)
 {
     $this->initialize();
     $select = 'fo.uid, fo.title';
     $from = 'tx_powermail_domain_model_forms fo';
     $where = 'fo.deleted = 0 and fo.hidden = 0 and ' . '(fo.sys_language_uid IN (-1,0) or ' . '(fo.l10n_parent = 0 and fo.sys_language_uid = ' . (int) $language . '))';
     if (!empty($startPid)) {
         $where .= ' and fo.pid in (' . $this->getPidListFromStartingPoint($startPid) . ')';
     }
     $groupBy = '';
     $orderBy = 'fo.title ASC';
     $limit = 10000;
     $res = $this->databaseConnection->exec_SELECTquery($select, $from, $where, $groupBy, $orderBy, $limit);
     $array = [];
     if ($res) {
         while ($row = $this->databaseConnection->sql_fetch_assoc($res)) {
             $array[] = $row;
         }
     }
     return $array;
 }
    /**
     * Displays additional statistics.
     *
     * @return  string The statistic table
     * @author  Martin Helmich <*****@*****.**>
     * @version 2007-05-31
     */
    function additionalStats()
    {
        $startTime = $this->getStartTime();
        $span = $GLOBALS['EXEC_TIME'] - $startTime;
        $days = round($span / 86400);
        $res = $this->databaseHandle->exec_SELECTquery('COUNT(*)', 'tx_mmforum_posts', 'deleted=0');
        list($post_count) = $this->databaseHandle->sql_fetch_row($res);
        $post_average = round($post_count / $days, 4);
        $res = $this->databaseHandle->exec_SELECTquery('COUNT(*)', 'tx_mmforum_topics', 'deleted=0');
        list($topic_count) = $this->databaseHandle->sql_fetch_row($res);
        $topic_average = round($topic_count / $days, 4);
        $res = $this->databaseHandle->exec_SELECTquery('COUNT(*)', 'fe_users', 'deleted=0 AND crdate >= ' . $startTime);
        list($user_count) = $this->databaseHandle->sql_fetch_row($res);
        $user_average = round($user_count / $days, 4);
        $res = $this->databaseHandle->exec_SELECTquery('COUNT(*)', 'tx_mmforum_pminbox', 'deleted=0 AND sendtime > ' . $startTime);
        list($pm_count) = $this->databaseHandle->sql_fetch_row($res);
        $pm_count /= 2;
        $pm_average = round($pm_count / $days, 4);
        $content = '
	<table cellspacing="0" cellpadding="2">
		<tr>
			<td>' . $this->getLL('menu.table.posts') . ' (' . $this->getLL('additional.totavg') . ')</td>
			<td>' . $post_count . ' / ' . $post_average . '</td>
		</tr>
		<tr>
			<td>' . $this->getLL('menu.table.topics') . ' (' . $this->getLL('additional.totavg') . ')</td>
			<td>' . $topic_count . ' / ' . $topic_average . '</td>
		</tr>
		<tr>
			<td>' . $this->getLL('menu.table.users') . ' (' . $this->getLL('additional.totavg') . ')</td>
			<td>' . $user_count . ' / ' . $user_average . '</td>
		</tr>
		<tr>
			<td>' . $this->getLL('menu.table.pms') . ' (' . $this->getLL('additional.totavg') . ')</td>
			<td>' . $pm_count . ' / ' . $pm_average . '</td>
		</tr>
	</table>
';
        return $content;
    }
    /**
     * Sends an e-mail to users who have subscribed to certain forumcategory
     * @param $topicId int The UID of the new topic that was created
     * @param $forumId int The UID of the forum about which the users are to be alerted.
     * @param \tx_mmforum_base $forumObj
     * @return void
     * @author Cyrill Helg
     */
    static function notifyForumSubscribers($topicId, $forumId, \tx_mmforum_base $forumObj)
    {
        $res = $this->databaseHandle->exec_SELECTquery('topic_title', 'tx_mmforum_topics', 'uid = ' . intval($topicId) . $forumObj->getStoragePIDQuery());
        list($topicName) = $this->databaseHandle->sql_fetch_row($res);
        $res = $this->databaseHandle->exec_SELECTquery('forum_name, parentID', 'tx_mmforum_forums', 'uid = ' . intval($forumId) . $forumObj->getStoragePIDQuery());
        list($forumName, $categoryId) = $this->databaseHandle->sql_fetch_row($res);
        // prepare the template (the variables that don't change all the time need only to be set once)
        $linkParams[$forumObj->prefixId] = array('action' => 'open_topic', 'id' => $topicId);
        $link = $forumObj->pi_getPageLink($GLOBALS['TSFE']->id, '', $linkParams);
        $link = $forumObj->tools->escapeBrackets($link);
        if (strlen($forumObj->conf['notifyingMail.']['topicLinkPrefix_override']) > 0) {
            $link = $forumObj->conf['notifyingMail.']['topicLinkPrefix_override'] . $link;
        }
        $template = $forumObj->pi_getLL('ntfMailForum.text');
        $marker = array('###LINK###' => $link, '###USERNAME###' => $toUsername, '###FORUMNAME###' => $forumName, '###TEAM###' => $forumObj->conf['teamName']);
        $subjectMarker = array('###TOPICNAME###' => $topicName, '###FORUMNAME###' => $forumName, '###BOARDNAME###' => $forumObj->conf['boardName']);
        // loop through each user who subscribed
        $res = $this->databaseHandle->exec_SELECTquery('DISTINCT tx_mmforum_forummail.user_id, fe_users.email, fe_users.' . $forumObj->getUserNameField(), 'tx_mmforum_forummail, fe_users', 'tx_mmforum_forummail.user_id = fe_users.uid AND
			 (tx_mmforum_forummail.forum_id = ' . intval($forumId) . ($categoryId > 0 ? ' OR tx_mmforum_forummail.forum_id = ' . $categoryId : '') . ') AND
			 fe_users.deleted = 0 AND
			 fe_users.disable = 0 AND
			 fe_users.email != "" AND
			 tx_mmforum_forummail.user_id != ' . intval($GLOBALS['TSFE']->fe_user->user['uid']) . $forumObj->getStoragePIDQuery('tx_mmforum_forummail'));
        while (list($toUserId, $toEmail, $toUsername) = $this->databaseHandle->sql_fetch_row($res)) {
            $marker['###USERNAME###'] = $forumObj->escape($toUsername);
            $mailtext = $forumObj->cObj->substituteMarkerArrayCached($template, $marker);
            // Compose mail and send
            $subject = $forumObj->cObj->substituteMarkerArray($forumObj->pi_getLL('ntfMailForum.subject'), $subjectMarker);
            $mail = GeneralUtility::makeInstance('t3lib_mail_Message');
            $mail->setFrom(array($forumObj->conf['notifyingMail.']['sender_address'] => $forumObj->conf['notifyingMail.']['sender']));
            $mail->setTo(array($toEmail => $toUsername));
            $mail->setSubject($subject);
            $mail->setBody($mailtext, 'text/plain');
            $mail->send();
        }
    }
 /**
  * Generates a list of options for the sorting selector.
  * This function generates a list of HTML-option elements for the
  * sorting selector that is used in all category and message board
  * forms. The selector box consists of two general items ("as first" and
  * "as last", meaning that the new/edited item will either stand as
  * first or as last item in the list) and of some other items allowing
  * to sort this item in relation to other items.
  *
  * @param  array   $row The record of the board/category that is to be edited.
  * @param  int     $pid The record's parent ID. If case of a category this value is
  *                      0, otherwise it will be the UID of the category the record
  *                      belongs to.
  * @param  boolean $new TRUE, if this item is to be generated for a board/category
  *                      creation form, otherwise FALSE.
  * @param  string  $sec The parameter name to read. Has to be 'ctg' for categories and
  *                      'forum' for message boards.
  * @return string       A list of HTML-option objects.
  * @author  Martin Helmich <*****@*****.**>
  * @version 2007-05-24
  */
 function getForumOrderField($row, $pid, $new = false, $sec = 'ctg')
 {
     $res = $this->databaseHandle->exec_SELECTquery('*', 'tx_mmforum_forums', 'parentID=' . $pid . ' AND pid=' . $this->pid . ' AND deleted=0 AND uid!=' . intval($row['uid']), '', 'sorting ASC');
     $pos = 'beginning';
     while ($arr = $this->databaseHandle->sql_fetch_assoc($res)) {
         $ctgs[] = $arr;
         if ($row['sorting'] > $arr['sorting']) {
             $pos = $arr['uid'];
         }
     }
     $first_sel = $row['sorting'] < $ctgs[0]['sorting'] ? 'selected="selected"' : '';
     $last_sel = $row['sorting'] >= $ctgs[count($ctgs) - 1]['sorting'] ? 'selected="selected"' : '';
     if ($new) {
         $first_sel = '';
         $last_sel = 'selected="selected"';
     }
     if ($this->param[$sec]['order'] == 'first') {
         $first_sel = 'selected="selected"';
         $last_sel = '';
     } elseif ($this->param[$sec]['order'] == 'last') {
         $last_sel = 'selected="selected"';
         $first_sel = '';
     }
     $content = '<option value="first" ' . $first_sel . '>' . $this->getLL('order.beginning') . '</option>';
     $content .= '<option value="last" ' . $last_sel . '>' . $this->getLL('order.ending') . '</option>';
     if (count($ctgs) > 0) {
         foreach ($ctgs as $ctg) {
             $sel = $pos == $ctg['uid'] ? 'selected="selected"' : '';
             if ($this->param[$sec]['order']) {
                 $sel = $this->param[$sec]['order'] == $ctg['sorting'] + 1 ? 'selected="selected"' : '';
             }
             $content .= '<option value="' . ($ctg['sorting'] + 1) . '" ' . $sel . '>' . $this->getLL('order.after') . ' ' . $ctg['forum_name'] . ' ' . $ctg['sorting'] . '</option>';
         }
     }
     return $content;
 }
 /**
  * Get a user from DB by username
  * provided for usage from services
  *
  * @param array $dbUser User db table definition: $this->db_user
  * @param string $username user name
  * @param string $extraWhere Additional WHERE clause: " AND ...
  * @return mixed User array or FALSE
  * @todo Define visibility
  */
 public function fetchUserRecord($dbUser, $username, $extraWhere = '')
 {
     $user = FALSE;
     $usernameClause = $username ? $dbUser['username_column'] . '=' . $this->db->fullQuoteStr($username, $dbUser['table']) : '1=1';
     if ($username || $extraWhere) {
         // Look up the user by the username and/or extraWhere:
         $dbres = $this->db->exec_SELECTquery('*', $dbUser['table'], $usernameClause . $dbUser['check_pid_clause'] . $dbUser['enable_clause'] . $extraWhere);
         if ($dbres) {
             $user = $this->db->sql_fetch_assoc($dbres);
             $this->db->sql_free_result($dbres);
         }
     }
     return $user;
 }
 /**
  * ('EXT:tinymce_rte/hooks/class.tx_tinymce_rte_handler.php:&tx_tinymce_rte_handler')
  * allow to use links as "record:tt_news:3"
  * original by Daniel Poetzinger (AOE media GmbH) in extension linkhandler
  *
  * @author Thomas Allmer <*****@*****.**>
  *
  */
 function getRecordRow($table, $uid, &$localcObj)
 {
     $res = $this->databaseHandle->exec_SELECTquery('*', $table, 'uid=' . intval($uid) . $localcObj->enableFields($table), '', '');
     $row = $this->databaseHandle->sql_fetch_assoc($res);
     return $row;
 }
Esempio n. 29
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;
 }
Esempio n. 30
0
 /**
  * Print log error messages from the operations of this script instance
  *
  * @param string $redirect Redirect URL (for creating link in message)
  * @return void (Will exit on error)
  */
 public function printLogErrorMessages($redirect)
 {
     $res_log = $this->databaseConnection->exec_SELECTquery('*', 'sys_log', 'type=1 AND action<256 AND userid=' . (int) $this->BE_USER->user['uid'] . ' AND tstamp=' . (int) $GLOBALS['EXEC_TIME'] . '	AND error<>0');
     while ($row = $this->databaseConnection->sql_fetch_assoc($res_log)) {
         $log_data = unserialize($row['log_data']);
         $msg = $row['error'] . ': ' . sprintf($row['details'], $log_data[0], $log_data[1], $log_data[2], $log_data[3], $log_data[4]);
         /** @var FlashMessage $flashMessage */
         $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, htmlspecialchars($msg), '', FlashMessage::ERROR, true);
         /** @var $flashMessageService FlashMessageService */
         $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
         $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
         $defaultFlashMessageQueue->enqueue($flashMessage);
     }
     $this->databaseConnection->sql_free_result($res_log);
 }