/** * Returns the user UID of a specific username. * * @deprecated Use tx_mmforum_tools::get_userid instead * @param string $username The username, whose user UID is to be determined. * @return int The user UID of $username. */ function get_userid($username) { GeneralUtility::logDeprecatedFunction(); return tx_mmforum_tools::get_userid($username); }
/** * Finds all posts and topics containing a certain word specified by * the word UID. * @param array $word_id_list An array of word UIDs that are to be searched * @param array $param The parameters for the search * @param int $words The amount of seach words (= count($word_id_list) ) * @param string $username Limits the posts searched to posts written by a * certain user, specified by $username * @return array A numeric array of all posts, one of the words specified * in $word_id_list was found in. */ function find_posts($word_id_list, $param, $words = 0, $username = '') { $mysql_option = ''; $word_id_list = implode(',', $word_id_list); if (!empty($word_id_list)) { $mysql_option = ' AND word_id IN (' . $word_id_list . ') '; } $mysql_group_option = ''; if ($words > 0) { if ($param['groupPost']) { $mysql_group_option .= ' topic_id HAVING count(post_id) >= ' . $words . ' '; } else { $mysql_group_option .= ' post_id HAVING count(post_id) >= ' . $words . ' '; } } if (is_numeric($param['search_place']) && $param['search_place'] > 0) { $mysql_option .= ' AND forum_id = ' . $this->databaseHandle->fullQuoteStr($param['search_place'], ''); } if ($param['solved'] == 1) { $mysql_option .= ' AND solved = 1 '; } if (!empty($username)) { $user_id = tx_mmforum_tools::get_userid($username); if (is_numeric($user_id) && $user_id != 0) { $mysql_option .= ' AND post_cruser = '******'TSFE']->fe_user->user) { $userGroups = $GLOBALS['TSFE']->fe_user->groupData['uid']; $fgrouprights_queries = array(); $cgrouprights_queries = array(); foreach ($userGroups as $userGroup) { $fgrouprights_queries[] = ' FIND_IN_SET(' . $userGroup . ',reqUserGroups_f) '; $cgrouprights_queries[] = ' FIND_IN_SET(' . $userGroup . ',reqUserGroups_c) '; } $mysql_option .= " AND (" . implode(' OR ', $fgrouprights_queries) . " OR reqUserGroups_f='')"; $mysql_option .= " AND (" . implode(' OR ', $cgrouprights_queries) . " OR reqUserGroups_c='')"; } switch ($param['search_order']) { default: $order_option = 'post_crdate DESC'; break; case "1": $order_option = 'post_crdate ASC'; break; case "2": $order_option = 'post_crdate DESC'; break; case "3": $order_option = 'topic_replies DESC'; break; case "4": $order_option = 'topic_replies ASC'; break; } if ($words > 0) { $count_option = ', count(post_id) as treffer'; } else { $count_option = ''; } $post_id_array = array(); // Array in denen die gefundenen Posts gespeichert werden if (!empty($mysql_option)) { $res = $this->databaseHandle->exec_SELECTquery('post_id, topic_id' . $count_option, 'tx_mmforum_wordmatch', '1=1 ' . $mysql_option . $this->getPidQuery(), $mysql_group_option, $order_option, ''); if ($this->conf['debug_mode']) { GeneralUtility::devLog('find_posts', 'mm_forum', 0, $this->databaseHandle->debug_lastBuiltQuery); } while ($row = $this->databaseHandle->sql_fetch_assoc($res)) { array_push($post_id_array, $row['post_id']); } } return $post_id_array; }
/** * Generates a custom rootline menu. * This function generates a custom rootline menu. This function can be included * as special.userfunc in HMENUs in TypoScript in order to merge the mm_forum * internal rootline with a global page rootline. On the same time, the property * tx_mmforum_pi1.disableRootline should be set to 1. * * @author Martin Helmich <*****@*****.**> * @version 2007-07-23 * @param string $content The content variable * @param array $conf The configuration array * @return array An array containing a set of HMENU items */ function createRootline($content, $conf) { $this->menuInit($conf); $result = array(); $action = $this->piVars['action']; switch ($action) { // List post view, new post form, post alert form // Displays a rootline like "mm_forum page -> Category -> Board -> Topic (-> New post/Report post)" case 'list_post': case 'new_post': case 'post_alert': $res = $this->databaseHandle->exec_SELECTquery('t.uid, t.forum_id, c.uid, topic_title, f.forum_name, c.forum_name', 'tx_mmforum_topics t, tx_mmforum_forums f, tx_mmforum_forums c', 't.uid="' . intval($this->piVars['tid']) . '" AND f.uid=t.forum_id AND c.uid=f.parentID'); list($topicId, $forumId, $catId, $topicTitle, $forumTitle, $catTitle) = $this->databaseHandle->sql_fetch_row($res); $topicTitle = stripslashes($topicTitle); $topicTitle = str_replace('<', '<', $topicTitle); $topicTitle = str_replace('>', '>', $topicTitle); if ($action == 'new_post') { $linkParams[$this->prefixId] = array('action' => 'new_post', 'tid' => $topicId, 'fid' => $forumId); $result[] = array('title' => $this->pi_getLL('rootline.reply'), '_OVERRIDE_HREF' => $this->pi_getPageLink($GLOBALS['TSFE']->id, '', $linkParams)); } elseif ($action == 'post_alert') { $linkParams[$this->prefixId] = array('action' => 'post_alert', 'tid' => $topicId, 'fid' => $forumId); $result[] = array('title' => $this->pi_getLL('rootline.post_alert'), '_OVERRIDE_HREF' => $this->pi_getPageLink($GLOBALS['TSFE']->id, '', $linkParams)); } break; // New topic form, topic listing view // Displays a rootline like "mm_forum page -> Category -> Board (-> New topic)" // New topic form, topic listing view // Displays a rootline like "mm_forum page -> Category -> Board (-> New topic)" case 'new_topic': case 'list_topic': $res = $this->databaseHandle->exec_SELECTquery('f.uid,f.forum_name,c.uid,c.forum_name', 'tx_mmforum_forums f, tx_mmforum_forums c', 'f.uid="' . intval($this->piVars['fid']) . '" AND c.uid=f.parentID'); list($forumId, $forumTitle, $catId, $catTitle) = $this->databaseHandle->sql_fetch_row($res); if ($action == 'new_topic') { $linkParams[$this->prefixId] = array('action' => 'new_topic', 'fid' => $forumId); $result[] = array('title' => $this->pi_getLL('rootline.new_topic'), '_OVERRIDE_HREF' => $this->pi_getPageLink($GLOBALS['TSFE']->id, '', $linkParams)); } break; // Post editing form // Displays a rootline like "mm_forum page -> Category -> Board -> Topic -> Edit post" // Post editing form // Displays a rootline like "mm_forum page -> Category -> Board -> Topic -> Edit post" case 'post_edit': $res = $this->databaseHandle->exec_SELECTquery('t.uid,t.forum_id,c.uid,topic_title,f.forum_name,c.forum_name', 'tx_mmforum_posts p, tx_mmforum_topics t, tx_mmforum_forums f, tx_mmforum_forums c', 'p.uid="' . intval($this->piVars['pid']) . '" AND t.uid=p.topic_id AND f.uid=p.forum_id AND c.uid=f.parentID'); list($topicId, $forumId, $catId, $topicTitle, $forumTitle, $catTitle) = $this->databaseHandle->sql_fetch_row($res); $topicTitle = stripslashes($topicTitle); $topicTitle = str_replace('<', '<', $topicTitle); $topicTitle = str_replace('>', '>', $topicTitle); $linkParams[$this->prefixId] = array('action' => 'post_edit', 'fid' => $forumId, 'tid' => $topicId, 'pid' => $this->piVars['pid']); $result[] = array('title' => $this->pi_getLL('rootline.edit_post'), '_OVERRIDE_HREF' => $this->pi_getPageLink($GLOBALS['TSFE']->id, '', $linkParams)); break; // User profile // Displays a rootline like "mm_forum page -> User profile: Username" // User profile // Displays a rootline like "mm_forum page -> User profile: Username" case 'forum_view_profil': if ($this->piVars['fid']) { $user_id = tx_mmforum_tools::get_userid($this->piVars['fid']); } else { $user_id = $this->piVars['user_id']; } $conf['userNameField'] ? $conf['userNameField'] : ($conf['userNameField'] = 'username'); $res = $this->databaseHandle->exec_SELECTquery($conf['userNameField'], 'fe_users', 'uid="' . intval($user_id) . '"'); list($username) = $this->databaseHandle->sql_fetch_row($res); $linkParams[$this->prefixId] = array('action' => 'forum_view_profil', 'user_id' => $this->piVars['user_id']); $result[] = array('title' => sprintf($this->pi_getLL('rootline.userprofile'), $username), '_OVERRIDE_HREF' => $this->pi_getPageLink($GLOBALS['TSFE']->id, '', $linkParams)); break; // List unread or unanswered topics // Displays a rootline like "mm_forum page -> List unread/unanswered topics" // List unread or unanswered topics // Displays a rootline like "mm_forum page -> List unread/unanswered topics" case 'list_unread': case 'list_unans': $linkParams[$this->prefixId] = array('action' => $action); $result[] = array('title' => $this->pi_getLL('rootline.' . $action), '_OVERRIDE_HREF' => $this->pi_getPageLink($GLOBALS['TSFE']->id, '', $linkParams)); break; } if ($topicId) { $topicParams[$this->prefixId] = array('action' => 'list_post', 'tid' => $topicId, 'fid' => $forumId); $result[] = array('title' => $topicTitle, '_OVERRIDE_HREF' => $this->pi_getPageLink($GLOBALS['TSFE']->id, '', $topicParams)); } if ($forumId) { $boardParams[$this->prefixId] = array('action' => 'list_topic', 'fid' => $forumId); $result[] = array('title' => $forumTitle, '_OVERRIDE_HREF' => $this->pi_getPageLink($GLOBALS['TSFE']->id, '', $boardParams)); } if ($catId) { $catParams[$this->prefixId] = array('action' => 'list_forum'); $result[] = array('title' => $catTitle, '_OVERRIDE_HREF' => $this->pi_getPageLink($GLOBALS['TSFE']->id) . '#cat' . $catId); } $result = array_reverse($result); if ($conf['entryLevel']) { $pageRootline = array_slice($GLOBALS['TSFE']->config['rootLine'], $conf['entryLevel']); } else { $pageRootline = $GLOBALS['TSFE']->config['rootLine']; } if (!$conf['includeNotInMenu']) { $pageRootline_final = array(); foreach ($pageRootline as $pageRootline_element) { if ($pageRootline_element['nav_hide'] != 1) { $pageRootline_final[] = $pageRootline_element; } } } else { $pageRootline_final = $pageRootline; } $result = array_merge((array) $pageRootline_final, $result); // Include hooks if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['display']['rootlineArray'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['display']['rootlineArray'] as $_classRef) { $_procObj =& GeneralUtility::getUserObj($_classRef); $result = $_procObj->processRootlineArray($result, $this); } } return $result; }