diff options
author | Brion Vibber <brion@pobox.com> | 2010-09-23 17:55:13 -0700 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-09-28 07:44:24 -0700 |
commit | 8f438da254defa35d9e066fb29947da208d14319 (patch) | |
tree | a768c0be8268b60691e734b30f20b1a94396dd26 /plugins/YammerImport/classes | |
parent | ae507b04856804acb41256a00a9cd2c8e7136c96 (diff) |
Ok, command-line workflow for YammerImportPlugin seems to mostly work, at least on tiny test site :D
Diffstat (limited to 'plugins/YammerImport/classes')
-rw-r--r-- | plugins/YammerImport/classes/Yammer_common.php | 4 | ||||
-rw-r--r-- | plugins/YammerImport/classes/Yammer_notice_stub.php | 45 | ||||
-rw-r--r-- | plugins/YammerImport/classes/Yammer_state.php | 20 |
3 files changed, 46 insertions, 23 deletions
diff --git a/plugins/YammerImport/classes/Yammer_common.php b/plugins/YammerImport/classes/Yammer_common.php index 81e302ab2..6ec6fc904 100644 --- a/plugins/YammerImport/classes/Yammer_common.php +++ b/plugins/YammerImport/classes/Yammer_common.php @@ -138,13 +138,13 @@ class Yammer_common extends Memcached_DataObject protected static function doRecord($class, $field, $orig_id, $local_id) { - $map = self::staticGet('id', $orig_id); + $map = parent::staticGet($class, 'id', $orig_id); if (!empty($map)) { return $map; } - $map = self::staticGet($field, $local_id); + $map = parent::staticGet($class, $field, $local_id); if (!empty($map)) { return $map; diff --git a/plugins/YammerImport/classes/Yammer_notice_stub.php b/plugins/YammerImport/classes/Yammer_notice_stub.php index cc52554de..e10300c4c 100644 --- a/plugins/YammerImport/classes/Yammer_notice_stub.php +++ b/plugins/YammerImport/classes/Yammer_notice_stub.php @@ -49,6 +49,23 @@ class Yammer_notice_stub extends Memcached_DataObject public $created; // datetime /** + * Get an instance by key + * + * This is a utility method to get a single instance with a given key value. + * + * @param string $k Key to use to lookup + * @param mixed $v Value to lookup + * + * @return Yammer_notice_stub object found, or null for no hits + * + */ + + function staticGet($k, $v=null) + { + return Memcached_DataObject::staticGet('Yammer_notice_stub', $k, $v); + } + + /** * Return schema definition to set this table up in onCheckSchema */ static function schemaDef() @@ -127,6 +144,16 @@ class Yammer_notice_stub extends Memcached_DataObject } /** + * Decode the stored data structure. + * + * @return mixed + */ + public function getData() + { + return json_decode($this->json_data, true); + } + + /** * Save the native Yammer API representation of a message for the pending * import. Since they come in in reverse chronological order, we need to * record them all as stubs and then go through from the beginning and @@ -153,22 +180,4 @@ class Yammer_notice_stub extends Memcached_DataObject return $stub; } - - /** - * Save a mapping between a remote Yammer and local imported user. - * - * @param integer $user_id ID of the status in StatusNet - * - * @return Yammer_notice_stub new object for this value - */ - - static function retrieve($orig_id) - { - $stub = self::staticGet('id', $orig_id); - if ($stub) { - return json_decode($stub->json_data, true); - } else { - return false; - } - } } diff --git a/plugins/YammerImport/classes/Yammer_state.php b/plugins/YammerImport/classes/Yammer_state.php index 0174ead15..2f1fd7780 100644 --- a/plugins/YammerImport/classes/Yammer_state.php +++ b/plugins/YammerImport/classes/Yammer_state.php @@ -36,7 +36,6 @@ class Yammer_state extends Memcached_DataObject public $__table = 'yammer_state'; // table name public $id; // int primary_key not_null public $state; // import state key - public $request_token; // oauth request token; clear when auth is complete. public $oauth_token; // actual oauth token! clear when import is done? public $oauth_secret; // actual oauth secret! clear when import is done? public $users_page; // last page of users we've fetched @@ -47,6 +46,23 @@ class Yammer_state extends Memcached_DataObject public $modified; // datetime /** + * Get an instance by key + * + * This is a utility method to get a single instance with a given key value. + * + * @param string $k Key to use to lookup + * @param mixed $v Value to lookup + * + * @return Yammer_state object found, or null for no hits + * + */ + + function staticGet($k, $v=null) + { + return Memcached_DataObject::staticGet('Yammer_state', $k, $v); + } + + /** * Return schema definition to set this table up in onCheckSchema */ static function schemaDef() @@ -54,7 +70,6 @@ class Yammer_state extends Memcached_DataObject return array(new ColumnDef('id', 'int', null, false, 'PRI'), new ColumnDef('state', 'text'), - new ColumnDef('request_token', 'text'), new ColumnDef('oauth_token', 'text'), new ColumnDef('oauth_secret', 'text'), new ColumnDef('users_page', 'int'), @@ -78,7 +93,6 @@ class Yammer_state extends Memcached_DataObject { return array('id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL, 'state' => DB_DATAOBJECT_STR, - 'request_token' => DB_DATAOBJECT_STR, 'oauth_token' => DB_DATAOBJECT_STR, 'oauth_secret' => DB_DATAOBJECT_STR, 'users_page' => DB_DATAOBJECT_INT, |