/** * Generates a custom forum category menu. * This function generates a custom navigation with a HMENU. This function can be included * as special.userfunc in HMENUs in TypoScript in order to display the mm_forum category * tree as a navigation line. * * @param string $content The content variable * @param array $conf The configuration array * @return array An array containing a set of HMENU items */ function catMenu($content, $conf) { $this->init($conf); $this->menuInit($conf); $result = array(); $forumPid = $conf['forumPID'] ? $conf['forumPID'] : $this->getForumPID(); $categoryAction = $conf['categoryAction'] ? $conf['categoryAction'] : 'list_cat'; $boardAction = $conf['boardAction'] ? $conf['boardAction'] : 'list_topic'; $activeCategory = intval($this->piVars['cid']); $activeBoard = intval($this->piVars['fid']); $activeTopic = intval($this->piVars['tid']); if ($activeTopic && !$activeBoard) { $activeBoard = tx_mmforum_pi1::get_forum_id($activeTopic); } $res = $this->databaseHandle->exec_SELECTquery('uid, forum_name AS name, parentID', 'tx_mmforum_forums', 'deleted = 0 AND hidden = 0' . $this->getStoragePIDQuery(), '', 'parentID ASC, sorting ASC'); // compile every entry in the list while ($row = $this->databaseHandle->sql_fetch_assoc($res)) { // top level = categories if ($row['parentID'] == 0) { $linkParams = array('action' => $categoryAction, 'cid' => $row['uid']); $menuItem = array('id' => $row['uid'], 'title' => $row['name'], '_OVERRIDE_HREF' => $this->pi_linkTP_keepPIvars_url($linkParams, 1, 1, $forumPid), 'ITEM_STATE' => $row['uid'] == $activeCategory ? 'ACT' : 'NO'); $result[] = $menuItem; } else { // 2nd level == forums $linkParams = array('action' => $boardAction, 'fid' => $row['uid']); $menuItem = array('id' => $row['uid'], 'title' => $row['name'], '_OVERRIDE_HREF' => $this->pi_linkTP_keepPIvars_url($linkParams, 1, 1, $forumPid), 'ITEM_STATE' => $row['uid'] == $activeBoard ? 'ACT' : 'NO'); $forums[$row['parentID']][] = $menuItem; } } // if a "forum" (2nd level) is active, we need to find the parentID to highlight // the parentID as ACTIFSUB foreach ($forums as $parentID => $menuItems) { foreach ($menuItems as $menuItem) { if ($menuItem['ITEM_STATE'] == 'ACT') { $activeCategory = $parentID; break; } } } // unless we use special.expAll = 1, set the parentID to ACTIFSUB and add // the second level of the category menu foreach ($result as &$menuItem) { if (($menuItem['ITEM_STATE'] == 'ACT' || $menuItem['id'] == $activeCategory || $conf['expAll']) && is_array($forums[$menuItem['id']])) { $menuItem['_SUB_MENU'] = $forums[$menuItem['id']]; $menuItem['ITEM_STATE'] = $menuItem['ITEM_STATE'] == 'ACT' || $menuItem['id'] == $activeCategory ? 'ACTIFSUB' : 'IFSUB'; } } // we also need to have the option that the category automatically displays the first subcategory if ($conf['linkCatToFirstBoard']) { foreach ($result as &$menuItem) { if (is_array($forums[$menuItem['id']])) { $firstBoard = reset($forums[$menuItem['id']]); if (is_array($firstBoard)) { $menuItem['_OVERRIDE_HREF'] = $firstBoard['_OVERRIDE_HREF']; } } } } return $result; }
/** * Removes a topic from a user's list of email subscriptions. * * @param tx_mmforum_pi1 $forumObj The plugin object * @return string An error message in case the redirect attempt to * the previous page fails. */ static function delete($forumObj) { $feUserId = intval($GLOBALS['TSFE']->fe_user->user['uid']); $forumId = intval($forumObj->piVars['fid']); // Executing database operations $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_mmforum_forummail', 'user_id = ' . $feUserId . ' AND forum_id = ' . $forumId . $forumObj->getStoragePIDQuery()); // Redirecting visitor back to previous page $forumObj->redirectToReferrer(); return $forumObj->pi_getLL('subscr.delSuccess') . '<br />' . $forumObj->pi_getLL('redirect.error') . '<br />'; }
/** * Conducts a search and displays the results. * This function gets the search results from the database, dependent * of the search string. * * @version 11. 10. 2006 * @param array $conf The plugin's configuration vars * @param string $searchstring The string of search words * @param array $param The parameter array for this function. Obsolete, since * this array is identical to the this->piVars array. * @return string The search results */ function searchfind($conf, $searchstring, $param) { $template = $this->cObj->fileResource($conf['template']); $template = $this->cObj->getSubpart($template, "###SEARCHRESULT###"); $template_sub = $this->cObj->getSubpart($template, "###SEARCHRESULT_SUB###"); // Language dependent markers $marker = array('###LABEL_RESULTS###' => $this->pi_getLL('search.results'), '###LABEL_TOPICINFO###' => $this->pi_getLL('search.topicinfo'), '###LABEL_REPLIES###' => $this->pi_getLL('search.replies'), '###LABEL_SOLVED###' => $this->pi_getLL('search.solved'), '###LABEL_CRUSER###' => $this->pi_getLL('search.cruser'), '###LABEL_CRDATE###' => $this->pi_getLL('search.crdate'), '###LLL_SEARCHRESULTS###' => $this->pi_getLL('search.searchresults'), '###IMG_CORNER###' => $conf['path_img'] . 'search-haken.gif', '###IMG_BACKGROUND###' => $conf['path_img'] . 'search-back.gif'); // Replace all special characters with space characters $orgsearchstring = $searchstring; $searchstring = str_replace('"', ' ', $searchstring); $searchstring = str_replace('+', ' ', $searchstring); $searchstring = str_replace('=', ' ', $searchstring); //$pattern = "/[^a-zA-Z0-9äüöÄÜÖß\*:\$._]/"; //$pattern = '/[^[\w\*]]/'; //$pattern = '/[\W^\*]/'; $pattern = '/[^\\w\\*]/'; #$searchstring = utf8_decode($searchstring); $searchstring = preg_replace($pattern, " ", $searchstring); //$searchstring = utf8_encode($searchstring); $post_id_array = $this->get_search_results($searchstring, $param); if (!is_array($post_id_array)) { $word_array = explode(' ', $searchstring); $good_words = array(); $bad_words = array(); $good_word_count = 0; foreach ($word_array as $val) { if (strtolower(substr($val, 0, 5)) == 'user:'******'min_length']) { // Check if search word is negated if (substr($val, 0, 1) == '-') { $val = substr($val, 1); $word_id = $this->word_id($val); if ($word_id) { foreach ($word_id as $wordval) { array_push($bad_words, $wordval); } } } else { $word_id = $this->word_id($val); if ($word_id) { $good_word_count++; foreach ($word_id as $wordval) { array_push($good_words, $wordval); } } } } } if (count($good_words) > 0 || isset($username)) { $good_posts = $this->find_posts($good_words, $param, $good_word_count, $username); } if (count($bad_words) > 0) { $bad_posts = $this->find_posts($bad_words, $param); } if ($bad_posts and $good_posts) { // Remove bad posts $post_id_array = array_diff($good_posts, $bad_posts); } else { $post_id_array = $good_posts; } if (count($post_id_array) > 0) { $post_id_array = array_flip($post_id_array); } // Write search result to database for later requests $userGroups = $GLOBALS['TSFE']->fe_user->groupData['uid']; sort($userGroups); $insertArray = array('pid' => $this->getStoragePID(), 'tstamp' => $GLOBALS['EXEC_TIME'], 'cruser_id' => is_array($GLOBALS['TSFE']->fe_user->user) ? $GLOBALS['TSFE']->fe_user->user['uid'] : 0, 'search_string' => $searchstring, 'array_string' => serialize($post_id_array), 'search_place' => $param['search_place'], 'solved' => isset($param['solved']) ? $param['solved'] : '', 'search_order' => $param['search_order'], 'groupPost' => $param['groupPost'], 'user_groups' => implode(',', $userGroups)); $this->databaseHandle->exec_INSERTquery('tx_mmforum_searchresults', $insertArray); if ($conf['debug_mode'] == 1) { echo '<h1>Suche Indiziert</h1>'; } } $treffer = count($post_id_array); $content = ''; if ($treffer > 0) { $find_array_split = array_chunk($post_id_array, $conf['show_items'], true); // Array in Pages Aufteilen if (empty($param['page'])) { $param['page'] = 0; } if (!intval($this->conf['doNotUsePageBrowseExtension']) === 0) { $page = $param['page'] - 1; } else { $page = $param['page']; } $post_id_array = $find_array_split[$page]; foreach ($post_id_array as $post_id => $values) { $topic_id = $this->tx_mmforum_pi1->get_topic_id($post_id); $topic_info = $this->topic_information($topic_id); $post_info = $this->post_information($post_id); $post_text = $this->get_posttext($post_id); $post_text = $this->clear_phpBB($post_text); $linkparams['tx_mmforum_pi1'] = array('action' => 'list_post', 'tid' => $topic_id, 'pid' => $post_id, 'sword' => addslashes($orgsearchstring)); if ($this->tx_mmforum_pi1->getIsRealURL()) { $linkparams['tx_mmforum_pi1']['fid'] = $topic_info['forum_id']; } $post_text = $this->escape(tx_mmforum_tools::textCut($post_text, 350, '')); $word_array = explode(" ", $searchstring); // Cleaning empty elements foreach ($word_array as $key => $value) { if ($value == '') { unset($word_array[$key]); } } $word_array = array_values($word_array); // Highlight Text with each word foreach ($word_array as $word) { $word = str_replace('$', '\\$', $word); $replace = $this->cObj->wrap("\\0", $this->conf['matchWrap']); $post_text = preg_replace("/{$word}/i", $replace, $post_text); } $marker['###TITLE###'] = $this->pi_linkToPage($this->escape($topic_info['topic_title']), $conf['pid_forum'], '', $linkparams); $marker['###SHORTTEXT###'] = $post_text; $dummylinkParams['tx_mmforum_pi1'] = array('action' => 'list_post', 'tid' => $topic_id); if ($this->tx_mmforum_pi1->getIsRealURL()) { $dummylinkParams['tx_mmforum_pi1']['fid'] = $topic_info['forum_id']; } #$link = GeneralUtility::getIndpEnv("HTTP_HOST").'/'.$this->pi_getPageLink($conf['pid_forum'],'',$dummylinkParams); $link = $this->tx_mmforum_pi1->getAbsUrl($this->pi_getPageLink($conf['pid_forum'], '', $dummylinkParams)); $link = $this->cObj->stdWrap($link, $conf['postPath.']); $marker['###POSTPATH###'] = $this->pi_linkToPage($link, $conf['pid_forum'], '_self', $linkparams); $marker['###VIEWS###'] = intval($topic_info['topic_views']); $marker['###ANSWERS###'] = intval($topic_info['topic_replies']); $marker['###CRDATE###'] = date("d.m.Y", $post_info['crdate']); $marker['###CRUSER###'] = tx_mmforum_pi4::get_username($post_info['poster_id']); if ($topic_info['solved'] == 1) { $marker['###SOLVED###'] = $this->pi_getLL('search.yes'); $marker['###SOLVEDIMAGE###'] = '<img src="' . $conf['path_img'] . $conf['images.']['solved'] . '" title="' . $this->pi_getLL('search.topicSolved') . '" alt="' . $this->pi_getLL('search.topicSolved') . '" />'; } else { $marker['###SOLVED###'] = $this->pi_getLL('search.no'); $marker['###SOLVEDIMAGE###'] = ''; } // Include hooks if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['search']['additionalPostMarkers'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['search']['additionalPostMarkers'] as $userFunction) { $params = array('marker' => $marker, 'topic_info' => $topic_info, 'post_info' => $post_info, 'post_text' => $post_text); $marker = GeneralUtility::callUserFunction($userFunction, $params, $this); } } $content .= $this->cObj->substituteMarkerArrayCached($template_sub, $marker); } $marker['###TREFFER###'] = $treffer; $marker['###PAGES###'] = $this->pagebar($treffer, $conf['show_items'], $param); $template = $this->cObj->substituteMarkerArrayCached($template, $marker); $content = $this->cObj->substituteSubpart($template, '###SEARCHRESULT_SUB###', $content); } else { $content = $this->pi_getLL('search.noResults'); } return $content; }
/** * @param $key * @return string */ function pi_getLL($key) { return $this->pObj->pi_getLL($key); }
/** * 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; }
/** * Shows the registration form. * @param array $marker An array of markers, with which the template is to * be filled. * @param $conf * @return string The registration form. */ function showRegForm($marker, $conf) { $template = $this->cObj->getSubpart($this->tmpl, "###TEMPLATE_CREATE###"); $marker["###FORM_URL###"] = $this->pi_getPageLink($GLOBALS["TSFE"]->id); $marker["###FORM_NAME###"] = $this->extKey . "[reg]"; if (ExtensionManagementUtility::isLoaded('captcha') && $this->conf['useCaptcha']) { $marker['###CAPTCHA_IMAGE###'] = '<img src="' . ExtensionManagementUtility::siteRelPath('captcha') . 'captcha/captcha.php" alt="" />'; } else { $template = $this->cObj->substituteSubpart($template, '###CAPTCHA###', ''); } $fields = 'username,name,tx_mmforum_occ,city,tx_mmforum_interests,www,email'; $fields = explode(',', $fields); //TODO: unused variable $requiredFields = GeneralUtility::trimExplode(',', $this->conf['required.']['fields']); $requiredFields[] = 'username'; $requiredFields[] = 'password'; $requiredFields[] = 'passwordrepeat'; $llMarker = array('###LABEL_REQUIRED###' => $this->pi_getLL('reg.requiredNote'), '###LABEL_USERNAME###' => $this->pi_getLL('reg.username'), '###LABEL_PASSWORD###' => $this->pi_getLL('reg.password'), '###LABEL_PASSWORDREPEAT###' => $this->pi_getLL('reg.passwordRepeat'), '###LABEL_NAME###' => $this->pi_getLL('reg.name'), '###LABEL_TX_MMFORUM_OCC###' => $this->pi_getLL('reg.profession'), '###LABEL_CITY###' => $this->pi_getLL('reg.location'), '###LABEL_TX_MMFORUM_INTERESTS###' => $this->pi_getLL('reg.interests'), '###LABEL_WWW###' => $this->pi_getLL('reg.website'), '###LABEL_CREATE###' => $this->pi_getLL('reg.create'), '###LABEL_EMAIL###' => $this->pi_getLL('reg.email'), '###LABEL_CAPTCHA###' => $this->pi_getLL('reg.captcha'), '###LABEL_REGISTRATION###' => $this->pi_getLL('reg.title'), '###IMG_MAIL###' => tx_mmforum_pi1::createButton('email', array(), 0, true, '', true), '###IMG_ICQ###' => tx_mmforum_pi1::createButton('icq', array(), 0, true, '', true), '###IMG_AIM###' => tx_mmforum_pi1::createButton('aim', array(), 0, true, '', true), '###IMG_YIM###' => tx_mmforum_pi1::createButton('yim', array(), 0, true, '', true), '###IMG_MSN###' => tx_mmforum_pi1::createButton('msn', array(), 0, true, '', true), '###IMG_SKYPE###' => tx_mmforum_pi1::createButton('skype', array(), 0, true, '', true)); /* Highlight required fields */ foreach ($requiredFields as $field) { $llMarker['###LABEL_' . strtoupper($field) . '###'] = $this->cObj->wrap($llMarker['###LABEL_' . strtoupper($field) . '###'], $this->conf['required.']['fieldWrap']); } /* Restore old markers for backwards compatibility */ $llMarker['###LABEL_PROFESSION###'] = $llMarker['###LABEL_TX_MMFORUM_OCC###']; $llMarker['###LABEL_LOCATION###'] = $llMarker['###LABEL_CITY###']; $llMarker['###LABEL_INTERESTS###'] = $llMarker['###LABEL_TX_MMFORUM_INTERESTS###']; $llMarker['###LABEL_WEBSITE###'] = $llMarker['###LABEL_WWW###']; $marker = array_merge($marker, $llMarker); $userField_template = $this->cObj->getSubpart($template, '###USERFIELDS###'); $userFields_content = ''; $res = $this->databaseHandle->exec_SELECTquery('*', 'tx_mmforum_userfields', 'deleted=0', '', 'sorting DESC'); if ($this->databaseHandle->sql_num_rows($res) > 0) { $userField = GeneralUtility::makeInstance('tx_mmforum_userfield'); $userField->init($this->userLib, $this->cObj); while ($arr = $this->databaseHandle->sql_fetch_assoc($res)) { $userField->get($arr); if ($this->conf['showOnlyRequiredUserfields'] == 1 && $userField->isRequired() || $this->conf['showOnlyRequiredUserfields'] != 1) { $label = $userField->getRenderedLabel(); if ($userField->isRequired()) { $label = $this->cObj->wrap($label, $this->conf['required.']['fieldWrap']); } $input = $userField->getRenderedInput($this->piVars['userfields'][$userField->getUID()]); if ($input === null) { $input = $this->cObj->getSubpart($userField_template, '###DEFUSERFIELD###'); } $userField_thisTemplate = $this->cObj->substituteSubpart($userField_template, '###DEFUSERFIELD###', $input); $userFields_marker = array('###USERFIELD_LABEL###' => $label, '###USERFIELD_UID###' => $userField->getUID(), '###USERFIELD_NAME###' => 'tx_mmforum_pi2[userfields][' . $userField->getUID() . ']', '###USERFIELD_VALUE###' => $this->piVars['userfields'][$userField->getUID()] ? $this->piVars['userfields'][$arr['uid']] : '', '###USERFIELD_ERROR###' => $marker['userfield_error'][$userField->getUID()]); if ($userFields_marker['###USERFIELD_ERROR###']) { $userFields_marker['###USERFIELD_ERROR###'] = $this->cObj->wrap($userFields_marker['###USERFIELD_ERROR###'], $this->conf['errorwrap']); } $userFields_content .= $this->cObj->substituteMarkerArrayCached($userField_thisTemplate, $userFields_marker); } } /* $parser = GeneralUtility::makeInstance('t3lib_TSparser'); while($arr = $this->databaseHandle->sql_fetch_assoc($res)) { $parser->setup = array(); if (strlen($arr['config'])>0) { $parser->parse($arr['config']); $config = $parser->setup; } else $config = array(); if ($config['label']) $label = $this->cObj->cObjGetSingle($config['label'],$config['label.']); else $label = $arr['label']; if ($config['required']) $label = $this->cObj->wrap($label, $this->conf['required.']['fieldWrap']); if ($config['input']) { $data = array( 'fieldvalue' => $value ); $tmpData = $this->cObj->data; $this->cObj->data = $data; $input = $this->cObj->cObjGetSingle($config['input'],$config['input.']); $this->cObj->data = $tmpData; } else $input = $this->cObj->getSubpart($userField_template, '###DEFUSERFIELD###'); $userField_thisTemplate = $this->cObj->substituteSubpart($userField_template, '###DEFUSERFIELD###', $input); if ($config['datasource']) { $label .= '<input type="hidden" name="tx_mmforum_pi2[userfields_exist]['.$arr['uid'].']" value="'.$config['datasource'].'" />'; } $userFields_marker = array( '###USERFIELD_LABEL###' => $label, '###USERFIELD_UID###' => $arr['uid'], '###USERFIELD_NAME###' => 'tx_mmforum_pi2[userfields]['.$arr['uid'].']', '###USERFIELD_VALUE###' => $this->piVars['userfields'][$arr['uid']]?$this->piVars['userfields'][$arr['uid']]:'', '###USERFIELD_ERROR###' => $marker['userfield_error'][$arr['uid']] ); $userFields_content .= $this->cObj->substituteMarkerArrayCached($userField_thisTemplate, $userFields_marker); } */ } $template = $this->cObj->substituteSubpart($template, '###USERFIELDS###', $userFields_content); $template = $this->cObj->substituteMarkerArrayCached($template, $marker); return $template; }