aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--_graphics/icons/default/topbar.pngbin0 -> 372 bytes
-rw-r--r--engine/lib/entities.php7
-rw-r--r--mod/profile/icon.php2
-rw-r--r--mod/profile/start.php51
-rw-r--r--mod/profile/views/default/profile/editicon.php2
-rw-r--r--mod/profile/views/default/profile/icon.php2
-rw-r--r--views/default/page_elements/elgg_topbar.php2
7 files changed, 57 insertions, 9 deletions
diff --git a/_graphics/icons/default/topbar.png b/_graphics/icons/default/topbar.png
new file mode 100644
index 000000000..8b6d00755
--- /dev/null
+++ b/_graphics/icons/default/topbar.png
Binary files differ
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index bd42a9edb..3a6e3c035 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -1853,7 +1853,8 @@
case 'master':
case 'large' : $size = 'large'; break;
- case 'topbar' :
+ case 'topbar' : $size = 'topbar'; break;
+
case 'tiny' : $size = 'tiny'; break;
case 'small' : $size = 'small'; break;
@@ -1864,10 +1865,10 @@
$url = false;
- $viewtype = elgg_get_viewtype();
+ $viewtype = elgg_get_viewtype();
// Step one, see if anyone knows how to render this in the current view
- $url = trigger_plugin_hook('entity:icon:url', $type, array('entity' => $entity, 'viewtype' => $viewtype, 'size' => $size), $url);
+ $url = trigger_plugin_hook('entity:icon:url', $entity->getType(), array('entity' => $entity, 'viewtype' => $viewtype, 'size' => $size), $url);
if(!@getimagesize($url))
$url = false; // If not exist then don't use the url
diff --git a/mod/profile/icon.php b/mod/profile/icon.php
index f13ec7322..33a5cde7f 100644
--- a/mod/profile/icon.php
+++ b/mod/profile/icon.php
@@ -24,7 +24,7 @@
$size = "medium";
// Try and get the icon
-
+
$filehandler = new ElggFile();
$filehandler->owner_guid = $user->getGUID();
$filehandler->setFilename("profile/" . $username . $size . ".jpg");
diff --git a/mod/profile/start.php b/mod/profile/start.php
index ff9d142a5..811bffbbd 100644
--- a/mod/profile/start.php
+++ b/mod/profile/start.php
@@ -65,7 +65,10 @@
if (isadminloggedin())
{
extend_view('profile/menu/links','profile/menu/adminwrapper',10000);
- }
+ }
+
+ // Now override icons
+ register_plugin_hook('entity:icon:url', 'user', 'profile_usericon_hook');
}
/**
@@ -127,6 +130,48 @@
function profile_url($user) {
global $CONFIG;
return $CONFIG->wwwroot . "pg/profile/" . $user->username;
+ }
+
+ /**
+ * 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 profile_usericon_hook($hook, $entity_type, $returnvalue, $params)
+ {
+ global $CONFIG;
+
+ if ((!$returnvalue) && ($hook == 'entity:icon:url') && ($params['entity'] instanceof ElggUser))
+ {
+ $entity = $params['entity'];
+ $type = $entity->type;
+ $subtype = get_subtype_from_id($entity->subtype);
+ $viewtype = $params['viewtype'];
+ $size = $params['size'];
+ $username = $entity->username;
+
+ if ($icontime = $entity->icontime) {
+ $icontime = "{$icontime}";
+ } else {
+ $icontime = "default";
+ }
+
+
+ $filehandler = new ElggFile();
+ $filehandler->owner_guid = $entity->getGUID();
+ $filehandler->setFilename("profile/" . $username . $size . ".jpg");
+
+ if ($filehandler->open("read")) {
+ $url = $CONFIG->url . "pg/icon/$username/$size/$icontime.jpg";
+
+
+ return $url;
+ }
+ }
}
// Make sure the profile initialisation function is called on initialisation
@@ -136,7 +181,9 @@
global $CONFIG;
register_action("profile/edit",false,$CONFIG->pluginspath . "profile/actions/edit.php");
register_action("profile/iconupload",false,$CONFIG->pluginspath . "profile/actions/iconupload.php");
- register_action("profile/cropicon",false,$CONFIG->pluginspath . "profile/actions/cropicon.php");
+ register_action("profile/cropicon",false,$CONFIG->pluginspath . "profile/actions/cropicon.php");
+
+
// Define widgets for use in this context
use_widgets('profile');
diff --git a/mod/profile/views/default/profile/editicon.php b/mod/profile/views/default/profile/editicon.php
index 0ab550eee..e3cf6517a 100644
--- a/mod/profile/views/default/profile/editicon.php
+++ b/mod/profile/views/default/profile/editicon.php
@@ -24,7 +24,7 @@
<label><?php echo elgg_echo('profile:currentavatar'); ?></label>
<?php
- $user_avatar = $vars['url'] . "pg/icon/" . $_SESSION['user']->username . "/medium/" . $_SESSION['user']->icontime . ".jpg";
+ $user_avatar = $_SESSION['user']->getIcon('medium');//$vars['url'] . "pg/icon/" . $_SESSION['user']->username . "/medium/" . $_SESSION['user']->icontime . ".jpg";
echo "<img src=\"{$user_avatar}\" alt=\"avatar\" />";
?>
diff --git a/mod/profile/views/default/profile/icon.php b/mod/profile/views/default/profile/icon.php
index 49d87a95f..ef5ab3769 100644
--- a/mod/profile/views/default/profile/icon.php
+++ b/mod/profile/views/default/profile/icon.php
@@ -76,7 +76,7 @@
}
- ?><img src="<?php echo $vars['url']; ?>pg/icon/<?php echo $username; ?>/<?php echo $vars['size']; ?>/<?php echo $icontime; ?>.jpg" border="0" <?php echo $align; ?> title="<?php echo htmlentities($vars['entity']->name, null, 'UTF-8'); ?>" <?php echo $vars['js']; ?> /><?php
+ ?><img src="<?php echo $vars['entity']->getIcon($vars['size']); ?>" border="0" <?php echo $align; ?> title="<?php echo htmlentities($vars['entity']->name, null, 'UTF-8'); ?>" <?php echo $vars['js']; ?> /><?php
if (!$override) {
diff --git a/views/default/page_elements/elgg_topbar.php b/views/default/page_elements/elgg_topbar.php
index 628b8c6d2..3620b7b0c 100644
--- a/views/default/page_elements/elgg_topbar.php
+++ b/views/default/page_elements/elgg_topbar.php
@@ -24,7 +24,7 @@
<div class="toolbarimages">
<a href="http://www.elgg.org" target="_blank"><img src="<?php echo $vars['url']; ?>_graphics/elgg_toolbar_logo.gif" /></a>
- <a href="<?php echo $_SESSION['user']->getURL(); ?>"><img class="user_mini_avatar" src="<?php echo $vars['url']; ?>pg/icon/<?php echo $_SESSION['user']->username; ?>/topbar/<?php echo $_SESSION['user']->timecreated; ?>.jpg"></a>
+ <a href="<?php echo $_SESSION['user']->getURL(); ?>"><img class="user_mini_avatar" src="<?php echo $_SESSION['user']->getIcon('topbar'); ?>"></a>
</div>
<div class="toolbarlinks">