Moves makeForlife to PlUser.
[platal.git] / classes / pluser.php
index 746f77b..84bcc60 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2009 Polytechnique.org                              *
+ *  Copyright (C) 2003-2010 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -324,7 +324,7 @@ abstract class PlUser
 
                 if (($user = User::get($login, $callback))) {
                     $list[$i] = $user->$property();
-                } else if (!$strict || User::isForeignEmailAddress($login)) {
+                } else if (!$strict || (User::isForeignEmailAddress($login) && isvalid_email($login))) {
                     $list[$i] = $login;
                 }
             }
@@ -369,6 +369,26 @@ abstract class PlUser
      * served locally by plat/al.
      */
     abstract public static function isForeignEmailAddress($email);
+
+    /**
+     * Creates a user forlive identifier from:
+     * @param $firstname User's firstname
+     * @param $lasttname User's lastname
+     * @param $category  User's promotion or type of account
+     */
+    public static function makeHrid($firstname, $lastname, $category)
+    {
+        assert(trim($category));
+        $plainFirstname = replace_accent(trim($firstname));
+        $plainLastname  = replace_accent(trim($lastname));
+
+        $hrid = strtolower($plainFirstname . '.' . $plainLastname . '.' . trim($category));
+        $hrid = str_replace(' ', '-', $hrid);
+        $hrid = str_replace("'", '', $hrid);
+        return $hrid;
+    }
+
+
 }
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: