]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Refs #2679 - returning to a separate annotation for discussion forum replies. For...
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Thu, 3 Mar 2011 01:41:18 +0000 (01:41 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Thu, 3 Mar 2011 01:41:18 +0000 (01:41 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@8570 36083f99-b078-4883-b0ff-0f9b5a30f544

12 files changed:
mod/groups/actions/discussion/reply/delete.php [new file with mode: 0644]
mod/groups/actions/discussion/reply/save.php [new file with mode: 0644]
mod/groups/languages/en.php
mod/groups/lib/discussion.php
mod/groups/lib/groups.php
mod/groups/start.php
mod/groups/views/default/annotation/group_topic_post.php [new file with mode: 0644]
mod/groups/views/default/discussion/replies.php [new file with mode: 0644]
mod/groups/views/default/forms/discussion/reply/save.php [new file with mode: 0644]
mod/groups/views/default/groups/css.php
mod/groups/views/default/object/groupforumtopic.php
mod/groups/views/default/river/annotation/group_topic_post/reply.php [new file with mode: 0644]

diff --git a/mod/groups/actions/discussion/reply/delete.php b/mod/groups/actions/discussion/reply/delete.php
new file mode 100644 (file)
index 0000000..88c6b79
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+/**
+ * Delete discussion reply
+ */
+
+$id = (int) get_input('annotation_id');
+
+$reply = elgg_get_annotation_from_id($id);
+if (!$reply || $reply->name != 'group_topic_post') {
+       register_error(elgg_echo('discussion:reply:error:notdeleted'));
+       forward(REFERER);
+}
+
+if (!$reply->canEdit()) {
+       register_error(elgg_echo('discussion:error:permissions'));
+       forward(REFERER);
+}
+
+$result = $reply->delete();
+if ($result) {
+       system_message(elgg_echo('discussion:reply:deleted'));
+} else {
+       register_error(elgg_echo('discussion:reply:error:notdeleted'));
+}
+
+forward(REFERER);
diff --git a/mod/groups/actions/discussion/reply/save.php b/mod/groups/actions/discussion/reply/save.php
new file mode 100644 (file)
index 0000000..e535856
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+/**
+ * Post a reply to discussion topic
+ *
+ */
+
+gatekeeper();
+
+// Get input
+$entity_guid = (int) get_input('entity_guid');
+$text = get_input('group_topic_post');
+
+// reply cannot be empty
+if (empty($text)) {
+       register_error(elgg_echo('grouppost:nopost'));
+       forward(REFERER);
+}
+
+$topic = get_entity($entity_guid);
+if (!$topic) {
+       register_error(elgg_echo('grouppost:nopost'));
+       forward(REFERER);
+}
+
+$user = get_loggedin_user();
+
+$group = $topic->getContainerEntity();
+if (!$group->isMember($user)) {
+       register_error(elgg_echo('groups:notmember'));
+       forward(REFERER);
+}
+
+
+// add the reply to the forum topic
+$reply_id = $topic->annotate('group_topic_post', $text, $topic->access_id, $user->guid);
+if ($reply_id == false) {
+       system_message(elgg_echo('groupspost:failure'));
+       forward(REFERER);
+}
+
+add_to_river('river/annotation/group_topic_post/reply', 'reply', $user->guid, $topic->guid, "", 0, $reply_id);
+
+system_message(elgg_echo('groupspost:success'));
+
+forward(REFERER);
index c16db859a77460a7a42d621018d6157951603633..91f9f0cb61307654e9d9f6b3cb1b749826307432 100644 (file)
@@ -118,6 +118,9 @@ $english = array(
        'discussion:error:permissions' => 'You do not have permissions to perform this action',
        'discussion:error:notdeleted' => 'Could not delete the discussion topic',
 
+       'discussion:reply:deleted' => 'Discussion reply has been deleted.',
+       'discussion:reply:error:notdeleted' => 'Could not delete the discussion reply',
+
        'group:replies' => 'Replies',
        'groups:forum:created' => 'Created %s with %d comments',
        'groups:forum:created:single' => 'Created %s with %d reply',
@@ -127,7 +130,7 @@ $english = array(
        'groups:latestdiscussion' => 'Latest discussion',
        'groups:newest' => 'Newest',
        'groups:popular' => 'Popular',
-       'groupspost:success' => 'Your comment was succesfully posted',
+       'groupspost:success' => 'Your reply was succesfully posted',
        'groups:alldiscussion' => 'Latest discussion',
        'groups:edittopic' => 'Edit topic',
        'groups:topicmessage' => 'Topic message',
@@ -167,7 +170,7 @@ $english = array(
        'groups:usernotinvited' => 'User could not be invited.',
        'groups:useralreadyinvited' => 'User has already been invited',
        'groups:invite:subject' => "%s you have been invited to join %s!",
-       'groups:updated' => "Last comment by %s %s",
+       'groups:updated' => "Last reply by %s %s",
        'groups:started' => "Started by %s",
        'groups:joinrequest:remove:check' => 'Are you sure you want to remove this join request?',
        'groups:invite:remove:check' => 'Are you sure you want to remove this invite?',
@@ -202,7 +205,7 @@ or click below to view the group's join requests:
        'groups:river:create' => 'created the group',
        'groups:river:join' => 'joined the group',
        'forumtopic:river:create' => 'added a new discussion topic',
-       'river:commented:object:groupforumtopic' => 'the discussion topic',
+       'groups:river:reply' => 'replied on the discussion topic',
        
        'groups:nowidgets' => 'No widgets have been defined for this group.',
 
index 6c86ff83f6ffdafe9350bc78323d0f813a37bc82..2a3de783bbdff29722b1394b3a84a3fa05a814f8 100644 (file)
@@ -14,7 +14,6 @@ function discussion_handle_all_page() {
        $content = elgg_list_entities(array(
                'type' => 'object',
                'subtype' => 'groupforumtopic',
-               'annotation_name' => 'generic_comment',
                'order_by' => 'e.last_action desc',
                'limit' => 40,
                'full_view' => false,
@@ -165,12 +164,21 @@ function discussion_handle_view_page($guid) {
 
        $content = elgg_view_entity($topic, true);
        if ($topic->status == 'closed') {
-               $content .= elgg_view_comments($topic, false);
+               $content .= elgg_view('discussion/replies', array(
+                       'entity' => $topic,
+                       'show_add_form' => false,
+               ));
                $content .= elgg_view('discussion/closed');
        } elseif ($group->isMember() || elgg_is_admin_logged_in()) {
-               $content .= elgg_view_comments($topic);
+               $content .= elgg_view('discussion/replies', array(
+                       'entity' => $topic,
+                       'show_add_form' => true,
+               ));
        } else {
-               $content .= elgg_view_comments($topic, false);
+               $content .= elgg_view('discussion/replies', array(
+                       'entity' => $topic,
+                       'show_add_form' => false,
+               ));
        }
 
        $params = array(
index be9bbfe19cda8eb9326a22b3536bd42c1da60409..563ed3cff84e8f586bd0e761c7220fd665d9a46e 100644 (file)
@@ -27,7 +27,6 @@ function groups_handle_all_page() {
                        $content = elgg_list_entities(array(
                                'type' => 'object',
                                'subtype' => 'groupforumtopic',
-                               'annotation_name' => 'generic_comment',
                                'order_by' => 'e.last_action desc',
                                'limit' => 40,
                                'fullview' => false,
index 61cb89090f0d9e56a82a4675217e1082fc63bafb..26452ebca5d2e2ccb85648197c560c9a842ea1d9 100644 (file)
@@ -83,6 +83,8 @@ function groups_init() {
        elgg_register_event_handler('leave', 'group', 'groups_user_leave_event_listener');
        elgg_register_event_handler('pagesetup', 'system', 'groups_submenus');
        elgg_register_event_handler('annotate', 'all', 'group_object_notifications');
+
+       elgg_register_event_handler('upgrade', 'system', 'groups_run_upgrades');
 }
 
 /**
@@ -481,6 +483,8 @@ function discussion_init() {
        $action_base = elgg_get_plugins_path() . 'groups/actions/discussion';
        elgg_register_action('discussion/save', "$action_base/save.php");
        elgg_register_action('discussion/delete', "$action_base/delete.php");
+       elgg_register_action('discussion/reply/save', "$action_base/reply/save.php");
+       elgg_register_action('discussion/reply/delete', "$action_base/reply/delete.php");
 
        // add link to owner block
        elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'discussion_owner_block_menu');
diff --git a/mod/groups/views/default/annotation/group_topic_post.php b/mod/groups/views/default/annotation/group_topic_post.php
new file mode 100644 (file)
index 0000000..d2303ab
--- /dev/null
@@ -0,0 +1,8 @@
+<?php
+/**
+ * Discussion reply
+ */
+
+$vars['delete_action'] = 'action/discussion/reply/delete';
+
+echo elgg_view('annotation/default', $vars);
diff --git a/mod/groups/views/default/discussion/replies.php b/mod/groups/views/default/discussion/replies.php
new file mode 100644 (file)
index 0000000..2bfb6f0
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+/**
+ * List replies with optional add form
+ *
+ * @uses $vars['entity']        ElggEntity
+ * @uses $vars['show_add_form'] Display add form or not
+ */
+
+$show_add_form = elgg_extract('show_add_form', $vars, true);
+
+echo '<div id="group-replies" class="mtl">';
+
+$options = array(
+       'guid' => $vars['entity']->getGUID(),
+       'annotation_name' => 'group_topic_post',
+);
+$html = elgg_list_annotations($options);
+if ($html) {
+       echo '<h3>' . elgg_echo('group:replies') . '</h3>';
+       echo $html;
+}
+
+if ($show_add_form) {
+       $form_vars = array('class' => 'mtm');
+       echo elgg_view_form('discussion/reply/save', $form_vars, $vars);
+}
+
+echo '</div>';
diff --git a/mod/groups/views/default/forms/discussion/reply/save.php b/mod/groups/views/default/forms/discussion/reply/save.php
new file mode 100644 (file)
index 0000000..6281e94
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+/**
+ * Discussion topic reply form bofy
+ *
+ * @uses $vars['entity']
+ */
+
+
+if (isset($vars['entity']) && elgg_is_logged_in()) {
+?>
+       <div>
+               <label><?php echo elgg_echo("reply"); ?></label>
+               <?php echo elgg_view('input/longtext', array('name' => 'group_topic_post')); ?>
+       </div>
+<?php
+       echo elgg_view('input/submit', array('value' => elgg_echo('reply')));
+
+       echo elgg_view('input/hidden', array(
+               'name' => 'entity_guid',
+               'value' => $vars['entity']->getGUID()
+       ));
+}
index 5276e2bfabd4164e33f1dd4f653c2a75a671263b..545f9c9b3e2ad725085b95143600deb514a3a28e 100644 (file)
@@ -22,7 +22,7 @@
        font-size: 85%;
 }
 
-.groups-latest-comment {
+.groups-latest-reply {
        float: right;
 }
 
index 8a1daece85d6ebca00977cc57bda3eeba540a720..b5efa0e6cffef7aa25eeb2377740390b7cba5303 100644 (file)
@@ -26,18 +26,22 @@ $poster_text = elgg_echo('groups:started', array($poster->name));
 $tags = elgg_view('output/tags', array('tags' => $topic->tags));
 $date = elgg_view_friendly_time($topic->time_created);
 
-$comments_link = '';
-$comments_text = '';
-$num_comments = $topic->countComments();
-if ($num_comments != 0) {
-       $last_comment = $topic->getAnnotations("generic_comment", 1, 0, "desc");
-       $commenter = $last_comment[0]->getOwnerEntity();
-       $comment_time = elgg_view_friendly_time($last_comment[0]->time_created);
-       $comments_text = elgg_echo('groups:updated', array($commenter->name, $comment_time));
+$replies_link = '';
+$replies_text = '';
+$num_replies = elgg_get_annotations(array(
+       'annotation_name' => 'group_topic_post',
+       'guid' => $topic->getGUID(),
+       'count' => true,
+));
+if ($num_replies != 0) {
+       $last_reply = $topic->getAnnotations('group_topic_post', 1, 0, 'desc');
+       $poster = $last_reply[0]->getOwnerEntity();
+       $reply_time = elgg_view_friendly_time($last_reply[0]->time_created);
+       $reply_text = elgg_echo('groups:updated', array($poster->name, $reply_time));
        
-       $comments_link = elgg_view('output/url', array(
-               'href' => $topic->getURL() . '#topic-comments',
-               'text' => elgg_echo("comments") . " ($num_comments)",
+       $replies_link = elgg_view('output/url', array(
+               'href' => $topic->getURL() . '#group-replies',
+               'text' => elgg_echo('group:replies') . " ($num_replies)",
        ));
 }
 
@@ -52,7 +56,7 @@ if (elgg_in_context('widgets')) {
 }
 
 if ($full) {
-       $subtitle = "$poster_text $date $comments_link";
+       $subtitle = "$poster_text $date $replies_link";
 
        $params = array(
                'entity' => $topic,
@@ -75,7 +79,7 @@ HTML;
 
 } else {
        // brief view
-       $subtitle = "$poster_text $date $comments_link <span class=\"groups-latest-comment\">$comments_text</span>";
+       $subtitle = "$poster_text $date $replies_link <span class=\"groups-latest-reply\">$reply_text</span>";
 
        $params = array(
                'entity' => $topic,
diff --git a/mod/groups/views/default/river/annotation/group_topic_post/reply.php b/mod/groups/views/default/river/annotation/group_topic_post/reply.php
new file mode 100644 (file)
index 0000000..f0b7d03
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+/**
+ * Reply river view
+ */
+$object = $vars['item']->getObjectEntity();
+$reply = $vars['item']->getAnnotation();
+
+$url = $object->getURL();
+$title = $object->title;
+$params = array(
+       'href' => $object->getURL(),
+       'text' => $title,
+);
+$object_link = elgg_view('output/url', $params);
+
+$type = $object->getType();
+$subtype = $object->getSubtype();
+
+echo elgg_echo('groups:river:reply') . ' ';
+echo $object_link;
+
+if ($reply) {
+       $excerpt = elgg_get_excerpt($reply->value);
+       echo '<div class="elgg-river-content">';
+       echo $excerpt;
+       echo '</div>';
+}
+