Overview

Packages

  • Agora
  • None

Classes

  • Agora_Application
  • Agora_Block_Forums
  • Agora_Block_Thread
  • Agora_Block_Threads
  • Agora_Tree_Flat
  • Agora_ViewComments

Functions

  • handle_avatarselect
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Proved an API to include any single Agora forum thread into any other
 4:  * Horde app through a block.
 5:  *
 6:  * Copyright 2003-2012 Horde LLC (http://www.horde.org/)
 7:  *
 8:  * See the enclosed file COPYING for license information (GPL). If you
 9:  * did not receive this file, see http://www.horde.org/licenses/gpl.
10:  *
11:  * @author  Marko Djukic <marko@oblo.com>
12:  */
13: class Agora_Block_Thread extends Horde_Core_Block
14: {
15:     /**
16:      */
17:     public function __construct($app, $params = array())
18:     {
19:         parent::__construct($app, $params);
20: 
21:         $this->_name = _("Single Thread");
22:     }
23: 
24:     /**
25:      */
26:     protected function _params()
27:     {
28:         $forumOb = $GLOBALS['injector']->getInstance('Agora_Factory_Driver')->create();
29:         $forums_list = $forumOb->getForums(0, true, 'forum_name', 0, true);
30: 
31:         $threads = array(
32:             'name'   => _("Thread"),
33:             'type'   => 'mlenum',
34:             'values' => array()
35:         );
36: 
37:         foreach ($forums_list as $forum) {
38:             $threadsOb = $GLOBALS['injector']->getInstance('Agora_Factory_Driver')->create('agora', $forum['forum_id']);
39:             $threads_list = $threadsOb->getThreads();
40:             foreach ($threads_list as $thread) {
41:                 if (!isset($threads['default'])) {
42:                     $threads['default'] = $forum['forum_id'] . '.' . $thread['message_id'];
43:                 }
44:                 $threads['values'][$forum['indent'] . $forum['forum_name']][$forum['forum_id'] . '.' . $thread['message_id']] = $thread['message_subject'];
45:             }
46:         }
47: 
48:         return array('thread_id' => $threads);
49:     }
50: 
51:     /**
52:      */
53:     protected function _content()
54:     {
55:         /* Return empty if we don't have a thread set. */
56:         if (empty($this->_params['thread_id'])) {
57:             return '';
58:         }
59: 
60:         /* Set up the message object. */
61:         list($forum_id, $message_id) = explode('.', $this->_params['thread_id']);
62:         $messages = $GLOBALS['injector']->getInstance('Agora_Factory_Driver')->create('agora', $forum_id);
63: 
64:         /* Check if valid thread, otherwise show forum list. */
65:         if ($messages instanceof PEAR_Error || empty($messages)) {
66:             throw new Horde_Exception(_("Unable to fetch selected thread."));
67:         }
68: 
69:         /* Get the sorting. */
70:         $sort_by = Agora::getSortBy('threads');
71:         $sort_dir = Agora::getSortDir('threads');
72:         $view_bodies = $GLOBALS['prefs']->getValue('thread_view_bodies');
73: 
74:         /* Get the message array and the sorted thread list. */
75:         $threads_list = $messages->getThreads($messages->getThreadRoot($message_id), true, $sort_by, $sort_dir, $view_bodies, Horde::selfUrl());
76: 
77:         /* Set up the column headers. */
78:         $col_headers = array(array('message_thread' => _("Thread"), 'message_subject' => _("Subject")), 'message_author' => _("Posted by"), 'message_timestamp' => _("Date"));
79:         $col_headers = Agora::formatColumnHeaders($col_headers, $sort_by, $sort_dir, 'threads');
80: 
81:         /* Set up the template tags. */
82:         $view = new Agora_View();
83:         $view->col_headers = $col_headers;
84:         $view->threads_list = $threads_list;
85:         $view->threads_list_header = _("Thread List");
86:         $view->thread_view_bodies = $view_bodies;
87: 
88:         return $view->render('block/thread');
89:     }
90: 
91: }
92: 
API documentation generated by ApiGen