/**
  * Displays the post queue.
  * This function displays all elements of the postqueue in a list
  * view.
  *
  * @author  Martin Helmich
  * @version 2007-07-21
  * @return  string The postqueue list content
  */
 function display_postQueue()
 {
     $template = $this->cObj->fileResource($this->conf['template.']['postqueue']);
     $template = $this->cObj->getSubpart($template, '###POSTQUEUE_LIST###');
     $template_row = $this->cObj->getSubpart($template, '###POSTQUEUE_ITEM###');
     $marker = array('###LLL_PUBLISH###' => $this->pi_getLL('postqueue.publishtab'), '###LLL_DELETE###' => $this->pi_getLL('postqueue.deletetab'), '###LLL_IGNORE###' => $this->pi_getLL('postqueue.ignoretab'), '###LLL_POSTTEXT###' => $this->pi_getLL('postqueue.posttext'), '###LLL_POSTQUEUE###' => $this->pi_getLL('postqueue.title'), '###LLL_PUBLISHBUTTON###' => $this->pi_getLL('postqueue.publishbutton'), '###LLL_NOITEMS###' => $this->pi_getLL('postqueue.noitems'), '###ACTION###' => $this->parent->escapeURL($this->parent->pi_getPageLink($GLOBALS['TSFE']->id)));
     $template = $this->cObj->substituteMarkerArray($template, $marker);
     $rContent = '';
     $boards = $this->getModeratorBoards();
     if (is_array($boards)) {
         $res = $this->databaseHandle->exec_SELECTquery('q.*', 'tx_mmforum_postqueue q LEFT JOIN tx_mmforum_topics t ON q.post_parent = t.uid', 'q.deleted = 0 AND (t.deleted=0 OR t.uid IS NULL) AND (q.topic_forum IN (' . implode(',', $boards) . ') OR t.forum_id IN (' . implode(',', $boards) . '))', '', 'q.crdate DESC');
     } elseif ($boards === true) {
         $res = $this->databaseHandle->exec_SELECTquery('*', 'tx_mmforum_postqueue', 'deleted=0', '', 'crdate DESC');
     }
     if ($boards !== false) {
         if ($this->databaseHandle->sql_num_rows($res) > 0) {
             $template = $this->cObj->substituteSubpart($template, '###POSTQUEUE_NOITEMS###', '');
         } else {
             $template = $this->cObj->substituteSubpart($template, '###POSTQUEUE_ITEMLIST###', '');
         }
         while ($arr = $this->databaseHandle->sql_fetch_assoc($res)) {
             $rMarker = array('###LLL_WROTE###' => $this->pi_getLL('postqueue.wrote'), '###DATE###' => $this->parent->formatDate($arr['post_time']), '###POST_TEXT###' => $this->tx_mmforum_postparser->main($this->parent, $this->conf, $this->parent->escape($arr['post_text']), 'textparser'), '###UID###' => $arr['uid'], '###POST_POSTER###' => $this->parent->linkToUserProfile($arr['post_user']), '###CHECK_DELETE###' => '', '###CHECK_IGNORE###' => $arr['hidden'] ? 'checked="checked"' : '', '###CHECK_PUBLISH###' => $arr['hidden'] ? '' : 'checked="checked"', '###FORUMPATH###' => $this->getForumLink($arr['topic_forum']));
             if ($arr['topic']) {
                 $rMarker['###TOPIC_LINK###'] = $this->parent->escape($arr['topic_title']) . ' [' . $this->pi_getLL('postqueue.newTopic') . ']';
             } else {
                 $tData = $this->parent->getTopicData($arr['post_parent']);
                 $linkParams[$this->parent->prefixId] = array('action' => 'list_post', 'tid' => $tData['uid']);
                 if ($this->parent->getIsRealURL()) {
                     $linkParams[$this->parent->prefixId]['fid'] = $tData['forum_id'];
                 }
                 $rMarker['###TOPIC_LINK###'] = $this->parent->pi_linkToPage($this->parent->escape($tData['topic_title']), $this->conf['pid_forum'], '', $linkParams);
             }
             $rContent .= $this->cObj->substituteMarkerArray($template_row, $rMarker);
         }
         $template = $this->cObj->substituteSubpart($template, '###POSTQUEUE_ITEM###', $rContent);
     } else {
         $template = $this->cObj->substituteSubpart($template, '###POSTQUEUE_ITEMLIST###', '');
     }
     return $template;
 }
 /**
  * Display a poll.
  * This function displays a poll. Depending on whether the user that is
  * currently logged in is allowed to vote on this poll (this will be the
  * case if the user has not already voted in this poll and if the poll is
  * not yet expired), the user will see a set of radio buttons allowing him/her
  * to choose an answering possibility, or the poll results.
  *
  * @return  string The poll content
  * @version 2007-05-22
  */
 function objDisplay()
 {
     if ($this->piVars['poll']['vote'] == '1') {
         $this->objVote();
     }
     $template = $this->cObj->fileResource($this->conf['template.']['polls']);
     $template = $this->cObj->getSubpart($template, '###POLL_DISPLAY###');
     $vote = $this->getMayVote();
     if (!$vote) {
         $template = $this->cObj->substituteSubpart($template, '###POLL_SUBMIT###', '');
         $row_template = $this->cObj->getSubpart($template, '###POLL_ANSWER_2###');
     } else {
         $row_template = $this->cObj->getSubpart($template, '###POLL_ANSWER_1###');
     }
     $res = $this->databaseHandle->exec_SELECTquery('*', 'tx_mmforum_polls_answers', 'poll_id=' . intval($this->data['uid']) . ' AND deleted=0');
     $i = 1;
     $aContent = '';
     while ($arr = $this->databaseHandle->sql_fetch_assoc($res)) {
         $pAnswers = $arr['votes'] > 0 ? round($arr['votes'] / $this->data['votes'] * 100) : 0;
         if ($this->conf['polls.']['pollBar_colorMap.'][$i]) {
             $color = $this->conf['polls.']['pollBar_colorMap.'][$i];
         } else {
             $color = $this->conf['polls.']['pollBar_colorMap.']['default'];
         }
         $aMarker = array('###ANSWER_UID###' => $arr['uid'], '###ANSWER_TEXT###' => $this->p->escape($arr['answer']), '###ANSWER_COUNT###' => sprintf($this->p->pi_getLL('poll.replies'), $arr['votes'], $this->data['votes'], $pAnswers . '%'), '###ANSWER_ANSWERS###' => '<div style="width: ' . $pAnswers . '%; height:10px; background-color: ' . $color . ';">&nbsp;</div>', '###ENABLE###' => '');
         $aContent .= $this->cObj->substituteMarkerArray($row_template, $aMarker);
         $i++;
     }
     $actionParams[$this->p->prefixId] = array('tid' => $this->p->piVars['tid'], 'fid' => $this->p->piVars['fid'], 'action' => 'list_post');
     $actionLink = $this->p->pi_getPageLink($GLOBALS['TSFE']->id, '', $actionParams);
     $marker = array('###LABEL_POLL###' => $this->p->pi_getLL('poll.title'), '###LABEL_VOTE###' => $this->p->pi_getLL('poll.vote'), '###LABEL_QUESTION###' => $this->p->pi_getLL('poll.question'), '###QUESTION###' => $this->p->escape($this->data['question']), '###EXPIRES###' => $this->data['endtime'] ? $this->p->pi_getLL('poll.expires') . ' ' . date('d. m. Y, H:i', $this->data['endtime']) : '', '###ACTION###' => $this->p->escapeURL($actionLink), '###ICON###' => $this->cObj->cObjGetSingle($this->conf['polls.']['poll_icon'], $this->conf['polls.']['poll_icon.']));
     $marker['###EXPIRES###'] = $this->cObj->stdWrap($marker['###EXPIRES###'], $this->conf['polls.']['expired_stdWrap.']);
     $template = $this->cObj->substituteMarkerArray($template, $marker);
     $template = $this->cObj->substituteSubpart($template, '###POLL_ANSWER_1###', $aContent);
     $template = $this->cObj->substituteSubpart($template, '###POLL_ANSWER_2###', '');
     return $template;
 }
 /**
  * Displays a list of a user's email subscriptions.
  * Performs also actions like editing or deleting subscriptions.
  * @param \tx_mmforum_base $forumObj
  * @return string
  */
 static function edit(\tx_mmforum_base $forumObj)
 {
     $content = '';
     $feUserId = intval($GLOBALS['TSFE']->fe_user->user['uid']);
     // can be
     //    "topic" - only topic subscriptions
     //    "forum" - only forum subscriptions
     //    "all"    - both of them (default)
     $displayMode = 'all';
     if ($forumObj->conf['havealook.']['displayOnlyTopics']) {
         $displayMode = 'topic';
     }
     if (isset($forumObj->piVars['displayMode'])) {
         $displayMode = $forumObj->piVars['displayMode'];
     }
     if ($feUserId) {
         // Delete a single subscription (through the link at every subscription)
         if ($forumObj->piVars['deltid']) {
             $deleleTopicId = intval($forumObj->piVars['deltid']);
             if ($forumObj->piVars['delmode'] == 'topic') {
                 $this->databaseHandle->exec_DELETEquery('tx_mmforum_topicmail', 'user_id = ' . $feUserId . ' AND topic_id = ' . $deleleTopicId . $forumObj->getStoragePIDQuery());
             } else {
                 $this->databaseHandle->exec_DELETEquery('tx_mmforum_forummail', 'user_id = ' . $feUserId . ' AND forum_id = ' . $deleleTopicId . $forumObj->getStoragePIDQuery());
             }
             unset($forumObj->piVars['deltid']);
         }
         // Delete several subscriptions (through the checkboxes)
         if ($forumObj->piVars['havealook_action'] == 'delete') {
             foreach ((array) $forumObj->piVars['fav_delete']['topic'] as $deleleTopicId) {
                 $this->databaseHandle->exec_DELETEquery('tx_mmforum_topicmail', 'user_id = ' . $feUserId . ' AND topic_id = ' . intval($deleleTopicId) . $forumObj->getStoragePIDQuery());
             }
             foreach ((array) $forumObj->piVars['fav_delete']['forum'] as $deleleTopicId) {
                 $this->databaseHandle->exec_DELETEquery('tx_mmforum_forummail', 'user_id = ' . $feUserId . ' AND forum_id = ' . intval($deleleTopicId) . $forumObj->getStoragePIDQuery());
             }
             unset($forumObj->piVars['havealook_action']);
         }
         // Determination of sorting mode
         $orderBy = $forumObj->piVars['order'] ? $forumObj->piVars['order'] : 'added';
         // rendering the settings
         $templateFile = $forumObj->cObj->fileResource($forumObj->conf['template.']['havealook']);
         $template = $forumObj->cObj->getSubpart($templateFile, '###HAVEALOOK_SETTINGS###');
         $marker = array('###ACTION###' => $forumObj->escapeURL($forumObj->pi_linkTP_keepPIvars_url()), '###ORDER_LPDATE###' => $orderBy == 'lpdate' ? 'selected="selected"' : '', '###ORDER_CAT###' => $orderBy == 'cat' ? 'selected="selected"' : '', '###ORDER_ADDED###' => $orderBy == 'added' ? 'selected="selected"' : '', '###ORDER_ALPHAB###' => $orderBy == 'alphab' ? 'selected="selected"' : '', '###LABEL_ORDERBY###' => $forumObj->pi_getLL('favorites.orderBy'), '###LABEL_ORDER_LPDATE###' => $forumObj->pi_getLL('favorites.orderBy.lpdate'), '###LABEL_ORDER_CAT###' => $forumObj->pi_getLL('favorites.orderBy.cat'), '###LABEL_ORDER_ADDED###' => $forumObj->pi_getLL('favorites.orderBy.added'), '###LABEL_ORDER_ALPHAB###' => $forumObj->pi_getLL('favorites.orderBy.alphab'));
         // Include hook to modify the output of the settings
         if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['havealook']['listsettings'])) {
             foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['havealook']['listsettings'] as $_classRef) {
                 $_procObj =& GeneralUtility::getUserObj($_classRef);
                 $marker = $_procObj->havealook_listsettings($marker, $forumObj);
             }
         }
         $content = $forumObj->cObj->substituteMarkerArray($template, $marker);
         // rendering the head part
         $template = $forumObj->cObj->getSubpart($templateFile, '###HAVEALOOK_BEGIN###');
         $marker = array('###ACTION###' => $forumObj->escapeURL($forumObj->pi_linkTP_keepPIvars_url()), '###LABEL_HAVEALOOK###' => $forumObj->pi_getLL('havealook.title'), '###LABEL_OPTIONS###' => $forumObj->pi_getLL('favorites.options'), '###LABEL_TOPICNAME###' => $forumObj->pi_getLL('topic.title'), '###LABEL_CONFIRMMULTIPLE###' => $forumObj->pi_getLL('havealook.confirmMultiple'));
         $content .= $forumObj->cObj->substituteMarkerArray($template, $marker);
         switch ($orderBy) {
             case 'lpdate':
                 $order = 'item_lastpost_uid DESC';
                 break;
             case 'cat':
                 $order = 'cat_order ASC, forum_order ASC, item_lastpost_uid DESC';
                 break;
             case 'added':
                 $order = 'mail_uid DESC';
                 break;
             case 'alphab':
             default:
                 $order = 'item_title ASC';
                 break;
         }
         $sqlTopic = 'SELECT' . '	t.topic_title			AS item_title,' . '	t.uid					AS item_uid,' . '	t.topic_last_post_id	AS item_lastpost_uid,' . '	t.solved				AS item_solved,' . '	t.topic_is				AS item_prefix,' . '	m.uid 					AS mail_uid,' . '	f.forum_name			AS forum_title,' . '	f.uid					AS forum_uid,' . '	f.forum_last_post_id	AS forum_lastpost_id,' . '	f.sorting 				AS forum_order,' . '	c.forum_name			AS cat_title,' . '	c.uid					AS cat_uid,' . '	c.sorting 				AS cat_order,' . '	"topic" 				AS notify_mode ' . 'FROM' . '	tx_mmforum_topicmail m' . '	LEFT JOIN tx_mmforum_topics t ON m.topic_id = t.uid ' . '	LEFT JOIN tx_mmforum_forums f ON t.forum_id = f.uid ' . '	LEFT JOIN tx_mmforum_forums c ON f.parentID = c.uid ' . 'WHERE' . '	m.user_id = ' . $feUserId . ' AND ' . '	m.deleted = 0 AND' . '	t.deleted = 0 AND' . '	f.deleted = 0 AND' . '	c.deleted = 0 ' . $forumObj->getMayRead_forum_query('f') . $forumObj->getMayRead_forum_query('c');
         $sqlForum = 'SELECT' . '	f.forum_name			AS item_title,' . '	f.uid					AS item_uid,' . '	f.forum_last_post_id	AS item_lastpost_uid,' . '	0						AS item_solved,' . '	""						AS item_prefix,' . '	m.uid					AS mail_uid,' . '	f.forum_name			AS forum_title,' . '	f.uid					AS forum_uid,' . '	f.forum_last_post_id	AS forum_lastpost_uid,' . '	f.sorting				AS forum_order,' . '	c.forum_name			AS cat_title,' . '	c.uid					AS cat_uid,' . '	c.sorting				AS cat_order,' . '	"forum"					AS notify_mode ' . 'FROM' . '	tx_mmforum_forummail m' . '	LEFT JOIN tx_mmforum_forums f ON m.forum_id = f.uid ' . '	LEFT JOIN tx_mmforum_forums c ON (f.parentID = c.uid OR (f.parentID = 0 AND f.uid = c.uid)) ' . 'WHERE' . '	m.user_id = ' . $feUserId . ' AND ' . '	m.deleted = 0 AND ' . '	f.deleted = 0 AND ' . '	c.deleted = 0 ' . $forumObj->getMayRead_forum_query('f') . $forumObj->getMayRead_forum_query('c');
         if ($displayMode == 'topic') {
             $sql = $sqlTopic;
         } else {
             if ($displayMode == 'forum') {
                 $sql = $sqlForum;
             } else {
                 $sql = '(' . $sqlTopic . ') UNION (' . $sqlForum . ')';
             }
         }
         $sql .= 'ORDER BY ' . $order;
         $res = $this->databaseHandle->sql_query($sql);
         if ($this->databaseHandle->sql_num_rows($res) == 0) {
             $template = $forumObj->cObj->getSubpart($templateFile, '###LIST_HAVEALOOK_EMPTY###');
             $content .= $forumObj->cObj->substituteMarker($template, '###LLL_HAVEALOOK_EMPTY###', $forumObj->pi_getLL('havealook.empty'));
         } else {
             $template = $forumObj->cObj->getSubpart($templateFile, '###LIST_HAVEALOOK###');
             // go through every found subscription
             while ($row = $this->databaseHandle->sql_fetch_assoc($res)) {
                 if ($row['notify_mode'] == 'topic') {
                     $linkParams[$forumObj->prefixId] = array('action' => 'list_post', 'tid' => $row['item_uid']);
                     $marker['###TOPICICON###'] = $forumObj->getTopicIcon($row['item_uid']);
                 } else {
                     $linkParams[$forumObj->prefixId] = array('action' => 'list_prefix', 'fid' => $row['item_uid']);
                     $marker['###TOPICICON###'] = $forumObj->getForumIcon($row['item_uid']);
                 }
                 $imgInfo = array('src' => $forumObj->conf['path_img'] . $forumObj->conf['images.']['solved'], 'alt' => $forumObj->pi_getLL('topic.isSolved'));
                 $marker['###SOLVED###'] = $row['item_solved'] == 1 ? $forumObj->buildImageTag($imgInfo) : '';
                 $marker['###PREFIX###'] = $row['item_prefix'] ? $forumObj->cObj->wrap($row['item_prefix'], $forumObj->conf['list_topics.']['prefix_wrap']) : '';
                 $marker['###NAME###'] = $forumObj->pi_linkToPage($forumObj->escape($row['item_title']), $forumObj->conf['pid_forum'], '', $linkParams);
                 $marker['###FORUMNAME###'] = $forumObj->escape($row['forum_title']);
                 $marker['###CATEGORY###'] = $forumObj->escape($row['cat_title']);
                 $marker['###TOPICNAME###'] = $marker['###PREFIX###'] . $marker['###NAME###'] . $marker['###SOLVED###'];
                 $marker['###TOPICSUB###'] = $marker['###CATEGORY###'] . ' / ' . $marker['###FORUMNAME###'] . ($row['notify_mode'] == 'topic' ? ' / ' . $forumObj->escape($row['item_title']) : '');
                 $marker['###TOPIC_CHECKBOX###'] = '<input type="checkbox" name="tx_mmforum_pi1[fav_delete][' . $row['notify_mode'] . '][]" value="' . $row['item_uid'] . '" />';
                 $linkParams[$forumObj->prefixId] = array('action' => 'havealook', 'deltid' => $row['item_uid'], 'delmode' => $row['notify_mode']);
                 $marker['###DELETELINK###'] = $marker['###TOPICDELLINK###'] = $forumObj->pi_linkTP($forumObj->pi_getLL('havealook.delete'), $linkParams);
                 // Include hook to modify the output of each item
                 if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['havealook']['listitem'])) {
                     foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['havealook']['listitem'] as $_classRef) {
                         $_procObj =& GeneralUtility::getUserObj($_classRef);
                         $marker = $_procObj->havealook_listitem($marker, $row, $forumObj);
                     }
                 }
                 $content .= $forumObj->cObj->substituteMarkerArrayCached($template, $marker);
             }
         }
         $template = $forumObj->cObj->getSubpart($templateFile, '###HAVEALOOK_END###');
         $marker = array('###LABEL_MARKEDTOPICS###' => $forumObj->pi_getLL('havealook.markedTopics'), '###LABEL_DELETE###' => $forumObj->pi_getLL('havealook.delete'), '###LABEL_GO###' => $forumObj->pi_getLL('havealook.go'));
     } else {
         $templateFile = $forumObj->cObj->fileResource($forumObj->conf['template.']['login_error']);
         $template = $forumObj->cObj->getSubpart($templateFile, '###LOGINERROR###');
         $marker = array('###LOGINERROR_MESSAGE###' => $forumObj->pi_getLL('subscr.noLogin'));
     }
     // Include hook to modify the output of the whole thing
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['havealook']['edit'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['havealook']['edit'] as $_classRef) {
             $_procObj =& GeneralUtility::getUserObj($_classRef);
             $marker = $_procObj->havealook_edit($marker, $forumObj);
         }
     }
     $content .= $forumObj->cObj->substituteMarkerArray($template, $marker);
     return $content;
 }