]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - classes/Notice_tag.php
replace all tabs with four spaces
[quix0rs-gnu-social.git] / classes / Notice_tag.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 require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
21
22 class Notice_tag extends Memcached_DataObject 
23 {
24     ###START_AUTOCODE
25     /* the code below is auto generated do not remove the above tag */
26
27     public $__table = 'notice_tag';                      // table name
28     public $tag;                             // varchar(64)  primary_key not_null
29     public $notice_id;                       // int(4)  primary_key not_null
30     public $created;                         // datetime()   not_null
31
32     /* Static get */
33     function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Notice_tag',$k,$v); }
34
35     /* the code above is auto generated do not remove the tag below */
36     ###END_AUTOCODE
37     
38     static function getStream($tag, $offset=0, $limit=20) {
39         $qry = 
40           'SELECT notice.* ' .
41           'FROM notice JOIN notice_tag ON notice.id = notice_tag.notice_id ' .
42           'WHERE notice_tag.tag = "%s" ';
43
44         return Notice::getStream(sprintf($qry, $tag),
45                                  'notice_tag:notice_stream:' . common_keyize($tag),
46                                  $offset, $limit);
47     }
48     
49     function blowCache() {
50         $cache = common_memcache();
51         if ($cache) {
52             $cache->delete(common_cache_key('notice_tag:notice_stream:' . $this->tag));
53         }
54     }
55 }