aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/users.php
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-12-18 21:25:54 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-12-18 21:25:54 +0000
commit9bc9a3e7590ba15039b019da22c60bdd9d9868e0 (patch)
tree405dd4a5fc8cfd5a9861507200b4c3982547b347 /engine/lib/users.php
parent9ac841f26e05af3515643e44eb5fde30bcfb1b75 (diff)
downloadelgg-9bc9a3e7590ba15039b019da22c60bdd9d9868e0.tar.gz
elgg-9bc9a3e7590ba15039b019da22c60bdd9d9868e0.tar.bz2
pulling the avatar code out of the profile plugin - just some minor icon related code left
git-svn-id: http://code.elgg.org/elgg/trunk@7671 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/users.php')
-rw-r--r--engine/lib/users.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/engine/lib/users.php b/engine/lib/users.php
index b9bf2058f..ee3814fd2 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -1463,6 +1463,39 @@ function user_create_hook_add_site_relationship($event, $object_type, $object) {
}
/**
+ * Serves the user's avatar
+ *
+ * @param string $hook
+ * @param string $entity_type
+ * @param string $returnvalue
+ * @param array $params
+ * @return string
+ */
+function user_avatar_hook($hook, $entity_type, $returnvalue, $params){
+ $entity = $params['entity'];
+ $size = $params['size'];
+ return "pg/avatar/view/{$entity->username}?size=$size";
+}
+
+/**
+ * Avatar page handler
+ *
+ * @param array $page
+ */
+function elgg_avatar_page_handler($page) {
+ global $CONFIG;
+
+ $user = get_user_by_username($page[1]);
+ elgg_set_page_owner_guid($user->guid);
+
+ if ($page[0] == 'edit') {
+ require_once("{$CONFIG->path}pages/avatar/edit.php");
+ } else {
+ require_once("{$CONFIG->path}pages/avatar/view.php");
+ }
+}
+
+/**
* Members page handler
*
* @param array $page url segments
@@ -1526,11 +1559,24 @@ function users_init() {
register_page_handler('resetpassword', 'elgg_user_resetpassword_page_handler');
register_page_handler('login', 'elgg_user_login_page_handler');
register_page_handler('members', 'elgg_members_page_handler');
+ register_page_handler('avatar', 'elgg_avatar_page_handler');
+
//register_page_handler('collections', 'collections_page_handler');
$item = new ElggMenuItem('members', elgg_echo('members'), 'pg/members');
elgg_register_menu_item('site', $item);
+ $user = get_loggedin_user();
+ if ($user) {
+ $params = array(
+ 'name' => 'edit_avatar',
+ 'url' => "pg/avatar/edit/{$user->username}",
+ 'title' => elgg_echo('avatar:edit'),
+ 'contexts' => array('avatar'),
+ );
+ elgg_register_menu_item('page', $params);
+ }
+
elgg_register_action("register", '', 'public');
elgg_register_action("useradd", '', 'public');
elgg_register_action("friends/add");
@@ -1543,6 +1589,8 @@ function users_init() {
//elgg_register_action('friends/editcollection');
//elgg_register_action("user/spotlight");
+ elgg_register_plugin_hook_handler('entity:icon:url', 'user', 'user_avatar_hook');
+
elgg_register_action("usersettings/save");
elgg_register_action("user/passwordreset", '', 'public');