aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-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
4 files changed, 52 insertions, 5 deletions
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) {