/** * 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; }
/** * Displays a poll creation form. * This function displays a form allowing the user to create a new post. * * @param array $piVars * @param tx_mmforum_base $pObj * @return string The form content * @version 2007-05-25 */ function display_createForm($piVars = array(), $pObj = NULL) { if (!$pObj->conf['polls.']['enable']) { return ''; } $defACount = $pObj->conf['polls.']['minAnswers']; $rDefACount = $defACount; if ($piVars) { $defACount = count($piVars['answer']['new']) > $defACount ? count($piVars['answer']['new']) : $defACount; } $template = $pObj->cObj->fileResource($pObj->conf['template.']['polls']); $template = $pObj->cObj->getSubpart($template, '###POLL_FORM###'); $answerTemplate = $pObj->cObj->getSubpart($template, '###ANSWERSECTION###'); $marker = array('###LABEL_QUESTION###' => $pObj->pi_getLL('poll.question'), '###LABEL_ANSWERS###' => $pObj->pi_getLL('poll.answers'), '###QUESTION###' => $pObj->escape($piVars ? $piVars['question'] : ''), '###ANSWER###' => '', '###DELETE###' => $pObj->pi_getLL('poll.deleteAnswer'), '###ADD_ANSWER###' => $pObj->pi_getLL('poll.addAnswer'), '###DELCONFIRM###' => $pObj->pi_getLL('poll.deleteAnswerConf'), '###LABEL_EXPIRES###' => $pObj->pi_getLL('poll.expires'), '###LABEL_NEWANSWER###' => $pObj->pi_getLL('poll.addAnswer'), '###ENB_EXP###' => $piVars['expires']['act'] ? '' : 'disabled="disabled"', '###DAY###' => $piVars['expires']['act'] ? $piVars['expires']['day'] : 'DD', '###MONTH###' => $piVars['expires']['act'] ? $piVars['expires']['month'] : 'MM', '###YEAR###' => $piVars['expires']['act'] ? $piVars['expires']['year'] : 'YYYY', '###HOUR###' => $piVars['expires']['act'] ? $piVars['expires']['hour'] : 'HH', '###MINUTE###' => $piVars['expires']['act'] ? $piVars['expires']['minute'] : 'MM', '###EXPIRES###' => $piVars['expires']['act'] ? 'checked="checked"' : '', '###DELETEFIELDS###' => '', '###DISABLED###' => $this->getMayCreatePoll($pObj) ? '' : 'disabled="disabled"', '###DISABLED_VAR###' => $this->getMayCreatePoll($pObj) ? 0 : 1); $template = $pObj->cObj->substituteMarkerArrayCached($template, $marker); $answers = ''; for ($i = 0; $i < $defACount; $i++) { $marker = array('###ANSWER###' => $pObj->escape($piVars ? $piVars['answer']['new'][$i] : ''), '###ANSWER_UID###' => '', '###ANSWER_MODE###' => 'new', '###DELETE###' => $pObj->pi_getLL('poll.deleteAnswer'), '###DISABLED###' => ''); if ($i < $rDefACount) { $tAnswTmpl = $pObj->cObj->substituteSubpart($answerTemplate, '###DELLINK###', ''); } else { $tAnswTmpl = $answerTemplate; } $answers .= $pObj->cObj->substituteMarkerArrayCached($tAnswTmpl, $marker); } $template = $pObj->cObj->substituteSubpart($template, '###ANSWERSECTION###', $answers); return $template; }
/** * Sends an e-mail to users who have subscribed to certain forumcategory * @param $topicId int The UID of the new topic that was created * @param $forumId int The UID of the forum about which the users are to be alerted. * @param \tx_mmforum_base $forumObj * @return void * @author Cyrill Helg */ static function notifyForumSubscribers($topicId, $forumId, \tx_mmforum_base $forumObj) { $res = $this->databaseHandle->exec_SELECTquery('topic_title', 'tx_mmforum_topics', 'uid = ' . intval($topicId) . $forumObj->getStoragePIDQuery()); list($topicName) = $this->databaseHandle->sql_fetch_row($res); $res = $this->databaseHandle->exec_SELECTquery('forum_name, parentID', 'tx_mmforum_forums', 'uid = ' . intval($forumId) . $forumObj->getStoragePIDQuery()); list($forumName, $categoryId) = $this->databaseHandle->sql_fetch_row($res); // prepare the template (the variables that don't change all the time need only to be set once) $linkParams[$forumObj->prefixId] = array('action' => 'open_topic', 'id' => $topicId); $link = $forumObj->pi_getPageLink($GLOBALS['TSFE']->id, '', $linkParams); $link = $forumObj->tools->escapeBrackets($link); if (strlen($forumObj->conf['notifyingMail.']['topicLinkPrefix_override']) > 0) { $link = $forumObj->conf['notifyingMail.']['topicLinkPrefix_override'] . $link; } $template = $forumObj->pi_getLL('ntfMailForum.text'); $marker = array('###LINK###' => $link, '###USERNAME###' => $toUsername, '###FORUMNAME###' => $forumName, '###TEAM###' => $forumObj->conf['teamName']); $subjectMarker = array('###TOPICNAME###' => $topicName, '###FORUMNAME###' => $forumName, '###BOARDNAME###' => $forumObj->conf['boardName']); // loop through each user who subscribed $res = $this->databaseHandle->exec_SELECTquery('DISTINCT tx_mmforum_forummail.user_id, fe_users.email, fe_users.' . $forumObj->getUserNameField(), 'tx_mmforum_forummail, fe_users', 'tx_mmforum_forummail.user_id = fe_users.uid AND (tx_mmforum_forummail.forum_id = ' . intval($forumId) . ($categoryId > 0 ? ' OR tx_mmforum_forummail.forum_id = ' . $categoryId : '') . ') AND fe_users.deleted = 0 AND fe_users.disable = 0 AND fe_users.email != "" AND tx_mmforum_forummail.user_id != ' . intval($GLOBALS['TSFE']->fe_user->user['uid']) . $forumObj->getStoragePIDQuery('tx_mmforum_forummail')); while (list($toUserId, $toEmail, $toUsername) = $this->databaseHandle->sql_fetch_row($res)) { $marker['###USERNAME###'] = $forumObj->escape($toUsername); $mailtext = $forumObj->cObj->substituteMarkerArrayCached($template, $marker); // Compose mail and send $subject = $forumObj->cObj->substituteMarkerArray($forumObj->pi_getLL('ntfMailForum.subject'), $subjectMarker); $mail = GeneralUtility::makeInstance('t3lib_mail_Message'); $mail->setFrom(array($forumObj->conf['notifyingMail.']['sender_address'] => $forumObj->conf['notifyingMail.']['sender'])); $mail->setTo(array($toEmail => $toUsername)); $mail->setSubject($subject); $mail->setBody($mailtext, 'text/plain'); $mail->send(); } }