diff --git a/plugins/unl_avatars/start.php b/plugins/unl_avatars/start.php index 4841e48f1b102b54985b4eb58a031f5456368cb4..5e4b90129b70a876860b46150568c3076e961d4d 100644 --- a/plugins/unl_avatars/start.php +++ b/plugins/unl_avatars/start.php @@ -8,21 +8,42 @@ function unl_avatars_init() { elgg_register_event_handler('init','system','unl_avatars_init'); function unl_avatars_pg_handler($segments) { - if ('icon' != $segments[0]) { + if (!isset($segments[0])) { return false; } + if ('profile' == $segments[0]) { + return unl_avatars_pg_profile($segments); + } + + if ('icon' == $segments[0]) { + return unl_avatars_pg_icon($segments); + } + + return false; +} + +function unl_avatars_pg_icon($segments) { if (!isset($segments[1], $segments[2])) { return false; } - + $username = $segments[1]; $size = $segments[2]; - + if (!$user = get_user_by_username($username)) { + //The legacy behavior was to return the default image rather than a 404 forward(elgg_get_simplecache_url("icons/user/default{$size}.gif")); } - + //Forward to the new guy forward('mod/profile/icondirect.php?guid='.$user->guid.'&size='.$size); } + +function unl_avatars_pg_profile($segments) { + if (!isset($segments[1])) { + return false; + } + + forward('profile/'.$segments[1]); +}