3 * Laconica - a distributed open-source microblogging tool
4 * Copyright (C) 2008, Controlez-Vous, Inc.
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.
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.
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/>.
20 if (!defined('LACONICA')) { exit(1); }
22 require_once(INSTALLDIR.'/lib/profilelist.php');
24 class PeopletagAction extends Action {
26 function handle($args) {
28 parent::handle($args);
30 $tag = $this->trimmed('tag');
32 if (!common_valid_profile_tag($tag)) {
33 $this->client_error(sprintf(_('Not a valid people tag: %s'), $tag));
37 $page = $this->trimmed('page');
43 # Looks like we're good; show the header
45 common_show_header(sprintf(_('Users self-tagged with %s - page %d'), $tag, $page),
46 NULL, $tag, array($this, 'show_top'));
48 $this->show_people($tag, $page);
53 function show_people($tag, $page) {
55 $profile = new Profile();
57 $offset = ($page-1)*PROFILES_PER_PAGE;
58 $limit = PROFILES_PER_PAGE + 1;
60 if (common_config('db','type') == 'pgsql') {
61 $lim = ' LIMIT ' . $limit . ' OFFSET ' . $offset;
63 $lim = ' LIMIT ' . $offset . ', ' . $limit;
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 ' .
73 'ORDER BY profile_tag.modified DESC ' .
76 $pl = new ProfileList($profile);
77 $cnt = $pl->show_list();
79 common_pagination($page > 1,
80 $cnt > PROFILES_PER_PAGE,
82 $this->trimmed('action'),
83 array('tag' => $tag));
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');
92 common_element_end('p');
93 common_element_end('div');
96 function get_title() {
100 function show_header($arr) {