Exemplo n.º 1
0
 function eventCheckUsernamePassword(EventControler $evctl)
 {
     /**   Event CheckUsernamePassword
      *
      * To test if passwords matches and there is not already a login and password
      * To work the uniq id of the table must be named as id<table name>.
      * If its a new record the uniqid must be an empty string else a integer..
      * If not it sets the doSave param at "no" to block the save and
      * Call the message page.
      * @package RadriaEvents
      * @author Philippe Lewicki <*****@*****.**>
      * @param array accessfield array with the name of the password and login fields
      * Option :
      * @param string errorpage page to display the errors
      * @copyright SQLFusion
      */
     /*
     $strMissingField  = "Vous devez avoir 1 login et 1 mot de passe" ;
     $strErrorPasswordNotMatch = "Les mots de passe saisie ne correspondent pas ";
     $strErrorLoginAlreadyUsed = "Loggin deja utilise, Vous devez choisir un autre login";
     */
     global $strMissingField, $strErrorPasswordNotMatch, $strErrorLoginAlreadyUsed;
     if (!isset($strMissingField)) {
         $strMissingField = "You need a login and password in the form";
     }
     if (!isset($strErrorPasswordNotMatch)) {
         $strErrorPasswordNotMatch = "The password entries do not match";
     }
     if (!isset($strErrorLoginAlreadyUsed)) {
         $strErrorLoginAlreadyUsed = "The username is already in use";
     }
     $accessfield = $evctl->accessfield;
     $fields = $evctl->fields;
     $fieldrepeatpass = $evctl->fieldrepeatpass;
     $errorpage = $evctl->errorpage;
     $this->setLog("\n Check login & password:"******"\n Repeat pass:"******"Cancel") {
         if (strlen($errorpage) > 0) {
             $dispError = new Display($errorpage);
         } else {
             $dispError = new Display($evctl->getMessagePage());
         }
         $dispError->addParam("message", "");
         if (is_array($accessfield)) {
             if (!isset($table)) {
                 $table = "users";
             }
             $nbraccess = count($accessfield);
             if ($nbraccess != 2) {
                 $dispError->editParam("message", $strMissingField);
             }
             $passwordfield = $accessfield["password"];
             $loginfield = $accessfield["login"];
             $this->setLog("\n Verify pass:"******"message", $strErrorPasswordNotMatch);
             }
             if (get_magic_quotes_gpc()) {
                 $primarykey = stripslashes($primarykey);
             }
             if (strlen($primarykey) > 0) {
                 $queryverif = "select * from " . $table . " where " . $loginfield . "='" . $fields[$loginfield] . "' AND NOT(" . $primarykey . ")";
             } else {
                 $queryverif = "select * from " . $table . " where " . $loginfield . "='" . $fields[$loginfield] . "'";
             }
             $qVerif = new SqlQuery($evctl->getDbCon());
             $rverif = $qVerif->query($queryverif);
             if ($qVerif->getNumRows()) {
                 $dispError->editParam("message", $strErrorLoginAlreadyUsed);
             }
         }
         $error = $dispError->getParam("message");
         if (strlen($error) > 0) {
             $_SESSION["in_page_message"] = $error;
             $evctl->setDisplayNext($dispError);
             $evctl->updateParam("doSave", "no");
             // echo "supposed to be no from here " ;
         }
     }
 }
Exemplo n.º 2
0
 /**   Event FieldType::eventCheckUnique
  *
  * Check that all the field set as required are field in.
  * If not it sets the doSave param at "no" to block the save and
  * call the message page.
  * <br>- param array fields that contains the content of the fields to check
  * <br>- param array required indexed on fields name and contains value "yes"
  * <br>Option:
  * <br>- param string errorpage page to display the error message
  */
 function eventCheckUnique(EventControler $evctl)
 {
     $this->setLog("\n Check Unique , table:" . $this->unique_table_name . " message:" . $this->unique_message);
     if (strlen($this->unique_message) > 0) {
         $validate_message = $this->unique_message;
     } elseif (strlen($this->label) > 0) {
         $validate_message = $this->label . _(" must be unique");
     }
     if ($evctl->submitbutton != _("Cancel") && strlen($this->unique_table_name) > 0) {
         $field_name = $this->getFieldName();
         if ($evctl->unique[$field_name] == "yes") {
             $q_check = new SqlQuery($this->getDbCon());
             $q_check->query("select {$field_name} from " . $this->unique_table_name . " where {$field_name} = '" . $q_check->quote($evctl->fields[$field_name]) . "'");
             if ($q_check->getNumRows() > 0) {
                 if (strlen($evctl->errorpage) > 0) {
                     $urlerror = $evctl->errorpage;
                 } else {
                     $urlerror = $evctl->getMessagePage();
                 }
                 $disp = new Display($urlerror);
                 $disp->addParam("message", $validate_message);
                 $_SESSION['in_page_message'] = $validate_message;
                 $this->setLog("\n Validate message:" . $_SESSION['in_page_message']);
                 $evctl->setDisplayNext($disp);
                 $evctl->updateParam("doSave", "no");
             }
         }
     }
 }