3 * StatusNet, the distributed open-source microblogging tool
5 * People tags by a user
9 * LICENCE: This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
21 * You should have received a copy of the GNU Affero General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
26 * @author Evan Prodromou <evan@status.net>
27 * @author Zach Copley <zach@status.net>
28 * @author Shashi Gowda <connect2shashi@gmail.com>
29 * @copyright 2009 StatusNet, Inc.
30 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
31 * @link http://status.net/
34 if (!defined('STATUSNET') && !defined('LACONICA')) {
38 require_once INSTALLDIR.'/lib/peopletaglist.php';
40 define('PEOPLETAG_CACHE_WINDOW', PEOPLETAGS_PER_PAGE*3 + 1);
42 class PeopletagAction extends Action
47 function isReadOnly($args)
54 if ($this->page == 1) {
55 return sprintf(_("Public people tag %s"), $this->tag);
57 return sprintf(_("Public people tag %s, page %d"), $this->tag, $this->page);
61 function prepare($args)
63 parent::prepare($args);
64 $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
66 $tag_arg = $this->arg('tag');
67 $tag = common_canonical_tag($tag_arg);
69 // Permanent redirect on non-canonical nickname
71 if ($tag_arg != $tag) {
72 $args = array('tag' => $nickname);
73 if ($this->page && $this->page != 1) {
74 $args['page'] = $this->page;
76 common_redirect(common_local_url('peopletag', $args), 301);
84 function handle($args)
86 parent::handle($args);
90 function showLocalNav()
92 $nav = new PublicGroupNav($this);
96 function showAnonymousMessage()
99 _('People tags are how you sort similar ' .
100 'people on %%site.name%%, a [micro-blogging]' .
101 '(http://en.wikipedia.org/wiki/Micro-blogging) service ' .
102 'based on the Free Software [StatusNet](http://status.net/) tool. ' .
103 'You can then easily keep track of what they ' .
104 'are doing by subscribing to the tag\'s timeline.' );
105 $this->elementStart('div', array('id' => 'anon_notice'));
106 $this->raw(common_markup_to_html($notice));
107 $this->elementEnd('div');
110 function showContent()
112 $offset = ($this->page-1) * PEOPLETAGS_PER_PAGE;
113 $limit = PEOPLETAGS_PER_PAGE + 1;
115 $ptags = new Profile_list();
116 $ptags->tag = $this->tag;
118 $user = common_current_user();
121 $ckey = sprintf('profile_list:tag:%s', $this->tag);
122 $ptags->private = false;
123 $ptags->orderBy('profile_list.modified DESC');
125 $c = Cache::instance();
126 if ($offset+$limit <= PEOPLETAG_CACHE_WINDOW && !empty($c)) {
127 $cached_ptags = Profile_list::getCached($ckey, $offset, $limit);
128 if ($cached_ptags === false) {
129 $ptags->limit(0, PEOPLETAG_CACHE_WINDOW);
132 Profile_list::setCache($ckey, $ptags, $offset, $limit);
134 $ptags = clone($cached_ptags);
137 $ptags->limit($offset, $limit);
141 $ptags->whereAdd('(profile_list.private = false OR (' .
142 ' profile_list.tagger =' . $user->id .
143 ' AND profile_list.private = true) )');
145 $ptags->orderBy('profile_list.modified DESC');
149 $pl = new PeopletagList($ptags, $this);
152 $this->pagination($this->page > 1, $cnt > PEOPLETAGS_PER_PAGE,
153 $this->page, 'peopletag', array('tag' => $this->tag));
156 function showSections()