3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 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/>.
21 * @package OStatusPlugin
22 * @maintainer Brion Vibber <brion@status.net>
25 class Ostatus_source extends Memcached_DataObject
27 public $__table = 'ostatus_source';
29 public $notice_id; // notice we're referring to
30 public $profile_uri; // uri of the ostatus_profile this came through -- may be a group feed
31 public $method; // push or salmon
33 public /*static*/ function staticGet($k, $v=null)
35 return parent::staticGet(__CLASS__, $k, $v);
39 * return table definition for DB_DataObject
41 * DB_DataObject needs to know something about the table to manipulate
42 * instances. This method provides all the DB_DataObject needs to know.
44 * @return array array of column definitions
49 return array('notice_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
50 'profile_uri' => DB_DATAOBJECT_STR,
51 'method' => DB_DATAOBJECT_STR);
54 static function schemaDef()
56 return array(new ColumnDef('notice_id', 'integer',
58 new ColumnDef('profile_uri', 'varchar',
60 new ColumnDef('method', "ENUM('push','salmon')",
65 * return key definitions for DB_DataObject
67 * DB_DataObject needs to know about keys that the table has; this function
70 * @return array key definitions
75 return array_keys($this->keyTypes());
79 * return key definitions for Memcached_DataObject
81 * Our caching system uses the same key definitions, but uses a different
84 * @return array key definitions
89 return array('notice_id' => 'K');
92 function sequenceKey()
94 return array(false, false, false);
98 * Save a remote notice source record; this helps indicate how trusted we are.
99 * @param string $method
101 public static function saveNew(Notice $notice, Ostatus_profile $oprofile, $method)
103 $osource = new Ostatus_source();
104 $osource->notice_id = $notice->id;
105 $osource->profile_uri = $oprofile->uri;
106 $osource->method = $method;
107 if ($osource->insert()) {
110 common_log_db_error($osource, 'INSERT', __FILE__);