diff options
Diffstat (limited to 'mod/groups')
-rw-r--r-- | mod/groups/actions/discussion/reply/save.php | 35 | ||||
-rw-r--r-- | mod/groups/actions/groups/membership/join.php | 4 | ||||
-rw-r--r-- | mod/groups/lib/groups.php | 10 | ||||
-rw-r--r-- | mod/groups/start.php | 48 | ||||
-rw-r--r-- | mod/groups/views/default/annotation/group_topic_post.php | 17 | ||||
-rw-r--r-- | mod/groups/views/default/forms/discussion/reply/save.php | 32 | ||||
-rw-r--r-- | mod/groups/views/default/widgets/a_users_groups/content.php | 2 |
7 files changed, 124 insertions, 24 deletions
diff --git a/mod/groups/actions/discussion/reply/save.php b/mod/groups/actions/discussion/reply/save.php index 109938dbb..a1ed036b6 100644 --- a/mod/groups/actions/discussion/reply/save.php +++ b/mod/groups/actions/discussion/reply/save.php @@ -9,6 +9,7 @@ gatekeeper(); // Get input $entity_guid = (int) get_input('entity_guid'); $text = get_input('group_topic_post'); +$annotation_id = (int) get_input('annotation_id'); // reply cannot be empty if (empty($text)) { @@ -30,16 +31,30 @@ if (!$group->canWriteToContainer($user)) { 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); +// if editing a reply, make sure it's valid +if ($annotation_id) { + $annotation = elgg_get_annotation_from_id($annotation_id); + if (!$annotation->canEdit()) { + register_error(elgg_echo('groups:notowner')); + forward(REFERER); + } + + $annotation->value = $text; + if (!$annotation->save()) { + system_message(elgg_echo('groups:forumpost:error')); + forward(REFERER); + } + system_message(elgg_echo('groups:forumpost:edited')); +} else { + // 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')); } -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); diff --git a/mod/groups/actions/groups/membership/join.php b/mod/groups/actions/groups/membership/join.php index 210e285a5..b4f4e280c 100644 --- a/mod/groups/actions/groups/membership/join.php +++ b/mod/groups/actions/groups/membership/join.php @@ -10,6 +10,8 @@ * @package ElggGroups */ +global $CONFIG; + $user_guid = get_input('user_guid', elgg_get_logged_in_user_guid()); $group_guid = get_input('group_guid'); @@ -45,7 +47,7 @@ if (($user instanceof ElggUser) && ($group instanceof ElggGroup)) { add_entity_relationship($user->guid, 'membership_request', $group->guid); // Notify group owner - $url = "{$CONFIG->url}mod/groups/membershipreq.php?group_guid={$group->guid}"; + $url = "{$CONFIG->url}groups/requests/$group->guid"; $subject = elgg_echo('groups:request:subject', array( $user->name, $group->name, diff --git a/mod/groups/lib/groups.php b/mod/groups/lib/groups.php index 126738566..86e6f018e 100644 --- a/mod/groups/lib/groups.php +++ b/mod/groups/lib/groups.php @@ -17,7 +17,7 @@ function groups_handle_all_page() { $selected_tab = get_input('filter', 'newest'); switch ($selected_tab) { - case 'pop': + case 'popular': $content = elgg_list_entities_from_relationship_count(array( 'type' => 'group', 'relationship' => 'member', @@ -25,7 +25,7 @@ function groups_handle_all_page() { 'full_view' => false, )); break; - case 'active': + case 'discussion': $content = elgg_list_entities(array( 'type' => 'object', 'subtype' => 'groupforumtopic', @@ -198,7 +198,7 @@ function groups_handle_invitations_page() { elgg_push_breadcrumb($title); // @todo temporary workaround for exts #287. - $invitations = groups_get_invited_groups($user->getGUID()); + $invitations = groups_get_invited_groups(elgg_get_logged_in_user_guid()); $content = elgg_view('groups/invitationrequests', array('invitations' => $invitations)); $params = array( @@ -424,9 +424,9 @@ function groups_register_profile_buttons($group) { if ($group->canEdit()) { // edit and invite $url = elgg_get_site_url() . "groups/edit/{$group->getGUID()}"; - $actions[$url] = elgg_echo('groups:edit'); + $actions[$url] = 'groups:edit'; $url = elgg_get_site_url() . "groups/invite/{$group->getGUID()}"; - $actions[$url] = elgg_echo('groups:invite'); + $actions[$url] = 'groups:invite'; } // group members diff --git a/mod/groups/start.php b/mod/groups/start.php index 83353bae5..9e4694457 100644 --- a/mod/groups/start.php +++ b/mod/groups/start.php @@ -65,6 +65,9 @@ function groups_init() { // group user hover menu elgg_register_plugin_hook_handler('register', 'menu:user_hover', 'groups_user_entity_menu_setup'); + // delete and edit annotations for topic replies + elgg_register_plugin_hook_handler('register', 'menu:annotation', 'groups_annotation_menu_setup'); + //extend some views elgg_extend_view('css/elgg', 'groups/css'); elgg_extend_view('js/elgg', 'groups/js'); @@ -409,6 +412,51 @@ function groups_user_entity_menu_setup($hook, $type, $return, $params) { } /** + * Add edit and delete links for forum replies + */ +function groups_annotation_menu_setup($hook, $type, $return, $params) { + if (elgg_in_context('widgets')) { + return $return; + } + + $annotation = $params['annotation']; + + if ($annotation->name != 'group_topic_post') { + return $return; + } + + if ($annotation->canEdit()) { + $url = elgg_http_add_url_query_elements('action/discussion/reply/delete', array( + 'annotation_id' => $annotation->id, + )); + + $options = array( + 'name' => 'delete', + 'href' => $url, + 'text' => "<span class=\"elgg-icon elgg-icon-delete\"></span>", + 'confirm' => elgg_echo('deleteconfirm'), + 'text_encode' => false + ); + $return[] = ElggMenuItem::factory($options); + + $url = elgg_http_add_url_query_elements('discussion', array( + 'annotation_id' => $annotation->id, + )); + + $options = array( + 'name' => 'edit', + 'href' => "#edit-annotation-$annotation->id", + 'text' => elgg_echo('edit'), + 'text_encode' => false, + 'rel' => 'toggle', + ); + $return[] = ElggMenuItem::factory($options); + } + + return $return; +} + +/** * Groups created so create an access list for it */ function groups_create_event_listener($event, $object_type, $object) { diff --git a/mod/groups/views/default/annotation/group_topic_post.php b/mod/groups/views/default/annotation/group_topic_post.php index d2303aba8..f38d2a77a 100644 --- a/mod/groups/views/default/annotation/group_topic_post.php +++ b/mod/groups/views/default/annotation/group_topic_post.php @@ -1,8 +1,19 @@ <?php -/** - * Discussion reply +/* + * Embeds an edit link for the annotation */ -$vars['delete_action'] = 'action/discussion/reply/delete'; +$annotation = elgg_extract('annotation', $vars); echo elgg_view('annotation/default', $vars); + +if ($annotation->canEdit()) { + $form = elgg_view_form('discussion/reply/save', array(), array_merge(array( + 'entity' => get_entity($annotation->entity_guid), + 'annotation' => $annotation + ), $vars) + ); + + echo "<div class=\"hidden mbm\" id=\"edit-annotation-$annotation->id\">$form</div>"; +} + diff --git a/mod/groups/views/default/forms/discussion/reply/save.php b/mod/groups/views/default/forms/discussion/reply/save.php index 40ea07303..083fefb78 100644 --- a/mod/groups/views/default/forms/discussion/reply/save.php +++ b/mod/groups/views/default/forms/discussion/reply/save.php @@ -6,7 +6,6 @@ * @uses $vars['inline'] Display a shortened form? */ - if (isset($vars['entity']) && elgg_is_logged_in()) { echo elgg_view('input/hidden', array( 'name' => 'entity_guid', @@ -14,18 +13,43 @@ if (isset($vars['entity']) && elgg_is_logged_in()) { )); $inline = elgg_extract('inline', $vars, false); + + $annotation = elgg_extract('annotation', $vars); + + $value = ''; + + if ($annotation) { + $value = $annotation->value; + echo elgg_view('input/hidden', array( + 'name' => 'annotation_id', + 'value' => $annotation->id + )); + } + if ($inline) { - echo elgg_view('input/text', array('name' => 'group_topic_post')); + echo elgg_view('input/text', array('name' => 'group_topic_post', 'value' => $value)); echo elgg_view('input/submit', array('value' => elgg_echo('reply'))); } else { ?> <div> - <label><?php echo elgg_echo("reply"); ?></label> - <?php echo elgg_view('input/longtext', array('name' => 'group_topic_post')); ?> + <label> + <?php + if ($annotation) { + echo elgg_echo('edit'); + } else { + echo elgg_echo("reply"); + } + ?> + </label> + <?php echo elgg_view('input/longtext', array('name' => 'group_topic_post', 'value' => $value)); ?> </div> <div class="elgg-foot"> <?php + if ($annotation) { + echo elgg_view('input/submit', array('value' => elgg_echo('save'))); + } else { echo elgg_view('input/submit', array('value' => elgg_echo('reply'))); + } ?> </div> <?php diff --git a/mod/groups/views/default/widgets/a_users_groups/content.php b/mod/groups/views/default/widgets/a_users_groups/content.php index 81d355442..114fd7565 100644 --- a/mod/groups/views/default/widgets/a_users_groups/content.php +++ b/mod/groups/views/default/widgets/a_users_groups/content.php @@ -21,7 +21,7 @@ $content = elgg_list_entities_from_relationship($options); echo $content; if ($content) { - $url = "group/member/" . elgg_get_page_owner_entity()->username; + $url = "groups/member/" . elgg_get_page_owner_entity()->username; $more_link = elgg_view('output/url', array( 'href' => $url, 'text' => elgg_echo('groups:more'), |