Beispiel #1
0
 /**
  * Show a single event based on eventid
  *
  * @return	@e void
  */
 public function calendarShowEvent()
 {
     //-----------------------------------------
     // Init
     //-----------------------------------------
     $event_id = intval($this->request['event_id']);
     if (!$event_id) {
         $this->registry->output->showError('calendar_event_not_found', 10429, null, null, 404);
     }
     //-----------------------------------------
     // Get the event data
     //-----------------------------------------
     $_joins = array(array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => 'm.member_id=e.event_member_id', 'type' => 'left'), array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'm.member_id=pp.pp_member_id', 'type' => 'left'));
     if ($this->settings['reputation_enabled']) {
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/class_reputation_cache.php', 'classReputationCache');
         $this->registry->setClass('repCache', new $classToLoad());
         $_joins[] = $this->registry->getClass('repCache')->getTotalRatingJoin('event_id', $event_id, 'calendar');
         $_joins[] = $this->registry->getClass('repCache')->getUserHasRatedJoin('event_id', $event_id, 'calendar');
     }
     $event = $this->DB->buildAndFetch(array('select' => 'e.*', 'from' => array('cal_events' => 'e'), 'where' => 'e.event_id=' . $event_id, 'add_join' => $_joins));
     if (!$event['event_id']) {
         $this->registry->output->showError('calendar_event_not_found', 10430, null, null, 404);
     }
     //-----------------------------------------
     // Reset calendar
     //-----------------------------------------
     $this->calendar = $this->functions->getCalendar($event['event_calendar_id']);
     if ($this->calendar['cal_id'] != $event['event_calendar_id']) {
         $this->registry->output->showError('cal_no_perm', 1040.22, null, null, 403);
     }
     //-----------------------------------------
     // Check permissions
     //-----------------------------------------
     if ($event['event_private'] and $this->memberData['member_id'] != $event['event_member_id']) {
         $this->registry->output->showError('calendar_event_not_found', 10431, null, null, 403);
     }
     if (!$this->memberData['g_is_supmod'] and !$event['event_approved']) {
         $this->registry->output->showError('calendar_event_not_found', 10432.1, null, null, 404);
     }
     if ($event['event_perms'] != '*') {
         $permissionGroups = explode(',', IPSText::cleanPermString($event['event_perms']));
         if (!IPSMember::isInGroup($this->memberData, $permissionGroups)) {
             $this->registry->output->showError('calendar_event_not_found', 10432, null, null, 404);
         }
     }
     //-----------------------------------------
     // Are we RSVPing?
     //-----------------------------------------
     if ($this->request['_rsvp'] and $event['event_rsvp']) {
         if ($this->registry->permissions->check('rsvp', $this->calendar) and $this->memberData['member_id']) {
             //-----------------------------------------
             // Make sure we aren't already RSVPed
             //-----------------------------------------
             $_check = $this->DB->buildAndFetch(array('select' => 'rsvp_id', 'from' => 'cal_event_rsvp', 'where' => 'rsvp_event_id=' . $event['event_id'] . ' AND rsvp_member_id=' . $this->memberData['member_id']));
             if (!$_check['rsvp_id']) {
                 $_insert = array('rsvp_event_id' => $event['event_id'], 'rsvp_member_id' => $this->memberData['member_id'], 'rsvp_date' => time());
                 $this->DB->insert('cal_event_rsvp', $_insert);
                 $this->registry->output->redirectScreen($this->lang->words['rsvp_saved_im'], $this->settings['base_url'] . "app=calendar&module=calendar&section=view&do=showevent&event_id=" . $event['event_id'], $event['event_title_seo'], 'cal_event');
             }
         }
     }
     //-----------------------------------------
     // Comments class
     //-----------------------------------------
     require_once IPS_ROOT_PATH . 'sources/classes/comments/bootstrap.php';
     /*noLibHook*/
     $this->_comments = classes_comments_bootstrap::controller('calendar-events');
     $comments = array('html' => $this->_comments->fetchFormatted($event, array('offset' => intval($this->request['st']))), 'count' => $this->_comments->count($event));
     //-----------------------------------------
     // Highlight...
     //-----------------------------------------
     if ($this->request['hl']) {
         $event['event_content'] = IPSText::searchHighlight($event['event_content'], $this->request['hl']);
         $event['event_title'] = IPSText::searchHighlight($event['event_title'], $this->request['hl']);
     }
     //-----------------------------------------
     // Can we report?
     //-----------------------------------------
     $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('core') . '/sources/classes/reportLibrary.php', 'reportLibrary', 'core');
     $reports = new $classToLoad($this->registry);
     $event['_canReport'] = $reports->canReport('calendar');
     //-----------------------------------------
     // Output
     //-----------------------------------------
     $member = IPSMember::load($event['event_member_id'], 'all');
     $this->registry->output->addNavigation($this->calendar['cal_title'], "app=calendar&module=calendar&section=view&cal_id={$this->calendar['cal_id']}", $this->calendar['cal_title_seo'], 'cal_calendar');
     //-----------------------------------------
     // Try to match out and improve navigation
     //-----------------------------------------
     $_referrer = $_SERVER['HTTP_REFERER'];
     if ($_referrer) {
         //-----------------------------------------
         // Came from add form?
         //-----------------------------------------
         if (preg_match("#/add\$#", $_referrer)) {
             $_data = $this->calendarMakeEventHTML($event, true);
             $_dateBits = explode('-', gmstrftime('%Y-%m-%d-%B', $_data['event']['_start_time']));
             $this->registry->output->addNavigation($_dateBits[3] . ' ' . $_dateBits[0], "app=calendar&module=calendar&section=view&cal_id={$this->calendar['cal_id']}&m={$_dateBits[1]}&y={$_dateBits[0]}", $this->calendar['cal_title_seo'], 'cal_month');
             $this->registry->output->addNavigation($_dateBits[3] . ' ' . $_dateBits[2] . ', ' . $_dateBits[0], "app=calendar&module=calendar&section=view&cal_id={$this->calendar['cal_id']}&do=showday&y={$_dateBits[0]}&m={$_dateBits[1]}&d={$_dateBits[2]}", $this->calendar['cal_title_seo'], 'cal_day');
         } else {
             if (preg_match("#/day\\-(\\d{4})\\-(\\d{1,2})\\-(\\d{1,2})\$#i", $_referrer, $matches)) {
                 $_dateBits = explode('-', gmstrftime('%Y-%m-%d-%B', gmmktime(0, 0, 0, $matches[2], $matches[3], $matches[1])));
                 $this->registry->output->addNavigation($_dateBits[3] . ' ' . $_dateBits[0], "app=calendar&module=calendar&section=view&cal_id={$this->calendar['cal_id']}&m={$_dateBits[1]}&y={$_dateBits[0]}", $this->calendar['cal_title_seo'], 'cal_month');
                 $this->registry->output->addNavigation($_dateBits[3] . ' ' . $_dateBits[2] . ', ' . $_dateBits[0], "app=calendar&module=calendar&section=view&cal_id={$this->calendar['cal_id']}&do=showday&y={$_dateBits[0]}&m={$_dateBits[1]}&d={$_dateBits[2]}", $this->calendar['cal_title_seo'], 'cal_day');
             } else {
                 if (preg_match("#/week\\-(\\d+?)\$#i", $_referrer, $matches)) {
                     $_dateBits = explode('-', gmstrftime('%Y-%m-%d-%B', $matches[1]));
                     $this->registry->output->addNavigation($_dateBits[3] . ' ' . $_dateBits[0], "app=calendar&module=calendar&section=view&cal_id={$this->calendar['cal_id']}&m={$_dateBits[1]}&y={$_dateBits[0]}", $this->calendar['cal_title_seo'], 'cal_month');
                     $this->registry->output->addNavigation("{$this->lang->words['week_beginning']} " . gmstrftime('%B %d, %Y', $matches[1]), "app=calendar&module=calendar&section=view&cal_id={$this->calendar['cal_id']}&do=showweek&week={$matches[1]}", $this->calendar['cal_title_seo'], 'cal_week');
                 } else {
                     if (preg_match("#/(\\d{1,2})\\-(\\d{4})\$#i", $_referrer, $matches)) {
                         $_dateBits = explode('-', gmstrftime('%Y-%m-%d-%B', gmmktime(0, 0, 0, $matches[1], 15, $matches[2])));
                         $this->registry->output->addNavigation($_dateBits[3] . " " . $_dateBits[0], "app=calendar&module=calendar&section=view&cal_id={$this->calendar['cal_id']}&m={$_dateBits[1]}&y={$_dateBits[0]}", $this->calendar['cal_title_seo'], 'cal_month');
                     } else {
                         if (preg_match("#/(\\d+?)\\-(.+?)\$#i", $_referrer, $matches)) {
                             $_data = $this->calendarMakeEventHTML($event, true);
                             $_dateBits = explode('-', gmstrftime('%Y-%m-%d-%B', $_data['event']['_start_time']));
                             $this->registry->output->addNavigation($_dateBits[3] . " " . $_dateBits[0], "app=calendar&module=calendar&section=view&cal_id={$this->calendar['cal_id']}&m={$_dateBits[1]}&y={$_dateBits[0]}", $this->calendar['cal_title_seo'], 'cal_month');
                         } else {
                             $_data = $this->calendarMakeEventHTML($event, true);
                             $_dateBits = explode('-', gmstrftime('%Y-%m-%d-%B', $_data['event']['_start_time']));
                             $this->registry->output->addNavigation($_dateBits[3] . ' ' . $_dateBits[0], "app=calendar&module=calendar&section=view&cal_id={$this->calendar['cal_id']}&m={$_dateBits[1]}&y={$_dateBits[0]}", $this->calendar['cal_title_seo'], 'cal_month');
                             $this->registry->output->addNavigation($_dateBits[3] . ' ' . $_dateBits[2] . ', ' . $_dateBits[0], "app=calendar&module=calendar&section=view&cal_id={$this->calendar['cal_id']}&do=showday&y={$_dateBits[0]}&m={$_dateBits[1]}&d={$_dateBits[2]}", $this->calendar['cal_title_seo'], 'cal_day');
                         }
                     }
                 }
             }
         }
     }
     //-----------------------------------------
     // Finish output
     //-----------------------------------------
     $this->registry->output->addNavigation($event['event_title']);
     $this->registry->output->addMetaTag('keywords', $this->chosen_date['month_name'] . ' ' . $_dateBits[2] . ' events event calendar ' . $event['event_title'] . ' ' . IPSText::getTextClass('bbcode')->stripAllTags($event['event_content']), TRUE);
     $this->registry->output->addMetaTag('description', str_replace("\n", " ", str_replace("\r", "", IPSText::getTextClass('bbcode')->stripAllTags($event['event_content']))), FALSE, 155);
     $this->registry->output->addToDocumentHead('raw', "<link rel='up' href='" . $this->registry->output->buildSEOUrl('app=calendar&amp;module=calendar&amp;section=view&amp;cal_id=' . $event['event_calendar_id'], 'publicNoSession', $this->calendar['cal_title_seo'], 'cal_calendar') . "' />");
     $this->registry->output->addToDocumentHead('raw', "<link rel='author' href='" . $this->registry->output->buildSEOUrl('showuser='******'event_member_id'], 'publicNoSession', $member['members_seo_name'], 'showuser') . "' />");
     $this->registry->getClass('output')->addCanonicalTag('app=calendar&amp;module=calendar&amp;section=view&amp;do=showevent&amp;event_id=' . $event['event_id'], $event['event_title_seo'], 'cal_event');
     $this->page_title = $event['event_title'];
     $this->output .= $this->registry->output->getTemplate('calendar')->calendarShowEvent($this->calendarMakeEventHTML($event), $comments);
 }
Beispiel #2
0
 /**
  * Parse common search results
  *
  * @access	private
  * @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');
     $results = array();
     /* loop and process */
     if (is_array($rows) and count($rows)) {
         foreach ($rows as $id => $r) {
             /* If basic search, strip the content - process only if we have content though */
             if ($r['content']) {
                 IPSText::getTextClass('bbcode')->parse_bbcode = 0;
                 IPSText::getTextClass('bbcode')->strip_quotes = 1;
                 IPSText::getTextClass('bbcode')->parsing_section = 'topics';
                 IPSText::getTextClass('bbcode')->parsing_mgroup = $r['member_group_id'];
                 IPSText::getTextClass('bbcode')->parsing_mgroup_others = $r['mgroup_others'];
                 $r['content'] = strip_tags(IPSText::getTextClass('bbcode')->stripAllTags($r['content']));
                 $r['content'] = str_replace(array('&lt;br&gt;', '&lt;br /&gt;'), '', $r['content']);
                 $r['content'] = trim(str_replace(array("\n\n\n", "\n\n"), "\n", str_replace("\r", '', $r['content'])));
                 /* Highlight */
                 $r['content'] = IPSText::searchHighlight($this->searchTruncate($r['content'], $search_term), $search_term);
             }
             /* Format title */
             $r['content_title'] = IPSText::searchHighlight($r['content_title'], $search_term);
             /* Format content */
             list($html, $sub) = $this->formatContent($r);
             $results[$id] = array('html' => $html, 'app' => $r['app'], 'type' => $r['type'], 'sub' => $sub, '_followData' => !empty($r['_followData']) ? $r['_followData'] : array());
         }
     }
     return $results;
 }
 /**
  * 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 #4
0
 /**
  * Displays a help file
  *
  * @return	@e void
  */
 public function helpShowSection()
 {
     /* Check ID */
     $id = $this->request['HID'] ? intval($this->request['HID']) : 0;
     if (!$id) {
         $this->helpShowTitles();
         return;
     }
     /* Query the hel topic */
     $topic = $this->DB->buildAndFetch(array('select' => 'id, title, text', 'from' => 'faq', 'where' => 'id=' . $id));
     if (!$topic['id']) {
         $this->registry->output->showError('help_no_id', 10128);
     }
     /* Parse out board URL */
     $topic['text'] = str_replace('{board_url}', $this->settings['base_url'], $topic['text']);
     IPSText::getTextClass('bbcode')->parse_smilies = 1;
     IPSText::getTextClass('bbcode')->parse_html = 1;
     IPSText::getTextClass('bbcode')->parse_nl2br = 1;
     IPSText::getTextClass('bbcode')->parse_bbcode = 1;
     IPSText::getTextClass('bbcode')->parsing_section = 'global';
     $topic['text'] = IPSText::getTextClass('bbcode')->preDisplayParse($topic['text']);
     if ($this->request['hl']) {
         $topic['text'] = IPSText::searchHighlight($topic['text'], $this->request['hl']);
         $topic['title'] = IPSText::searchHighlight($topic['title'], $this->request['hl']);
     }
     /* Output */
     $this->output .= $this->registry->output->getTemplate('help')->helpShowSection($this->lang->words['help_topic'], $this->lang->words['topic_text'], $topic['title'], $topic['text']);
     /* Navigation */
     $this->registry->output->setTitle($this->lang->words['help_topic'] . ': ' . $topic['title'] . ' - ' . ipsRegistry::$settings['board_name']);
     $this->registry->output->addNavigation($this->lang->words['help_topics'], "app=core&amp;module=help");
     $this->registry->output->addNavigation($this->lang->words['help_topic'], '');
     if ($this->request['xml'] == 1) {
         $classToLoad = IPSLib::loadLibrary(IPS_KERNEL_PATH . 'classAjax.php', 'classAjax');
         $classAjax = new $classToLoad();
         $classAjax->returnHtml($this->output);
     }
 }
 /**
  * Builds an array of post data for output
  *
  * @access	public
  * @param	array	$row	Array of post data
  * @return	array
  **/
 public function parsePostRow($row = array())
 {
     //-----------------------------------------
     // Memory Debug
     //-----------------------------------------
     $_NOW = IPSDebug::getMemoryDebugFlag();
     $poster = array();
     //-----------------------------------------
     // Cache member
     //-----------------------------------------
     if ($row['author_id'] != 0) {
         //-----------------------------------------
         // Is it in the hash?
         //-----------------------------------------
         if (isset($this->cached_members[$row['author_id']])) {
             //-----------------------------------------
             // Ok, it's already cached, read from it
             //-----------------------------------------
             $poster = $this->cached_members[$row['author_id']];
             $row['name_css'] = 'normalname';
         } else {
             $row['name_css'] = 'normalname';
             $poster = $row;
             if (isset($poster['cache_content_sig'])) {
                 $poster['cache_content'] = $poster['cache_content_sig'];
                 $poster['cache_updated'] = $poster['cache_updated_sig'];
                 /* Cache data monitor */
                 $this->_cacheMonitor['sig']['cached']++;
             } else {
                 unset($poster['cache_content'], $poster['cache_updated']);
                 /* Cache data monitor */
                 $this->_cacheMonitor['sig']['raw']++;
             }
             $poster = IPSMember::buildDisplayData($poster, array('signature' => 1, 'customFields' => 1, 'warn' => 1, 'avatar' => 1, 'checkFormat' => 1, 'cfLocation' => 'topic'));
             $poster['member_id'] = $row['mid'];
             //-----------------------------------------
             // Add it to the cached list
             //-----------------------------------------
             $this->cached_members[$row['author_id']] = $poster;
         }
     } else {
         //-----------------------------------------
         // It's definitely a guest...
         //-----------------------------------------
         $row['author_name'] = $this->settings['guest_name_pre'] . $row['author_name'] . $this->settings['guest_name_suf'];
         $poster = IPSMember::setUpGuest($row['author_name']);
         $poster['members_display_name'] = $row['author_name'];
         $poster['_members_display_name'] = $row['author_name'];
         $poster['custom_fields'] = "";
         $poster['warn_img'] = "";
         $row['name_css'] = 'unreg';
     }
     # Memory Debug
     IPSDebug::setMemoryDebugFlag("PID: " . $row['pid'] . " - Member Parsed", $_NOW);
     //-----------------------------------------
     // Queued
     //-----------------------------------------
     if ($this->topic['topic_firstpost'] == $row['pid'] and $this->topic['approved'] != 1) {
         $row['queued'] = 1;
     }
     //-----------------------------------------
     // Edit...
     //-----------------------------------------
     $row['edit_by'] = "";
     if ($row['append_edit'] == 1 and $row['edit_time'] != "" and $row['edit_name'] != "") {
         $e_time = $this->registry->class_localization->getDate($row['edit_time'], 'LONG');
         $row['edit_by'] = sprintf($this->lang->words['edited_by'], $row['edit_name'], $e_time);
     }
     //-----------------------------------------
     // Parse the post
     //-----------------------------------------
     if (!$row['cache_content']) {
         $_NOW2 = IPSDebug::getMemoryDebugFlag();
         IPSText::getTextClass('bbcode')->parse_smilies = $row['use_emo'];
         IPSText::getTextClass('bbcode')->parse_html = ($this->forum['use_html'] and $this->caches['group_cache'][$row['member_group_id']]['g_dohtml'] and $row['post_htmlstate']) ? 1 : 0;
         IPSText::getTextClass('bbcode')->parse_nl2br = $row['post_htmlstate'] == 2 ? 1 : 0;
         IPSText::getTextClass('bbcode')->parse_bbcode = $this->forum['use_ibc'];
         IPSText::getTextClass('bbcode')->parsing_section = 'topics';
         IPSText::getTextClass('bbcode')->parsing_mgroup = $row['member_group_id'];
         IPSText::getTextClass('bbcode')->parsing_mgroup_others = $row['mgroup_others'];
         /* Work around */
         $_tmp = $this->memberData['view_img'];
         $this->memberData['view_img'] = 1;
         $row['post'] = IPSText::getTextClass('bbcode')->preDisplayParse($row['post']);
         $this->memberData['view_img'] = $_tmp;
         IPSDebug::setMemoryDebugFlag("topics::parsePostRow - bbcode parse - Completed", $_NOW2);
         IPSContentCache::update($row['pid'], 'post', $row['post']);
         /* Cache data monitor */
         $this->_cacheMonitor['post']['raw']++;
     } else {
         $row['post'] = '<!--cached-' . gmdate('r', $row['cache_updated']) . '-->' . $row['cache_content'];
         /* Cache data monitor */
         $this->_cacheMonitor['post']['cached']++;
     }
     //-----------------------------------------
     // Capture content
     //-----------------------------------------
     if ($this->topic['topic_firstpost'] == $row['pid']) {
         $this->_firstPostContent = $row['post'];
     }
     //-----------------------------------------
     // View image...
     //-----------------------------------------
     $row['post'] = IPSText::getTextClass('bbcode')->memberViewImages($row['post']);
     //-----------------------------------------
     // Highlight...
     //-----------------------------------------
     if ($this->request['hl']) {
         $row['post'] = IPSText::searchHighlight($row['post'], $this->request['hl']);
     }
     //-----------------------------------------
     // Multi Quoting?
     //-----------------------------------------
     if ($this->qpids) {
         if (strstr(',' . $this->qpids . ',', ',' . $row['pid'] . ',')) {
             $row['_mq_selected'] = 1;
         }
     }
     //-----------------------------------------
     // Multi PIDS?
     //-----------------------------------------
     if ($this->memberData['is_mod']) {
         if ($this->request['selectedpids']) {
             if (strstr(',' . $this->request['selectedpids'] . ',', ',' . $row['pid'] . ',')) {
                 $row['_pid_selected'] = 1;
             }
             $this->request['selectedpidcount'] = count(explode(",", $this->request['selectedpids']));
         }
     }
     //-----------------------------------------
     // Delete button..
     //-----------------------------------------
     $row['_can_delete'] = $row['pid'] != $this->topic['topic_firstpost'] ? $this->_getDeleteButtonData($row) : FALSE;
     $row['_can_edit'] = $this->_getEditButtonData($row);
     $row['_show_ip'] = $this->_getIPAddressData();
     //-----------------------------------------
     // Siggie stuff
     //-----------------------------------------
     $row['signature'] = "";
     if (isset($poster['signature']) and $poster['signature'] and $this->memberData['view_sigs']) {
         if ($row['use_sig'] == 1) {
             $row['signature'] = $this->registry->output->getTemplate('global')->signature_separator($poster['signature']);
         }
     }
     //-----------------------------------------
     // Fix up the membername so it links to the members profile
     //-----------------------------------------
     if ($poster['member_id']) {
         $poster['_members_display_name'] = "<a href='{$this->settings['_base_url']}showuser={$poster['member_id']}'>{$poster['members_display_name_short']}</a>";
     }
     //-----------------------------------------
     // Post number
     //-----------------------------------------
     if ($this->topic_view_mode == 'linearplus' and $this->topic['topic_firstpost'] == $row['pid']) {
         $row['post_count'] = 1;
         if (!$this->first) {
             $this->post_count++;
         }
     } else {
         $this->post_count++;
         $row['post_count'] = intval($this->request['st']) + $this->post_count;
     }
     $row['forum_id'] = $this->topic['forum_id'];
     //-----------------------------------------
     // Memory Debug
     //-----------------------------------------
     IPSDebug::setMemoryDebugFlag("PID: " . $row['pid'] . " - Completed", $_NOW);
     return array('row' => $row, 'poster' => $poster);
 }
 /**
  * Show a single event based on eventid
  *
  * @access	public
  * @return	void
  */
 public function calendarShowEvent()
 {
     /* INIT */
     $event_id = intval($this->request['event_id']);
     /* Check */
     if (!$event_id) {
         $this->registry->output->showError('calendar_event_not_found', 10429);
     }
     /* Get it from the DB */
     $this->DB->build(array('select' => '*', 'from' => 'cal_events', 'where' => "event_id={$event_id}"));
     $this->DB->execute();
     if (!($event = $this->DB->fetch())) {
         $this->registry->output->showError('calendar_event_not_found', 10430);
     }
     $set_offset = 0;
     if ($event['event_timeset']) {
         $set_offset = ($this->memberData['member_id'] ? $this->memberData['time_offset'] : $this->settings['time_offset']) * 3600;
     }
     $event['event_unix_from'] = $event['event_unix_from'] + $set_offset;
     /* Is it a private event */
     if ($event['event_private'] == 1 and $this->memberData['member_id'] != $event['event_member_id']) {
         $this->registry->output->showError('calendar_event_not_found', 10431);
     }
     /* Do we have permission to see the event? */
     if ($event['event_perms'] != '*') {
         $this_member_mgroups[] = $this->memberData['member_group_id'];
         if ($this->memberData['mgroup_others']) {
             $this_member_mgroups = array_merge($this_member_mgroups, explode(",", IPSText::cleanPermString($this->memberData['mgroup_others'])));
         }
         $check = 0;
         foreach ($this_member_mgroups as $this_member_mgroup) {
             if (preg_match("/(^|,)" . $this_member_mgroup . "(,|\$)/", $event['event_perms'])) {
                 $check = 1;
             }
         }
         if ($check == 0) {
             $this->registry->output->showError('calendar_event_not_found', 10432);
         }
     }
     //-----------------------------------------
     // Highlight...
     //-----------------------------------------
     if ($this->request['hl']) {
         $event['event_content'] = IPSText::searchHighlight($event['event_content'], $this->request['hl']);
         $event['event_title'] = IPSText::searchHighlight($event['event_title'], $this->request['hl']);
     }
     /* Output */
     $this->output .= $this->registry->output->getTemplate('calendar')->calendarEventsList($this->calendarMakeEventHTML($event));
     /* Navigation */
     $this->registry->output->addNavigation($this->lang->words['page_title'], 'app=calendar&amp;module=calendar');
     $this->registry->output->addNavigation($this->calendar['cal_title'], 'app=calendar&amp;module=calendar&amp;cal_id=' . $this->calendar_id);
     $this->registry->output->addNavigation($event['event_title'], '');
 }
 /**
  * Builds an array of post data for output
  *
  * @param	array	$row	Array of post data
  * @return	array
  */
 public function parsePostRow($row = array())
 {
     /* Init */
     $topicData = $this->registry->getClass('topics')->getTopicData();
     $forumData = $this->forumClass->getForumById($topicData['forum_id']);
     $permissionData = $this->registry->getClass('topics')->getPermissionData();
     /* Parse post */
     $parsed = $this->registry->getClass('topics')->parsePost($row);
     if ($parsed['post']['_can_edit']) {
         $this->_canEditAPost = true;
     }
     /* Collect PIDS of soft deleted posts */
     if ($parsed['post']['_isDeleted'] and $parsed['post']['_softDeleteSee']) {
         $this->_sdPids[] = $parsed['post']['pid'];
     }
     /* Grab first post */
     if ($topicData['topic_firstpost'] == $parsed['post']['pid']) {
         $this->_firstPostContent = $parsed['post']['post'];
     } else {
         if ($this->request['page'] and !$this->_firstPostContent) {
             $this->_firstPostContent = $parsed['post']['post'];
         }
     }
     /* Anything to highlight? */
     if (isset($this->request['hl']) and $this->request['hl']) {
         $parsed['post']['post'] = IPSText::searchHighlight($parsed['post']['post'], $this->request['hl']);
     }
     /* Multi quote */
     if ($this->qpids) {
         if (strstr(',' . $this->qpids . ',', ',' . $parsed['post']['pid'] . ',')) {
             $parsed['post']['_mq_selected'] = 1;
         }
     }
     /* Mod PIDS */
     if ($this->memberData['is_mod']) {
         if ($this->request['selectedpids']) {
             if (strstr(',' . $this->request['selectedpids'] . ',', ',' . $parsed['post']['pid'] . ',')) {
                 $parsed['post']['_pid_selected'] = 1;
             }
             $this->request['selectedpidcount'] = count(explode(",", $this->request['selectedpids']));
         }
     }
     /* Post number */
     $this->post_count++;
     $parsed['post']['post_count'] = $this->request['page'] > 1 ? intval($this->request['page'] - 1) * $this->settings['display_max_posts'] + $this->post_count : $this->post_count;
     if ($parsed['post']['_isDeleted']) {
         $this->post_count--;
     }
     /* Post max date for item marking*/
     if ($row['post_date'] > $this->_maxPostDate) {
         $this->_maxPostDate = $row['post_date'];
     }
     return $parsed;
 }
Beispiel #8
0
 /**
  * Displays a topic preview
  *
  * @return	@e void
  */
 protected function _topicPreview()
 {
     /* INIT */
     $tid = intval($this->request['tid']);
     $pid = intval($this->request['pid']);
     $sTerm = trim($this->request['searchTerm']);
     $topic = array();
     $posts = array();
     $permissions = array();
     $query = '';
     /* Topic visibility */
     $_perms = array('visible');
     if ($this->registry->getClass('class_forums')->canSeeSoftDeletedTopics(false)) {
         $_perms[] = 'sdelete';
     }
     if ($this->registry->getClass('class_forums')->canQueuePosts(false)) {
         $_perms[] = 'hidden';
     }
     /* Grab topic data and first post */
     $topic = $this->DB->buildAndFetch(array('select' => '*, title as topic_title, posts as topic_posts, last_post as topic_last_post', 'from' => 'topics', 'where' => $this->registry->class_forums->fetchTopicHiddenQuery($_perms) . ' AND tid=' . $tid));
     if (!$topic['tid']) {
         return $this->returnString('no_topic');
     }
     /* Permission check */
     if ($this->registry->class_forums->forumsCheckAccess($topic['forum_id'], 0, 'topic', $topic, true) !== true) {
         return $this->returnString('no_permission');
     }
     /* is archived? */
     $isArchived = $this->registry->topics->isArchived($topic);
     /* Build permissions */
     $permissions['PostSoftDeleteSee'] = $this->registry->getClass('class_forums')->canSeeSoftDeletedPosts($topic['forum_id']);
     $permissions['SoftDeleteContent'] = $this->registry->getClass('class_forums')->canSeeSoftDeleteContent($topic['forum_id']);
     $permissions['TopicSoftDeleteSee'] = $this->registry->getClass('class_forums')->canSeeSoftDeletedTopics($topic['forum_id']);
     $permissions['canQueue'] = $this->registry->getClass('class_forums')->canQueuePosts($topic['forum_id']);
     /* Boring old boringness */
     if ($permissions['canQueue']) {
         if ($permissions['PostSoftDeleteSee']) {
             $query = $this->registry->class_forums->fetchPostHiddenQuery(array('visible', 'hidden', 'sdeleted'), $this->registry->topics->getPostTableField('_prefix_', $isArchived)) . ' AND ';
         } else {
             $query = $this->registry->class_forums->fetchPostHiddenQuery(array('visible', 'hidden'), $this->registry->topics->getPostTableField('_prefix_', $isArchived)) . ' AND ';
         }
     } else {
         if ($permissions['PostSoftDeleteSee']) {
             $query = $this->registry->class_forums->fetchPostHiddenQuery(array('visible', 'sdeleted'), $this->registry->topics->getPostTableField('_prefix_', $isArchived)) . ' AND ';
         } else {
             $query = $this->registry->class_forums->fetchPostHiddenQuery(array('visible'), $this->registry->topics->getPostTableField('_prefix_', $isArchived)) . ' AND ';
         }
     }
     /* Get first post */
     $_post = $this->registry->topics->getPosts(array('onlyViewable' => true, 'skipForumCheck' => true, 'sortField' => $this->settings['post_order_column'], 'sortOrder' => 'asc', 'topicId' => array($topic['tid']), 'limit' => 1, 'archiveToNative' => true, 'isArchivedTopic' => $this->registry->topics->isArchived($topic)));
     $posts['first'] = array_pop($_post);
     /* Archived? Get last post */
     if ($topic['topic_posts'] && $isArchived) {
         /* Get last post */
         $_post = $this->registry->topics->getPosts(array('onlyViewable' => true, 'skipForumCheck' => true, 'sortField' => $this->settings['post_order_column'], 'sortOrder' => 'desc', 'topicId' => array($topic['tid']), 'limit' => 1, 'archiveToNative' => true, 'isArchivedTopic' => $this->registry->topics->isArchived($topic)));
         $posts['last'] = array_pop($_post);
     } else {
         if ($topic['topic_posts'] && !$isArchived) {
             /* Grab number of unread posts? */
             $last_time = $this->registry->classItemMarking->fetchTimeLastMarked(array('forumID' => $topic['forum_id'], 'itemID' => $tid));
             if ($last_time and $last_time < $topic['topic_last_post']) {
                 $count = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as count, MAX(' . $this->registry->topics->getPostTableField($this->settings['post_order_column'], $isArchived) . ') as max, MIN(' . $this->settings['post_order_column'] . ') as min', 'from' => $this->registry->topics->getPostTableField('_table_', $isArchived), 'where' => $query . $this->registry->topics->getPostTableField('topic_id', $isArchived) . "={$tid} AND " . $this->registry->topics->getPostTableField('post_date', $isArchived) . " > " . intval($last_time)));
             } else {
                 $count = $this->DB->buildAndFetch(array('select' => 'MAX(' . $this->registry->topics->getPostTableField($this->settings['post_order_column'], $isArchived) . ') as max', 'from' => $this->registry->topics->getPostTableField('_table_', $isArchived), 'where' => $query . $this->registry->topics->getPostTableField('topic_id', $isArchived) . "={$tid}"));
                 $count['min'] = 0;
                 $count['count'] = 0;
             }
             $topic['_lastRead'] = $last_time;
             $topic['_unreadPosts'] = intval($count['count']);
             /* Got a max and min */
             if ($count['max']) {
                 $_posts = $this->registry->topics->getPosts(array('onlyViewable' => true, 'postId' => $this->settings['post_order_column'] == 'pid' ? array(intval($count['min']), intval($count['max'])) : array(), 'postDate' => $this->settings['post_order_column'] == 'post_date' ? array(intval($count['min']), intval($count['max'])) : array(), 'archiveToNative' => true, 'isArchivedTopic' => $this->registry->topics->isArchived($topic)));
                 foreach ($_posts as $pid => $r) {
                     $r['tid'] = $topic['tid'];
                     $r['title_seo'] = $topic['title_seo'];
                     if ($r[$this->settings['post_order_column']] == $count['max']) {
                         $posts['last'] = $r;
                     } else {
                         $posts['unread'] = $r;
                     }
                 }
             }
             if (is_array($posts['unread']) and is_array($posts['last'])) {
                 if ($posts['unread']['pid'] == $posts['last']['pid']) {
                     unset($posts['unread']);
                 } else {
                     if ($posts['unread']['pid'] == $posts['first']['pid']) {
                         unset($posts['unread']);
                     }
                 }
             }
         }
     }
     /* Search? */
     if ($pid and $sTerm) {
         $_posts = $this->registry->topics->getPosts(array('onlyViewable' => true, 'postId' => array($pid), 'archiveToNative' => true, 'isArchivedTopic' => $this->registry->topics->isArchived($topic)));
         $posts['search'] = array_pop($_posts);
     }
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/text/parser.php', 'classes_text_parser');
     $parser = new $classToLoad();
     /* Set up some settings */
     $parser->set(array('parseArea' => 'topics', 'memberData' => $this->memberData, 'parseBBCode' => $this->registry->class_forums->forum_by_id[$topic['forum_id']]['use_ibc'], 'parseHtml' => ($this->registry->class_forums->forum_by_id[$topic['forum_id']]['use_html'] and $this->caches['group_cache'][$data['member_group_id']]['g_dohtml'] and $data['post_htmlstate']) ? 1 : 0, 'parseEmoticons' => $data['use_emo']));
     /* Still here? */
     foreach ($posts as $k => $data) {
         $data = IPSMember::buildDisplayData($data);
         $data['post'] = $parser->stripQuotes($data['post']);
         $data['post'] = $parser->display($data['post']);
         /* Search term? */
         if ($k == 'search' and $pid and $sTerm) {
             $data['post'] = IPSText::truncateTextAroundPhrase(IPSText::getTextClass('bbcode')->stripAllTags(str_replace('<br />', ' ', strip_tags($data['post'], '<br>'))), $sTerm);
             $data['post'] = IPSText::searchHighlight($data['post'], $sTerm);
         } else {
             $data['post'] = IPSText::truncate(IPSText::getTextClass('bbcode')->stripAllTags(strip_tags($data['post'], '<br>')), 500);
         }
         $data['_isVisible'] = $this->registry->getClass('class_forums')->fetchHiddenType($data) == 'visible' ? true : false;
         $data['_isHidden'] = $this->registry->getClass('class_forums')->fetchHiddenType($data) == 'hidden' ? true : false;
         $data['_isDeleted'] = $this->registry->getClass('class_forums')->fetchHiddenType($data) == 'sdelete' ? true : false;
         $posts[$k] = $data;
     }
     $topic['_key'] = uniqid(microtime());
     return $this->returnHtml($this->registry->output->getTemplate('topic')->topicPreview($topic, $posts));
 }
 /**
  * Parse a common search result
  *
  * @access	private
  * @param	array 	$r				Search result
  * @param	string	$search_term	Keywords searched for
  * @param	bool	$isVnc			Is from view new content
  * @return	array 	$search_result	Search result for template
  */
 private function _parseSearchResult($r, $search_term = '', $isVnc = false)
 {
     /* Forum stuff */
     $sub = false;
     $r['_topic_array'] = $this->_topicArray;
     /* If basic search, strip the content */
     IPSText::getTextClass('bbcode')->parse_wordwrap = 0;
     IPSText::getTextClass('bbcode')->parse_bbcode = 0;
     IPSText::getTextClass('bbcode')->strip_quotes = 1;
     IPSText::getTextClass('bbcode')->parsing_section = 'topics';
     IPSText::getTextClass('bbcode')->parsing_mgroup = $r['member_group_id'];
     IPSText::getTextClass('bbcode')->parsing_mgroup_others = $r['mgroup_others'];
     $r['content'] = strip_tags(IPSText::getTextClass('bbcode')->stripAllTags($r['content']));
     $r['content'] = str_replace(array('&lt;br&gt;', '&lt;br /&gt;'), '', $r['content']);
     $r['content'] = trim(str_replace(array("\n\n\n", "\n\n"), "\n", str_replace("\r", '', $r['content'])));
     /* Highlight */
     $r['content'] = IPSText::searchHighlight($this->_searchTruncate($r['content'], $search_term), $search_term);
     $r['content_title'] = (!$this->search_plugin->onlyPosts and $this->_getShowAsForum() === false) ? IPSText::searchHighlight($r['content_title'], $search_term) : $r['content_title'];
     /* Check to see if the display plugin is loaded */
     if (!isset($this->search_plugin->display_plugins[$r['app']])) {
         $this->search_plugin->display_plugins[$r['app']] = IPSSearchIndex::getSearchDisplayPlugin($r['app']);
         $this->search_plugin->display_plugins[$r['app']]->search_plugin = $this->search_plugin;
     }
     /* Return the formatted result */
     if (isset($this->search_plugin->display_plugins[$r['app']]) && is_object($this->search_plugin->display_plugins[$r['app']])) {
         $return = $this->search_plugin->display_plugins[$r['app']]->formatContent($r, $isVnc);
         if (is_array($return)) {
             $html = $return[0];
             $sub = $return[1];
         } else {
             $html = $return;
         }
     } else {
         $html = $this->registry->output->getTemplate('search')->searchRowGenericFormat($r);
     }
     return array('html' => $html, 'app' => $r['app'], 'type' => $r['type'], 'sub' => $sub);
 }