コード例 #1
0
ファイル: AuieoFields.php プロジェクト: Hassanj343/candidats
 /**
  * Sets an extra field (even if it previously existed).
  * If the requested field not exist, the data will not updated
  * 
  * @param string field name
  * @param string field value
  * @param integer candidate ID
  * @return boolean True if successful; false otherwise.
  */
 public function setValue($field, $value, $moduleID)
 {
     $objSQL = new ClsNaanalSQL();
     $objSQL->addTable("auieo_fields");
     $objSQL->addWhereNew("auieo_fields", "data_item_type", $this->_dataItemType);
     $objSQL->addWhereNew("auieo_fields", "field_name", $field);
     $objSQL->addWhereNew("auieo_fields", "site_id", $this->_siteID);
     $sql = $objSQL->render();
     $row = $this->_db->getAssoc($sql);
     if (empty($row)) {
         return false;
     }
     /* Delete old entries. */
     $sql = sprintf("DELETE FROM\n                extra_field\n            WHERE\n                extra_field.field_name = %s\n            AND\n                extra_field.data_item_id = %s\n            AND\n                extra_field.site_id = %s\n            AND\n                extra_field.data_item_type = %s", $this->_db->makeQueryString($field), $this->_db->makeQueryInteger($moduleID), $this->_siteID, $this->_dataItemType);
     $this->_db->query($sql);
     /* Don't set empty values at all. 0 is okay. */
     if (empty($value) && $value !== 0 && $value !== '0') {
         return false;
     }
     $sql = sprintf("INSERT INTO extra_field (\n                data_item_id,\n                field_name,\n                value,\n                import_id,\n                site_id,\n                data_item_type\n            )\n            VALUES (\n                %s,\n                %s,\n                %s,\n                0,\n                %s,\n                %s\n            )", $this->_db->makeQueryInteger($moduleID), $this->_db->makeQueryString($field), $this->_db->makeQueryString($value), $this->_siteID, $this->_dataItemType);
     return (bool) $this->_db->query($sql);
 }
コード例 #2
0
ファイル: Modules.php プロジェクト: Hassanj343/candidats
 public function copyRecord($id)
 {
     $objSQL = new ClsNaanalSQL();
     $objSQL->addTable($this->module_table);
     $objSQL->addWhereNew($this->module_table, $this->module_id, $id);
     $sql = $objSQL->render();
     $record = $this->_db->getAssoc($sql);
     unset($record[$this->module_id]);
     $objSQL = new ClsNaanalSQL("INSERT");
     $objSQL->addTable($this->module_table);
     foreach ($record as $field => $data) {
         if ($field == "site_id") {
             $objSQL->addValue("site_id", $_GET["siteID"]);
         } else {
             $objSQL->addValue($field, $data);
         }
     }
     $sql = $objSQL->render();
     $this->_db->query($sql);
     $insid = $this->_db->getLastInsertId();
     $efield = new ExtraFields($this->_siteID, $this->data_item_type);
     $records = $efield->getValues($id);
     if ($records) {
         $efield = new ExtraFields($_GET["siteID"], $this->data_item_type);
         foreach ($records as $record) {
             $efield->setValue($record["fieldName"], $record["value"], $insid);
         }
     }
     //if($this->data_item_type===DATA_ITEM_CANDIDATE)
     //{
     $this->copyAttachment($id, $insid, $_GET["siteID"]);
     //}
     return true;
 }