aboutsummaryrefslogtreecommitdiff
path: root/mod/groups
diff options
context:
space:
mode:
Diffstat (limited to 'mod/groups')
-rw-r--r--mod/groups/actions/discussion/reply/save.php6
-rw-r--r--mod/groups/actions/discussion/save.php2
-rw-r--r--mod/groups/actions/groups/edit.php20
-rw-r--r--mod/groups/actions/groups/membership/delete_invite.php4
-rw-r--r--mod/groups/icon.php12
-rw-r--r--mod/groups/languages/en.php12
-rw-r--r--mod/groups/lib/discussion.php6
-rw-r--r--mod/groups/lib/groups.php6
-rw-r--r--mod/groups/start.php56
-rw-r--r--mod/groups/upgrades/2011030101.php16
-rw-r--r--mod/groups/views/default/forms/groups/find.php16
-rw-r--r--mod/groups/views/default/forms/groups/search.php14
-rw-r--r--mod/groups/views/default/group/default.php3
-rw-r--r--mod/groups/views/default/groups/group_sort_menu.php10
-rw-r--r--mod/groups/views/default/groups/js.php3
-rw-r--r--mod/groups/views/default/groups/sidebar/find.php2
-rw-r--r--mod/groups/views/default/groups/sidebar/members.php3
-rw-r--r--mod/groups/views/default/groups/sidebar/search.php15
18 files changed, 129 insertions, 77 deletions
diff --git a/mod/groups/actions/discussion/reply/save.php b/mod/groups/actions/discussion/reply/save.php
index a1ed036b6..f8be8aa2c 100644
--- a/mod/groups/actions/discussion/reply/save.php
+++ b/mod/groups/actions/discussion/reply/save.php
@@ -4,8 +4,6 @@
*
*/
-gatekeeper();
-
// Get input
$entity_guid = (int) get_input('entity_guid');
$text = get_input('group_topic_post');
@@ -23,10 +21,10 @@ if (!$topic) {
forward(REFERER);
}
-$user = get_loggedin_user();
+$user = elgg_get_logged_in_user_entity();
$group = $topic->getContainerEntity();
-if (!$group->canWriteToContainer($user)) {
+if (!$group->canWriteToContainer()) {
register_error(elgg_echo('groups:notmember'));
forward(REFERER);
}
diff --git a/mod/groups/actions/discussion/save.php b/mod/groups/actions/discussion/save.php
index a51775cd6..de4afadfb 100644
--- a/mod/groups/actions/discussion/save.php
+++ b/mod/groups/actions/discussion/save.php
@@ -21,7 +21,7 @@ if (!$title || !$desc) {
}
$container = get_entity($container_guid);
-if (!$container || !$container->canWriteToContainer()) {
+if (!$container || !$container->canWriteToContainer(0, 'object', 'groupforumtopic')) {
register_error(elgg_echo('discussion:error:permissions'));
forward(REFERER);
}
diff --git a/mod/groups/actions/groups/edit.php b/mod/groups/actions/groups/edit.php
index c4cf6667e..b513a6098 100644
--- a/mod/groups/actions/groups/edit.php
+++ b/mod/groups/actions/groups/edit.php
@@ -89,14 +89,10 @@ if ($new_group_flag) {
$group->save();
-// group creator needs to be member of new group and river entry created
-if ($new_group_flag) {
- elgg_set_page_owner_guid($group->guid);
- $group->join($user);
- add_to_river('river/group/create', 'create', $user->guid, $group->guid);
-}
-
// Invisible group support
+// @todo this requires save to be called to create the acl for the group. This
+// is an odd requirement and should be removed. Either the acl creation happens
+// in the action or the visibility moves to a plugin hook
if (elgg_get_plugin_setting('hidden_groups', 'groups') == 'yes') {
$visibility = (int)get_input('vis', '', false);
if ($visibility != ACCESS_PUBLIC && $visibility != ACCESS_LOGGED_IN) {
@@ -105,10 +101,18 @@ if (elgg_get_plugin_setting('hidden_groups', 'groups') == 'yes') {
if ($group->access_id != $visibility) {
$group->access_id = $visibility;
- $group->save();
}
}
+$group->save();
+
+// group creator needs to be member of new group and river entry created
+if ($new_group_flag) {
+ elgg_set_page_owner_guid($group->guid);
+ $group->join($user);
+ add_to_river('river/group/create', 'create', $user->guid, $group->guid, $group->access_id);
+}
+
// Now see if we have a file icon
if ((isset($_FILES['icon'])) && (substr_count($_FILES['icon']['type'],'image/'))) {
diff --git a/mod/groups/actions/groups/membership/delete_invite.php b/mod/groups/actions/groups/membership/delete_invite.php
index 4b654f0b6..d21aa0309 100644
--- a/mod/groups/actions/groups/membership/delete_invite.php
+++ b/mod/groups/actions/groups/membership/delete_invite.php
@@ -9,7 +9,11 @@ $user_guid = get_input('user_guid', elgg_get_logged_in_user_guid());
$group_guid = get_input('group_guid');
$user = get_entity($user_guid);
+
+// invisible groups require overriding access to delete invite
+$old_access = elgg_set_ignore_access(true);
$group = get_entity($group_guid);
+elgg_set_ignore_access($old_access);
// If join request made
if (check_entity_relationship($group->guid, 'invited', $user->guid)) {
diff --git a/mod/groups/icon.php b/mod/groups/icon.php
index f4c0f8010..f86f84fa5 100644
--- a/mod/groups/icon.php
+++ b/mod/groups/icon.php
@@ -10,8 +10,15 @@ require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
$group_guid = get_input('group_guid');
$group = get_entity($group_guid);
+// If is the same ETag, content didn't changed.
+$etag = $group->icontime . $group_guid;
+if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag) {
+ header("HTTP/1.1 304 Not Modified");
+ exit;
+}
+
$size = strtolower(get_input('size'));
-if (!in_array($size,array('large','medium','small','tiny','master','topbar')))
+if (!in_array($size, array('large', 'medium', 'small', 'tiny', 'master', 'topbar')))
$size = "medium";
$success = false;
@@ -28,7 +35,7 @@ if ($filehandler->open("read")) {
}
if (!$success) {
- $location = elgg_get_plugins_path() . "groups/graphics/default{$size}.jpg";
+ $location = elgg_get_plugins_path() . "groups/graphics/default{$size}.gif";
$contents = @file_get_contents($location);
}
@@ -37,4 +44,5 @@ header('Expires: ' . date('r',time() + 864000));
header("Pragma: public");
header("Cache-Control: public");
header("Content-Length: " . strlen($contents));
+header("ETag: $etag");
echo $contents;
diff --git a/mod/groups/languages/en.php b/mod/groups/languages/en.php
index 09feaf8d1..e51e51a14 100644
--- a/mod/groups/languages/en.php
+++ b/mod/groups/languages/en.php
@@ -61,6 +61,18 @@ $english = array(
'groups:search:tags' => "tag",
'groups:search:title' => "Search for groups tagged with '%s'",
'groups:search:none' => "No matching groups were found",
+ 'groups:search_in_group' => "Search in this group",
+ 'groups:acl' => "Group: %s",
+
+ 'groups:notification' =>
+'%s added a new discussion topic to %s:
+
+%s
+%s
+
+View and reply to the discussion:
+%s
+',
'groups:activity' => "Group activity",
'groups:enableactivity' => 'Enable group activity',
diff --git a/mod/groups/lib/discussion.php b/mod/groups/lib/discussion.php
index 2bda4678e..55642644d 100644
--- a/mod/groups/lib/discussion.php
+++ b/mod/groups/lib/discussion.php
@@ -92,8 +92,8 @@ function discussion_handle_edit_page($type, $guid) {
forward();
}
- // make sure user has permissions to write to container
- if (!$group->canWriteToContainer()) {
+ // make sure user has permissions to add a topic to container
+ if (!$group->canWriteToContainer(0, 'object', 'groupforumtopic')) {
register_error(elgg_echo('groups:permissions:error'));
forward($group->getURL());
}
@@ -173,7 +173,7 @@ function discussion_handle_view_page($guid) {
'show_add_form' => false,
));
$content .= elgg_view('discussion/closed');
- } elseif ($group->canWriteToContainer() || elgg_is_admin_logged_in()) {
+ } elseif ($group->canWriteToContainer(0, 'object', 'groupforumtopic') || elgg_is_admin_logged_in()) {
$content .= elgg_view('discussion/replies', array(
'entity' => $topic,
'show_add_form' => true,
diff --git a/mod/groups/lib/groups.php b/mod/groups/lib/groups.php
index f8ff2d74b..498766df0 100644
--- a/mod/groups/lib/groups.php
+++ b/mod/groups/lib/groups.php
@@ -249,7 +249,11 @@ function groups_handle_profile_page($guid) {
$content = elgg_view('groups/profile/layout', array('entity' => $group));
if (group_gatekeeper(false)) {
- $sidebar = elgg_view('groups/sidebar/members', array('entity' => $group));
+ $sidebar = '';
+ if (elgg_is_active_plugin('search')) {
+ $sidebar .= elgg_view('groups/sidebar/search', array('entity' => $group));
+ }
+ $sidebar .= elgg_view('groups/sidebar/members', array('entity' => $group));
} else {
$sidebar = '';
}
diff --git a/mod/groups/start.php b/mod/groups/start.php
index 09362cbbc..aeab0649a 100644
--- a/mod/groups/start.php
+++ b/mod/groups/start.php
@@ -663,7 +663,7 @@ function group_access_options($group) {
ACCESS_PRIVATE => 'private',
ACCESS_LOGGED_IN => 'logged in users',
ACCESS_PUBLIC => 'public',
- $group->group_acl => 'Group: ' . $group->name,
+ $group->group_acl => elgg_echo('groups:acl', array($group->name)),
);
return $access_array;
}
@@ -741,7 +741,6 @@ function discussion_init() {
// notifications
register_notification_object('object', 'groupforumtopic', elgg_echo('groupforumtopic:new'));
- elgg_register_plugin_hook_handler('object:notifications', 'object', 'group_object_notifications_intercept');
elgg_register_plugin_hook_handler('notify:entity:message', 'object', 'groupforumtopic_notify_message');
}
@@ -855,41 +854,19 @@ function discussion_add_to_river_menu($hook, $type, $return, $params) {
function group_object_notifications($event, $object_type, $object) {
static $flag;
- if (!isset($flag))
+ if (!isset($flag)) {
$flag = 0;
+ }
if (is_callable('object_notifications'))
if ($object instanceof ElggObject) {
if ($object->getSubtype() == 'groupforumtopic') {
- //if ($object->countAnnotations('group_topic_post') > 0) {
if ($flag == 0) {
$flag = 1;
object_notifications($event, $object_type, $object);
}
- //}
- }
- }
-}
-
-/**
- * Intercepts the notification on group topic creation and prevents a notification from going out
- * (because one will be sent on the annotation)
- *
- * @param unknown_type $hook
- * @param unknown_type $entity_type
- * @param unknown_type $returnvalue
- * @param unknown_type $params
- * @return unknown
- */
-function group_object_notifications_intercept($hook, $entity_type, $returnvalue, $params) {
- if (isset($params)) {
- if ($params['event'] == 'create' && $params['object'] instanceof ElggObject) {
- if ($params['object']->getSubtype() == 'groupforumtopic') {
- return true;
}
}
- }
- return null;
}
/**
@@ -904,26 +881,23 @@ function groupforumtopic_notify_message($hook, $entity_type, $returnvalue, $para
$entity = $params['entity'];
$to_entity = $params['to_entity'];
$method = $params['method'];
- if (($entity instanceof ElggEntity) && ($entity->getSubtype() == 'groupforumtopic')) {
+ if (($entity instanceof ElggEntity) && ($entity->getSubtype() == 'groupforumtopic')) {
$descr = $entity->description;
$title = $entity->title;
$url = $entity->getURL();
-
- $msg = get_input('topicmessage');
- if (empty($msg))
- $msg = get_input('topic_post');
- if (!empty($msg))
- $msg = $msg . "\n\n"; else
- $msg = '';
-
- $owner = get_entity($entity->container_guid);
- if ($method == 'sms') {
- return elgg_echo("groupforumtopic:new") . ': ' . $url . " ({$owner->name}: {$title})";
- } else {
- return elgg_get_logged_in_user_entity()->name . ' ' . elgg_echo("groups:viagroups") . ': ' . $title . "\n\n" . $msg . "\n\n" . $entity->getURL();
- }
+ $owner = $entity->getOwnerEntity();
+ $group = $entity->getContainerEntity();
+
+ return elgg_echo('groups:notification', array(
+ $owner->name,
+ $group->name,
+ $entity->title,
+ $entity->description,
+ $entity->getURL()
+ ));
}
+
return null;
}
diff --git a/mod/groups/upgrades/2011030101.php b/mod/groups/upgrades/2011030101.php
index c2a80c08c..55edb1a16 100644
--- a/mod/groups/upgrades/2011030101.php
+++ b/mod/groups/upgrades/2011030101.php
@@ -9,6 +9,7 @@ $topics = elgg_get_entities(array(
'type' => 'object',
'subtype' => 'groupforumtopic',
'limit' => 5,
+ 'order_by' => 'e.time_created asc',
));
// if not topics, no upgrade required
@@ -25,12 +26,17 @@ foreach ($topics as $topic) {
/**
- * Condense annotation into object
+ * Condense first annotation into object
*
* @param ElggObject $topic
*/
function groups_2011030101($topic) {
+ // do not upgrade topics that have already been upgraded
+ if ($topic->description) {
+ return true;
+ }
+
$annotation = $topic->getAnnotations('group_topic_post', 1);
if (!$annotation) {
// no text for this forum post so we delete (probably caused by #2624)
@@ -43,8 +49,14 @@ function groups_2011030101($topic) {
return $annotation[0]->delete();
}
-$options = array('type' => 'object', 'subtype' => 'groupforumtopic');
+$previous_access = elgg_set_ignore_access(true);
+$options = array(
+ 'type' => 'object',
+ 'subtype' => 'groupforumtopic',
+ 'limit' => 0,
+);
$batch = new ElggBatch('elgg_get_entities', $options, 'groups_2011030101', 100);
+elgg_set_ignore_access($previous_access);
if ($batch->callbackResult) {
error_log("Elgg Groups upgrade (2011030101) succeeded");
diff --git a/mod/groups/views/default/forms/groups/find.php b/mod/groups/views/default/forms/groups/find.php
new file mode 100644
index 000000000..ddf639b74
--- /dev/null
+++ b/mod/groups/views/default/forms/groups/find.php
@@ -0,0 +1,16 @@
+<?php
+/**
+ * Group tag-based search form body
+ */
+
+$tag_string = elgg_echo('groups:search:tags');
+
+$params = array(
+ 'name' => 'tag',
+ 'class' => 'elgg-input-search mbm',
+ 'value' => $tag_string,
+ 'onclick' => "if (this.value=='$tag_string') { this.value='' }",
+);
+echo elgg_view('input/text', $params);
+
+echo elgg_view('input/submit', array('value' => elgg_echo('search:go')));
diff --git a/mod/groups/views/default/forms/groups/search.php b/mod/groups/views/default/forms/groups/search.php
index ddf639b74..850b6088e 100644
--- a/mod/groups/views/default/forms/groups/search.php
+++ b/mod/groups/views/default/forms/groups/search.php
@@ -1,16 +1,20 @@
<?php
/**
- * Group tag-based search form body
+ * Group search form
+ *
+ * @uses $vars['entity'] ElggGroup
*/
-$tag_string = elgg_echo('groups:search:tags');
-
$params = array(
- 'name' => 'tag',
+ 'name' => 'q',
'class' => 'elgg-input-search mbm',
'value' => $tag_string,
- 'onclick' => "if (this.value=='$tag_string') { this.value='' }",
);
echo elgg_view('input/text', $params);
+echo elgg_view('input/hidden', array(
+ 'name' => 'container_guid',
+ 'value' => $vars['entity']->getGUID(),
+));
+
echo elgg_view('input/submit', array('value' => elgg_echo('search:go')));
diff --git a/mod/groups/views/default/group/default.php b/mod/groups/views/default/group/default.php
index 6eae467c6..d9460dff4 100644
--- a/mod/groups/views/default/group/default.php
+++ b/mod/groups/views/default/group/default.php
@@ -22,10 +22,9 @@ if (elgg_in_context('owner_block') || elgg_in_context('widgets')) {
if ($vars['full_view']) {
- echo elgg_view("groups/profile/profile_block", $vars);
+ echo elgg_view('groups/profile/summary', $vars);
} else {
// brief view
-
$params = array(
'entity' => $group,
'metadata' => $metadata,
diff --git a/mod/groups/views/default/groups/group_sort_menu.php b/mod/groups/views/default/groups/group_sort_menu.php
index c53b49c8e..f5631a31f 100644
--- a/mod/groups/views/default/groups/group_sort_menu.php
+++ b/mod/groups/views/default/groups/group_sort_menu.php
@@ -2,6 +2,7 @@
/**
* All groups listing page navigation
*
+ * @uses $vars['selected'] Name of the tab that has been selected
*/
$tabs = array(
@@ -22,14 +23,13 @@ $tabs = array(
),
);
-// sets default selected item
-if (strpos(full_url(), 'filter') === false) {
- $tabs['newest']['selected'] = true;
-}
-
foreach ($tabs as $name => $tab) {
$tab['name'] = $name;
+ if ($vars['selected'] == $name) {
+ $tab['selected'] = true;
+ }
+
elgg_register_menu_item('filter', $tab);
}
diff --git a/mod/groups/views/default/groups/js.php b/mod/groups/views/default/groups/js.php
index ad742445b..1b4d33f32 100644
--- a/mod/groups/views/default/groups/js.php
+++ b/mod/groups/views/default/groups/js.php
@@ -1,5 +1,6 @@
-$(function() {
+// this adds a class to support IE8 and older
+elgg.register_hook_handler('init', 'system', function() {
// jQuery uses 0-based indexing
$('#groups-tools').children('li:even').addClass('odd');
});
diff --git a/mod/groups/views/default/groups/sidebar/find.php b/mod/groups/views/default/groups/sidebar/find.php
index c5c986759..c1a8da3c2 100644
--- a/mod/groups/views/default/groups/sidebar/find.php
+++ b/mod/groups/views/default/groups/sidebar/find.php
@@ -5,7 +5,7 @@
* @package ElggGroups
*/
$url = elgg_get_site_url() . 'groups/search';
-$body = elgg_view_form('groups/search', array(
+$body = elgg_view_form('groups/find', array(
'action' => $url,
'method' => 'get',
'disable_security' => true,
diff --git a/mod/groups/views/default/groups/sidebar/members.php b/mod/groups/views/default/groups/sidebar/members.php
index 49f14697c..11273d0e6 100644
--- a/mod/groups/views/default/groups/sidebar/members.php
+++ b/mod/groups/views/default/groups/sidebar/members.php
@@ -8,7 +8,7 @@
* @uses $vars['limit'] The number of members to display
*/
-$limit = elgg_extract('limit', $vars, 10);
+$limit = elgg_extract('limit', $vars, 14);
$all_link = elgg_view('output/url', array(
'href' => 'groups/members/' . $vars['entity']->guid,
@@ -24,6 +24,7 @@ $body = elgg_list_entities_from_relationship(array(
'limit' => $limit,
'list_type' => 'gallery',
'gallery_class' => 'elgg-gallery-users',
+ 'pagination' => false
));
$body .= "<div class='center mts'>$all_link</div>";
diff --git a/mod/groups/views/default/groups/sidebar/search.php b/mod/groups/views/default/groups/sidebar/search.php
new file mode 100644
index 000000000..226835715
--- /dev/null
+++ b/mod/groups/views/default/groups/sidebar/search.php
@@ -0,0 +1,15 @@
+<?php
+/**
+ * Search for content in this group
+ *
+ * @uses vars['entity'] ElggGroup
+ */
+
+$url = elgg_get_site_url() . 'search';
+$body = elgg_view_form('groups/search', array(
+ 'action' => $url,
+ 'method' => 'get',
+ 'disable_security' => true,
+), $vars);
+
+echo elgg_view_module('aside', elgg_echo('groups:search_in_group'), $body); \ No newline at end of file