本文整理汇总了PHP中VTWS_PreserveGlobal类的典型用法代码示例。如果您正苦于以下问题:PHP VTWS_PreserveGlobal类的具体用法?PHP VTWS_PreserveGlobal怎么用?PHP VTWS_PreserveGlobal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VTWS_PreserveGlobal类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: vtws_query_related
function vtws_query_related($query, $id, $relatedLabel, $user, $filterClause = null)
{
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);
// Extract related module name from query.
$relatedType = null;
if (preg_match("/FROM\\s+([^\\s]+)/i", $query, $m)) {
$relatedType = trim($m[1]);
}
// Check for presence of expected relation.
$found = false;
$relatedTypes = vtws_relatedtypes($entityName, $user);
foreach ($relatedTypes['information'] as $label => $information) {
if ($label == $relatedLabel && $information['name'] == $relatedType) {
$found = true;
break;
}
}
if (!$found) {
throw new WebServiceException(WebServiceErrorCode::$UNKOWNENTITY, "Relation specified is incorrect");
}
vtws_preserveGlobal('currentModule', $entityName);
// Fetch related record IDs - so we can further retrieve complete information using vtws_query
$relatedWebserviceObject = VtigerWebserviceObject::fromName($adb, $relatedType);
$relatedHandlerPath = $relatedWebserviceObject->getHandlerPath();
$relatedHandlerClass = $relatedWebserviceObject->getHandlerClass();
require_once $relatedHandlerPath;
$relatedHandler = new $relatedHandlerClass($relatedWebserviceObject, $user, $adb, $log);
$relatedIds = $handler->relatedIds($id, $relatedType, $relatedLabel, $relatedHandler);
// Initialize return value
$relatedRecords = array();
// Rewrite query and extract related records if there at least one.
if (!empty($relatedIds)) {
$relatedIdClause = "id IN ('" . implode("','", $relatedIds) . "')";
if (stripos($query, 'WHERE') == false) {
$query .= " WHERE " . $relatedIdClause;
} else {
$queryParts = explode('WHERE', $query);
$query = $queryParts[0] . " WHERE " . $relatedIdClause;
$query .= " AND " . $queryParts[1];
}
if (!empty($filterClause)) {
$query .= " " . $filterClause;
}
$query .= ";";
$relatedRecords = vtws_query($query, $user);
}
VTWS_PreserveGlobal::flush();
return $relatedRecords;
}
示例2: vtws_retrieve
function vtws_retrieve($id, $user)
{
$adb = PearDatabase::getInstance();
$log = vglobal('log');
$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(null, $user);
if (!in_array($entityName, $types['types'])) {
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to perform the operation is denied");
}
if ($meta->hasReadAccess() !== true) {
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to write is denied");
}
if ($entityName !== $webserviceObject->getEntityName()) {
throw new WebServiceException(WebServiceErrorCode::$INVALIDID, "Id specified is incorrect");
}
if (!$meta->hasPermission(EntityMeta::$RETRIEVE, $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");
}
$entity = $handler->retrieve($id);
VTWS_PreserveGlobal::flush();
return $entity;
}
示例3: vtws_changePassword
/**
*
* @param WebserviceId $id
* @param String $oldPassword
* @param String $newPassword
* @param String $confirmPassword
* @param Users $user
*
*/
function vtws_changePassword($id, $oldPassword, $newPassword, $confirmPassword, $user)
{
vtws_preserveGlobal('current_user', $user);
$idComponents = vtws_getIdComponents($id);
if ($idComponents[1] == $user->id || is_admin($user)) {
$newUser = new Users();
$newUser->retrieve_entity_info($idComponents[1], 'Users');
if (!is_admin($user)) {
if (empty($oldPassword)) {
throw new WebServiceException(WebServiceErrorCode::$INVALIDOLDPASSWORD, vtws_getWebserviceTranslatedString('LBL_' . WebServiceErrorCode::$INVALIDOLDPASSWORD));
}
if (!$user->verifyPassword($oldPassword)) {
throw new WebServiceException(WebServiceErrorCode::$INVALIDOLDPASSWORD, vtws_getWebserviceTranslatedString('LBL_' . WebServiceErrorCode::$INVALIDOLDPASSWORD));
}
}
if (strcmp($newPassword, $confirmPassword) === 0) {
$success = $newUser->change_password($oldPassword, $newPassword);
$error = $newUser->db->hasFailedTransaction();
if ($error) {
throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, vtws_getWebserviceTranslatedString('LBL_' . WebServiceErrorCode::$DATABASEQUERYERROR));
}
if (!$success) {
throw new WebServiceException(WebServiceErrorCode::$CHANGEPASSWORDFAILURE, vtws_getWebserviceTranslatedString('LBL_' . WebServiceErrorCode::$CHANGEPASSWORDFAILURE));
}
} else {
throw new WebServiceException(WebServiceErrorCode::$CHANGEPASSWORDFAILURE, vtws_getWebserviceTranslatedString('LBL_' . WebServiceErrorCode::$CHANGEPASSWORDFAILURE));
}
VTWS_PreserveGlobal::flush();
return array('message' => 'Changed password successfully');
}
}
示例4: vtws_setrelation
function vtws_setrelation($relateThisId, $withTheseIds, $user)
{
global $log, $adb;
list($moduleId, $elementId) = vtws_getIdComponents($relateThisId);
$webserviceObject = VtigerWebserviceObject::fromId($adb, $moduleId);
$handlerPath = $webserviceObject->getHandlerPath();
$handlerClass = $webserviceObject->getHandlerClass();
require_once $handlerPath;
$handler = new $handlerClass($webserviceObject, $user, $adb, $log);
$meta = $handler->getMeta();
$moduleName = $meta->getObjectEntityName($relateThisId);
$types = vtws_listtypes(null, $user);
if (!in_array($moduleName, $types['types'])) {
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to perform the operation is denied");
}
if ($moduleName !== $webserviceObject->getEntityName()) {
throw new WebServiceException(WebServiceErrorCode::$INVALIDID, "Id specified is incorrect");
}
if (!$meta->hasPermission(EntityMeta::$UPDATE, $relateThisId)) {
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to read given object is denied");
}
if (!$meta->exists($elementId)) {
throw new WebServiceException(WebServiceErrorCode::$RECORDNOTFOUND, "Record you are trying to access is not found");
}
if ($meta->hasWriteAccess() !== true) {
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to write is denied");
}
vtws_internal_setrelation($elementId, $moduleName, $withTheseIds);
VTWS_PreserveGlobal::flush();
return true;
}
示例5: vtws_update
function vtws_update($element, $user)
{
global $log, $adb;
$idList = vtws_getIdComponents($element['id']);
$webserviceObject = VtigerWebserviceObject::fromId($adb, $idList[0]);
$handlerPath = $webserviceObject->getHandlerPath();
$handlerClass = $webserviceObject->getHandlerClass();
require_once $handlerPath;
$handler = new $handlerClass($webserviceObject, $user, $adb, $log);
$meta = $handler->getMeta();
$entityName = $meta->getObjectEntityName($element['id']);
$types = vtws_listtypes($user);
if (!in_array($entityName, $types['types'])) {
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to perform the operation is denied");
}
if ($entityName !== $webserviceObject->getEntityName()) {
throw new WebServiceException(WebServiceErrorCode::$INVALIDID, "Id specified is incorrect");
}
if (!$meta->hasPermission(EntityMeta::$UPDATE, $element['id'])) {
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to read given object is denied");
}
if (!$meta->exists($idList[1])) {
throw new WebServiceException(WebServiceErrorCode::$RECORDNOTFOUND, "Record you are trying to access is not found");
}
if ($meta->hasWriteAccess() !== true) {
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to write is denied");
}
$referenceFields = $meta->getReferenceFieldDetails();
foreach ($referenceFields as $fieldName => $details) {
if (isset($element[$fieldName]) && strlen($element[$fieldName]) > 0) {
$ids = vtws_getIdComponents($element[$fieldName]);
$elemTypeId = $ids[0];
$elemId = $ids[1];
$referenceObject = VtigerWebserviceObject::fromId($adb, $elemTypeId);
if (!in_array($referenceObject->getEntityName(), $details)) {
throw new WebServiceException(WebServiceErrorCode::$REFERENCEINVALID, "Invalid reference specified for {$fieldName}");
}
if (!in_array($referenceObject->getEntityName(), $types['types'])) {
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to access reference type is denied " . $referenceObject->getEntityName());
}
} else {
if ($element[$fieldName] !== NULL) {
unset($element[$fieldName]);
}
}
}
$meta->hasMandatoryFields($element);
$ownerFields = $meta->getOwnerFields();
if (is_array($ownerFields) && sizeof($ownerFields) > 0) {
foreach ($ownerFields as $ownerField) {
if (isset($element[$ownerField]) && $element[$ownerField] !== null && !$meta->hasAssignPrivilege($element[$ownerField])) {
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Cannot assign record to the given user");
}
}
}
$entity = $handler->update($element);
VTWS_PreserveGlobal::flush();
return $entity;
}
示例6: vtws_retrieve
function vtws_retrieve($id, $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(null, $user);
if (!in_array($entityName, $types['types'])) {
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to perform the operation is denied");
}
if ($meta->hasReadAccess() !== true) {
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to write is denied");
}
if ($entityName !== $webserviceObject->getEntityName()) {
throw new WebServiceException(WebServiceErrorCode::$INVALIDID, "Id specified is incorrect");
}
if (!$meta->hasPermission(EntityMeta::$RETRIEVE, $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");
}
$entity = $handler->retrieve($id);
//return product lines
if ($entityName == 'Quotes' || $entityName == 'PurchaseOrder' || $entityName == 'SalesOrder' || $entityName == 'Invoice') {
list($wsid, $recordid) = explode('x', $id);
$result = $adb->pquery('select * from vtiger_inventoryproductrel where id=?', array($recordid));
while ($row = $adb->getNextRow($result, false)) {
if ($row['discount_amount'] == NULL && $row['discount_percent'] == NULL) {
$discount = 0;
$discount_type = 0;
} else {
$discount = 1;
}
if ($row['discount_amount'] == NULL) {
$discount_amount = 0;
} else {
$discount_amount = $row['discount_amount'];
$discount_type = 'amount';
}
if ($row['discount_percent'] == NULL) {
$discount_percent = 0;
} else {
$discount_percent = $row['discount_percent'];
$discount_type = 'percentage';
}
$onlyPrd = array("productid" => $row['productid'], "comment" => $row['comment'], "qty" => $row['quantity'], "listprice" => $row['listprice'], 'discount' => $discount, "discount_type" => $discount_type, "discount_percentage" => $discount_percent, "discount_amount" => $discount_amount);
$entity['pdoInformation'][] = $onlyPrd;
}
}
VTWS_PreserveGlobal::flush();
return $entity;
}
示例7: vtws_retrievedocattachment
function vtws_retrievedocattachment($all_ids, $returnfile, $user)
{
global $log, $adb;
$entities = array();
$docWSId = vtyiicpng_getWSEntityId('Documents');
$log->debug("Entering function vtws_retrievedocattachment");
$all_ids = "(" . str_replace($docWSId, '', $all_ids) . ")";
$query = "SELECT n.notesid, n.filename, n.filelocationtype\n FROM vtiger_notes n\n INNER JOIN vtiger_crmentity c ON c.crmid=n.notesid\n WHERE n.notesid in {$all_ids} and n.filelocationtype in ('I','E') and c.deleted=0";
$result = $adb->query($query);
$nr = $adb->num_rows($result);
for ($i = 0; $i < $nr; $i++) {
$id = $docWSId . $adb->query_result($result, $i, 'notesid');
$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(null, $user);
if (!in_array($entityName, $types['types'])) {
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to perform the operation is denied");
}
if ($meta->hasReadAccess() !== true) {
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to write is denied");
}
if ($entityName !== $webserviceObject->getEntityName()) {
throw new WebServiceException(WebServiceErrorCode::$INVALIDID, "Id specified is incorrect");
}
if (!$meta->hasPermission(EntityMeta::$RETRIEVE, $id)) {
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to read given object ({$id}) is denied");
}
$ids = vtws_getIdComponents($id);
if (!$meta->exists($ids[1])) {
throw new WebServiceException(WebServiceErrorCode::$RECORDNOTFOUND, "Document Record you are trying to access is not found");
}
$document_id = $ids[1];
$filetype = $adb->query_result($result, $i, 'filelocationtype');
if ($filetype == 'E') {
$entity["recordid"] = $adb->query_result($result, $i, 'notesid');
$entity["filetype"] = $fileType;
$entity["filename"] = $adb->query_result($result, $i, 'filename');
$entity["filesize"] = 0;
$entity["attachment"] = base64_encode('');
} elseif ($filetype == 'I') {
$entity = vtws_retrievedocattachment_get_attachment($document_id, true, $returnfile);
}
$entities[$id] = $entity;
VTWS_PreserveGlobal::flush();
}
// end for ids
$log->debug("Leaving function vtws_retrievedocattachment");
return $entities;
}
示例8: cbws_getrecordimageinfo
function cbws_getrecordimageinfo($id, $user)
{
global $log, $adb, $site_URL;
$log->debug("Entering function cbws_getrecordimageinfo({$id})");
$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(null, $user);
if (!in_array($entityName, $types['types'])) {
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to perform the operation is denied");
}
if ($meta->hasReadAccess() !== true) {
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to read entity is denied");
}
if ($entityName !== $webserviceObject->getEntityName()) {
throw new WebServiceException(WebServiceErrorCode::$INVALIDID, "Id specified is incorrect");
}
if (!$meta->hasPermission(EntityMeta::$RETRIEVE, $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");
}
$ids = vtws_getIdComponents($id);
$pdoid = $ids[1];
$rdo = array();
$query = 'select vtiger_attachments.name, vtiger_attachments.type, vtiger_attachments.attachmentsid, vtiger_attachments.path
from vtiger_attachments
inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_attachments.attachmentsid
inner join vtiger_seattachmentsrel on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid
where (vtiger_crmentity.setype LIKE "%Image" or vtiger_crmentity.setype LIKE "%Attachment")
and deleted=0 and vtiger_seattachmentsrel.crmid=?';
$result_image = $adb->pquery($query, array($pdoid));
$rdo['results'] = $adb->num_rows($result_image);
$rdo['images'] = array();
while ($img = $adb->fetch_array($result_image)) {
$imga = array();
$imga['name'] = $img['name'];
$imga['path'] = $img['path'];
$imga['fullpath'] = $site_URL . '/' . $img['path'] . $img['attachmentsid'] . '_' . $img['name'];
$imga['type'] = $img['type'];
$imga['id'] = $img['attachmentsid'];
$rdo['images'][] = $imga;
}
VTWS_PreserveGlobal::flush();
$log->debug("Leaving function cbws_getrecordimageinfo");
return $rdo;
}
示例9: vtws_listtypes
function vtws_listtypes($user)
{
try {
global $adb, $log;
vtws_preserveGlobal('current_user', $user);
//get All the modules the current user is permitted to Access.
$allModuleNames = getPermittedModuleNames();
if (array_search('Calendar', $allModuleNames) !== false) {
array_push($allModuleNames, 'Events');
}
//get All the CRM entity names.
$webserviceEntities = vtws_getWebserviceEntities();
$accessibleModules = array_values(array_intersect($webserviceEntities['module'], $allModuleNames));
$entities = $webserviceEntities['entity'];
$accessibleEntities = array();
foreach ($entities as $entity) {
$webserviceObject = VtigerWebserviceObject::fromName($adb, $entity);
$handlerPath = $webserviceObject->getHandlerPath();
$handlerClass = $webserviceObject->getHandlerClass();
require_once $handlerPath;
$handler = new $handlerClass($webserviceObject, $user, $adb, $log);
$meta = $handler->getMeta();
if ($meta->hasAccess() === true) {
array_push($accessibleEntities, $entity);
}
}
} catch (WebServiceException $exception) {
throw $exception;
} catch (Exception $exception) {
throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, "An Database error occured while performing the operation");
}
$default_language = VTWS_PreserveGlobal::getGlobal('default_language');
$current_language = vtws_preserveGlobal('current_language', $default_language);
$appStrings = return_application_language($current_language);
$appListString = return_app_list_strings_language($current_language);
vtws_preserveGlobal('app_strings', $appStrings);
vtws_preserveGlobal('app_list_strings', $appListString);
$informationArray = array();
foreach ($accessibleModules as $module) {
$vtigerModule = $module == 'Events' ? 'Calendar' : $module;
$informationArray[$module] = array('isEntity' => true, 'label' => getTranslatedString($module, $vtigerModule), 'singular' => getTranslatedString('SINGLE_' . $module, $vtigerModule));
}
foreach ($accessibleEntities as $entity) {
$label = isset($appStrings[$entity]) ? $appStrings[$entity] : $entity;
$singular = isset($appStrings['SINGLE_' . $entity]) ? $appStrings['SINGLE_' . $entity] : $entity;
$informationArray[$entity] = array('isEntity' => false, 'label' => $label, 'singular' => $singular);
}
VTWS_PreserveGlobal::flush();
return array("types" => array_merge($accessibleModules, $accessibleEntities), 'information' => $informationArray);
}
示例10: vtws_query
function vtws_query($q, $user)
{
static $vtws_query_cache = array();
$adb = PearDatabase::getInstance();
$log = vglobal('log');
// Cache the instance for re-use
$moduleRegex = "/[fF][rR][Oo][Mm]\\s+([^\\s;]+)/";
$moduleName = '';
if (preg_match($moduleRegex, $q, $m)) {
$moduleName = trim($m[1]);
}
if (!isset($vtws_create_cache[$moduleName]['webserviceobject'])) {
$webserviceObject = VtigerWebserviceObject::fromQuery($adb, $q);
$vtws_query_cache[$moduleName]['webserviceobject'] = $webserviceObject;
} else {
$webserviceObject = $vtws_query_cache[$moduleName]['webserviceobject'];
}
// END
$handlerPath = $webserviceObject->getHandlerPath();
$handlerClass = $webserviceObject->getHandlerClass();
require_once $handlerPath;
// Cache the instance for re-use
if (!isset($vtws_query_cache[$moduleName]['handler'])) {
$handler = new $handlerClass($webserviceObject, $user, $adb, $log);
$vtws_query_cache[$moduleName]['handler'] = $handler;
} else {
$handler = $vtws_query_cache[$moduleName]['handler'];
}
// END
// Cache the instance for re-use
if (!isset($vtws_query_cache[$moduleName]['meta'])) {
$meta = $handler->getMeta();
$vtws_query_cache[$moduleName]['meta'] = $meta;
} else {
$meta = $vtws_query_cache[$moduleName]['meta'];
}
// END
$types = vtws_listtypes(null, $user);
if (!in_array($webserviceObject->getEntityName(), $types['types'])) {
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to perform the operation is denied");
}
if (!$meta->hasReadAccess()) {
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to read is denied");
}
$result = $handler->query($q);
VTWS_PreserveGlobal::flush();
return $result;
}
示例11: vtws_describe
function vtws_describe($elementType, $user)
{
global $log, $adb;
$webserviceObject = VtigerWebserviceObject::fromName($adb, $elementType);
$handlerPath = $webserviceObject->getHandlerPath();
$handlerClass = $webserviceObject->getHandlerClass();
require_once $handlerPath;
$handler = new $handlerClass($webserviceObject, $user, $adb, $log);
$meta = $handler->getMeta();
$types = vtws_listtypes(null, $user);
if (!in_array($elementType, $types['types'])) {
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to perform the operation is denied");
}
$entity = $handler->describe($elementType);
VTWS_PreserveGlobal::flush();
return $entity;
}
示例12: cbws_SearchGlobalVar
function cbws_SearchGlobalVar($gvname, $defaultvalue, $gvmodule, $user)
{
global $log, $adb, $current_user;
$entityName = 'GlobalVariable';
$webserviceObject = VtigerWebserviceObject::fromName($adb, $entityName);
$handlerPath = $webserviceObject->getHandlerPath();
$handlerClass = $webserviceObject->getHandlerClass();
require_once $handlerPath;
$handler = new $handlerClass($webserviceObject, $user, $adb, $log);
$meta = $handler->getMeta();
if ($meta->hasReadAccess() !== true) {
return $defaultvalue;
}
require_once 'modules/GlobalVariable/GlobalVariable.php';
$rdo = GlobalVariable::getVariable($gvname, $defaultvalue, $gvmodule, $user->id);
VTWS_PreserveGlobal::flush();
return $rdo;
}
示例13: vtws_query
function vtws_query($q, $user)
{
global $log, $adb;
$webserviceObject = VtigerWebserviceObject::fromQuery($adb, $q);
$handlerPath = $webserviceObject->getHandlerPath();
$handlerClass = $webserviceObject->getHandlerClass();
require_once $handlerPath;
$handler = new $handlerClass($webserviceObject, $user, $adb, $log);
$meta = $handler->getMeta();
$types = vtws_listtypes(null, $user);
if (!in_array($webserviceObject->getEntityName(), $types['types'])) {
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to perform the operation is denied");
}
if (!$meta->hasReadAccess()) {
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to read is denied");
}
$result = $handler->query($q);
VTWS_PreserveGlobal::flush();
return $result;
}
示例14: vtws_deleteUser
/**
* @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");
}
示例15: cbws_getpdfdata
function cbws_getpdfdata($id, $user)
{
global $log, $adb;
$log->debug("Entering function vtws_getpdfdata");
$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(null, $user);
if (!in_array($entityName, $types['types'])) {
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to perform the operation is denied");
}
if ($meta->hasReadAccess() !== true) {
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to write is denied");
}
if ($entityName !== $webserviceObject->getEntityName()) {
throw new WebServiceException(WebServiceErrorCode::$INVALIDID, "Id specified is incorrect");
}
if (!$meta->hasPermission(EntityMeta::$RETRIEVE, $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");
}
$objectName = $webserviceObject->getEntityName();
if (!in_array($objectName, array('Invoice', 'Quotes', 'SalesOrder', 'PurchaseOrder'))) {
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Only Inventory modules support PDF Output.");
}
$ids = vtws_getIdComponents($id);
$document_id = $ids[1];
$entity = get_module_pdf($objectName, $document_id);
VTWS_PreserveGlobal::flush();
$log->debug("Leaving function vtws_getpdfdata");
return $entity;
}