public function getWidget() { $widget = array(); $model = Vtiger_Module_Model::getInstance($this->Data['relatedmodule']); if ($model->isPermitted('DetailView')) { $this->Config['url'] = $this->getUrl(); $this->Config['tpl'] = 'Basic.tpl'; if ($this->Data['action'] == 1) { $createPermission = $model->isPermitted('EditView'); $this->Config['action'] = $createPermission == true ? 1 : 0; $this->Config['actionURL'] = $model->getQuickCreateUrl(); } if (isset($this->Data['filter'])) { $filterArray = explode('::', $this->Data['filter']); $this->Config['field_name'] = $filterArray[2]; } if (isset($this->Data['checkbox']) && $this->Data['checkbox'] != '-') { $this->Config['url'] .= '&whereCondition[' . getTableNameForField(getTabModuleName($this->Data['relatedmodule']), $this->Data['checkbox']) . '.' . $this->Data['checkbox'] . ']=1'; $on = 'LBL_SWITCH_ON_' . strtoupper($this->Data['checkbox']); $translateOn = vtranslate($on, $model->getName()); if ($on == $translateOn) { $translateOn = vtranslate('LBL_YES', $model->getName()); } $off = 'LBL_SWITCH_OFF_' . strtoupper($this->Data['checkbox']); $translateOff = vtranslate($off, $model->getName()); if ($off == $translateOff) { $translateOff = vtranslate('LBL_NO', $model->getName()); } $this->Config['checkboxLables'] = ['on' => $translateOn, 'off' => $translateOff]; } $widget = $this->Config; } return $widget; }
/** * Get module name. */ function module() { if (!empty($this->tabid)) { return getTabModuleName($this->tabid); } return false; }
static function getDependentPicklistFields($module = '') { global $adb; if (empty($module)) { $result = $adb->pquery('SELECT DISTINCT sourcefield, targetfield, tabid FROM vtiger_picklist_dependency', array()); } else { $tabId = getTabid($module); $result = $adb->pquery('SELECT DISTINCT sourcefield, targetfield, tabid FROM vtiger_picklist_dependency WHERE tabid=?', array($tabId)); } $noofrows = $adb->num_rows($result); $dependentPicklists = array(); if ($noofrows > 0) { $fieldlist = array(); for ($i = 0; $i < $noofrows; ++$i) { $fieldTabId = $adb->query_result($result, $i, 'tabid'); $sourceField = $adb->query_result($result, $i, 'sourcefield'); $targetField = $adb->query_result($result, $i, 'targetfield'); if (getFieldid($fieldTabId, $sourceField) == false || getFieldid($fieldTabId, $targetField) == false) { continue; } $fieldResult = $adb->pquery('SELECT fieldlabel FROM vtiger_field WHERE fieldname = ?', array($sourceField)); $sourceFieldLabel = $adb->query_result($fieldResult, 0, 'fieldlabel'); $fieldResult = $adb->pquery('SELECT fieldlabel FROM vtiger_field WHERE fieldname = ?', array($targetField)); $targetFieldLabel = $adb->query_result($fieldResult, 0, 'fieldlabel'); $forModule = getTabModuleName($fieldTabId); $dependentPicklists[] = array('sourcefield' => $sourceField, 'sourcefieldlabel' => vtranslate($sourceFieldLabel, $forModule), 'targetfield' => $targetField, 'targetfieldlabel' => vtranslate($targetFieldLabel, $forModule), 'module' => $forModule); } } return $dependentPicklists; }
/** Function to get the details for fieldlabels for a given table array * @param $tablearray -- tablearray:: Type string array (table names in array) * @param $tabid -- tabid:: Type integer * @returns $fieldName_array -- fieldName_array:: Type string array (field name details) * */ function getDBValidationData_510($tablearray, $tabid = '') { global $log; $log->debug("Entering getDBValidationData(" . $tablearray . "," . $tabid . ") method ..."); $sql = ''; $params = array(); $tab_con = ""; $numValues = count($tablearray); global $adb, $mod_strings; if ($tabid != '') { $tab_con = ' and tabid=' . $adb->sql_escape_string($tabid); } for ($i = 0; $i < $numValues; $i++) { if (in_array("emails", $tablearray)) { if ($numValues > 1 && $i != $numValues - 1) { $sql .= "select fieldlabel,fieldname,typeofdata from vtiger_field where tablename=? and tabid=10 and vtiger_field.presence in (0,2) and displaytype <> 2 union "; array_push($params, $tablearray[$i]); } else { $sql .= "select fieldlabel,fieldname,typeofdata from vtiger_field where tablename=? and tabid=10 and vtiger_field.presence in (0,2) and displaytype <> 2 "; array_push($params, $tablearray[$i]); } } else { if ($numValues > 1 && $i != $numValues - 1) { $sql .= "select fieldlabel,fieldname,typeofdata from vtiger_field where tablename=? {$tab_con} and displaytype in (1,3) and vtiger_field.presence in (0,2) union "; array_push($params, $tablearray[$i]); } else { $sql .= "select fieldlabel,fieldname,typeofdata from vtiger_field where tablename=? {$tab_con} and displaytype in (1,3) and vtiger_field.presence in (0,2)"; array_push($params, $tablearray[$i]); } } } $result = $adb->pquery($sql, $params); $noofrows = $adb->num_rows($result); $fieldModuleName = empty($tabid) ? false : getTabModuleName($tabid); $fieldName_array = array(); for ($i = 0; $i < $noofrows; $i++) { // Translate label with reference to module language string $fieldlabel = getTranslatedString($adb->query_result($result, $i, 'fieldlabel'), $fieldModuleName); $fieldname = $adb->query_result($result, $i, 'fieldname'); $typeofdata = $adb->query_result($result, $i, 'typeofdata'); //echo '<br> '.$fieldlabel.'....'.$fieldname.'....'.$typeofdata; $fldLabel_array = array(); $fldLabel_array[$fieldlabel] = $typeofdata; $fieldName_array[$fieldname] = $fldLabel_array; } $log->debug("Exiting getDBValidationData method ..."); return $fieldName_array; }
public function showBlocksAndFields(Vtiger_Request $request) { $sourceModuleId = $request->get('moduleId'); $language = $request->get('lang'); $currentModule = $request->get('module'); $parent = $request->get('parent'); $settings_block = $request->get('block'); $settings_fieldid = $request->get('fieldid'); $adb = PearDatabase::getInstance(); $sourceModule = getTabModuleName($sourceModuleId); $moduleModel = Settings_LayoutEditor_Module_Model::getInstanceByName($sourceModule); $fieldModels = $moduleModel->getFields(); $blockModels = $moduleModel->getBlocks(); $blockIdFieldMap = array(); $inactiveFields = array(); foreach ($fieldModels as $fieldModel) { $blockIdFieldMap[$fieldModel->getBlockId()][$fieldModel->getName()] = $fieldModel; if (!$fieldModel->isActiveField()) { $inactiveFields[$fieldModel->getBlockId()][$fieldModel->getId()] = vtranslate($fieldModel->get('label'), $sourceModule); } } foreach ($blockModels as $blockLabel => $blockModel) { $fieldModelList = $blockIdFieldMap[$blockModel->get('id')]; $blockModel->setFields($fieldModelList); } $query = "SELECT * from its4you_labels where tabid = ? and lang =?"; $result = $adb->pquery($query, array($sourceModuleId, $language)); while ($row = $adb->fetchByAssoc($result)) { $Fields_Labels[$row['fieldid']] = $row['translate_label']; } $qualifiedModule = $request->getModule(false); $viewer = $this->getViewer($request); $viewer->assign('SELECTED_MODULE_NAME', $sourceModule); $viewer->assign('SELECTED_MODULE_MODEL', $moduleModel); $viewer->assign('BLOCKS', $blockModels); $viewer->assign('ADD_SUPPORTED_FIELD_TYPES', $moduleModel->getAddSupportedFieldTypes()); $viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel()); $viewer->assign('QUALIFIED_MODULE', $qualifiedModule); $viewer->assign('LANGUAGE', $language); $viewer->assign('CURRENT_MODULE', $currentModule); $viewer->assign('PARENT', $parent); $viewer->assign('FIELDS_LABELS', $Fields_Labels); $viewer->assign('SETTINGS_FIELDID', $settings_fieldid); $viewer->assign('SETTINGS_BLOCK', $settings_block); echo $viewer->view('EditView.tpl', $qualifiedModule, true); }
function vtJsonDependentModules($adb, $request) { $moduleName = $request['modulename']; $result = $adb->pquery("SELECT fieldname, tabid, typeofdata, vtiger_ws_referencetype.type as reference_module FROM vtiger_field\n\t\t\t\t\t\t\t\t\tINNER JOIN vtiger_ws_fieldtype ON vtiger_field.uitype = vtiger_ws_fieldtype.uitype\n\t\t\t\t\t\t\t\t\tINNER JOIN vtiger_ws_referencetype ON vtiger_ws_fieldtype.fieldtypeid = vtiger_ws_referencetype.fieldtypeid\n\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\tSELECT fieldname, tabid, typeofdata, relmodule as reference_module FROM vtiger_field\n\t\t\t\t\t\t\t\t\tINNER JOIN vtiger_fieldmodulerel ON vtiger_field.fieldid = vtiger_fieldmodulerel.fieldid", array()); $noOfFields = $adb->num_rows($result); $dependentFields = array(); // List of modules which will not be supported by 'Create Entity' workflow task $filterModules = array('Invoice', 'Quotes', 'SalesOrder', 'PurchaseOrder', 'Emails', 'Calendar', 'Events', 'Accounts'); $skipFieldsList = array(); for ($i = 0; $i < $noOfFields; ++$i) { $tabId = $adb->query_result($result, $i, 'tabid'); $fieldName = $adb->query_result($result, $i, 'fieldname'); $typeOfData = $adb->query_result($result, $i, 'typeofdata'); $referenceModule = $adb->query_result($result, $i, 'reference_module'); $tabModuleName = getTabModuleName($tabId); if (in_array($tabModuleName, $filterModules)) { continue; } if ($referenceModule == $moduleName && $tabModuleName != $moduleName) { if (!vtlib_isModuleActive($tabModuleName)) { continue; } $dependentFields[$tabModuleName] = array('fieldname' => $fieldName, 'modulelabel' => getTranslatedString($tabModuleName, $tabModuleName)); } else { $dataTypeInfo = explode('~', $typeOfData); if ($dataTypeInfo[1] == 'M') { // If the current reference field is mandatory $skipFieldsList[$tabModuleName] = array('fieldname' => $fieldName); } } } foreach ($skipFieldsList as $tabModuleName => $fieldInfo) { $dependentFieldInfo = $dependentFields[$tabModuleName]; if ($dependentFieldInfo['fieldname'] != $fieldInfo['fieldname']) { unset($dependentFields[$tabModuleName]); } } $returnValue = array('count' => count($dependentFields), 'entities' => $dependentFields); echo Zend_Json::encode($returnValue); }
public function getNameFields() { global $adb; $data = getEntityFieldNames(getTabModuleName($this->getEffectiveTabId())); $fieldNames = ''; if ($data) { $fieldNames = $data['fieldname']; if (is_array($fieldNames)) { $fieldNames = implode(',', $fieldNames); } } return $fieldNames; }
function getFieldRelatedInfo($tabId, $fieldName) { $fieldInfo = VTCacheUtils::lookupFieldInfo($tabId, $fieldName); if ($fieldInfo === false) { getColumnFields(getTabModuleName($tabid)); $fieldInfo = VTCacheUtils::lookupFieldInfo($tabId, $fieldName); } return $fieldInfo; }
function getPickListOptions() { global $app_strings, $mod_strings, $log, $current_language; static $purified_plcache = array(); $fieldName = $this->getFieldName(); $default_charset = VTWS_PreserveGlobal::getGlobal('default_charset'); $moduleName = getTabModuleName($this->getTabId()); if ($moduleName == 'Events') { $moduleName = 'Calendar'; } $temp_mod_strings = $moduleName != '' ? return_module_language($current_language, $moduleName) : $mod_strings; if (array_key_exists($moduleName . $fieldName, $purified_plcache)) { return $purified_plcache[$moduleName . $fieldName]; } $options = array(); $sql = "select * from vtiger_picklist where name=?"; $result = $this->pearDB->pquery($sql, array($fieldName)); $numRows = $this->pearDB->num_rows($result); if ($numRows == 0) { $sql = "select * from vtiger_{$fieldName}"; $result = $this->pearDB->pquery($sql, array()); $numRows = $this->pearDB->num_rows($result); for ($i = 0; $i < $numRows; ++$i) { $elem = array(); $picklistValue = $this->pearDB->query_result($result, $i, $fieldName); $picklistValue = decode_html($picklistValue); $trans_str = $temp_mod_strings[$picklistValue] != '' ? $temp_mod_strings[$picklistValue] : ($app_strings[$picklistValue] != '' ? $app_strings[$picklistValue] : $picklistValue); while ($trans_str != preg_replace('/(.*) {.+}(.*)/', '$1$2', $trans_str)) { $trans_str = preg_replace('/(.*) {.+}(.*)/', '$1$2', $trans_str); } $elem["label"] = $trans_str; $elem["value"] = $picklistValue; array_push($options, $elem); } } else { $user = VTWS_PreserveGlobal::getGlobal('current_user'); $details = getPickListValues($fieldName, $user->roleid); for ($i = 0; $i < sizeof($details); ++$i) { $elem = array(); $picklistValue = decode_html($details[$i]); $trans_str = $temp_mod_strings[$picklistValue] != '' ? $temp_mod_strings[$picklistValue] : ($app_strings[$picklistValue] != '' ? $app_strings[$picklistValue] : $picklistValue); while ($trans_str != preg_replace('/(.*) {.+}(.*)/', '$1$2', $trans_str)) { $trans_str = preg_replace('/(.*) {.+}(.*)/', '$1$2', $trans_str); } $elem["label"] = $trans_str; $elem["value"] = $picklistValue; array_push($options, $elem); } } $purified_plcache[$moduleName . $fieldName] = $options; return $options; }
/** Function to get the permitted module name Array with presence as 0 * @returns permitted module name Array :: Type Array * */ function getPermittedModuleNames() { global $log; global $WERPASCOPETABDATA; $log->debug("Entering getPermittedModuleNames() method ..."); global $current_user; $permittedModules = array(); global $WERPASCOPEUSERPRIVILEGES; require $WERPASCOPEUSERPRIVILEGES . '/user_privileges_' . $current_user->id . '.php'; include $WERPASCOPETABDATA; if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1) { foreach ($tab_seq_array as $tabid => $seq_value) { if ($seq_value === 0 && $profileTabsPermission[$tabid] === 0) { $permittedModules[] = getTabModuleName($tabid); } } } else { foreach ($tab_seq_array as $tabid => $seq_value) { if ($seq_value === 0) { $permittedModules[] = getTabModuleName($tabid); } } } $log->debug("Exiting getPermittedModuleNames method ..."); return $permittedModules; }
function get_modules($id) { $adb = PearDatabase::getInstance(); $log = vglobal('log'); $log->debug("Entering customer portal Function get_modules"); getServerSessionId($id); // Check if information is available in cache? $modules = Vtiger_Soap_YetiPortal::lookupAllowedModules(); if ($modules === false) { $modules = array(); $query = $adb->pquery("SELECT vtiger_customerportal_tabs.* FROM vtiger_customerportal_tabs\n\t\t\tINNER JOIN vtiger_tab ON vtiger_tab.tabid = vtiger_customerportal_tabs.tabid\n\t\t\tWHERE vtiger_tab.presence = 0 AND vtiger_customerportal_tabs.visible = 1", array()); $norows = $adb->num_rows($query); if ($norows) { while ($resultrow = $adb->fetch_array($query)) { $name = getTabModuleName($resultrow['tabid']); $modules[(int) $resultrow['sequence']] = array('name' => $name, 'translated_name' => Vtiger_Language_Handler::getTranslatedString($name, $name, vglobal('default_language'))); } ksort($modules); // Order via SQL might cost us, so handling it ourselves in this case } Vtiger_Soap_YetiPortal::updateAllowedModules($modules); } $log->debug("Exiting customerportal function get_modules"); return $modules; }
/** Function to get picklist value array based on profile * * returns permitted fields in array format **/ function getAccessPickListValues() { $adb = PearDatabase::getInstance(); $current_user = vglobal('current_user'); $id = array(getTabid($this->primarymodule)); if ($this->secondarymodule != '') { array_push($id, getTabid($this->secondarymodule)); } $query = 'select fieldname,columnname,fieldid,fieldlabel,tabid,uitype from vtiger_field where tabid in(' . generateQuestionMarks($id) . ') and uitype in (15,33,55)'; //and columnname in (?)'; $result = $adb->pquery($query, $id); //,$select_column)); $roleid = $current_user->roleid; $subrole = getRoleSubordinates($roleid); if (count($subrole) > 0) { $roleids = $subrole; array_push($roleids, $roleid); } else { $roleids = $roleid; } $temp_status = array(); for ($i = 0; $i < $adb->num_rows($result); $i++) { $fieldname = $adb->query_result($result, $i, "fieldname"); $fieldlabel = $adb->query_result($result, $i, "fieldlabel"); $tabid = $adb->query_result($result, $i, "tabid"); $uitype = $adb->query_result($result, $i, "uitype"); $fieldlabel1 = str_replace(" ", "__", $fieldlabel); $keyvalue = getTabModuleName($tabid) . "__" . $fieldlabel1; $fieldvalues = array(); if (count($roleids) > 1) { $mulsel = "select distinct {$fieldname} from vtiger_{$fieldname} inner join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid = vtiger_{$fieldname}.picklist_valueid where roleid in (\"" . implode($roleids, "\",\"") . "\") and picklistid in (select picklistid from vtiger_{$fieldname})"; // order by sortid asc - not requried } else { $mulsel = "select distinct {$fieldname} from vtiger_{$fieldname} inner join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid = vtiger_{$fieldname}.picklist_valueid where roleid ='" . $roleid . "' and picklistid in (select picklistid from vtiger_{$fieldname})"; // order by sortid asc - not requried } if ($fieldname != 'firstname') { $mulselresult = $adb->query($mulsel); } for ($j = 0; $j < $adb->num_rows($mulselresult); $j++) { $fldvalue = $adb->query_result($mulselresult, $j, $fieldname); if (in_array($fldvalue, $fieldvalues)) { continue; } $fieldvalues[] = $fldvalue; } $field_count = count($fieldvalues); if ($uitype == 15 && $field_count > 0 && ($fieldname == 'taskstatus' || $fieldname == 'eventstatus')) { $temp_count = count($temp_status[$keyvalue]); if ($temp_count > 0) { for ($t = 0; $t < $field_count; $t++) { $temp_status[$keyvalue][$temp_count + $t] = $fieldvalues[$t]; } $fieldvalues = $temp_status[$keyvalue]; } else { $temp_status[$keyvalue] = $fieldvalues; } } if ($uitype == 33) { $fieldlists[1][$keyvalue] = $fieldvalues; } else { if ($uitype == 55 && $fieldname == 'salutationtype') { $fieldlists[$keyvalue] = $fieldvalues; } else { if ($uitype == 15) { $fieldlists[$keyvalue] = $fieldvalues; } } } } return $fieldlists; }
/** * * @param <type> $module * @param <type> $user * @param <type> $parentRole * @param <type> $userGroups */ protected function setupTemporaryTable($tableName, $tabId, $user, $parentRole, $userGroups) { $module = null; if (!empty($tabId)) { $module = getTabModuleName($tabId); } $query = $this->getNonAdminAccessQuery($module, $user, $parentRole, $userGroups); $query = "create temporary table IF NOT EXISTS {$tableName}(id int(11) primary key) ignore " . $query; $db = PearDatabase::getInstance(); $result = $db->pquery($query, array()); if (is_object($result)) { return true; } return false; }
/** Function to get the tabname for a given id * @param $tabid -- tab id:: Type integer * @returns $string -- string:: Type string * */ function getTabname($tabid) { global $log; $log->debug("Entering getTabname() method ..."); $tabname = getTabModuleName($tabid); $log->debug("Exiting getTabname method ..."); return $tabname; }
$sharing_module = vtlib_purify($_REQUEST['sharing_module']); $tabid = getTabid($sharing_module); $sharedby = explode('::', vtlib_purify($_REQUEST[$sharing_module . '_share'])); $sharedto = explode('::', vtlib_purify($_REQUEST[$sharing_module . '_access'])); $share_entity_type = $sharedby[0]; $to_entity_type = $sharedto[0]; $share_entity_id = $sharedby[1]; $to_entity_id = $sharedto[1]; $module_sharing_access = vtlib_purify($_REQUEST['share_memberType']); $mode = vtlib_purify($_REQUEST['mode']); $relatedShareModuleArr = getRelatedSharingModules($tabid); if ($mode == 'create') { $shareId = addSharingRule($tabid, $share_entity_type, $to_entity_type, $share_entity_id, $to_entity_id, $module_sharing_access); //Adding the Related ModulePermission Sharing foreach ($relatedShareModuleArr as $reltabid => $ds_rm_id) { $reltabname = getTabModuleName($reltabid); $relSharePermission = vtlib_purify($_REQUEST[$reltabname . '_accessopt']); addRelatedModuleSharingPermission($shareId, $tabid, $reltabid, $relSharePermission); } } elseif ($mode == 'edit') { $shareId = vtlib_purify($_REQUEST['shareId']); updateSharingRule($shareId, $tabid, $share_entity_type, $to_entity_type, $share_entity_id, $to_entity_id, $module_sharing_access); //Adding the Related ModulePermission Sharing foreach ($relatedShareModuleArr as $reltabid => $ds_rm_id) { $reltabname = getTabModuleName($reltabid); $relSharePermission = vtlib_purify($_REQUEST[$reltabname . '_accessopt']); updateRelatedModuleSharingPermission($shareId, $tabid, $reltabid, $relSharePermission); } } $loc = "Location: index.php?action=OrgSharingDetailView&module=Settings&parenttab=Settings"; header($loc);
private function getObjectTypeName($moduleId) { return getTabModuleName($moduleId); }
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 getTreeDetails() { if (count(self::$treeDetails) > 0) { return self::$treeDetails; } $result = $this->pearDB->pquery('SELECT module FROM vtiger_trees_templates WHERE templateid = ?', [$this->getFieldParams()]); $module = $this->pearDB->getSingleValue($result); $moduleName = getTabModuleName($module); $result = $this->pearDB->pquery('SELECT tree,label FROM vtiger_trees_templates_data WHERE templateid = ?', [$this->getFieldParams()]); while ($row = $this->pearDB->fetch_array($result)) { self::$treeDetails[$row['tree']] = getTranslatedString($row['label'], $moduleName); } return self::$treeDetails; }
static function getImportInfoFromResult($rowData) { return array('id' => $rowData['importid'], 'module' => getTabModuleName($rowData['tabid']), 'field_mapping' => Zend_Json::decode($rowData['field_mapping']), 'default_values' => Zend_Json::decode($rowData['default_values']), 'merge_type' => $rowData['merge_type'], 'merge_fields' => Zend_Json::decode($rowData['merge_fields']), 'user_id' => $rowData['userid'], 'status' => $rowData['status']); }
/** * Function to get the fieldid * * @param Integer $tabid * @param Boolean $onlyactive */ function getFieldid($tabid, $fieldname, $onlyactive = true) { global $adb; // Look up information at cache first $fieldinfo = VTCacheUtils::lookupFieldInfo($tabid, $fieldname); if ($fieldinfo === false) { getColumnFields(getTabModuleName($tabid)); $fieldinfo = VTCacheUtils::lookupFieldInfo($tabid, $fieldname); } // Get the field id based on required criteria $fieldid = false; if ($fieldinfo) { $fieldid = $fieldinfo['fieldid']; if ($onlyactive && !in_array($fieldinfo['presence'], array('0', '2'))) { $fieldid = false; } } return $fieldid; }
/** Function to getQuickCreate for a given tabid * @param $tabid -- tab id :: Type string * @param $actionid -- action id :: Type integer * @returns $QuickCreateForm -- QuickCreateForm :: Type boolean */ function getQuickCreate($tabid, $actionid) { global $log; $log->debug("Entering getQuickCreate(" . $tabid . "," . $actionid . ") method ..."); $module = getTabModuleName($tabid); $actionname = getActionname($actionid); $QuickCreateForm = 'true'; $perr = isPermitted($module, $actionname); if ($perr == 'no') { $QuickCreateForm = 'false'; } $log->debug("Exiting getQuickCreate method ..."); return $QuickCreateForm; }
function getListViewEntries($focus, $module, $result, $navigationInfo, $skipActions = false) { require 'user_privileges/user_privileges_' . $this->user->id . '.php'; global $listview_max_textlength, $theme, $default_charset, $current_user, $currentModule; $fields = $this->queryGenerator->getFields(); $whereFields = $this->queryGenerator->getWhereFields(); $meta = $this->queryGenerator->getMeta($this->queryGenerator->getModule()); $moduleFields = $meta->getModuleFields(); $accessibleFieldList = array_keys($moduleFields); if ($this->queryGenerator->getReferenceFieldInfoList()) { $accessibleFieldList = array_merge($this->queryGenerator->getReferenceFieldNameList(), $accessibleFieldList); } $listViewFields = array_intersect($fields, $accessibleFieldList); $referenceFieldList = $this->queryGenerator->getReferenceFieldList(); foreach ($referenceFieldList as $fieldName) { if (in_array($fieldName, $listViewFields)) { $field = $moduleFields[$fieldName]; $this->fetchNameList($field, $result); } } $db = PearDatabase::getInstance(); $rowCount = $db->num_rows($result); $listviewcolumns = $db->getFieldsArray($result); $ownerFieldList = $this->queryGenerator->getOwnerFieldList(); foreach ($ownerFieldList as $fieldName) { if (in_array($fieldName, $listViewFields)) { if (!empty($moduleFields[$fieldName])) { $field = $moduleFields[$fieldName]; } else { $field = $this->queryGenerator->getReferenceField($fieldName, false); if (is_null($field)) { continue; } } $fldcolname = $field->getColumnName(); $idList = array(); for ($i = 0; $i < $rowCount; $i++) { $id = $this->db->query_result($result, $i, $fldcolname); if (!isset($this->ownerNameList[$fieldName][$id])) { $idList[] = $id; } } if (count($idList) > 0) { if (!isset($this->ownerNameList[$fieldName]) or !is_array($this->ownerNameList[$fieldName])) { $this->ownerNameList[$fieldName] = getOwnerNameList($idList); } else { $newOwnerList = getOwnerNameList($idList); $this->ownerNameList[$fieldName] = $this->ownerNameList[$fieldName] + $newOwnerList; } } } } foreach ($listViewFields as $fieldName) { if (!empty($moduleFields[$fieldName])) { $field = $moduleFields[$fieldName]; } else { $field = $this->queryGenerator->getReferenceField($fieldName, false); if (is_null($field)) { continue; } } if (!$is_admin && ($field->getFieldDataType() == 'picklist' || $field->getFieldDataType() == 'multipicklist')) { $this->setupAccessiblePicklistValueList($fieldName); } $idList = array(); if ($fieldName != 'assigned_user_id' && strstr($fieldName, ".assigned_user_id")) { $modrel = getTabModuleName($field->getTabId()); $fldcolname = 'smowner' . strtolower($modrel); $j = $rowCount * $k; $k++; for ($i = 0; $i < $rowCount; $i++) { $id = $this->db->query_result($result, $i, $fldcolname); if (!isset($this->ownerNameListrel[$fieldName][$id])) { $idList[$j] = $id; $j++; } } } else { if (getTabid($currentModule) != $field->getTabId() && $field->getFieldDataType() == 'reference') { $this->fetchNameList($field, $result, 1); } } if (count($idList) > 0) { if (!isset($this->ownerNameListrel[$fieldName]) or !is_array($this->ownerNameListrel[$fieldName])) { $this->ownerNameListrel[$fieldName] = getOwnerNameList($idList); } else { $newOwnerList = getOwnerNameList($idList); $this->ownerNameListrel[$fieldName] = $this->ownerNameListrel[$fieldName] + $newOwnerList; } } } $useAsterisk = get_use_asterisk($this->user->id); $data = array(); for ($i = 0; $i < $rowCount; ++$i) { //Getting the recordId if ($module != 'Users') { $baseTable = $meta->getEntityBaseTable(); $moduleTableIndexList = $meta->getEntityTableIndexList(); $baseTableIndex = $moduleTableIndexList[$baseTable]; $recordId = $db->query_result($result, $i, $baseTableIndex); $ownerId = $db->query_result($result, $i, "smownerid"); } else { $recordId = $db->query_result($result, $i, "id"); } $row = array(); foreach ($listViewFields as $fieldName) { if (!empty($moduleFields[$fieldName])) { $field = $moduleFields[$fieldName]; } else { $field = $this->queryGenerator->getReferenceField($fieldName, false); if (is_null($field)) { continue; } } $uitype = $field->getUIType(); if ($fieldName != 'assigned_user_id' && strstr($fieldName, ".assigned_user_id")) { $modrel = getTabModuleName($field->getTabId()); $rawValue = $this->db->query_result($result, $i, "smowner" . strtolower($modrel)); } else { if (getTabid($currentModule) != $field->getTabId()) { $modrel = getTabModuleName($field->getTabId()); $relfieldname = strtolower($modrel) . $field->getColumnName(); if (in_array($relfieldname, $listviewcolumns)) { $rawValue = $this->db->query_result($result, $i, $relfieldname); } else { $rawValue = $this->db->query_result($result, $i, $field->getColumnName()); } } else { $rawValue = $this->db->query_result($result, $i, $field->getColumnName()); } } if ($module == 'Calendar') { $activityType = $this->db->query_result($result, $i, 'activitytype'); } if ($uitype != 8) { $value = html_entity_decode($rawValue, ENT_QUOTES, $default_charset); } else { $value = $rawValue; } if ($module == 'Documents' && $fieldName == 'filename') { $downloadtype = $db->query_result($result, $i, 'filelocationtype'); if ($downloadtype == 'I') { $ext = substr($value, strrpos($value, ".") + 1); $ext = strtolower($ext); if ($value != '') { if ($ext == 'bin' || $ext == 'exe' || $ext == 'rpm') { $fileicon = "<img src='" . vtiger_imageurl('fExeBin.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'jpg' || $ext == 'gif' || $ext == 'bmp') { $fileicon = "<img src='" . vtiger_imageurl('fbImageFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'txt' || $ext == 'doc' || $ext == 'xls') { $fileicon = "<img src='" . vtiger_imageurl('fbTextFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'zip' || $ext == 'gz' || $ext == 'rar') { $fileicon = "<img src='" . vtiger_imageurl('fbZipFile.gif', $theme) . "' hspace='3' align='absmiddle'\tborder='0'>"; } else { $fileicon = "<img src='" . vtiger_imageurl('fbUnknownFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } } } elseif ($downloadtype == 'E') { if (trim($value) != '') { $fileicon = "<img src='" . vtiger_imageurl('fbLink.gif', $theme) . "' alt='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' title='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' hspace='3' align='absmiddle' border='0'>"; } else { $value = '--'; $fileicon = ''; } } else { $value = ' --'; $fileicon = ''; } $fileName = $db->query_result($result, $i, 'filename'); $downloadType = $db->query_result($result, $i, 'filelocationtype'); $status = $db->query_result($result, $i, 'filestatus'); $fileIdQuery = "select attachmentsid from vtiger_seattachmentsrel where crmid=?"; $fileIdRes = $db->pquery($fileIdQuery, array($recordId)); $fileId = $db->query_result($fileIdRes, 0, 'attachmentsid'); if ($fileName != '' && $status == 1) { if ($downloadType == 'I') { $value = "<a href='index.php?module=uploads&action=downloadfile&" . "entityid={$recordId}&fileid={$fileId}' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "' onclick='javascript:dldCntIncrease({$recordId});'>" . textlength_check($value) . "</a>"; } elseif ($downloadType == 'E') { $value = "<a target='_blank' href='{$fileName}' onclick='javascript:" . "dldCntIncrease({$recordId});' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "'>" . textlength_check($value) . "</a>"; } else { $value = ' --'; } } $value = $fileicon . $value; } elseif ($module == 'Documents' && $fieldName == 'filesize') { $downloadType = $db->query_result($result, $i, 'filelocationtype'); if ($downloadType == 'I') { $filesize = $value; if ($filesize < 1024) { $value = $filesize . ' B'; } elseif ($filesize > 1024 && $filesize < 1048576) { $value = round($filesize / 1024, 2) . ' KB'; } else { if ($filesize > 1048576) { $value = round($filesize / (1024 * 1024), 2) . ' MB'; } } } else { $value = ' --'; } } elseif ($module == 'Documents' && $fieldName == 'filestatus') { if ($value == 1) { $value = getTranslatedString('yes', $module); } elseif ($value == 0) { $value = getTranslatedString('no', $module); } else { $value = '--'; } } elseif ($module == 'Documents' && $fieldName == 'filetype') { $downloadType = $db->query_result($result, $i, 'filelocationtype'); if ($downloadType == 'E' || $downloadType != 'I') { $value = '--'; } } elseif ($field->getUIType() == '27') { if ($value == 'I') { $value = getTranslatedString('LBL_INTERNAL', $module); } elseif ($value == 'E') { $value = getTranslatedString('LBL_EXTERNAL', $module); } else { $value = ' --'; } } elseif ($field->getFieldDataType() == 'picklist') { if ($value != '' && !$is_admin && $this->picklistRoleMap[$fieldName] && !in_array($value, $this->picklistValueMap[$fieldName])) { $value = "<font color='red'>" . getTranslatedString('LBL_NOT_ACCESSIBLE', $module) . "</font>"; } else { $value = getTranslatedString($value, $module); $value = textlength_check($value); } } elseif ($field->getFieldDataType() == 'date' || $field->getFieldDataType() == 'datetime') { if ($value != '' && $value != '0000-00-00') { $date = new DateTimeField($value); $value = $date->getDisplayDate(); if ($field->getFieldDataType() == 'datetime') { $value .= ' ' . $date->getDisplayTime(); } } elseif ($value == '0000-00-00') { $value = ''; } } elseif ($field->getFieldDataType() == 'currency') { if ($value != '') { if ($field->getUIType() == 72) { if ($fieldName == 'unit_price') { $currencyId = getProductBaseCurrency($recordId, $module); $cursym_convrate = getCurrencySymbolandCRate($currencyId); $currencySymbol = $cursym_convrate['symbol']; } else { $currencyInfo = getInventoryCurrencyInfo($module, $recordId); $currencySymbol = $currencyInfo['currency_symbol']; } $value = number_format($value, 2, '.', ''); $currencyValue = CurrencyField::convertToUserFormat($value, null, true); $value = CurrencyField::appendCurrencySymbol($currencyValue, $currencySymbol); } else { //changes made to remove vtiger_currency symbol infront of each //vtiger_potential amount if ($value != 0) { $value = CurrencyField::convertToUserFormat($value); } } } } elseif ($field->getFieldDataType() == 'url') { $matchPattern = "^[\\w]+:\\/\\/^"; preg_match($matchPattern, $rawValue, $matches); if (!empty($matches[0])) { $value = '<a href="' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>'; } else { $value = '<a href="http://' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>'; } } elseif ($field->getFieldDataType() == 'email') { if ($_SESSION['internal_mailer'] == 1) { //check added for email link in user detailview $fieldId = $field->getFieldId(); $value = "<a href=\"javascript:InternalMailer({$recordId},{$fieldId}," . "'{$fieldName}','{$module}','record_id');\">" . textlength_check($value) . "</a>"; } else { $value = '<a href="mailto:' . $rawValue . '">' . textlength_check($value) . '</a>'; } } elseif ($field->getFieldDataType() == 'boolean') { if ($value == 1) { $value = getTranslatedString('yes', $module); } elseif ($value == 0) { $value = getTranslatedString('no', $module); } else { $value = '--'; } } elseif ($field->getUIType() == 98) { $value = '<a href="index.php?action=RoleDetailView&module=Settings&parenttab=' . 'Settings&roleid=' . $value . '">' . textlength_check(getRoleName($value)) . '</a>'; } elseif ($field->getUIType() == 69) { if ($module == 'Products') { $queryPrdt = 'SELECT vtiger_attachments.path,vtiger_attachments.attachmentsid,vtiger_attachments.`name` FROM vtiger_attachments INNER JOIN vtiger_seattachmentsrel ON vtiger_attachments.attachmentsid = vtiger_seattachmentsrel.attachmentsid INNER JOIN vtiger_products ON vtiger_seattachmentsrel.crmid = vtiger_products.productid where vtiger_seattachmentsrel.crmid=?'; $resultprdt = $this->db->pquery($queryPrdt, array($recordId)); if ($resultprdt and $this->db->num_rows($resultprdt) > 0) { $imgpath = $this->db->query_result($resultprdt, 0, 'path'); $attid = $this->db->query_result($resultprdt, 0, 'attachmentsid'); $imgfilename = $this->db->query_result($resultprdt, 0, 'name'); $value = "<div style='text-align:center;width:100%;'><img src='./" . $imgpath . $attid . '_' . $imgfilename . "' height='50'></div>"; } else { $value = ''; } } else { if ($module == 'Contacts') { $imageattachment = 'Image'; } else { $imageattachment = 'Attachment'; } //$imgpath = getModuleFileStoragePath('Contacts').$col_fields[$fieldname]; $sql = "select vtiger_attachments.*,vtiger_crmentity.setype\n\t\t\t\t\t\t from vtiger_attachments\n\t\t\t\t\t\t inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid\n\t\t\t\t\t\t inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_attachments.attachmentsid\n\t\t\t\t\t\t where vtiger_crmentity.setype='{$module} {$imageattachment}'\n\t\t\t\t\t\t and vtiger_attachments.name = ?\n\t\t\t\t\t\t and vtiger_seattachmentsrel.crmid=?"; $image_res = $this->db->pquery($sql, array(str_replace(' ', '_', $value), $recordId)); $image_id = $this->db->query_result($image_res, 0, 'attachmentsid'); $image_path = $this->db->query_result($image_res, 0, 'path'); $image_name = urlencode(decode_html($this->db->query_result($image_res, 0, 'name'))); $imgpath = $image_path . $image_id . "_" . $image_name; if ($image_name != '') { $ftype = $this->db->query_result($image_res, 0, 'type'); $isimage = stripos($ftype, 'image') !== false; if ($isimage) { $imgtxt = getTranslatedString('SINGLE_' . $module, $module) . ' ' . getTranslatedString('Image'); $value = '<div style="width:100%;text-align:center;"><img src="' . $imgpath . '" alt="' . $imgtxt . '" title= "' . $imgtxt . '" style="max-width: 50px;"></div>'; } else { $imgtxt = getTranslatedString('SINGLE_' . $module, $module) . ' ' . getTranslatedString('SINGLE_Documents'); $value = '<a href="' . $imgpath . '" alt="' . $imgtxt . '" title= "' . $imgtxt . '">' . $image_name . '</a>'; } } else { $value = ''; } } } elseif ($field->getFieldDataType() == 'multipicklist') { $value = $value != "" ? str_replace(' |##| ', ', ', $value) : ""; if (!$is_admin && $value != '') { $valueArray = $rawValue != "" ? explode(' |##| ', $rawValue) : array(); $notaccess = '<font color="red">' . getTranslatedString('LBL_NOT_ACCESSIBLE', $module) . "</font>"; $tmp = ''; $tmpArray = array(); foreach ($valueArray as $index => $val) { if (!$listview_max_textlength || !(strlen(preg_replace("/(<\\/?)(\\w+)([^>]*>)/i", "", $tmp)) > $listview_max_textlength)) { if (!$is_admin && $this->picklistRoleMap[$fieldName] && !in_array(trim(decode_html($val)), $this->picklistValueMap[$fieldName])) { $tmpArray[] = $notaccess; $tmp .= ', ' . $notaccess; } else { $tmpArray[] = $val; $tmp .= ', ' . $val; } } else { $tmpArray[] = '...'; $tmp .= '...'; } } $value = implode(', ', $tmpArray); $value = textlength_check($value); } } elseif ($field->getUIType() == 1024) { $content = array(); if ($value != '') { $arr_evo_actions = explode(' |##| ', $value); for ($fvalues = 0; $fvalues < sizeof($arr_evo_actions); $fvalues++) { $roleid = $arr_evo_actions[$fvalues]; $rolename = getRoleName($roleid); $content[$fvalues] = $rolename; } } $value = textlength_check(implode(', ', $content)); } elseif ($field->getFieldDataType() == 'skype') { $value = $value != "" ? "<a href='skype:{$value}?call'>" . textlength_check($value) . "</a>" : ""; } elseif ($field->getFieldDataType() == 'phone') { if ($useAsterisk == 'true') { $value = "<a href='javascript:;' onclick='startCall("{$value}", " . ""{$recordId}")'>" . textlength_check($value) . "</a>"; } else { $value = textlength_check($value); } } elseif ($field->getFieldDataType() == 'reference') { $referenceFieldInfoList = $this->queryGenerator->getReferenceFieldInfoList(); if (getTabid($currentModule) != $field->getTabId()) { $modrel = getTabModuleName($field->getTabId()); $fieldName = str_replace($modrel . '.', "", $fieldName); } $moduleList = $referenceFieldInfoList[$fieldName]; if (count($moduleList) == 1) { $parentModule = $moduleList[0]; } else { $parentModule = $this->typeList[$value]; } if (!empty($value) && !empty($this->nameList[$fieldName]) && !empty($parentModule)) { $parentMeta = $this->queryGenerator->getMeta($parentModule); $value = textlength_check($this->nameList[$fieldName][$value]); if ($parentMeta->isModuleEntity() && $parentModule != "Users") { $value = "<a href='index.php?module={$parentModule}&action=DetailView&" . "record={$rawValue}' title='" . getTranslatedString($parentModule, $parentModule) . "'>{$value}</a>"; } } else { $value = '--'; } } elseif ($field->getFieldDataType() == 'owner') { if ($fieldName != 'assigned_user_id' && strstr($fieldName, ".assigned_user_id")) { $value = textlength_check($this->ownerNameListrel[$fieldName][$value]); } else { $value = textlength_check($this->ownerNameList[$fieldName][$value]); } } elseif ($field->getUIType() == 25) { //TODO clean request object reference. $contactId = $_REQUEST['record']; $emailId = $this->db->query_result($result, $i, "activityid"); $result1 = $this->db->pquery("SELECT access_count FROM vtiger_email_track WHERE " . "crmid=? AND mailid=?", array($contactId, $emailId)); $value = $this->db->query_result($result1, 0, "access_count"); if (!$value) { $value = 0; } } elseif ($field->getUIType() == 8) { if (!empty($value)) { $temp_val = html_entity_decode($value, ENT_QUOTES, $default_charset); $json = new Zend_Json(); $value = vt_suppressHTMLTags(implode(',', $json->decode($temp_val))); } } elseif (in_array($uitype, array(7, 9, 90))) { $value = "<span align='right'>" . textlength_check($value) . "</div>"; } elseif ($field->getUIType() == 55) { $value = getTranslatedString($value, $currentModule); } else { $value = textlength_check($value); } $parenttab = getParentTab(); $nameFields = $this->queryGenerator->getModuleNameFields($module); $nameFieldList = explode(',', $nameFields); if (in_array($fieldName, $nameFieldList) && $module != 'Emails') { $value = "<a href='index.php?module={$module}&parenttab={$parenttab}&action=DetailView&record=" . "{$recordId}' title='" . getTranslatedString($module, $module) . "'>{$value}</a>"; } elseif ($fieldName == $focus->list_link_field && $module != 'Emails') { $value = "<a href='index.php?module={$module}&parenttab={$parenttab}&action=DetailView&record=" . "{$recordId}' title='" . getTranslatedString($module, $module) . "'>{$value}</a>"; } // vtlib customization: For listview javascript triggers $value = "{$value} <span type='vtlib_metainfo' vtrecordid='{$recordId}' vtfieldname=" . "'{$fieldName}' vtmodule='{$module}' style='display:none;'></span>"; // END $row[] = $value; } //Added for Actions ie., edit and delete links in listview $actionLinkInfo = ""; if (isPermitted($module, "EditView", "") == 'yes') { $edit_link = $this->getListViewEditLink($module, $recordId); if (isset($navigationInfo['start']) && $navigationInfo['start'] > 1 && $module != 'Emails') { $actionLinkInfo .= "<a href=\"{$edit_link}&start=" . $navigationInfo['start'] . "\">" . getTranslatedString("LNK_EDIT", $module) . "</a> "; } else { $actionLinkInfo .= "<a href=\"{$edit_link}\">" . getTranslatedString("LNK_EDIT", $module) . "</a> "; } } if (isPermitted($module, "Delete", "") == 'yes') { $del_link = $this->getListViewDeleteLink($module, $recordId); if ($actionLinkInfo != "" && $del_link != "") { $actionLinkInfo .= ' | '; } if ($del_link != "") { $actionLinkInfo .= "<a href='javascript:confirmdelete(\"" . addslashes(urlencode($del_link)) . "\")'>" . getTranslatedString("LNK_DELETE", $module) . "</a>"; } } // Record Change Notification if (method_exists($focus, 'isViewed') && PerformancePrefs::getBoolean('LISTVIEW_RECORD_CHANGE_INDICATOR', true)) { if (!$focus->isViewed($recordId)) { $actionLinkInfo .= " | <img src='" . vtiger_imageurl('important1.gif', $theme) . "' border=0>"; } } // END if ($actionLinkInfo != "" && !$skipActions) { $row[] = $actionLinkInfo; } list($row, $unused, $unused2) = cbEventHandler::do_filter('corebos.filter.listview.render', array($row, $this->db->query_result_rowdata($result, $i), $recordId)); $data[$recordId] = $row; } return $data; }
public static function showImportLockedError($lockInfo) { $errorMessage = vtranslate('ERR_MODULE_IMPORT_LOCKED', 'Import'); $errorDetails = array(vtranslate('LBL_MODULE_NAME', 'Import') => getTabModuleName($lockInfo['tabid']), vtranslate('LBL_USER_NAME', 'Import') => getUserFullName($lockInfo['userid']), vtranslate('LBL_LOCKED_TIME', 'Import') => $lockInfo['locked_since']); self::showErrorPage($errorMessage, $errorDetails); }
function get_modules() { global $adb, $log; $log->debug("Entering customer portal Function get_modules"); // Check if information is available in cache? $modules = Vtiger_Soap_CustomerPortal::lookupAllowedModules(); if ($modules === false) { $modules = array(); $query = $adb->pquery("SELECT vtiger_customerportal_tabs.* FROM vtiger_customerportal_tabs\n\t\t\tINNER JOIN vtiger_tab ON vtiger_tab.tabid = vtiger_customerportal_tabs.tabid\n\t\t\tWHERE vtiger_tab.presence = 0 AND vtiger_customerportal_tabs.visible = 1", array()); $norows = $adb->num_rows($query); if ($norows) { while ($resultrow = $adb->fetch_array($query)) { $modules[(int) $resultrow['sequence']] = getTabModuleName($resultrow['tabid']); } ksort($modules); // Order via SQL might cost us, so handling it ourselves in this case } Vtiger_Soap_CustomerPortal::updateAllowedModules($modules); } $log->debug("Exiting customerportal function get_modules"); return $modules; }
/** Function to get the permitted module name Array with presence as 0 * @returns permitted module name Array :: Type Array * */ function getPermittedModuleNames() { $log = vglobal('log'); $log->debug("Entering getPermittedModuleNames() method ..."); $current_user = vglobal('current_user'); $permittedModules = array(); require 'user_privileges/user_privileges_' . $current_user->id . '.php'; include 'user_privileges/tabdata.php'; if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1) { foreach ($tab_seq_array as $tabid => $seq_value) { if ($seq_value === 0 && $profileTabsPermission[$tabid] === 0) { $permittedModules[] = getTabModuleName($tabid); } } } else { foreach ($tab_seq_array as $tabid => $seq_value) { if ($seq_value === 0) { $permittedModules[] = getTabModuleName($tabid); } } } $log->debug("Exiting getPermittedModuleNames method ..."); return $permittedModules; }
$rec = $_POST['accid']; if (isset($_POST['orgmodH'])) { $orgmod = explode("\$\$", $_POST['orgmodH']); } else { $orgmod = explode("\$\$", $_POST['orgmod']); } $orgmodID = $orgmod[0]; $mapid = $_REQUEST['mapid']; $orgmodName = getTabModuleName($orgmodID); if (isset($_POST['targetmodH'])) { $targetmod = explode("\$\$", $_POST['targetmodH']); } else { $targetmod = explode("\$\$", $_POST['targetmod']); } $targetmodID = $targetmod[0]; $targetmodName = getTabModuleName($targetmodID); $targetVal = $_POST['targetVal']; $targetArr = explode("::", $targetVal); $orgVal = $_POST['orgVal']; $orgArr = explode(",", $orgVal); $nrmaps = count($orgArr); global $adb; $adb->pquery("Update vtiger_cbmap set origin=?,originname=?, target=?, \n targetname=?, field1=?,field2=?,delimiter=? where cbmapid=?", array($orgmodID, $orgmodName, $targetmodID, $targetmodName, $orgVal, $targetVal, $defaultDelimiter, $mapid)); $delimArr = explode("@", $defaultDelimiter); $xml = new DOMDocument("1.0"); $root = $xml->createElement("map"); $xml->appendChild($root); //$name = $xml->createElement("name"); $target = $xml->createElement("originmodule"); $targetid = $xml->createElement("originid"); $targetidText = $xml->createTextNode($targetmodID);
function getPickListOptions() { $fieldName = $this->getFieldName(); $default_charset = VTWS_PreserveGlobal::getGlobal('default_charset'); $options = array(); $sql = "select * from vtiger_picklist where name=?"; $result = $this->pearDB->pquery($sql, array($fieldName)); $numRows = $this->pearDB->num_rows($result); if ($numRows == 0) { $sql = "select * from vtiger_{$fieldName}"; $result = $this->pearDB->pquery($sql, array()); $numRows = $this->pearDB->num_rows($result); for ($i = 0; $i < $numRows; ++$i) { $elem = array(); $picklistValue = $this->pearDB->query_result($result, $i, $fieldName); $picklistValue = decode_html($picklistValue); $moduleName = getTabModuleName($this->getTabId()); if ($moduleName == 'Events') { $moduleName = 'Calendar'; } $elem["label"] = getTranslatedString($picklistValue, $moduleName); $elem["value"] = $picklistValue; array_push($options, $elem); } } else { $user = VTWS_PreserveGlobal::getGlobal('current_user'); $details = getPickListValues($fieldName, $user->roleid); for ($i = 0; $i < sizeof($details); ++$i) { $elem = array(); $picklistValue = decode_html($details[$i]); $moduleName = getTabModuleName($this->getTabId()); if ($moduleName == 'Events') { $moduleName = 'Calendar'; } $elem["label"] = getTranslatedString($picklistValue, $moduleName); $elem["value"] = $picklistValue; array_push($options, $elem); } } return $options; }
foreach ($action_array as $action_id => $act_per) { $action_name = getActionname($action_id); $tab_util_act_per = $action_array[$action_id]; $tab_util_per = getDisplayOutput($tab_util_act_per, $tabid, $action_id); $util[] = $action_name; $util[] = $tab_util_per; } $util = array_chunk($util, 2); $util = array_chunk($util, 3); $privilege_util[$tabid] = $util; } } else { $act_utility_arry = getTabsUtilityActionPermission(1); foreach ($act_utility_arry as $tabid => $action_array) { $util = array(); $entity_name = getTabModuleName($tabid); $no_of_actions = sizeof($action_array); foreach ($action_array as $action_id => $act_per) { $action_name = getActionname($action_id); $tab_util_act_per = $action_array[$action_id]; $tab_util_per = getDisplayOutput(0, $tabid, $action_id); $util[] = $action_name; $util[] = $tab_util_per; } $util = array_chunk($util, 2); $util = array_chunk($util, 3); $privilege_util[$tabid] = $util; } } } $smarty->assign("UTILITIES_PRIV", $privilege_util);
function updateFieldProperties() { global $adb, $smarty, $log; $fieldid = vtlib_purify($_REQUEST['fieldid']); $req_sql = "select * from vtiger_field where fieldid = ? and fieldname not in('salutationtype') and vtiger_field.presence in (0,2)"; $req_result = $adb->pquery($req_sql, array($fieldid)); $typeofdata = $adb->query_result($req_result, 0, 'typeofdata'); $tabid = $adb->query_result($req_result, 0, 'tabid'); $fieldname = $adb->query_result($req_result, 0, 'fieldname'); $uitype = $adb->query_result($req_result, 0, 'uitype'); $oldfieldlabel = $adb->query_result($req_result, 0, 'fieldlabel'); $tablename = $adb->query_result($req_result, 0, 'tablename'); $columnname = $adb->query_result($req_result, 0, 'columnname'); $oldquickcreate = $adb->query_result($req_result, 0, 'quickcreate'); $oldmassedit = $adb->query_result($req_result, 0, 'masseditable'); $oldpresence = $adb->query_result($req_result, 0, 'presence'); if (!empty($_REQUEST['fld_module'])) { $fld_module = vtlib_purify($_REQUEST['fld_module']); } else { $fld_module = getTabModuleName($tabid); } $focus = CRMEntity::getInstance($fld_module); $fieldtype = explode("~", $typeofdata); $mandatory_checked = vtlib_purify($_REQUEST['ismandatory']); $quickcreate_checked = vtlib_purify($_REQUEST['quickcreate']); $presence_check = vtlib_purify($_REQUEST['isPresent']); $massedit_check = vtlib_purify($_REQUEST['massedit']); $defaultvalue = vtlib_purify($_REQUEST['defaultvalue']); if (!empty($defaultvalue)) { if ($uitype == 56) { if ($defaultvalue == 'on' || $defaultvalue == '1') { $defaultvalue = '1'; } elseif ($defaultvalue == 'off' || $defaultvalue == '0') { $defaultvalue = '0'; } else { $defaultvalue = ''; } } elseif ($uitype == 5 || $uitype == 6 || $uitype == 23) { $defaultvalue = getValidDBInsertDateValue($defaultvalue); } } if (isset($focus->mandatory_fields) && !empty($focus->mandatory_fields) && in_array($fieldname, $focus->mandatory_fields)) { $fieldtype[1] = 'M'; } elseif ($mandatory_checked == 'true' || $mandatory_checked == '') { $fieldtype[1] = 'M'; } else { $fieldtype[1] = 'O'; } $datatype = implode('~', $fieldtype); $maxseq = ''; if ($oldquickcreate != 3) { if ($quickcreate_checked == 'true' || $quickcreate_checked == '') { $qcdata = 2; $quickcreateseq_Query = 'select max(quickcreatesequence) as maxseq from vtiger_field where tabid = ?'; $res = $adb->pquery($quickcreateseq_Query, array($tabid)); $maxseq = $adb->query_result($res, 0, 'maxseq'); } else { $qcdata = 1; } } if ($oldpresence != 3) { if ($presence_check == 'true' || $presence_check == '') { $presence = 2; } else { $presence = 1; } } else { $presence = 1; } if ($oldmassedit != 3) { if ($massedit_check == 'true' || $massedit_check == '') { $massedit = 1; } else { $massedit = 2; } } else { $massedit = 1; } if (isset($focus->mandatory_fields) && !empty($focus->mandatory_fields)) { $fieldname_list = implode(',', $focus->mandatory_fields); } else { $fieldname_list = ''; } $mandatory_query = "update vtiger_field set typeofdata=? where fieldid=? and fieldname not in (?) AND displaytype != 2"; $mandatory_params = array($datatype, $fieldid, $fieldname_list); $adb->pquery($mandatory_query, $mandatory_params); if (!empty($qcdata)) { $quickcreate_query = "update vtiger_field set quickcreate = ? ,quickcreatesequence = ? where fieldid = ? and quickcreate not in (0,3) AND displaytype != 2"; $quickcreate_params = array($qcdata, $maxseq + 1, $fieldid); $adb->pquery($quickcreate_query, $quickcreate_params); } $presence_query = "update vtiger_field set presence = ? where fieldid = ? and presence not in (0,3) and quickcreate != 0"; $quickcreate_params = array($presence, $fieldid); $adb->pquery($presence_query, $quickcreate_params); $massedit_query = "update vtiger_field set masseditable = ? where fieldid = ? and masseditable not in (0,3) AND displaytype != 2"; $massedit_params = array($massedit, $fieldid); $adb->pquery($massedit_query, $massedit_params); $defaultvalue_query = "update vtiger_field set defaultvalue=? where fieldid = ? and fieldname not in (?) AND displaytype != 2"; $defaultvalue_params = array($defaultvalue, $fieldid, $fieldname_list); $adb->pquery($defaultvalue_query, $defaultvalue_params); }
/** * function gives an array of module names for which modtracking is enabled */ function getModTrackerEnabledModules() { $adb = PearDatabase::getInstance(); $moduleResult = $adb->pquery('SELECT * FROM vtiger_modtracker_tabs', array()); for ($i = 0; $i < $adb->num_rows($moduleResult); $i++) { $tabId = $adb->query_result($moduleResult, $i, 'tabid'); $visible = $adb->query_result($moduleResult, $i, 'visible'); self::updateCache($tabId, $visible); if ($visible == 1) { $modules[] = getTabModuleName($tabId); } } return $modules; }