3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2008, 2009, 2010 StatusNet, 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('STATUSNET')) { exit(1); }
22 class Status_network_tag extends Safe_DataObject
25 /* the code below is auto generated do not remove the above tag */
27 public $__table = 'status_network_tag'; // table name
28 public $site_id; // int(4) primary_key not_null
29 public $tag; // varchar(64) primary_key not_null
30 public $created; // datetime() not_null
33 function __construct()
36 global $_DB_DATAOBJECT;
38 $sn = new Status_network();
41 $config['db']['table_'. $this->__table] = $sn->_database;
47 function staticGet($k,$v=null)
49 $i = DB_DataObject::staticGet('Status_network_tag',$k,$v);
51 // Don't use local process cache; if we're fetching multiple
52 // times it's because we're reloading it in a long-running
53 // process; we need a fresh copy!
54 global $_DB_DATAOBJECT;
55 unset($_DB_DATAOBJECT['CACHE']['status_network_tag']);
59 /* the code above is auto generated do not remove the tag below */
65 return Memcached_DataObject::pkeyGet('Status_network_tag', $kv);
69 * Fetch the (possibly cached) tag entries for the given site id.
70 * Uses status_network's cache settings.
72 * @param string $site_id
73 * @return array of strings
75 static function getTags($site_id)
77 $key = 'status_network_tags:' . $site_id;
78 if (Status_network::$cache) {
79 $packed = Status_network::$cache->get($key);
80 if (is_string($packed)) {
84 return explode('|', $packed);
91 $tags = new Status_network_tag();
92 $tags->site_id = $site_id;
94 while ($tags->fetch()) {
95 $result[] = $tags->tag;
99 if (Status_network::$cache) {
100 $packed = implode('|', $result);
101 Status_network::$cache->set($key, $packed, 0, 3600);
108 * Drop the cached tag entries for this site.
109 * Needed after inserting/deleting a tag entry.
113 $key = 'status_network_tags:' . $this->site_id;
114 if (Status_network::$cache) {
115 Status_network::$cache->delete($key);
121 $ret = parent::insert();
128 $ret = parent::delete();