本文整理汇总了PHP中VtigerWebserviceObject::fromName方法的典型用法代码示例。如果您正苦于以下问题:PHP VtigerWebserviceObject::fromName方法的具体用法?PHP VtigerWebserviceObject::fromName怎么用?PHP VtigerWebserviceObject::fromName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VtigerWebserviceObject
的用法示例。
在下文中一共展示了VtigerWebserviceObject::fromName方法的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: fromQuery
static function fromQuery($adb, $query)
{
$moduleRegex = "/[fF][rR][Oo][Mm]\\s+([^\\s;]+)/";
$matches = array();
$found = preg_match($moduleRegex, $query, $matches);
if ($found === 1) {
return VtigerWebserviceObject::fromName($adb, trim($matches[1]));
}
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to perform the operation is denied for query");
}
示例3: 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);
}
示例4: vtws_create
function vtws_create($elementType, $element, $user)
{
$types = vtws_listtypes($user);
if (!in_array($elementType, $types['types'])) {
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to perform the operation is denied");
}
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();
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->create($elementType, $element);
VTWS_PreserveGlobal::flush();
return $entity;
}
示例5: vtws_extendSession
function vtws_extendSession()
{
global $adb, $API_VERSION, $application_unique_key;
if (isset($_SESSION["authenticated_user_id"]) && $_SESSION["app_unique_key"] == $application_unique_key) {
$userId = $_SESSION["authenticated_user_id"];
$sessionManager = new SessionManager();
$sessionManager->set("authenticatedUserId", $userId);
$crmObject = VtigerWebserviceObject::fromName($adb, "Users");
$userId = vtws_getId($crmObject->getEntityId(), $userId);
$vtigerVersion = vtws_getVtigerVersion();
$resp = array("sessionName" => $sessionManager->getSessionId(), "userId" => $userId, "version" => $API_VERSION, "vtigerVersion" => $vtigerVersion);
return $resp;
} else {
throw new WebServiceException(WebServiceErrorCode::$AUTHFAILURE, "Authencation Failed");
}
}
示例6: 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;
}
示例7: 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;
}
示例8: relatedIds
public function relatedIds($id, $relatedModule, $relatedLabel, $relatedHandler = null)
{
$ids = vtws_getIdComponents($id);
$sourceModule = $this->webserviceObject->getEntityName();
global $currentModule;
$currentModule = $sourceModule;
$sourceRecordModel = Vtiger_Record_Model::getInstanceById($ids[1], $sourceModule);
$targetModel = Vtiger_RelationListView_Model::getInstance($sourceRecordModel, $relatedModule, $relatedLabel);
$sql = $targetModel->getRelationQuery();
$relatedWebserviceObject = VtigerWebserviceObject::fromName($adb, $relatedModule);
$relatedModuleWSId = $relatedWebserviceObject->getEntityId();
// Rewrite query to pull only crmid transformed as webservice id.
$sqlFromPart = substr($sql, stripos($sql, ' FROM ') + 6);
$sql = sprintf("SELECT DISTINCT concat('%sx',vtiger_crmentity.crmid) as wsid FROM %s", $relatedModuleWSId, $sqlFromPart);
$rs = $this->pearDB->pquery($sql, array());
$relatedIds = array();
while ($row = $this->pearDB->fetch_array($rs)) {
$relatedIds[] = $row['wsid'];
}
return $relatedIds;
}
示例9: vtws_relatedtypes
function vtws_relatedtypes($elementType, $user)
{
global $adb, $log;
$allowedTypes = vtws_listtypes(null, $user);
$webserviceObject = VtigerWebserviceObject::fromName($adb, $elementType);
$handlerPath = $webserviceObject->getHandlerPath();
$handlerClass = $webserviceObject->getHandlerClass();
require_once $handlerPath;
$handler = new $handlerClass($webserviceObject, $user, $adb, $log);
$meta = $handler->getMeta();
$tabid = $meta->getTabId();
$sql = "SELECT vtiger_relatedlists.label, vtiger_tab.name, vtiger_tab.isentitytype FROM vtiger_relatedlists \n INNER JOIN vtiger_tab ON vtiger_tab.tabid=vtiger_relatedlists.related_tabid \n WHERE vtiger_relatedlists.tabid=? AND vtiger_tab.presence = 0";
$params = array($tabid);
$rs = $adb->pquery($sql, $params);
$return = array('types' => array(), 'information' => array());
while ($row = $adb->fetch_array($rs)) {
if (in_array($row['name'], $allowedTypes['types'])) {
$return['types'][] = $row['name'];
// There can be same module related under different label - so label is our key.
$return['information'][$row['label']] = array('name' => $row['name'], 'label' => $row['label'], 'isEntity' => $row['isentitytype']);
}
}
return $return;
}
示例10: vtws_convertlead
function vtws_convertlead($entityvalues, $user)
{
$adb = PearDatabase::getInstance();
$log = vglobal('log');
$log->debug('Start ' . __CLASS__ . ':' . __FUNCTION__);
if (empty($entityvalues['assignedTo'])) {
$entityvalues['assignedTo'] = vtws_getWebserviceEntityId('Users', $user->id);
}
if (empty($entityvalues['transferRelatedRecordsTo'])) {
$entityvalues['transferRelatedRecordsTo'] = 'Accounts';
}
$leadObject = VtigerWebserviceObject::fromName($adb, 'Leads');
$handlerPath = $leadObject->getHandlerPath();
$handlerClass = $leadObject->getHandlerClass();
require_once $handlerPath;
$leadHandler = new $handlerClass($leadObject, $user, $adb, $log);
$leadInfo = vtws_retrieve($entityvalues['leadId'], $user);
$sql = "select converted from vtiger_leaddetails where converted = 1 and leadid=?";
$leadIdComponents = vtws_getIdComponents($entityvalues['leadId']);
$result = $adb->pquery($sql, array($leadIdComponents[1]));
if ($result === false) {
$log->error('Error converting a lead: ' . vtws_getWebserviceTranslatedString('LBL_' . WebServiceErrorCode::$DATABASEQUERYERROR));
throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, vtws_getWebserviceTranslatedString('LBL_' . WebServiceErrorCode::$DATABASEQUERYERROR));
}
$rowCount = $adb->num_rows($result);
if ($rowCount > 0) {
$log->error('Error converting a lead: Lead is already converted');
throw new WebServiceException(WebServiceErrorCode::$LEAD_ALREADY_CONVERTED, "Lead is already converted");
}
require_once "include/events/include.inc";
$em = new VTEventsManager($adb);
// Initialize Event trigger cache
$em->initTriggerCache();
$entityData = VTEntityData::fromEntityId($adb, $leadIdComponents[1]);
$em->triggerEvent('entity.convertlead.before', [$entityvalues, $user, $leadInfo]);
$entityIds = [];
$availableModules = ['Accounts', 'Contacts', 'Potentials'];
if (!($entityvalues['entities']['Accounts']['create'] || $entityvalues['entities']['Contacts']['create'])) {
return null;
}
foreach ($availableModules as $entityName) {
if ($entityvalues['entities'][$entityName]['create']) {
$entityvalue = $entityvalues['entities'][$entityName];
$entityObject = VtigerWebserviceObject::fromName($adb, $entityvalue['name']);
$handlerPath = $entityObject->getHandlerPath();
$handlerClass = $entityObject->getHandlerClass();
require_once $handlerPath;
$entityHandler = new $handlerClass($entityObject, $user, $adb, $log);
$entityObjectValues = array();
$entityObjectValues['assigned_user_id'] = $entityvalues['assignedTo'];
$entityObjectValues = vtws_populateConvertLeadEntities($entityvalue, $entityObjectValues, $entityHandler, $leadHandler, $leadInfo);
//update potential related to property
if ($entityvalue['name'] == 'Potentials') {
if (!empty($entityIds['Accounts'])) {
$entityObjectValues['related_to'] = $entityIds['Accounts'];
}
if (!empty($entityIds['Contacts'])) {
$entityObjectValues['contact_id'] = $entityIds['Contacts'];
}
}
//update the contacts relation
if ($entityvalue['name'] == 'Contacts') {
if (!empty($entityIds['Accounts'])) {
$entityObjectValues['parent_id'] = $entityIds['Accounts'];
}
}
try {
$create = true;
if ($entityvalue['name'] == 'Accounts' && $entityvalue['convert_to_id'] && is_int($entityvalue['convert_to_id'])) {
$entityIds[$entityName] = vtws_getWebserviceEntityId('Accounts', $entityvalue['convert_to_id']);
$create = false;
}
if ($create) {
$entityRecord = vtws_create($entityvalue['name'], $entityObjectValues, $user);
$entityIds[$entityName] = $entityRecord['id'];
}
} catch (Exception $e) {
$log->error('Error converting a lead: ' . $e->getMessage());
throw new WebServiceException(WebServiceErrorCode::$UNKNOWNOPERATION, $e->getMessage() . ' : ' . $entityvalue['name']);
}
}
}
try {
$accountIdComponents = vtws_getIdComponents($entityIds['Accounts']);
$accountId = $accountIdComponents[1];
$contactIdComponents = vtws_getIdComponents($entityIds['Contacts']);
$contactId = $contactIdComponents[1];
if (!empty($accountId) && !empty($contactId) && !empty($entityIds['Potentials'])) {
$potentialIdComponents = vtws_getIdComponents($entityIds['Potentials']);
$potentialId = $potentialIdComponents[1];
$sql = "insert into vtiger_contpotentialrel values(?,?)";
$result = $adb->pquery($sql, array($contactId, $potentialIdComponents[1]));
if ($result === false) {
throw new WebServiceException(WebServiceErrorCode::$FAILED_TO_CREATE_RELATION, "Failed to related Contact with the Potential");
}
}
$transfered = vtws_convertLeadTransferHandler($leadIdComponents, $entityIds, $entityvalues);
$relatedIdComponents = vtws_getIdComponents($entityIds[$entityvalues['transferRelatedRecordsTo']]);
vtws_getRelatedActivities($leadIdComponents[1], $accountId, $contactId, $relatedIdComponents[1]);
vtws_updateConvertLeadStatus($entityIds, $entityvalues['leadId'], $user);
//.........这里部分代码省略.........
示例11: runOperation
function runOperation($params, $user)
{
global $API_VERSION;
try {
$operation = strtolower($this->operationName);
if (!$this->preLogin) {
$params[] = $user;
return call_user_func_array($this->handlerMethod, $params);
} else {
$userDetails = call_user_func_array($this->handlerMethod, $params);
if (is_array($userDetails)) {
return $userDetails;
} else {
$this->sessionManager->set("authenticatedUserId", $userDetails->id);
global $adb;
$webserviceObject = VtigerWebserviceObject::fromName($adb, "Users");
$userId = vtws_getId($webserviceObject->getEntityId(), $userDetails->id);
$vtigerVersion = vtws_getVtigerVersion();
$resp = array("sessionName" => $this->sessionManager->getSessionId(), "userId" => $userId, "version" => $API_VERSION, "vtigerVersion" => $vtigerVersion);
return $resp;
}
}
} catch (WebServiceException $e) {
throw $e;
} catch (Exception $e) {
throw new WebServiceException(WebServiceErrorCode::$INTERNALERROR, "Unknown Error while processing request");
}
}
示例12: webforms_init
function webforms_init()
{
global $defaultUserName, $defaultUserAccessKey, $defaultOwner, $adb, $enableAppKeyValidation, $application_unique_key;
try {
$active = vtlib_isModuleActive('Webforms');
if ($active === false) {
webforms_returnError(array('code' => "WEBFORMS_DISABLED", 'message' => 'Webforms module is disabled'), 'Webforms');
}
if ($enableAppKeyValidation == true) {
if ($application_unique_key !== $_REQUEST['appKey']) {
webforms_returnError(array('code' => "WEBFORMS_INVALID_APPKEY", 'message' => 'AppKey provided is invalid'), null);
return;
}
}
$module = $_REQUEST['moduleName'];
$challengeResult = vtws_getchallenge($defaultUserName);
$challengeToken = $challengeResult['token'];
$user = vtws_login($defaultUserName, md5($challengeToken . $defaultUserAccessKey));
$describeResult = vtws_describe($module, $user);
$fields = $describeResult['fields'];
$assignedUser = new Users();
$ownerId = $assignedUser->retrieve_user_id($defaultOwner);
$userData = webforms_getUserData(vtws_getId(VtigerWebserviceObject::fromName($adb, "Users")->getEntityId(), $ownerId), $fields, $_REQUEST);
if ($userData === null) {
webforms_returnError(array('code' => "WEBFORMS_INVALID_DATA", 'message' => 'data provided is invalid'), $module);
return;
}
if (sizeof($userData) < 1) {
webforms_returnError(array('code' => "WEBFORMS_INVALID_DATA", 'message' => 'data provided is invalid'), $module);
return;
}
$createResult = vtws_create($module, $userData, $user);
webforms_returnSuccess($createResult, $module);
} catch (WebServiceException $e) {
webforms_returnError($e, $module);
}
}
示例13: save
/**
* Function to save the record
*/
public function save()
{
$currentUser = Users_Record_Model::getCurrentUserModel();
$mode = $this->get('mode');
$db = PearDatabase::getInstance();
$this->setCheckBoxValue('enabled');
$this->setCheckBoxValue('captcha');
$this->setCheckBoxValue('roundrobin');
if (is_array($this->get('roundrobin_userid'))) {
$roundrobinUsersList = json_encode($this->get('roundrobin_userid'), JSON_FORCE_OBJECT);
}
//Saving data about webform
if ($mode) {
$updateQuery = "UPDATE vtiger_webforms SET description = ?, returnurl = ?, ownerid = ?, enabled = ?, captcha = ? , roundrobin = ?, roundrobin_userid = ?, roundrobin_logic = ? ,targetmodule = ? WHERE id = ?";
$params = array($this->get('description'), $this->get('returnurl'), $this->get('ownerid'), $this->get('enabled'), $this->get('captcha'), $this->get('roundrobin'), $roundrobinUsersList, 0, $this->get('targetmodule'), $this->getId());
$db->pquery($updateQuery, $params);
} else {
$insertQuery = "INSERT INTO vtiger_webforms(name, targetmodule, publicid, enabled, description, ownerid, returnurl, captcha, roundrobin, roundrobin_userid, roundrobin_logic) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$params = array($this->getName(), $this->get('targetmodule'), $this->generatePublicId(), $this->get('enabled'), $this->get('description'), $this->get('ownerid'), $this->get('returnurl'), $this->get('captcha'), $this->get('roundrobin'), $roundrobinUsersList, 0);
$db->pquery($insertQuery, $params);
$this->set('id', $db->getLastInsertID());
}
//Deleting existing data
$db->pquery("DELETE FROM vtiger_webforms_field WHERE webformid = ?", array($this->getId()));
//Saving data of source module fields info for this webform
$selectedFieldsData = $this->get('selectedFieldsData');
$sourceModuleModel = Vtiger_Module_Model::getInstance($this->get('targetmodule'));
$fieldInsertQuery = "INSERT INTO vtiger_webforms_field(webformid, fieldname, neutralizedfield, defaultvalue, required, sequence, hidden) VALUES(?, ?, ?, ?, ?, ?, ?)";
foreach ($selectedFieldsData as $fieldName => $fieldDetails) {
$params = array($this->getId());
$neutralizedField = $fieldName;
$fieldDefaultValue = $fieldDetails['defaultvalue'];
$fieldModel = Vtiger_Field_Model::getInstance($fieldName, $sourceModuleModel);
$dataType = $fieldModel->getFieldDataType();
//Updating custom field label
if (self::isCustomField($fieldName)) {
$neutralizedField = 'label:' . str_replace(' ', '_', decode_html($fieldModel->get('label')));
}
//Handling multi picklist
if (is_array($fieldDefaultValue)) {
$fieldDefaultValue = implode(" |##| ", $fieldDefaultValue);
}
//Handling Data format
if ($dataType === 'date') {
$fieldDefaultValue = Vtiger_Date_UIType::getDBInsertedValue($fieldDefaultValue);
}
if ($dataType === 'time') {
$fieldDefaultValue = Vtiger_Time_UIType::getTimeValueWithSeconds($fieldDefaultValue);
}
//Handling CheckBox value
if ($dataType === 'boolean') {
if ($fieldDefaultValue) {
$fieldDefaultValue = 'on';
} else {
$fieldDefaultValue = '';
}
}
if ($dataType === 'reference') {
$referenceModule = $fieldDetails['referenceModule'];
$referenceObject = VtigerWebserviceObject::fromName($db, $referenceModule);
$referenceEntityId = $referenceObject->getEntityId();
$fieldDefaultValue = $referenceEntityId . "x" . $fieldDefaultValue;
}
if ($dataType === 'currency') {
$decimalSeperator = $currentUser->get('currency_decimal_separator');
$groupSeperator = $currentUser->get('currency_grouping_separator');
$fieldDefaultValue = str_replace($decimalSeperator, '.', $fieldDefaultValue);
$fieldDefaultValue = str_replace($groupSeperator, '', $fieldDefaultValue);
}
array_push($params, $fieldName, $neutralizedField, $fieldDefaultValue, $fieldDetails['required'], $fieldDetails['sequence'], $fieldDetails['hidden']);
$db->pquery($fieldInsertQuery, $params);
}
}
示例14: get_to_emailids
/** Function to get the emailids for the given ids form the request parameters
* It returns an array which contains the mailids and the parentidlists
*/
function get_to_emailids($module)
{
global $adb, $current_user, $log;
require_once 'include/Webservices/Query.php';
//$idlists1 = "";
$mailds = '';
if (empty($_REQUEST['field_lists'])) {
switch ($module) {
case 'Accounts':
$_REQUEST["field_lists"] = 9;
break;
case 'Contacts':
$_REQUEST["field_lists"] = 80;
break;
case 'Vendors':
$_REQUEST["field_lists"] = 292;
break;
}
}
$fieldids = explode(":", vtlib_purify($_REQUEST['field_lists']));
if ($_REQUEST['idlist'] == 'all' || $_REQUEST['idlist'] == 'relatedListSelectAll') {
$idlist = getSelectedRecords($_REQUEST, vtlib_purify($_REQUEST['pmodule']), vtlib_purify($_REQUEST['idlist']), vtlib_purify($_REQUEST['excludedRecords']));
} else {
$idlist = explode(":", str_replace("undefined", "", vtlib_purify($_REQUEST['idlist'])));
}
$entityids = array();
foreach ($idlist as $key => $id) {
$entityids[] = vtws_getWebserviceEntityId($module, $id);
}
$vtwsObject = VtigerWebserviceObject::fromName($adb, $module);
$vtwsCRMObjectMeta = new VtigerCRMObjectMeta($vtwsObject, $current_user);
$emailFields = $vtwsCRMObjectMeta->getEmailFields();
foreach ($emailFields as $key => $fieldname) {
$fieldid = $vtwsCRMObjectMeta->getFieldIdFromFieldName($fieldname);
if (!in_array($fieldid, $fieldids)) {
unset($emailFields[$key]);
}
}
if (empty($emailFields)) {
return false;
}
if ($module == 'Leads') {
$query = 'SELECT firstname,lastname,' . implode(",", $emailFields) . ',vtiger_leaddetails.leadid as id
FROM vtiger_leaddetails
INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_leaddetails.leadid
LEFT JOIN vtiger_leadscf ON vtiger_leaddetails.leadid = vtiger_leadscf.leadid
WHERE vtiger_crmentity.deleted=0 AND vtiger_leaddetails.leadid IN (' . generateQuestionMarks($idlist) . ')';
} else {
if ($module == 'Contacts') {
$query = 'SELECT firstname,lastname,' . implode(",", $emailFields) . ',vtiger_contactdetails.contactid as id
FROM vtiger_contactdetails
INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_contactdetails.contactid
LEFT JOIN vtiger_contactscf ON vtiger_contactdetails.contactid = vtiger_contactscf.contactid
WHERE vtiger_crmentity.deleted=0 AND vtiger_contactdetails.contactid IN (' . generateQuestionMarks($idlist) . ') AND vtiger_contactdetails.emailoptout=0';
} else {
if ($module == 'Accounts') {
$query = 'SELECT vtiger_account.accountname, ' . implode(",", $emailFields) . ',vtiger_account.accountid as id FROM vtiger_account
INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_account.accountid
LEFT JOIN vtiger_accountscf ON vtiger_accountscf.accountid= vtiger_account.accountid
WHERE vtiger_crmentity.deleted=0 AND vtiger_account.accountid IN (' . generateQuestionMarks($idlist) . ') AND vtiger_account.emailoptout=0';
} else {
if ($module == 'Project') {
$query = 'SELECT projectname,' . implode(",", $emailFields) . ',vtiger_project.projectid as id
FROM vtiger_project
INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_project.projectid
LEFT JOIN vtiger_projectcf ON vtiger_projectcf.projectid = vtiger_project.projectid
WHERE vtiger_crmentity.deleted=0 AND vtiger_project.projectid IN (' . generateQuestionMarks($idlist) . ')';
} else {
if ($module == 'ProjectTask') {
$query = 'SELECT projecttaskname,' . implode(",", $emailFields) . ',vtiger_projecttask.projecttaskid as id
FROM vtiger_projecttask
INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_projecttask.projecttaskid
LEFT JOIN vtiger_projecttaskcf ON vtiger_projecttaskcf.projecttaskid = vtiger_projecttask.projecttaskid
WHERE vtiger_crmentity.deleted=0 AND vtiger_projecttask.projecttaskid IN (' . generateQuestionMarks($idlist) . ')';
} else {
if ($module == 'Potentials') {
$query = 'SELECT potentialname,' . implode(",", $emailFields) . ',vtiger_potential.potentialid as id
FROM vtiger_potential
INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_potential.potentialid
LEFT JOIN vtiger_potentialscf ON vtiger_potentialscf.potentialid = vtiger_potential.potentialid
WHERE vtiger_crmentity.deleted=0 AND vtiger_potential.potentialid IN (' . generateQuestionMarks($idlist) . ')';
} else {
if ($module == 'HelpDesk') {
$query = 'SELECT title,' . implode(",", $emailFields) . ',vtiger_troubletickets.ticketid as id
FROM vtiger_troubletickets
INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_troubletickets.ticketid
LEFT JOIN vtiger_ticketcf ON vtiger_ticketcf.ticketid = vtiger_troubletickets.ticketid
WHERE vtiger_crmentity.deleted=0 AND vtiger_troubletickets.ticketid IN (' . generateQuestionMarks($idlist) . ')';
} else {
// vendors
$query = 'SELECT vtiger_vendor.vendorname, ' . implode(",", $emailFields) . ',vtiger_vendor.vendorid as id FROM vtiger_vendor
INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_vendor.vendorid
LEFT JOIN vtiger_vendorcf ON vtiger_vendorcf.vendorid= vtiger_vendor.vendorid
WHERE vtiger_crmentity.deleted=0 AND vtiger_vendor.vendorid IN (' . generateQuestionMarks($idlist) . ')';
}
}
}
//.........这里部分代码省略.........
示例15: vtws_listtypes
function vtws_listtypes($fieldTypeList, $user)
{
// Bulk Save Mode: For re-using information
static $webserviceEntities = false;
// END
static $types = array();
if (!empty($fieldTypeList)) {
$fieldTypeList = array_map(strtolower, $fieldTypeList);
sort($fieldTypeList);
$fieldTypeString = implode(',', $fieldTypeList);
} else {
$fieldTypeString = 'all';
}
if (!empty($types[$user->id][$fieldTypeString])) {
return $types[$user->id][$fieldTypeString];
}
try {
global $log;
/**
* @var PearDatabase
*/
$db = PearDatabase::getInstance();
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');
}
if (!empty($fieldTypeList)) {
$sql = "SELECT distinct(vtiger_field.tabid) as tabid FROM vtiger_field LEFT JOIN vtiger_ws_fieldtype ON " . "vtiger_field.uitype=vtiger_ws_fieldtype.uitype\n\t\t\t\t INNER JOIN vtiger_profile2field ON vtiger_field.fieldid = vtiger_profile2field.fieldid\n\t\t\t\t INNER JOIN vtiger_def_org_field ON vtiger_def_org_field.fieldid = vtiger_field.fieldid\n\t\t\t\t INNER JOIN vtiger_role2profile ON vtiger_profile2field.profileid = vtiger_role2profile.profileid\n\t\t\t\t INNER JOIN vtiger_user2role ON vtiger_user2role.roleid = vtiger_role2profile.roleid\n\t\t\t\t where vtiger_profile2field.visible=0 and vtiger_def_org_field.visible = 0\n\t\t\t\t and vtiger_field.presence in (0,2)\n\t\t\t\t and vtiger_user2role.userid=? and fieldtype in (" . generateQuestionMarks($fieldTypeList) . ')';
$params = array();
$params[] = $user->id;
foreach ($fieldTypeList as $fieldType) {
$params[] = $fieldType;
}
$result = $db->pquery($sql, $params);
$it = new SqlResultIterator($db, $result);
$moduleList = array();
foreach ($it as $row) {
$moduleList[] = getTabModuleName($row->tabid);
}
$allModuleNames = array_intersect($moduleList, $allModuleNames);
$params = $fieldTypeList;
$sql = "select name from vtiger_ws_entity inner join vtiger_ws_entity_tables on " . "vtiger_ws_entity.id=vtiger_ws_entity_tables.webservice_entity_id inner join " . "vtiger_ws_entity_fieldtype on vtiger_ws_entity_fieldtype.table_name=" . "vtiger_ws_entity_tables.table_name where fieldtype=(" . generateQuestionMarks($fieldTypeList) . ')';
$result = $db->pquery($sql, $params);
$it = new SqlResultIterator($db, $result);
$entityList = array();
foreach ($it as $row) {
$entityList[] = $row->name;
}
}
//get All the CRM entity names.
if ($webserviceEntities === false || !CRMEntity::isBulkSaveMode()) {
// Bulk Save Mode: For re-using information
$webserviceEntities = vtws_getWebserviceEntities();
}
$accessibleModules = array_values(array_intersect($webserviceEntities['module'], $allModuleNames));
$entities = $webserviceEntities['entity'];
$accessibleEntities = array();
if (empty($fieldTypeList)) {
foreach ($entities as $entity) {
$webserviceObject = VtigerWebserviceObject::fromName($db, $entity);
$handlerPath = $webserviceObject->getHandlerPath();
$handlerClass = $webserviceObject->getHandlerClass();
require_once $handlerPath;
$handler = new $handlerClass($webserviceObject, $user, $db, $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');
global $current_language;
if (empty($current_language)) {
$current_language = $default_language;
}
$current_language = vtws_preserveGlobal('current_language', $current_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();
$types[$user->id][$fieldTypeString] = array("types" => array_merge($accessibleModules, $accessibleEntities), 'information' => $informationArray);
return $types[$user->id][$fieldTypeString];
//.........这里部分代码省略.........