aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/groups/all.php6
-rw-r--r--mod/groups/groupprofile.php48
-rw-r--r--mod/groups/index.php6
-rw-r--r--mod/groups/invite.php8
-rw-r--r--mod/groups/languages/en.php205
-rw-r--r--mod/groups/new.php6
-rw-r--r--mod/groups/start.php495
7 files changed, 398 insertions, 376 deletions
diff --git a/mod/groups/all.php b/mod/groups/all.php
index 7a07cb69e..ede0f841f 100644
--- a/mod/groups/all.php
+++ b/mod/groups/all.php
@@ -28,9 +28,9 @@
set_context($context);
$title = sprintf(elgg_echo("groups:all"),page_owner_entity()->name);
- $body = elgg_view_title($title);
- $body .= $objects;
- $body = elgg_view_layout('one_column',$body);
+ $area2 = elgg_view_title($title);
+ $area2 .= $objects;
+ $body = elgg_view_layout('two_column_left_sidebar',$area1, $area2);
// Finally draw the page
page_draw($title, $body);
diff --git a/mod/groups/groupprofile.php b/mod/groups/groupprofile.php
index e29435efc..cf9a96f1f 100644
--- a/mod/groups/groupprofile.php
+++ b/mod/groups/groupprofile.php
@@ -1,28 +1,26 @@
-<?php
- /**
- * Full group profile
- *
- * @package ElggGroups
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Marcus Povey
- * @copyright Curverider Ltd 2008
- * @link http://elgg.com/
- */
-
- $group_guid = get_input('group_guid');
- set_context('groups');
-
-
- $group = get_entity($group_guid);
+<?php
+ /**
+ * Full group profile
+ *
+ * @package ElggGroups
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Marcus Povey
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ $group_guid = get_input('group_guid');
+ set_context('groups');
+
+
+ $group = get_entity($group_guid);
set_page_owner($group_guid);
-
- $body = elgg_view_title($group->name);
- $body .= elgg_view('group/group', array('entity' => $group, 'user' => $_SESSION['user'], 'full' => true));
- $body = elgg_view_layout('one_column', $body);
-
- //$body .= elgg_view_layout('widgets', "", "", elgg_echo('groups:nowidgets'));
-
- // Finally draw the page
- page_draw($group->name, $body);
+
+ $area2 = elgg_view_title($group->name);
+ $area2 .= elgg_view('group/group', array('entity' => $group, 'user' => $_SESSION['user'], 'full' => true));
+ $body = elgg_view_layout('two_column_left_sidebar', $area1, $area2);
+
+ // Finally draw the page
+ page_draw($group->name, $body);
?> \ No newline at end of file
diff --git a/mod/groups/index.php b/mod/groups/index.php
index e4ca5a3ed..c0464dfdf 100644
--- a/mod/groups/index.php
+++ b/mod/groups/index.php
@@ -23,9 +23,9 @@
$objects = list_entities("group", "", page_owner(), $limit, false);
set_context($context);
- $body = elgg_view_title($title);
- $body .= $objects;
- $body = elgg_view_layout('one_column',$body);
+ $area2 = elgg_view_title($title);
+ $area2 .= $objects;
+ $body = elgg_view_layout('two_column_left_sidebar',$area1, $area2);
// Finally draw the page
page_draw($title, $body);
diff --git a/mod/groups/invite.php b/mod/groups/invite.php
index bb7aa75b7..ee6c028ad 100644
--- a/mod/groups/invite.php
+++ b/mod/groups/invite.php
@@ -16,17 +16,17 @@
$group = get_entity($group_guid);
$title = elgg_echo("groups:invite");
- $body = elgg_view_title($title);
+ $area2 = elgg_view_title($title);
if (($group) && ($group->canEdit()))
{
- $body .= elgg_view("forms/groups/invite", array('entity' => $group));
+ $area2 .= elgg_view("forms/groups/invite", array('entity' => $group));
} else {
- $body .= elgg_echo("groups:noaccess");
+ $area2 .= elgg_echo("groups:noaccess");
}
- $body = elgg_view_layout('one_column', $body);
+ $body = elgg_view_layout('two_column_left_sidebar', $area1, $area2);
page_draw($title, $body);
?> \ No newline at end of file
diff --git a/mod/groups/languages/en.php b/mod/groups/languages/en.php
index 612cac205..1dc9c1840 100644
--- a/mod/groups/languages/en.php
+++ b/mod/groups/languages/en.php
@@ -1,105 +1,106 @@
-<?php
- /**
- * Elgg groups plugin language pack
- *
- * @package ElggGroups
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Marcus Povey
- * @copyright Curverider Ltd 2008
- * @link http://elgg.com/
- */
-
- $english = array(
-
- /**
- * Menu items and titles
- */
-
- 'groups' => "Groups",
- 'groups:yours' => "Your groups",
- 'groups:user' => "%s's groups",
- 'groups:all' => "All groups",
- 'groups:new' => "Create a new group",
- 'groups:edit' => "Edit a group",
-
- 'groups:icon' => 'Group icon (leave blank to leave unchanged)',
+<?php
+ /**
+ * Elgg groups plugin language pack
+ *
+ * @package ElggGroups
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Marcus Povey
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ $english = array(
+
+ /**
+ * Menu items and titles
+ */
+
+ 'groups' => "Groups",
+ 'groups:yours' => "Your groups",
+ 'groups:user' => "%s's groups",
+ 'groups:all' => "All groups",
+ 'groups:new' => "Create a new group",
+ 'groups:edit' => "Edit a group",
+
+ 'groups:icon' => 'Group icon (leave blank to leave unchanged)',
'groups:name' => 'Group name',
'groups:username' => 'Group short name (displayed in URLs, alphanumeric characters only)',
- 'groups:description' => 'Description',
- 'groups:interests' => 'Interests',
- 'groups:website' => 'Website',
- 'groups:membership' => "Membership",
- 'groups:access' => "Access permissions",
- 'groups:owner' => "Owner",
-
- 'groups:noaccess' => 'No access to group',
- 'groups:cantedit' => 'You can not edit this group',
- 'groups:saved' => 'Group saved',
-
- 'groups:joinrequest' => 'Request membership',
- 'groups:join' => 'Join group',
- 'groups:leave' => 'Leave group',
- 'groups:invite' => 'Invite friends',
- 'groups:inviteto' => "Invite friends to '%s'",
- 'groups:nofriends' => "You have no friends left who have not been invited to this group.",
-
- 'groups:group' => "Group",
-
- 'groups:privategroup' => 'This group is private, requesting membership.',
- 'groups:notitle' => 'Groups must have a title',
- 'groups:cantjoin' => 'Can not join group',
- 'groups:cantleave' => 'Could not leave group',
- 'groups:addedtogroup' => 'Successfully added the user to the group',
- 'groups:joinrequestnotmade' => 'Join request could not be made',
- 'groups:joinrequestmade' => 'Request to join group successfully made',
- 'groups:joined' => 'Successfully joined group!',
- 'groups:left' => 'Successfully left group',
- 'groups:notowner' => 'Sorry, you are not the owner of this group.',
- 'groups:alreadymember' => 'You are already a member of this group!',
- 'groups:userinvited' => 'User has been invited.',
- 'groups:usernotinvited' => 'User could not be invited.',
-
- 'groups:invite:subject' => "%s you have been invited to join %s!",
- 'groups:invite:body' => "Hi %s,
-
-You have been invited to join the '%s' group, click below to confirm:
-
-%s",
-
- 'groups:welcome:subject' => "Welcome to the %s group!",
- 'groups:welcome:body' => "Hi %s!
-
-You are now a member of the '%s' group! Click below to begin posting!
-
-%s",
-
- 'groups:request:subject' => "%s has requested to join %s",
- 'groups:request:body' => "Hi %s,
-
-%s has requested to join the '%s' group, click below to view their profile:
-
-%s
-
-or click below to confirm request:
-
-%s",
-
- 'groups:river:member' => 'is now a member of',
-
- 'groups:nowidgets' => 'No widgets have been defined for this group.',
-
-
- 'groups:widgets:members:title' => 'Group members',
- 'groups:widgets:members:description' => 'List the members of a group.',
- 'groups:widgets:members:label:displaynum' => 'List the members of a group.',
- 'groups:widgets:members:label:pleaseedit' => 'Please configure this widget.',
-
- 'groups:widgets:entities:title' => "Objects in group",
- 'groups:widgets:entities:description' => "List the objects saved in this group",
- 'groups:widgets:entities:label:displaynum' => 'List the objects of a group.',
- 'groups:widgets:entities:label:pleaseedit' => 'Please configure this widget.',
-
- );
-
- add_translation("en",$english);
+ 'groups:description' => 'Description',
+ 'groups:briefdescription' => 'Brief description',
+ 'groups:interests' => 'Interests',
+ 'groups:website' => 'Website',
+ 'groups:membership' => "Membership",
+ 'groups:access' => "Access permissions",
+ 'groups:owner' => "Owner",
+
+ 'groups:noaccess' => 'No access to group',
+ 'groups:cantedit' => 'You can not edit this group',
+ 'groups:saved' => 'Group saved',
+
+ 'groups:joinrequest' => 'Request membership',
+ 'groups:join' => 'Join group',
+ 'groups:leave' => 'Leave group',
+ 'groups:invite' => 'Invite friends',
+ 'groups:inviteto' => "Invite friends to '%s'",
+ 'groups:nofriends' => "You have no friends left who have not been invited to this group.",
+
+ 'groups:group' => "Group",
+
+ 'groups:privategroup' => 'This group is private, requesting membership.',
+ 'groups:notitle' => 'Groups must have a title',
+ 'groups:cantjoin' => 'Can not join group',
+ 'groups:cantleave' => 'Could not leave group',
+ 'groups:addedtogroup' => 'Successfully added the user to the group',
+ 'groups:joinrequestnotmade' => 'Join request could not be made',
+ 'groups:joinrequestmade' => 'Request to join group successfully made',
+ 'groups:joined' => 'Successfully joined group!',
+ 'groups:left' => 'Successfully left group',
+ 'groups:notowner' => 'Sorry, you are not the owner of this group.',
+ 'groups:alreadymember' => 'You are already a member of this group!',
+ 'groups:userinvited' => 'User has been invited.',
+ 'groups:usernotinvited' => 'User could not be invited.',
+
+ 'groups:invite:subject' => "%s you have been invited to join %s!",
+ 'groups:invite:body' => "Hi %s,
+
+You have been invited to join the '%s' group, click below to confirm:
+
+%s",
+
+ 'groups:welcome:subject' => "Welcome to the %s group!",
+ 'groups:welcome:body' => "Hi %s!
+
+You are now a member of the '%s' group! Click below to begin posting!
+
+%s",
+
+ 'groups:request:subject' => "%s has requested to join %s",
+ 'groups:request:body' => "Hi %s,
+
+%s has requested to join the '%s' group, click below to view their profile:
+
+%s
+
+or click below to confirm request:
+
+%s",
+
+ 'groups:river:member' => 'is now a member of',
+
+ 'groups:nowidgets' => 'No widgets have been defined for this group.',
+
+
+ 'groups:widgets:members:title' => 'Group members',
+ 'groups:widgets:members:description' => 'List the members of a group.',
+ 'groups:widgets:members:label:displaynum' => 'List the members of a group.',
+ 'groups:widgets:members:label:pleaseedit' => 'Please configure this widget.',
+
+ 'groups:widgets:entities:title' => "Objects in group",
+ 'groups:widgets:entities:description' => "List the objects saved in this group",
+ 'groups:widgets:entities:label:displaynum' => 'List the objects of a group.',
+ 'groups:widgets:entities:label:pleaseedit' => 'Please configure this widget.',
+
+ );
+
+ add_translation("en",$english);
?> \ No newline at end of file
diff --git a/mod/groups/new.php b/mod/groups/new.php
index e77815e20..30336b52e 100644
--- a/mod/groups/new.php
+++ b/mod/groups/new.php
@@ -13,10 +13,10 @@
// Render the file upload page
$title = elgg_echo("groups:new");
- $body = elgg_view_title($title);
- $body .= elgg_view("forms/groups/edit");
+ $area2 = elgg_view_title($title);
+ $area2 .= elgg_view("forms/groups/edit");
- $body = elgg_view_layout('one_column', $body);
+ $body = elgg_view_layout('two_column_left_sidebar', $area1, $area2);
page_draw($title, $body);
?> \ No newline at end of file
diff --git a/mod/groups/start.php b/mod/groups/start.php
index c17b88096..d5dfc76f8 100644
--- a/mod/groups/start.php
+++ b/mod/groups/start.php
@@ -1,239 +1,262 @@
-<?php
- /**
- * Elgg groups plugin
- *
- * @package ElggGroups
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Marcus Povey
- * @copyright Curverider Ltd 2008
- * @link http://elgg.com/
- */
-
- /**
- * Initialise the groups plugin.
- * Register actions, set up menus
- */
- function groups_init()
- {
- global $CONFIG;
-
- // Set up the menu for logged in users
- if (isloggedin())
- {
- add_menu(elgg_echo('groups'), $CONFIG->wwwroot . "pg/groups/owned/" . $_SESSION['user']->username,array(
- menu_item(elgg_echo('groups:new'), $CONFIG->wwwroot."pg/groups/new/"),
- menu_item(elgg_echo('groups:yours'), $CONFIG->wwwroot . "pg/groups/owned/" . $_SESSION['user']->username),
- menu_item(elgg_echo('groups:all'), $CONFIG->wwwroot . "pg/groups/world/"),
- ),'groups');
- }
- else
- {
- add_menu(elgg_echo('groups'), $CONFIG->wwwroot . "mod/groups/",array(
- menu_item(elgg_echo('groups:all'),$CONFIG->wwwroot."mod/groups/all.php"),
- ));
- }
-
- // Register a page handler, so we can have nice URLs
- register_page_handler('groups','groups_page_handler');
-
- // Register a URL handler for groups
- register_entity_url_handler('groups_url','group','all');
-
- // Register an icon handler for groups
- register_page_handler('icon','groups_icon_handler');
-
- // Register some actions
- register_action("groups/edit",false, $CONFIG->pluginspath . "groups/actions/edit.php");
- register_action("groups/join",false, $CONFIG->pluginspath . "groups/actions/join.php");
- register_action("groups/leave",false, $CONFIG->pluginspath . "groups/actions/leave.php");
- register_action("groups/joinrequest",false, $CONFIG->pluginspath . "groups/actions/joinrequest.php");
-
- register_action("groups/addtogroup",false, $CONFIG->pluginspath . "groups/actions/addtogroup.php");
-
- // Use group widgets
- use_widgets('groups');
-
- // Add a page owner handler
- add_page_owner_handler('groups_page_owner_handler');
-
- // Add some widgets
- add_widget_type('group_members_widget',elgg_echo('groups:widgets:members:title'), elgg_echo('groups:widgets:members:description'), 'groups');
- add_widget_type('group_entities_widget',elgg_echo('groups:widgets:entities:title'), elgg_echo('groups:widgets:entities:description'), 'groups');
+<?php
+ /**
+ * Elgg groups plugin
+ *
+ * @package ElggGroups
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Marcus Povey
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ /**
+ * Initialise the groups plugin.
+ * Register actions, set up menus
+ */
+ function groups_init()
+ {
+
+ global $CONFIG;
+
+ // Set up the menu for logged in users
+ if (isloggedin())
+ {
+ add_menu(elgg_echo('groups'), $CONFIG->wwwroot . "pg/groups/owned/" . $_SESSION['user']->username,array(
+ //menu_item(elgg_echo('groups:new'), $CONFIG->wwwroot."pg/groups/new/"),
+ //menu_item(elgg_echo('groups:yours'), $CONFIG->wwwroot . "pg/groups/owned/" . $_SESSION['user']->username),
+ //menu_item(elgg_echo('groups:all'), $CONFIG->wwwroot . "pg/groups/world/"),
+ ),'groups');
+ }
+ else
+ {
+ add_menu(elgg_echo('groups'), $CONFIG->wwwroot . "mod/groups/",array(
+ menu_item(elgg_echo('groups:all'),$CONFIG->wwwroot."mod/groups/all.php"),
+ ));
+ }
+
+ // Register a page handler, so we can have nice URLs
+ register_page_handler('groups','groups_page_handler');
+
+ // Register a URL handler for groups
+ register_entity_url_handler('groups_url','group','all');
+
+ // Register an icon handler for groups
+ register_page_handler('icon','groups_icon_handler');
+
+ // Register some actions
+ register_action("groups/edit",false, $CONFIG->pluginspath . "groups/actions/edit.php");
+ register_action("groups/join",false, $CONFIG->pluginspath . "groups/actions/join.php");
+ register_action("groups/leave",false, $CONFIG->pluginspath . "groups/actions/leave.php");
+ register_action("groups/joinrequest",false, $CONFIG->pluginspath . "groups/actions/joinrequest.php");
+
+ register_action("groups/addtogroup",false, $CONFIG->pluginspath . "groups/actions/addtogroup.php");
+
+ // Use group widgets
+ use_widgets('groups');
+
+ // Add a page owner handler
+ add_page_owner_handler('groups_page_owner_handler');
+
+ // Add some widgets
+ add_widget_type('group_members_widget',elgg_echo('groups:widgets:members:title'), elgg_echo('groups:widgets:members:description'), 'groups');
+ add_widget_type('group_entities_widget',elgg_echo('groups:widgets:entities:title'), elgg_echo('groups:widgets:entities:description'), 'groups');
extend_view('profile/icon','groups/icon');
-
- // For now, we'll hard code the groups profile items as follows:
- // TODO make this user configurable
-
- // Language short codes must be of the form "groups:key"
- // where key is the array key below
- $CONFIG->group = array(
-
- 'name' => 'text',
- 'description' => 'longtext',
- //'location' => 'tags',
- 'interests' => 'tags',
- //'skills' => 'tags',
- //'contactemail' => 'email',
- //'phone' => 'text',
- //'mobile' => 'text',
- 'website' => 'url',
-
- );
- }
-
- /**
- * Set a page owner handler.
- *
- */
- function groups_page_owner_handler()
- {
- $group_guid = get_input('group_guid');
- if ($group_guid)
- {
- $group = get_entity($group_guid);
- if ($group instanceof ElggGroup)
- return $group->owner_guid;
- }
-
- return false;
- }
-
- /**
- * Group page handler
- *
- * @param array $page Array of page elements, forwarded by the page handling mechanism
- */
- function groups_page_handler($page)
- {
- global $CONFIG;
-
-
- if (isset($page[0]))
- {
- // See what context we're using
- switch($page[0])
- {
- case "new" :
- include($CONFIG->pluginspath . "groups/new.php");
- break;
- case "world":
- include($CONFIG->pluginspath . "groups/all.php");
- break;
- case "owned" :
- // Owned by a user
- if (isset($page[1]))
- set_input('username',$page[1]);
-
- include($CONFIG->pluginspath . "groups/index.php");
- break;
- default:
- set_input('group_guid', $page[0]);
- include($CONFIG->pluginspath . "groups/groupprofile.php");
- break;
- }
- }
-
- }
-
- /**
- * Populates the ->getUrl() method for group objects
- *
- * @param ElggEntity $entity File entity
- * @return string File URL
- */
- function groups_url($entity) {
-
- global $CONFIG;
-
- $title = friendly_title($entity->name);
-
- return $CONFIG->url . "pg/groups/{$entity->guid}/$title/";
-
- }
-
- /**
- * Groups created, so add users to access lists.
- */
- function groups_create_event_listener($event, $object_type, $object)
- {
- if (($event == 'create') && ($object_type == 'group') && ($object instanceof ElggGroup))
- {
- $group_id = create_access_collection(elgg_echo('groups:group') . ": " . $object->name);
- if ($group_id)
- {
- $object->group_acl = $group_id;
- }
- else
- return false;
- }
-
- return true;
- }
-
- /**
- * Hook to listen to read access control requests and return all the groups you are a member of.
- */
- function groups_read_acl_plugin_hook($hook, $entity_type, $returnvalue, $params)
- {
- //error_log("READ: " . var_export($returnvalue));
- $user = $_SESSION['user'];
- if ($user)
- {
- $membership = get_users_membership($user->guid);
-
- if ($membership)
- {
- foreach ($membership as $group)
- $returnvalue[$user->guid][$group->group_acl] = elgg_echo('groups:group') . ": " . $group->name;
-
- return $returnvalue;
- }
- }
- }
-
- /**
- * Return the write access for the current group if the user has write access to it.
- */
- function groups_write_acl_plugin_hook($hook, $entity_type, $returnvalue, $params)
- {
- $group_guid = get_input('group_guid');
-
- if ($group_guid)
- {
- $group = get_entity($group_guid);
-
- if (($group) && ($group->can_write_to_container($_SESSION['user']->guid)))
- {
- $returnvalue[$group->group_acl] = elgg_echo('groups:group') . ": " . $group->name;
-
- return $returnvalue;
- }
- }
- }
-
- /**
- * Groups deleted, so remove access lists.
- */
- function groups_delete_event_listener($event, $object_type, $object)
- {
- delete_access_collection($object->access_id);
-
- return true;
- }
-
- // Register a handler for create groups
- register_elgg_event_handler('create', 'group', 'groups_create_event_listener');
-
- // Register a handler for delete groups
- register_elgg_event_handler('delete', 'group', 'groups_delete_event_listener');
-
- // Read access permissions
- register_plugin_hook('access:collections', 'all', 'groups_read_acl_plugin_hook');
-
- // Write access permissions
- register_plugin_hook('access:collections:write', 'all', 'groups_write_acl_plugin_hook');
-
- // Make sure the groups initialisation function is called on initialisation
- register_elgg_event_handler('init','system','groups_init');
+
+ // For now, we'll hard code the groups profile items as follows:
+ // TODO make this user configurable
+
+ // Language short codes must be of the form "groups:key"
+ // where key is the array key below
+ $CONFIG->group = array(
+
+ 'name' => 'text',
+ 'description' => 'longtext',
+ 'briefdescription' => 'text',
+ 'interests' => 'tags',
+ 'website' => 'url',
+
+ );
+ }
+
+ /**
+ * Sets up submenus for the groups system. Triggered on pagesetup.
+ *
+ */
+ function groups_submenus() {
+
+ global $CONFIG;
+
+ // Add submenu options
+ if (get_context() == "groups") {
+ if ((page_owner() == $_SESSION['guid'] || !page_owner()) && isloggedin()) {
+ add_submenu_item(sprintf(elgg_echo('groups:new'), $CONFIG->wwwroot."pg/groups/new/"));
+ add_submenu_item(sprintf(elgg_echo('groups:yours'), $CONFIG->wwwroot . "pg/groups/owned/" . $_SESSION['user']->username));
+ add_submenu_item(elgg_echo('groups:all'), $CONFIG->wwwroot . "pg/groups/world/");
+ } else if (page_owner()) {
+ $page_owner = page_owner_entity();
+ add_submenu_item(sprintf(elgg_echo('groups:yours'), $CONFIG->wwwroot . "pg/groups/owned/" . $page_owner->username));
+ add_submenu_item(elgg_echo('groups:all'), $CONFIG->wwwroot . "pg/groups/world/");
+ } else {
+ add_submenu_item(elgg_echo('groups:all'), $CONFIG->wwwroot . "pg/groups/world/");
+ }
+ }
+
+ }
+
+ /**
+ * Set a page owner handler.
+ *
+ */
+ function groups_page_owner_handler()
+ {
+ $group_guid = get_input('group_guid');
+ if ($group_guid)
+ {
+ $group = get_entity($group_guid);
+ if ($group instanceof ElggGroup)
+ return $group->owner_guid;
+ }
+
+ return false;
+ }
+
+ /**
+ * Group page handler
+ *
+ * @param array $page Array of page elements, forwarded by the page handling mechanism
+ */
+ function groups_page_handler($page)
+ {
+ global $CONFIG;
+
+
+ if (isset($page[0]))
+ {
+ // See what context we're using
+ switch($page[0])
+ {
+ case "new" :
+ include($CONFIG->pluginspath . "groups/new.php");
+ break;
+ case "world":
+ include($CONFIG->pluginspath . "groups/all.php");
+ break;
+ case "owned" :
+ // Owned by a user
+ if (isset($page[1]))
+ set_input('username',$page[1]);
+
+ include($CONFIG->pluginspath . "groups/index.php");
+ break;
+ default:
+ set_input('group_guid', $page[0]);
+ include($CONFIG->pluginspath . "groups/groupprofile.php");
+ break;
+ }
+ }
+
+ }
+
+ /**
+ * Populates the ->getUrl() method for group objects
+ *
+ * @param ElggEntity $entity File entity
+ * @return string File URL
+ */
+ function groups_url($entity) {
+
+ global $CONFIG;
+
+ $title = friendly_title($entity->name);
+
+ return $CONFIG->url . "pg/groups/{$entity->guid}/$title/";
+
+ }
+
+ /**
+ * Groups created, so add users to access lists.
+ */
+ function groups_create_event_listener($event, $object_type, $object)
+ {
+ if (($event == 'create') && ($object_type == 'group') && ($object instanceof ElggGroup))
+ {
+ $group_id = create_access_collection(elgg_echo('groups:group') . ": " . $object->name);
+ if ($group_id)
+ {
+ $object->group_acl = $group_id;
+ }
+ else
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Hook to listen to read access control requests and return all the groups you are a member of.
+ */
+ function groups_read_acl_plugin_hook($hook, $entity_type, $returnvalue, $params)
+ {
+ //error_log("READ: " . var_export($returnvalue));
+ $user = $_SESSION['user'];
+ if ($user)
+ {
+ $membership = get_users_membership($user->guid);
+
+ if ($membership)
+ {
+ foreach ($membership as $group)
+ $returnvalue[$user->guid][$group->group_acl] = elgg_echo('groups:group') . ": " . $group->name;
+
+ return $returnvalue;
+ }
+ }
+ }
+
+ /**
+ * Return the write access for the current group if the user has write access to it.
+ */
+ function groups_write_acl_plugin_hook($hook, $entity_type, $returnvalue, $params)
+ {
+ $group_guid = get_input('group_guid');
+
+ if ($group_guid)
+ {
+ $group = get_entity($group_guid);
+
+ if (($group) && ($group->can_write_to_container($_SESSION['user']->guid)))
+ {
+ $returnvalue[$group->group_acl] = elgg_echo('groups:group') . ": " . $group->name;
+
+ return $returnvalue;
+ }
+ }
+ }
+
+ /**
+ * Groups deleted, so remove access lists.
+ */
+ function groups_delete_event_listener($event, $object_type, $object)
+ {
+ delete_access_collection($object->access_id);
+
+ return true;
+ }
+
+ // Register a handler for create groups
+ register_elgg_event_handler('create', 'group', 'groups_create_event_listener');
+
+ // Register a handler for delete groups
+ register_elgg_event_handler('delete', 'group', 'groups_delete_event_listener');
+
+ // Read access permissions
+ register_plugin_hook('access:collections', 'all', 'groups_read_acl_plugin_hook');
+
+ // Write access permissions
+ register_plugin_hook('access:collections:write', 'all', 'groups_write_acl_plugin_hook');
+
+ // Make sure the groups initialisation function is called on initialisation
+ register_elgg_event_handler('init','system','groups_init');
+ register_elgg_event_handler('pagesetup','system','groups_submenus');
?> \ No newline at end of file