public function delete($id) { $ids = vtws_getIdComponents($id); $elemid = $ids[1]; $crmObject = new VtigerCRMObject($this->tabId, true); $error = $crmObject->delete($elemid); if (!$error) { throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, "Database error while performing required operation"); } return array("status" => "successful"); }
public function delete($id) { $ids = vtws_getIdComponents($id); $elemid = $ids[1]; $crmObject = new VtigerCRMObject($this->tabId, true); $error = $crmObject->delete($elemid); if (!$error) { throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, vtws_getWebserviceTranslatedString('LBL_' . WebServiceErrorCode::$DATABASEQUERYERROR)); } return array("status" => "successful"); }
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); }