Fixes vim mode line.
[platal.git] / classes / pluser.php
index 187f131..e5baf6c 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -146,6 +146,17 @@ abstract class PlUser implements PlUserInterface
         return $this->hruid;
     }
 
+    public function isMe($other)
+    {
+        if (!$other) {
+            return false;
+        } else if ($other instanceof PlUser) {
+            return $other->id() == $this->id();
+        } else {
+            return false;
+        }
+    }
+
     public function bestEmail()
     {
         if (!empty($this->bestalias)) {
@@ -356,7 +367,7 @@ abstract class PlUser implements PlUserInterface
                     $list[$i] = $login;
                 }
             }
-            return $list;
+            return array_unique($list);
         }
         return null;
     }
@@ -392,7 +403,7 @@ abstract class PlUser implements PlUserInterface
 
     private static function stripBadChars($text)
     {
-        return str_replace(array(' ', "'"), array('-', ''),
+        return str_replace(array(' ', "'", '+'), array('-', '', '_'),
                            strtolower(stripslashes(replace_accent(trim($text)))));
     }
 
@@ -415,7 +426,7 @@ abstract class PlUser implements PlUserInterface
     public static function makeHrid($firstname, $lastname, $category)
     {
         $cat = self::stripBadChars($category);
-        if (!cat) {
+        if (!$cat) {
             Platal::page()->kill("$category is not a suitable category.");
         }
 
@@ -443,5 +454,5 @@ abstract class PlUser implements PlUserInterface
     }
 }
 
-// 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:
 ?>