Exemplo n.º 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);
     }
 }
Exemplo n.º 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;
     }
 }
Exemplo n.º 3
0
 /**
  * Load Registry from table description
  * This method will load the registry by discovering the different
  * fields type from the table.
  * @param String table_name name of the table
  * @see registryFromXML()
  */
 function registryFromTable($table_name)
 {
     if (is_object($this->dbc)) {
         $qTable = new SqlQuery($this->dbc);
     } else {
         $qTable = new SqlQuery($GLOBALS['conx']);
     }
     $fields = $qTable->getTableField($table_name);
     if (is_array($fields)) {
         $this->setRegistryFromQueryMetadata($fields, $qTable);
     } else {
         $this->setError(" Registry From Table: no field founds for this table: " . $table_name);
     }
 }
Exemplo n.º 4
0
 /**
  * __call magic method to generate DataObject or load data in the object.
  *
  *  This is where the magic happened.
  *  
  *  Those magic methods display saved view, form or saved query as well a manage relations.
  *  ->get_name_of_saved_query will load and run an SQLfusion from the savedquery/ folder.
  *  ->view_name_of_a_serialized_report will load and display a view from the report/ folder.
  *  ->form_name_of_a_serialized_form will load and display a form from the form/ folder.
  *  Relation:
  *  ->GetChildNameOfChildDataObject ($BlogEntries->GetChildComments()) will return an instance of
  *  the child object with a dataset containing only the child entries of the current Object value.
  *  An example is at: http://radria.sqlfusion.com/documentation/core:by_example_php5#relations
  *  ->GetParent... works the same why but look on the Parent relation and will return one record. 
  *
  * @param method name of the method called
  * @param params array of parameters used on the method call.
  */
 public function __call($method, $params)
 {
     try {
         $this->setLog("\n DataObject __call for method:" . $method);
         if (method_exists($this, $method)) {
             return;
         }
         $method_found = false;
         // lets use the method as an ordering.
         if (ereg("^getChild(.*)\$", $method, $match)) {
             $this->setLog("\n DataObject __call for child:" . $match[1]);
             $tablename = strtolower($match[1]);
             $order_limit = $params[0];
             $class_name = $match[1];
             $this->setLog("\n DataObject:" . $tablename . " Doesn exist checking if the table exists");
             $q_tables = new sqlQuery($this->getDbCon());
             $q_tables->getTables();
             $table_found = false;
             if (class_exists($class_name)) {
                 $this->setLog("\n DataObject:" . $class_name . " exist instanciating it with child values");
                 $new_data_object = new $class_name($this->getDbCon());
                 if (strlen($new_data_object->getTable()) > 0) {
                     $tablename = $new_data_object->getTable();
                 }
                 $new_data_object->{$this->getPrimaryKey()} = $this->getPrimaryKeyValue();
                 $new_data_object->query("select * from " . $tablename . " where " . $this->getPrimaryKey() . "=" . $this->getPrimaryKeyValue() . " " . $order_limit);
                 $method_found = true;
                 return $new_data_object;
             } else {
                 $this->setLog("\n DataObject:" . $class_name . " Doesn't exist checking if the table " . $tablename . " exists");
                 while ($tables = $q_tables->fetchArray()) {
                     if ($tablename == $tables[0]) {
                         $table_found = true;
                     }
                 }
                 if ($table_found) {
                     $this->setLog("\nDataObject Table Found creating new data object:" . $tablename);
                     $new_data_object = new DataObject($this->getDbCon());
                     $new_data_object->setTable($tablename);
                     $new_data_object->setPrimaryKey("id" . $tablename);
                     $new_data_object->{$this->getPrimaryKey()} = $this->getData($this->getPrimaryKey());
                     $new_data_object->query("select * from " . $tablename . " where " . $this->getPrimaryKey() . "=" . $this->getData($this->getPrimaryKey()));
                     $method_found = true;
                     //$this->{$tablename} = $new_data_object;
                     return $new_data_object;
                 } else {
                     throw new RadriaException("Table:" . $tablename . " Not Found Could not create an Object");
                 }
             }
         }
         if (ereg("^getParent(.*)\$", $method, $match)) {
             $this->setLog("\n DataObject __call for parent:" . $match[1]);
             $tablename = strtolower($match[1]);
             if (class_exists($tablename) && is_subclass_of($tablename, "DataObject")) {
                 $this->setLog("\n DataObject class for" . $tablename . " exists will instanciate it");
                 $do = new $tablename($this->getDbCon());
                 //$do->query("select * from ".$tablename." where ".$do->getPrimaryKey()."=".$this->getData($do->getPrimaryKey()));
                 $do->getId($this->{$do->getPrimaryKey()});
                 $method_found = true;
                 return $do;
             } else {
                 $this->setLog("\n DataObject class for " . $tablename . " Doesn exist checking if the table exists");
                 $q_tables = new SqlQuery($this->getDbCon());
                 $q_tables->getTables();
                 $table_found = false;
                 while ($tables = $q_tables->fetchArray()) {
                     if ($tablename == $tables[0]) {
                         $table_found = true;
                     }
                 }
                 if ($table_found) {
                     $this->setLog("\n Creating new data object:" . $tablename);
                     $new_data_object = new DataObject($this->getDbCon());
                     $new_data_object->setTable($tablename);
                     $new_data_object->setPrimaryKey("id" . $tablename);
                     $new_data_object->query("select * from " . $tablename . " where " . $new_data_object->getPrimaryKey() . "=" . $this->getData($new_data_object->getPrimaryKey()));
                     $method_found = true;
                     //$this->{$tablename} = $new_data_object;
                     return $new_data_object;
                 } else {
                     throw new RadriaException("Table:" . $tablename . " Not Found");
                 }
             }
         }
         if (!$method_found) {
             //
             throw new RadriaException("Method:" . $method . " Not Found");
             die("Method:" . $method . " Not Found");
         }
         return false;
     } catch (RadriaException $e) {
         $this->setError("\n DataObject Exception: " . $e->getMessage());
         throw new RadriaException($e->getMessage() . " when calling method:" . $method);
     } catch (\Exception $e) {
         trigger_error("Method" . $method . " Not found", E_USER_ERROR);
     }
 }
Exemplo n.º 5
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.º 6
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");
             }
         }
     }
 }