aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordave <dave@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-09-21 14:50:23 +0000
committerdave <dave@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-09-21 14:50:23 +0000
commitf1ba6ec14130a5480653745b22de6a001112bddb (patch)
tree2ec0fba80900655965b1c6d88bf4aaa7c22e39a6
parent59f01de10c6a581c074889b96fbe4698ccd47309 (diff)
downloadelgg-f1ba6ec14130a5480653745b22de6a001112bddb.tar.gz
elgg-f1ba6ec14130a5480653745b22de6a001112bddb.tar.bz2
New river code added to allow user comment to be pulled out and displayed
git-svn-id: http://code.elgg.org/elgg/trunk@3490 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--actions/comments/add.php7
-rw-r--r--engine/lib/annotations.php2
-rw-r--r--engine/lib/river2.php18
-rw-r--r--engine/schema/upgrades/2009091901.sql2
-rw-r--r--version.php2
-rw-r--r--views/default/annotation/annotate.php23
6 files changed, 26 insertions, 28 deletions
diff --git a/actions/comments/add.php b/actions/comments/add.php
index 80478b9ad..0f0658837 100644
--- a/actions/comments/add.php
+++ b/actions/comments/add.php
@@ -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(
@@ -36,10 +36,9 @@
$_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 {
diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php
index 49ffc7840..028c33006 100644
--- a/engine/lib/annotations.php
+++ b/engine/lib/annotations.php
@@ -191,7 +191,7 @@
if ($result!==false) {
$obj = get_annotation($result);
if (trigger_elgg_event('create', 'annotation', $obj)) {
- return true;
+ return $result;
} else {
delete_annotation($result);
}
diff --git a/engine/lib/river2.php b/engine/lib/river2.php
index 1a982e6a4..510ec7b8c 100644
--- a/engine/lib/river2.php
+++ b/engine/lib/river2.php
@@ -23,14 +23,8 @@
* @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;
@@ -39,10 +33,9 @@
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} ");
}
@@ -217,7 +211,7 @@
$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
index 000000000..7182c7f76
--- /dev/null
+++ b/engine/schema/upgrades/2009091901.sql
@@ -0,0 +1,2 @@
+-- add an additional column to the river table
+ALTER TABLE `prefix_river` ADD COLUMN `annotation_id` int(11) NOT NULL AFTER `posted`; \ No newline at end of file
diff --git a/version.php b/version.php
index 28466f9cb..58963471a 100644
--- a/version.php
+++ b/version.php
@@ -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
diff --git a/views/default/annotation/annotate.php b/views/default/annotation/annotate.php
index dfff81e83..d2869536a 100644
--- a/views/default/annotation/annotate.php
+++ b/views/default/annotation/annotate.php
@@ -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>";
?>