예제 #1
0
 function default_Disp($field_value = "")
 {
     if (!$this->getRData('hidden')) {
         $dbc = $this->getDbCon();
         //$dbc = $GLOBALS['conx'];
         list($tablename, $fielduniqid, $fielddisplay, $defaultvalue, $query) = explode(":", $this->getRData('radiobutton'));
         $qFieldDisplay = new SqlQuery($dbc);
         $qFieldDisplay->query("select  {$fielduniqid}, {$fielddisplay} from {$tablename} where {$fielduniqid}='" . $field_value . "'");
         $avfielddisplay = $qFieldDisplay->fetchArray();
         $fval = "";
         for ($i = 1; $i < count($avfielddisplay); $i++) {
             $fval .= $avfielddisplay[$i] . " ";
         }
         // $fval=$vfielddisplay;
         $fval = substr($fval, 0, strlen($fval) - 2);
         $qFieldDisplay->free();
         $this->processed .= $this->no_PhpCode($fval);
     }
 }
예제 #2
0
 function default_Form($field_value = "")
 {
     if (!$this->getRData("hidden")) {
         //global $conx;
         //$query = new sqlQuery($conx);
         $tableName = "auditlog";
         $columnName = "application";
         $sql = "SHOW COLUMNS FROM {$tableName} LIKE '{$columnName}'";
         $query = new SqlQuery($this->getDbConn());
         $query->query($sql);
         $row = $query->fetchArray();
         $enum = explode("','", preg_replace("/(enum|set)\\('(.+?)'\\)/", "\\2", $row["Type"]));
         $fval = "<select name=\"fields[" . $this->getFieldName() . "]\">";
         for ($i = 0; $i < sizeof($applications); $i++) {
             $fval .= "<option value=\"" . $applications[$i] . "\">" . $applications[$i] . "</option>";
         }
         $fval .= "</select>";
         $this->processed .= $fval;
     }
 }
예제 #3
0
 /**
  * query()  Execute an SQLQuery
  * 
  * Overwrite the query method to add an initial fetch() if the query 
  * returns only one row.
  * Used the setCursor to reset its position to the first record in case
  * a next() method would be executed afterward.
  *
  * @access public
  * @return database result set ressource
  */
 public function query($sql = "", $dbCon = 0)
 {
     $this->setLog($sql);
     parent::query($sql, $dbCon);
     // This sounds good but could be counter intuitive
     // Improved it by reseting the cursor to zero
     // That would make the first call to next() fetch the same data.
     //if ($this->getNumRows() == 1) {
     if ($this->getNumRows() > 0) {
         $result = $this->next();
         $this->setCursor(0);
         return $result;
     }
 }
예제 #4
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 " ;
         }
     }
 }
예제 #5
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");
             }
         }
     }
 }