aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-10-08 11:27:00 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-10-08 11:27:00 +0000
commit939ce5e44c049b0897899c8c7a79544068d2e3b3 (patch)
tree60bd2fab99b295623466d9093acc1449ffd873fb /mod
parent161d44727c9e786f538e9715a566eee76bc7187a (diff)
downloadelgg-939ce5e44c049b0897899c8c7a79544068d2e3b3.tar.gz
elgg-939ce5e44c049b0897899c8c7a79544068d2e3b3.tar.bz2
Closes #301: Profile icons now use getIcon() API. Overrides now possible:
For themes to override, create a plugin hook listening to 'entity:icon:url' and object 'user'. In the hook return a different url. To replace default user icons in a plugin one might create a hook: function profile_usericon_hook($hook, $entity_type, $returnvalue, $params) { if ((!$returnvalue) && ($params['entity'] instanceof ElggUser)) { // return your default graphic here. } } And set it to priority 900 (lower priority than the code that displays a pretty icon for users but higher than the default object display code in entities.php) git-svn-id: https://code.elgg.org/elgg/trunk@2221 36083f99-b078-4883-b0ff-0f9b5a30f544
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) {