aboutsummaryrefslogtreecommitdiff
path: root/mod/groups
diff options
context:
space:
mode:
Diffstat (limited to 'mod/groups')
-rw-r--r--mod/groups/actions/discussion/reply/save.php35
-rw-r--r--mod/groups/actions/groups/membership/join.php4
-rw-r--r--mod/groups/lib/groups.php22
-rw-r--r--mod/groups/start.php48
-rw-r--r--mod/groups/views/default/annotation/group_topic_post.php17
-rw-r--r--mod/groups/views/default/forms/discussion/reply/save.php32
-rw-r--r--mod/groups/views/default/groups/invitationrequests.php2
-rw-r--r--mod/groups/views/default/groups/membershiprequests.php2
-rw-r--r--mod/groups/views/default/plugins/groups/settings.php (renamed from mod/groups/views/default/settings/groups/edit.php)0
-rw-r--r--mod/groups/views/default/widgets/a_users_groups/content.php2
10 files changed, 133 insertions, 31 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..4e2b045a6 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,18 +424,20 @@ 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
if ($group->isMember($user)) {
- // leave
- $url = elgg_get_site_url() . "action/groups/leave?group_guid={$group->getGUID()}";
- $url = elgg_add_action_tokens_to_url($url);
- $actions[$url] = 'groups:leave';
- } else {
+ if ($group->getOwnerGUID() != elgg_get_logged_in_user_guid()) {
+ // leave
+ $url = elgg_get_site_url() . "action/groups/leave?group_guid={$group->getGUID()}";
+ $url = elgg_add_action_tokens_to_url($url);
+ $actions[$url] = 'groups:leave';
+ }
+ } elseif (elgg_is_logged_in()) {
// join - admins can always join.
$url = elgg_get_site_url() . "action/groups/join?group_guid={$group->getGUID()}";
$url = elgg_add_action_tokens_to_url($url);
diff --git a/mod/groups/start.php b/mod/groups/start.php
index 83353bae5..0425bdea6 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'),
+ 'encode_text' => 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'),
+ 'encode_text' => 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/groups/invitationrequests.php b/mod/groups/views/default/groups/invitationrequests.php
index 788788324..9c2df8b9c 100644
--- a/mod/groups/views/default/groups/invitationrequests.php
+++ b/mod/groups/views/default/groups/invitationrequests.php
@@ -10,7 +10,7 @@ if (!empty($vars['invitations']) && is_array($vars['invitations'])) {
echo '<ul class="elgg-list">';
foreach ($vars['invitations'] as $group) {
if ($group instanceof ElggGroup) {
- $icon = elgg_view_entity_icon($group, 'tiny', array('override' => 'true'));
+ $icon = elgg_view_entity_icon($group, 'tiny', array('hover' => 'true'));
$group_title = elgg_view('output/url', array(
'href' => $group->getURL(),
diff --git a/mod/groups/views/default/groups/membershiprequests.php b/mod/groups/views/default/groups/membershiprequests.php
index 4d1c78c8c..7f33b83e0 100644
--- a/mod/groups/views/default/groups/membershiprequests.php
+++ b/mod/groups/views/default/groups/membershiprequests.php
@@ -11,7 +11,7 @@ if (!empty($vars['requests']) && is_array($vars['requests'])) {
echo '<ul class="elgg-list">';
foreach ($vars['requests'] as $user) {
if ($user instanceof ElggUser) {
- $icon = elgg_view_entity_icon($user, 'tiny', array('override' => 'true'));
+ $icon = elgg_view_entity_icon($user, 'tiny', array('hover' => 'true'));
$user_title = elgg_view('output/url', array(
'href' => $user->getURL(),
diff --git a/mod/groups/views/default/settings/groups/edit.php b/mod/groups/views/default/plugins/groups/settings.php
index 7197dcb37..7197dcb37 100644
--- a/mod/groups/views/default/settings/groups/edit.php
+++ b/mod/groups/views/default/plugins/groups/settings.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'),