aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-06-13 19:59:20 -0700
committerfriendica <info@friendica.com>2012-06-13 19:59:20 -0700
commit7d8b087f4a90dfa8b69bb7660cf68a2b021a31a2 (patch)
tree852daf8fb843b2f69aa798c69b9bf89d81f17978 /include
parent24bf4632af7b060c9d0cbc39ff9cbc5baee741c3 (diff)
downloadvolse-hubzilla-7d8b087f4a90dfa8b69bb7660cf68a2b021a31a2.tar.gz
volse-hubzilla-7d8b087f4a90dfa8b69bb7660cf68a2b021a31a2.tar.bz2
volse-hubzilla-7d8b087f4a90dfa8b69bb7660cf68a2b021a31a2.zip
fix to imported youtube videos, updating of contact profile photos, do not remove "dead" contacts but archive them.
Diffstat (limited to 'include')
-rw-r--r--include/Contact.php13
-rw-r--r--include/Photo.php113
-rw-r--r--include/queue_fn.php7
-rw-r--r--include/text.php6
4 files changed, 105 insertions, 34 deletions
diff --git a/include/Contact.php b/include/Contact.php
index 675d1c81e..3b255a072 100644
--- a/include/Contact.php
+++ b/include/Contact.php
@@ -146,12 +146,23 @@ function mark_for_death($contact) {
);
}
else {
+
+ // TODO: We really should send a notification to the owner after 2-3 weeks
+ // so they won't be surprised when the contact vanishes and can take
+ // remedial action if this was a serious mistake or glitch
+
$expiry = $contact['term-date'] . ' + 32 days ';
if(datetime_convert() > datetime_convert('UTC','UTC',$expiry)) {
// relationship is really truly dead.
+ // archive them rather than delete
+ // though if the owner tries to unarchive them we'll start the whole process over again
+
+ q("update contact set `archive` = 1 where id = %d limit 1",
+ intval($contact['id'])
+ );
- contact_remove($contact['id']);
+ //contact_remove($contact['id']);
}
}
diff --git a/include/Photo.php b/include/Photo.php
index f769a70a6..da7c49622 100644
--- a/include/Photo.php
+++ b/include/Photo.php
@@ -256,35 +256,81 @@ class Photo {
else
$guid = get_guid();
- $r = q("INSERT INTO `photo`
- ( `uid`, `contact-id`, `guid`, `resource-id`, `created`, `edited`, `filename`, type, `album`, `height`, `width`, `data`, `scale`, `profile`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` )
- VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, '%s', '%s', '%s', '%s' )",
- intval($uid),
- intval($cid),
- dbesc($guid),
- dbesc($rid),
- dbesc(datetime_convert()),
- dbesc(datetime_convert()),
- dbesc(basename($filename)),
- dbesc($this->type),
- dbesc($album),
- intval($this->height),
- intval($this->width),
- dbesc($this->imageString()),
- intval($scale),
- intval($profile),
- dbesc($allow_cid),
- dbesc($allow_gid),
- dbesc($deny_cid),
- dbesc($deny_gid)
+ $x = q("select id from photo where `resource-id` = '%s' and uid = %d and `contact-id` = %d and `scale` = %d limit 1",
+ dbesc($rid),
+ intval($uid),
+ intval($cid),
+ intval($scale)
);
+ if(count($x)) {
+ $r = q("UPDATE `photo`
+ set `uid` = %d,
+ `contact-id` = %d,
+ `guid` = '%s',
+ `resource-id` = '%s',
+ `created` = '%s',
+ `edited` = '%s',
+ `filename` = '%s',
+ `type` = '%s',
+ `album` = '%s',
+ `height` = %d,
+ `width` = %d,
+ `data` = '%s',
+ `scale` = %d,
+ `profile` = %d,
+ `allow_cid` = '%s',
+ `allow_gid` = '%s',
+ `deny_cid` = '%s',
+ `deny_gid` = '%s',
+ where id = %d limit 1",
+
+ intval($uid),
+ intval($cid),
+ dbesc($guid),
+ dbesc($rid),
+ dbesc(datetime_convert()),
+ dbesc(datetime_convert()),
+ dbesc(basename($filename)),
+ dbesc($this->type),
+ dbesc($album),
+ intval($this->height),
+ intval($this->width),
+ dbesc($this->imageString()),
+ intval($scale),
+ intval($profile),
+ dbesc($allow_cid),
+ dbesc($allow_gid),
+ dbesc($deny_cid),
+ dbesc($deny_gid),
+ intval($x[0]['id'])
+ );
+ }
+ else {
+ $r = q("INSERT INTO `photo`
+ ( `uid`, `contact-id`, `guid`, `resource-id`, `created`, `edited`, `filename`, type, `album`, `height`, `width`, `data`, `scale`, `profile`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` )
+ VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, '%s', '%s', '%s', '%s' )",
+ intval($uid),
+ intval($cid),
+ dbesc($guid),
+ dbesc($rid),
+ dbesc(datetime_convert()),
+ dbesc(datetime_convert()),
+ dbesc(basename($filename)),
+ dbesc($this->type),
+ dbesc($album),
+ intval($this->height),
+ intval($this->width),
+ dbesc($this->imageString()),
+ intval($scale),
+ intval($profile),
+ dbesc($allow_cid),
+ dbesc($allow_gid),
+ dbesc($deny_cid),
+ dbesc($deny_gid)
+ );
+ }
return $r;
}
-
-
-
-
-
}}
@@ -326,6 +372,17 @@ function import_profile_photo($photo,$uid,$cid) {
$a = get_app();
+ $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)) {
+ $hash = $r[0]['resource-id'];
+ }
+ else {
+ $hash = photo_new_resource();
+ }
+
$photo_failure = false;
$filename = basename($photo);
@@ -340,8 +397,6 @@ function import_profile_photo($photo,$uid,$cid) {
$img->scaleImageSquare(175);
- $hash = photo_new_resource();
-
$r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 4 );
if($r === false)
@@ -361,8 +416,6 @@ function import_profile_photo($photo,$uid,$cid) {
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();
diff --git a/include/queue_fn.php b/include/queue_fn.php
index 2aca338f5..e43912431 100644
--- a/include/queue_fn.php
+++ b/include/queue_fn.php
@@ -23,6 +23,13 @@ function was_recently_delayed($cid) {
);
if(count($r))
return true;
+
+ $r = q("select `term-date` from contact where id = %d and `term-date` != '' and `term-date` != '0000-00-00 00:00:00' limit 1",
+ intval($cid)
+ );
+ if(count($r))
+ return true;
+
return false;
}
diff --git a/include/text.php b/include/text.php
index 8948bf8c4..cc4bee268 100644
--- a/include/text.php
+++ b/include/text.php
@@ -1255,13 +1255,13 @@ function bb_translate_video($s) {
function html2bb_video($s) {
- $s = preg_replace('#<object[^>]+>(.*?)https+://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+)(.*?)</object>#ism',
+ $s = preg_replace('#<object[^>]+>(.*?)https?://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+)(.*?)</object>#ism',
'[youtube]$2[/youtube]', $s);
- $s = preg_replace('#<iframe[^>](.*?)https+://www.youtube.com/embed/([A-Za-z0-9\-_=]+)(.*?)</iframe>#ism',
+ $s = preg_replace('#<iframe[^>](.*?)https?://www.youtube.com/embed/([A-Za-z0-9\-_=]+)(.*?)</iframe>#ism',
'[youtube]$2[/youtube]', $s);
- $s = preg_replace('#<iframe[^>](.*?)https+://player.vimeo.com/video/([0-9]+)(.*?)</iframe>#ism',
+ $s = preg_replace('#<iframe[^>](.*?)https?://player.vimeo.com/video/([0-9]+)(.*?)</iframe>#ism',
'[vimeo]$2[/vimeo]', $s);
return $s;