From 12da36e25bc1bab6b3235117399f265b7514c4f1 Mon Sep 17 00:00:00 2001 From: cash Date: Wed, 26 Jan 2011 12:30:18 +0000 Subject: adding activity module to groups git-svn-id: http://code.elgg.org/elgg/trunk@7941 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/groups/languages/en.php | 3 + mod/groups/start.php | 37 +++++++---- mod/groups/views/default/groups/css.php | 2 +- .../default/groups/profile/activity_module.php | 74 ++++++++++++++++++++++ .../default/groups/profile/activity_widget.php | 35 ---------- .../views/default/groups/profile/widgets.php | 5 -- 6 files changed, 101 insertions(+), 55 deletions(-) create mode 100644 mod/groups/views/default/groups/profile/activity_module.php delete mode 100644 mod/groups/views/default/groups/profile/activity_widget.php diff --git a/mod/groups/languages/en.php b/mod/groups/languages/en.php index 7ea83bcee..c16db859a 100644 --- a/mod/groups/languages/en.php +++ b/mod/groups/languages/en.php @@ -56,8 +56,11 @@ $english = array( 'groups:viagroups' => "via groups", 'groups:group' => "Group", 'groups:search:tags' => "tag", + 'groups:activity' => "Group activity", + 'groups:enableactivity' => 'Enable group activity', 'groups:no_activity' => "There is no group activity yet", + 'groups:notfound' => "Group not found", 'groups:notfound:details' => "The requested group either does not exist or you do not have access to it", diff --git a/mod/groups/start.php b/mod/groups/start.php index 0abd48571..72ea31480 100644 --- a/mod/groups/start.php +++ b/mod/groups/start.php @@ -50,6 +50,13 @@ function groups_init() { // Add some widgets elgg_register_widget_type('a_users_groups', elgg_echo('groups:widget:membership'), elgg_echo('groups:widgets:description')); + // add group activity tool option + add_group_tool_option('activity', elgg_echo('groups:enableactivity'), true); + elgg_extend_view('groups/tool_latest', 'groups/profile/activity_module'); + + // add link to owner block + elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'groups_activity_owner_block_menu'); + //extend some views elgg_extend_view('profile/icon', 'groups/icon'); @@ -126,7 +133,7 @@ function groups_submenus() { global $CONFIG; // Get the page owner entity - $page_owner = elgg_get_page_owner(); + $page_owner = elgg_get_page_owner_entity(); if (elgg_get_context() == 'groups') { if ($page_owner instanceof ElggGroup) { @@ -257,6 +264,20 @@ function groups_url($entity) { return "pg/groups/profile/{$entity->guid}/$title"; } +/** + * Add owner block link + */ +function groups_activity_owner_block_menu($hook, $type, $return, $params) { + if (elgg_instanceof($params['entity'], 'group')) { + if ($params['entity']->activity_enable != "no") { + $url = "pg/groups/activity/{$params['entity']->guid}"; + $item = new ElggMenuItem('activity', elgg_echo('groups:activity'), $url); + $return[] = $item; + } + } + + return $return; +} /** * Groups created so create an access list for it @@ -302,7 +323,7 @@ function groups_read_acl_plugin_hook($hook, $entity_type, $returnvalue, $params) * 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(); + $page_owner = elgg_get_page_owner_entity(); if (!$loggedin = get_loggedin_user()) { return $returnvalue; } @@ -443,18 +464,6 @@ function group_access_options($group) { return $access_array; } -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; -} - function activity_profile_menu($hook, $entity_type, $return_value, $params) { global $CONFIG; diff --git a/mod/groups/views/default/groups/css.php b/mod/groups/views/default/groups/css.php index 5a7366fe3..5be21e981 100644 --- a/mod/groups/views/default/groups/css.php +++ b/mod/groups/views/default/groups/css.php @@ -17,7 +17,7 @@ margin-right: 30px; } -#group_tools_latest > .elgg-module .elgg-head { +#group_tools_latest > .elgg-module > .elgg-inner > .elgg-head { padding: 5px 5px 3px; background-color: #e4e4e4; border-bottom: 1px solid #cccccc; diff --git a/mod/groups/views/default/groups/profile/activity_module.php b/mod/groups/views/default/groups/profile/activity_module.php new file mode 100644 index 000000000..8a2d587c9 --- /dev/null +++ b/mod/groups/views/default/groups/profile/activity_module.php @@ -0,0 +1,74 @@ +activity_enable == 'no') { + return true; +} + +$group = $vars['entity']; + + +$all_link = elgg_view('output/url', array( + 'href' => "pg/groups/activity/$group->guid", + 'text' => elgg_echo('link:view:all'), +)); + +$header = "$all_link"; +$header .= '

' . elgg_echo('groups:activity') . '

'; + + +elgg_push_context('widgets'); +$content = elgg_list_river(array( + 'limit' => 4, + 'pagination' => false, + 'joins' => array("join {$CONFIG->dbprefix}entities e1 on e1.guid = rv.object_guid"), + 'wheres' => array("(e1.container_guid = $group->guid)"), +)); +elgg_pop_context(); + +if (!$content) { + $content = '

' . elgg_echo('groups:activity:none') . '

'; +} + +$params = array( + 'header' => $header, + 'body' => $content, +); +echo elgg_view('layout/objects/module', $params); + +return true; +?> +"> +

+guid; + $limit = 5; + + $offset = (int) get_input('offset', 0); + + // Sanitise variables -- future proof in case they get sourced elsewhere + $limit = (int) $limit; + $offset = (int) $offset; + $group_guid = (int) $group_guid; + + $sql = "SELECT {$CONFIG->dbprefix}river.id, {$CONFIG->dbprefix}river.type, {$CONFIG->dbprefix}river.subtype, {$CONFIG->dbprefix}river.action_type, {$CONFIG->dbprefix}river.access_id, {$CONFIG->dbprefix}river.view, {$CONFIG->dbprefix}river.subject_guid, {$CONFIG->dbprefix}river.object_guid, {$CONFIG->dbprefix}river.posted FROM {$CONFIG->dbprefix}river INNER JOIN {$CONFIG->dbprefix}entities AS entities1 ON {$CONFIG->dbprefix}river.object_guid = entities1.guid INNER JOIN {$CONFIG->dbprefix}entities AS entities2 ON entities1.container_guid = entities2.guid WHERE entities2.guid = $group_guid OR {$CONFIG->dbprefix}river.object_guid = $group_guid ORDER BY posted DESC limit {$offset},{$limit}"; + + $items = get_data($sql); + + if (count($items) > 0) { + $river_items = elgg_view('river/item/list',array( + 'limit' => $limit, + 'offset' => $offset, + 'items' => $items + )); + } + echo $river_items; + +?> diff --git a/mod/groups/views/default/groups/profile/activity_widget.php b/mod/groups/views/default/groups/profile/activity_widget.php deleted file mode 100644 index 3ac385553..000000000 --- a/mod/groups/views/default/groups/profile/activity_widget.php +++ /dev/null @@ -1,35 +0,0 @@ - -"> -

-guid; - $limit = 5; - - $offset = (int) get_input('offset', 0); - - // Sanitise variables -- future proof in case they get sourced elsewhere - $limit = (int) $limit; - $offset = (int) $offset; - $group_guid = (int) $group_guid; - - $sql = "SELECT {$CONFIG->dbprefix}river.id, {$CONFIG->dbprefix}river.type, {$CONFIG->dbprefix}river.subtype, {$CONFIG->dbprefix}river.action_type, {$CONFIG->dbprefix}river.access_id, {$CONFIG->dbprefix}river.view, {$CONFIG->dbprefix}river.subject_guid, {$CONFIG->dbprefix}river.object_guid, {$CONFIG->dbprefix}river.posted FROM {$CONFIG->dbprefix}river INNER JOIN {$CONFIG->dbprefix}entities AS entities1 ON {$CONFIG->dbprefix}river.object_guid = entities1.guid INNER JOIN {$CONFIG->dbprefix}entities AS entities2 ON entities1.container_guid = entities2.guid WHERE entities2.guid = $group_guid OR {$CONFIG->dbprefix}river.object_guid = $group_guid ORDER BY posted DESC limit {$offset},{$limit}"; - - $items = get_data($sql); - - if (count($items) > 0) { - $river_items = elgg_view('river/item/list',array( - 'limit' => $limit, - 'offset' => $offset, - 'items' => $items - )); - } - echo $river_items; - -?> diff --git a/mod/groups/views/default/groups/profile/widgets.php b/mod/groups/views/default/groups/profile/widgets.php index 3e28c0091..b72932ab3 100644 --- a/mod/groups/views/default/groups/profile/widgets.php +++ b/mod/groups/views/default/groups/profile/widgets.php @@ -7,11 +7,6 @@ // tools widget area echo "
"; - - // activity latest - echo "
"; - echo elgg_view("groups/profile/activity_widget", array('entity' => $vars['entity'])); - echo "
"; // enable tools to extend this area echo elgg_view("groups/tool_latest", array('entity' => $vars['entity'])); -- cgit v1.2.3