From 9e0d8ea4aa08f6390c0f93f6466c2a101dffcbed Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Fri, 29 Oct 2010 11:28:00 +0000 Subject: tags now support avatars on riverdashboard (but no longer support versions of Elgg < 1.7) --- actions/addtag.php | 5 +++-- languages/en.php | 3 ++- upgrades/2010102801.php | 26 ++++++++++++++++++++++++ views/default/river/object/image/tag.php | 34 ++++++++++++++++++-------------- 4 files changed, 50 insertions(+), 18 deletions(-) create mode 100644 upgrades/2010102801.php diff --git a/actions/addtag.php b/actions/addtag.php index 9e5313b7f..97418f495 100644 --- a/actions/addtag.php +++ b/actions/addtag.php @@ -71,14 +71,15 @@ $owner_id = get_loggedin_userid(); $tagger = get_loggedin_user(); //Save annotation -if ($image->annotate('phototag', serialize($tag), $access_id, $owner_id)) { +$annotation_id = $image->annotate('phototag', serialize($tag), $access_id, $owner_id); +if ($annotation_id) { // if tag is a user id, add relationship for searching (find all images with user x) if ($relationships_type === 'user') { if (!check_entity_relationship($user_id, 'phototag', $image_guid)) { add_entity_relationship($user_id, 'phototag', $image_guid); // also add this to the river - subject is image, object is the tagged user - add_to_river('river/object/image/tag', 'tag', $image_guid, $user_id, $access_id); + add_to_river('river/object/image/tag', 'tag', $tagger->guid, $user_id, $access_id, 0, $annotation_id); // notify user of tagging as long as not self if ($owner_id != $user_id) { diff --git a/languages/en.php b/languages/en.php index 2a4c63e87..28a705590 100644 --- a/languages/en.php +++ b/languages/en.php @@ -161,7 +161,8 @@ The photo can be viewed here: %s", 'image:river:created' => "%s added the photo %s to album %s", 'image:river:item' => "an photo", 'image:river:annotate' => "a comment on the photo", - 'image:river:tagged' => "was tagged in the photo", + 'image:river:tagged' => "%s tagged %s in the photo %s", + 'image:river:tagged:unknown' => "%s tagged %s in a photo", //albums 'album:river:created' => "%s created a new photo album", diff --git a/upgrades/2010102801.php b/upgrades/2010102801.php new file mode 100644 index 000000000..9190912fe --- /dev/null +++ b/upgrades/2010102801.php @@ -0,0 +1,26 @@ +dbprefix}river WHERE view = 'river/object/image/tag'"; +$river_items = mysql_query($query); +while ($item = mysql_fetch_object($river_items)) { + $DB_QUERY_CACHE = $DB_PROFILE = array(); + + // find the annotation for this river item + $annotations = get_annotations($item->subject_guid, '', '', 'phototag', '', 0, 999); + foreach ($annotations as $annotation) { + $tag = unserialize($annotation->value); + if ($tag->type === 'user') { + if ($tag->value == $item->object_guid) { + $update = "UPDATE {$CONFIG->dbprefix}river SET subject_guid = $annotation->owner_guid, annotation_id = $annotation->id where id = $item->id"; + mysql_query($update); + } + } + } +} diff --git a/views/default/river/object/image/tag.php b/views/default/river/object/image/tag.php index 961761c99..a59066c67 100644 --- a/views/default/river/object/image/tag.php +++ b/views/default/river/object/image/tag.php @@ -1,22 +1,26 @@ subject_guid); -$person_tagged = get_entity($vars['item']->object_guid); -if ($image->title) { - $title = $image->title; -} else { - $title = "untitled"; -} - -// viewer may not have permission to view image -if (!$image) { - return; -} +$tagger = get_entity($vars['item']->subject_guid); +$tagged = get_entity($vars['item']->object_guid); +$annotation = get_annotation($vars['item']->annotation_id); +if ($annotation) { + $image = get_entity($annotation->entity_guid); + // viewer may not have permission to view image + if (!$image) { + return; + } -$image_url = "getURL()}\">{$title}"; -$person_url = "getURL()}\">{$person_tagged->name}"; + $image_title = $image->title; +} -$string = $person_url . ' ' . elgg_echo('image:river:tagged') . ' ' . $image_url; +$tagger_link = "getURL()}\">$tagger->name"; +$tagged_link = "getURL()}\">$tagged->name"; +if (!empty($image_title)) { + $image_link = "getURL()}\">$image_title"; + $string = sprintf(elgg_echo('image:river:tagged'), $tagger_link, $tagged_link, $image_link); +} else { + $string = sprintf(elgg_echo('image:river:tagged:unknown'), $tagger_link, $tagged_link); +} echo $string; -- cgit v1.2.3