]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/peopletag.php
generate an etag for shownotice
[quix0rs-gnu-social.git] / actions / peopletag.php
1 <?php
2 /*
3  * Laconica - a distributed open-source microblogging tool
4  * Copyright (C) 2008, Controlez-Vous, Inc.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Affero General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU Affero General Public License for more details.
15  *
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 if (!defined('LACONICA')) { exit(1); }
21
22 require_once(INSTALLDIR.'/lib/profilelist.php');
23
24 class PeopletagAction extends Action {
25         
26         function handle($args) {
27
28                 parent::handle($args);
29
30                 $tag = $this->trimmed('tag');
31                 
32                 if (!common_valid_profile_tag($tag)) {
33                         $this->client_error(sprintf(_('Not a valid people tag: %s'), $tag));
34                         return;
35                 }
36
37                 $page = $this->trimmed('page');
38                 
39                 if (!$page) {
40                         $page = 1;
41                 }
42                 
43                 # Looks like we're good; show the header
44
45                 common_show_header(sprintf(_('Users self-tagged with %s - page %d'), $tag, $page),
46                                                    NULL, $tag, array($this, 'show_top'));
47
48                 $this->show_people($tag, $page);
49
50                 common_show_footer();
51         }
52
53         function show_people($tag, $page) {
54                 
55                 $profile = new Profile();
56
57                 $offset = ($page-1)*PROFILES_PER_PAGE;
58                 $limit = PROFILES_PER_PAGE + 1;
59                 
60                 if (common_config('db','type') == 'pgsql') {
61                         $lim = ' LIMIT ' . $limit . ' OFFSET ' . $offset;
62                 } else {
63                         $lim = ' LIMIT ' . $offset . ', ' . $limit;
64                 }
65
66                 # XXX: memcached this
67                 
68                 $profile->query(sprintf('SELECT profile.* ' .
69                                                                 'FROM profile JOIN profile_tag ' .
70                                                                 'ON profile.id = profile_tag.tagger ' .
71                                                                 'WHERE profile_tag.tagger = profile_tag.tagged ' .
72                                                                 'AND tag = "%s" ' .
73                                                                 'ORDER BY profile_tag.modified DESC ' . 
74                                                                 $lim, $tag));
75
76                 $pl = new ProfileList($profile);
77                 $cnt = $pl->show_list();
78                 
79                 common_pagination($page > 1,
80                                                   $cnt > PROFILES_PER_PAGE,
81                                                   $page,
82                                                   $this->trimmed('action'),
83                                                   array('tag' => $tag));
84         }
85         
86         function show_top($tag) {
87                 $instr = sprintf(_('These are users who have tagged themselves "%s" ' .
88                                                    'to show a common interest, characteristic, hobby or job.'), $tag);
89                 common_element_start('div', 'instructions');
90                 common_element_start('p');
91                 common_text($instr);
92                 common_element_end('p');
93                 common_element_end('div');
94         }
95
96         function get_title() {
97                 return NULL;
98         }
99
100         function show_header($arr) {
101                 return;
102         }
103 }