public function getAuthor() { return $this->obj_user_author ? $this->obj_user_author : ($this->obj_user_author = tx_mmforum_user::getUserByID($this->gD('topic_poster'))); }
/** * Lists all current user's posts in a HTML table, including page navigation and * general information like total post/topic count and average posts per day. * @param array $conf The plugin's configuration vars. * @param int $userId The UID of the user, whose posts are to be listed. * @param int $page The current page * @return string The HTML table */ function list_user_post($conf, $userId = 0, $page = 0) { $this->conf = $conf; $userId = intval($userId ? $userId : $GLOBALS['TSFE']->fe_user->user['uid']); if (!$userId) { return $this->errorMessage($conf, $this->pi_getLL('user.noLogin')); } $page = intval($this->useRealUrl() ? str_replace($this->pi_getLL('realurl.page') . '_', '', $page) : $page); $itemsPerPage = 10; $templateFile = $this->cObj->fileResource($conf['template.']['userdetail']); $template = $this->cObj->getSubpart($templateFile, '###USERPOSTS###'); $template_sub = $this->cObj->getSubpart($template, '###LIST###'); $marker = array('###LABEL_POSTLIST###' => $this->pi_getLL('user.postList'), '###LABEL_TOPIC###' => $this->pi_getLL('board.topic'), '###LABEL_LASTPOST###' => $this->pi_getLL('board.lastPost')); // Determine post count $res = $this->databaseHandle->exec_SELECTquery('COUNT(uid)', 'tx_mmforum_posts', 'hidden = 0 AND deleted = 0 AND poster_id = ' . $userId); list($count) = $this->databaseHandle->sql_fetch_row($res); $marker['###POSTCOUNT###'] = $this->getauthor($userId); // Determine topic count $res = $this->databaseHandle->exec_SELECTquery('COUNT(uid)', 'tx_mmforum_topics', 'hidden = 0 AND deleted = 0 AND topic_poster = "' . $userId . '"'); list($topics) = $this->databaseHandle->sql_fetch_row($res); // Build page navigation $pageCount = ceil($count / $itemsPerPage); if (!intval($this->conf['doNotUsePageBrowseExtension']) === 0) { $page--; // find the page right now, but if ($page -3) is less than 1, set it to at least "1" $page = max($page, 1); // also, $page is not allowed to be bigger than the $pageCount $page = min($page, $pageCount); // find the page links, but if ($page -3) is less than 1, set it to at least "1" $i = max($page - 3, 1); $pages = ''; for ($j = 1; $j <= 7; $j++) { $pagelink = tx_mmforum_user::listpost_pagelink($i, $i, $userId); if ($i >= 1 && $i <= $pageCount) { if ($i == $page) { $pages .= '|<strong> ' . $i . ' </strong>|'; } else { $pages .= $pagelink; } } $i++; } $min = $page > 1 ? tx_mmforum_user::listpost_pagelink('' . $this->pi_getLL('page.first'), 1, $userId) : ''; $left = $page > 2 ? tx_mmforum_user::listpost_pagelink('«' . $this->pi_getLL(''), $page - 1, $userId) : ''; $right = $page < $pageCount - 1 ? tx_mmforum_user::listpost_pagelink($this->pi_getLL('') . '»', $page + 1, $userId) : ''; $max = $page < $pageCount ? tx_mmforum_user::listpost_pagelink($this->pi_getLL('page.last') . '', $pageCount, $userId) : ''; $marker['###PAGES###'] = $min . $left . $pages . $right . $max; $marker['###PAGES###'] = str_replace('||', '|', $marker['###PAGES###']); } else { $marker['###PAGES###'] = $this->getListGetPageBrowser($pageCount); } $from = $itemsPerPage * $page; if ($count > 0) { $template = $this->cObj->substituteSubpart($template, '###NOPOSTS###', ''); // Read posts $res = $this->databaseHandle->exec_SELECTquery('t.topic_title, t.topic_is, t.solved, f.forum_name, c.forum_name AS category_name, p.*', 'tx_mmforum_posts p 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.hidden = 0 AND p.deleted = 0 AND p.poster_id = ' . $userId . ' ' . $this->getMayRead_forum_query('f'), '', 'p.crdate DESC', $from . ', ' . $itemsPerPage); $content = ''; while ($row = $this->databaseHandle->sql_fetch_assoc($res)) { $imgInfo = array('src' => $conf['path_img'] . $conf['images.']['solved'], 'alt' => $this->pi_getLL('topic.isSolved')); $solved = $row['solved'] ? $this->buildImageTag($imgInfo) : ''; $linkParams[$this->prefixId] = array('action' => 'list_post', 'tid' => $row['topic_id']); if ($this->useRealUrl()) { $linkParams[$this->prefixId]['fid'] = $row['forum_id']; } $postMarker = array('###TOPICNAME###' => ($row['topic_is'] ? $this->cObj->wrap($row['topic_is'], $this->conf['list_topics.']['prefix_wrap']) : '') . $this->pi_linkToPage($this->escape($row['topic_title']), $conf['pid_forum'], '', $linkParams) . $solved, '###TOPICDATE###' => $this->formatDate($row['post_time']), '###PREFIX###' => $this->escape($row['topic_is']), '###CATEGORY###' => $this->escape($row['category_name']), '###FORUM###' => $this->escape($row['forum_name']), '###READIMAGE###' => $this->getTopicIcon($row['topic_id'])); // Include hooks if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['listUserPosts_item'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['listUserPosts_item'] as $_classRef) { $_procObj =& GeneralUtility::getUserObj($_classRef); $postMarker = $_procObj->listUserPosts_item($postMarker, $row, $this); } } $content .= $this->cObj->substituteMarkerArrayCached($template_sub, $postMarker); } } else { $marker['###LABEL_NOPOSTS###'] = $this->pi_getLL('user.noposts'); } $res = $this->databaseHandle->exec_SELECTquery('crdate', 'fe_users', 'uid = ' . $userId); list($ucrdate) = $this->databaseHandle->sql_fetch_row($res); $marker['###STAT###'] .= '<strong>' . $count . '</strong> ' . $this->pi_getLL('user.totalPosts') . ', <strong>' . $topics . '</strong> ' . $this->pi_getLL('user.topicsTotal') . '<br />'; $marker['###STAT###'] .= $this->cObj->substituteMarker($this->pi_getLL('user.postsPerDay'), '###POSTS###', '<strong>' . round($count / ceil(($GLOBALS['EXEC_TIME'] - $ucrdate) / 86400), 2) . '</strong>'); $template = $this->cObj->substituteMarkerArray($template, $marker); $content = $this->cObj->substituteSubpart($template, '###LIST###', $content); return $content; }
/** * Returns a list with the 10 last posts from user_id * @param array $conf The plugin's configuration vars * @return string The content */ function post_history($conf) { if ($this->useRealUrl() && $this->piVars['fid']) { $this->piVars['user_id'] = tx_mmforum_tools::get_userid($this->piVars['fid']); } elseif (isset($this->piVars['user_id']) && !is_numeric($this->piVars['user_id'])) { $this->piVars['user_id'] = tx_mmforum_tools::get_userid($this->piVars['user_id']); } elseif (!isset($this->piVars['user_id'])) { $this->piVars['user_id'] = $GLOBALS['TSFE']->fe_user->user['uid']; } return tx_mmforum_user::list_user_post($conf, $this->piVars['user_id'], $this->useRealUrl() ? $this->piVars['tid'] : $this->piVars['page']); }