Improves Banana profile form behavious and use FlagSet to store the flags.
[platal.git] / include / platal.inc.php
index 7ab9ef8..6bfd24f 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2007 Polytechnique.org                              *
+ *  Copyright (C) 2003-2008 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -49,6 +49,10 @@ function __autoload($cls)
         if (substr($cls, -3, 3) == 'req') {
             @include 'validations.inc.php';
             return;
+        } else if (substr($cls, 0, 6) == 'banana') {
+            require_once 'banana/banana.inc.php';
+            Banana::load(substr($cls, 6));
+            return;
         }
         @include "$cls.inc.php";
     }
@@ -74,7 +78,8 @@ function pl_error_handler($errno, $errstr, $errfile, $errline)
             E_USER_ERROR      => "User Error",
             E_USER_WARNING    => "User Warning",
             E_USER_NOTICE     => "User Notice",
-            E_STRICT          => "Runtime Notice"
+            E_STRICT          => "Runtime Notice",
+            E_RECOVERABLE_ERROR => "Recoverable Error"
         );
     }
 
@@ -85,10 +90,11 @@ function pl_error_handler($errno, $errstr, $errfile, $errline)
         }
     }
 
+    $type = isset($errortype[$errno]) ? $errortype[$errno] : $errno;
     $errstr = utf8_encode(htmlentities($errstr));
     $GLOBALS['pl_errors'][] =
         "<div class='phperror'>".
-        "<strong>{$errortype[$errno]}</strong> <em>$errstr</em><br />".
+        "<strong>{$type}</strong> <em>$errstr</em><br />".
         "<tt>$errfile : $errline</tt>".
         "</div>";
 }
@@ -134,7 +140,7 @@ function isvalid_email($email)
     // la rfc2822 authorise les caractères "a-z", "0-9", "!", "#", "$", "%", "&", "'", "*", "+", "-", "/", "=", "?", "^",  `", "{", "|", "}", "~" aussi bien dans la partie locale que dans le domaine.
     // Pour la partie locale, on réduit cet ensemble car il n'est pas utilisé.
     // Pour le domaine, le système DNS limite à [a-z0-9.-], on y ajoute le "_" car il est parfois utilisé.
-    return preg_match("/^[a-z0-9_.'+-]+@[a-z0-9._-]+\.[a-z]{2,4}$/i", $email);
+    return preg_match("/^[a-z0-9_.'+-]+@[a-z0-9._-]+\.[a-z]{2,6}$/i", $email);
 }
 
 function pl_url($path, $query = null, $fragment = null)