Merge branch 'develop' into task/admin-block-list
This commit is contained in:
commit
ff459441cf
29 changed files with 742 additions and 600 deletions
|
@ -10,6 +10,7 @@ use Friendica\Core\System;
|
|||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Object\Contact;
|
||||
use Friendica\Object\Profile;
|
||||
use Friendica\Protocol\PortableContact;
|
||||
use dba;
|
||||
|
@ -18,7 +19,6 @@ use Exception;
|
|||
require_once 'include/datetime.php';
|
||||
require_once 'include/network.php';
|
||||
require_once 'include/html2bbcode.php';
|
||||
require_once 'include/Photo.php';
|
||||
|
||||
/**
|
||||
* @brief This class handles GlobalContact related functions
|
||||
|
@ -881,7 +881,7 @@ class GlobalContact
|
|||
if (DBM::is_result($r)) {
|
||||
logger("Update public contact ".$r[0]["id"], LOGGER_DEBUG);
|
||||
|
||||
update_contact_avatar($contact["photo"], 0, $r[0]["id"]);
|
||||
Contact::updateAvatar($contact["photo"], 0, $r[0]["id"]);
|
||||
|
||||
$fields = array('name', 'nick', 'addr',
|
||||
'network', 'bd', 'gender',
|
||||
|
|
|
@ -13,6 +13,7 @@ use Friendica\Core\System;
|
|||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Object\Photo;
|
||||
use Friendica\Protocol\Diaspora;
|
||||
use Friendica\Protocol\DFRN;
|
||||
use Friendica\Protocol\OStatus;
|
||||
|
@ -645,9 +646,7 @@ class Contact extends BaseObject
|
|||
}
|
||||
}
|
||||
|
||||
require_once 'include/Photo.php';
|
||||
|
||||
update_contact_avatar($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));
|
||||
|
||||
|
@ -846,5 +845,50 @@ class Contact extends BaseObject
|
|||
$return = dba::update('contact', ['blocked' => false], ['id' => $uid]);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
|
|
1165
src/Object/Photo.php
Normal file
1165
src/Object/Photo.php
Normal file
File diff suppressed because it is too large
Load diff
|
@ -6,6 +6,7 @@
|
|||
namespace Friendica;
|
||||
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Object\Photo;
|
||||
use Friendica\Util\XML;
|
||||
|
||||
use dba;
|
||||
|
@ -13,7 +14,6 @@ use DomXPath;
|
|||
use DOMDocument;
|
||||
|
||||
require_once "include/network.php";
|
||||
require_once "include/Photo.php";
|
||||
require_once "include/oembed.php";
|
||||
|
||||
/**
|
||||
|
@ -353,7 +353,7 @@ class ParseUrl
|
|||
}
|
||||
|
||||
$src = self::completeUrl($attr["src"], $url);
|
||||
$photodata = get_photo_info($src);
|
||||
$photodata = Photo::getInfoFromURL($src);
|
||||
|
||||
if (($photodata) && ($photodata[0] > 150) && ($photodata[1] > 150)) {
|
||||
if ($photodata[0] > 300) {
|
||||
|
@ -374,7 +374,7 @@ class ParseUrl
|
|||
|
||||
unset($siteinfo["image"]);
|
||||
|
||||
$photodata = get_photo_info($src);
|
||||
$photodata = Photo::getInfoFromURL($src);
|
||||
|
||||
if (($photodata) && ($photodata[0] > 10) && ($photodata[1] > 10)) {
|
||||
$siteinfo["images"][] = array("src" => $src,
|
||||
|
|
|
@ -15,6 +15,7 @@ use Friendica\Core\Worker;
|
|||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\GlobalContact;
|
||||
use Friendica\Object\Contact;
|
||||
use Friendica\Object\Photo;
|
||||
use Friendica\Object\Profile;
|
||||
use Friendica\Protocol\OStatus;
|
||||
use Friendica\Util\XML;
|
||||
|
@ -1659,7 +1660,7 @@ class DFRN
|
|||
);
|
||||
}
|
||||
|
||||
update_contact_avatar(
|
||||
Contact::updateAvatar(
|
||||
$author["avatar"],
|
||||
$importer["uid"],
|
||||
$contact["id"],
|
||||
|
@ -2034,7 +2035,7 @@ class DFRN
|
|||
dbesc(normalise_link($old["url"]))
|
||||
);
|
||||
|
||||
update_contact_avatar($relocate["avatar"], $importer["importer_uid"], $importer["id"], true);
|
||||
Contact::updateAvatar($relocate["avatar"], $importer["importer_uid"], $importer["id"], true);
|
||||
|
||||
if ($x === false) {
|
||||
return false;
|
||||
|
|
|
@ -27,7 +27,6 @@ use SimpleXMLElement;
|
|||
|
||||
require_once 'include/items.php';
|
||||
require_once 'include/bb2diaspora.php';
|
||||
require_once 'include/Photo.php';
|
||||
require_once 'include/group.php';
|
||||
require_once 'include/datetime.php';
|
||||
require_once 'include/queue_fn.php';
|
||||
|
@ -2211,7 +2210,7 @@ class Diaspora
|
|||
$image_url = "http://".$handle_parts[1].$image_url;
|
||||
}
|
||||
|
||||
update_contact_avatar($image_url, $importer["uid"], $contact["id"]);
|
||||
Contact::updateAvatar($image_url, $importer["uid"], $contact["id"]);
|
||||
|
||||
// Generic birthday. We don't know the timezone. The year is irrelevant.
|
||||
|
||||
|
@ -2471,7 +2470,7 @@ class Diaspora
|
|||
group_add_member($importer["uid"], "", $contact_record["id"], $def_gid);
|
||||
}
|
||||
|
||||
update_contact_avatar($ret["photo"], $importer['uid'], $contact_record["id"], true);
|
||||
Contact::updateAvatar($ret["photo"], $importer['uid'], $contact_record["id"], true);
|
||||
|
||||
if ($importer["page-flags"] == PAGE_NORMAL) {
|
||||
logger("Sending intra message for author ".$author.".", LOGGER_DEBUG);
|
||||
|
@ -2494,7 +2493,7 @@ class Diaspora
|
|||
|
||||
logger("Does an automatic friend approval for author ".$author.".", LOGGER_DEBUG);
|
||||
|
||||
update_contact_avatar($contact_record["photo"], $importer["uid"], $contact_record["id"]);
|
||||
Contact::updateAvatar($contact_record["photo"], $importer["uid"], $contact_record["id"]);
|
||||
|
||||
// technically they are sharing with us (CONTACT_IS_SHARING),
|
||||
// but if our page-type is PAGE_COMMUNITY or PAGE_SOAPBOX
|
||||
|
|
|
@ -12,6 +12,7 @@ use Friendica\Database\DBM;
|
|||
use Friendica\Model\GlobalContact;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Object\Contact;
|
||||
use Friendica\Object\Photo;
|
||||
use Friendica\Util\Lock;
|
||||
use Friendica\Util\XML;
|
||||
use dba;
|
||||
|
@ -24,7 +25,6 @@ require_once 'include/bbcode.php';
|
|||
require_once 'include/items.php';
|
||||
require_once 'mod/share.php';
|
||||
require_once 'include/enotify.php';
|
||||
require_once 'include/Photo.php';
|
||||
require_once 'include/follow.php';
|
||||
require_once 'include/api.php';
|
||||
require_once 'mod/proxy.php';
|
||||
|
@ -203,7 +203,7 @@ class OStatus
|
|||
|
||||
if (!empty($author["author-avatar"]) && ($author["author-avatar"] != $current['avatar'])) {
|
||||
logger("Update profile picture for contact ".$contact["id"], LOGGER_DEBUG);
|
||||
update_contact_avatar($author["author-avatar"], $importer["uid"], $contact["id"]);
|
||||
Contact::updateAvatar($author["author-avatar"], $importer["uid"], $contact["id"]);
|
||||
}
|
||||
|
||||
// Ensure that we are having this contact (with uid=0)
|
||||
|
@ -223,7 +223,7 @@ class OStatus
|
|||
dba::update('contact', $fields, array('id' => $cid), $old_contact);
|
||||
|
||||
// Update the avatar
|
||||
update_contact_avatar($author["author-avatar"], 0, $cid);
|
||||
Contact::updateAvatar($author["author-avatar"], 0, $cid);
|
||||
}
|
||||
|
||||
$contact["generation"] = 2;
|
||||
|
@ -1326,7 +1326,7 @@ class OStatus
|
|||
|
||||
switch ($siteinfo["type"]) {
|
||||
case 'photo':
|
||||
$imgdata = get_photo_info($siteinfo["image"]);
|
||||
$imgdata = Photo::getInfoFromURL($siteinfo["image"]);
|
||||
$attributes = array("rel" => "enclosure",
|
||||
"href" => $siteinfo["image"],
|
||||
"type" => $imgdata["mime"],
|
||||
|
@ -1346,7 +1346,7 @@ class OStatus
|
|||
}
|
||||
|
||||
if (!Config::get('system', 'ostatus_not_attach_preview') && ($siteinfo["type"] != "photo") && isset($siteinfo["image"])) {
|
||||
$imgdata = get_photo_info($siteinfo["image"]);
|
||||
$imgdata = Photo::getInfoFromURL($siteinfo["image"]);
|
||||
$attributes = array("rel" => "enclosure",
|
||||
"href" => $siteinfo["image"],
|
||||
"type" => $imgdata["mime"],
|
||||
|
|
|
@ -14,6 +14,7 @@ use Friendica\Core\Worker;
|
|||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\GlobalContact;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Object\Photo;
|
||||
use Friendica\Object\Profile;
|
||||
use dba;
|
||||
use DOMDocument;
|
||||
|
@ -23,7 +24,6 @@ use Exception;
|
|||
require_once 'include/datetime.php';
|
||||
require_once 'include/network.php';
|
||||
require_once 'include/html2bbcode.php';
|
||||
require_once 'include/Photo.php';
|
||||
|
||||
class PortableContact
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue