]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
New river code added to allow user comment to be pulled out and displayed
authordave <dave@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 21 Sep 2009 14:50:23 +0000 (14:50 +0000)
committerdave <dave@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 21 Sep 2009 14:50:23 +0000 (14:50 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@3490 36083f99-b078-4883-b0ff-0f9b5a30f544

actions/comments/add.php
engine/lib/annotations.php
engine/lib/river2.php
engine/schema/upgrades/2009091901.sql [new file with mode: 0644]
version.php
views/default/annotation/annotate.php

index 80478b9ad063d9ce0db2a5a5fe95414a915d2521..0f0658837a508b08ad4a0da0d853ac834d92830a 100644 (file)
@@ -22,8 +22,8 @@
                if ($entity = get_entity($entity_guid)) {
                        
                // If posting the comment was successful, say so
-                               if ($entity->annotate('generic_comment',$comment_text,$entity->access_id, $_SESSION['guid'])) {
-                                       
+                       $annotation = create_annotation($entity->guid, 'generic_comment', $comment_text, "", $_SESSION['guid'], $entity->access_id);
+                       if ($annotation) {
                                        if ($entity->owner_guid != $_SESSION['user']->getGUID())
                                        notify_user($entity->owner_guid, $_SESSION['user']->getGUID(), elgg_echo('generic_comment:email:subject'), 
                                                sprintf(
                                                                        $_SESSION['user']->getURL()
                                                                )
                                        ); 
-                                       
                                        system_message(elgg_echo("generic_comment:posted"));
                                        //add to river
-                                       add_to_river('annotation/annotate','comment',$_SESSION['user']->guid,$entity->guid);
+                                       add_to_river('annotation/annotate','comment',$_SESSION['user']->guid,$entity->guid, "", 0, $annotation);
 
                                        
                                } else {
index 49ffc7840eca92b2354a41e6b68fe348123e7dc1..028c330065bcf53b7be1766d5f816377770e115c 100644 (file)
                        if ($result!==false) {
                                $obj = get_annotation($result);
                                if (trigger_elgg_event('create', 'annotation', $obj)) {
-                                       return true;
+                                       return $result;
                                } else {
                                        delete_annotation($result);
                                }
index 1a982e6a4e41b46f4cf2b4c1697158c70802ce9b..510ec7b8ceb1ceb4102b9358b580d0cec9d18532 100644 (file)
         * @param int $posted The UNIX epoch timestamp of the river item (default: now)
         * @return true|false Depending on success
         */
-               function add_to_river(
-                                                               $view,
-                                                               $action_type,
-                                                               $subject_guid,
-                                                               $object_guid,
-                                                               $access_id = "",
-                                                               $posted = 0
-                                                         ) {
+               function add_to_river($view,$action_type,$subject_guid,$object_guid,$access_id = "",$posted = 0, $annotation_id = 0)
+               {
                                                                
                        // Sanitise variables
                                if (!elgg_view_exists($view)) return false;
                                if (empty($action_type)) return false;
                                if ($posted == 0) $posted = time();
                                if ($access_id === "") $access_id = $object->access_id;
-                               
+                               $annotation_id = (int)$annotation_id;
                                $type = $object->getType();
                                $subtype = $object->getSubtype();
-                               
                                $action_type = sanitise_string($action_type);
                                
                        // Load config
@@ -57,7 +50,8 @@
                                                                                " view = '{$view}', " .
                                                                                " subject_guid = {$subject_guid}, " .
                                                                                " object_guid = {$object_guid}, " .
-                                                                               " posted = {$posted} ");
+                                                                               " posted = {$posted}, " .
+                                                                               " annotation_id = {$annotation_id} ");
                                                                
                }
                
                                $whereclause = implode(' and ', $where);
                                
                        // Construct main SQL
-                               $sql = "select id,type,subtype,action_type,access_id,view,subject_guid,object_guid,posted from {$CONFIG->dbprefix}river where {$whereclause} order by posted desc limit {$offset},{$limit}";
+                               $sql = "select id,type,subtype,action_type,access_id,view,subject_guid,object_guid,posted,annotation_id from {$CONFIG->dbprefix}river where {$whereclause} order by posted desc limit {$offset},{$limit}";
                                
                        // Get data
                                return get_data($sql);
diff --git a/engine/schema/upgrades/2009091901.sql b/engine/schema/upgrades/2009091901.sql
new file mode 100644 (file)
index 0000000..7182c7f
--- /dev/null
@@ -0,0 +1,2 @@
+-- add an additional column to the river table\r
+ALTER TABLE `prefix_river` ADD COLUMN `annotation_id` int(11) NOT NULL AFTER `posted`;
\ No newline at end of file
index 28466f9cb58795a60c0536e823fff1bba0559088..58963471ac26d008cbe8672f48a06193bdb15316 100644 (file)
@@ -11,7 +11,7 @@
         * @link http://elgg.org/
         */
 
-          $version = 2009072201;  // YYYYMMDD   = Elgg Date
+          $version = 2009091901;  // YYYYMMDD   = Elgg Date
                                   //         XX = Interim incrementer
        
           $release = '1.6.1';    // Human-friendly version name
index dfff81e83ca8ad4e836ad80ba3998b314004a27e..d2869536a07c73c550b33082a1b3e76dce335d1f 100644 (file)
@@ -3,20 +3,23 @@
        $performed_by = get_entity($vars['item']->subject_guid); // $statement->getSubject();
        $object = get_entity($vars['item']->object_guid);
        $url = $object->getURL();
+       $title = $object->title;
+       if(!$title)
+               $title = 'Untitled';
        $subtype = get_subtype_from_id($object->subtype);
-       $comment = $object->getAnnotations("generic_comment", 1, 0, "desc"); 
-       foreach($comment as $c){
-               $contents = $c->value;
-       }
-       $contents = strip_tags($contents);//this is so we don't get large images etc in the activity river
+       //grab the annotation, if one exists
+       if($vars['item']->annotation_id != 0)
+               $comment = get_annotation($vars['item']->annotation_id)->value; 
        $url = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>";
        $string = sprintf(elgg_echo("river:posted:generic"),$url) . " ";
-       $string .= elgg_echo("{$subtype}:river:annotate") . " | <a href=\"" . $object->getURL() . "\">" . $object->title . "</a>";
+       $string .= elgg_echo("{$subtype}:river:annotate") . " | <a href=\"{$object->getURL()}\">" . $title . "</a>";
        $string .= "<div class=\"river_content_display\">";
-       if(strlen($contents) > 200) {
-               $string .= substr($contents, 0, strpos($contents, ' ', 200)) . "...";
-    }else{
-           $string .= $contents;
+       if($comment){
+               $contents = strip_tags($comment);//this is so we don't get large images etc in the activity river
+               if(strlen($contents) > 200)
+                       $string .= substr($contents, 0, strpos($contents, ' ', 200)) . "...";
+           else
+                   $string .= $contents;
     }
        $string .= "</div>";
 ?>