diff options
Diffstat (limited to 'classes')
-rw-r--r-- | classes/Foreign_link.php | 18 | ||||
-rw-r--r-- | classes/Foreign_user.php | 34 |
2 files changed, 23 insertions, 29 deletions
diff --git a/classes/Foreign_link.php b/classes/Foreign_link.php index a93f30f2c..4fcad4b17 100644 --- a/classes/Foreign_link.php +++ b/classes/Foreign_link.php @@ -25,4 +25,22 @@ class Foreign_link extends DB_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + + // XXX: This only returns a 1->1 single obj mapping. Change? Or make + // a getForeignUsers() that returns more than one? --Zach + static function getForeignLink($user_id, $service) { + + $flink = new Foreign_link(); + $flink->whereAdd("service = $service"); + $flink->whereAdd("user_id = $user_id"); + $flink->limit(1); + + if ($flink->find()) { + $flink->fetch(); + return $flink; + } + + return NULL; + } + } diff --git a/classes/Foreign_user.php b/classes/Foreign_user.php index 6dbad9aa2..2b6e81015 100644 --- a/classes/Foreign_user.php +++ b/classes/Foreign_user.php @@ -23,11 +23,12 @@ class Foreign_user extends DB_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE - function getForeignUser($user_id, $service) { - - $fuser = DB_DataObject::factory('foreign_user'); + // XXX: This only returns a 1->1 single obj mapping. Change? Or make + // a getForeignUsers() that returns more than one? --Zach + static function getForeignUser($id, $service) { + $fuser = new Foreign_user(); $fuser->whereAdd("service = $service"); - $fuser->whereAdd("user_id = $user_id"); + $fuser->whereAdd("id = $id"); $fuser->limit(1); if ($fuser->find()) { @@ -38,29 +39,4 @@ class Foreign_user extends DB_DataObject return NULL; } - - static function save($fields) { - - extract($fields); - - $fuser = new Foreign_user(); - - $fuser->id = $id; - $fuser->service = $service; - $fuser->uri = $uri; - $fuser->nickname = $nickname; - $fuser->user_id = $user_id; - $fuser->credentials = $credentials; - $fuser->created = common_sql_now(); - - $result = $fuser->insert(); - - if (!$result) { - common_log_db_error($fuser, 'INSERT', __FILE__); - return FALSE; - } - - return $fuser; - } - } |