]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
updated the groups plugin to use the new icon structure
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sun, 6 Feb 2011 22:39:20 +0000 (22:39 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sun, 6 Feb 2011 22:39:20 +0000 (22:39 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@8052 36083f99-b078-4883-b0ff-0f9b5a30f544

mod/groups/icon.php
mod/groups/start.php
mod/groups/views/default/group/default.php
mod/groups/views/default/groups/profile/profile_block.php

index c72b5f308ecd89c1bd5574c3e716da6fbc44f6c5..f4c0f80109f105e4d83294d235bd925f78be4a93 100644 (file)
@@ -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);
index 58c47c30558702dde0f448b8c3759d93dff89fc3..5e318a5f1eb8c5a4aa6bb27f19e583503b1fafdd 100644 (file)
@@ -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;
 }
 
index 568867da998c8976769c75f1bb9d922960a510cc..d025a894bb3eaa44ad22fefde6c5b11a1904f8ee 100644 (file)
@@ -1,16 +1,13 @@
 <?php 
 /**
- * Elgg groups profile display
+ * Group entity view
  * 
  * @package ElggGroups
  */
 
 $group = $vars['entity'];
 
-$icon = elgg_view("groups/icon", array(
-       'entity' => $group,
-       'size' => 'tiny',
-));
+$icon = elgg_view_entity_icon($group, 'tiny');
 
 //get the membership type
 $membership = $group->membership;
index 98595ad076ddc081ebd367ec87608ffc41eb4df8..a0d41ba1486451fc9ac87aa6cd42ae6c90c1a3cf 100644 (file)
@@ -21,12 +21,7 @@ $profile_fields = elgg_get_config('group');
 <div class="group_profile clearfix">
        <div class="group_profile_column icon">
                <div class="group_profile_icon">
-               <?php
-                       echo elgg_view('groups/icon', array(
-                               'entity' => $group,
-                               'size' => 'large',
-                       ));
-               ?>
+                       <?php echo elgg_view_entity_icon($group, 'large', array('href' => '')); ?>
                </div>
                <div class="group_stats">
                        <p>