/**
  * Add meta tag
  * <code>$output->addMetaTag( 'description', 'This is a short description' );</code>
  *
  * @param	string		$tag		Tag name
  * @param	string		$content	Tag content
  * @param	boolean		$encode		Encode content
  * @param	integer		$trimLen	Length to trim to (default 500)
  * @return	@e void
  * @link	http://community.invisionpower.com/tracker/issue-22826-case-sensitivity-in-meta-tags/
  * @link	http://community.invisionpower.com/tracker/issue-32572-bbcode-included-in-meta-description
  */
 public function addMetaTag($tag, $content, $encode = true, $trimLen = 500)
 {
     $encode = $encode === FALSE ? FALSE : TRUE;
     $trimLen = $trimLen - 3;
     $tag = trim(strtolower($tag));
     // 'ROBOTS' should overwrite 'robots'
     switch ($tag) {
         case 'description':
             /* Clear out 'Quote' if it's present in the bbcode parsed content */
             $content = str_replace(array('"', "'"), '', $content);
             $content = preg_replace('/\\<p class=\'citation\'\\>.+?\\<\\/p\\>/ims', '', $content);
             $content = strip_tags(IPSText::stripAttachTag($content));
             # Hebrew chars screw up Facebook sharer
             if ($this->member->iAmFacebook) {
                 $content = $this->encodeMetaTagContent($content, true);
             }
             # There is no max value, but we trim so we don't bloat the output.
             # It's not just search engines that use this, also link sharing services
             # pick up the meta description.
             $content = IPSText::truncate($content, $trimLen);
             break;
         case 'keywords':
             /* @link http://community.invisionpower.com/resources/bugs.html/_/ip-board/seo-meta-keyworks-doesnt-work-correctly-r38420
                @link http://community.invisionpower.com/resources/bugs.html/_/ip-board/meta-issues-r39358
                When encode is passed as true, we should assume the block of text has not been formatted, and that we need to convert spaces to commas basically.
                When encode is passed as false, we should assume that the keywords coming in have been explicitly set (with commas) and not change that */
             if ($encode === TRUE) {
                 $content = IPSText::stripAttachTag($content);
                 //Bug #15323 breaks accented characters, etc
                 //$content = strtolower( preg_replace( "/[^0-9a-zA-Z ]/", "", preg_replace( "/&([^;]+?);/", "", $content ) ) );
                 $content = str_replace(array('.', '!', ':', ';', ',', '"', '@', '%', '*', '(', ')'), '', preg_replace("/&([^;]+?);/", "", $content));
                 //Also breaks accented characters
                 //$_vals   = preg_split( '/\s+?/', $content, -1, PREG_SPLIT_NO_EMPTY );
                 $_vals = explode(' ', $content);
                 $_sw = explode(',', $this->lang->words['_stopwords_']);
                 $_fvals = array();
                 $_limit = 30;
                 $_c = 0;
                 if (is_array($_vals)) {
                     foreach ($_vals as $_v) {
                         if (strlen($_v) >= 3 and !in_array($_v, array_values($_fvals)) and !in_array($_v, $_sw)) {
                             $_fvals[] = $_v;
                         }
                         if ($_c >= $_limit) {
                             break;
                         }
                         $_c++;
                     }
                 }
                 $content = implode(',', $_fvals);
             } else {
                 $content = str_replace(array('.', '!', ':', ';', "'", '"', '@', '%', '*', '(', ')'), '', preg_replace("/&([^;]+?);/", "", $content));
             }
             $content = IPSText::truncate($content, $trimLen);
             break;
     }
     $this->_metaTags[$tag][0] = $encode === TRUE ? preg_replace('#&amp;(amp|gt|lt|quot);#', '&\\1;', $this->encodeMetaTagContent(preg_replace('/&amp;#(\\d+?);/', "&#\\1;", htmlspecialchars($content)))) : preg_replace('#&amp;(amp|gt|lt|quot);#', '&\\1;', $content);
 }
Beispiel #2
0
 /**
  * Clean the topic title
  *
  * @param	string	Raw title
  * @return	string	Cleaned title
  */
 public function cleanTopicTitle($title = "")
 {
     if ($this->settings['etfilter_punct']) {
         $title = preg_replace('/\\?{1,}/', "?", $title);
         $title = preg_replace("/(&#33;){1,}/", "&#33;", $title);
     }
     //-----------------------------------------
     // The DB column is 250 chars, so we need to do true mb_strcut, then fix broken HTML entities
     // This should be fine, as DB would do it regardless (cept we can fix the entities)
     //-----------------------------------------
     $title = preg_replace("/&(#{0,}([a-zA-Z0-9]+?)?)?\$/", '', IPSText::mbsubstr($title, 0, 250));
     $title = IPSText::stripAttachTag($title);
     $title = str_replace("<br />", "", $title);
     $title = trim($title);
     return $title;
 }
Beispiel #3
0
 /**
  * Process Results
  *
  * @param	array	Row from database using query specified in fetch()
  * @return	array	Same data with any additional processing necessary
  */
 public function process($row)
 {
     /* Build poster's display data */
     $member = $row['author_id'] ? IPSMember::load($row['author_id'], 'profile_portal,pfields_content,sessions,groups', 'id') : IPSMember::setUpGuest();
     $row = array_merge($row, IPSMember::buildDisplayData($member, array('reputation' => 0, 'warn' => 0)));
     /* Get forum data (damn HTML >.<) */
     $forumData = ipsRegistry::getClass('class_forums')->getForumById($row['forum_id']);
     /* Parse BBCode */
     IPSText::getTextClass('bbcode')->parse_smilies = $row['use_emo'];
     IPSText::getTextClass('bbcode')->parse_html = ($forumData['use_html'] and $member['g_dohtml'] and $row['post_htmlstate']) ? 1 : 0;
     IPSText::getTextClass('bbcode')->parse_nl2br = $row['post_htmlstate'] == 2 ? 1 : 0;
     IPSText::getTextClass('bbcode')->parse_bbcode = 1;
     IPSText::getTextClass('bbcode')->parsing_section = 'topics';
     IPSText::getTextClass('bbcode')->parsing_mgroup = $member['member_group_id'];
     IPSText::getTextClass('bbcode')->parsing_mgroup_others = $member['mgroup_others'];
     $row['post'] = IPSText::getTextClass('bbcode')->preDisplayParse($row['post']);
     /* Parse attachments */
     $messageHTML = array($row['pid'] => $row['post']);
     $attachHTML = $this->class_attach->renderAttachments($messageHTML, array($row['pid']));
     if (is_array($attachHTML) and count($attachHTML)) {
         /* Get rid of any lingering attachment tags */
         if (stristr($attachHTML[$row['pid']]['html'], "[attachment=")) {
             $attachHTML[$row['pid']]['html'] = IPSText::stripAttachTag($attachHTML[$row['pid']]['html']);
         }
         $row['post'] = $attachHTML[$row['pid']]['html'] . $attachHTML[$row['pid']]['attachmentHtml'];
     }
     /* Get rep buttons */
     if ($row['repUserGiving'] == ipsRegistry::member()->getProperty('member_id')) {
         $row['has_given_rep'] = $row['rep_rating'];
     }
     $row['rep_points'] = ipsRegistry::getClass('repCache')->getRepPoints(array('app' => 'forums', 'type' => 'pid', 'type_id' => $row['pid'], 'rep_points' => $row['rep_points']));
     $row['repButtons'] = ipsRegistry::getClass('repCache')->getLikeFormatted(array('app' => 'forums', 'type' => 'pid', 'id' => $row['pid'], 'rep_like_cache' => $row['rep_like_cache']));
     /* Return */
     return $row;
 }
 /**
  * Parse search results
  *
  * @param	array 	$r			Search result
  * @return	array 	$html		Blocks of HTML
  */
 public function parseAndFetchHtmlBlocks($rows)
 {
     /* Forum stuff */
     $sub = false;
     $isVnc = false;
     $search_term = IPSSearchRegistry::get('in.clean_search_term');
     $noPostPreview = IPSSearchRegistry::get('opt.noPostPreview');
     $results = array();
     $attachPids = array();
     /* loop and process */
     foreach ($rows as $id => $data) {
         /* Reset */
         $pages = 0;
         /* Set up forum */
         $forum = $this->registry->getClass('class_forums')->forum_by_id[$data['forum_id']];
         $this->last_topic = $data['tid'];
         /* Various data */
         $data['_last_post'] = $data['last_post'];
         $data['_longTitle'] = $data['content_title'];
         $data['_shortTitle'] = IPSText::mbstrlen(strip_tags($data['content_title'])) > 60 ? IPSText::truncate($data['content_title'], 60) : $data['content_title'];
         $data['last_poster'] = $data['last_poster_id'] ? IPSMember::buildDisplayData($data['last_poster_id']) : IPSMember::buildDisplayData(IPSMember::setUpGuest($this->settings['guest_name_pre'] . $data['last_poster_name'] . $this->settings['guest_name_suf']));
         $data['starter'] = $data['starter_id'] ? IPSMember::makeProfileLink($data['starter_name'], $data['starter_id'], $data['seo_first_name']) : $this->settings['guest_name_pre'] . $data['starter_name'] . $this->settings['guest_name_suf'];
         //$data['last_post']   = $this->registry->getClass( 'class_localization')->getDate( $data['last_post'], 'SHORT' );
         if (isset($data['post_date'])) {
             $data['_post_date'] = $data['post_date'];
             //$data['post_date']	= $this->registry->getClass( 'class_localization')->getDate( $data['post_date'], 'SHORT' );
         }
         if ($this->registry->getClass('class_forums')->canQueuePosts($forum['id'])) {
             $data['posts'] += intval($data['topic_queuedposts']);
         }
         if ($this->registry->getClass('class_forums')->canSeeSoftDeletedPosts($forum['id'])) {
             $data['posts'] += intval($data['topic_deleted_posts']);
         }
         if ($data['posts']) {
             if (($data['posts'] + 1) % $this->settings['display_max_posts'] == 0) {
                 $pages = ($data['posts'] + 1) / $this->settings['display_max_posts'];
             } else {
                 $number = ($data['posts'] + 1) / $this->settings['display_max_posts'];
                 $pages = ceil($number);
             }
         }
         if ($pages > 1) {
             for ($i = 0; $i < $pages; ++$i) {
                 $real_no = $i * $this->settings['display_max_posts'];
                 $page_no = $i + 1;
                 if ($page_no == 4 and $pages > 4) {
                     $data['pages'][] = array('last' => 1, 'st' => ($pages - 1) * $this->settings['display_max_posts'], 'page' => $pages, 'total' => $pages);
                     break;
                 } else {
                     $data['pages'][] = array('last' => 0, 'st' => $real_no, 'page' => $page_no, 'total' => $pages);
                 }
             }
         }
         /* For-matt some stuffs */
         if (IPSSearchRegistry::get('opt.noPostPreview') != true) {
             if (!$data['cache_content']) {
                 IPSText::getTextClass('bbcode')->parse_smilies = $data['use_emo'];
                 IPSText::getTextClass('bbcode')->parse_html = ($forum['use_html'] and $this->caches['group_cache'][$data['member_group_id']]['g_dohtml'] and $data['post_htmlstate']) ? 1 : 0;
                 IPSText::getTextClass('bbcode')->parse_nl2br = $data['post_htmlstate'] == 2 ? 1 : 0;
                 IPSText::getTextClass('bbcode')->parse_bbcode = $forum['use_ibc'];
                 IPSText::getTextClass('bbcode')->parsing_section = 'topics';
                 IPSText::getTextClass('bbcode')->parsing_mgroup = $data['member_group_id'];
                 IPSText::getTextClass('bbcode')->parsing_mgroup_others = $data['mgroup_others'];
                 $data['post'] = IPSText::getTextClass('bbcode')->preDisplayParse($data['post']);
             } else {
                 $data['post'] = '<!--cached-' . gmdate('r', $data['cache_updated']) . '-->' . $data['cache_content'];
             }
             $data['post'] = IPSText::searchHighlight($data['post'], $search_term);
         }
         /* Has attachments */
         if ($data['topic_hasattach']) {
             $attachPids[$data['pid']] = $data['post'];
         }
         $rows[$id] = $data;
     }
     /* Attachments */
     if (count($attachPids) and IPSSearchRegistry::get('set.returnType') != 'tids') {
         /* Load attachments class */
         if (!is_object($this->class_attach)) {
             $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('core') . '/sources/classes/attach/class_attach.php', 'class_attach');
             $this->class_attach = new $classToLoad($this->registry);
             $this->class_attach->type = 'post';
             $this->class_attach->init();
         }
         $attachHTML = $this->class_attach->renderAttachments($attachPids, array_keys($attachPids));
         /* Now parse back in the rendered posts */
         if (is_array($attachHTML) and count($attachHTML)) {
             foreach ($attachHTML as $id => $_data) {
                 /* Get rid of any lingering attachment tags */
                 if (stristr($_data['html'], "[attachment=")) {
                     $_data['html'] = IPSText::stripAttachTag($_data['html']);
                 }
                 $rows[$id]['post'] = $_data['html'];
                 $rows[$id]['attachmentHtml'] = $_data['attachmentHtml'];
             }
         }
     }
     /* Go through and build HTML */
     foreach ($rows as $id => $data) {
         /* Format content */
         list($html, $sub) = $this->formatContent($data);
         $results[$id] = array('html' => $html, 'app' => $data['app'], 'type' => $data['type'], 'sub' => $sub, '_followData' => !empty($data['_followData']) ? $data['_followData'] : array());
     }
     return $results;
 }
Beispiel #5
0
 /**
  * Rebuild Export Cache
  *
  * @param	mixed	$rss_export_id	Which export id to execute
  * @param	bool	$return			Whether to return afterwards or output to page
  * @return	mixed
  */
 public function rssExportRebuildCache($rss_export_id = '', $return = true)
 {
     /* INIT */
     if (!$rss_export_id) {
         $rss_export_id = $this->request['rss_export_id'] == 'all' ? 'all' : intval($this->request['rss_export_id']);
     }
     /* Load topics lang file (for attachment stuff) */
     $this->registry->class_localization->loadLanguageFile(array('public_topic'), 'forums');
     /* Check ID */
     if (!$rss_export_id) {
         $this->registry->output->global_message = $this->lang->words['ex_noid'];
         $this->rssExportOverview();
         return;
     }
     /* Get RSS Clas */
     $classToLoad = IPSLib::loadLibrary(IPS_KERNEL_PATH . 'classRss.php', 'classRss');
     $class_rss = new $classToLoad();
     $class_rss->doc_type = IPS_DOC_CHAR_SET;
     /* Reset rss_export cache */
     $this->cache->updateCacheWithoutSaving('rss_export', array());
     /* Grab the parser file */
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/text/parser.php', 'classes_text_parser');
     $parser = new $classToLoad();
     /* Go loopy */
     $this->DB->build(array('select' => '*', 'from' => 'rss_export'));
     $outer = $this->DB->execute();
     $cache = array();
     while ($row = $this->DB->fetch($outer)) {
         /* Update RSS Cache */
         if ($row['rss_export_enabled']) {
             $cache[] = array('url' => $this->settings['board_url'] . '/index.php?act=rssout&amp;id=' . $row['rss_export_id'], 'title' => $row['rss_export_title']);
         }
         /* Add to cache? */
         if ($rss_export_id == 'all' or $row['rss_export_id'] == $rss_export_id) {
             /* Build DB Query */
             if ($row['rss_export_include_post']) {
                 $this->DB->build(array('select' => 't.*', 'from' => array('topics' => 't'), 'where' => "t.forum_id IN( " . $row['rss_export_forums'] . " ) AND t.state != 'link' AND " . $this->registry->getClass('class_forums')->fetchTopicHiddenQuery(array('visible'), 't.'), 'order' => 't.' . $row['rss_export_order'] . ' ' . $row['rss_export_sort'], 'limit' => array(0, $row['rss_export_count']), 'add_join' => array(array('select' => 'p.pid, p.post, p.use_emo, p.post_htmlstate', 'from' => array('posts' => 'p'), 'where' => 't.topic_firstpost=p.pid', 'type' => 'left'))));
             } else {
                 $this->DB->build(array('select' => '*', 'from' => 'topics', 'where' => "forum_id IN( " . $row['rss_export_forums'] . " ) AND state != 'link' AND " . $this->registry->getClass('class_forums')->fetchTopicHiddenQuery(array('visible'), ''), 'order' => $row['rss_export_order'] . ' ' . $row['rss_export_sort'], 'limit' => array(0, $row['rss_export_count'])));
             }
             /* Exec Query */
             $inner = $this->DB->execute();
             /* Set var.  Doing this so we can set pubDate to start date or last post date appropriately... */
             $channelCreated = false;
             $_attachments = null;
             /* Loop through topics and display */
             while ($topic = $this->DB->fetch($inner)) {
                 //-----------------------------------------
                 // Create channel if not already crated
                 //-----------------------------------------
                 if (!$channelCreated) {
                     /* Create Channel */
                     $channel_id = $class_rss->createNewChannel(array('title' => $row['rss_export_title'], 'description' => $row['rss_export_desc'], 'link' => $this->settings['board_url'], 'pubDate' => $class_rss->formatDate($row['rss_export_order'] == 'start_date' ? $topic['start_date'] : $topic['last_post']), 'ttl' => $row['rss_export_cache_time']));
                     if ($row['rss_export_image']) {
                         $class_rss->addImageToChannel($channel_id, array('title' => $row['rss_export_title'], 'url' => $row['rss_export_image'], 'link' => $this->settings['board_url']));
                     }
                     $channelCreated = true;
                 }
                 //-----------------------------------------
                 // Parse the post
                 //-----------------------------------------
                 $this->settings['__noTruncateUrl'] = 1;
                 /* set up parser */
                 $parser->set(array('memberData' => array('member_id' => 0, 'member_group_id' => $this->settings['guest_group']), 'parseBBCode' => 1, 'parseHtml' => ($this->registry->class_forums->forum_by_id[$topic['forum_id']]['use_html'] and $topic['post_htmlstate']) ? 1 : 0, 'parseEmoticons' => $topic['use_emo'], 'parseArea' => 'topics'));
                 $topic['post'] = $parser->display($topic['post']);
                 if ($row['rss_export_include_post'] and $topic['topic_hasattach']) {
                     if (!is_object($_attachments)) {
                         /* Grab render attach class */
                         $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('core') . '/sources/classes/attach/class_attach.php', 'class_attach');
                         $_attachments = new $classToLoad($this->registry);
                     }
                     $_attachments->type = 'post';
                     $_attachments->init();
                     # attach_pids is generated in the func_topic_xxxxx files
                     $attachHTML = $_attachments->renderAttachments(array($topic['pid'] => $topic['post']), array($topic['pid'] => $topic['pid']));
                     /* Now parse back in the rendered posts */
                     if (is_array($attachHTML) and count($attachHTML)) {
                         foreach ($attachHTML as $id => $data) {
                             /* Get rid of any lingering attachment tags */
                             if (stristr($data['html'], "[attachment=")) {
                                 $data['html'] = IPSText::stripAttachTag($data['html']);
                             }
                             $topic['post'] = $data['html'];
                             $topic['post'] .= $data['attachmentHtml'];
                         }
                     }
                 }
                 /* Parse */
                 //$topic['post'] = preg_replace( "#\[attachment=(\d+?)\:(?:[^\]]+?)\]#is", "<a href='{$this->settings['board_url']}/index.php?app=core&module=attach&section=attach&attach_rel_module=post&attach_id=\\1'>".$this->settings['board_url']."/index.php?app=forums&module=forums&section=attach&type=post&attach_id=\\1</a>", $topic['post'] );
                 /* Fix up relative URLs */
                 $topic['post'] = preg_replace('#([^/])style_images/(<\\#IMG_DIR\\#>)#is', "\\1" . $this->settings['board_url'] . "/style_images/\\2", $topic['post']);
                 $topic['post'] = preg_replace('#(["\'])style_emoticons/#is', "\\1" . $this->settings['board_url'] . "/style_emoticons/", $topic['post']);
                 $topic['post'] = $this->registry->output->replaceMacros($topic['post']);
                 $topic['last_poster_name'] = $topic['last_poster_name'] ? $topic['last_poster_name'] : 'Guest';
                 $topic['starter_name'] = $topic['starter_name'] ? $topic['starter_name'] : 'Guest';
                 /* Add item */
                 $class_rss->addItemToChannel($channel_id, array('title' => $topic['title'], 'link' => $this->registry->output->buildSEOUrl('showtopic=' . $topic['tid'], 'publicNoSession', $topic['title_seo'], 'showtopic'), 'description' => $topic['post'], 'pubDate' => $class_rss->formatDate($row['rss_export_order'] == 'last_post' ? $topic['last_post'] : $topic['start_date']), 'guid' => $this->registry->output->buildSEOUrl('showtopic=' . $topic['tid'], 'publicNoSession', $topic['title_seo'], 'showtopic')));
             }
             /* Build document				 */
             $class_rss->createRssDocument();
             /* Update the cache */
             $this->DB->update('rss_export', array('rss_export_cache_last' => time(), 'rss_export_cache_content' => $class_rss->rss_document), 'rss_export_id=' . $row['rss_export_id']);
         }
     }
     /* Update cache */
     $this->cache->setCache('rss_export', $cache, array('donow' => 1, 'array' => 1));
     $this->cache->rebuildCache('rss_output_cache');
     /* Return */
     if ($return) {
         $this->registry->output->global_message = $this->lang->words['ex_recached'];
         $this->rssExportOverview();
         return;
     } else {
         return $class_rss->rss_document;
     }
 }
 /**
  * Returns a complete topic
  *
  * @access	public
  * @param	int 		Member ID
  * @param	string		Folder ID (eg: inbox, sent, etc)
  * @param	array 		Array of data ( array[ sort => '', offsetStart' => '', 'offsetEnd' => '' )
  * @return	array 		Array of PMs indexed by PM ID
  *
  * <code>
  * Exception Codes
  * NO_READ_PERMISSION		You do not have permission to read the topic
  * YOU_ARE_BANNED			You have been banned
  * </code>
  */
 public function fetchConversation($topicID, $readingMemberID, $filters = array())
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $readingMemberID = intval($readingMemberID);
     $topicID = intval($topicID);
     $oStart = intval($filters['offsetStart']);
     $oEnd = intval($filters['offsetEnd']);
     $replyData = array();
     $topicData = array();
     $remapData = array();
     $memberData = array();
     $missingMembers = array();
     $whereExtra = '';
     //-----------------------------------------
     // Figure out sort key
     //-----------------------------------------
     switch ($filters['sort']) {
         case 'rdate':
             $sortKey = 'msg.msg_date DESC';
             break;
         default:
             $sortKey = 'msg.msg_date ASC';
             break;
     }
     if (!$topicID) {
         return array('topicData' => $topicData, 'replyData' => $replyData);
     } else {
         /* Get member data */
         $memberData = $this->fetchTopicParticipants($topicID, TRUE);
         /* Get reading member's data */
         $readingMemberData = $memberData[$readingMemberID];
         /* Fetch topic data */
         $topicData = $this->fetchTopicData($topicID, FALSE);
         /* Topic deleted? Grab topic starter details, as they won't be in the participant array */
         if ($topicData['mt_is_deleted'] and $topicData['mt_starter_id'] > 0) {
             $memberData[$topicData['mt_starter_id']] = IPSMember::load($topicData['mt_starter_id'], 'all');
             $memberData[$topicData['mt_starter_id']]['_canBeBlocked'] = IPSMember::isIgnorable($memberData[$topicData['mt_starter_id']]['member_group_id'], $memberData[$topicData['mt_starter_id']]['mgroup_others']);
             $memberData[$topicData['mt_starter_id']] = IPSMember::buildDisplayData($memberData[$topicData['mt_starter_id']], array('__all__' => 1));
             $memberData[$topicData['mt_starter_id']]['map_user_active'] = 1;
             /* Set flag for topic participant starter */
             $memberData[$topicData['mt_starter_id']]['map_is_starter'] = 1;
             foreach ($memberData as $id => $data) {
                 $memberData[$id]['_topicDeleted'] = 1;
             }
         }
         /* Can access this topic? */
         if ($this->canAccessTopic($readingMemberID, $topicData, $memberData) !== TRUE) {
             /* Banned? */
             if ($readingMemberData['map_user_banned']) {
                 throw new Exception("YOU_ARE_BANNED");
             } else {
                 throw new Exception("NO_READ_PERMISSION");
             }
         }
         /* Reply Data */
         $this->DB->build(array('select' => 'msg.*', 'from' => array('message_posts' => 'msg'), 'where' => "msg.msg_topic_id=" . $topicID . $whereExtra, 'order' => $sortKey, 'limit' => array($oStart, $oEnd), 'add_join' => array(array('select' => 'iu.*', 'from' => array('ignored_users' => 'iu'), 'where' => 'iu.ignore_owner_id=' . $readingMemberID . ' AND iu.ignore_ignore_id=msg.msg_author_id', 'type' => 'left'), array('select' => 'm.member_group_id, m.mgroup_others', 'from' => array('members' => 'm'), 'where' => 'm.member_id=msg.msg_author_id', 'type' => 'left'))));
         $o = $this->DB->execute();
         //-----------------------------------------
         // Get the messages
         //-----------------------------------------
         while ($msg = $this->DB->fetch($o)) {
             $msg['_ip_address'] = "";
             /* IP Address */
             if ($msg['msg_ip_address'] and $readingMemberData['g_is_supmod'] == 1) {
                 $msg['_ip_address'] = $msg['msg_ip_address'];
             }
             /* Edit */
             $msg['_canEdit'] = $this->_conversationCanEdit($msg, $topicData, $readingMemberData);
             /* Delete */
             $msg['_canDelete'] = $this->_conversationCanDelete($msg, $topicData, $readingMemberData);
             /* Format Message */
             $msg['msg_post'] = $this->_formatMessageForDisplay($msg['msg_post'], $msg);
             /* Member missing? */
             if (!isset($memberData[$msg['msg_author_id']])) {
                 $missingMembers[$msg['msg_author_id']] = $msg['msg_author_id'];
             }
             $replyData[$msg['msg_id']] = $msg;
         }
     }
     /* Members who've deleted a closed conversation? */
     if (count($missingMembers)) {
         $_members = IPSMember::load(array_keys($missingMembers), 'all');
         foreach ($_members as $id => $data) {
             $data['_canBeBlocked'] = IPSMember::isIgnorable($memberData[$topicData['mt_starter_id']]['member_group_id'], $memberData[$topicData['mt_starter_id']]['mgroup_others']);
             $data['map_user_active'] = 0;
             $memberData[$data['member_id']] = IPSMember::buildDisplayData($data, array('__all__' => 1));
         }
     }
     /* Update reading member's read time */
     $this->DB->update('message_topic_user_map', array('map_read_time' => time(), 'map_has_unread' => 0), 'map_user_id=' . intval($readingMemberData['member_id']) . ' AND map_topic_id=' . $topicID);
     /* Reduce the number of 'new' messages */
     $_newMsgs = intval($this->getPersonalTopicsCount($readingMemberID, 'new'));
     if ($memberData[$readingMemberID]['map_has_unread']) {
         $_pc = $this->rebuildFolderCount($readingMemberID, array('new' => $_newMsgs), TRUE);
         IPSMember::save($readingMemberID, array('core' => array('msg_count_new' => $_newMsgs)));
         /* is this us? */
         if ($readingMemberID == $this->memberData['member_id']) {
             /* Reset folder data */
             $this->_dirData = $this->explodeFolderData($_pc);
             /* Reset global new count */
             $this->memberData['msg_count_new'] = $_newMsgs;
         }
     }
     /* Clean up topic title */
     $topicData['mt_title'] = str_replace('[attachmentid=', '&#91;attachmentid=', $topicData['mt_title']);
     /* Ensure our read time is updated */
     $memberData[$readingMemberID]['map_read_time'] = time();
     /* Do we  have a deleted user? */
     if (isset($memberData[0]) and $memberData[0]['member_id'] == 0) {
         $memberData[0] = IPSMember::buildDisplayData(IPSMember::setUpGuest("Deleted Member"), array('__all__' => 1));
     }
     //-----------------------------------------
     // Attachments?
     //-----------------------------------------
     if ($topicData['mt_hasattach']) {
         //-----------------------------------------
         // INIT. Yes it is
         //-----------------------------------------
         $postHTML = array();
         //-----------------------------------------
         // Separate out post content
         //-----------------------------------------
         foreach ($replyData as $id => $post) {
             $postHTML[$id] = $post['msg_post'];
         }
         if (!is_object($this->class_attach)) {
             require_once IPSLib::getAppDir('core') . '/sources/classes/attach/class_attach.php';
             $this->class_attach = new class_attach($this->registry);
         }
         $this->class_attach->type = 'msg';
         $this->class_attach->init();
         $attachHTML = $this->class_attach->renderAttachments($postHTML);
         /* Now parse back in the rendered posts */
         foreach ($attachHTML as $id => $data) {
             /* Get rid of any lingering attachment tags */
             if (stristr($data['html'], "[attachment=")) {
                 $data['html'] = IPSText::stripAttachTag($data['html']);
             }
             $replyData[$id]['msg_post'] = $data['html'];
             $replyData[$id]['attachmentHtml'] = $data['attachmentHtml'];
         }
     }
     /* Return */
     return array('topicData' => $topicData, 'replyData' => $replyData, 'memberData' => $memberData);
 }
 /**
  * Parse attachments
  *
  * @access	public
  * @param	array	Array of post data
  * @return	string	HTML parsed by attachment class
  */
 public function _parseAttachments($postData)
 {
     //-----------------------------------------
     // INIT. Yes it is
     //-----------------------------------------
     $postHTML = array();
     //-----------------------------------------
     // Separate out post content
     //-----------------------------------------
     foreach ($postData as $id => $post) {
         $postHTML[$id] = $post['post']['post'];
     }
     //-----------------------------------------
     // ATTACHMENTS!!!
     //-----------------------------------------
     if ($this->topic['topic_hasattach']) {
         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);
         }
         //-----------------------------------------
         // Not got permission to view downloads?
         //-----------------------------------------
         if ($this->registry->permissions->check('download', $this->registry->class_forums->forum_by_id[$this->topic['forum_id']]) === FALSE) {
             $this->settings['show_img_upload'] = 0;
         }
         //-----------------------------------------
         // Continue...
         //-----------------------------------------
         $this->class_attach->type = 'post';
         $this->class_attach->init();
         # attach_pids is generated in the func_topic_xxxxx files
         $attachHTML = $this->class_attach->renderAttachments($postHTML, $this->attach_pids);
     }
     /* Now parse back in the rendered posts */
     if (is_array($attachHTML) and count($attachHTML)) {
         foreach ($attachHTML as $id => $data) {
             /* Get rid of any lingering attachment tags */
             if (stristr($data['html'], "[attachment=")) {
                 $data['html'] = IPSText::stripAttachTag($data['html']);
             }
             $postData[$id]['post']['post'] = $data['html'];
             $postData[$id]['post']['attachmentHtml'] = $data['attachmentHtml'];
         }
     }
     return $postData;
 }
 /**
  * Auto populate the data and that. Populated topicData and forumData. Also does rudimentary access checks
  *
  * @param	mixed	$topic	Array of topic data, or single topic id
  * @param	bool	$return	Return errors instead of printing
  * @return	@e void
  */
 public function autoPopulate($topic = "", $return = true)
 {
     /* @todo Remove other calls to request['t'] - intvalled here because it's called in a million places */
     $this->request['t'] = intval($this->request['t']);
     $this->return = $return;
     /* Sanitize */
     $topicId = intval($this->request['t']);
     if (!is_array($topic)) {
         if (!$topicId) {
             throw new Exception('EX_topics_no_tid');
         }
         /* May have loaded topic data previously */
         if (empty($this->registry->class_forums->topic_cache['tid'])) {
             /* Load tagging stuff */
             if (!$this->registry->isClassLoaded('tags')) {
                 require_once IPS_ROOT_PATH . 'sources/classes/tags/bootstrap.php';
                 /*noLibHook*/
                 $this->registry->setClass('tags', classes_tags_bootstrap::run('forums', 'topics'));
             }
             $this->DB->build(array('select' => 't.*', 'from' => array('topics' => 't'), 'where' => 't.tid=' . $topicId, 'add_join' => array($this->registry->tags->getCacheJoin(array('meta_id_field' => 't.tid')))));
             $this->DB->execute();
             $this->setTopicData($this->DB->fetch());
         } else {
             $this->setTopicData($this->registry->class_forums->topic_cache);
         }
     } else {
         $this->setTopicData($topic);
     }
     $this->topicData['title'] = IPSText::stripAttachTag($this->topicData['title']);
     /* @todo Remove other calls to request['f'] - intvalled here because it's called in a million places */
     $this->request['f'] = intval($this->topicData['forum_id']);
     /* Check to see if stuff is stuffable */
     $result = $this->canView();
     if ($result === false) {
         throw new Exception($this->getErrorMessage());
     }
     if (!empty($this->topicData['tag_cache_key'])) {
         $this->topicData['tags'] = $this->registry->tags->formatCacheJoinData($this->topicData);
     }
     /* Set up */
     $this->topicData = $this->setUpTopic($this->topicData);
 }
Beispiel #9
0
 /**
  * Return the HTML to display the tab
  *
  * @return	@e string
  */
 public function showTab($string)
 {
     //-----------------------------------------
     // Are we a member?
     //-----------------------------------------
     if (!$this->memberData['member_id']) {
         return '';
     }
     //-----------------------------------------
     // How many approved events do we have?
     //-----------------------------------------
     $st = intval($this->request['st']);
     $each = 30;
     $where = '';
     if ($string) {
         $where = " AND ( event_title LIKE '%{$string}%' OR event_content LIKE '%{$string}%' )";
     }
     $count = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as total', 'from' => 'cal_events', 'where' => "event_approved=1 AND event_private=0 AND event_member_id={$this->memberData['member_id']}" . $where));
     $rows = array();
     $pages = $this->registry->output->generatePagination(array('totalItems' => $count['total'], 'itemsPerPage' => $each, 'currentStartValue' => $st, 'seoTitle' => '', 'method' => 'nextPrevious', 'noDropdown' => true, 'ajaxLoad' => 'mymedia_content', 'baseUrl' => "app=core&amp;module=ajax&amp;section=media&amp;do=loadtab&amp;tabapp=calendar&amp;tabplugin=events&amp;search=" . urlencode($string)));
     $this->DB->build(array('select' => '*', 'from' => 'cal_events', 'where' => "event_approved=1 AND event_private=0 AND event_member_id={$this->memberData['member_id']}" . $where, 'order' => 'event_lastupdated DESC', 'limit' => array($st, $each)));
     $outer = $this->DB->execute();
     while ($r = $this->DB->fetch($outer)) {
         $rows[] = array('image' => $this->settings['img_url'] . '/sharedmedia/events.png', 'width' => 0, 'height' => 0, 'title' => IPSText::truncate($r['event_title'], 25), 'desc' => IPSText::truncate(strip_tags(IPSText::stripAttachTag(IPSText::getTextClass('bbcode')->stripAllTags($r['event_content'])), '<br>'), 100), 'insert' => "calendar:events:" . $r['event_id']);
     }
     return $this->registry->output->getTemplate('editors')->mediaGenericWrapper($rows, $pages, 'calendar', 'events');
 }
 /**
  * Returns the data for the best answer
  * @param array $postData
  */
 protected function _getBestAnswerFeature(array $postData, $topicData)
 {
     if ($this->registry->class_forums->answerTopicsEnabled($topicData['forum_id']) !== true) {
         return false;
     }
     if (empty($topicData['topic_answered_pid'])) {
         return false;
     }
     if (in_array($topicData['topic_answered_pid'], array_keys($postData))) {
         $postData[$topicData['topic_answered_pid']]['post']['post'] = IPSText::stripAttachTag($postData[$topicData['topic_answered_pid']]['post']['post']);
         return $postData[$topicData['topic_answered_pid']];
     } else {
         $result = $this->registry->topics->parsePost($this->registry->topics->getPostById($topicData['topic_answered_pid']));
         /* Hasn't been deleted has it? */
         if (!$result['post']['pid']) {
             $result = array();
         }
         $result[$topicData['topic_answered_pid']]['post']['post'] = IPSText::stripAttachTag($result[$topicData['topic_answered_pid']]['post']['post']);
         return $result;
     }
 }
Beispiel #11
0
 /**
  * Saves the post
  *
  * @return	@e void
  */
 public function editBoxSave()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $pid = intval($this->request['p']);
     $fid = intval($this->request['f']);
     $tid = intval($this->request['t']);
     $attach_pids = array();
     $this->request['post_edit_reason'] = $this->convertAndMakeSafe($_POST['post_edit_reason']);
     //-----------------------------------------
     // Set things right
     //-----------------------------------------
     $this->request['Post'] = IPSText::parseCleanValue($_POST['Post']);
     //-----------------------------------------
     // Check P|T|FID
     //-----------------------------------------
     if (!$pid or !$tid or !$fid) {
         $this->returnString('error');
     }
     if ($this->memberData['member_id']) {
         if (IPSMember::isOnModQueue($this->memberData) === NULL) {
             $this->returnJsonError($this->lang->words['ajax_reply_noperm']);
         }
     }
     //-----------------------------------------
     // Load Lang
     //-----------------------------------------
     $this->registry->getClass('class_localization')->loadLanguageFile(array('public_topics'));
     if (!is_object($this->postClass)) {
         require_once IPSLib::getAppDir('forums') . '/sources/classes/post/classPost.php';
         /*noLibHook*/
         $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('forums') . '/sources/classes/post/classPostForms.php', 'classPostForms', 'forums');
         $this->postClass = new $classToLoad($this->registry);
     }
     # Forum Data
     $this->postClass->setForumData($this->registry->getClass('class_forums')->forum_by_id[$fid]);
     # IDs
     $this->postClass->setTopicID($tid);
     $this->postClass->setPostID($pid);
     $this->postClass->setForumID($fid);
     $this->postClass->setPublished('reply');
     $this->postClass->setSettings(array('post_htmlstatus' => intval($this->request['post_htmlstatus'])));
     /* Topic Data */
     $this->postClass->setTopicData($this->DB->buildAndFetch(array('select' => 't.*, p.poll_only', 'from' => array('topics' => 't'), 'where' => "t.forum_id={$fid} AND t.tid={$tid}", 'add_join' => array(array('type' => 'left', 'from' => array('polls' => 'p'), 'where' => 'p.tid=t.tid')))));
     # Set Author
     $this->postClass->setAuthor($this->member->fetchMemberData());
     # Set from ajax
     $this->postClass->setIsAjax(TRUE);
     # Post Content
     $this->postClass->setPostContent($_POST['Post']);
     # Get Edit form
     try {
         /**
          * If there was an error, return it as a JSON error
          */
         if ($this->postClass->editPost() === FALSE) {
             $this->returnJsonError($this->postClass->getPostError());
         }
         $topic = $this->postClass->getTopicData();
         $post = $this->postClass->getPostData();
         //-----------------------------------------
         // Display-parse
         //-----------------------------------------
         /* Load parser */
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/text/parser.php', 'classes_text_parser');
         $parser = new $classToLoad();
         $parser->set(array('memberData' => $this->postClass->getAuthor(), 'parseBBCode' => $this->registry->getClass('class_forums')->forum_by_id[$fid]['use_ibc'], 'parseArea' => 'topics', 'parseHtml' => ($this->registry->getClass('class_forums')->forum_by_id[$fid]['use_html'] and $this->memberData['g_dohtml'] and $this->request['post_htmlstatus']) ? 1 : 0, 'parseEmoticons' => $post['use_emo']));
         /* Make suitable for display */
         $post['post'] = $parser->display($post['post']);
         if (IPSText::getTextClass('bbcode')->error) {
             $this->returnJsonError($this->lang->words[IPSText::getTextClass('bbcode')->error]);
         }
         $edit_by = '';
         if ($post['append_edit'] == 1 and $post['edit_time'] and $post['edit_name']) {
             $e_time = $this->registry->getClass('class_localization')->getDate($post['edit_time'], 'LONG');
             $edit_by = sprintf($this->lang->words['edited_by'], $post['edit_name'], $e_time);
         }
         /* Attachments */
         if (!is_object($this->class_attach)) {
             //-----------------------------------------
             // Grab render attach class
             //-----------------------------------------
             $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('core') . '/sources/classes/attach/class_attach.php', 'class_attach');
             $this->class_attach = new $classToLoad($this->registry);
         }
         //-----------------------------------------
         // Not got permission to view downloads?
         //-----------------------------------------
         if ($this->registry->permissions->check('download', $this->registry->class_forums->forum_by_id[$topic['forum_id']]) === FALSE) {
             $this->settings['show_img_upload'] = 0;
         }
         $this->class_attach->type = 'post';
         $this->class_attach->init();
         $attachHtml = $this->class_attach->renderAttachments(array($pid => $post['post']));
         $post['post'] = $attachHtml[$pid]['html'];
         $post['attachmentHtml'] = $attachHtml[$pid]['attachmentHtml'];
         $output = $this->registry->output->getTemplate('topic')->quickEditPost(array('post' => $this->registry->getClass('output')->replaceMacros(IPSText::stripAttachTag($post['post'])), 'attachmentHtml' => $post['attachmentHtml'], 'pid' => $pid, 'edit_by' => $edit_by, 'post_edit_reason' => $post['post_edit_reason']));
         //-----------------------------------------
         // Return plain text
         //-----------------------------------------
         $this->returnJsonArray(array('successString' => $output), true);
     } catch (Exception $error) {
         $this->returnJsonError($error->getMessage());
     }
 }
Beispiel #12
0
 /**
  * Legacy, generic method: builds an email from a template, replacing variables
  *
  * @param	array		Replacement keys to values
  * @param	boolean		Raw HTML mode?
  * @return	@e void
  */
 public function buildHtmlContent($words = array(), $rawHtml = false)
 {
     /* Init */
     $htmlWords = array();
     /* Did we set a plainText template but not bother with HTML ? */
     if (!$this->htmlTemplate && $this->plainTextTemplate) {
         /* Need to exchange BRs? */
         if (!stristr($this->plainTextTemplate, '<br')) {
             $this->plainTextTemplate = nl2br($this->plainTextTemplate);
         }
         /* Sniff, sniff */
         $this->setHtmlTemplate($this->plainTextTemplate);
     }
     /* HTML enabled but no specific template: Auto convert */
     if ($this->html_email && !$this->htmlTemplate) {
         /* It will be dynamically updated at the end */
         $this->setHtmlTemplate($this->plainTextTemplate);
     }
     /* Bit more clean up */
     $this->htmlTemplate = str_replace(array("\r\n", "\r", "\n"), "\n", $this->htmlTemplate);
     /* Add some default words */
     $words['BOARD_ADDRESS'] = $this->settings['board_url'] . '/index.' . $this->settings['php_ext'];
     $words['WEB_ADDRESS'] = $this->settings['home_url'];
     $words['BOARD_NAME'] = $this->settings['board_name'];
     $words['SIGNATURE'] = $this->settings['signature'] ? $this->settings['signature'] : '';
     /* Swap the words: 10.7.08 - Added replacements in subject */
     foreach ($words as $k => $v) {
         $htmlWords[$k] = $v;
     }
     $this->_words = $htmlWords;
     $this->htmlTemplate = preg_replace_callback("/<#(.+?)#>/", array(&$this, '_swapWords'), str_replace(array('&lt;#', '#&gt;'), array('<#', '#>'), $this->htmlTemplate));
     $this->subject = preg_replace_callback("/<#(.+?)#>/", array(&$this, '_swapWords'), $this->subject);
     $this->_words = array();
     /* Final touches */
     $this->htmlTemplate = IPSText::stripAttachTag($this->htmlTemplate);
     $this->htmlTemplate = preg_replace('#<blockquote(?:[^>]+?)?>(.+?)</blockquote>#s', '<br /><div class="eQuote">\\1</div><br />', $this->htmlTemplate);
     $this->htmlTemplate = $this->applyHtmlWrapper($this->subject, $this->convertTextEmailToHtmlEmail($this->htmlTemplate, $rawHtml));
     $this->htmlTemplate = preg_replace('#<!--hook\\.([^\\>]+?)-->#', '', $this->htmlTemplate);
     $this->htmlTemplate = $this->registry->getClass('output')->parseIPSTags($this->htmlTemplate);
     /* For those who need it */
     return $this->htmlTemplate;
 }
 /**
  * Saves the post
  *
  * @access	public
  * @return	void
  */
 public function editBoxSave()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $pid = intval($this->request['p']);
     $fid = intval($this->request['f']);
     $tid = intval($this->request['t']);
     $attach_pids = array();
     $this->request['post_edit_reason'] = $this->convertAndMakeSafe($_POST['post_edit_reason']);
     //-----------------------------------------
     // Set things right
     //-----------------------------------------
     $this->request['Post'] = IPSText::parseCleanValue($_POST['Post']);
     //-----------------------------------------
     // Check P|T|FID
     //-----------------------------------------
     if (!$pid or !$tid or !$fid) {
         $this->returnString('error');
     }
     if ($this->memberData['member_id']) {
         if ($this->memberData['restrict_post']) {
             if ($this->memberData['restrict_post'] == 1) {
                 $this->returnString('nopermission');
             }
             $post_arr = IPSMember::processBanEntry($this->memberData['restrict_post']);
             if (time() >= $post_arr['date_end']) {
                 //-----------------------------------------
                 // Update this member's profile
                 //-----------------------------------------
                 IPSMember::save($this->memberData['member_id'], array('core' => array('restrict_post' => 0)));
             } else {
                 $this->returnString('nopermission');
             }
         }
     }
     //-----------------------------------------
     // Load Lang
     //-----------------------------------------
     $this->registry->getClass('class_localization')->loadLanguageFile(array('public_topics'));
     if (!is_object($this->postClass)) {
         require_once IPSLib::getAppDir('forums') . "/sources/classes/post/classPost.php";
         require_once IPSLib::getAppDir('forums') . "/sources/classes/post/classPostForms.php";
         $this->registry->getClass('class_localization')->loadLanguageFile(array('public_editors'), 'core');
         $this->postClass = new classPostForms($this->registry);
     }
     # Forum Data
     $this->postClass->setForumData($this->registry->getClass('class_forums')->forum_by_id[$fid]);
     # IDs
     $this->postClass->setTopicID($tid);
     $this->postClass->setPostID($pid);
     $this->postClass->setForumID($fid);
     /* Topic Data */
     $this->postClass->setTopicData($this->DB->buildAndFetch(array('select' => 't.*, p.poll_only', 'from' => array('topics' => 't'), 'where' => "t.forum_id={$fid} AND t.tid={$tid}", 'add_join' => array(array('type' => 'left', 'from' => array('polls' => 'p'), 'where' => 'p.tid=t.tid')))));
     # Set Author
     $this->postClass->setAuthor($this->member->fetchMemberData());
     # Set from ajax
     $this->postClass->setIsAjax(TRUE);
     # Post Content
     $this->postClass->setPostContent($_POST['Post']);
     if ($this->request['post_htmlstatus']) {
         $this->postClass->setSettings(array('post_htmlstatus' => $this->request['post_htmlstatus']));
     }
     # Get Edit form
     try {
         /**
          * If there was an error, return it as a JSON error
          */
         if ($this->postClass->editPost() === FALSE) {
             $this->returnJsonError($this->postClass->getPostError());
         }
         $topic = $this->postClass->getTopicData();
         $post = $this->postClass->getPostData();
         //-----------------------------------------
         // Pre-display-parse
         //-----------------------------------------
         IPSText::getTextClass('bbcode')->parse_smilies = $post['use_emo'];
         IPSText::getTextClass('bbcode')->parse_html = ($this->registry->getClass('class_forums')->forum_by_id[$fid]['use_html'] and $this->memberData['g_dohtml'] and $post['post_htmlstate']) ? 1 : 0;
         IPSText::getTextClass('bbcode')->parse_nl2br = $post['post_htmlstate'] == 2 ? 1 : 0;
         IPSText::getTextClass('bbcode')->parse_bbcode = 1;
         IPSText::getTextClass('bbcode')->parsing_section = 'topics';
         IPSText::getTextClass('bbcode')->parsing_mgroup = $this->postClass->getAuthor('member_group_id');
         IPSText::getTextClass('bbcode')->parsing_mgroup_others = $this->postClass->getAuthor('mgroup_others');
         $post['post'] = IPSText::getTextClass('bbcode')->preDisplayParse($post['post']);
         if (IPSText::getTextClass('bbcode')->error) {
             $this->returnJsonError($this->lang->words[IPSText::getTextClass('bbcode')->error]);
         }
         $edit_by = '';
         if ($post['append_edit'] == 1 and $post['edit_time'] and $post['edit_name']) {
             $e_time = $this->registry->getClass('class_localization')->getDate($post['edit_time'], 'LONG');
             $edit_by = sprintf($this->lang->words['edited_by'], $post['edit_name'], $e_time);
         }
         /* Attachments */
         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);
         }
         $this->class_attach->type = 'post';
         $this->class_attach->init();
         $attachHtml = $this->class_attach->renderAttachments(array($pid => $post['post']));
         $post['post'] = $attachHtml[$pid]['html'];
         $post['attachmentHtml'] = $attachHtml[$pid]['attachmentHtml'];
         $output = $this->registry->output->getTemplate('topic')->quickEditPost(array('post' => $this->registry->getClass('output')->replaceMacros(IPSText::stripAttachTag($post['post'])), 'attachmentHtml' => $post['attachmentHtml'], 'pid' => $pid, 'edit_by' => $edit_by, 'post_edit_reason' => $post['post_edit_reason']));
         //-----------------------------------------
         // Return plain text
         //-----------------------------------------
         $this->returnJsonArray(array('successString' => $output));
     } catch (Exception $error) {
         $this->returnJsonError($error->getMessage());
     }
 }
Beispiel #14
0
 /**
  * Process Results
  *
  * @param	array	Row from database using query specified in fetch()
  * @return	array	Same data with any additional processing necessary
  */
 public function process($row)
 {
     if (empty($row['comment_id'])) {
         $idField = 'event_id';
         $authorField = 'event_member_id';
         $contentField = 'event_content';
         $parseSmilies = intval($row['event_smilies']);
     } else {
         $idField = 'comment_id';
         $authorField = 'comment_mid';
         $contentField = 'comment_text';
         $parseSmilies = 1;
     }
     /* Build poster's display data */
     $member = $row[$authorField] ? IPSMember::load($row[$authorField], 'profile_portal,pfields_content,sessions,groups', 'id') : IPSMember::setUpGuest();
     $row = array_merge($row, IPSMember::buildDisplayData($member, array('reputation' => 0, 'warn' => 0)));
     /* Parse BBCode */
     IPSText::getTextClass('bbcode')->parse_smilies = $parseSmilies;
     IPSText::getTextClass('bbcode')->parse_html = 0;
     IPSText::getTextClass('bbcode')->parse_nl2br = 1;
     IPSText::getTextClass('bbcode')->parse_bbcode = 1;
     IPSText::getTextClass('bbcode')->parsing_section = 'calendar';
     IPSText::getTextClass('bbcode')->parsing_mgroup = $member['member_group_id'];
     IPSText::getTextClass('bbcode')->parsing_mgroup_others = $member['mgroup_others'];
     $row[$contentField] = IPSText::getTextClass('bbcode')->preDisplayParse($row[$contentField]);
     /* Parse attachments */
     $messageHTML = array($row[$idField] => $row[$contentField]);
     $attachHTML = $this->class_attach->renderAttachments($messageHTML, array($row[$idField]));
     if (is_array($attachHTML) and count($attachHTML)) {
         /* Get rid of any lingering attachment tags */
         if (stristr($attachHTML[$row[$idField]]['html'], "[attachment=")) {
             $attachHTML[$row[$idField]]['html'] = IPSText::stripAttachTag($attachHTML[$row[$idField]]['html']);
         }
         $row[$contentField] = $attachHTML[$row[$idField]]['html'] . $attachHTML[$row[$idField]]['attachmentHtml'];
     }
     /* Get rep buttons */
     if ($row['repUserGiving'] == ipsRegistry::member()->getProperty('member_id')) {
         $row['has_given_rep'] = $row['rep_rating'];
     }
     $row['repButtons'] = ipsRegistry::getClass('repCache')->getLikeFormatted(array('app' => 'calendar', 'type' => $idField, 'id' => $row[$idField], 'rep_like_cache' => $row['rep_like_cache']));
     /* Return */
     return $row;
 }