Permalink
Browse files

Update sla_users and filters functions

  • Loading branch information...
wakdev committed May 21, 2013
1 parent b1df611 commit 2d0bbb533e7ca3b6c39add977e72cc22849c8266
@@ -195,7 +195,6 @@ public function delete_items($id_array) {
public function save_item($id,$values){
if ($id != 0) {
$values=$this->slash->database->escapeArray($values);
$this->slash->database->setQuery("UPDATE ".$this->slash->database_prefix."users set
name='".$values["name"]."',
@@ -209,7 +208,15 @@ public function save_item($id,$values){
");
if (!$this->slash->database->execute()) {
$this->slash->show_fatal_error("QUERY_ERROR",$this->slash->database->getError());
}
}
//Update password
if (!empty($values["_password"])) {
$this->slash->database->setQuery("UPDATE ".$this->slash->database_prefix."users set password='".sha1($values["_password"])."' WHERE id='".$values["id"]."'");
if (!$this->slash->database->execute()) {
$this->slash->show_fatal_error("QUERY_ERROR",$this->slash->database->getError());
}
}
} else {
@@ -266,6 +273,7 @@ public function recovery_fields() {
public function check_fields($values) {
$mess = array();
$filters = new sl_filters();
//Login verification
$sql_values=$this->slash->database->escapeArray($values);
@@ -301,6 +309,11 @@ public function check_fields($values) {
$mess[4]["message"] = $this->slash->trad_word("ERROR_PWD_SHORT");
}
}
if (!$filters->check_mail($values["mail"])){
$mess[5]["message"] = $this->slash->trad_word("ERROR_FIELD_INCORRECT");
}
if (count($mess) > 0){ return $mess; } else { return null; }
}
@@ -149,13 +149,13 @@ public function show_form($id=0, $values=null, $errors=null) {
if (!isset($values["_password"])){$values["_password"]="";}
sl_form::title($this->slash->trad_word("PASSWORD")." * : ");
sl_form::password($mn,3,array("value" => $values["_password"]));
if ($errors[3]["message"]) { sl_form::error($errors[3]["message"]); }
if (isset($errors[3]["message"])) { sl_form::error($errors[3]["message"]); }
sl_form::br(2);
if (!isset($values["_password2"])){$values["_password2"]="";}
sl_form::title($this->slash->trad_word("PASSWORD")." * : ");
sl_form::password($mn,4,array("value" => $values["_password2"]));
if ($errors[4]["message"]) { sl_form::error($errors[4]["message"]); }
if (isset($errors[4]["message"])) { sl_form::error($errors[4]["message"]); }
sl_form::br(2);
if (!isset($values["mail"])){$values["mail"]="";}
@@ -68,31 +68,29 @@ public function is_time($time) {
/**
* Compare date
* @param $first:date First date
* @param $first:date First date
* @param $second:date Seconde date
* @return True if date passed or return false
*/
public function date_compare($first,$second) {
if (strtotime($first) < strtotime($second) ) {
return true;
}else{
return false;
}
try {
$date1 = new DateTime($first);
$date2 = new DateTime($second);
return ($date1 < $date2);
} catch (Exception $e) {
//@todo show warning and callback exception
return null;
}
}
/**
* Check Mail
* @param $mail:mail string
* @return True or false
*/
public function check_mail($mail)
{
$syntaxe='#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,6}$#';
if(preg_match($syntaxe,$mail))
return true;
else
return false;
public function check_mail($mail) {
return filter_var($mail, FILTER_VALIDATE_EMAIL);
}
/**
@@ -139,6 +139,7 @@
//Errors
define("ERROR_FIELD_EMPTY", "Field is empty !");
define("ERROR_FIELD_INCORRECT", "Field is faulty !");
define("ERROR_TITLE_FIELD_EMPTY", "Field title is empty !");
define("ERROR_PWD_SHORT","Password should be at least 3 caracters long");
define("ERROR_FIELD_CHECK", "Some fields are incorrect !");
@@ -139,6 +139,7 @@
//Errors
define("ERROR_FIELD_EMPTY", "Le champs est vide !");
define("ERROR_FIELD_INCORRECT", "Le champs est incorrect !");
define("ERROR_TITLE_FIELD_EMPTY", "Le champs Titre est vide !");
define("ERROR_PWD_SHORT","Le mot de passe doit contenir au moin 3 caract&egrave;res");
define("ERROR_FIELD_CHECK", "Certains champs sont incorrects !");

0 comments on commit 2d0bbb5

Please sign in to comment.