Skip to content
This repository
Browse code

Closes #417 & #418

git-svn-id: https://code.elgg.org/elgg/trunk@2223 36083f99-b078-4883-b0ff-0f9b5a30f544
  • Loading branch information...
commit b6ccae4fcde10809993a08dfe1af96738b3b2aea 1 parent 6a8eb8b
authored
14  engine/lib/entities.php
@@ -1869,8 +1869,6 @@ function get_entity_icon_url(ElggEntity $entity, $size = 'medium')
1869 1869
 		
1870 1870
 		// Step one, see if anyone knows how to render this in the current view
1871 1871
 		$url = trigger_plugin_hook('entity:icon:url', $entity->getType(), array('entity' => $entity, 'viewtype' => $viewtype, 'size' => $size), $url);
1872  
-		if(!@getimagesize($url))
1873  
-			$url = false; // If not exist then don't use the url
1874 1872
 		
1875 1873
 		// Fail, so use default
1876 1874
 		if (!$url)
@@ -1966,15 +1964,15 @@ function default_entity_icon_hook($hook, $entity_type, $returnvalue, $params)
1966 1964
 			$viewtype = $params['viewtype'];
1967 1965
 			$size = $params['size'];
1968 1966
 			
1969  
-			$url = $CONFIG->url . "views/$viewtype/graphics/icons/$type/$subtype/$size.png";
  1967
+			$url = "views/$viewtype/graphics/icons/$type/$subtype/$size.png";
1970 1968
 			
1971  
-			if(!@getimagesize($url))
1972  
-				$url = $CONFIG->url . "views/$viewtype/graphics/icons/$type/default/$size.png";
  1969
+			if (!@getimagesize($CONFIG->path . $url))
  1970
+				$url = "views/$viewtype/graphics/icons/$type/default/$size.png";
1973 1971
 			
1974  
-			if(!@getimagesize($url))
1975  
-				$url = $CONFIG->url . "views/$viewtype/graphics/icons/default/$size.png";
  1972
+			if(!@getimagesize($CONFIG->path . $url))
  1973
+				$url = "views/$viewtype/graphics/icons/default/$size.png";
1976 1974
 		
1977  
-			return $url;
  1975
+			return $CONFIG->url . $url;
1978 1976
 		}
1979 1977
 	}
1980 1978
 	
BIN  mod/groups/graphics/defaultlarge.jpg
BIN  mod/groups/graphics/defaultmedium.jpg
BIN  mod/groups/graphics/defaultsmall.jpg
BIN  mod/groups/graphics/defaulttiny.jpg
66  mod/groups/start.php
@@ -36,7 +36,7 @@ function groups_init()
36 36
 		register_entity_url_handler('groups_url','group','all');
37 37
 		
38 38
 		// Register an icon handler for groups
39  
-		register_page_handler('icon','groups_icon_handler');
  39
+		register_page_handler('groupicon','groups_icon_handler');
40 40
 		
41 41
 		// Register some actions
42 42
 		register_action("groups/edit",false, $CONFIG->pluginspath . "groups/actions/edit.php");
@@ -78,7 +78,10 @@ function groups_init()
78 78
 			'interests' => 'tags',
79 79
 			'website' => 'url',
80 80
 							   
81  
-		);
  81
+		);
  82
+		
  83
+		// Now override icons
  84
+		register_plugin_hook('entity:icon:url', 'group', 'groups_groupicon_hook');
82 85
 	}
83 86
 	
84 87
 	/**
@@ -194,6 +197,27 @@ function groups_page_handler($page)
194 197
 			}
195 198
 		}
196 199
 		
  200
+	}
  201
+	
  202
+	/**
  203
+	 * Handle group icons.
  204
+	 *
  205
+	 * @param unknown_type $page
  206
+	 */
  207
+	function groups_icon_handler($page) {
  208
+			
  209
+		global $CONFIG;
  210
+		
  211
+		// The username should be the file we're getting
  212
+		if (isset($page[0])) {
  213
+			set_input('group_guid',$page[0]);
  214
+		}
  215
+		if (isset($page[1])) {
  216
+			set_input('size',$page[1]);
  217
+		}
  218
+		// Include the standard profile index
  219
+		include($CONFIG->pluginspath . "groups/graphics/icon.php");
  220
+		
197 221
 	}
198 222
 	
199 223
 	/**
@@ -310,6 +334,44 @@ function groups_user_leave_event_listener($event, $object_type, $object) {
310 334
 		
311 335
 		return true;
312 336
 		
  337
+	}
  338
+
  339
+	/**
  340
+	 * This hooks into the getIcon API and provides nice user icons for users where possible.
  341
+	 *
  342
+	 * @param unknown_type $hook
  343
+	 * @param unknown_type $entity_type
  344
+	 * @param unknown_type $returnvalue
  345
+	 * @param unknown_type $params
  346
+	 * @return unknown
  347
+	 */
  348
+	function groups_groupicon_hook($hook, $entity_type, $returnvalue, $params)
  349
+	{
  350
+		global $CONFIG;
  351
+		
  352
+		if ((!$returnvalue) && ($hook == 'entity:icon:url') && ($params['entity'] instanceof ElggGroup))
  353
+		{
  354
+			$entity = $params['entity'];
  355
+			$type = $entity->type;
  356
+			$viewtype = $params['viewtype'];
  357
+			$size = $params['size'];
  358
+			
  359
+			if ($icontime = $entity->icontime) {
  360
+				$icontime = "{$icontime}";
  361
+			} else {
  362
+				$icontime = "default";
  363
+			}
  364
+			
  365
+			$filehandler = new ElggFile();
  366
+			$filehandler->owner_guid = $entity->owner_guid;
  367
+			$filehandler->setFilename("groups/" . $entity->guid . $size . ".jpg");
  368
+			
  369
+			if ($filehandler->exists()) {
  370
+				$url = $CONFIG->url . "pg/groupicon/{$entity->guid}/$size/$icontime.jpg";
  371
+			
  372
+				return $url;
  373
+			}
  374
+		}
313 375
 	}
314 376
 	
315 377
 	// Register a handler for create groups
2  mod/groups/views/default/groups/icon.php
@@ -38,7 +38,7 @@
38 38
 ?>
39 39
 
40 40
 <div class="groupicon">
41  
-<a href="<?php echo $vars['entity']->getURL(); ?>" class="icon" ><img src="<?php echo $vars['url']; ?>mod/groups/graphics/icon.php?group_guid=<?php echo $group->getGUID(); ?>&size=<?php echo $vars['size']; ?>" border="0" <?php echo $align; ?> title="<?php echo $name; ?>" <?php echo $vars['js']; ?> /></a>
  41
+<a href="<?php echo $vars['entity']->getURL(); ?>" class="icon" ><img src="<?php echo $vars['entity']->getIcon($vars['size']); ?>" border="0" <?php echo $align; ?> title="<?php echo $name; ?>" <?php echo $vars['js']; ?> /></a>
42 42
 </div>
43 43
 
44 44
 <?php

0 notes on commit b6ccae4

Please sign in to comment.
Something went wrong with that request. Please try again.