/** * Outputs a list of all posts alerted by users. * * This function output a list of all post alerts submitted by users. * It allows a filtering by post alert status and different ordering options. * @param array $conf The calling plugin's configuration vars * @return string The post alert list */ function list_alerts($conf) { $param = GeneralUtility::_GP('tx_mmforum_pi1'); if ($param['update'] == 'update_status') { foreach ($param as $key => $value) { $key = str_replace('status_', '', $key); if (is_numeric($key)) { $key = $this->databaseHandle->fullQuoteStr($key, 'tx_mmforum_post_alert'); $value = $this->databaseHandle->fullQuoteStr($value, 'tx_mmforum_post_alert'); $updateArray = array('status' => $value, 'tstamp' => $GLOBALS['EXEC_TIME']); $this->databaseHandle->exec_UPDATEquery('tx_mmforum_post_alert', 'uid=' . $key . ' AND status <> ' . $value, $updateArray); } } } $template = $this->cObj->fileResource($conf['template.']['post_alert']); $template = $this->cObj->getSubpart($template, "###ALERT_LIST###"); $template_sub = $this->cObj->getSubpart($template, "###ALERT_LIST_SUB###"); // Language dependent markers $marker = array('###LABEL_POSTALERTS###' => $this->pi_getLL('postalert.title'), '###LABEL_ORDERBY###' => $this->pi_getLL('postalert.orderby'), '###LABEL_ORDERBY_STATUS###' => $this->pi_getLL('postalert.orderby.status'), '###LABEL_ORDERBY_DATE###' => $this->pi_getLL('postalert.orderby.date'), '###LABEL_ORDERBY_USER###' => $this->pi_getLL('postalert.orderby.user'), '###LABEL_ORDERASC###' => $this->pi_getLL('postalert.ordermode.asc'), '###LABEL_ORDERDESC###' => $this->pi_getLL('postalert.ordermode.desc'), '###LABEL_DISPLAY###' => $this->pi_getLL('postalert.display'), '###LABEL_OPEN###' => $this->pi_getLL('postalert.status.open'), '###LABEL_INPROGRESS###' => $this->pi_getLL('postalert.status.progress'), '###LABEL_DONE###' => $this->pi_getLL('postalert.status.done'), '###LABEL_NR###' => $this->pi_getLL('postalert.number'), '###LABEL_DATE###' => $this->pi_getLL('postalert.date'), '###LABEL_PROBLEM###' => $this->pi_getLL('postalert.problem'), '###LABEL_POST###' => $this->pi_getLL('postalert.post'), '###LABEL_USER###' => $this->pi_getLL('postalert.user'), '###LABEL_STATUS###' => $this->pi_getLL('postalert.status'), '###LABEL_POSTTEXT###' => $this->pi_getLL('postalert.posttext')); $marker['###ORDERBY_USER###'] = ''; $marker['###ORDERBY_DATE###'] = ''; $marker['###ORDERBY_STAT###'] = ''; $marker['###ORDERASC###'] = ''; $marker['###ORDERDESC###'] = ''; $marker['###VIEW_OPEN###'] = ''; $marker['###VIEW_WORK###'] = ''; $marker['###VIEW_CLOSE###'] = ''; // Determine ordering mode switch ($param['order_by']) { case "user": $order_by = 'cruser_id'; $marker['###ORDERBY_USER###'] = 'selected'; break; case "date": $order_by = 'crdate'; $marker['###ORDERBY_DATE###'] = 'selected'; break; case "status": $order_by = 'status'; $marker['###ORDERBY_STAT###'] = 'selected'; break; default: $order_by = 'status'; $marker['###ORDERBY_STAT###'] = 'selected'; break; } switch ($param['order']) { case "up": $order = 'ASC'; $marker['###ORDERASC###'] = 'selected'; break; case "down": $order = 'DESC'; $marker['###ORDERDESC###'] = 'selected'; break; default: $order = 'ASC'; $marker['###ORDERASC###'] = 'selected'; break; } $allowedStatus = array(); // Determine filtering mode if ($param['view_open'] == 1) { $marker['###VIEW_OPEN###'] = 'checked'; #$where .= 'OR status = -1 '; $allowedStatus[] = -1; } if ($param['view_work'] == 1) { $marker['###VIEW_WORK###'] = 'checked'; #$where .= 'OR status = 0 ';= -1 '; $allowedStatus[] = 0; } if ($param['view_close'] == 1) { $marker['###VIEW_CLOSE###'] = 'checked'; #$where .= 'OR status = 1 ';= -1 '; $allowedStatus[] = 1; } if ($param['view_close'] == '' and $param['view_work'] == '' and $param['view_open'] == '' and empty($param)) { $marker['###VIEW_OPEN###'] = 'checked'; $marker['###VIEW_WORK###'] = 'checked'; $marker['###VIEW_CLOSE###'] = ''; #$where = ' OR status = -1 OR status = 0'; $allowedStatus = array(0, -1); } $where = count($allowedStatus) ? ' AND status IN (' . implode(',', $allowedStatus) . ') ' : ''; $boards = tx_mmforum_postalert::getModeratorBoards(); if ($boards === false) { $accessWhere = ' AND 0=1 '; } elseif ($boards === true) { $accessWhere = ' AND 1=1 '; } else { $accessWhere = ' AND t.forum_id IN (' . implode(',', $boards) . ') '; } // Load post alert records from database $res = $this->databaseHandle->exec_SELECTquery('a.*', 'tx_mmforum_post_alert a LEFT JOIN tx_mmforum_topics t ON a.topic_id = t.uid', "1 = 1 {$where} {$accessWhere}", '', $order_by . ' ' . $order); $content_sub = ''; while ($row = $this->databaseHandle->sql_fetch_assoc($res)) { $marker['###STATUS###'] = ''; switch ($row['status']) { case '-1': $marker['###STATCOLOR###'] = $this->conf['postalerts.']['statusColors.']['open']; $marker['###STATUS###'] .= '<option value="-1" selected>' . $this->pi_getLL('postalert.status.open') . '</option>'; $marker['###STATUS###'] .= '<option value="0">' . $this->pi_getLL('postalert.status.progress') . '</option>'; $marker['###STATUS###'] .= '<option value="1">' . $this->pi_getLL('postalert.status.done') . '</option>'; break; case '0': $marker['###STATCOLOR###'] = $this->conf['postalerts.']['statusColors.']['work']; $marker['###STATUS###'] .= '<option value="-1">' . $this->pi_getLL('postalert.status.open') . '</option>'; $marker['###STATUS###'] .= '<option value="0" selected>' . $this->pi_getLL('postalert.status.progress') . '</option>'; $marker['###STATUS###'] .= '<option value="1">' . $this->pi_getLL('postalert.status.done') . '</option>'; break; case '1': $marker['###STATCOLOR###'] = $this->conf['postalerts.']['statusColors.']['done']; $marker['###STATUS###'] .= '<option value="-1">' . $this->pi_getLL('postalert.status.open') . '</option>'; $marker['###STATUS###'] .= '<option value="0">' . $this->pi_getLL('postalert.status.progress') . '</option>'; $marker['###STATUS###'] .= '<option value="1" selected>' . $this->pi_getLL('postalert.status.done') . '</option>'; break; } $linkparams[$this->prefixId] = array('action' => 'list_post', 'tid' => $row['topic_id'], 'pid' => $row['post_id']); list($posttext) = $this->databaseHandle->sql_fetch_row($this->databaseHandle->exec_SELECTquery('post_text', 'tx_mmforum_posts_text', 'deleted="0" AND hidden="0" AND post_id="' . $row['post_id'] . '"')); $marker['###UID###'] = $row['uid']; $marker['###TOPIC###'] = $this->pi_linkToPage($this->escape($this->get_topic_name($row['topic_id'])), $conf['pid_forum'], $target = '_self', $linkparams); $marker['###DATE###'] = $this->formatDate($row['crdate']); $marker['###POST_TEXT###'] = nl2br($this->escape($posttext)); $marker['###TEXT_SHORT###'] = $this->escape(tx_mmforum_tools::textCut($row['alert_text'], 15, '')); $marker['###TEXT###'] = nl2br($this->escape($row['alert_text'])); $mod_data = tx_mmforum_tools::get_userdata($row['cruser_id']); $marker['###MOD###'] = $mod_data[$this->getUserNameField()]; $marker['###POST_USER###'] = $this->pi_linkToPage($mod_data[$this->getUserNameField()], $conf['pm_id'], '', array('tx_mmforum_pi3[action]' => 'message_write', 'userid' => $row['cruser_id'])); $content_sub .= $this->cObj->substituteMarkerArrayCached($template_sub, $marker); } $content = $this->cObj->substituteSubpart($template, '###ALERT_LIST_SUB###', $content_sub); $marker['###FORMACTION###'] = $this->escapeURL($this->pi_getPageLink($GLOBALS["TSFE"]->id, '', $linkparams)); $content = $this->cObj->substituteMarkerArrayCached($content, $marker); return $content; }
/** * 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; }