]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/conversation.php
Merge branch '0.7.x' into 0.8.x
[quix0rs-gnu-social.git] / actions / conversation.php
1 <?php
2 /**
3  * Display a conversation in the browser
4  *
5  * PHP version 5
6  *
7  * @category Action
8  * @package  Laconica
9  * @author   Evan Prodromou <evan@controlyourself.ca>
10  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
11  * @link     http://laconi.ca/
12  *
13  * Laconica - a distributed open-source microblogging tool
14  * Copyright (C) 2008, Controlez-Vous, Inc.
15  *
16  * This program is free software: you can redistribute it and/or modify
17  * it under the terms of the GNU Affero General Public License as published by
18  * the Free Software Foundation, either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU Affero General Public License for more details.
25  *
26  * You should have received a copy of the GNU Affero General Public License
27  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
28  */
29
30 if (!defined('LACONICA')) {
31     exit(1);
32 }
33
34 require_once(INSTALLDIR.'/lib/noticelist.php');
35
36 /**
37  * Conversation tree in the browser
38  *
39  * @category Action
40  * @package  Laconica
41  * @author   Evan Prodromou <evan@controlyourself.ca>
42  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
43  * @link     http://laconi.ca/
44  */
45 class ConversationAction extends Action
46 {
47     var $id = null;
48     var $page = null;
49
50     /**
51      * Initialization.
52      *
53      * @param array $args Web and URL arguments
54      *
55      * @return boolean false if id not passed in
56      */
57
58     function prepare($args)
59     {
60         parent::prepare($args);
61         $this->id = $this->trimmed('id');
62         if (empty($this->id)) {
63             return false;
64         }
65         $this->page = $this->trimmed('page');
66         if (empty($this->page)) {
67             $this->page = 1;
68         }
69         return true;
70     }
71
72     function handle($args)
73     {
74         parent::handle($args);
75         $this->showPage();
76     }
77
78     function title()
79     {
80         return _("Conversation");
81     }
82
83     function showContent()
84     {
85         // FIXME this needs to be a tree, not a list
86
87         $qry = 'SELECT * FROM notice WHERE conversation = %s ';
88
89         $offset = ($this->page-1)*NOTICES_PER_PAGE;
90         $limit  = NOTICES_PER_PAGE + 1;
91
92         $txt = sprintf($qry, $this->id);
93
94         $notices = Notice::getStream($txt,
95                                      'notice:conversation:'.$this->id,
96                                      $offset, $limit);
97
98         $nl = new NoticeList($notices, $this);
99
100         $cnt = $nl->show();
101
102         $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
103                           $this->page, 'conversation', array('id' => $this->id));
104     }
105
106 }
107