public function revise($element) { $ids = vtws_getIdComponents($element["id"]); $element = DataTransform::sanitizeForInsert($element, $this->meta); $crmObject = new VtigerCRMObject($this->tabId, true); $crmObject->setObjectId($ids[1]); $error = $crmObject->revise($element); if (!$error) { throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, vtws_getWebserviceTranslatedString('LBL_' . WebServiceErrorCode::$DATABASEQUERYERROR)); } $id = $crmObject->getObjectId(); $error = $crmObject->read($id); if (!$error) { throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, vtws_getWebserviceTranslatedString('LBL_' . WebServiceErrorCode::$DATABASEQUERYERROR)); } return DataTransform::filterAndSanitize($crmObject->getFields(), $this->meta); }
public function update($element) { $ids = vtws_getIdComponents($element["id"]); $element = DataTransform::sanitizeForInsert($element, $this->meta); $crmObject = new VtigerCRMObject($this->tabId, true); $crmObject->setObjectId($ids[1]); $error = $crmObject->update($element); if (!$error) { throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, "Database error while performing required operation"); } $id = $crmObject->getObjectId(); $error = $crmObject->read($id); if (!$error) { throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, "Database error while performing required operation"); } return DataTransform::filterAndSanitize($crmObject->getFields(), $this->meta); }
public function revise($element) { $ids = vtws_getIdComponents($element["id"]); $element = DataTransform::sanitizeForInsert($element, $this->meta); $element = $this->restrictFields($element, true); $success = $this->__retrieve($ids[1]); if (!$success) { throw new WebServiceException(WebServiceErrorCode::$RECORDNOTFOUND, "Record not found"); } $allDetails = $this->getElement(); foreach ($allDetails as $index => $value) { if (!isset($element)) { $element[$index] = $value; } } $success = $this->__revise($element, $ids[1]); if (!$success) { throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, "Database error while performing required operation"); } return $this->retrieve(vtws_getId($this->meta->getEntityId(), $ids[1])); }
public function update($element) { $ids = vtws_getIdComponents($element["id"]); $element = DataTransform::sanitizeForInsert($element, $this->meta); $element = $this->restrictFields($element); $columnStr = 'set ' . implode('=?,', array_keys($element)) . ' =? '; $query = 'update ' . $this->entityTableName . ' ' . $columnStr . 'where ' . $this->meta->getObectIndexColumn() . '=?'; $params = array_values($element); array_push($params, $ids[1]); $result = null; $transactionSuccessful = vtws_runQueryAsTransaction($query, $params, $result); if (!$transactionSuccessful) { throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, "Database error while performing required operation"); } return $this->retrieve(vtws_getId($ids[0], $ids[1])); }
public function update($element) { global $adb; $ids = vtws_getIdComponents($element["id"]); if (!empty($element['filename'])) { $element['filesize'] = $element['filename']['size']; $attachid = SaveAttachmentDB($element); $element['filetype'] = $element['filename']['type']; $element['filename'] = $filename = str_replace(' ', '_', $element['filename']['name']); } $relations = $element['relations']; unset($element['relations']); $element = DataTransform::sanitizeForInsert($element, $this->meta); $crmObject = new VtigerCRMObject($this->tabId, true); $crmObject->setObjectId($ids[1]); $error = $crmObject->update($element); if (!$error) { throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, "Database error while performing required operation"); } $id = $crmObject->getObjectId(); $error = $crmObject->read($id); if (!$error) { throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, "Database error while performing required operation"); } if (!empty($attachid)) { // Link file attached to document $adb->pquery("DELETE from vtiger_seattachmentsrel where crmid=?", array($id)); $adb->pquery("INSERT INTO vtiger_seattachmentsrel(crmid, attachmentsid) VALUES(?,?)", array($id, $attachid)); } // Establish relations //$adb->pquery("DELETE from vtiger_senotesrel where crmid=?",Array($id)); //foreach ($relations as $rel) { // $ids = vtws_getIdComponents($rel); // $relid = $ids[1]; // $adb->pquery("INSERT INTO vtiger_senotesrel(crmid, notesid) VALUES(?,?)",Array($relid, $id)); //} return DataTransform::filterAndSanitize($crmObject->getFields(), $this->meta); }