diff options
Diffstat (limited to 'mod/groups')
-rw-r--r-- | mod/groups/actions/forums/deletepost.php | 4 | ||||
-rw-r--r-- | mod/groups/actions/forums/editpost.php | 52 | ||||
-rw-r--r-- | mod/groups/languages/en.php | 3 | ||||
-rw-r--r-- | mod/groups/start.php | 1 | ||||
-rw-r--r-- | mod/groups/views/default/forum/topicposts.php | 44 |
5 files changed, 97 insertions, 7 deletions
diff --git a/mod/groups/actions/forums/deletepost.php b/mod/groups/actions/forums/deletepost.php index 2298a930a..9c89610bb 100644 --- a/mod/groups/actions/forums/deletepost.php +++ b/mod/groups/actions/forums/deletepost.php @@ -21,8 +21,8 @@ if ($post = get_annotation($post_id)) {
- //check that the user can edit
- if ($post->canEdit()) {
+ //check that the user can edit as well as admin
+ if ($post->canEdit() || ($post->owner_guid == $_SESSION['user']->guid)) {
//delete
$post->delete();
diff --git a/mod/groups/actions/forums/editpost.php b/mod/groups/actions/forums/editpost.php new file mode 100644 index 000000000..bd37c5c31 --- /dev/null +++ b/mod/groups/actions/forums/editpost.php @@ -0,0 +1,52 @@ +<?php
+
+ /**
+ * Elgg groups plugin edit post action.
+ *
+ * @package ElggGroups
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider
+ * @copyright Curverider Ltd 2008-2009
+ * @link http://elgg.com/
+ */
+
+ // Make sure we're logged in (send us to the front page if not)
+ if (!isloggedin()) forward();
+
+ // Check the user is a group member
+ $group_guid = get_input('group');
+ $group_entity = get_entity($group_guid);
+ if (!$group_entity->isMember($vars['user'])) forward();
+
+ //get the required variables
+ $post = get_input("post");
+ $post_comment = get_input("postComment");
+ $annotation = get_annotation($post);
+ $commentOwner = get_input("commentOwner");
+ $access_id = get_input("access_id");
+ $topic = get_input("topic");
+
+ if($annotation){
+
+ //can edit? Either the comment owner or admin can
+ if($annotation->canedit() || ($commentOwner == $_SESSION['user']->guid)){
+
+ update_annotation($post, "group_topic_post", $post_comment, "",$commentOwner, $access_id);
+ system_message(elgg_echo("groups:forumpost:edited"));
+
+ }else{
+ system_message(elgg_echo("groups:forumpost:error"));
+ }
+
+ }else{
+
+ system_message(elgg_echo("groups:forumpost:error"));
+ }
+
+ // Forward to the group forum page
+ global $CONFIG;
+ $url = $CONFIG->wwwroot . "mod/groups/topicposts.php?topic={$topic}&group_guid={$group_guid}/";
+ forward($url);
+
+
+?>
\ No newline at end of file diff --git a/mod/groups/languages/en.php b/mod/groups/languages/en.php index ef45d5f57..47f8a10e1 100644 --- a/mod/groups/languages/en.php +++ b/mod/groups/languages/en.php @@ -118,7 +118,8 @@ 'groups:topicisclosed' => 'This topic is closed.',
'groups:topiccloseddesc' => 'This topic has now been closed and is not accepting new comments.',
'grouptopic:error' => 'Your group topic could not be created. Please try again or contact a system administrator.',
-
+ 'groups:forumpost:edited' => "You have successfully edited the forum post.",
+ 'groups:forumpost:error' => "There was a problem editing the forum post.",
'groups:privategroup' => 'This group is private, requesting membership.',
'groups:notitle' => 'Groups must have a title',
'groups:cantjoin' => 'Can not join group',
diff --git a/mod/groups/start.php b/mod/groups/start.php index 043951452..da6001d32 100644 --- a/mod/groups/start.php +++ b/mod/groups/start.php @@ -489,5 +489,6 @@ register_action("groups/edittopic",false,$CONFIG->pluginspath . "groups/actions/forums/edittopic.php");
register_action("groups/deletepost",false,$CONFIG->pluginspath . "groups/actions/forums/deletepost.php");
register_action("groups/featured",false,$CONFIG->pluginspath . "groups/actions/featured.php");
+ register_action("groups/editpost",false,$CONFIG->pluginspath . "groups/actions/forums/editpost.php");
?>
\ No newline at end of file diff --git a/mod/groups/views/default/forum/topicposts.php b/mod/groups/views/default/forum/topicposts.php index 60337522c..99b6b0ee8 100644 --- a/mod/groups/views/default/forum/topicposts.php +++ b/mod/groups/views/default/forum/topicposts.php @@ -12,6 +12,7 @@ * @uses $vars['entity'] The posted comment to view
*/
+
?>
<div class="topic_post"><!-- start the topic_post -->
@@ -47,8 +48,8 @@ </table>
<?php
- //if the comment owner is looking at it, they can edit
- if ($vars['entity']->canEdit()) {
+ //if the comment owner is looking at it, or admin they can edit
+ if ($vars['entity']->canEdit() || ($vars['entity']->owner_guid == $_SESSION['user']->guid)) {
?>
<p class="topic-post-menu">
<?php
@@ -58,8 +59,43 @@ 'text' => elgg_echo('delete'),
'confirm' => elgg_echo('deleteconfirm'),
));
-
- ?>
+
+ //display an edit link that will open up an edit area
+ echo " <a class=\"manifest_details\">edit</a>";
+ echo "<div class=\"manifest_file\">";
+ //get the edit form and details
+ $submit_input = elgg_view('input/submit', array('internalname' => 'submit', 'value' => elgg_echo('save')));
+ $text_textarea = elgg_view('input/longtext', array('internalname' => 'postComment', 'value' => $vars['entity']->value));
+ $post = elgg_view('input/hidden', array('internalname' => 'post', 'value' => $vars['entity']->id));
+ $topic = elgg_view('input/hidden', array('internalname' => 'topic', 'value' => get_input('topic')));
+ $group = elgg_view('input/hidden', array('internalname' => 'group', 'value' => get_input('group_guid')));
+ $commentOwner = elgg_view('input/hidden', array('internalname' => 'commentOwner', 'value' => $vars['entity']->owner_guid));
+ $access = elgg_view('input/hidden', array('internalname' => 'access', 'value' => $vars['entity']->access_id));
+
+ $form_body = <<<EOT
+
+ <div class='edit_forum_comments'>
+ <p>
+ $text_textarea
+ </p>
+ $post
+ $topic
+ $group
+ $commentOwner
+ <p>
+ $submit_input
+ </p>
+
+ </div>
+
+EOT;
+
+?>
+
+ <?php
+ echo elgg_view('input/form', array('action' => "{$vars['url']}action/groups/editpost", 'body' => $form_body, 'internalid' => 'editforumpostForm'));
+ ?>
+ </div>
</p>
<?php
|