/**
  * Show PM form
  *
  * @access	private
  * @param	array 		Array of errors
  * @return	string		returns HTML
  */
 private function _showNewTopicForm($errors = '')
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     /* Check max per day */
     if ($this->messengerFunctions->checkHasHitMax()) {
         $this->registry->getClass('output')->showError('maxperday_hit', 10271);
     }
     /* Check PM flood */
     if ($this->messengerFunctions->floodControlCheck() !== TRUE) {
         $this->registry->getClass('output')->showError(sprintf($this->lang->words['pm_flood_stop'], $this->messengerFunctions->exceptionData[0]), 010271);
     }
     $_msg_id = 0;
     $formMemberID = intval($this->request['fromMemberID']);
     # WAS MID
     $topicID = intval($this->request['topicID']);
     $preview = $this->request['preview'];
     $inviteUsers = array();
     $displayData = array('errors' => $errors, 'topicID' => $topicID, 'preview' => '', 'name' => '', 'title' => '', 'message' => '');
     $_POST['Post-NS'] = isset($_POST['Post']) ? $_POST['Post'] : '';
     $_POST['Post'] = IPSText::removeMacrosFromInput(IPSText::raw2form(isset($_POST['Post']) ? $_POST['Post'] : ''));
     //-----------------------------------------
     // Preview post?
     //-----------------------------------------
     if ($preview) {
         /* Grab language for attachment previews */
         $this->registry->getClass('class_localization')->loadLanguageFile(array("public_topic"), 'forums');
         IPSText::getTextClass('bbcode')->parse_html = $this->settings['msg_allow_html'];
         IPSText::getTextClass('bbcode')->parse_nl2br = 1;
         IPSText::getTextClass('bbcode')->parse_smilies = 1;
         IPSText::getTextClass('bbcode')->parse_bbcode = $this->settings['msg_allow_code'];
         IPSText::getTextClass('bbcode')->parsing_section = 'pms';
         IPSText::getTextClass('bbcode')->parsing_mgroup = $this->memberData['member_group_id'];
         IPSText::getTextClass('bbcode')->parsing_mgroup_others = $this->memberData['mgroup_others'];
         $this->settings['max_emos'] = 0;
         $old_msg = IPSText::getTextClass('editor')->processRawPost('Post-NS');
         $old_msg = IPSText::getTextClass('bbcode')->preDisplayParse(IPSText::getTextClass('bbcode')->preDbParse($old_msg));
         if (!is_object($this->class_attach)) {
             //-----------------------------------------
             // Grab render attach class
             //-----------------------------------------
             require_once IPSLib::getAppDir('core') . '/sources/classes/attach/class_attach.php';
             $this->class_attach = new class_attach($this->registry);
         }
         //-----------------------------------------
         // Continue...
         //-----------------------------------------
         $this->class_attach->type = 'msg';
         $this->class_attach->attach_post_key = $this->_postKey;
         $this->class_attach->init();
         $attachData = $this->class_attach->renderAttachments(array(0 => $old_msg));
         $displayData['preview'] = $attachData[0]['html'] . $attachData[0]['attachmentHtml'];
     }
     //-----------------------------------------
     // Errors
     //-----------------------------------------
     if ($errors or IPSText::getTextClass('bbcode')->error != "") {
         if (IPSText::getTextClass('bbcode')->error) {
             $displayData['errors'][] = $this->lang->words[IPSText::getTextClass('bbcode')->error];
         }
         $preview = 1;
     }
     //-----------------------------------------
     // Did we come from a button with a user ID?
     //-----------------------------------------
     if ($formMemberID) {
         $name = IPSMember::load($formMemberID, 'core');
         if ($name['member_id']) {
             $displayData['name'] = $name['members_display_name'];
         }
     } else {
         $displayData['name'] = $this->request['entered_name'] ? $this->request['entered_name'] : '';
     }
     //-----------------------------------------
     // Are we quoting an old message?
     //-----------------------------------------
     if ($preview) {
         $displayData['message'] = $_POST['Post-NS'];
         $displayData['title'] = str_replace("'", "'", str_replace('"', '"', IPSText::stripslashes($_POST['msg_title'])));
     } else {
         if ($topicID) {
             $draftTopic = $this->messengerFunctions->fetchTopicDataWithMessage($topicID, TRUE);
             if ($draftTopic['mt_to_member_id']) {
                 $displayData['name'] = $draftTopic['from_name'];
             }
             if ($draftTopic['mt_title']) {
                 $_member = IPSMember::load($draftTopic['mt_to_member_id'], 'core');
                 $displayData['name'] = $_member['members_display_name'];
                 $displayData['title'] = $draftTopic['mt_title'];
                 $_msg_id = $draftTopic['msg_id'];
                 $this->_postKey = $draftTopic['msg_post_key'];
                 IPSText::getTextClass('bbcode')->parse_html = $this->settings['msg_allow_html'];
                 IPSText::getTextClass('bbcode')->parse_nl2br = 1;
                 IPSText::getTextClass('bbcode')->parse_smilies = 1;
                 IPSText::getTextClass('bbcode')->parse_bbcode = $this->settings['msg_allow_code'];
                 IPSText::getTextClass('bbcode')->parsing_section = 'pms';
                 $displayData['message'] = IPSText::getTextClass('bbcode')->preEditParse($draftTopic['msg_post']);
             }
         }
     }
     //-----------------------------------------
     // CC Boxes
     //-----------------------------------------
     if ($this->memberData['g_max_mass_pm'] > 0) {
         if ($_POST['inviteUsers']) {
             $displayData['inviteUsers'] = $_POST['inviteUsers'];
         } else {
             if ($draftTopic['mt_invited_members']) {
                 $_inviteUsers = $this->messengerFunctions->getInvitedUsers($draftTopic['mt_invited_members']);
                 $__inviteUsers = IPSMember::load($_inviteUsers, 'core');
                 if (is_array($__inviteUsers)) {
                     $_tmp = array();
                     foreach ($__inviteUsers as $id => $data) {
                         $_tmp[] = $data['members_display_name'];
                     }
                     if (is_array($_tmp)) {
                         $displayData['inviteUsers'] = implode(", ", $_tmp);
                     }
                 }
             }
         }
     }
     //-----------------------------------------
     // Remove side panel
     //-----------------------------------------
     IPSText::getTextClass('editor')->remove_side_panel = 1;
     //-----------------------------------------
     // PM returns
     //-----------------------------------------
     if (IPSText::getTextClass('editor')->method == 'rte' and $displayData['message'] and $fromMsgID) {
         $displayData['message'] = IPSText::getTextClass('bbcode')->convertForRTE(nl2br($displayData['message']));
     } else {
         if (IPSText::getTextClass('editor')->method == 'std' and $displayData['message'] and $fromMsgID) {
             $displayData['message'] = IPSText::getTextClass('bbcode')->preEditParse($displayData['message']);
         }
     }
     //-----------------------------------------
     // Is this RTE? If so, convert BBCode
     //-----------------------------------------
     if (IPSText::getTextClass('editor')->method == 'rte' and $displayData['message']) {
         if (count($errors) or $preview) {
             $displayData['message'] = stripslashes($displayData['message']);
         }
         $displayData['message'] = IPSText::getTextClass('bbcode')->convertForRTE($displayData['message']);
     } else {
         if ($displayData['message']) {
             $displayData['message'] = IPSText::stripslashes($displayData['message']);
         }
     }
     $displayData['editor'] = IPSText::getTextClass('editor')->showEditor($displayData['message'], 'Post');
     //-----------------------------------------
     // More Data...
     //-----------------------------------------
     $displayData['uploadData'] = $this->_canUpload ? array('canUpload' => 1) : array('canUpload' => 0);
     $displayData['postKey'] = $this->_postKey;
     //-----------------------------------------
     // Load attachments so we get some stats
     //-----------------------------------------
     require_once IPSLib::getAppDir('core') . '/sources/classes/attach/class_attach.php';
     $class_attach = new class_attach($this->registry);
     $class_attach->type = 'msg';
     $class_attach->init();
     $class_attach->getUploadFormSettings();
     $displayData['uploadData']['attach_stats'] = $class_attach->attach_stats;
     //-----------------------------------------
     // Build up the HTML for the send form
     //-----------------------------------------
     $this->_title = $this->lang->words['sendMsgTitle'];
     $this->_navigation[] = array($this->lang->words['sendMsgTitle'], '');
     return $this->registry->getClass('output')->getTemplate('messaging')->sendNewPersonalTopicForm($displayData);
 }
 /**
  * Sends a new personal message. Very simple.
  *
  * @access	public
  * @param	int				TO Member ID
  * @param	int				FROM Member ID
  * @param	array 			Array of InviteUser Names (display name)
  * @param	string			Message Title
  * @param	string			Message Content
  * @param	array 			Options array[ 'isSystem' (if true, then user will have no record of sending this PM) postKey, 'isDraft', 'sendMode' (invite/copy), 'topicID' ] If a topicID is passed, it's presumed that it was a draft....
  * @return	mixed			TRUE or FALSE or Exception
  *
  * <code>
  * Exception Codes:
  * TOPIC_ID_NOT_EXISTS:				Topic ID does not exist (re-sending a draft)
  * NOT_ALL_INVITE_USERS_EXIST: 		Not all invite users exist (check $this->exceptionData for a list of names)
  * NOT_ALL_INVITE_USERS_CAN_PM:		Not all invite users can PM (check $this->exceptionData for a list of names)
  * INVITE_USERS_BLOCKED:			Some invite users have been blocked (check $this->exceptionData for a list of names)
  * TO_USER_DOES_NOT_EXIST:		    The 'to' user ID does not exist
  * FROM_USER_DOES_NOT_EXIST:		The 'from' user ID does not exist
  * TO_USER_CANNOT_USE_PM:		    The 'to' user does not have access to PM system
  * TO_USER_FULL:					The 'to' user cannot accept any more PMs (inbox full)
  * FROM_USER_BLOCKED:			    The 'from' user has been blocked by the 'to' user
  * CANNOT_SAVE_TO_SENT_FOLDER:	    The 'from' user does not have space to store a copy of the message in their sent folder
  * MSG_TITLE_EMPTY:				    The 'msgTitle' variable is empty
  * MSG_CONTENT_EMPTY:			    The 'msgContent' varable is empty
  * CANT_SEND_TO_SELF:				The main recipient and sender are the same
  * CANT_INVITE_SELF:				The sender is in the invite list
  * CANT_INVITE_RECIPIENT:			The main recipient is in the invite list
  * FLOOD_STOP						Flood control will not allow this message to send
  * </code>
  */
 public function sendNewPersonalTopic($toMemberID, $fromMemberID, $inviteUsers, $msgTitle, $msgContent, $options = array())
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $toMemberData = array();
     $fromMemberData = array();
     $inviteUsersData = array();
     $isDraft = $options['isDraft'] ? TRUE : FALSE;
     $isCopyTo = $options['sendMode'] == 'copy' ? TRUE : FALSE;
     $isSystem = $options['isSystem'] === TRUE || $options['isSystem'] == 1 ? 1 : 0;
     $options['postKey'] = $options['postKey'] ? $options['postKey'] : md5(microtime());
     /* Set up force message*/
     $this->forceMessageToSend = $this->forceMessageToSend ? $this->forceMessageToSend : ($options['forcePm'] ? TRUE : FALSE);
     //-----------------------------------------
     // Check content
     //-----------------------------------------
     if ($toMemberID == $fromMemberID) {
         throw new Exception('CANT_SEND_TO_SELF');
     }
     if (!$msgTitle) {
         throw new Exception('MSG_TITLE_EMPTY');
     }
     if (!$msgContent) {
         throw new Exception('MSG_CONTENT_EMPTY');
     }
     //-----------------------------------------
     // Format content
     //-----------------------------------------
     try {
         $_originalMessageContent = $msgContent;
         $msgContent = $this->_formatMessageForSaving($msgContent);
     } catch (Exception $error) {
         throw new Exception($error->getMessage());
     }
     //-----------------------------------------
     // First off, load the to and from members
     //-----------------------------------------
     $_members = IPSMember::load(array($toMemberID, $fromMemberID), 'groups,extendedProfile');
     $toMemberData = $this->_setMaxMessages($_members[$toMemberID]);
     $fromMemberData = $this->_setMaxMessages($_members[$fromMemberID]);
     if (!$toMemberData['member_id'] and $this->forceMessageToSend !== TRUE) {
         throw new Exception('TO_USER_DOES_NOT_EXIST');
     }
     if (!$fromMemberData['member_id'] and $this->forceMessageToSend !== TRUE) {
         throw new Exception('FROM_USER_DOES_NOT_EXIST');
     }
     if ($this->floodControlCheck() !== TRUE and $this->forceMessageToSend !== TRUE) {
         throw new Exception('FLOOD_STOP');
     }
     //-----------------------------------------
     // Sort out invite users
     //-----------------------------------------
     if (is_array($inviteUsers) and count($inviteUsers)) {
         try {
             if ($fromMemberData['g_max_mass_pm'] > 0 or $this->forceMessageToSend === TRUE) {
                 $inviteUsersData = $this->checkAndReturnInvitedUsers($inviteUsers);
             }
         } catch (Exception $error) {
             if ($this->forceMessageToSend !== TRUE) {
                 throw new Exception($error->getMessage());
             }
         }
         if (isset($inviteUsersData[$fromMemberID])) {
             throw new Exception('CANT_INVITE_SELF');
         }
         if (isset($inviteUsersData[$toMemberID])) {
             throw new Exception('CANT_INVITE_RECIPIENT');
         }
     }
     //-----------------------------------------
     // Can the 'to' user accept a PM?
     //-----------------------------------------
     if ($this->canUsePMSystem($toMemberData) !== TRUE) {
         if ($this->forceMessageToSend !== TRUE) {
             throw new Exception('TO_USER_CANNOT_USE_PM');
         }
     }
     //-----------------------------------------
     // Does the 'to' user have enough space?
     //-----------------------------------------
     if ($this->withinPMQuota($toMemberData) !== TRUE) {
         if ($this->forceMessageToSend !== TRUE) {
             throw new Exception('TO_USER_FULL');
         }
     }
     //-----------------------------------------
     // Has the 'to' use blocked us?
     //-----------------------------------------
     if (count($this->blockedByUser($fromMemberData, $toMemberData))) {
         if ($this->forceMessageToSend !== TRUE) {
             throw new Exception('FROM_USER_BLOCKED');
         }
     }
     //-----------------------------------------
     // Is this simply a copy-to?
     //-----------------------------------------
     if ($isCopyTo === TRUE) {
         /* Send out the main one */
         $this->sendNewPersonalTopic($toMemberID, $fromMemberID, array(), $msgTitle, $_originalMessageContent, array());
         /* Send out copy-tos */
         foreach ($inviteUsersData as $id => $toMember) {
             $this->sendNewPersonalTopic($toMember['member_id'], $fromMemberID, array(), $msgTitle, $_originalMessageContent, array());
         }
         /* Done */
         return TRUE;
     }
     //-----------------------------------------
     // Insert the user data
     //-----------------------------------------
     $_count = count($inviteUsersData);
     //-----------------------------------------
     // Got a topic ID?
     //-----------------------------------------
     if ($options['topicID']) {
         /* Fetch topic data */
         $_topicData = $this->fetchTopicData($options['topicID']);
         if (!$_topicData['mt_id'] and $this->forceMessageToSend !== TRUE) {
             throw new Exception('TOPIC_ID_NOT_EXISTS');
         }
         $this->DB->force_data_type = array('mt_title' => 'string');
         /* First off, update message_topics and message_posts... */
         $this->DB->update('message_topics', array('mt_date' => time(), 'mt_title' => $msgTitle, 'mt_starter_id' => $fromMemberData['member_id'], 'mt_start_time' => time(), 'mt_last_post_time' => time(), 'mt_invited_members' => serialize(array_keys($inviteUsersData)), 'mt_to_count' => count(array_keys($inviteUsersData)) + 1, 'mt_to_member_id' => $toMemberData['member_id'], 'mt_is_draft' => $isDraft), 'mt_id=' . $_topicData['mt_id']);
         /* Now the posts ... */
         $this->DB->update('message_posts', array('msg_date' => time(), 'msg_topic_id' => $_topicData['mt_id'], 'msg_post' => IPSText::removeMacrosFromInput($msgContent), 'msg_author_id' => $fromMemberData['member_id'], 'msg_is_first_post' => 1, 'msg_ip_address' => $this->member->ip_address), 'msg_id=' . $_topicData['mt_first_msg_id']);
         /* Delete any current user mapping as this will be sorted out below */
         $this->DB->delete('message_topic_user_map', 'map_topic_id=' . $_topicData['mt_id']);
         /* Reset variable IDs */
         $msg_topic_id = $_topicData['mt_id'];
         $msg_id = $_topicData['mt_first_msg_id'];
         IPSMember::save($toMemberData['member_id'], array('core' => array('msg_count_new' => 'plus:1')));
     } else {
         /* Create topic entry */
         $this->DB->force_data_type = array('mt_title' => 'string');
         $this->DB->insert('message_topics', array('mt_date' => time(), 'mt_title' => $msgTitle, 'mt_starter_id' => $fromMemberData['member_id'], 'mt_start_time' => time(), 'mt_last_post_time' => time(), 'mt_invited_members' => serialize(array_keys($inviteUsersData)), 'mt_to_count' => count(array_keys($inviteUsersData)) + 1, 'mt_to_member_id' => $toMemberData['member_id'], 'mt_is_draft' => $isDraft ? 1 : 0, 'mt_is_system' => $isSystem, 'mt_replies' => 0));
         $msg_topic_id = $this->DB->getInsertId();
         $this->DB->insert('message_posts', array('msg_date' => time(), 'msg_topic_id' => $msg_topic_id, 'msg_post' => IPSText::removeMacrosFromInput($msgContent), 'msg_post_key' => $options['postKey'], 'msg_author_id' => $fromMemberData['member_id'], 'msg_is_first_post' => 1, 'msg_ip_address' => $this->member->ip_address));
         $msg_id = $this->DB->getInsertId();
         IPSMember::save($toMemberData['member_id'], array('core' => array('msg_count_new' => 'plus:1')));
     }
     //-----------------------------------------
     // Update with last / first msg ID
     //-----------------------------------------
     $this->DB->update('message_topics', array('mt_last_msg_id' => $msg_id, 'mt_first_msg_id' => $msg_id, 'mt_hasattach' => intval($this->_makeAttachmentsPermanent($options['postKey'], $msg_id, $msg_topic_id))), 'mt_id=' . $msg_topic_id);
     //-----------------------------------------
     // Not a draft?
     //-----------------------------------------
     if ($isDraft !== TRUE) {
         //-----------------------------------------
         // Add in 'to user' and 'from user' to the cc array
         //-----------------------------------------
         $inviteUsersData[$toMemberData['member_id']] = $toMemberData;
         $inviteUsersData[$fromMemberData['member_id']] = $fromMemberData;
         //-----------------------------------------
         // Loop....
         //-----------------------------------------
         foreach ($inviteUsersData as $id => $toMember) {
             //-----------------------------------------
             // Enter the info into the DB
             // Target user side.
             //-----------------------------------------
             $_isStarter = $fromMemberData['member_id'] == $toMember['member_id'] ? 1 : 0;
             $_isSystem = ($fromMemberData['member_id'] == $toMember['member_id'] and $isSystem) ? 1 : 0;
             $_isActive = $_isSystem ? 0 : 1;
             /* Create user map entry */
             $this->DB->insert('message_topic_user_map', array('map_user_id' => $toMember['member_id'], 'map_topic_id' => $msg_topic_id, 'map_folder_id' => 'myconvo', 'map_user_active' => $_isActive, 'map_is_starter' => $fromMemberData['member_id'] == $toMember['member_id'] ? 1 : 0, 'map_has_unread' => $fromMemberData['member_id'] == $toMember['member_id'] ? 0 : 1, 'map_read_time' => $fromMemberData['member_id'] == $toMember['member_id'] ? time() : 0, 'map_is_system' => $_isSystem));
             //-----------------------------------------
             // Update profile
             //-----------------------------------------
             if ($fromMemberData['member_id'] != $toMember['member_id']) {
                 IPSMember::save($toMember['member_id'], array('core' => array('msg_count_total' => 'plus:1', 'msg_show_notification' => $toMember['view_pop'], 'msg_count_reset' => 1)));
             } else {
                 IPSMember::save($fromMemberData['member_id'], array('core' => array('msg_count_total' => 'plus:1', 'msg_count_reset' => 1)));
             }
             //-----------------------------------------
             // Has this member requested a PM email nofity?
             //-----------------------------------------
             if ($toMember['email_pm'] == 1 and $fromMemberData['member_id'] != $toMember['member_id']) {
                 $toMember['language'] = $toMember['language'] == "" ? IPSLib::getDefaultLanguage() : $toMember['language'];
                 IPSText::getTextClass('email')->getTemplate("personal_convo_new_convo", $toMember['language']);
                 IPSText::getTextClass('email')->buildMessage(array('NAME' => $toMember['members_display_name'], 'POSTER' => $fromMemberData['members_display_name'], 'TITLE' => $msgTitle, 'TEXT' => IPSText::removeMacrosFromInput($msgContent), 'LINK' => "?app=members&module=messaging&section=view&do=showConversation&topicID={$msg_topic_id}#msg{$msg_id}"));
                 $this->DB->insert('mail_queue', array('mail_to' => $toMember['email'], 'mail_from' => '', 'mail_date' => time(), 'mail_subject' => IPSText::getTextClass('email')->subject, 'mail_content' => IPSText::getTextClass('email')->message));
                 $cache = $this->cache->getCache('systemvars');
                 $cache['mail_queue'] += 1;
                 $this->cache->setCache('systemvars', $cache, array('array' => 1, 'donow' => 1, 'deletefirst' => 0));
             }
         }
     } else {
         //-----------------------------------------
         // Is a draft
         //-----------------------------------------
         /* Create user map entry */
         $this->DB->insert('message_topic_user_map', array('map_user_id' => $fromMemberData['member_id'], 'map_topic_id' => $msg_topic_id, 'map_folder_id' => 'drafts', 'map_user_active' => 1, 'map_has_unread' => 0, 'map_read_time' => 0));
         if (!$options['topicID']) {
             //-----------------------------------------
             // Update profile
             //-----------------------------------------
             $this->rebuildFolderCount($fromMemberData['member_id'], array('drafts' => 'plus:1'), TRUE, array('core' => array('msg_count_total' => 'plus:1')));
         }
     }
     return TRUE;
 }
 /**
  * UserCP Save Form: About me page
  *
  * @access	public
  * @return	array	Errors
  */
 public function saveAboutMe()
 {
     //-----------------------------------------
     // Check to make sure that we can edit profiles..
     //-----------------------------------------
     if (!$this->memberData['g_edit_profile']) {
         $this->registry->getClass('output')->showError('members_profile_disabled', 10212);
     }
     $aboutme = $this->DB->buildAndFetch(array('select' => 'pp_member_id, pp_about_me', 'from' => 'profile_portal', 'where' => 'pp_member_id=' . $this->memberData['member_id']));
     //-----------------------------------------
     // Remove board tags
     //-----------------------------------------
     $this->request['Post'] = IPSText::removeMacrosFromInput($this->request['Post']);
     //-----------------------------------------
     // Post process the editor
     // Now we have safe HTML and bbcode
     //-----------------------------------------
     $post = IPSText::getTextClass('editor')->processRawPost('Post');
     //-----------------------------------------
     // Parse post
     //-----------------------------------------
     IPSText::getTextClass('bbcode')->parse_smilies = intval($this->settings['aboutme_emoticons']);
     IPSText::getTextClass('bbcode')->parse_html = intval($this->settings['aboutme_html']);
     IPSText::getTextClass('bbcode')->parse_bbcode = intval($this->settings['aboutme_bbcode']);
     IPSText::getTextClass('bbcode')->parsing_section = 'aboutme';
     $post = IPSText::getTextClass('bbcode')->preDbParse($post);
     $text = IPSText::getTextClass('bbcode')->preDisplayParse($post);
     if (IPSText::getTextClass('bbcode')->error != "") {
         $this->lang->loadLanguageFile(array('public_post'), 'forums');
         $this->registry->getClass('output')->showError(IPSText::getTextClass('bbcode')->error, 10213);
     }
     //-----------------------------------------
     // Write it to the DB.
     //-----------------------------------------
     IPSMember::save($this->memberData['member_id'], array('extendedProfile' => array('pp_about_me' => $post)));
     return TRUE;
 }
 /**
  * Compiles all the incoming information into an array which is returned to hte accessor
  *
  * @access	protected
  * @return	array
  **/
 protected function compilePostData()
 {
     //-----------------------------------------
     // Sort out post content
     //-----------------------------------------
     if ($this->getPostContentPreFormatted()) {
         $postContent = $this->getPostContentPreFormatted();
     } else {
         $postContent = $this->formatPost($this->getPostContent());
     }
     //-----------------------------------------
     // Remove board tags
     //-----------------------------------------
     $postContent = IPSText::removeMacrosFromInput($postContent);
     //-----------------------------------------
     // Need to format the post?
     //-----------------------------------------
     $post = array('author_id' => $this->getAuthor('member_id') ? $this->getAuthor('member_id') : 0, 'use_sig' => $this->getSettings('enableSignature'), 'use_emo' => $this->getSettings('enableEmoticons'), 'ip_address' => $this->member->ip_address, 'post_date' => time(), 'icon_id' => $this->request['iconid'] ? $this->request['iconid'] : 0, 'post' => $postContent, 'author_name' => $this->getAuthor('member_id') ? $this->getAuthor('members_display_name') : $this->request['UserName'], 'topic_id' => "", 'queued' => $this->getPublished() ? 0 : 1, 'post_htmlstate' => $this->getSettings('post_htmlstatus'));
     //-----------------------------------------
     // If we had any errors, parse them back to this class
     // so we can track them later.
     //-----------------------------------------
     IPSText::getTextClass('bbcode')->parse_smilies = $post['use_emo'];
     IPSText::getTextClass('bbcode')->parse_html = ($this->getForumData('use_html') and $this->getAuthor('g_dohtml') and $post['post_htmlstate']) ? 1 : 0;
     IPSText::getTextClass('bbcode')->parse_nl2br = $post['post_htmlstate'] == 2 ? 1 : 0;
     IPSText::getTextClass('bbcode')->parse_bbcode = $this->getForumData('use_ibc') ? 1 : 0;
     IPSText::getTextClass('bbcode')->parsing_section = 'topics';
     IPSText::getTextClass('bbcode')->parsing_mgroup = $this->getAuthor('member_group_id');
     IPSText::getTextClass('bbcode')->parsing_mgroup_others = $this->getAuthor('mgroup_others');
     $testParse = IPSText::getTextClass('bbcode')->preDisplayParse($postContent);
     if (IPSText::getTextClass('bbcode')->error) {
         $this->_postErrors = IPSText::getTextClass('bbcode')->error;
     }
     return $post;
 }
 /**
  * UserCP Save Form: Notes
  *
  * @access	public
  * @return	boolean		Successful
  */
 public function saveFormNotes()
 {
     //-----------------------------------------
     // Remove board tags
     //-----------------------------------------
     $_POST['Post'] = IPSText::removeMacrosFromInput($_POST['Post']);
     //-----------------------------------------
     // Write it to the DB.
     //-----------------------------------------
     IPSMember::save($this->memberData['member_id'], array('extendedProfile' => array('notes' => htmlspecialchars($_POST['Post']))));
     $this->ok_message = $this->lang->words['notes_saved_msg'];
     return TRUE;
 }