
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#	modified:   public_html/includes/class/class.LSerror.php
#	modified:   public_html/includes/class/class.LSsession.php
#
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   public_html/conf/LSobjects/config.LSobjects.LSgroup.php
#	modified:   public_html/conf/LSobjects/config.LSobjects.LSpeople.php
#	modified:   public_html/conf/config.inc.php
#	modified:   public_html/includes/class/class.LSattr_html_select_list.php
#	modified:   public_html/includes/class/class.LSformElement_select.php
#	modified:   public_html/includes/class/class.LSldapObject.php
#	modified:   public_html/includes/class/class.LSsession.php
#	modified:   public_html/templates/default/LSformElement_select.tpl
#	modified:   public_html/view.php
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#	lsexample/import_test.csv
#	public_html/images/default/import.png
#	public_html/import.php
#	public_html/includes/class/class.LSformRule_callable.php
#	public_html/includes/class/class.LSimport.php
#	public_html/includes/class/class.LSioFormat.php
#	public_html/includes/class/class.LSioFormatCSV.php
#	public_html/includes/class/class.LSioFormatDriver.php
#	public_html/templates/default/import.tpl
#	test.php
diff --git a/public_html/includes/class/class.LSerror.php b/public_html/includes/class/class.LSerror.php
index 0da9a1e..8c41d1a 100644
--- a/public_html/includes/class/class.LSerror.php
+++ b/public_html/includes/class/class.LSerror.php
@@ -171,11 +171,57 @@ class LSerror {
     }
     return;
   }
+
+  /**
+   * PHP error handler (see set_error_handler() function doc)
+   **/
+  public function errorHandler($errno, $errstr, $errfile, $errline) {
+    self :: addErrorCode(-2,"Error ".self :: convertPHPErrorNo($errno)." occured in file $errfile (line : $errline) : $errstr");
+    if ( E_RECOVERABLE_ERROR===$errno ) {
+      throw new ErrorException($errstr, $errno, 0, $errfile, $errline);
+    }
+    return False;
+  }
+
+  /**
+   * Convert PHP error number to string
+   * 
+   * @param[in] $errno int Error number
+   * 
+   * @retval string Corresponding error name
+   **/
+  public function convertPHPErrorNo($errno) {
+    $error_levels=array (
+      1       => "ERROR",
+      2       => "WARNING",
+      4       => "PARSE",
+      8       => "NOTICE",
+      16      => "CORE_ERROR",
+      32      => "CORE_WARNING",
+      64      => "COMPILE_ERROR",
+      128     => "COMPILE_WARNING",
+      256     => "USER_ERROR",
+      512     => "USER_WARNING",
+      1024    => "USER_NOTICE",
+      2048    => "STRICT",
+      4096    => "RECOVERABLE_ERROR",
+      8192    => "DEPRECATED",
+      16384   => "USER_DEPRECATED",
+      32767   => "ALL",
+    );
+    if (isset($error_levels[$errno])) {
+      return $error_levels[$errno];
+    }
+    else {
+      return "UNKNOWN_ERROR";
+    }
+  }
 }
 
 /*
  * Error Codes
  */
-LSerror :: defineError(-1,_("Unknown error!"));
+LSerror :: defineError(-1,_("Unknown error : %{error}"));
+LSerror :: defineError(-2,_("PHP error : %{error}"));
 
 ?>
diff --git a/public_html/includes/class/class.LSsession.php b/public_html/includes/class/class.LSsession.php
index 2e0fe94..a0bdae0 100644
--- a/public_html/includes/class/class.LSsession.php
+++ b/public_html/includes/class/class.LSsession.php
@@ -191,6 +191,7 @@ class LSsession {
     if(!self :: loadLSclass('LSerror')) {
       return;
     }
+    set_error_handler(array('LSerror','errorHandler'),E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED & ~E_WARNING);
     self :: defineLSerrors();
     return true;
   }
