Example #1
0
 /**
  * Main class entry point
  *
  * @param	object		ipsRegistry reference
  * @return	@e void		[Outputs to screen]
  */
 public function doExecute(ipsRegistry $registry)
 {
     /* From App */
     $fromApp = trim($this->request['fromApp']);
     /* Init some data */
     require_once IPS_ROOT_PATH . 'sources/classes/comments/bootstrap.php';
     /*noLibHook*/
     $this->_comments = classes_comments_bootstrap::controller($fromApp);
     /* What to do? */
     switch ($this->request['do']) {
         case 'add':
             $this->_add();
             break;
         case 'delete':
             $this->_delete();
             break;
         case 'showEdit':
             $this->_showEdit();
             break;
         case 'saveEdit':
             $this->_saveEdit();
             break;
         case 'fetchReply':
             $this->_fetchReply();
             break;
         case 'moderate':
             $this->_moderate();
             break;
     }
 }
Example #2
0
 /**
  * Main class entry point
  *
  * @param	object		ipsRegistry reference
  * @return	@e void		[Outputs to screen]
  */
 public function doExecute(ipsRegistry $registry)
 {
     /* From App */
     $fromApp = trim($this->request['fromApp']);
     if (!$fromApp) {
         $this->registry->output->showError('noappcomments', 100135.8);
     }
     /* Init some data */
     try {
         require_once IPS_ROOT_PATH . 'sources/classes/comments/bootstrap.php';
         /*noLibHook*/
         $this->_comments = classes_comments_bootstrap::controller($fromApp);
     } catch (Exception $e) {
         $this->registry->output->showError('nocomment_found', '1-global-comments-noapp');
     }
     /* Some templates/files are still using comment_id too, so let's work around it.. */
     if (!empty($this->request['comment_id'])) {
         $this->request['commentId'] = $this->request['comment_id'];
     }
     /* What to do? */
     switch ($this->request['do']) {
         case 'add':
             $this->_add();
             break;
         case 'delete':
             $this->_delete();
             break;
         case 'approve':
             $this->_approve();
             break;
         case 'showEdit':
             $this->_showEdit();
             break;
         case 'saveEdit':
             $this->_saveEdit();
             break;
         case 'fetchReply':
             $this->_fetchReply();
             break;
         case 'moderate':
             $this->_moderate();
             break;
         case 'hide':
             $this->_hide();
             break;
         case 'unhide':
             $this->_unhide();
             break;
         case 'findLastComment':
             $this->_findLastComment();
             break;
         case 'findComment':
             $this->_findComment();
             break;
     }
 }
Example #3
0
 /**
  * Get Content URL
  *
  * @param	array		$warning		Row from members_warn_logs
  * @return	@e array	array( url => URL to the content the warning came from, title => Title )
  */
 public function getContentUrl($warning)
 {
     $exploded = explode('-', $warning['wl_content_id2']);
     require_once IPS_ROOT_PATH . 'sources/classes/comments/bootstrap.php';
     /*noLibHook*/
     $comments = classes_comments_bootstrap::controller($warning['wl_content_id1']);
     $parent = $comments->fetchParent($exploded[0]);
     if (is_null($parent)) {
         return NULL;
     } else {
         $parent = $comments->remapFromLocal($parent, 'parent');
         return array('url' => ipsRegistry::getClass('output')->buildUrl("app=core&module=global&section=comments&fromApp={$warning['wl_content_id1']}&do=findComment&parentId={$exploded[0]}&comment_id={$exploded[1]}"), 'title' => $parent['parent_title']);
     }
 }
Example #4
0
 /**
  * Get Content URL
  *
  * @param	array		$warning		Row from members_warn_logs
  * @return	@e array	array( url => URL to the content the warning came from, title => Title )
  */
 public function getContentUrl($warning)
 {
     ipsRegistry::getClass('class_localization')->loadLanguageFile(array('public_profile'), 'members');
     if ($warning['wl_content_id1'] == 'mreport') {
         $report = ipsRegistry::DB()->buildAndFetch(array('select' => '*', 'from' => 'rc_reports_index', 'where' => "id=" . intval($warning['wl_content_id2'])));
         if (!empty($report['id'])) {
             return array('url' => ipsRegistry::getClass('output')->buildUrl("app=core&module=reports&do=show_report&rid={$report['id']}"), 'title' => $report['title']);
         }
     } elseif ($warning['wl_content_id1'] == 'core-reports') {
         $exploded = explode('-', $warning['wl_content_id2']);
         require_once IPS_ROOT_PATH . 'sources/classes/comments/bootstrap.php';
         /*noLibHook*/
         $comments = classes_comments_bootstrap::controller($warning['wl_content_id1']);
         $parent = $comments->fetchParent($exploded[0]);
         if (!is_null($parent)) {
             $parent = $comments->remapFromLocal($parent, 'parent');
             return array('url' => ipsRegistry::getClass('output')->buildUrl("app=core&module=global&section=comments&fromApp={$warning['wl_content_id1']}&do=findComment&parentId={$exploded[0]}&comment_id={$exploded[1]}"), 'title' => $parent['parent_title']);
         }
     }
     return NULL;
 }
Example #5
0
 /**
  * Construct
  *
  * @param	string	Comment class key (app-section)
  * @param	mixed	Optional extra data to pass to init() method
  */
 public static function controller($app = null, $extraData = null)
 {
     if (strstr($app, '-')) {
         list($app, $key) = explode('-', $app);
     }
     $_file = IPSLib::getAppDir($app) . '/extensions/comments/' . $key . '.php';
     $_class = 'comments_' . $app . '_' . $key;
     if (is_file($_file)) {
         $classToLoad = IPSLib::loadLibrary($_file, $_class, $app);
         if (class_exists($classToLoad)) {
             self::$_app = new $classToLoad();
             self::$_app->init($extraData);
         } else {
             throw new Exception("No comment class available for {$app}");
         }
     } else {
         throw new Exception("No comment class available for {$app}");
     }
     /* Load up language file */
     $registry = ipsRegistry::instance();
     $registry->getClass('class_localization')->loadLanguageFile(array('public_comments', 'public_editors'), 'core');
     return self::$_app;
 }
Example #6
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);
 }
Example #7
0
 /**
  * Displays a report
  *
  * @return	@e void
  */
 public function _displayReport()
 {
     //-----------------------------------------
     // Lets make sure this report exists...
     //-----------------------------------------
     $rid = intval($this->request['rid']);
     $options = array('rid' => $rid);
     $reports = array();
     $comments = array();
     if (!$rid) {
         $this->registry->output->showError('reports_no_rid', 10137);
     }
     $this->registry->class_localization->loadLanguageFile(array('public_editors'));
     $report_index = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'rc_reports_index', 'where' => "id=" . $rid));
     //-----------------------------------------
     // Basic title and nav routine..
     //-----------------------------------------
     $this->registry->output->addNavigation($this->lang->words['main_title'], 'app=core&amp;module=reports&amp;do=index');
     $this->registry->output->addNavigation($report_index['title'], '');
     if (!$report_index['id']) {
         $this->registry->output->showError('reports_no_rid', 10138);
     }
     $COM_PERM = $this->registry->getClass('reportLibrary')->buildQueryPermissions();
     /* Load parser */
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/text/parser.php', 'classes_text_parser');
     $parser = new $classToLoad();
     //-----------------------------------------
     // Get reports
     //-----------------------------------------
     $this->DB->buildFromCache('grab_report', array('COM' => $COM_PERM, 'rid' => $rid), 'report_sql_queries');
     $outer = $this->DB->execute();
     while ($row = $this->DB->fetch($outer)) {
         $row['points'] = isset($row['points']) ? $row['points'] : $this->settings['_tmpPoints'][$row['id']];
         if (!$options['url'] && $row['url']) {
             $options['url'] = $this->registry->getClass('reportLibrary')->processUrl($row['url'], $row['seoname'], $row['seotemplate']);
         }
         if (!$options['class'] && $row['my_class']) {
             $options['class'] = $row['my_class'];
         }
         if ($row['my_class'] == 'messages' && !$options['topicID'] && $row['exdat1']) {
             $options['topicID'] = intval($row['exdat1']);
         }
         $options['title'] = $row['title'];
         $options['status_id'] = $row['status'];
         if (!$options['status_icon']) {
             $options['status_icon'] = $this->registry->getClass('reportLibrary')->buildStatusIcon($row);
             $options['status_text'] = $this->registry->getClass('reportLibrary')->flag_cache[$row['status']][$row['points']]['title'];
         }
         /* Stupid stupid stupidness */
         $row['_title'] = $row['title'];
         $row['title'] = $row['member_title'];
         if ($row['member_id']) {
             $row['author'] = IPSMember::buildDisplayData($row);
         } else {
             $row['author'] = IPSMember::buildDisplayData(IPSMember::setUpGuest(''));
         }
         $row['title'] = $row['_title'];
         /* Set up some settings */
         $parser->set(array('parseArea' => 'reports', 'memberData' => $row['author'], 'parseBBCode' => true, 'parseHtml' => false, 'parseEmoticons' => true));
         $row['report'] = $parser->display($row['report']);
         $reports[] = $row;
     }
     if (!$options['class']) {
         $this->registry->output->showError('reports_no_rid', 10138);
     }
     $_tmp = $this->registry->getClass('reportLibrary')->flag_cache;
     // Manually build array get just the statuses, not severities
     foreach ($_tmp as $sid => $sta) {
         if (is_array($sta) && count($sta)) {
             foreach ($sta as $points => $info) {
                 if ($options['statuses'][$sid]) {
                     break;
                 }
                 $options['statuses'][$sid] = $info;
             }
         }
     }
     //-----------------------------------------
     // Get comments
     //-----------------------------------------
     require_once IPS_ROOT_PATH . 'sources/classes/comments/bootstrap.php';
     /*noLibHook*/
     $this->_comments = classes_comments_bootstrap::controller('core-reports');
     $comments = array('html' => $this->_comments->fetchFormatted($report_index, array('offset' => intval($this->request['st']))), 'count' => $this->_comments->count($report_index));
     //-----------------------------------------
     // Mark as read
     //-----------------------------------------
     $this->registry->classItemMarking->markRead(array('forumID' => 0, 'itemID' => $rid), 'core');
     //-----------------------------------------
     // And output
     //-----------------------------------------
     $this->output .= $this->registry->getClass('output')->getTemplate('reports')->viewReport($options, $reports, $comments);
 }