aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/addtag.php5
-rw-r--r--languages/en.php3
-rw-r--r--upgrades/2010102801.php26
-rw-r--r--views/default/river/object/image/tag.php34
4 files changed, 50 insertions, 18 deletions
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 @@
+<?php
+/**
+ * Convert river entries for tags to be tagger-tagee-annotation from
+ * image-tagee
+ */
+
+$album_subtype_id = get_subtype_id('object', 'album');
+
+global $DB_QUERY_CACHE, $DB_PROFILE, $ENTITY_CACHE, $CONFIG;
+$query = "SELECT * FROM {$CONFIG->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 @@
<?php
-$image = get_entity($vars['item']->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 = "<a href=\"{$image->getURL()}\">{$title}</a>";
-$person_url = "<a href=\"{$person_tagged->getURL()}\">{$person_tagged->name}</a>";
+ $image_title = $image->title;
+}
-$string = $person_url . ' ' . elgg_echo('image:river:tagged') . ' ' . $image_url;
+$tagger_link = "<a href=\"{$tagger->getURL()}\">$tagger->name</a>";
+$tagged_link = "<a href=\"{$tagged->getURL()}\">$tagged->name</a>";
+if (!empty($image_title)) {
+ $image_link = "<a href=\"{$image->getURL()}\">$image_title</a>";
+ $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;