aboutsummaryrefslogtreecommitdiff
path: root/mod/groups
diff options
context:
space:
mode:
authorSem <sembrestels@riseup.net>2012-01-12 16:15:16 +0100
committerSem <sembrestels@riseup.net>2012-01-12 16:15:16 +0100
commitcc544cfa2086e418318a899ffd550adfb744c7ba (patch)
tree6c04fbe2e3df67513aa76803cb8d05c105ba219b /mod/groups
parente7d64510ebd823f186282e2b80780295bcca1b79 (diff)
parent68e4829ac0959d86c651e7ed6dc255c39694c8af (diff)
downloadelgg-cc544cfa2086e418318a899ffd550adfb744c7ba.tar.gz
elgg-cc544cfa2086e418318a899ffd550adfb744c7ba.tar.bz2
Merge Elgg 1.8.3.
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.php10
-rw-r--r--mod/groups/languages/en.php2
-rw-r--r--mod/groups/lib/discussion.php6
-rw-r--r--mod/groups/lib/groups.php8
-rw-r--r--mod/groups/start.php2
-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/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/search.php15
16 files changed, 103 insertions, 33 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..104da4b41 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;
@@ -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..a4a9e2b2b 100644
--- a/mod/groups/languages/en.php
+++ b/mod/groups/languages/en.php
@@ -61,6 +61,8 @@ $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: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 7798e5dc3..5d6083077 100644
--- a/mod/groups/lib/groups.php
+++ b/mod/groups/lib/groups.php
@@ -234,6 +234,8 @@ function groups_handle_invitations_page() {
function groups_handle_profile_page($guid) {
elgg_set_page_owner_guid($guid);
+ elgg_push_context('group_profile');
+
// turn this into a core function
global $autofeed;
$autofeed = true;
@@ -247,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..86a1da279 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;
}
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/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/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