Merge pull request #2299 from annando/1601-contact-photos
Improved avatar storage in contacts
This commit is contained in:
commit
fdb864157d
2
boot.php
2
boot.php
|
@ -36,7 +36,7 @@ define ( 'FRIENDICA_PLATFORM', 'Friendica');
|
||||||
define ( 'FRIENDICA_CODENAME', 'Asparagus');
|
define ( 'FRIENDICA_CODENAME', 'Asparagus');
|
||||||
define ( 'FRIENDICA_VERSION', '3.5-dev' );
|
define ( 'FRIENDICA_VERSION', '3.5-dev' );
|
||||||
define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
|
define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
|
||||||
define ( 'DB_UPDATE_VERSION', 1193 );
|
define ( 'DB_UPDATE_VERSION', 1194 );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Constant with a HTML line break.
|
* @brief Constant with a HTML line break.
|
||||||
|
|
|
@ -486,21 +486,16 @@ function get_contact($url, $uid = 0) {
|
||||||
|
|
||||||
require_once("Photo.php");
|
require_once("Photo.php");
|
||||||
|
|
||||||
$photos = import_profile_photo($data["photo"],$uid,$contactid);
|
update_contact_avatar($data["photo"],$uid,$contactid);
|
||||||
|
|
||||||
q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s',
|
q("UPDATE `contact` SET `addr` = '%s', `alias` = '%s', `name` = '%s', `nick` = '%s',
|
||||||
`addr` = '%s', `alias` = '%s', `name` = '%s', `nick` = '%s',
|
`name-date` = '%s', `uri-date` = '%s' WHERE `id` = %d",
|
||||||
`name-date` = '%s', `uri-date` = '%s', `avatar-date` = '%s' WHERE `id` = %d",
|
|
||||||
dbesc($photos[0]),
|
|
||||||
dbesc($photos[1]),
|
|
||||||
dbesc($photos[2]),
|
|
||||||
dbesc($data["addr"]),
|
dbesc($data["addr"]),
|
||||||
dbesc($data["alias"]),
|
dbesc($data["alias"]),
|
||||||
dbesc($data["name"]),
|
dbesc($data["name"]),
|
||||||
dbesc($data["nick"]),
|
dbesc($data["nick"]),
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
dbesc(datetime_convert()),
|
|
||||||
intval($contactid)
|
intval($contactid)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -720,65 +720,100 @@ function guess_image_type($filename, $fromcurl=false) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function import_profile_photo($photo,$uid,$cid) {
|
/**
|
||||||
|
* @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
|
||||||
|
*
|
||||||
|
* @return array Returns array of the different avatar sizes
|
||||||
|
*/
|
||||||
|
function update_contact_avatar($avatar,$uid,$cid) {
|
||||||
|
|
||||||
$a = get_app();
|
$r = q("SELECT `avatar`, `photo`, `thumb`, `micro` FROM `contact` WHERE `id` = %d LIMIT 1", intval($cid));
|
||||||
|
if (!$r)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
$data = array($r[0]["photo"], $r[0]["thumb"], $r[0]["micro"]);
|
||||||
|
|
||||||
$r = q("select `resource-id` from photo where `uid` = %d and `contact-id` = %d and `scale` = 4 and `album` = 'Contact Photos' limit 1",
|
if ($r[0]["avatar"] != $avatar) {
|
||||||
intval($uid),
|
$photos = import_profile_photo($avatar,$uid,$cid, true);
|
||||||
intval($cid)
|
|
||||||
);
|
|
||||||
if(count($r) && strlen($r[0]['resource-id'])) {
|
|
||||||
$hash = $r[0]['resource-id'];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$hash = photo_new_resource();
|
|
||||||
}
|
|
||||||
|
|
||||||
$photo_failure = false;
|
if ($photos) {
|
||||||
|
q("UPDATE `contact` SET `avatar` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' WHERE `id` = %d",
|
||||||
|
dbesc($avatar), dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]),
|
||||||
|
dbesc(datetime_convert()), intval($cid));
|
||||||
|
return $photos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$filename = basename($photo);
|
return $data;
|
||||||
$img_str = fetch_url($photo,true);
|
}
|
||||||
|
|
||||||
$type = guess_image_type($photo,true);
|
function import_profile_photo($photo,$uid,$cid, $quit_on_error = false) {
|
||||||
$img = new Photo($img_str, $type);
|
|
||||||
if($img->is_valid()) {
|
|
||||||
|
|
||||||
$img->scaleImageSquare(175);
|
$a = get_app();
|
||||||
|
|
||||||
$r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 4 );
|
$r = q("select `resource-id` from photo where `uid` = %d and `contact-id` = %d and `scale` = 4 and `album` = 'Contact Photos' limit 1",
|
||||||
|
intval($uid),
|
||||||
|
intval($cid)
|
||||||
|
);
|
||||||
|
if(count($r) && strlen($r[0]['resource-id'])) {
|
||||||
|
$hash = $r[0]['resource-id'];
|
||||||
|
} else {
|
||||||
|
$hash = photo_new_resource();
|
||||||
|
}
|
||||||
|
|
||||||
if($r === false)
|
$photo_failure = false;
|
||||||
$photo_failure = true;
|
|
||||||
|
|
||||||
$img->scaleImage(80);
|
$filename = basename($photo);
|
||||||
|
$img_str = fetch_url($photo,true);
|
||||||
|
|
||||||
$r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 5 );
|
if ($quit_on_error AND ($img_str == ""))
|
||||||
|
return false;
|
||||||
|
|
||||||
if($r === false)
|
$type = guess_image_type($photo,true);
|
||||||
$photo_failure = true;
|
$img = new Photo($img_str, $type);
|
||||||
|
if($img->is_valid()) {
|
||||||
|
|
||||||
$img->scaleImage(48);
|
$img->scaleImageSquare(175);
|
||||||
|
|
||||||
$r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 6 );
|
$r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 4 );
|
||||||
|
|
||||||
if($r === false)
|
if($r === false)
|
||||||
$photo_failure = true;
|
$photo_failure = true;
|
||||||
|
|
||||||
$photo = $a->get_baseurl() . '/photo/' . $hash . '-4.' . $img->getExt();
|
$img->scaleImage(80);
|
||||||
$thumb = $a->get_baseurl() . '/photo/' . $hash . '-5.' . $img->getExt();
|
|
||||||
$micro = $a->get_baseurl() . '/photo/' . $hash . '-6.' . $img->getExt();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
$photo_failure = true;
|
|
||||||
|
|
||||||
if($photo_failure) {
|
$r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 5 );
|
||||||
$photo = $a->get_baseurl() . '/images/person-175.jpg';
|
|
||||||
$thumb = $a->get_baseurl() . '/images/person-80.jpg';
|
|
||||||
$micro = $a->get_baseurl() . '/images/person-48.jpg';
|
|
||||||
}
|
|
||||||
|
|
||||||
return(array($photo,$thumb,$micro));
|
if($r === false)
|
||||||
|
$photo_failure = true;
|
||||||
|
|
||||||
|
$img->scaleImage(48);
|
||||||
|
|
||||||
|
$r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 6 );
|
||||||
|
|
||||||
|
if($r === false)
|
||||||
|
$photo_failure = true;
|
||||||
|
|
||||||
|
$photo = $a->get_baseurl() . '/photo/' . $hash . '-4.' . $img->getExt();
|
||||||
|
$thumb = $a->get_baseurl() . '/photo/' . $hash . '-5.' . $img->getExt();
|
||||||
|
$micro = $a->get_baseurl() . '/photo/' . $hash . '-6.' . $img->getExt();
|
||||||
|
} else
|
||||||
|
$photo_failure = true;
|
||||||
|
|
||||||
|
if($photo_failure AND $quit_on_error)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if($photo_failure) {
|
||||||
|
$photo = $a->get_baseurl() . '/images/person-175.jpg';
|
||||||
|
$thumb = $a->get_baseurl() . '/images/person-80.jpg';
|
||||||
|
$micro = $a->get_baseurl() . '/images/person-48.jpg';
|
||||||
|
}
|
||||||
|
|
||||||
|
return(array($photo,$thumb,$micro));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -453,6 +453,7 @@ function db_definition() {
|
||||||
"keywords" => array("type" => "text", "not null" => "1"),
|
"keywords" => array("type" => "text", "not null" => "1"),
|
||||||
"gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
|
"gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
|
||||||
"attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
|
"avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"photo" => array("type" => "text", "not null" => "1"),
|
"photo" => array("type" => "text", "not null" => "1"),
|
||||||
"thumb" => array("type" => "text", "not null" => "1"),
|
"thumb" => array("type" => "text", "not null" => "1"),
|
||||||
"micro" => array("type" => "text", "not null" => "1"),
|
"micro" => array("type" => "text", "not null" => "1"),
|
||||||
|
|
|
@ -729,7 +729,7 @@ function diaspora_request($importer,$xml) {
|
||||||
|
|
||||||
require_once('include/Photo.php');
|
require_once('include/Photo.php');
|
||||||
|
|
||||||
$photos = import_profile_photo($contact_record['photo'],$importer['uid'],$contact_record['id']);
|
update_contact_avatar($contact_record['photo'],$importer['uid'],$contact_record['id']);
|
||||||
|
|
||||||
// technically they are sharing with us (CONTACT_IS_SHARING),
|
// technically they are sharing with us (CONTACT_IS_SHARING),
|
||||||
// but if our page-type is PAGE_COMMUNITY or PAGE_SOAPBOX
|
// but if our page-type is PAGE_COMMUNITY or PAGE_SOAPBOX
|
||||||
|
@ -740,26 +740,17 @@ function diaspora_request($importer,$xml) {
|
||||||
else
|
else
|
||||||
$new_relation = CONTACT_IS_FOLLOWER;
|
$new_relation = CONTACT_IS_FOLLOWER;
|
||||||
|
|
||||||
$r = q("UPDATE `contact` SET
|
$r = q("UPDATE `contact` SET `rel` = %d,
|
||||||
`photo` = '%s',
|
|
||||||
`thumb` = '%s',
|
|
||||||
`micro` = '%s',
|
|
||||||
`rel` = %d,
|
|
||||||
`name-date` = '%s',
|
`name-date` = '%s',
|
||||||
`uri-date` = '%s',
|
`uri-date` = '%s',
|
||||||
`avatar-date` = '%s',
|
|
||||||
`blocked` = 0,
|
`blocked` = 0,
|
||||||
`pending` = 0,
|
`pending` = 0,
|
||||||
`writable` = 1
|
`writable` = 1
|
||||||
WHERE `id` = %d
|
WHERE `id` = %d
|
||||||
",
|
",
|
||||||
dbesc($photos[0]),
|
|
||||||
dbesc($photos[1]),
|
|
||||||
dbesc($photos[2]),
|
|
||||||
intval($new_relation),
|
intval($new_relation),
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
dbesc(datetime_convert()),
|
|
||||||
intval($contact_record['id'])
|
intval($contact_record['id'])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -2432,7 +2423,7 @@ function diaspora_profile($importer,$xml,$msg) {
|
||||||
|
|
||||||
require_once('include/Photo.php');
|
require_once('include/Photo.php');
|
||||||
|
|
||||||
$images = import_profile_photo($image_url,$importer['uid'],$contact['id']);
|
update_contact_avatar($image_url,$importer['uid'],$contact['id']);
|
||||||
|
|
||||||
// Generic birthday. We don't know the timezone. The year is irrelevant.
|
// Generic birthday. We don't know the timezone. The year is irrelevant.
|
||||||
|
|
||||||
|
@ -2450,15 +2441,12 @@ function diaspora_profile($importer,$xml,$msg) {
|
||||||
/// @TODO Update name on item['author-name'] if the name changed. See consume_feed()
|
/// @TODO Update name on item['author-name'] if the name changed. See consume_feed()
|
||||||
/// (Not doing this currently because D* protocol is scheduled for revision soon).
|
/// (Not doing this currently because D* protocol is scheduled for revision soon).
|
||||||
|
|
||||||
$r = q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `addr` = '%s', `name-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' , `bd` = '%s', `location` = '%s', `about` = '%s', `keywords` = '%s', `gender` = '%s' WHERE `id` = %d AND `uid` = %d",
|
$r = q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `addr` = '%s', `name-date` = '%s', `bd` = '%s',
|
||||||
|
`location` = '%s', `about` = '%s', `keywords` = '%s', `gender` = '%s' WHERE `id` = %d AND `uid` = %d",
|
||||||
dbesc($name),
|
dbesc($name),
|
||||||
dbesc($nick),
|
dbesc($nick),
|
||||||
dbesc($diaspora_handle),
|
dbesc($diaspora_handle),
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
dbesc($image_url),
|
|
||||||
dbesc($images[1]),
|
|
||||||
dbesc($images[2]),
|
|
||||||
dbesc(datetime_convert()),
|
|
||||||
dbesc($birthday),
|
dbesc($birthday),
|
||||||
dbesc($location),
|
dbesc($location),
|
||||||
dbesc($about),
|
dbesc($about),
|
||||||
|
|
|
@ -264,24 +264,8 @@ function new_contact($uid,$url,$interactive = false) {
|
||||||
|
|
||||||
require_once("include/Photo.php");
|
require_once("include/Photo.php");
|
||||||
|
|
||||||
$photos = import_profile_photo($ret['photo'],$uid,$contact_id);
|
// Update the avatar
|
||||||
|
update_contact_avatar($ret['photo'],$uid,$contact_id);
|
||||||
$r = q("UPDATE `contact` SET `photo` = '%s',
|
|
||||||
`thumb` = '%s',
|
|
||||||
`micro` = '%s',
|
|
||||||
`name-date` = '%s',
|
|
||||||
`uri-date` = '%s',
|
|
||||||
`avatar-date` = '%s'
|
|
||||||
WHERE `id` = %d",
|
|
||||||
dbesc($photos[0]),
|
|
||||||
dbesc($photos[1]),
|
|
||||||
dbesc($photos[2]),
|
|
||||||
dbesc(datetime_convert()),
|
|
||||||
dbesc(datetime_convert()),
|
|
||||||
dbesc(datetime_convert()),
|
|
||||||
intval($contact_id)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// pull feed and consume it, which should subscribe to the hub.
|
// pull feed and consume it, which should subscribe to the hub.
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,8 @@ function ostatus_fetchauthor($xpath, $context, $importer, &$contact, $onlyfetch)
|
||||||
$author["owner-link"] = $author["author-link"];
|
$author["owner-link"] = $author["author-link"];
|
||||||
$author["owner-avatar"] = $author["author-avatar"];
|
$author["owner-avatar"] = $author["author-avatar"];
|
||||||
|
|
||||||
if ($r AND !$onlyfetch) {
|
// Only update the contacts if it is an OStatus contact
|
||||||
|
if ($r AND !$onlyfetch AND ($contact["network"] == NETWORK_OSTATUS)) {
|
||||||
// Update contact data
|
// Update contact data
|
||||||
|
|
||||||
$value = $xpath->query("atom:link[@rel='salmon']", $context)->item(0)->nodeValue;
|
$value = $xpath->query("atom:link[@rel='salmon']", $context)->item(0)->nodeValue;
|
||||||
|
@ -158,31 +159,25 @@ function ostatus_fetchauthor($xpath, $context, $importer, &$contact, $onlyfetch)
|
||||||
|
|
||||||
logger("Update contact data for contact ".$contact["id"], LOGGER_DEBUG);
|
logger("Update contact data for contact ".$contact["id"], LOGGER_DEBUG);
|
||||||
|
|
||||||
q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `about` = '%s', `location` = '%s', `name-date` = '%s' WHERE `id` = %d AND `network` = '%s'",
|
q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `about` = '%s', `location` = '%s', `name-date` = '%s' WHERE `id` = %d",
|
||||||
dbesc($contact["name"]), dbesc($contact["nick"]), dbesc($contact["about"]), dbesc($contact["location"]),
|
dbesc($contact["name"]), dbesc($contact["nick"]), dbesc($contact["about"]), dbesc($contact["location"]),
|
||||||
dbesc(datetime_convert()), intval($contact["id"]), dbesc(NETWORK_OSTATUS));
|
dbesc(datetime_convert()), intval($contact["id"]));
|
||||||
|
|
||||||
poco_check($contact["url"], $contact["name"], $contact["network"], $author["author-avatar"], $contact["about"], $contact["location"],
|
poco_check($contact["url"], $contact["name"], $contact["network"], $author["author-avatar"], $contact["about"], $contact["location"],
|
||||||
"", "", "", datetime_convert(), 2, $contact["id"], $contact["uid"]);
|
"", "", "", datetime_convert(), 2, $contact["id"], $contact["uid"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($author["author-avatar"]) AND ($author["author-avatar"] != $r[0]['photo'])) {
|
if (isset($author["author-avatar"]) AND ($author["author-avatar"] != $r[0]['avatar'])) {
|
||||||
logger("Update profile picture for contact ".$contact["id"], LOGGER_DEBUG);
|
logger("Update profile picture for contact ".$contact["id"], LOGGER_DEBUG);
|
||||||
|
|
||||||
$photos = import_profile_photo($author["author-avatar"], $importer["uid"], $contact["id"]);
|
update_contact_avatar($author["author-avatar"], $importer["uid"], $contact["id"]);
|
||||||
|
|
||||||
q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' WHERE `id` = %d AND `network` = '%s'",
|
|
||||||
dbesc($author["author-avatar"]), dbesc($photos[1]), dbesc($photos[2]),
|
|
||||||
dbesc(datetime_convert()), intval($contact["id"]), dbesc(NETWORK_OSTATUS));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only update the global contact if it is an OStatus contact
|
|
||||||
if ($contact["network"] == NETWORK_OSTATUS) {
|
/// @todo Add the "addr" field
|
||||||
/// @todo Add the "addr" field
|
$contact["generation"] = 2;
|
||||||
$contact["generation"] = 2;
|
$contact["photo"] = $author["author-avatar"];
|
||||||
$contact["photo"] = $author["author-avatar"];
|
update_gcontact($contact);
|
||||||
update_gcontact($contact);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return($author);
|
return($author);
|
||||||
|
|
|
@ -293,23 +293,8 @@ function _contact_update_profile($contact_id) {
|
||||||
intval(local_user())
|
intval(local_user())
|
||||||
);
|
);
|
||||||
|
|
||||||
$photos = import_profile_photo($data['photo'], local_user(), $contact_id);
|
// Update the entry in the contact table
|
||||||
|
update_contact_avatar($data['photo'], local_user(), $contact_id);
|
||||||
$r = q("UPDATE `contact` SET `photo` = '%s',
|
|
||||||
`thumb` = '%s',
|
|
||||||
`micro` = '%s',
|
|
||||||
`name-date` = '%s',
|
|
||||||
`uri-date` = '%s',
|
|
||||||
`avatar-date` = '%s'
|
|
||||||
WHERE `id` = %d",
|
|
||||||
dbesc($data["photo"]),
|
|
||||||
dbesc($photos[1]),
|
|
||||||
dbesc($photos[2]),
|
|
||||||
dbesc(datetime_convert()),
|
|
||||||
dbesc(datetime_convert()),
|
|
||||||
dbesc(datetime_convert()),
|
|
||||||
intval($contact_id)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Update the entry in the gcontact table
|
// Update the entry in the gcontact table
|
||||||
update_gcontact_from_probe($data["url"]);
|
update_gcontact_from_probe($data["url"]);
|
||||||
|
|
|
@ -80,24 +80,7 @@ function crepair_post(&$a) {
|
||||||
logger('mod-crepair: updating photo from ' . $photo);
|
logger('mod-crepair: updating photo from ' . $photo);
|
||||||
require_once("include/Photo.php");
|
require_once("include/Photo.php");
|
||||||
|
|
||||||
$photos = import_profile_photo($photo,local_user(),$contact['id']);
|
update_contact_avatar($photo,local_user(),$contact['id']);
|
||||||
|
|
||||||
$x = q("UPDATE `contact` SET `photo` = '%s',
|
|
||||||
`thumb` = '%s',
|
|
||||||
`micro` = '%s',
|
|
||||||
`name-date` = '%s',
|
|
||||||
`uri-date` = '%s',
|
|
||||||
`avatar-date` = '%s'
|
|
||||||
WHERE `id` = %d
|
|
||||||
",
|
|
||||||
dbesc($photos[0]),
|
|
||||||
dbesc($photos[1]),
|
|
||||||
dbesc($photos[2]),
|
|
||||||
dbesc(datetime_convert()),
|
|
||||||
dbesc(datetime_convert()),
|
|
||||||
dbesc(datetime_convert()),
|
|
||||||
intval($contact['id'])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($r)
|
if($r)
|
||||||
|
|
|
@ -315,7 +315,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
|
||||||
|
|
||||||
require_once('include/Photo.php');
|
require_once('include/Photo.php');
|
||||||
|
|
||||||
$photos = import_profile_photo($contact['photo'],$uid,$contact_id);
|
update_contact_avatar($contact['photo'],$uid,$contact_id);
|
||||||
|
|
||||||
logger('dfrn_confirm: confirm - imported photos');
|
logger('dfrn_confirm: confirm - imported photos');
|
||||||
|
|
||||||
|
@ -328,27 +328,18 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
|
||||||
if(($relation == CONTACT_IS_SHARING) && ($duplex))
|
if(($relation == CONTACT_IS_SHARING) && ($duplex))
|
||||||
$duplex = 0;
|
$duplex = 0;
|
||||||
|
|
||||||
$r = q("UPDATE `contact` SET
|
$r = q("UPDATE `contact` SET `rel` = %d,
|
||||||
`photo` = '%s',
|
|
||||||
`thumb` = '%s',
|
|
||||||
`micro` = '%s',
|
|
||||||
`rel` = %d,
|
|
||||||
`name-date` = '%s',
|
`name-date` = '%s',
|
||||||
`uri-date` = '%s',
|
`uri-date` = '%s',
|
||||||
`avatar-date` = '%s',
|
|
||||||
`blocked` = 0,
|
`blocked` = 0,
|
||||||
`pending` = 0,
|
`pending` = 0,
|
||||||
`duplex` = %d,
|
`duplex` = %d,
|
||||||
`hidden` = %d,
|
`hidden` = %d,
|
||||||
`network` = '%s' WHERE `id` = %d
|
`network` = '%s' WHERE `id` = %d
|
||||||
",
|
",
|
||||||
dbesc($photos[0]),
|
|
||||||
dbesc($photos[1]),
|
|
||||||
dbesc($photos[2]),
|
|
||||||
intval($new_relation),
|
intval($new_relation),
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
dbesc(datetime_convert()),
|
|
||||||
intval($duplex),
|
intval($duplex),
|
||||||
intval($hidden),
|
intval($hidden),
|
||||||
dbesc(NETWORK_DFRN),
|
dbesc(NETWORK_DFRN),
|
||||||
|
@ -394,12 +385,8 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
$r = q("UPDATE `contact` SET `photo` = '%s',
|
$r = q("UPDATE `contact` SET `name-date` = '%s',
|
||||||
`thumb` = '%s',
|
|
||||||
`micro` = '%s',
|
|
||||||
`name-date` = '%s',
|
|
||||||
`uri-date` = '%s',
|
`uri-date` = '%s',
|
||||||
`avatar-date` = '%s',
|
|
||||||
`notify` = '%s',
|
`notify` = '%s',
|
||||||
`poll` = '%s',
|
`poll` = '%s',
|
||||||
`blocked` = 0,
|
`blocked` = 0,
|
||||||
|
@ -410,10 +397,6 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
|
||||||
`rel` = %d
|
`rel` = %d
|
||||||
WHERE `id` = %d
|
WHERE `id` = %d
|
||||||
",
|
",
|
||||||
dbesc($photos[0]),
|
|
||||||
dbesc($photos[1]),
|
|
||||||
dbesc($photos[2]),
|
|
||||||
dbesc(datetime_convert()),
|
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
dbesc($notify),
|
dbesc($notify),
|
||||||
|
@ -683,7 +666,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
|
||||||
|
|
||||||
require_once("include/Photo.php");
|
require_once("include/Photo.php");
|
||||||
|
|
||||||
$photos = import_profile_photo($photo,$local_uid,$dfrn_record);
|
update_contact_avatar($photo,$local_uid,$dfrn_record);
|
||||||
|
|
||||||
logger('dfrn_confirm: request - photos imported');
|
logger('dfrn_confirm: request - photos imported');
|
||||||
|
|
||||||
|
@ -695,13 +678,9 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
|
||||||
$duplex = 0;
|
$duplex = 0;
|
||||||
|
|
||||||
$r = q("UPDATE `contact` SET
|
$r = q("UPDATE `contact` SET
|
||||||
`photo` = '%s',
|
|
||||||
`thumb` = '%s',
|
|
||||||
`micro` = '%s',
|
|
||||||
`rel` = %d,
|
`rel` = %d,
|
||||||
`name-date` = '%s',
|
`name-date` = '%s',
|
||||||
`uri-date` = '%s',
|
`uri-date` = '%s',
|
||||||
`avatar-date` = '%s',
|
|
||||||
`blocked` = 0,
|
`blocked` = 0,
|
||||||
`pending` = 0,
|
`pending` = 0,
|
||||||
`duplex` = %d,
|
`duplex` = %d,
|
||||||
|
@ -709,13 +688,9 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
|
||||||
`prv` = %d,
|
`prv` = %d,
|
||||||
`network` = '%s' WHERE `id` = %d
|
`network` = '%s' WHERE `id` = %d
|
||||||
",
|
",
|
||||||
dbesc($photos[0]),
|
|
||||||
dbesc($photos[1]),
|
|
||||||
dbesc($photos[2]),
|
|
||||||
intval($new_relation),
|
intval($new_relation),
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
dbesc(datetime_convert()),
|
|
||||||
intval($duplex),
|
intval($duplex),
|
||||||
intval($forum),
|
intval($forum),
|
||||||
intval($prv),
|
intval($prv),
|
||||||
|
|
|
@ -158,13 +158,18 @@ function wall_upload_post(&$a, $desktopmode = true) {
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = q("select sum(octet_length(data)) as total from photo where uid = %d and scale = 0 and album != 'Contact Photos' ",
|
|
||||||
intval($page_owner_uid)
|
|
||||||
);
|
|
||||||
|
|
||||||
$limit = service_class_fetch($page_owner_uid,'photo_upload_limit');
|
$limit = service_class_fetch($page_owner_uid,'photo_upload_limit');
|
||||||
|
|
||||||
if(($limit !== false) && (($r[0]['total'] + strlen($imagedata)) > $limit)) {
|
if ($limit) {
|
||||||
|
$r = q("select sum(octet_length(data)) as total from photo where uid = %d and scale = 0 and album != 'Contact Photos' ",
|
||||||
|
intval($page_owner_uid)
|
||||||
|
);
|
||||||
|
$size = $r[0]['total'];
|
||||||
|
} else
|
||||||
|
$size = 0;
|
||||||
|
|
||||||
|
if(($limit !== false) && (($size + strlen($imagedata)) > $limit)) {
|
||||||
$msg = upgrade_message(true);
|
$msg = upgrade_message(true);
|
||||||
if ($r_json) {
|
if ($r_json) {
|
||||||
echo json_encode(array('error'=>$msg));
|
echo json_encode(array('error'=>$msg));
|
||||||
|
@ -266,6 +271,7 @@ function wall_upload_post(&$a, $desktopmode = true) {
|
||||||
return $picture;
|
return $picture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($r_json) {
|
if ($r_json) {
|
||||||
echo json_encode(array('ok'=>true));
|
echo json_encode(array('ok'=>true));
|
||||||
killme();
|
killme();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
define( 'UPDATE_VERSION' , 1193 );
|
define( 'UPDATE_VERSION' , 1194 );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue