/** * 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(); } }
/** * Wrapper function for language label retrieval. * * @author Martin Helmich <*****@*****.**> * @version 2007-07-19 * @param string $key The language label's key * @param string $default The default label if no language label was found * @return string The language label */ function pi_getLL($key, $default = '') { return $this->parent->pi_getLL($key, $default); }
/** * * Wrapper for the pi_getLL method of the parent object. For convenience only. * * @param String $key The label key * @param String $default Default value * @return String The text */ function l($key, $default = '') { $res = $this->p->pi_getLL('feadmin-' . $key, $key); return strlen($res) ? $res : ($default ? $default : 'feadmin-' . $key); }