Moving to GitHub.
[platal.git] / plugins / insert.getUserName.php
index ce34a96..8e81c7e 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2011 Polytechnique.org                              *
+ *  Copyright (C) 2003-2014 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -28,27 +28,9 @@ function smarty_insert_getUsername()
         return '';
     }
 
-    $domain = Cookie::v('domain', 'login');
-    if ($domain == 'hruid') {
-        return XDB::fetchOneCell('SELECT  hruid
-                                    FROM  accounts
-                                   WHERE  uid = {?}',
-                                 $id);
-    } elseif ($domain == 'alias') {
-        return XDB::fetchOneCell('SELECT  email
-                                    FROM  email_source_account
-                                   WHERE  uid = {?} AND type = \'alias_aux\'',
-                                 $id);
-    } else {
-        return XDB::fetchOneCell('SELECT  email
-                                    FROM  email_source_account
-                                   WHERE  uid = {?} AND type != \'alias_aux\'
-                                ORDER BY  NOT FIND_IN_SET(\'bestalias\', flags), MIN(email)',
-                                 $id);
-    }
-
-     return '';
+    $user = User::getSilentWithUID($id);
+    return $user->bestEmail();
 }
 
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
 ?>