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
27 function handle($args)
30 parent::handle($args);
32 $tag = $this->trimmed('tag');
34 if (!common_valid_profile_tag($tag)) {
35 $this->clientError(sprintf(_('Not a valid people tag: %s'), $tag));
39 $page = $this->trimmed('page');
45 # Looks like we're good; show the header
47 common_show_header(sprintf(_('Users self-tagged with %s - page %d'), $tag, $page),
48 null, $tag, array($this, 'show_top'));
50 $this->show_people($tag, $page);
55 function show_people($tag, $page)
58 $profile = new Profile();
60 $offset = ($page-1)*PROFILES_PER_PAGE;
61 $limit = PROFILES_PER_PAGE + 1;
63 if (common_config('db','type') == 'pgsql') {
64 $lim = ' LIMIT ' . $limit . ' OFFSET ' . $offset;
66 $lim = ' LIMIT ' . $offset . ', ' . $limit;
71 $profile->query(sprintf('SELECT profile.* ' .
72 'FROM profile JOIN profile_tag ' .
73 'ON profile.id = profile_tag.tagger ' .
74 'WHERE profile_tag.tagger = profile_tag.tagged ' .
76 'ORDER BY profile_tag.modified DESC ' .
79 $pl = new ProfileList($profile);
80 $cnt = $pl->show_list();
82 common_pagination($page > 1,
83 $cnt > PROFILES_PER_PAGE,
85 $this->trimmed('action'),
86 array('tag' => $tag));
89 function show_top($tag)
91 $instr = sprintf(_('These are users who have tagged themselves "%s" ' .
92 'to show a common interest, characteristic, hobby or job.'), $tag);
93 $this->elementStart('div', 'instructions');
94 $this->elementStart('p');
96 $this->elementEnd('p');
97 $this->elementEnd('div');
105 function show_header($arr)