From 736667c429cb84ab62f49814e2fcf94ca2c8b89b Mon Sep 17 00:00:00 2001 From: cash Date: Sun, 6 Feb 2011 22:39:20 +0000 Subject: updated the groups plugin to use the new icon structure git-svn-id: http://code.elgg.org/elgg/trunk@8052 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/groups/icon.php | 2 +- mod/groups/start.php | 92 ++++++++-------------- mod/groups/views/default/group/default.php | 7 +- .../views/default/groups/profile/profile_block.php | 7 +- 4 files changed, 35 insertions(+), 73 deletions(-) (limited to 'mod/groups') diff --git a/mod/groups/icon.php b/mod/groups/icon.php index c72b5f308..f4c0f8010 100644 --- a/mod/groups/icon.php +++ b/mod/groups/icon.php @@ -5,7 +5,7 @@ * @package ElggGroups */ -require_once(dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php"); +require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); $group_guid = get_input('group_guid'); $group = get_entity($group_guid); diff --git a/mod/groups/start.php b/mod/groups/start.php index 58c47c305..5e318a5f1 100644 --- a/mod/groups/start.php +++ b/mod/groups/start.php @@ -27,8 +27,9 @@ function groups_init() { // Register a page handler, so we can have nice URLs register_page_handler('groups', 'groups_page_handler'); - // Register a URL handler for groups + // Register URL handlers for groups register_entity_url_handler('groups_url', 'group', 'all'); + elgg_register_plugin_hook_handler('entity:icon:url', 'group', 'groups_icon_url_override'); // Register an icon handler for groups register_page_handler('groupicon', 'groups_icon_handler'); @@ -46,9 +47,6 @@ function groups_init() { elgg_register_action("groups/invite", "$action_base/invite.php"); elgg_register_action("groups/featured", "$action_base/featured.php", 'admin'); - // 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')); @@ -68,9 +66,6 @@ function groups_init() { 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'); - // Now override icons - elgg_register_plugin_hook_handler('entity:icon:url', 'group', 'groups_groupicon_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'); @@ -151,21 +146,6 @@ function groups_submenus() { } } -/** - * 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; -} - /** * Groups page handler * @@ -261,6 +241,24 @@ function groups_url($entity) { return "pg/groups/profile/{$entity->guid}/$title"; } +/** + * Override the default entity icon for groups + * + * @return string Relative URL + */ +function groups_icon_url_override($hook, $type, $returnvalue, $params) { + $group = $params['entity']; + $size = $params['size']; + + if (isset($group->icontime)) { + // return thumbnail + $icontime = $group->icontime; + return "pg/groupicon/$group->guid/$size/$icontime.jpg"; + } + + return "mod/groups/graphics/default{$size}.gif"; +} + /** * Add owner block link */ @@ -391,41 +389,6 @@ function groups_user_leave_event_listener($event, $object_type, $object) { 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) { - - 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; - } - } -} - /** * Grabs groups by invitations * Have to override all access until there's a way override access to getter functions. @@ -452,11 +415,18 @@ function groups_get_invited_groups($user_guid, $return_guids = FALSE) { /** * 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 - * */ + * and the group itself. This is when you don't want other groups or access lists + * in the access options available. + * + * @return array + */ function group_access_options($group) { - $access_array = array(0 => 'private', 1 => 'logged in users', 2 => 'public', $group->group_acl => 'Group: ' . $group->name); + $access_array = array( + ACCESS_PRIVATE => 'private', + ACCESS_LOGGED_IN => 'logged in users', + ACCESS_PUBLIC => 'public', + $group->group_acl => 'Group: ' . $group->name, + ); return $access_array; } diff --git a/mod/groups/views/default/group/default.php b/mod/groups/views/default/group/default.php index 568867da9..d025a894b 100644 --- a/mod/groups/views/default/group/default.php +++ b/mod/groups/views/default/group/default.php @@ -1,16 +1,13 @@ $group, - 'size' => 'tiny', -)); +$icon = elgg_view_entity_icon($group, 'tiny'); //get the membership type $membership = $group->membership; diff --git a/mod/groups/views/default/groups/profile/profile_block.php b/mod/groups/views/default/groups/profile/profile_block.php index 98595ad07..a0d41ba14 100644 --- a/mod/groups/views/default/groups/profile/profile_block.php +++ b/mod/groups/views/default/groups/profile/profile_block.php @@ -21,12 +21,7 @@ $profile_fields = elgg_get_config('group');
- $group, - 'size' => 'large', - )); - ?> + '')); ?>

-- cgit v1.2.3