aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mod/groups/activity.php57
-rw-r--r--mod/groups/all.php72
-rw-r--r--mod/groups/edit.php29
-rw-r--r--mod/groups/groupprofile.php43
-rw-r--r--mod/groups/index.php27
-rw-r--r--mod/groups/invitations.php31
-rw-r--r--mod/groups/languages/en.php2
-rw-r--r--mod/groups/lib/groups.php248
-rw-r--r--mod/groups/membership.php34
-rw-r--r--mod/groups/new.php20
-rw-r--r--mod/groups/start.php1083
-rw-r--r--mod/groups/views/default/groups/group_sort_menu.php23
-rw-r--r--mod/groups/views/default/groups/profile/buttons.php2
13 files changed, 793 insertions, 878 deletions
diff --git a/mod/groups/activity.php b/mod/groups/activity.php
deleted file mode 100644
index 57678be6d..000000000
--- a/mod/groups/activity.php
+++ /dev/null
@@ -1,57 +0,0 @@
-<?php
-/**
- * Elgg group activity
- */
-
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
-$group_guid = (int)get_input('group');
-set_page_owner($group_guid);
-if (!(elgg_get_page_owner() instanceof ElggGroup)) {
- forward();
-}
-group_gatekeeper();
-
-global $CONFIG;
-
-// set up breadcrumbs
-$group = get_entity($group_guid);
-elgg_push_breadcrumb(elgg_echo('groups'), elgg_get_site_url()."pg/groups/world/");
-elgg_push_breadcrumb($group->name, $group->getURL());
-elgg_push_breadcrumb(elgg_echo('groups:activity'));
-
-$area1 = elgg_view('navigation/breadcrumbs');
-
-$limit = get_input("limit", 20);
-$offset = get_input("offset", 0);
-$group_guid = get_input("group", 7);
-// Sanitise variables -- future proof in case they get sourced elsewhere
-$limit = (int) $limit;
-$offset = (int) $offset;
-$group_guid = (int) $group_guid;
-
-$entities = elgg_get_entities(array(
- 'container_guids' => $group_guid,
- 'group_by' => 'e.guid'
-));
-
-$entity_guids = array();
-foreach ($entities as $entity) {
- $entity_guids[] = $entity->getGUID();
-}
-
-if (count($entity_guids) > 0) {
- $river_items = elgg_view_river_items('', $entity_guids, '', '', '', '', $limit);
- $river_items .= elgg_view('riverdashboard/js');
-} else {
- $river_items .= elgg_echo('groups:no_activity');
-}
-
-$area1 .= elgg_view_title(elgg_echo('groups:activity'));
-$area1 .= elgg_view("group_activity/extend");
-$area1 .= "<div class='group_listings hide_comments'>".$river_items."</div>";
-$title = elgg_echo("groups:activity", array(elgg_get_page_owner()->name));
-$body = elgg_view_layout('one_column_with_sidebar', array('content' => $area1));
-
-// Finally draw the page
-echo elgg_view_page($title, $body); \ No newline at end of file
diff --git a/mod/groups/all.php b/mod/groups/all.php
deleted file mode 100644
index 51030adc9..000000000
--- a/mod/groups/all.php
+++ /dev/null
@@ -1,72 +0,0 @@
-<?php
-/**
- * Elgg groups plugin
- *
- * @package ElggGroups
- */
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
-$limit = get_input("limit", 10);
-$offset = get_input("offset", 0);
-$filter = get_input("filter");
-if (!$filter) {
- // active discussions is the default
- $filter = "newest";
-}
-
-$context = elgg_get_context();
-
-switch ($filter) {
- case "newest":
- $objects = elgg_list_entities(array(
- 'type' => 'group',
- 'limit' => $limit,
- 'full_view' => false,
- ));
- break;
-
- case "pop":
- $objects = list_entities_by_relationship_count('member', true, "", "", 0, $limit, false);
- break;
-
- case "active":
- case 'default':
- $options = array(
- 'type' => 'object',
- 'subtype' => 'groupforumtopic',
- 'annotation_name' => 'generic_comment',
- 'order_by' => 'e.last_action desc',
- 'limit' => 40,
- 'fullview' => TRUE
- );
- $objects = elgg_list_entities($options);
- break;
-}
-
-//get a group count
-$group_count = elgg_get_entities(array('types' => 'group', 'limit' => 10, 'count' => TRUE));
-
-//find groups
-$area2 .= elgg_view("groups/sidebar/find");
-
-//featured groups
-$area2 .= elgg_view("groups/sidebar/featured");
-
-elgg_set_context($context);
-
-$objects = "<div class='group_listings'>" . $objects . "</div>";
-
-$title = elgg_echo("groups:all", array(elgg_get_page_owner()->name));
-if (isloggedin ()) {
- $area1 .= elgg_view('page/elements/content_header', array('context' => "everyone", 'type' => 'groups', 'new_link' => "pg/groups/new"));
-}
-$area1 .= elgg_view("groups/group_sort_menu", array("count" => $group_count, "filter" => $filter)) . $objects;
-
-$params = array(
- 'content' => $area1,
- 'sidebar' => $area2
-);
-$body = elgg_view_layout('one_sidebar', $params);
-
-// Finally draw the page
-echo elgg_view_page($title, $body); \ No newline at end of file
diff --git a/mod/groups/edit.php b/mod/groups/edit.php
deleted file mode 100644
index 59064b7d8..000000000
--- a/mod/groups/edit.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
- /**
- * Elgg groups plugin
- *
- * @package ElggGroups
- */
-
- require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
- group_gatekeeper();
-
- $group_guid = get_input('group_guid');
- $group = get_entity($group_guid);
- set_page_owner($group_guid);
-
- $title = elgg_echo("groups:edit");
- $body = elgg_view_title($title);
-
- if (($group) && ($group->canEdit()))
- {
- $body .= elgg_view("forms/groups/edit", array('entity' => $group));
-
- } else {
- $body .= elgg_echo('groups:noaccess');
- }
-
- $body = elgg_view_layout('one_column_with_sidebar', array('content' => $body));
-
- echo elgg_view_page($title, $body);
-?> \ No newline at end of file
diff --git a/mod/groups/groupprofile.php b/mod/groups/groupprofile.php
deleted file mode 100644
index 1c35163ad..000000000
--- a/mod/groups/groupprofile.php
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-/**
- * Profile of a group
- *
- * @package ElggGroups
- */
-
-$guid = get_input('group_guid');
-elgg_set_context('groups');
-
-elgg_set_page_owner_guid($guid);
-
-// can the user see all content
-$group_access = group_gatekeeper(false);
-
-// turn this into a core function
-global $autofeed;
-$autofeed = true;
-
-$group = get_entity($guid);
-
-elgg_push_breadcrumb(elgg_echo('groups:all'), elgg_get_site_url() . "pg/groups/world");
-elgg_push_breadcrumb($group->name);
-
-$sidebar = '';
-$content = elgg_view('groups/profile/profile_block', array('entity' => $group));
-if (group_gatekeeper(false)) {
- $content .= elgg_view('groups/profile/widgets', array('entity' => $group));
- $sidebar = elgg_view('groups/sidebar/members', array('entity' => $group));
-} else {
- $content .= elgg_view('groups/profile/closed_membership');
-}
-
-$params = array(
- 'content' => $content,
- 'sidebar' => $sidebar,
- 'title' => $group->name,
- 'buttons' => elgg_view('groups/profile/buttons', array('entity' => $group)),
- 'filter' => '',
-);
-$body = elgg_view_layout('content', $params);
-
-echo elgg_view_page($title, $body);
diff --git a/mod/groups/index.php b/mod/groups/index.php
deleted file mode 100644
index 1deabb3de..000000000
--- a/mod/groups/index.php
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
- /**
- * Elgg groups plugin
- *
- * @package ElggGroups
- */
-
- require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
- $limit = get_input("limit", 10);
- $offset = get_input("offset", 0);
-
- $title = elgg_echo("groups:owned");
-
- // Get objects
- $area1 = elgg_view('page/elements/content_header', array('context' => "everyone", 'type' => 'groups', 'new_link' => "pg/groups/new"));
-
- elgg_push_context('search');
- $objects = elgg_list_entities(array('types' => 'group', 'owner_guid' => elgg_get_page_owner_guid(), 'limit' => $limit, 'offset' => $offset, 'full_view' => FALSE));
- elgg_pop_context();
-
- $area1 .= $objects;
- $body = elgg_view_layout('one_column_with_sidebar', array('content' => $area1));
-
- // Finally draw the page
- echo elgg_view_page($title, $body);
-?>
diff --git a/mod/groups/invitations.php b/mod/groups/invitations.php
deleted file mode 100644
index 6a187a8fa..000000000
--- a/mod/groups/invitations.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-/**
- * Manage group invitation requests.
- *
- * @package ElggGroups
- */
-
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-gatekeeper();
-
-set_page_owner(get_loggedin_userid());
-
-$user = get_loggedin_user();
-
-$title = elgg_echo('groups:invitations');
-
-$area2 = elgg_view_title($title);
-
-if ($user) {
- // @todo temporary workaround for exts #287.
- $invitations = groups_get_invited_groups($user->getGUID());
-
- $area2 .= elgg_view('groups/invitationrequests',array('invitations' => $invitations));
- elgg_set_ignore_access($ia);
-} else {
- $area2 .= elgg_echo("groups:noaccess");
-}
-
-$body = elgg_view_layout('one_column_with_sidebar', array('content' => $area1));
-
-echo elgg_view_page($title, $body); \ No newline at end of file
diff --git a/mod/groups/languages/en.php b/mod/groups/languages/en.php
index f28bc0846..1d136e741 100644
--- a/mod/groups/languages/en.php
+++ b/mod/groups/languages/en.php
@@ -15,7 +15,7 @@ $english = array(
'groups:yours' => "My groups",
'groups:user' => "%s's groups",
'groups:all' => "All groups",
- 'groups:new' => "Create a new group",
+ 'groups:add' => "Create a new group",
'groups:edit' => "Edit group",
'groups:delete' => 'Delete group',
'groups:membershiprequests' => 'Manage join requests',
diff --git a/mod/groups/lib/groups.php b/mod/groups/lib/groups.php
new file mode 100644
index 000000000..faedca18e
--- /dev/null
+++ b/mod/groups/lib/groups.php
@@ -0,0 +1,248 @@
+<?php
+/**
+ * Groups function library
+ */
+
+/**
+ * List all groups
+ */
+function groups_handle_all_page() {
+
+ // all groups doesn't get link to self
+ elgg_pop_breadcrumb();
+ elgg_push_breadcrumb(elgg_echo('groups'));
+
+ $selected_tab = get_input('filter', 'newest');
+
+ switch ($selected_tab) {
+ case 'pop':
+ $content = elgg_list_entities_from_relationship_count(array(
+ 'type' => 'group',
+ 'relationship' => 'member',
+ 'inverse_relationship' => false,
+ 'full_view' => false,
+ ));
+ break;
+ case 'active':
+ $content = elgg_list_entities(array(
+ 'type' => 'object',
+ 'subtype' => 'groupforumtopic',
+ 'annotation_name' => 'generic_comment',
+ 'order_by' => 'e.last_action desc',
+ 'limit' => 40,
+ 'fullview' => false,
+ ));
+ break;
+ case 'newest':
+ default:
+ $content = elgg_list_entities(array(
+ 'type' => 'group',
+ 'full_view' => false,
+ ));
+ break;
+ }
+
+ $filter = elgg_view('groups/group_sort_menu', array('selected' => $selected_tab));
+
+ $sidebar = elgg_view('groups/sidebar/find');
+ $sidebar .= elgg_view('groups/sidebar/featured');
+
+ $params = array(
+ 'content' => $content,
+ 'sidebar' => $sidebar,
+ 'filter' => $filter,
+ );
+ $body = elgg_view_layout('content', $params);
+
+ echo elgg_view_page($title, $body);
+}
+
+/**
+ * List owned groups
+ */
+function groups_handle_owned_page() {
+
+ $page_owner = elgg_get_page_owner();
+
+ $title = elgg_echo('groups:owned');
+ elgg_push_breadcrumb($title);
+
+ $content = elgg_list_entities(array(
+ 'type' => 'group',
+ 'owner_guid' => elgg_get_page_owner_guid(),
+ 'full_view' => false,
+ ));
+
+ $params = array(
+ 'content' => $content,
+ 'title' => $title,
+ 'filter' => '',
+ );
+ $body = elgg_view_layout('content', $params);
+
+ echo elgg_view_page($title, $body);
+}
+
+/**
+ * List groups the user is memober of
+ */
+function groups_handle_mine_page() {
+
+ $page_owner = elgg_get_page_owner();
+
+ $title = elgg_echo('groups:yours');
+ elgg_push_breadcrumb($title);
+
+ $content = elgg_list_entities_from_relationship_count(array(
+ 'type' => 'group',
+ 'relationship' => 'member',
+ 'relationship_guid' => elgg_get_page_owner_guid(),
+ 'inverse_relationship' => false,
+ 'full_view' => false,
+ ));
+
+ $params = array(
+ 'content' => $content,
+ 'title' => $title,
+ 'filter' => '',
+ );
+ $body = elgg_view_layout('content', $params);
+
+ echo elgg_view_page($title, $body);
+}
+
+/**
+ * Create or edit a group
+ *
+ * @param string $page
+ * @param int $guid
+ */
+function groups_handle_edit_page($page, $guid = 0) {
+ gatekeeper();
+
+ if ($page == 'add') {
+ elgg_set_page_owner_guid(get_loggedin_userid());
+ $title = elgg_echo('groups:add');
+ elgg_push_breadcrumb($title);
+ $content = elgg_view('forms/groups/edit');
+ } else {
+ $title = elgg_echo("groups:edit");
+ $group = get_entity($guid);
+
+ if ($group && $group->canEdit()) {
+ elgg_set_page_owner_guid($group->getGUID());
+ elgg_push_breadcrumb($group->name, $group->getURL());
+ elgg_push_breadcrumb($title);
+ $content = elgg_view("forms/groups/edit", array('entity' => $group));
+ } else {
+ $content = elgg_echo('groups:noaccess');
+ }
+ }
+
+ $params = array(
+ 'content' => $content,
+ 'title' => $title,
+ 'filter' => '',
+ 'buttons' => '',
+ );
+ $body = elgg_view_layout('content', $params);
+
+ echo elgg_view_page($title, $body);
+}
+
+/**
+ * Group invitations for a user
+ */
+function groups_handle_invitations_page() {
+ gatekeeper();
+
+ $user = elgg_get_page_owner();
+
+ $title = elgg_echo('groups:invitations');
+ elgg_push_breadcrumb($title);
+
+ // @todo temporary workaround for exts #287.
+ $invitations = groups_get_invited_groups($user->getGUID());
+ $content = elgg_view('groups/invitationrequests', array('invitations' => $invitations));
+
+ $params = array(
+ 'content' => $content,
+ 'title' => $title,
+ 'filter' => '',
+ 'buttons' => '',
+ );
+ $body = elgg_view_layout('content', $params);
+
+ echo elgg_view_page($title, $body);
+}
+
+/**
+ * Group profile page
+ *
+ * @param int $guid Group entity GUID
+ */
+function groups_handle_profile_page($guid) {
+ elgg_set_page_owner_guid($guid);
+
+ // turn this into a core function
+ global $autofeed;
+ $autofeed = true;
+
+ $group = get_entity($guid);
+
+ elgg_push_breadcrumb($group->name);
+
+ $sidebar = '';
+ $content = elgg_view('groups/profile/profile_block', array('entity' => $group));
+ if (group_gatekeeper(false)) {
+ $content .= elgg_view('groups/profile/widgets', array('entity' => $group));
+ $sidebar = elgg_view('groups/sidebar/members', array('entity' => $group));
+ } else {
+ $content .= elgg_view('groups/profile/closed_membership');
+ }
+
+ $params = array(
+ 'content' => $content,
+ 'sidebar' => $sidebar,
+ 'title' => $group->name,
+ 'buttons' => elgg_view('groups/profile/buttons', array('entity' => $group)),
+ 'filter' => '',
+ );
+ $body = elgg_view_layout('content', $params);
+
+ echo elgg_view_page($title, $body);
+}
+
+/**
+ * Group activity page
+ *
+ * @param int $guid Group entity GUID
+ */
+function groups_handle_activity_page($guid) {
+
+ elgg_set_page_owner_guid($guid);
+
+ $group = get_entity($guid);
+ if (!$group || !elgg_instanceof($group, 'group')) {
+ forward();
+ }
+
+ group_gatekeeper();
+
+ $title = elgg_echo('groups:activity');
+
+ elgg_push_breadcrumb($group->name, $group->getURL());
+ elgg_push_breadcrumb($title);
+
+ $content = "Group activity goes here";
+
+ $params = array(
+ 'content' => $content,
+ 'title' => $title,
+ 'buttons' => '',
+ 'filter' => '',
+ );
+ $body = elgg_view_layout('content', $params);
+
+ echo elgg_view_page($title, $body);
+}
diff --git a/mod/groups/membership.php b/mod/groups/membership.php
deleted file mode 100644
index 6af38f4ae..000000000
--- a/mod/groups/membership.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-
- /**
- * Elgg groups 'member of' page
- *
- * @package ElggGroups
- */
-
- require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
- gatekeeper();
- group_gatekeeper();
-
- $limit = get_input("limit", 10);
- $offset = get_input("offset", 0);
-
- if (elgg_get_page_owner_guid() == get_loggedin_userid()) {
- $title = elgg_echo("groups:yours");
- } else $title = elgg_echo("groups:owned");
-
- // Get objects
- $area2 = elgg_view('page/elements/content_header', array('context' => "mine", 'type' => 'groups', 'new_link' => "pg/groups/new"));
-
- elgg_push_context('search');
- // offset is grabbed in the list_entities_from_relationship() function
- $objects = list_entities_from_relationship('member',page_owner(),false,'group','',0, $limit,false, false);
- elgg_pop_context();
-
- $area2 .= $objects;
- $body = elgg_view_layout('one_column_with_sidebar', array('content' => $area1. $area2));
-
- // Finally draw the page
- echo elgg_view_page($title, $body);
-?>
diff --git a/mod/groups/new.php b/mod/groups/new.php
deleted file mode 100644
index 84d1539af..000000000
--- a/mod/groups/new.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
- /**
- * Elgg groups plugin
- *
- * @package ElggGroups
- */
-
- gatekeeper();
-
- set_page_owner(get_loggedin_userid());
-
- // Render the file upload page
- $title = elgg_echo("groups:new");
- $area2 = elgg_view_title($title);
- $area2 .= elgg_view("forms/groups/edit");
-
- $body = elgg_view_layout('one_column_with_sidebar', array('content' => $area1 . $area2));
-
- echo elgg_view_page($title, $body);
-?> \ No newline at end of file
diff --git a/mod/groups/start.php b/mod/groups/start.php
index c2b3dc35b..23936fed7 100644
--- a/mod/groups/start.php
+++ b/mod/groups/start.php
@@ -1,92 +1,92 @@
<?php
- /**
- * Elgg groups plugin
- *
- * @package ElggGroups
- */
-
- /**
- * Initialise the groups plugin.
- * Register actions, set up menus
- */
- function groups_init() {
+/**
+ * Elgg groups plugin
+ *
+ * @package ElggGroups
+ */
+
+/**
+ * Initialise the groups plugin.
+ * Register actions, set up menus
+ */
+function groups_init() {
- global $CONFIG;
-
- // Set up the menu
- $item = new ElggMenuItem('groups', elgg_echo('groups'), 'pg/groups/world');
- elgg_register_menu_item('site', $item);
-
- // Register a page handler, so we can have nice URLs
- register_page_handler('groups','groups_page_handler');
+ global $CONFIG;
- // Register a URL handler for groups and forum topics
- register_entity_url_handler('groups_url','group','all');
- register_entity_url_handler('groups_groupforumtopic_url','object','groupforumtopic');
+ elgg_register_library('elgg:groups', elgg_get_plugin_path() . 'groups/lib/groups.php');
- // Register an icon handler for groups
- register_page_handler('groupicon','groups_icon_handler');
+ // Set up the menu
+ $item = new ElggMenuItem('groups', elgg_echo('groups'), 'pg/groups/world');
+ elgg_register_menu_item('site', $item);
- // Register some actions
- elgg_register_action("groups/edit", $CONFIG->pluginspath . "groups/actions/edit.php");
- elgg_register_action("groups/delete", $CONFIG->pluginspath . "groups/actions/delete.php");
- elgg_register_action("groups/join", $CONFIG->pluginspath . "groups/actions/join.php");
- elgg_register_action("groups/leave", $CONFIG->pluginspath . "groups/actions/leave.php");
- elgg_register_action("groups/joinrequest", $CONFIG->pluginspath . "groups/actions/joinrequest.php");
- elgg_register_action("groups/killrequest", $CONFIG->pluginspath . "groups/actions/groupskillrequest.php");
- elgg_register_action("groups/killinvitation", $CONFIG->pluginspath . "groups/actions/groupskillinvitation.php");
- elgg_register_action("groups/addtogroup", $CONFIG->pluginspath . "groups/actions/addtogroup.php");
- elgg_register_action("groups/invite", $CONFIG->pluginspath . "groups/actions/invite.php");
+ // Register a page handler, so we can have nice URLs
+ register_page_handler('groups', 'groups_page_handler');
- // Add a page owner handler
- //elgg_register_plugin_hook_handler('page_owner', 'system', 'groups_page_owner_handler');
+ // Register a URL handler for groups and forum topics
+ register_entity_url_handler('groups_url', 'group', 'all');
+ register_entity_url_handler('groups_groupforumtopic_url', 'object', 'groupforumtopic');
- // Add some widgets
- elgg_register_widget_type('a_users_groups',elgg_echo('groups:widget:membership'), elgg_echo('groups:widgets:description'));
+ // Register an icon handler for groups
+ register_page_handler('groupicon', 'groups_icon_handler');
+ // Register some actions
+ elgg_register_action("groups/edit", $CONFIG->pluginspath . "groups/actions/edit.php");
+ elgg_register_action("groups/delete", $CONFIG->pluginspath . "groups/actions/delete.php");
+ elgg_register_action("groups/join", $CONFIG->pluginspath . "groups/actions/join.php");
+ elgg_register_action("groups/leave", $CONFIG->pluginspath . "groups/actions/leave.php");
+ elgg_register_action("groups/joinrequest", $CONFIG->pluginspath . "groups/actions/joinrequest.php");
+ elgg_register_action("groups/killrequest", $CONFIG->pluginspath . "groups/actions/groupskillrequest.php");
+ elgg_register_action("groups/killinvitation", $CONFIG->pluginspath . "groups/actions/groupskillinvitation.php");
+ elgg_register_action("groups/addtogroup", $CONFIG->pluginspath . "groups/actions/addtogroup.php");
+ elgg_register_action("groups/invite", $CONFIG->pluginspath . "groups/actions/invite.php");
- //extend some views
- elgg_extend_view('profile/icon','groups/icon');
- elgg_extend_view('css/screen','groups/css');
+ // Add a page owner handler
+ //elgg_register_plugin_hook_handler('page_owner', 'system', 'groups_page_owner_handler');
+ // Add some widgets
+ elgg_register_widget_type('a_users_groups', elgg_echo('groups:widget:membership'), elgg_echo('groups:widgets:description'));
- // Access permissions
- elgg_register_plugin_hook_handler('access:collections:write', 'all', 'groups_write_acl_plugin_hook');
- //elgg_register_plugin_hook_handler('access:collections:read', 'all', 'groups_read_acl_plugin_hook');
- // Notification hooks
- if (is_callable('register_notification_object'))
- register_notification_object('object', 'groupforumtopic', elgg_echo('groupforumtopic:new'));
- elgg_register_plugin_hook_handler('object:notifications','object','group_object_notifications_intercept');
+ //extend some views
+ elgg_extend_view('profile/icon', 'groups/icon');
+ elgg_extend_view('css/screen', 'groups/css');
- // Listen to notification events and supply a more useful message
- elgg_register_plugin_hook_handler('notify:entity:message', 'object', 'groupforumtopic_notify_message');
+ // Access permissions
+ elgg_register_plugin_hook_handler('access:collections:write', 'all', 'groups_write_acl_plugin_hook');
+ //elgg_register_plugin_hook_handler('access:collections:read', 'all', 'groups_read_acl_plugin_hook');
+ // Notification hooks
+ if (is_callable('register_notification_object'))
+ register_notification_object('object', 'groupforumtopic', elgg_echo('groupforumtopic:new'));
+ elgg_register_plugin_hook_handler('object:notifications', 'object', 'group_object_notifications_intercept');
- // add the forum tool option
- add_group_tool_option('forum',elgg_echo('groups:enableforum'),true);
+ // Listen to notification events and supply a more useful message
+ elgg_register_plugin_hook_handler('notify:entity:message', 'object', 'groupforumtopic_notify_message');
- // Now override icons
- elgg_register_plugin_hook_handler('entity:icon:url', 'group', 'groups_groupicon_hook');
+ // add the forum tool option
+ add_group_tool_option('forum', elgg_echo('groups:enableforum'), true);
- // Register profile menu hook
- elgg_register_plugin_hook_handler('profile_menu', 'profile', 'forum_profile_menu');
- elgg_register_plugin_hook_handler('profile_menu', 'profile', 'activity_profile_menu');
+ // Now override icons
+ elgg_register_plugin_hook_handler('entity:icon:url', 'group', 'groups_groupicon_hook');
- // allow ecml in discussion and profiles
- elgg_register_plugin_hook_handler('get_views', 'ecml', 'groups_ecml_views_hook');
- elgg_register_plugin_hook_handler('get_views', 'ecml', 'groupprofile_ecml_views_hook');
+ // Register profile menu hook
+ elgg_register_plugin_hook_handler('profile_menu', 'profile', 'forum_profile_menu');
+ elgg_register_plugin_hook_handler('profile_menu', 'profile', 'activity_profile_menu');
- }
+ // allow ecml in discussion and profiles
+ elgg_register_plugin_hook_handler('get_views', 'ecml', 'groups_ecml_views_hook');
+ elgg_register_plugin_hook_handler('get_views', 'ecml', 'groupprofile_ecml_views_hook');
+}
- /**
- * Event handler for group forum posts
- *
- */
- function group_object_notifications($event, $object_type, $object) {
+/**
+ * Event handler for group forum posts
+ *
+ */
+function group_object_notifications($event, $object_type, $object) {
- static $flag;
- if (!isset($flag)) $flag = 0;
+ static $flag;
+ if (!isset($flag))
+ $flag = 0;
- if (is_callable('object_notifications'))
+ if (is_callable('object_notifications'))
if ($object instanceof ElggObject) {
if ($object->getSubtype() == 'groupforumtopic') {
//if ($object->countAnnotations('group_topic_post') > 0) {
@@ -97,551 +97,534 @@
//}
}
}
-
- }
-
- /**
- * 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;
- }
- }
+}
+
+/**
+ * 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;
}
-
- /**
- * Returns a more meaningful message
- *
- * @param unknown_type $hook
- * @param unknown_type $entity_type
- * @param unknown_type $returnvalue
- * @param unknown_type $params
- */
- function groupforumtopic_notify_message($hook, $entity_type, $returnvalue, $params)
- {
- $entity = $params['entity'];
- $to_entity = $params['to_entity'];
- $method = $params['method'];
- if (($entity instanceof ElggEntity) && ($entity->getSubtype() == 'groupforumtopic'))
- {
-
- $descr = $entity->description;
- $title = $entity->title;
- global $CONFIG;
- $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 get_loggedin_user()->name . ' ' . elgg_echo("groups:viagroups") . ': ' . $title . "\n\n" . $msg . "\n\n" . $entity->getURL();
- }
-
- }
- return null;
- }
-
- /**
- * This function loads a set of default fields into the profile, then triggers a hook letting other plugins to edit
- * add and delete fields.
- *
- * Note: This is a secondary system:init call and is run at a super low priority to guarantee that it is called after all
- * other plugins have initialised.
- */
- function groups_fields_setup()
- {
+ }
+ return null;
+}
+
+/**
+ * Returns a more meaningful message
+ *
+ * @param unknown_type $hook
+ * @param unknown_type $entity_type
+ * @param unknown_type $returnvalue
+ * @param unknown_type $params
+ */
+function groupforumtopic_notify_message($hook, $entity_type, $returnvalue, $params) {
+ $entity = $params['entity'];
+ $to_entity = $params['to_entity'];
+ $method = $params['method'];
+ if (($entity instanceof ElggEntity) && ($entity->getSubtype() == 'groupforumtopic')) {
+
+ $descr = $entity->description;
+ $title = $entity->title;
global $CONFIG;
+ $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 get_loggedin_user()->name . ' ' . elgg_echo("groups:viagroups") . ': ' . $title . "\n\n" . $msg . "\n\n" . $entity->getURL();
+ }
+ }
+ return null;
+}
+
+/**
+ * This function loads a set of default fields into the profile, then triggers a hook letting other plugins to edit
+ * add and delete fields.
+ *
+ * Note: This is a secondary system:init call and is run at a super low priority to guarantee that it is called after all
+ * other plugins have initialised.
+ */
+function groups_fields_setup() {
+ global $CONFIG;
- $profile_defaults = array(
-
- 'name' => 'text',
- 'description' => 'longtext',
- 'briefdescription' => 'text',
- 'interests' => 'tags',
+ $profile_defaults = array(
+ 'name' => 'text',
+ 'description' => 'longtext',
+ 'briefdescription' => 'text',
+ 'interests' => 'tags',
//'website' => 'url',
- );
+ );
- $CONFIG->group = elgg_trigger_plugin_hook('profile:fields', 'group', NULL, $profile_defaults);
+ $CONFIG->group = elgg_trigger_plugin_hook('profile:fields', 'group', NULL, $profile_defaults);
- // register any tag metadata names
- foreach ($CONFIG->group as $name => $type) {
- if ($type == 'tags') {
- elgg_register_tag_metadata_name($name);
+ // register any tag metadata names
+ foreach ($CONFIG->group as $name => $type) {
+ if ($type == 'tags') {
+ elgg_register_tag_metadata_name($name);
- // register a tag name translation
- add_translation(get_current_language(), array("tag_names:$name" => elgg_echo("groups:$name")));
- }
+ // register a tag name translation
+ add_translation(get_current_language(), array("tag_names:$name" => elgg_echo("groups:$name")));
}
}
+}
- /**
- * Sets up submenus for the groups system. Triggered on pagesetup.
- *
- */
- function groups_submenus() {
- global $CONFIG;
+/**
+ * Sets up submenus for the groups system. Triggered on pagesetup.
+ *
+ */
+function groups_submenus() {
+ global $CONFIG;
- // Get the page owner entity
- $page_owner = elgg_get_page_owner();
+ // Get the page owner entity
+ $page_owner = elgg_get_page_owner();
- if (elgg_get_context() == 'groups') {
- if ($page_owner instanceof ElggGroup) {
- if (isloggedin() && $page_owner->canEdit() && !$page_owner->isPublicMembership()) {
- $url = elgg_get_site_url()."mod/groups/membershipreq.php?group_guid={$page_owner->getGUID()}";
- add_submenu_item(elgg_echo('groups:membershiprequests'), $url, 'groupsactions1');
- }
- } else {
- add_submenu_item(elgg_echo('groups:all'), "pg/groups/world/", 'groupslinks1');
+ if (elgg_get_context() == 'groups') {
+ if ($page_owner instanceof ElggGroup) {
+ if (isloggedin() && $page_owner->canEdit() && !$page_owner->isPublicMembership()) {
+ $url = elgg_get_site_url() . "mod/groups/membershipreq.php?group_guid={$page_owner->getGUID()}";
+ add_submenu_item(elgg_echo('groups:membershiprequests'), $url, 'groupsactions1');
+ }
+ } else {
+ add_submenu_item(elgg_echo('groups:all'), "pg/groups/world/", 'groupslinks1');
- if ($user = get_loggedin_user()) {
- add_submenu_item(elgg_echo('groups:owned'), "pg/groups/owned/$user->username", 'groupslinks1');
- add_submenu_item(elgg_echo('groups:yours'), "pg/groups/member/$user->username", 'groupslinks1');
- add_submenu_item(elgg_echo('groups:invitations'), "pg/groups/invitations/$user->username", 'groupslinks1');
- }
+ if ($user = get_loggedin_user()) {
+ add_submenu_item(elgg_echo('groups:owned'), "pg/groups/owned/$user->username", 'groupslinks1');
+ add_submenu_item(elgg_echo('groups:yours'), "pg/groups/member/$user->username", 'groupslinks1');
+ add_submenu_item(elgg_echo('groups:invitations'), "pg/groups/invitations/$user->username", 'groupslinks1');
}
}
}
-
- /**
- * 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;
+}
+
+/**
+ * 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;
}
- /**
- * 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 'invitations':
- include($CONFIG->pluginspath . "groups/invitations.php");
- $user_guid = get_loggedin_userid();
-
- $invitations = elgg_get_entities_from_relationship(array(
- 'relationship' => 'membership_request',
- 'guid' => $user_guid
- ));
-
- break;
-
- case "new" :
- include($CONFIG->pluginspath . "groups/new.php");
- break;
- case "world":
- elgg_set_context('groups');
- set_page_owner(0);
- include($CONFIG->pluginspath . "groups/all.php");
- break;
- case "forum":
- set_input('group_guid', $page[1]);
- include($CONFIG->pluginspath . "groups/forum.php");
- break;
- case "edittopic":
- set_input('group', $page[1]);
- set_input('topic', $page[2]);
- include($CONFIG->pluginspath . "groups/edittopic.php");
- break;
- case "activity":
- set_input('group', $page[1]);
- include($CONFIG->pluginspath . "groups/activity.php");
- break;
- case "owned" :
- // Owned by a user
- if (isset($page[1]))
- set_input('username',$page[1]);
+ return false;
+}
+
+/**
+ * Groups page handler
+ * URLs take the form of
+ * All groups: pg/groups/all
+ * User's owned groups: pg/groups/owned/<username>
+ * User's member groups: pg/groups/member/<username>
+ * Group profile: pg/groups/profile/<guid>/<title>
+ * New group: pg/groups/add/<guid>
+ * Edit group: pg/groups/edit/<guid>
+ * Group invitations: pg/groups/invitations/<username>
+ * Group activity: pg/groups/activity/<guid>
+ *
+ * @param array $page Array of url segments for routing
+ */
+function groups_page_handler($page) {
+ global $CONFIG;
- include($CONFIG->pluginspath . "groups/index.php");
- break;
- case "member" :
- // User is a member of
- if (isset($page[1]))
- set_input('username',$page[1]);
+ elgg_load_library('elgg:groups');
+
+ elgg_push_breadcrumb(elgg_echo('groups'), "pg/groups/world");
+
+ // beginnings of new page handler
+ switch ($page[0]) {
+ case 'world':
+ groups_handle_all_page();
+ break;
+ case 'owned':
+ set_input('username', $page[1]);
+ groups_handle_owned_page();
+ break;
+ case 'member':
+ set_input('username', $page[1]);
+ groups_handle_mine_page();
+ break;
+ case 'invitations':
+ set_input('username', $page[1]);
+ groups_handle_invitations_page();
+ break;
+ case 'add':
+ groups_handle_edit_page('add');
+ break;
+ case 'edit':
+ groups_handle_edit_page('edit', $page[1]);
+ break;
+ case 'profile':
+ groups_handle_profile_page($page[1]);
+ break;
+ case 'activity':
+ groups_handle_activity_page($page[1]);
+ break;
+ }
- include($CONFIG->pluginspath . "groups/membership.php");
+ // old page handler
+ if (isset($page[0])) {
+ // See what context we're using
+ switch ($page[0]) {
+ case "forum":
+ set_input('group_guid', $page[1]);
+ include($CONFIG->pluginspath . "groups/forum.php");
break;
- default:
- set_input('group_guid', $page[0]);
- include($CONFIG->pluginspath . "groups/groupprofile.php");
+ case "edittopic":
+ set_input('group', $page[1]);
+ set_input('topic', $page[2]);
+ include($CONFIG->pluginspath . "groups/edittopic.php");
break;
- }
}
-
}
+}
- /**
- * Handle group icons.
- *
- * @param unknown_type $page
- */
- function groups_icon_handler($page) {
+/**
+ * Handle group icons.
+ *
+ * @param unknown_type $page
+ */
+function groups_icon_handler($page) {
- global $CONFIG;
-
- // The username should be the file we're getting
- if (isset($page[0])) {
- set_input('group_guid',$page[0]);
- }
- if (isset($page[1])) {
- set_input('size',$page[1]);
- }
- // Include the standard profile index
- include($CONFIG->pluginspath . "groups/graphics/icon.php");
+ global $CONFIG;
+ // The username should be the file we're getting
+ if (isset($page[0])) {
+ set_input('group_guid', $page[0]);
}
-
- /**
- * Populates the ->getUrl() method for group objects
- *
- * @param ElggEntity $entity File entity
- * @return string File URL
- */
- function groups_url($entity) {
- $title = elgg_get_friendly_title($entity->name);
-
- return "pg/groups/{$entity->guid}/$title/";
+ if (isset($page[1])) {
+ set_input('size', $page[1]);
}
-
- function groups_groupforumtopic_url($entity) {
- return 'mod/groups/topicposts.php?topic='. $entity->guid .'&group_guid=' . $entity->container_guid;
+ // Include the standard profile index
+ include($CONFIG->pluginspath . "groups/graphics/icon.php");
+}
+
+/**
+ * Populates the ->getUrl() method for group objects
+ *
+ * @param ElggEntity $entity File entity
+ * @return string File URL
+ */
+function groups_url($entity) {
+ $title = elgg_get_friendly_title($entity->name);
+
+ return "pg/groups/profile/{$entity->guid}/$title";
+}
+
+function groups_groupforumtopic_url($entity) {
+ return 'mod/groups/topicposts.php?topic=' . $entity->guid . '&group_guid=' . $entity->container_guid;
+}
+
+/**
+ * Groups created so create an access list for it
+ */
+function groups_create_event_listener($event, $object_type, $object) {
+ $ac_name = elgg_echo('groups:group') . ": " . $object->name;
+ $group_id = create_access_collection($ac_name, $object->guid);
+ if ($group_id) {
+ $object->group_acl = $group_id;
+ } else {
+ // delete group if access creation fails
+ return false;
}
- /**
- * Groups created so create an access list for it
- */
- function groups_create_event_listener($event, $object_type, $object)
- {
- $ac_name = elgg_echo('groups:group') . ": " . $object->name;
- $group_id = create_access_collection($ac_name, $object->guid);
- if ($group_id) {
- $object->group_acl = $group_id;
- } else {
- // delete group if access creation fails
- 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 = get_loggedin_user();
+ if ($user) {
+ // Not using this because of recursion.
+ // Joining a group automatically add user to ACL,
+ // So just see if they're a member of the ACL.
+ //$membership = get_users_membership($user->guid);
+
+ $members = get_members_of_access_collection($group->group_acl);
+ print_r($members);
+ exit;
+
+ if ($membership) {
+ foreach ($membership as $group)
+ $returnvalue[$user->guid][$group->group_acl] = elgg_echo('groups:group') . ": " . $group->name;
+ return $returnvalue;
}
-
- 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 = get_loggedin_user();
- if ($user)
- {
- // Not using this because of recursion.
- // Joining a group automatically add user to ACL,
- // So just see if they're a member of the ACL.
- //$membership = get_users_membership($user->guid);
-
- $members = get_members_of_access_collection($group->group_acl);
- print_r($members);
- exit;
-
- 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) {
+ $page_owner = elgg_get_page_owner();
+ if (!$loggedin = get_loggedin_user()) {
+ 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)
- {
- $page_owner = elgg_get_page_owner();
- if (!$loggedin = get_loggedin_user()) {
- return $returnvalue;
- }
-
- // only insert group access for current group
- if ($page_owner instanceof ElggGroup && $loggedin) {
- if ($page_owner->isMember($loggedin)) {
- $returnvalue[$page_owner->group_acl] = elgg_echo('groups:group') . ': ' . $page_owner->name;
+ // only insert group access for current group
+ if ($page_owner instanceof ElggGroup && $loggedin) {
+ if ($page_owner->isMember($loggedin)) {
+ $returnvalue[$page_owner->group_acl] = elgg_echo('groups:group') . ': ' . $page_owner->name;
- unset($returnvalue[ACCESS_FRIENDS]);
- }
- } else {
- // if the user owns the group, remove all access collections manually
- // this won't be a problem once the group itself owns the acl.
- $groups = elgg_get_entities_from_relationship(array(
- 'relationship' => 'member',
- 'relationship_guid' => $loggedin->getGUID(),
- 'inverse_relationship' => FALSE,
- 'limit' => 999
- ));
-
- if ($groups) {
- foreach ($groups as $group) {
- unset($returnvalue[$group->group_acl]);
- }
+ unset($returnvalue[ACCESS_FRIENDS]);
+ }
+ } else {
+ // if the user owns the group, remove all access collections manually
+ // this won't be a problem once the group itself owns the acl.
+ $groups = elgg_get_entities_from_relationship(array(
+ 'relationship' => 'member',
+ 'relationship_guid' => $loggedin->getGUID(),
+ 'inverse_relationship' => FALSE,
+ 'limit' => 999
+ ));
+
+ if ($groups) {
+ foreach ($groups as $group) {
+ unset($returnvalue[$group->group_acl]);
}
}
-
- return $returnvalue;
}
- /**
- * Groups deleted, so remove access lists.
- */
- function groups_delete_event_listener($event, $object_type, $object)
- {
- delete_access_collection($object->group_acl);
+ return $returnvalue;
+}
+
+/**
+ * Groups deleted, so remove access lists.
+ */
+function groups_delete_event_listener($event, $object_type, $object) {
+ delete_access_collection($object->group_acl);
+
+ return true;
+}
+
+/**
+ * Listens to a group join event and adds a user to the group's access control
+ *
+ */
+function groups_user_join_event_listener($event, $object_type, $object) {
+
+ $group = $object['group'];
+ $user = $object['user'];
+ $acl = $group->group_acl;
+
+ add_user_to_access_collection($user->guid, $acl);
+
+ return true;
+}
+
+/**
+ * Listens to a group leave event and removes a user from the group's access control
+ *
+ */
+function groups_user_leave_event_listener($event, $object_type, $object) {
+
+ $group = $object['group'];
+ $user = $object['user'];
+ $acl = $group->group_acl;
+
+ remove_user_from_access_collection($user->guid, $acl);
+
+ return true;
+}
+
+/**
+ * This hooks into the getIcon API and provides nice user icons for users where possible.
+ *
+ * @param unknown_type $hook
+ * @param unknown_type $entity_type
+ * @param unknown_type $returnvalue
+ * @param unknown_type $params
+ * @return unknown
+ */
+function groups_groupicon_hook($hook, $entity_type, $returnvalue, $params) {
+ global $CONFIG;
- return true;
- }
+ if ((!$returnvalue) && ($hook == 'entity:icon:url') && ($params['entity'] instanceof ElggGroup)) {
+ $entity = $params['entity'];
+ $type = $entity->type;
+ $viewtype = $params['viewtype'];
+ $size = $params['size'];
- /**
- * Listens to a group join event and adds a user to the group's access control
- *
- */
- function groups_user_join_event_listener($event, $object_type, $object) {
+ if ($icontime = $entity->icontime) {
+ $icontime = "{$icontime}";
+ } else {
+ $icontime = "default";
+ }
- $group = $object['group'];
- $user = $object['user'];
- $acl = $group->group_acl;
+ $filehandler = new ElggFile();
+ $filehandler->owner_guid = $entity->owner_guid;
+ $filehandler->setFilename("groups/" . $entity->guid . $size . ".jpg");
- add_user_to_access_collection($user->guid, $acl);
+ if ($filehandler->exists()) {
+ $url = elgg_get_site_url() . "pg/groupicon/{$entity->guid}/$size/$icontime.jpg";
- return true;
+ return $url;
+ }
}
+}
- /**
- * Listens to a group leave event and removes a user from the group's access control
- *
- */
- function groups_user_leave_event_listener($event, $object_type, $object) {
-
- $group = $object['group'];
- $user = $object['user'];
- $acl = $group->group_acl;
+/**
+ * A simple function to see who can edit a group discussion post
+ * @param the comment $entity
+ * @param user who owns the group $group_owner
+ * @return boolean
+ */
+function groups_can_edit_discussion($entity, $group_owner) {
- remove_user_from_access_collection($user->guid, $acl);
+ //logged in user
+ $user = get_loggedin_userid();
+ if (($entity->owner_guid == $user) || $group_owner == $user || isadminloggedin()) {
return true;
+ } else {
+ return false;
}
-
- /**
- * This hooks into the getIcon API and provides nice user icons for users where possible.
- *
- * @param unknown_type $hook
- * @param unknown_type $entity_type
- * @param unknown_type $returnvalue
- * @param unknown_type $params
- * @return unknown
- */
- function groups_groupicon_hook($hook, $entity_type, $returnvalue, $params)
- {
+}
+
+/**
+ * Overrides topic post getURL() value.
+ *
+ */
+function group_topicpost_url($annotation) {
+ if ($parent = get_entity($annotation->entity_guid)) {
global $CONFIG;
-
- if ((!$returnvalue) && ($hook == 'entity:icon:url') && ($params['entity'] instanceof ElggGroup))
- {
- $entity = $params['entity'];
- $type = $entity->type;
- $viewtype = $params['viewtype'];
- $size = $params['size'];
-
- if ($icontime = $entity->icontime) {
- $icontime = "{$icontime}";
- } else {
- $icontime = "default";
- }
-
- $filehandler = new ElggFile();
- $filehandler->owner_guid = $entity->owner_guid;
- $filehandler->setFilename("groups/" . $entity->guid . $size . ".jpg");
-
- if ($filehandler->exists()) {
- $url = elgg_get_site_url() . "pg/groupicon/{$entity->guid}/$size/$icontime.jpg";
-
- return $url;
- }
- }
+ return 'mod/groups/topicposts.php?topic=' . $parent->guid . '&amp;group_guid=' . $parent->container_guid . '#' . $annotation->id;
}
-
- /**
- * A simple function to see who can edit a group discussion post
- * @param the comment $entity
- * @param user who owns the group $group_owner
- * @return boolean
- */
- function groups_can_edit_discussion($entity, $group_owner)
- {
-
- //logged in user
- $user = get_loggedin_userid();
-
- if (($entity->owner_guid == $user) || $group_owner == $user || isadminloggedin()) {
- return true;
- }else{
- return false;
+}
+
+/**
+ * Grabs groups by invitations
+ * Have to override all access until there's a way override access to getter functions.
+ *
+ * @param $user_guid
+ * @return unknown_type
+ */
+function groups_get_invited_groups($user_guid, $return_guids = FALSE) {
+ $ia = elgg_set_ignore_access(TRUE);
+ $invitations = elgg_get_entities_from_relationship(array('relationship' => 'invited', 'relationship_guid' => $user_guid, 'inverse_relationship' => TRUE, 'limit' => 9999));
+ elgg_set_ignore_access($ia);
+
+ if ($return_guids) {
+ $guids = array();
+ foreach ($invitations as $invitation) {
+ $guids[] = $invitation->getGUID();
}
+ return $guids;
}
- /**
- * Overrides topic post getURL() value.
- *
- */
- function group_topicpost_url($annotation) {
- if ($parent = get_entity($annotation->entity_guid)) {
- global $CONFIG;
- return 'mod/groups/topicposts.php?topic='.$parent->guid.'&amp;group_guid='.$parent->container_guid.'#' . $annotation->id;
- }
- }
+ return $invitations;
+}
- /**
- * Grabs groups by invitations
- * Have to override all access until there's a way override access to getter functions.
- *
- * @param $user_guid
- * @return unknown_type
- */
- function groups_get_invited_groups($user_guid, $return_guids = FALSE) {
- $ia = elgg_set_ignore_access(TRUE);
- $invitations = elgg_get_entities_from_relationship(array('relationship' => 'invited', 'relationship_guid' => $user_guid, 'inverse_relationship' => TRUE, 'limit' => 9999));
- elgg_set_ignore_access($ia);
-
- if ($return_guids) {
- $guids = array();
- foreach ($invitations as $invitation) {
- $guids[] = $invitation->getGUID();
- }
-
- return $guids;
- }
-
- return $invitations;
- }
-
- /**
- * Function to use on groups for access. It will house private, loggedin, public,
- * and the group itself. This is when you don't want other groups or channels in the access options available
- * Returns an array
- **/
-
- function group_access_options($group){
- $access_array = array(0 => 'private',1 => 'logged in users',2 => 'public',$group->group_acl => 'Group: ' . $group->name );
- return $access_array;
- }
+/**
+ * Function to use on groups for access. It will house private, loggedin, public,
+ * and the group itself. This is when you don't want other groups or channels in the access options available
+ * Returns an array
+ * */
+function group_access_options($group) {
+ $access_array = array(0 => 'private', 1 => 'logged in users', 2 => 'public', $group->group_acl => 'Group: ' . $group->name);
+ return $access_array;
+}
- function forum_profile_menu($hook, $entity_type, $return_value, $params) {
- global $CONFIG;
+function forum_profile_menu($hook, $entity_type, $return_value, $params) {
+ global $CONFIG;
- if ($params['owner'] instanceof ElggGroup && $group_owner->forum_enable != 'no') {
- $return_value[] = array(
- 'text' => elgg_echo('groups:forum'),
- 'href' => "pg/groups/forum/{$params['owner']->getGUID()}"
- );
- }
- return $return_value;
+ if ($params['owner'] instanceof ElggGroup && $group_owner->forum_enable != 'no') {
+ $return_value[] = array(
+ 'text' => elgg_echo('groups:forum'),
+ 'href' => "pg/groups/forum/{$params['owner']->getGUID()}"
+ );
}
-
- function activity_profile_menu($hook, $entity_type, $return_value, $params) {
- global $CONFIG;
+ return $return_value;
+}
- if ($params['owner'] instanceof ElggGroup) {
- $return_value[] = array(
- 'text' => elgg_echo('Activity'),
- 'href' => "pg/groups/activity/{$params['owner']->getGUID()}"
- );
- }
- return $return_value;
- }
+function activity_profile_menu($hook, $entity_type, $return_value, $params) {
+ global $CONFIG;
- /**
- * Parse ECML on group discussion views
- *
- * @param unknown_type $hook
- * @param unknown_type $entity_type
- * @param unknown_type $return_value
- * @param unknown_type $params
- */
- function groups_ecml_views_hook($hook, $entity_type, $return_value, $params) {
- $return_value['forum/viewposts'] = elgg_echo('groups:ecml:discussion');
-
- return $return_value;
- }
- /**
- * Parse ECML on group profiles
- *
- * @param unknown_type $hook
- * @param unknown_type $entity_type
- * @param unknown_type $return_value
- * @param unknown_type $params
- */
- function groupprofile_ecml_views_hook($hook, $entity_type, $return_value, $params) {
- $return_value['groups/groupprofile'] = elgg_echo('groups:ecml:groupprofile');
-
- return $return_value;
+ if ($params['owner'] instanceof ElggGroup) {
+ $return_value[] = array(
+ 'text' => elgg_echo('Activity'),
+ 'href' => "pg/groups/activity/{$params['owner']->getGUID()}"
+ );
}
+ return $return_value;
+}
+
+/**
+ * Parse ECML on group discussion views
+ *
+ * @param unknown_type $hook
+ * @param unknown_type $entity_type
+ * @param unknown_type $return_value
+ * @param unknown_type $params
+ */
+function groups_ecml_views_hook($hook, $entity_type, $return_value, $params) {
+ $return_value['forum/viewposts'] = elgg_echo('groups:ecml:discussion');
+
+ return $return_value;
+}
+
+/**
+ * Parse ECML on group profiles
+ *
+ * @param unknown_type $hook
+ * @param unknown_type $entity_type
+ * @param unknown_type $return_value
+ * @param unknown_type $params
+ */
+function groupprofile_ecml_views_hook($hook, $entity_type, $return_value, $params) {
+ $return_value['groups/groupprofile'] = elgg_echo('groups:ecml:groupprofile');
+
+ return $return_value;
+}
+
+register_extender_url_handler('group_topicpost_url', 'annotation', 'group_topic_post');
+
+// Register a handler for create groups
+elgg_register_event_handler('create', 'group', 'groups_create_event_listener');
+
+// Register a handler for delete groups
+elgg_register_event_handler('delete', 'group', 'groups_delete_event_listener');
+
+// Make sure the groups initialisation function is called on initialisation
+elgg_register_event_handler('init', 'system', 'groups_init');
+elgg_register_event_handler('init', 'system', 'groups_fields_setup', 10000); // Ensure this runs after other plugins
+elgg_register_event_handler('join', 'group', 'groups_user_join_event_listener');
+elgg_register_event_handler('leave', 'group', 'groups_user_leave_event_listener');
+elgg_register_event_handler('pagesetup', 'system', 'groups_submenus');
+elgg_register_event_handler('annotate', 'all', 'group_object_notifications');
+
+// Register actions
+global $CONFIG;
+elgg_register_action("groups/addtopic", $CONFIG->pluginspath . "groups/actions/forums/addtopic.php");
+elgg_register_action("groups/deletetopic", $CONFIG->pluginspath . "groups/actions/forums/deletetopic.php");
+elgg_register_action("groups/addpost", $CONFIG->pluginspath . "groups/actions/forums/addpost.php");
+elgg_register_action("groups/edittopic", $CONFIG->pluginspath . "groups/actions/forums/edittopic.php");
+elgg_register_action("groups/deletepost", $CONFIG->pluginspath . "groups/actions/forums/deletepost.php");
+elgg_register_action("groups/featured", $CONFIG->pluginspath . "groups/actions/featured.php", 'admin');
+elgg_register_action("groups/editpost", $CONFIG->pluginspath . "groups/actions/forums/editpost.php");
- register_extender_url_handler('group_topicpost_url','annotation', 'group_topic_post');
-
- // Register a handler for create groups
- elgg_register_event_handler('create', 'group', 'groups_create_event_listener');
- // Register a handler for delete groups
- elgg_register_event_handler('delete', 'group', 'groups_delete_event_listener');
-
- // Make sure the groups initialisation function is called on initialisation
- elgg_register_event_handler('init','system','groups_init');
- elgg_register_event_handler('init','system','groups_fields_setup', 10000); // Ensure this runs after other plugins
- elgg_register_event_handler('join','group','groups_user_join_event_listener');
- elgg_register_event_handler('leave','group','groups_user_leave_event_listener');
- elgg_register_event_handler('pagesetup','system','groups_submenus');
- elgg_register_event_handler('annotate','all','group_object_notifications');
-
- // Register actions
- global $CONFIG;
- elgg_register_action("groups/addtopic", $CONFIG->pluginspath . "groups/actions/forums/addtopic.php");
- elgg_register_action("groups/deletetopic", $CONFIG->pluginspath . "groups/actions/forums/deletetopic.php");
- elgg_register_action("groups/addpost", $CONFIG->pluginspath . "groups/actions/forums/addpost.php");
- elgg_register_action("groups/edittopic", $CONFIG->pluginspath . "groups/actions/forums/edittopic.php");
- elgg_register_action("groups/deletepost", $CONFIG->pluginspath . "groups/actions/forums/deletepost.php");
- elgg_register_action("groups/featured", $CONFIG->pluginspath . "groups/actions/featured.php", 'admin');
- elgg_register_action("groups/editpost", $CONFIG->pluginspath . "groups/actions/forums/editpost.php");
-
-?>
diff --git a/mod/groups/views/default/groups/group_sort_menu.php b/mod/groups/views/default/groups/group_sort_menu.php
index b25f682e7..958c4084d 100644
--- a/mod/groups/views/default/groups/group_sort_menu.php
+++ b/mod/groups/views/default/groups/group_sort_menu.php
@@ -1,24 +1,21 @@
<?php
+/**
+ * All groups navigation menu
+ */
- /**
- * A simple view to provide the user with group filters and the number of group on the site
- **/
-
- $num_groups = $vars['count'];
- if(!$num_groups)
- $num_groups = 0;
-
- $filter = $vars['filter'];
+$group_count = (int)elgg_get_entities(array('types' => 'group', 'count' => true));
+
+$selected = elgg_get_array_value('selected', $vars);
//url
$url = elgg_get_site_url() . "pg/groups/world/";
?>
<div class="elgg-tabs margin-top">
-<div class="group_count"><?php echo $num_groups . " " . elgg_echo("groups:count"); ?></div>
+<div class="group_count"><?php echo $group_count . " " . elgg_echo("groups:count"); ?></div>
<ul>
- <li <?php if($filter == "newest") echo "class='selected'"; ?>><a href="<?php echo $url; ?>?filter=newest"><?php echo elgg_echo('groups:newest'); ?></a></li>
- <li <?php if($filter == "pop") echo "class='selected'"; ?>><a href="<?php echo $url; ?>?filter=pop"><?php echo elgg_echo('groups:popular'); ?></a></li>
- <li <?php if($filter == "active") echo "class='selected'"; ?>><a href="<?php echo $url; ?>?filter=active"><?php echo elgg_echo('groups:latestdiscussion'); ?></a></li>
+ <li <?php if($selected == "newest") echo "class='selected'"; ?>><a href="<?php echo $url; ?>?filter=newest"><?php echo elgg_echo('groups:newest'); ?></a></li>
+ <li <?php if($selected == "pop") echo "class='selected'"; ?>><a href="<?php echo $url; ?>?filter=pop"><?php echo elgg_echo('groups:popular'); ?></a></li>
+ <li <?php if($selected == "active") echo "class='selected'"; ?>><a href="<?php echo $url; ?>?filter=active"><?php echo elgg_echo('groups:latestdiscussion'); ?></a></li>
</ul>
</div>
diff --git a/mod/groups/views/default/groups/profile/buttons.php b/mod/groups/views/default/groups/profile/buttons.php
index 68cd2591a..cd4ee49dd 100644
--- a/mod/groups/views/default/groups/profile/buttons.php
+++ b/mod/groups/views/default/groups/profile/buttons.php
@@ -15,7 +15,7 @@ $actions = array();
// group owners
if ($vars['entity']->canEdit()) {
// edit and invite
- $url = elgg_get_site_url() . "mod/groups/edit.php?group_guid={$vars['entity']->getGUID()}";
+ $url = elgg_get_site_url() . "pg/groups/edit/{$vars['entity']->getGUID()}";
$actions[$url] = elgg_echo('groups:edit');
$url = elgg_get_site_url() . "mod/groups/invite.php?group_guid={$vars['entity']->getGUID()}";
$actions[$url] = elgg_echo('groups:invite');