/**
  * Outputs the form for users to create a post alert.
  * @param  array  $conf The calling plugin's configuration vars
  * @return string       The form
  */
 function post_alert($conf)
 {
     // Check login
     if ($GLOBALS['TSFE']->fe_user->user['uid']) {
         $template = $this->cObj->fileResource($conf['template.']['post_alert']);
         $template = $this->cObj->getSubpart($template, "###POST_ALERT###");
         $param = GeneralUtility::_GP('mm_forum');
         $post_id = intval($this->piVars['pid']);
         // Language dependent markers
         $marker = array('###LABEL_HEADING###' => $this->pi_getLL('postalert.heading'), '###LABEL_POSTTEXT###' => $this->pi_getLL('postalert.posttext'), '###LABEL_REASON###' => $this->pi_getLL('postalert.reason'), '###LABEL_ALERT###' => $this->pi_getLL('postalert.alert'));
         $marker['###ERRORMESSAGE###'] = '';
         // Create alert record
         if (isset($param) && $param['submit'] == $this->pi_getLL('postalert.alert')) {
             if (empty($param['alert_text'])) {
                 $marker['###ERRORMESSAGE###'] = '<div class="tx-mmforum-pi1-postalert-error">' . $this->pi_getLL('postalert.errorNoReason') . '</div>';
             } else {
                 $insertArray = array('tstamp' => $GLOBALS['EXEC_TIME'], 'crdate' => $GLOBALS['EXEC_TIME'], 'cruser_id' => $GLOBALS['TSFE']->fe_user->user['uid'], 'alert_text' => $param['alert_text'], 'post_id' => $post_id, 'topic_id' => $this->get_topic_id($post_id), 'mod_id' => '', 'status' => '-1');
                 $this->databaseHandle->exec_INSERTquery('tx_mmforum_post_alert', $insertArray);
                 $linkto = $this->get_pid_link($post_id, GeneralUtility::_GP('sword'), $conf);
                 HttpUtility::redirect($linkto);
             }
         }
         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='{$post_id}'"));
         $linkParams[$this->prefixId] = array('action' => 'list_post', 'tid' => $this->get_topic_id($post_id), 'pid' => 'last');
         $marker['###ACTIONLINK###'] = $this->escapeURL($this->pi_linkTP_keepPIvars_url());
         $marker['###POSTTEXT###'] = $this->tx_mmforum_postparser->main($this, $this->conf, $posttext, 'textparser');
         $marker['###FORMOPTIONS###'] .= '<input type="hidden" name="tx_mmforum_pi1[action]" value="' . $this->escape($this->piVars['action']) . '" />';
         $marker['###FORMOPTIONS###'] .= '<input type="hidden" name="tx_mmforum_pi1[pid]" value="' . $post_id . '" />';
         $content = $this->cObj->substituteMarkerArrayCached($template, $marker);
     } else {
         $content = $this->errorMessage($conf, $this->pi_getLL('postalert.errorNoLogin'));
     }
     return $content;
 }
 /**
  * generates a string that fits perfectly to render the signature's user in a marker tempalte
  * @param	array	$userData the user's data array
  * @return	string	the string ready to output (only if there is a signature of course)
  */
 function marker_getUserSignature($userData)
 {
     $signature = '';
     if ($userData['tx_mmforum_user_sig']) {
         if ($this->conf['signatureBBCodes']) {
             $signature = $this->tx_mmforum_postparser->main($this, $this->conf, $userData['tx_mmforum_user_sig'], 'textparser');
         } else {
             $signature = $this->escape($userData['tx_mmforum_user_sig']);
             $signature = nl2br($signature);
         }
         if (intval($this->conf['signatureLimit']) > 0) {
             $sigLines = explode("\n", $signature);
             if (count($sigLines) > $this->conf['signatureLimit']) {
                 $sigLines = array_slice($sigLines, 0, $this->conf['signatureLimit']);
             }
             $signature = implode("\n", $sigLines);
         }
         $signature = $this->cObj->stdWrap($signature, $this->conf['list_posts.']['signature_stdWrap.']);
     }
     return $signature;
 }
 /**
  * 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;
 }
 /**
  * Gets the complete post text.
  * This function returns the complete text of a posts. It uses the postparser
  * class to generate the content.
  *
  * @author  Martin Helmich <*****@*****.**>
  * @param   string $text The post text
  * @return  string       The parsed post text
  */
 function getPostTextComplete($text)
 {
     return $this->tx_mmforum_postparser->main($this->pObj, $this->conf, $text, 'textparser');
 }
 /**
  * Displays a form for editing the data of the current user.
  *
  * @author  Georg Ringer <*****@*****.**>
  * @author  Martin Helmich <*****@*****.**>
  * @version 2007-05-15
  * @param   string $content The plugin content
  * @return  string          The content
  */
 function listUserdata($content)
 {
     $action = GeneralUtility::_GP('action');
     switch ($action) {
         case 'change_data':
             $this->writeUserdata($content);
             break;
         case 'avatar_upload':
             $content = $this->uploadAvatar($content);
             break;
         case 'change_pass':
             $content .= $this->changePassword($this->piVars['newpass1'], $this->piVars['newpass2'], $this->piVars['oldpass']);
             break;
         default:
             if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['listUserdata'][$action])) {
                 $userFuncRef = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['listUserdata'][$action];
                 $params = array();
                 $params['content'] = $content;
                 $content = GeneralUtility::callUserFunction($userFuncRef, $params, $this);
             }
             break;
     }
     $template = $this->cObj->fileResource($this->conf['template']);
     $template = $this->cObj->getSubpart($template, '###MAIN###');
     $marker = array('###LABEL_UPLOADAVATAR###' => $this->pi_getLL('avatar.uploadAvatar'), '###LABEL_AVATAR###' => $this->pi_getLL('avatar.avatar'), '###LABEL_CHANGEPASSWORD###' => $this->pi_getLL('password.change'), '###LABEL_OLDPW###' => $this->pi_getLL('password.old'), '###LABEL_NEWPW###' => $this->pi_getLL('password.new'), '###LABEL_REPEAT###' => $this->pi_getLL('password.repeat'), '###LABEL_CHANGE###' => $this->pi_getLL('password.save'), '###LABEL_SETTINGS2###' => $this->pi_getLL('settings2'), '###LABEL_PMNOTIFY###' => $this->pi_getLL('pmnotifymode'), '###LABEL_PMNOTIFY_0###' => $this->pi_getLL('pmnotifymode.0'), '###LABEL_PMNOTIFY_1###' => $this->pi_getLL('pmnotifymode.1'), '###LABEL_PMNOTIFY_2###' => $this->pi_getLL('pmnotifymode.2'), '###IMG_MAIL###' => $this->createButton('email', array(), 0, true, '', true), '###IMG_ICQ###' => $this->createButton('icq', array(), 0, true, '', true), '###IMG_AIM###' => $this->createButton('aim', array(), 0, true, '', true), '###IMG_YIM###' => $this->createButton('yim', array(), 0, true, '', true), '###IMG_MSN###' => $this->createButton('msn', array(), 0, true, '', true), '###IMG_SKYPE###' => $this->createButton('skype', array(), 0, true, '', true), '###PMNOTIFY_0###' => $this->user->pmNotifyModeIs(0) ? 'checked="checked"' : '', '###PMNOTIFY_1###' => $this->user->pmNotifyModeIs(1) ? 'checked="checked"' : '', '###PMNOTIFY_2###' => $this->user->pmNotifyModeIs(2) ? 'checked="checked"' : '', '###SETTINGS_ICON###' => $this->cObj->cObjGetSingle($this->conf['icons.']['settings'], $this->conf['icons.']['settings.']), '###SETTINGS2_ICON###' => $this->cObj->cObjGetSingle($this->conf['icons.']['settings'], $this->conf['icons.']['settings2.']), '###AVATAR_ICON###' => $this->cObj->cObjGetSingle($this->conf['icons.']['settings'], $this->conf['icons.']['avatar.']), '###PASSWORD_ICON###' => $this->cObj->cObjGetSingle($this->conf['icons.']['settings'], $this->conf['icons.']['password.']), '###FORMACTION###' => $this->pi_getPageLink($GLOBALS['TSFE']->id));
     // Create marker array, field names are retrieved from TypoScript
     $extrafields = array('uid', 'username', 'crdate', 'tx_mmforum_posts', 'tx_mmforum_avatar', 'image');
     $fields = array_unique(array_merge($extrafields, GeneralUtility::trimExplode(',', $this->conf['userFields'], true)));
     $required = GeneralUtility::trimExplode(',', $this->conf['required.']['fields'], true);
     foreach ($fields as $fieldName) {
         $label = $this->pi_getLL($fieldName);
         if (in_array($fieldName, $required)) {
             $label = $this->cObj->wrap($label, $this->conf['required.']['fieldWrap']);
         }
         $marker['###DESCR_' . strtoupper($fieldName) . '###'] = $label;
         $marker['###' . strtoupper($fieldName) . '###'] = isset($this->piVars[$fieldName]) ? $this->piVars[$fieldName] : $this->user->gD($fieldName);
     }
     // Some special fields
     $marker['###CRDATE###'] = strftime($this->conf['date'], $this->user->gD('crdate'));
     $marker['###ACTIONLINK###'] = '';
     $marker['###SIGNATUR_PREVIEW###'] = $this->tx_mmforum_postparser->main($this, $this->conf, $this->user->gD('tx_mmforum_user_sig'), 'textparser');
     // Avatar
     $imgTSConfig = $this->conf['avatar.'];
     $imgTSConfig['file'] = $this->user->getAvatar($this->conf['path_avatar']);
     $marker['###AVATAR###'] = $this->cObj->IMAGE($imgTSConfig);
     $marker['###AVATAR_DEL###'] = '';
     if ($this->user->hasAvatar()) {
         $marker['###AVATAR_DEL###'] = '<input type="checkbox"  name="' . $this->prefixId . '[del_avatar]" />' . $this->pi_getLL('delete_avatar');
     }
     // Language markers
     $dataLL = array('descr_signatur_preview', 'send', 'about', 'filename', 'descr_date');
     foreach ($dataLL as $llKey) {
         $marker['###' . strtoupper($llKey) . '###'] = $this->pi_getLL($llKey);
     }
     // User fields
     $userField_template = $this->cObj->getSubpart($template, '###USERFIELDS###');
     $userField_content = '';
     $userFields = $this->databaseHandle->exec_SELECTgetRows('*', 'tx_mmforum_userfields', 'deleted=0 AND hidden=0', '', 'sorting DESC');
     $parser = GeneralUtility::makeInstance('t3lib_TSparser');
     foreach ($userFields as $field) {
         if (isset($this->piVars['userfield'][$field['uid']])) {
             $value = $this->piVars['userfield'][$field['uid']];
         } else {
             $res2 = $this->databaseHandle->exec_SELECTquery('field_value', 'tx_mmforum_userfields_contents', 'field_id=' . $field['uid'] . ' AND user_id=' . $this->user->getUid());
             $value = '';
             if ($this->databaseHandle->sql_num_rows($res2) > 0) {
                 list($value) = $this->databaseHandle->sql_fetch_row($res2);
             }
         }
         $parser->setup = array();
         if (strlen($field['config']) > 0) {
             $parser->parse($field['config']);
         }
         $config = $parser->setup;
         $label = $field['label'];
         if ($config['label']) {
             $label = $this->cObj->cObjGetSingle($config['label'], $config['label.']);
         }
         if ($config['required']) {
             $label = $this->cObj->wrap($label, $this->conf['required.']['fieldWrap']);
         }
         if ($config['datasource']) {
             $value = isset($this->piVars['userfield'][$field['uid']]) ? $this->piVars['userfield'][$field['uid']] : $this->user->gD($config['datasource']);
             $label .= '<input type="hidden" name="tx_mmforum_pi5[userfield_exists][' . $field['uid'] . ']" value="' . $config['datasource'] . '" />';
         }
         if ($config['input']) {
             $tmpData = $this->cObj->data;
             $this->cObj->data = array('fieldvalue' => $value);
             $input = $this->cObj->cObjGetSingle($config['input'], $config['input.']);
             $this->cObj->data = $tmpData;
         } else {
             $input = $this->cObj->getSubpart($userField_template, '###DEFUSERFIELD###');
         }
         $userField_thisTemplate = $this->cObj->substituteSubpart($userField_template, '###DEFUSERFIELD###', $input);
         $userField_marker = array('###USERFIELD_LABEL###' => $label, '###USERFIELD_VALUE###' => $value, '###USERFIELD_UID###' => $field['uid'], '###USERFIELD_NAME###' => $this->prefixId . '[userfield][' . $field['uid'] . ']', '###USERFIELD_ERROR###' => isset($this->userfield_error[$field['uid']]) ? $this->cObj->wrap($this->userfield_error[$field['uid']], $this->conf['userFields.']['wrap']) : '');
         $userField_content .= $this->cObj->substituteMarkerArrayCached($userField_thisTemplate, $userField_marker);
     }
     $template = $this->cObj->substituteSubpart($template, '###USERFIELDS###', $userField_content);
     // Include hooks
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['display']['editProfilMarkerArray'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['display']['editProfilMarkerArray'] as $classRef) {
             $procObj =& GeneralUtility::getUserObj($classRef);
             $marker = $procObj->processProfilMarkerArray($marker, $this->cObj);
         }
     }
     $content .= $this->cObj->substituteMarkerArrayCached($template, $marker);
     return $content;
 }
 /**
  * Displays the form for editing an existing post. Regular users can only edit their own
  * posts if they have not been answered yet. Moderators and administrators can edit all
  * posts, regardless if they have been answered or not.
  * @param  string $content The plugin content
  * @param  array  $conf    The plugin's configuration vars
  * @return string          The content
  */
 function post_edit($content, $conf)
 {
     $postId = intval($this->piVars['pid']);
     $this->generateToken();
     // Get topic UID
     $res = $this->databaseHandle->exec_SELECTquery('*', 'tx_mmforum_posts', 'deleted=0 AND hidden=0 AND uid=' . $postId . $this->getStoragePIDQuery());
     $row = $this->databaseHandle->sql_fetch_assoc($res);
     $topicId = $row['topic_id'];
     $forumId = $row['forum_id'];
     // Determine, if edited post is the last post in topic
     $res = $this->databaseHandle->exec_SELECTquery('MAX(post_time)', 'tx_mmforum_posts', 'deleted=0 AND hidden=0 AND topic_id=' . $topicId . $this->getStoragePIDQuery());
     list($lastpostdate) = $this->databaseHandle->sql_fetch_row($res);
     // Determine if edited post is the first post in topic
     $res = $this->databaseHandle->exec_SELECTquery('uid', 'tx_mmforum_posts', 'deleted=0 AND hidden=0 AND topic_id=' . $topicId . ' ' . $this->getStoragePIDQuery(), '', 'post_time ASC');
     list($firstPostId) = $this->databaseHandle->sql_fetch_row($res);
     $firstPost = $postId === intval($firstPostId);
     // Load topic data
     $res = $this->databaseHandle->exec_SELECTquery('*', 'tx_mmforum_topics', 'deleted=0 AND hidden=0 AND uid=' . $topicId . $this->getStoragePIDQuery());
     $topicData = $this->databaseHandle->sql_fetch_assoc($res);
     $previewContent = '';
     if ($row['poster_id'] == $GLOBALS['TSFE']->fe_user->user['uid'] && $lastpostdate == $row['post_time'] && $topicData['closed_flag'] != 1 or $this->getIsAdmin() or $this->getIsMod($row['forum_id'])) {
         //Check CSRF Attacks
         if ($GLOBALS["TSFE"]->fe_user->getKey('ses', "token") == $this->piVars['token'] || $this->piVars['token'] == false) {
             $content .= $this->errorMessage($this->conf, $this->pi_getLL('newPost.quote.error'));
             return $this->new_post($content, $conf);
         }
         if ($this->piVars['button'] == $this->pi_getLL('newPost.save')) {
             // Write changes to database
             $updateArray = array('post_text' => $this->piVars['message'], 'tstamp' => $GLOBALS['EXEC_TIME']);
             $res = $this->databaseHandle->exec_UPDATEquery('tx_mmforum_posts_text', 'post_id=' . $postId, $updateArray);
             // check for attachments that should be deleted
             if ($this->piVars['attachment_delete']) {
                 foreach ($this->piVars['attachment_delete'] as $attachementId => $delete) {
                     $attachementId = intval($attachementId);
                     $this->databaseHandle->exec_UPDATEquery('tx_mmforum_attachments', 'uid=' . $attachementId, array('deleted' => 1, 'tstamp' => $GLOBALS['EXEC_TIME']));
                     $this->databaseHandle->exec_UPDATEquery('tx_mmforum_posts', 'uid=' . $attachementId, array('attachment' => 0, 'tstamp' => $GLOBALS['EXEC_TIME']));
                     $attachments = GeneralUtility::intExplode(',', $row['attachment']);
                     unset($attachments[array_search($attachementId, $attachments)]);
                     $row['attachment'] = implode(',', $attachments);
                 }
                 $this->databaseHandle->exec_UPDATEquery('tx_mmforum_posts', 'uid=' . $postId, array('attachment' => $row['attachment']));
             }
             // Check for new file uploads / attachments
             if ($_FILES['tx_mmforum_pi1_attachment_1']['size'] > 0) {
                 $res = $this->performAttachmentUpload();
                 if (!is_array($res)) {
                     $content .= $res;
                     unset($this->piVars['button']);
                     return $this->post_edit($content, $conf);
                 } else {
                     $attachmentIds = $res;
                     $attachments = GeneralUtility::intExplode(',', $row['attachment']);
                     $attachments = tx_mmforum_tools::processArray_numeric($attachments);
                     $updateData = array('attachment' => implode(',', array_merge($attachments, $attachmentIds)));
                     $this->databaseHandle->exec_UPDATEquery('tx_mmforum_posts', 'uid = ' . $postId, $updateData);
                     // Update attachment records with the post ID (as this is not set within the performAttachmentUpload)
                     if (count($attachmentIds)) {
                         $this->databaseHandle->exec_UPDATEquery('tx_mmforum_attachments', 'uid IN (' . implode(',', $attachmentIds) . ')', array('post_id' => $postId));
                     }
                 }
             } else {
                 $attachmentIds = null;
             }
             if ($this->conf['polls.']['enable']) {
                 if ($this->piVars['enable_poll'] == '1' && $firstPost) {
                     $pollObj = GeneralUtility::makeInstance('tx_mmforum_polls');
                     /* @var $pollObj tx_mmforum_polls */
                     if ($topicData['poll_id'] > 0) {
                         $res = $pollObj->editPoll($topicData['poll_id'], $this->piVars['poll'], $this);
                         if ($res) {
                             $content .= $this->errorMessage($this->conf, $res);
                             unset($this->piVars['button']);
                             return $this->post_edit($content, $conf);
                         }
                     } else {
                         $pollId = $pollObj->createPoll($this->piVars['poll'], $this);
                         if (!is_numeric($pollId)) {
                             $content .= $this->errorMessage($this->conf, $pollId);
                             unset($this->piVars['button']);
                             return $this->post_edit($content, $conf);
                         }
                         $this->databaseHandle->exec_UPDATEquery('tx_mmforum_topics', 'uid=' . $topicId, array('poll_id' => $pollId, 'tstamp' => $GLOBALS['EXEC_TIME']));
                     }
                 } else {
                     if ($firstPost && $topicData['poll_id'] > 0) {
                         $pollObj = GeneralUtility::makeInstance('tx_mmforum_polls');
                         $pollObj->deletePoll($topicData['poll_id'], $topicData['uid']);
                     }
                 }
             }
             if ($this->piVars['title'] and $this->getIsMod($row['forum_id']) || $this->getIsAdmin() || $firstPost && $row['poster_id'] == $GLOBALS['TSFE']->fe_user->user['uid']) {
                 $updateArray = array('topic_title' => $this->piVars['title'], 'tstamp' => $GLOBALS['EXEC_TIME']);
                 $res = $this->databaseHandle->exec_UPDATEquery('tx_mmforum_topics', 'uid=' . $topicId, $updateArray);
             }
             // If the editing user is no admin or mod, the change is logged in the database
             if (!$this->getIsMod($row['forum_id']) && !$this->getIsAdmin()) {
                 $this->databaseHandle->exec_UPDATEquery('tx_mmforum_posts', 'uid=' . $postId, array('edit_count' => intval($row['edit_count']) + 1, 'edit_time' => $GLOBALS['EXEC_TIME']));
             }
             // Clearing for new indexing
             tx_mmforum_indexing::delete_topic_ind_date($topicId);
             $linkParams[$this->prefixId] = array('action' => 'list_post', 'tid' => $topicId, 'pid' => $this->piVars['pid']);
             if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['postEdit_linkParams'])) {
                 foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['postEdit_linkParams'] as $classRef) {
                     $procObj =& GeneralUtility::getUserObj($classRef);
                     $linkParams = $procObj->postEdit_linkParams($linkParams, $this);
                 }
             }
             $link = $this->pi_getPageLink($GLOBALS['TSFE']->id, '', $linkParams);
             HttpUtility::redirect($link . '#pid' . $postId);
         } else {
             // Display post preview
             if ($this->piVars['button'] == $this->pi_getLL('newPost.preview')) {
                 if ($this->piVars['enable_poll'] == '1' && $this->conf['polls.']['enable']) {
                     $content .= tx_mmforum_polls::displayPreview($this->piVars['poll'], $this);
                 }
                 $template = $this->cObj->fileResource($conf['template.']['list_post']);
                 $template = $this->cObj->getSubpart($template, "###LIST_POSTS###");
                 $template = $this->cObj->substituteSubpart($template, '###ATTACHMENT_SECTION###', '');
                 $posttext = $this->piVars['message'];
                 $posttext = $this->tx_mmforum_postparser->main($this, $conf, $posttext, 'textparser');
                 $marker['###POSTOPTIONS###'] = '';
                 $marker['###SOLVEDOPTION###'] = '';
                 $marker['###POSTMENU###'] = '';
                 $marker['###POSTUSER###'] = $this->ident_user($row['poster_id'], $conf);
                 $marker['###POSTTEXT###'] = $posttext;
                 $marker['###ANKER###'] = '';
                 $marker['###POSTANCHOR###'] = '';
                 $marker['###POSTDATE###'] = $this->pi_getLL('post.writtenOn') . ': ' . $this->formatDate($topicData['topic_time']);
                 $marker['###POSTRATING###'] = '';
                 // Include hooks
                 if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['editPost_INpreviewMarker'])) {
                     foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['editPost_INpreviewMarker'] as $classRef) {
                         $procObj =& GeneralUtility::getUserObj($classRef);
                         $marker = $procObj->editPost_INpreviewMarker($marker, $this);
                     }
                 }
                 $previewTemplate = $this->cObj->fileResource($conf['template.']['new_post']);
                 $previewTemplate = $this->cObj->getSubpart($previewTemplate, '###PREVIEW###');
                 $previewMarker = array("###TOPIC_TITLE###" => $this->escape($this->piVars['topicname']), "###LABEL_PREVIEW###" => $this->pi_getLL('newTopic.preview'), "###PREVIEW_POST###" => $this->cObj->substituteMarkerArrayCached($template, $marker));
                 // Include hooks
                 if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['editPost_previewMarker'])) {
                     foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['editPost_previewMarker'] as $classRef) {
                         $procObj =& GeneralUtility::getUserObj($classRef);
                         $previewMarker = $procObj->editPost_previewMarker($previewMarker, $this);
                     }
                 }
                 $previewContent = $this->cObj->substituteMarkerArrayCached($previewTemplate, $previewMarker);
             }
             $template = $this->cObj->fileResource($conf['template.']['new_post']);
             $template = $this->cObj->getSubpart($template, stristr($template, '###NEWTOPIC###') === false ? '###NEWPOST###' : '###NEWTOPIC###');
             // compatibility: typo in template file fixed. was 'NEWTOPIC'
             $attachments = GeneralUtility::intExplode(',', $row['attachment']);
             $attachments = tx_mmforum_tools::processArray_numeric($attachments);
             $attachCount = count($attachments);
             if ($attachCount == $this->conf['attachments.']['maxCount'] || !$this->conf['attachments.']['enable']) {
                 $template = $this->cObj->substituteSubpart($template, "###ATTACHMENT_SECTION###", '');
             } else {
                 $attachDiff = $this->conf['attachments.']['maxCount'] - $attachCount;
                 $aTemplate = $this->cObj->getSubpart($template, '###ATTACHMENT_FIELD###');
                 $aContent = '';
                 for ($i = 1; $i <= $attachDiff; $i++) {
                     $aMarker = array('###ATTACHMENT_NO###' => $i);
                     $aContent .= $this->cObj->substituteMarkerArray($aTemplate, $aMarker);
                 }
                 $marker = array('###LABEL_ATTACHMENT###' => $this->pi_getLL('newPost.attachment'), '###MAXFILESIZE###' => $this->conf['attachments.']['maxFileSize']);
                 // Maximum file size
                 $mFileSize = $this->conf['attachments.']['maxFileSize'] . ' B';
                 if ($this->conf['attachments.']['maxFileSize'] >= 1024) {
                     $mFileSize = round($this->conf['attachments.']['maxFileSize'] / 1024, 2) . ' KB';
                 }
                 if ($this->conf['attachments.']['maxFileSize'] >= 1024 * 1024) {
                     $mFileSize = round($this->conf['attachments.']['maxFileSize'] / (1024 * 1024), 2) . ' MB';
                 }
                 $marker['###MAXFILESIZE_TEXT###'] = sprintf($this->pi_getLL('newPost.maxFileSize'), $mFileSize);
                 $marker['###MAXFILESIZE_TEXT###'] = $this->cObj->stdWrap($marker['###MAXFILESIZE_TEXT###'], $this->conf['attachments.']['maxFileSize_stdWrap.']);
                 $marker['###TOKEN###'] = $GLOBALS["TSFE"]->fe_user->getKey('ses', "token");
                 $template = $this->cObj->substituteMarkerArray($template, $marker);
                 $template = $this->cObj->substituteSubpart($template, '###ATTACHMENT_FIELD###', $aContent);
             }
             $marker = array();
             if (strlen($row['attachment']) == 0) {
                 $template = $this->cObj->substituteSubpart($template, '###ATTACHMENT_EDITSECTION###', '');
             } else {
                 $aRes = $this->databaseHandle->exec_SELECTquery('*', 'tx_mmforum_attachments', 'uid IN (' . $row['attachment'] . ') AND deleted=0', '', 'uid ASC');
                 $marker['###LABEL_ATTACHMENT###'] = $this->pi_getLL('newPost.attachment');
                 $aTemplate = $this->cObj->getSubpart($template, '###ATTACHMENT_EDITFIELD###');
                 $aContent = '';
                 while ($attachment = $this->databaseHandle->sql_fetch_assoc($aRes)) {
                     $size = $attachment['file_size'] . ' ' . $this->pi_getLL('attachment.bytes');
                     if ($attachment['file_size'] > 1024) {
                         $size = round($attachment['file_size'] / 1024, 2) . ' ' . $this->pi_getLL('attachment.kilobytes');
                     }
                     if ($attachment['file_size'] > 1048576) {
                         $size = round($attachment['file_size'] / 1048576, 2) . ' ' . $this->pi_getLL('attachment.megabytes');
                     }
                     $aMarker['###LABEL_DELETEATTACHMENT###'] = $this->pi_getLL('attachment.delete');
                     $sAttachment = $attachment['file_name'] . ' (' . $this->pi_getLL('attachment.type') . ': ' . $attachment['file_type'] . ', ' . $this->pi_getLL('attachment.size') . ': ' . $size . '), ' . $attachment['downloads'] . ' ' . $this->pi_getLL('attachment.downloads');
                     $sAttachment = $this->escape($sAttachment);
                     $sAttachment = $this->cObj->stdWrap($sAttachment, $this->conf['attachments.']['attachmentEditLabel_stdWrap.']);
                     $aMarker['###ATTACHMENT_DATA###'] = $sAttachment;
                     $aMarker['###ATTACHMENT_UID###'] = $attachment['uid'];
                     $aContent .= $this->cObj->substituteMarkerArray($aTemplate, $aMarker);
                 }
                 $template = $this->cObj->substituteSubpart($template, '###ATTACHMENT_EDITFIELD###', $aContent);
             }
             if ($firstPost && $this->conf['polls.']['enable']) {
                 $pollObj = GeneralUtility::makeInstance('tx_mmforum_polls');
                 if ($topicData['poll_id'] == 0) {
                     $marker['###POLL###'] = $pollObj->display_createForm($this->piVars['poll'] ? $this->piVars['poll'] : array(), $this);
                     $marker['###ENABLE_POLL###'] = $this->piVars['enable_poll'] ? 'checked="checked"' : '';
                     $marker['###POLLDIV_STYLE###'] = $this->piVars['enable_poll'] ? '' : 'style="display:none;"';
                     $marker['###LABEL_POLL_CE###'] = $this->pi_getLL('poll.postattach.new');
                     $marker['###DISABLE_POLL###'] = '';
                     $marker['###DISABLE_POLL_VAR###'] = 0;
                     $marker['###CALLPOLLJS###'] = $this->conf['callpolljs'];
                 } else {
                     $pollEnabled = $pollObj->getMayEditPoll($topicData['poll_id'], $this);
                     $marker['###POLL###'] = $pollObj->display_editForm($topicData['poll_id'], $this->piVars['poll'] ? $this->piVars['poll'] : array(), $this);
                     $marker['###ENABLE_POLL###'] = 'checked="checked"';
                     $marker['###POLLDIV_STYLE###'] = '';
                     $marker['###LABEL_POLL_CE###'] = $this->pi_getLL('poll.postattach.edit');
                     $marker['###DISABLE_POLL###'] = $pollEnabled ? '' : 'disabled="disabled"';
                     $marker['###DISABLE_POLL_VAR###'] = $pollEnabled ? 0 : 1;
                     $marker['###CALLPOLLJS###'] = $this->conf['callpolljs'];
                 }
                 $marker['###LABEL_POLL###'] = $this->pi_getLL('poll.postattach');
             } else {
                 $template = $this->cObj->substituteSubpart($template, '###POLL_SECTION###', '');
             }
             $res = $this->databaseHandle->exec_SELECTquery('post_text', 'tx_mmforum_posts_text', 'post_id=' . $postId);
             list($posttext) = $this->databaseHandle->sql_fetch_row($res);
             $res = $this->databaseHandle->exec_SELECTquery('topic_title', 'tx_mmforum_topics', 'uid=' . $topicId);
             list($title) = $this->databaseHandle->sql_fetch_row($res);
             $marker['###POSTTEXT###'] = $this->piVars['message'] ? $this->escape($this->piVars['message']) : $this->escape($posttext);
             if ($this->getIsMod($row['forum_id']) || $this->getIsAdmin()) {
                 $marker['###POSTTITLE###'] = '<input type="text"  name="tx_mmforum_pi1[title]" size="50" value="' . $this->escape($title) . '" style="width:80%;"></div>';
             } else {
                 if ($firstPost && $row['poster_id'] == $GLOBALS['TSFE']->fe_user->user['uid']) {
                     $marker['###POSTTITLE###'] = '<input type="text"  name="tx_mmforum_pi1[title]" size="50" value="' . $this->escape($title) . '" style="width:80%;"></div>';
                 } else {
                     $marker['###POSTTITLE###'] = $this->escape($title);
                 }
             }
             $marker['###OLDPOSTTEXT###'] = '';
             $marker['###SMILIES###'] = $this->show_smilie_db($conf);
             $marker['###SOLVEDOPTION###'] = '';
             $marker['###ACTION###'] = htmlspecialchars($this->pi_getPageLink($GLOBALS['TSFE']->id, '', array($this->prefixId => array('action' => 'post_edit', 'pid' => $postId))));
             $marker['###LABEL_SEND###'] = $this->pi_getLL('newPost.save');
             $marker['###LABEL_PREVIEW###'] = $this->pi_getLL('newPost.preview');
             $marker['###LABEL_RESET###'] = $this->pi_getLL('newPost.reset');
             $marker['###LABEL_ATTENTION###'] = $this->pi_getLL('newPost.attention');
             $marker['###LABEL_NOTECODESAMPLES###'] = $this->pi_getLL('newPost.codeSamples');
             $marker['###TOPICICON###'] = $this->getTopicIcon($topicData);
             $marker['###TOPICTITLE###'] = $this->escape($topicData['topic_title']);
             // no have-a-look on post edit
             $template = $this->cObj->substituteSubpart($template, '###HAVEALOOK_SECTION###', '');
             $bbCodeButtons_template = $this->cObj->getSubpart($template, '###BBCODEBUTTONS###');
             if (empty($conf['jQueryEditorJavaScript'])) {
                 $bbCodeButtons = $this->generateBBCodeButtons($bbCodeButtons_template);
             } else {
                 $bbCodeButtons = stristr($bbCodeButtons_template, '<td>') ? '<td></td>' : '';
             }
             $template = $this->cObj->substituteSubpart($template, '###BBCODEBUTTONS###', $bbCodeButtons);
             $template = str_replace('###POLLJAVASCRIPT###', $this->conf['polljavascript'], $template);
             if ($this->conf['disableRootline']) {
                 $template = $this->cObj->substituteSubpart($template, '###ROOTLINE_CONTAINER###', '');
             } else {
                 $marker['###FORUMPATH###'] = $this->get_forum_path($forumId, $topicId);
             }
         }
     } else {
         $template = $this->cObj->fileResource($conf['template.']['error']);
         $marker = array('###ERROR###' => $this->pi_getLL('editPost.noAccess'));
     }
     // Include hooks
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['editPost_formMarker'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['editPost_formMarker'] as $classRef) {
             $procObj =& GeneralUtility::getUserObj($classRef);
             $marker = $procObj->editPost_formMarker($marker, $this);
         }
     }
     $marker['###STARTJAVASCRIPT###'] = $this->includeEditorJavaScript();
     $marker['###POST_PREVIEW###'] = (string) $previewContent;
     $content .= $this->cObj->substituteMarkerArrayCached($template, $marker);
     return $content;
 }