aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-27 15:20:33 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-27 15:20:33 +0000
commit10e5db3119afca7060a680517393518be3aa54ab (patch)
treeec6c1eb164c3d73120bfa2632ebfad3189a94faa /engine
parent5aa81ebf7107556b39336a326abc421d715c3650 (diff)
downloadelgg-10e5db3119afca7060a680517393518be3aa54ab.tar.gz
elgg-10e5db3119afca7060a680517393518be3aa54ab.tar.bz2
Brought generic comments into Elgg core
git-svn-id: https://code.elgg.org/elgg/trunk@1185 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/elgglib.php35
1 files changed, 30 insertions, 5 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index 3b8e444d7..d4feabf53 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -321,7 +321,7 @@
$name = get_metastring($intname);
}
if (empty($name)) { return ""; }
-
+
if (elgg_view_exists("annotation/{$name}")) {
return elgg_view("annotation/{$name}",array(
'annotation' => $annotation,
@@ -413,7 +413,7 @@
));
$html .= $nav;
-
+
if (is_array($annotations) && sizeof($annotations) > 0) {
foreach($annotations as $annotation) {
$html .= elgg_view_annotation($annotation, "", false);
@@ -422,7 +422,7 @@
if ($count)
$html .= $nav;
-
+
return $html;
}
@@ -464,6 +464,25 @@
}
/**
+ * Automatically views comments and a comment form relating to the given entity
+ *
+ * @param ElggEntity $entity The entity to comment on
+ * @return string|false The HTML (etc) for the comments, or false on failure
+ */
+ function elgg_view_comments($entity){
+
+ if (!($entity instanceof ElggEntity)) return false;
+
+ $comments = list_annotations($entity->getGUID(),'generic_comment');
+
+ //display the comment form
+ $comments .= elgg_view('comments/forms/edit',array('entity' => $entity));
+
+ return $comments;
+
+ }
+
+ /**
* Wrapper function to display search listings.
*
* @param string $icon The icon for the listing
@@ -1491,7 +1510,13 @@
$port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
return $protocol . "://" . $_SERVER['SERVER_NAME'] . $port . $_SERVER['REQUEST_URI'];
}
-
-
+
+ function elgg_init() {
+ // Important actions
+ register_action('comments/add');
+ register_action('comments/delete');
+ }
+
+ register_elgg_event_handler('init','system','elgg_init');
?> \ No newline at end of file