mirror of
https://github.com/friendica/friendica
synced 2025-04-29 11:44:24 +02:00
Review and Use statements
use statements and review changes.
This commit is contained in:
parent
eb148cad55
commit
0373056448
15 changed files with 83 additions and 247 deletions
|
@ -644,7 +644,7 @@ class Contact extends BaseObject
|
|||
}
|
||||
}
|
||||
|
||||
Photo::updateContactAvatar($data["photo"], $uid, $contact_id);
|
||||
self::updateAvatar($data["photo"], $uid, $contact_id);
|
||||
|
||||
$contact = dba::select('contact', array('url', 'nurl', 'addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'avatar-date'), array('id' => $contact_id), array('limit' => 1));
|
||||
|
||||
|
@ -818,4 +818,49 @@ class Contact extends BaseObject
|
|||
|
||||
return $account_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Updates the avatar links in a contact only if needed
|
||||
*
|
||||
* @param string $avatar Link to avatar picture
|
||||
* @param int $uid User id of contact owner
|
||||
* @param int $cid Contact id
|
||||
* @param bool $force force picture update
|
||||
*
|
||||
* @return array Returns array of the different avatar sizes
|
||||
*/
|
||||
public static function updateAvatar($avatar, $uid, $cid, $force = false)
|
||||
{
|
||||
// Limit = 1 returns the row so no need for dba:inArray()
|
||||
$r = dba::select('contact', array('avatar', 'photo', 'thumb', 'micro', 'nurl'), array('id' => $cid), array('limit' => 1));
|
||||
if (!DBM::is_result($r)) {
|
||||
return false;
|
||||
} else {
|
||||
$data = array($r["photo"], $r["thumb"], $r["micro"]);
|
||||
}
|
||||
|
||||
if (($r["avatar"] != $avatar) || $force) {
|
||||
$photos = Photo::importProfilePhoto($avatar, $uid, $cid, true);
|
||||
|
||||
if ($photos) {
|
||||
dba::update(
|
||||
'contact',
|
||||
array('avatar' => $avatar, 'photo' => $photos[0], 'thumb' => $photos[1], 'micro' => $photos[2], 'avatar-date' => datetime_convert()),
|
||||
array('id' => $cid)
|
||||
);
|
||||
|
||||
// Update the public contact (contact id = 0)
|
||||
if ($uid != 0) {
|
||||
$pcontact = dba::select('contact', array('id'), array('nurl' => $r[0]['nurl']), array('limit' => 1));
|
||||
if (DBM::is_result($pcontact)) {
|
||||
self::updateAvatar($avatar, 0, $pcontact['id'], $force);
|
||||
}
|
||||
}
|
||||
|
||||
return $photos;
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue