aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/photo/photo_driver.php26
-rw-r--r--mod/thing.php23
-rw-r--r--version.inc2
3 files changed, 35 insertions, 16 deletions
diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php
index 3d8ee2196..4896f300b 100644
--- a/include/photo/photo_driver.php
+++ b/include/photo/photo_driver.php
@@ -513,20 +513,28 @@ function guess_image_type($filename, $headers = '') {
}
-function import_profile_photo($photo,$xchan) {
+function import_profile_photo($photo,$xchan,$thing = false) {
$a = get_app();
+ $flags = (($thing) ? PHOTO_THING : PHOTO_XCHAN);
+ $album = (($thing) ? 'Things' : 'Contact Photos');
+
logger('import_profile_photo: updating channel photo from ' . $photo . ' for ' . $xchan, LOGGER_DEBUG);
- $r = q("select resource_id from photo where xchan = '%s' and scale = 4 limit 1",
- dbesc($xchan)
- );
- if($r) {
- $hash = $r[0]['resource_id'];
- }
- else {
+ if($thing)
$hash = photo_new_resource();
+ else {
+ $r = q("select resource_id from photo where xchan = '%s' and (photo_flags & %d ) scale = 4 limit 1",
+ dbesc($xchan),
+ intval(PHOTO_XCHAN)
+ );
+ if($r) {
+ $hash = $r[0]['resource_id'];
+ }
+ else {
+ $hash = photo_new_resource();
+ }
}
$photo_failure = false;
@@ -544,7 +552,7 @@ function import_profile_photo($photo,$xchan) {
$img->scaleImageSquare(175);
- $p = array('xchan' => $xchan,'resource_id' => $hash, 'filename' => 'Contact Photos', 'photo_flags' => PHOTO_XCHAN, 'scale' => 4);
+ $p = array('xchan' => $xchan,'resource_id' => $hash, 'filename' => basename($photo), 'album' => $album, 'photo_flags' => $flags, 'scale' => 4);
$r = $img->save($p);
diff --git a/mod/thing.php b/mod/thing.php
index 91bdca78a..955a6c173 100644
--- a/mod/thing.php
+++ b/mod/thing.php
@@ -16,7 +16,7 @@ function thing_init(&$a) {
$verb = escape_tags($_REQUEST['verb']);
$profile_guid = escape_tags($_REQUEST['profile']);
$url = $_REQUEST['link'];
- $photo = $_REQUEST['photo'];
+ $photo = $_REQUEST['img'];
$hash = random_string();
@@ -68,6 +68,14 @@ function thing_init(&$a) {
else
return;
+ $local_photo = null;
+
+ if($photo) {
+ $arr = import_profile_photo($photo,get_observer_hash(),true);
+ $local_photo = $arr[0];
+ $local_photo_type = $arr[3];
+ }
+
$r = q("select * from term where uid = %d and otype = %d and type = %d and term = '%s' limit 1",
intval(local_user()),
@@ -85,7 +93,7 @@ function thing_init(&$a) {
intval(TERM_THING),
dbesc($name),
dbesc(($url) ? $url : z_root() . '/thing/' . $hash),
- dbesc(($photo) ? $photo : ''),
+ dbesc(($photo) ? $local_photo : ''),
dbesc($hash)
);
$r = q("select * from term where uid = %d and otype = %d and type = %d and term = '%s' limit 1",
@@ -113,8 +121,10 @@ function thing_init(&$a) {
info( t('thing/stuff added'));
$arr = array();
- $links = array(array('rel' => 'alternate','type' => 'text/html',
- 'href' => $term['url']));
+ $links = array(array('rel' => 'alternate','type' => 'text/html', 'href' => $term['url']));
+ if($local_photo)
+ $links[] = array('rel' => 'photo', 'type' => $local_photo_type, 'href' => $local_photo);
+
$objtype = ACTIVITY_OBJ_THING;
@@ -139,6 +149,9 @@ function thing_init(&$a) {
$arr['body'] = sprintf( $bodyverb, $ulink, $translated_verb, $plink );
+ if($local_photo)
+ $arr['body'] .= "\n\n[zmg]" . $local_photo . "[/zmg]";
+
$arr['verb'] = $verb;
$arr['obj_type'] = $objtype;
$arr['object'] = $obj;
@@ -161,8 +174,6 @@ function thing_init(&$a) {
$ret = post_activity_item($arr);
- if($ret['success'])
- proc_run('php','include/notifier.php','tag',$ret['activity']['id']);
}
diff --git a/version.inc b/version.inc
index 5f829f0e0..e4679339c 100644
--- a/version.inc
+++ b/version.inc
@@ -1 +1 @@
-2013-12-27.539
+2013-12-28.540