X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=classes%2FForeign_user.php;h=61727abe5ed5924d6a8a7bb41eb721a2d672cefc;hb=8b9e559167e27c490648cc55c4f617c2e9122a18;hp=d70923caa5848f451b19250409b40683140478e3;hpb=8da61dc1d36e2ac600a50450038ce69d458b0e7b;p=quix0rs-gnu-social.git diff --git a/classes/Foreign_user.php b/classes/Foreign_user.php index d70923caa5..61727abe5e 100644 --- a/classes/Foreign_user.php +++ b/classes/Foreign_user.php @@ -18,25 +18,55 @@ class Foreign_user extends Memcached_DataObject public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP /* Static get */ - function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Foreign_user',$k,$v); } + function staticGet($k,$v=null) + { return Memcached_DataObject::staticGet('Foreign_user',$k,$v); } /* 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 getForeignUser($id, $service) { - $fuser = new Foreign_user(); - $fuser->whereAdd("service = $service"); - $fuser->whereAdd("id = $id"); - $fuser->limit(1); - - if ($fuser->find()) { - $fuser->fetch(); - return $fuser; - } - - return NULL; - } - + + // 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("id = $id"); + $fuser->limit(1); + + if ($fuser->find()) { + $fuser->fetch(); + return $fuser; + } + + return null; + } + + function updateKeys(&$orig) + { + $parts = array(); + foreach (array('id', 'service', 'uri', 'nickname') as $k) { + if (strcmp($this->$k, $orig->$k) != 0) { + $parts[] = $k . ' = ' . $this->_quote($this->$k); + } + } + if (count($parts) == 0) { + # No changes + return true; + } + $toupdate = implode(', ', $parts); + + $table = $this->tableName(); + if(common_config('db','quote_identifiers')) { + $table = '"' . $table . '"'; + } + $qry = 'UPDATE ' . $table . ' SET ' . $toupdate . + ' WHERE id = ' . $this->id; + $orig->decache(); + $result = $this->query($qry); + if ($result) { + $this->encache(); + } + return $result; + } + + }