/** */ protected function _content() { /* Return empty if we don't have a thread set. */ if (empty($this->_params['thread_id'])) { return ''; } /* Set up the message object. */ list($forum_id, $message_id) = explode('.', $this->_params['thread_id']); $messages = $GLOBALS['injector']->getInstance('Agora_Factory_Driver')->create('agora', $forum_id); /* Check if valid thread, otherwise show forum list. */ if ($messages instanceof PEAR_Error || empty($messages)) { throw new Horde_Exception(_("Unable to fetch selected thread.")); } /* Get the sorting. */ $sort_by = Agora::getSortBy('threads'); $sort_dir = Agora::getSortDir('threads'); $view_bodies = $GLOBALS['prefs']->getValue('thread_view_bodies'); /* Get the message array and the sorted thread list. */ $threads_list = $messages->getThreads($messages->getThreadRoot($message_id), true, $sort_by, $sort_dir, $view_bodies, Horde::selfUrl()); /* Set up the column headers. */ $col_headers = array(array('message_thread' => _("Thread"), 'message_subject' => _("Subject")), 'message_author' => _("Posted by"), 'message_timestamp' => _("Date")); $col_headers = Agora::formatColumnHeaders($col_headers, $sort_by, $sort_dir, 'threads'); /* Set up the template tags. */ $view = new Agora_View(); $view->col_headers = $col_headers; $view->threads_list = $threads_list; $view->threads_list_header = _("Thread List"); $view->thread_view_bodies = $view_bodies; return $view->render('block/thread'); }
/** */ protected function _content() { if (!isset($this->_params['forum_id'])) { throw new Horde_Exception(_("No forum selected")); } if (empty($this->_threads)) { $this->_threads = $GLOBALS['injector']->getInstance('Agora_Factory_Driver')->create('agora', $this->_params['forum_id']); if ($this->_threads instanceof PEAR_Error) { throw new Horde_Exception(_("Unable to fetch threads for selected forum.")); } } /* Get the sorting. */ $sort_by = Agora::getSortBy('threads'); $sort_dir = Agora::getSortDir('threads'); /* Get a list of threads and display only the most recent if * preference is set. */ $threads_list = $this->_threads->getThreads(0, false, $sort_by, $sort_dir, false, Horde::selfUrl(), null, 0, !empty($this->_params['thread_display']) ? $this->_params['thread_display'] : null); /* Show a message if no available threads. Don't raise an error * as it is not an error to have no threads. */ if (empty($threads_list)) { return _("No available threads."); } /* Set up the column headers. */ $col_headers = array('message_subject' => _("Subject"), 'message_author' => _("Posted by"), 'message_timestamp' => _("Date")); $col_headers = Agora::formatColumnHeaders($col_headers, $sort_by, $sort_dir, 'threads'); /* Set up the template tags. */ $view = new Agora_View(); $view->col_headers = $col_headers; $view->threads = $threads_list; return $view->render('block/threads'); }
/** */ protected function _content() { global $registry; /* Set up the forums object. */ $forums = array($GLOBALS['injector']->getInstance('Agora_Factory_Driver')->create()); if ($GLOBALS['registry']->isAdmin()) { foreach ($registry->listApps(array('hidden', 'notoolbar', 'active')) as $scope) { if ($registry->hasMethod('hasComments', $scope) && $registry->callByPackage($scope, 'hasComments') === true) { $forums[] = $GLOBALS['injector']->getInstance('Agora_Factory_Driver')->create($scope); } } } /* Get the sorting. */ $sort_by = Agora::getSortBy('forums'); $sort_dir = Agora::getSortDir('forums'); /* Get the list of forums. */ $forums_list = array(); foreach ($forums as $forum) { try { $scope_forums = $forum->getForums(0, true, $sort_by, $sort_dir, true); $forums_list = array_merge($forums_list, $scope_forums); } catch (Agora_Exception $e) { return $e->getMessage(); /* Catch NotFound exception here so it won't break the cycle. */ } catch (Horde_Exception_NotFound $e) { } } /* Show a message if no available forums. Don't raise an error * as it is not an error to have no forums. */ if (empty($forums_list)) { return _("There are no forums."); } /* Display only the most recent threads if preference set. */ if (!empty($this->_params['forum_display'])) { $forums_list = array_slice($forums_list, 0, $this->_params['forum_display']); } /* Set up the column headers. */ $col_headers = array('forum_name' => _("Forum"), 'message_count' => _("Posts"), 'message_subject' => _("Last Post"), 'message_author' => _("Posted by"), 'message_timestamp' => _("Date")); $col_headers = Agora::formatColumnHeaders($col_headers, $sort_by, $sort_dir, 'forums'); /* Set up the template tags. */ $view = new Agora_View(); $view->col_headers = $col_headers; $view->forums_list = $forums_list; return $view->render('block/forums'); }
Horde_Registry::appInit('agora'); /* Set up the forums object. */ $scope = Horde_Util::getGet('scope', 'agora'); $forums = $injector->getInstance('Agora_Factory_Driver')->create($scope); /* Set up actions */ if ($registry->isAdmin()) { $url = Horde::url('forums.php'); foreach ($registry->listApps(array('hidden', 'notoolbar', 'active')) as $app) { if ($registry->hasMethod('hasComments', $app) && $registry->callByPackage($app, 'hasComments') === true) { $app_name = $registry->get('name', $app); $actions[] = Horde::link($url->add('scope', $app), $app_name) . $app_name . '</a>'; } } } /* Get the sorting. */ $sort_by = Agora::getSortBy('forums'); $sort_dir = Agora::getSortDir('forums'); /* Which forums page are we on? Default to page 0. */ $forum_page = Horde_Util::getFormData('forum_page', 0); $forums_per_page = $prefs->getValue('forums_per_page'); $forum_start = $forum_page * $forums_per_page; /* Get the list of forums. */ try { $forums_list = $forums->getForums(0, true, $sort_by, $sort_dir, true, $forum_start, $forums_per_page); $forums_count = $forums->countForums(); } catch (Horde_Exception_NotFound $e) { $forums_count = 0; } /* Set up the column headers. */ $col_headers = array('forum_name' => _("Forum"), 'forum_description' => _("Description"), 'message_count' => _("Posts"), 'thread_count' => _("Threads"), 'message_timestamp' => _("Last Post"), 'message_author' => _("Posted by"), 'message_date' => _("Date")); $col_headers = Agora::formatColumnHeaders($col_headers, $sort_by, $sort_dir, 'forums');
* Copyright 2003-2015 Horde LLC (http://www.horde.org/) * * See the enclosed file COPYING for license information (GPL). If you * did not receive this file, see http://www.horde.org/licenses/gpl. */ require_once __DIR__ . '/lib/Application.php'; Horde_Registry::appInit('agora'); /* Set up the messages object. */ $scope = Horde_Util::getGet('scope', 'agora'); $messages = $injector->getInstance('Agora_Factory_Driver')->create($scope); /* Which page are we on? Default to page 0. */ $messages_page = Horde_Util::getFormData('page', 0); $messages_per_page = $prefs->getValue('threads_per_page'); $messages_start = $messages_page * $messages_per_page; /* Get the sorting. */ $sort_by = Agora::getSortBy('moderate'); $sort_dir = Agora::getSortDir('moderate'); /* Check for any actions. */ switch (Horde_Util::getFormData('action')) { case _("Approve"): $message_ids = Horde_Util::getFormData('message_ids'); $messages->moderate('approve', $message_ids); $notification->push(sprintf(_("%d messages was approved."), count($message_ids)), 'horde.success'); break; case _("Delete"): $message_ids = Horde_Util::getFormData('message_ids'); $messages->moderate('delete', $message_ids); $notification->push(sprintf(_("%d messages was deleted."), count($message_ids)), 'horde.success'); break; } /* Get a list of messages still to moderate. Error will occur if you don't have the right permissions */
* The Agora script to display a list of forums. * * Copyright 2003-2015 Horde LLC (http://www.horde.org/) * * See the enclosed file COPYING for license information (GPL). If you * did not receive this file, see http://www.horde.org/licenses/gpl. * * @author Duck <*****@*****.**> */ require_once __DIR__ . '/lib/Application.php'; Horde_Registry::appInit('agora'); /* Default to agora and current user if is not an admin. */ $scope = Horde_Util::getGet('scope', 'agora'); $owner = $registry->isAdmin() ? Horde_Util::getGet('owner', $registry->getAuth()) : $registry->getAuth(); /* Get the sorting. */ $sort_by = Agora::getSortBy('threads'); $sort_dir = Agora::getSortDir('threads'); $page_output->header(); $notification->notify(array('listeners' => 'status')); echo '<h1>' . sprintf(_("Last posts in forums owned by %s"), $owner) . '</h1>'; foreach ($registry->listApps() as $scope) { if ($scope == 'agora' || $registry->hasMethod('hasComments', $scope) && $registry->callByPackage($scope, 'hasComments') === true) { $scope_name = $registry->get('name', $scope); $forums = $injector->getInstance('Agora_Factory_Driver')->create($scope); $threads = $forums->getThreadsByForumOwner($owner, 0, false, $sort_by, $sort_dir, false, 0, 5); echo '<h1 class="header">' . $scope_name . '</h1>'; if ($threads instanceof PEAR_Error) { echo $threads->getMessage(); } elseif (empty($threads)) { echo _("No threads"); } else {
Horde::url('forums.php', true)->redirect(); } /* Get requested message, if fail then back to forums list. */ $message = $messages->getMessage($message_id); if ($message instanceof PEAR_Error) { $notification->push(sprintf(_("Could not open the message. %s"), $message->getMessage()), 'horde.warning'); Horde::url('forums.php', true)->redirect(); } /* Check if we must show bodies */ if (($view_bodies = Horde_Util::getGet('bodies')) !== null) { $prefs->setValue('thread_view_bodies', $view_bodies); } else { $view_bodies = $prefs->getValue('thread_view_bodies'); } /* Get view settings. */ $sort_by = $view_bodies == 1 ? 'message_thread' : Agora::getSortBy('thread'); $sort_dir = Agora::getSortDir('thread'); $forum = $messages->getForum(); $title = $forum['forum_name'] . ' :: ' . $message['message_subject']; $thread_page = Horde_Util::getFormData('thread_page'); /* Count = replies + opening thread */ $thread_count = $messages->countThreads($message['message_thread']); if ($thread_count instanceof PEAR_Error) { $notification->push(sprintf(_("Could not open the message. %s"), $thread_count->getMessage()), 'horde.warning'); $thread_count = 0; } else { $thread_count++; } /* Log thread views. */ $seen = $messages->logView($message['message_thread']); /* Set thread page views */
/** * Returns all threads of a forum in a threaded view. * * @param string $forum_name The unique name for the forum. * @param boolean $bodies Whether to include message bodies in the view. * @param string $scope The application that the specified forum belongs to. * @param string $base_url An alternate link where edit/delete/reply links * point to. * @param string $template_file Template file to use. * * @return string The HTML code of the thread view. */ public static function render($forum_name, $scope = 'agora', $base_url = null, $template_file = false) { $forums = $GLOBALS['injector']->getInstance('Agora_Factory_Driver')->create($scope); $forum_id = $forums->getForumId($forum_name); if ($forum_id === null) { return ''; } $messages = $GLOBALS['injector']->getInstance('Agora_Factory_Driver')->create($scope, $forum_id); if ($messages instanceof PEAR_Error) { return $messages->getMessage(); } if (($view_bodies = Horde_Util::getPost('bodies')) !== null) { $GLOBALS['prefs']->setValue('comments_view_bodies', $view_bodies); } else { $view_bodies = $GLOBALS['prefs']->getValue('comments_view_bodies'); } if ($messages->_forum['message_count'] == 0) { return ''; } $sort_by = Agora::getSortBy('comments'); $sort_dir = Agora::getSortDir('comments'); $html = '<div class="header">' . _("Comments") . ' (' . $messages->_forum['message_count'] . ')' . ' '; if (!$GLOBALS['prefs']->isLocked('comments_view_bodies')) { $rss = Horde::url('rss/threads.php', true, -1)->add(array('scope' => $scope, 'forum_id' => $forum_id)); $html .= '<span style="font-size: 0.8em;">'; $html .= '<form action=' . urldecode($base_url) . ' method="post" name="sorter" style="display: inline;">'; $html .= _("View") . ' <select name="bodies" onchange="document.sorter.submit()" >'; $html .= '<option value="2">' . _("Flat") . '</option>'; $html .= '<option value="1" ' . ($view_bodies == 1 ? 'selected="selected"' : '') . '>' . _("Thread") . '</option>'; $html .= '</select>'; if ($view_bodies != '1') { $html .= ' ' . _("Sort by") . ' '; $html .= '<select name="comments_sortby" onchange="document.sorter.submit()" >'; $html .= '<option value="message_timestamp" ' . ($sort_by == 'message_timestamp' ? 'selected="selected"' : '') . '>' . _("Date") . '</option>'; $html .= '<option value="message_author" ' . ($sort_by == 'message_author' ? 'selected="selected"' : '') . '>' . _("Author") . '</option>'; $html .= '<option value="message_subject" ' . ($sort_by == 'message_subject' ? 'selected="selected"' : '') . '>' . _("Subject") . '</option>'; $html .= '</select>'; $html .= ' ' . _("Sort direction") . ' '; $html .= '<select name="comments_sortdir" onchange="document.sorter.submit()" >'; $html .= '<option value="0">' . _("Ascending") . '</option>'; $html .= '<option value="1" ' . ($sort_dir == 1 ? 'selected="selected"' : '') . '>' . _("Descending") . '</option>'; $html .= '</select>'; } $html .= '<link rel="alternate" title="' . _("Threads") . '" href="' . $rss . '" type="application/rss+xml" />'; $html .= ' <a href="' . $rss . '" />RSS</a> '; $html .= '</form></span>'; } $html .= '</div>'; $col_headers = array('message_thread' => _("Subject"), 'message_thread_class_plain' => 'msgThreadPlain', 'message_author' => _("Posted by"), 'message_author_class_plain' => 'msgAuthorPlain', 'message_timestamp' => _("Date"), 'message_timestamp_class_plain' => 'msgTimestampPlain'); if ($view_bodies == 1) { $threads = $messages->getThreads(0, true, 'message_thread', 0, true, '', $base_url); $html .= $messages->getThreadsUi($threads, $col_headers, true, $template_file); } else { $thread_page = Horde_Util::getFormData('comments_page', 0); $thread_per_page = $GLOBALS['prefs']->getValue('comments_per_page'); $thread_start = $thread_page * $thread_per_page; if (empty($template_file)) { $template_file = 'messages/flat'; } if ($messages->_forum['message_count'] > $thread_per_page && $view_bodies == 2) { $vars = new Horde_Variables(array('comments_page' => $thread_page)); $pager_ob = new Horde_Core_Ui_Pager('comments_page', $vars, array('num' => $messages->_forum['message_count'], 'url' => $base_url, 'perpage' => $thread_per_page)); $pager_html = $pager_ob->render(); } else { $pager_html = ''; } $threads_list = $messages->getThreads(0, true, $sort_by, $sort_dir, 1, '', $base_url, $thread_start, $thread_per_page); if ($threads_list instanceof PEAR_Error) { $html .= $threads_list->getDebugInfo(); } else { $html .= $pager_html . $messages->getThreadsUi($threads_list, $col_headers, true, $template_file) . $pager_html; } } return $html; }