From 9b3dc5a2c1071461d5e80e0e70d0bc7de736021e Mon Sep 17 00:00:00 2001
From: Michael Fairchild <mfairchild365@gmail.com>
Date: Fri, 26 Feb 2016 13:29:41 -0600
Subject: [PATCH] Also handle legacy profile urls

---
 plugins/unl_avatars/start.php | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/plugins/unl_avatars/start.php b/plugins/unl_avatars/start.php
index 4841e48f..5e4b9012 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]);
+}
-- 
GitLab