public function delete($id)
 {
     $ids = vtws_getIdComponents($id);
     $elemId = $ids[1];
     $result = null;
     $query = 'update ' . $this->entityTableName . ' set deleted=1 where ' . $this->meta->getObectIndexColumn() . '=?';
     $transactionSuccessful = vtws_runQueryAsTransaction($query, array($elemId), $result);
     if (!$transactionSuccessful) {
         throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, "Database error while performing required operation");
     }
     return array("status" => "successful");
 }
Пример #2
0
/**
 * @author MAK
 */
function vtws_deleteUser($id, $newOwnerId, $user)
{
    global $log, $adb;
    $webserviceObject = VtigerWebserviceObject::fromId($adb, $id);
    $handlerPath = $webserviceObject->getHandlerPath();
    $handlerClass = $webserviceObject->getHandlerClass();
    require_once $handlerPath;
    $handler = new $handlerClass($webserviceObject, $user, $adb, $log);
    $meta = $handler->getMeta();
    $entityName = $meta->getObjectEntityName($id);
    $types = vtws_listtypes($user);
    if (!in_array($entityName, $types['types'])) {
        throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to perform the operation is denied, EntityName = " . $entityName);
    }
    if ($entityName !== $webserviceObject->getEntityName()) {
        throw new WebServiceException(WebServiceErrorCode::$INVALIDID, "Id specified is incorrect");
    }
    if (!$meta->hasPermission(EntityMeta::$DELETE, $id)) {
        throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to read given object is denied");
    }
    $idComponents = vtws_getIdComponents($id);
    if (!$meta->exists($idComponents[1])) {
        throw new WebServiceException(WebServiceErrorCode::$RECORDNOTFOUND, "Record you are trying to access is not found, idComponent = " . $idComponents);
    }
    if ($meta->hasWriteAccess() !== true) {
        throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to write is denied");
    }
    $newIdComponents = vtws_getIdComponents($newOwnerId);
    if (empty($newIdComponents[1])) {
        //force the default user to be the default admin user.
        //added cause eazybusiness team is sending this value empty
        $newIdComponents[1] = 1;
    }
    vtws_transferOwnership($idComponents[1], $newIdComponents[1]);
    //delete from user vtiger_table;
    $sql = "delete from vtiger_users where id=?";
    vtws_runQueryAsTransaction($sql, array($idComponents[1]), $result);
    VTWS_PreserveGlobal::flush();
    return array("status" => "successful");
}
    private function getProductTaxList($productId)
    {
        $db = PearDatabase::getInstance();
        $sql = 'select * from vtiger_producttaxrel inner join vtiger_inventorytaxinfo on
			vtiger_producttaxrel.taxid=vtiger_inventorytaxinfo.taxid and deleted=0
			where productid=?';
        $params = array($productId);
        $result = null;
        $transactionSuccessful = vtws_runQueryAsTransaction($sql, $params, $result);
        if (!$transactionSuccessful) {
            throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, "Database error while performing required operation");
        }
        $it = new SqlResultIterator($db, $result);
        $this->taxList = array();
        foreach ($it as $row) {
            $this->taxList[$row->taxname] = array('label' => $row->taxlabel, 'percentage' => $row->taxpercentage);
        }
        return $this->taxList;
    }
Пример #4
0
 public function __delete($elemId)
 {
     $result = null;
     $query = 'delete from ' . $this->entityTableName . ' where ' . $this->meta->getObectIndexColumn() . '=?';
     $transactionSuccessful = vtws_runQueryAsTransaction($query, array($elemId), $result);
     return $transactionSuccessful;
 }