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); }
// for printing $module = isset($_REQUEST['module']) ? vtlib_purify($_REQUEST['module']) : ""; $action = isset($_REQUEST['action']) ? vtlib_purify($_REQUEST['action']) : ""; $record = isset($_REQUEST['record']) ? vtlib_purify($_REQUEST['record']) : ""; $lang_crm = isset($_SESSION['authenticated_user_language']) ? $_SESSION['authenticated_user_language'] : ""; $GLOBALS['request_string'] = "&module={$module}&action={$action}&record={$record}&lang_crm={$lang_crm}"; $current_user = new Users(); if ($use_current_login) { //$result = $current_user->retrieve($_SESSION['authenticated_user_id']); //getting the current user info from flat file $result = $current_user->retrieveCurrentUserInfoFromFile($_SESSION['authenticated_user_id']); if ($result == null) { session_destroy(); header("Location: index.php?action=Login&module=Users"); } $moduleList = getPermittedModuleNames(); foreach ($moduleList as $mod) { $moduleDefaultFile[$mod] = "modules/" . $currentModule . "/index.php"; } //auditing require_once 'user_privileges/audit_trail.php'; if ($audit_trail == 'true') { if ($record == '') { $auditrecord = ''; } else { $auditrecord = $record; } /* Skip audit trial log for special request types */ $skip_auditing = false; if ($action == 'chat') { $skip_auditing = true;
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]; }
/** * Function to list all modules for userid * It gets all the allowed entities to be shown in a picklist uitype 1613. 1633 and return an array in the following format * $modules = Array($index=>$tabname,$index1=>$tabname1) */ function getAllowedPicklistModules() { global $adb; //get All the modules the current user is permitted to Access. $allAllowedModules = getPermittedModuleNames(); $allEntities = array(); $entityQuery = "SELECT name FROM vtiger_tab\n\t\t\tWHERE isentitytype=1 and name NOT IN ('Rss','Webmails','Recyclebin','Events')"; $result = $adb->pquery($entityQuery, array()); while ($result && ($row = $adb->fetch_array($result))) { $allEntities[] = $row['name']; } $allowedEntities = array_intersect($allAllowedModules, $allEntities); return $allowedEntities; }