3 * Data class for remembering Yammer import state
9 * @author Brion Vibber <brion@status.net>
10 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
11 * @link http://status.net/
13 * StatusNet - the distributed open-source microblogging tool
14 * Copyright (C) 2010, StatusNet, Inc.
16 * This program is free software: you can redistribute it and/or modify
17 * it under the terms of the GNU Affero General Public License as published by
18 * the Free Software Foundation, either version 3 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU Affero General Public License for more details.
26 * You should have received a copy of the GNU Affero General Public License
27 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 if (!defined('STATUSNET')) {
34 class Yammer_state extends Memcached_DataObject
36 public $__table = 'yammer_state'; // table name
37 public $id; // int primary_key not_null
38 public $state; // import state key
39 public $request_token; // oauth request token; clear when auth is complete.
40 public $oauth_token; // actual oauth token! clear when import is done?
41 public $oauth_secret; // actual oauth secret! clear when import is done?
42 public $users_page; // last page of users we've fetched
43 public $groups_page; // last page of groups we've fetched
44 public $messages_oldest; // oldest message ID we've fetched
45 public $messages_newest; // newest message ID we've imported
46 public $created; // datetime
47 public $modified; // datetime
50 * Return schema definition to set this table up in onCheckSchema
52 static function schemaDef()
54 return array(new ColumnDef('id', 'int', null,
56 new ColumnDef('state', 'text'),
57 new ColumnDef('request_token', 'text'),
58 new ColumnDef('oauth_token', 'text'),
59 new ColumnDef('oauth_secret', 'text'),
60 new ColumnDef('users_page', 'int'),
61 new ColumnDef('groups_page', 'int'),
62 new ColumnDef('messages_oldest', 'bigint'),
63 new ColumnDef('messages_newest', 'bigint'),
64 new ColumnDef('created', 'datetime'),
65 new ColumnDef('modified', 'datetime'));
69 * return table definition for DB_DataObject
71 * DB_DataObject needs to know something about the table to manipulate
72 * instances. This method provides all the DB_DataObject needs to know.
74 * @return array array of column definitions
79 return array('id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
80 'state' => DB_DATAOBJECT_STR,
81 'request_token' => DB_DATAOBJECT_STR,
82 'oauth_token' => DB_DATAOBJECT_STR,
83 'oauth_secret' => DB_DATAOBJECT_STR,
84 'users_page' => DB_DATAOBJECT_INT,
85 'groups_page' => DB_DATAOBJECT_INT,
86 'messages_oldest' => DB_DATAOBJECT_INT,
87 'messages_newest' => DB_DATAOBJECT_INT,
88 'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL);
92 * return key definitions for DB_DataObject
94 * DB_DataObject needs to know about keys that the table has, since it
95 * won't appear in StatusNet's own keys list. In most cases, this will
96 * simply reference your keyTypes() function.
98 * @return array list of key field names
103 return array_keys($this->keyTypes());
107 * return key definitions for Memcached_DataObject
109 * Our caching system uses the same key definitions, but uses a different
110 * method to get them. This key information is used to store and clear
111 * cached data, so be sure to list any key that will be used for static
114 * @return array associative array of key definitions, field name to type:
115 * 'K' for primary key: for compound keys, add an entry for each component;
116 * 'U' for unique keys: compound keys are not well supported here.
121 return array('id' => 'K');
125 * Magic formula for non-autoincrementing integer primary keys
127 * If a table has a single integer column as its primary key, DB_DataObject
128 * assumes that the column is auto-incrementing and makes a sequence table
129 * to do this incrementation. Since we don't need this for our class, we
130 * overload this method and return the magic formula that DB_DataObject needs.
132 * @return array magic three-false array that stops auto-incrementing.
135 function sequenceKey()
137 return array(false, false, false);