]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
tags now support avatars on riverdashboard (but no longer support versions of Elgg...
authorCash Costello <cash.costello@gmail.com>
Fri, 29 Oct 2010 11:28:00 +0000 (11:28 +0000)
committerCash Costello <cash.costello@gmail.com>
Fri, 29 Oct 2010 11:28:00 +0000 (11:28 +0000)
actions/addtag.php
languages/en.php
upgrades/2010102801.php [new file with mode: 0644]
views/default/river/object/image/tag.php

index 9e5313b7fac542bb7105178e0db442740c6929ea..97418f495c18091777b361ee7cb410ff0eca528a 100644 (file)
@@ -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) {
index 2a4c63e87e39e7d42b74cc76af5392e395f77245..28a705590509d511419163f9fc3ce145967bb3c0 100644 (file)
@@ -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 (file)
index 0000000..9190912
--- /dev/null
@@ -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);
+                       }
+               }
+       }
+}
index 961761c99cb8791f5eb6b28afda6cfb79c3c2537..a59066c670e83d17201cd38b5ff1cc386133254a 100644 (file)
@@ -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;