Example #1
0
 /**
  * Overload the update() method so we can fall back on idcontact as an update key
  */
 function update()
 {
     if ($this->getPrimaryKeyValue()) {
         parent::update();
     } else {
         $this->query("UPDATE " . $this->getTable() . " SET `when`=now() WHERE idcontact=" . $this->idcontact);
     }
 }
 /**
  * Check for submit, therefore all fields must be set 
  */
 protected function checkForSubmit()
 {
     if (!$this->wasSubmitted) {
         return;
     }
     $this->validateAllFieldsets();
     $Failures = FormularField::getValidationFailures();
     if (empty($Failures)) {
         $this->dataObject->setFromArray($_POST);
         if ($this->submitMode == self::$SUBMIT_MODE_CREATE) {
             $this->dataObject->insert();
         } elseif ($this->submitMode == self::$SUBMIT_MODE_EDIT) {
             $this->dataObject->update();
         }
     }
     foreach ($Failures as $message) {
         $this->addFailure($message);
     }
     if (!$this->submitSucceeded() || $this->submitMode == self::$SUBMIT_MODE_EDIT) {
         $this->initFieldsets();
     }
 }
 /**
  * Converts either the given HTTP Body into an array
  * (based on the DataFormatter instance), or returns
  * the POST variables.
  * Automatically filters out certain critical fields
  * that shouldn't be set by the client (e.g. ID).
  *
  * @param DataObject $obj
  * @param DataFormatter $formatter
  * @return DataObject The passed object
  */
 protected function updateDataObject($obj, $formatter)
 {
     // if neither an http body nor POST data is present, return error
     $body = $this->request->getBody();
     if (!$body && !$this->request->postVars()) {
         $this->getResponse()->setStatusCode(204);
         // No Content
         return 'No Content';
     }
     if (!empty($body)) {
         $data = $formatter->convertStringToArray($body);
     } else {
         // assume application/x-www-form-urlencoded which is automatically parsed by PHP
         $data = $this->request->postVars();
     }
     // @todo Disallow editing of certain keys in database
     $data = array_diff_key($data, array('ID', 'Created'));
     $apiAccess = singleton($this->urlParams['ClassName'])->stat('api_access');
     if (is_array($apiAccess) && isset($apiAccess['edit'])) {
         $data = array_intersect_key($data, array_combine($apiAccess['edit'], $apiAccess['edit']));
     }
     $obj->update($data);
     $obj->write();
     return $obj;
 }
 /**
  * Update this with the message, info and write to the database.
  * @param $message
  * @param null $info
  * @return ProgressLogEntry $this
  */
 protected function update_progress($message, $info = null)
 {
     parent::update(array('ResultMessage' => $message, 'ResultInfo' => $info));
     $this->write();
     return $this;
 }
Example #5
0
 /**
  * Overload the update() method to add last update date in UpdateRecordLog
  */
 function update()
 {
     parent::update();
     if ($this->getPrimaryKeyValue() > 0) {
         $rlog = new UpdateRecordLog();
         $rlog->setLastUpdate($this->getTable(), $this->getPrimaryKeyValue());
         // moved to eventUpdateWebView();
         //$q = new sqlQuery($GLOBALS['conx']);
         //$q->query("UPDATE ".$this->getSqlViewName()." SET last_update=now() WHERE idcontact=".$this->getPrimaryKeyValue());
         //$q->free();
         $this->setActivity();
     }
     $_SESSION['refresh_contacts'] = true;
 }
 /**
  * Writes the given language object
  *
  * @param DataObject $languageObj Language object to write
  * @param array      $mainRecord  Main record data of the multilingual DataObject
  *
  * @return void 
  * 
  * @author Roland Lehmann <*****@*****.**>
  * @since 04.01.2012
  */
 public static function writeLanguageObject($languageObj, $mainRecord)
 {
     $record = array();
     foreach ($languageObj->db() as $dbFieldName => $dbFieldType) {
         if (array_key_exists($dbFieldName, $mainRecord)) {
             $record[$dbFieldName] = $mainRecord[$dbFieldName];
         }
     }
     $languageObj->update($record);
     $languageObj->write();
 }