From 9bc9a3e7590ba15039b019da22c60bdd9d9868e0 Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 18 Dec 2010 21:25:54 +0000 Subject: 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 --- engine/lib/users.php | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'engine/lib') 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 @@ -1462,6 +1462,39 @@ function user_create_hook_add_site_relationship($event, $object_type, $object) { add_entity_relationship($object->getGUID(), 'member_of_site', $CONFIG->site->getGUID()); } +/** + * 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 * @@ -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'); -- cgit v1.2.3