/** * Get the filterable field types and their operators. * * @param string $client The client that you are working on. * @return array The list of filterable field types and their operators. */ public static function getOperators($client = 'base') { $filtersMetadata = MetaDataManager::getManager($client)->getSugarFilters(); if (empty($filtersMetadata['operators']['meta'])) { return array(); } return $filtersMetadata['operators']['meta']; }
public function clearCaches() { //Need to invalidate the caches for rolesets when roles change (availible modules may change) if ($this->load_relationship('acl_role_sets')) { $rolesets = $this->acl_role_sets->getBeans(); $mm = MetaDataManager::getManager(); foreach ($rolesets as $roleset) { $context = new MetaDataContextRoleSet($roleset); $mm->invalidateCache($mm->getPlatformsWithCaches(), $context); } } sugar_cache_clear('ACL'); }
/** * Gets a MetaDataManager object * @param string $platform The platform to get the manager for * @param boolean $public Flag to describe visibility for metadata * @return MetaDataManager */ protected function getMetaDataManager($platform = '', $public = false) { return MetaDataManager::getManager($platform, $public); }
/** * Sets up metadata caches for various platforms and languages. * * NOTE: This can get expensive for many platforms and/or many languages. * * @param array $platforms Array of platforms for setup metadata for * @param array $languages Array of language metadata caches to build * @return void */ public static function setupMetadata($platforms = array(), $languages = array()) { // Set up the platforms array if (empty($platforms)) { $platforms = array('base'); } if (!is_array($platforms)) { $platforms = (array) $platforms; } if (empty($languages)) { $languages = array('en_us'); } if (!is_array($languages)) { $languages = (array) $languages; } // Loop over the metadata managers for each platform and visibility, then // over each of the languages for each manager foreach ($platforms as $platform) { foreach (array(true, false) as $public) { $mm = MetaDataManager::getManager($platform, $public); $mm->getMetadata(); foreach ($languages as $language) { $mm->getLanguage($language); } } } }
/** * Gets the metadata manager for this user and platform * * @return MetaDataManager */ protected function getMetadataManager() { return MetaDataManager::getManager(array($this->platform)); }
protected function buildRelationshipCache() { global $beanList, $buildingRelCache; if ($buildingRelCache) { return; } $buildingRelCache = true; $relationships = $this->getRelationshipData(); //Save it out sugar_mkdir(dirname($this->getCacheFile()), null, true); $out = "<?php \n \$relationships = " . var_export($relationships, true) . ";"; sugar_file_put_contents_atomic($this->getCacheFile(), $out); // There are only certain times when the relationship cache needs to be // refreshed... // // If we have a cache, but no internal relationships yet, do NOT rebuild // the api cache. This is a first load of this class. // // If there is no cache, then do NOT rebuild the api cache since there is // nothing to rebuild. // // DO rebuild the cache if there is a cache, there is an internal relationships // property and it is different than $relationships $rebuildApiCache = false; $metaCacheKey = MetaDataManager::getManager()->getCachedMetadataHash(); if (empty($metaCacheKey)) { $rebuildApiCache = !empty($this->relationships) && array_diff_key($this->relationships, $relationships) !== array(); } $this->relationships = $relationships; if ($rebuildApiCache) { MetaDataManager::refreshSectionCache(array(MetaDataManager::MM_RELATIONSHIPS)); } // set the variable back to false, as we are now going to rebuild the vardefs since we have all the // relationships are loaded $buildingRelCache = false; //Now load all vardefs a second time populating the rel_calc_fields foreach ($beanList as $moduleName => $beanName) { // need to refresh the vardef so that the related calc fields are loaded VardefManager::loadVardef($moduleName, BeanFactory::getObjectName($moduleName), true); } }
foreach ($currentReauthPrefs as $key => $val) { if ($focus->getPreference($key) != $val) { $refreshMetadata = true; break; } } } // [BR-200] Force reauth so user pref metadata is refreshed if ($refreshMetadata) { // This will more than likely already be true, but force it to be sure $focus->update_date_modified = true; } // Since metadata caches contain data specific to roles and users, we need // to nuke the caches when a user changes since it is possible for one // user to change another user MetaDataManager::getManager()->invalidateUserCache($focus); $GLOBALS['sugar_config']['disable_team_access_check'] = true; $focus->save(); $GLOBALS['sugar_config']['disable_team_access_check'] = false; $return_id = $focus->id; $ieVerified = true; global $new_pwd; $new_pwd = ''; if ((isset($_POST['old_password']) || $focus->portal_only) && (isset($_POST['new_password']) && !empty($_POST['new_password'])) && (isset($_POST['password_change']) && $_POST['password_change'] == 'true')) { if (!$focus->change_password($_POST['old_password'], $_POST['new_password'])) { if (isset($_POST['page']) && $_POST['page'] == 'EditView') { header("Location: index.php?action=EditView&module=Users&record=" . $_POST['record'] . "&error_password="******"Location: index.php?action=ChangePassword&module=Users&record=" . $_POST['record'] . "&error_password=" . urlencode($focus->error_string));
/** * Load the layout def file and associate the definition with a variable in the file. */ function open_layout_defs($reload = false, $layout_def_key = '', $original_only = false) { require_once 'include/MetaDataManager/MetaDataManager.php'; $mm = MetaDataManager::getManager(); $layout_defs[$this->_focus->module_dir] = array(); $layout_defs[$layout_def_key] = array(); $def_path = array(); if (empty($this->layout_defs) || $reload || !empty($layout_def_key) && !isset($layout_defs[$layout_def_key])) { if (!$original_only) { if (isModuleBWC($this->_focus->module_dir)) { $def_path = array('modules/' . $this->_focus->module_dir . '/metadata/' . ($this->platform == 'mobile' ? 'wireless.' : '') . 'subpaneldefs.php'); $def_path[] = SugarAutoLoader::loadExtension($this->platform == 'mobile' ? 'wireless_subpanels' : 'layoutdefs', $this->_focus->module_dir); foreach (SugarAutoLoader::existing($def_path) as $file) { require $file; } } else { $viewdefs = $mm->getModuleLayouts($this->_focus->module_dir); $viewdefs = !empty($viewdefs['subpanels']['meta']['components']) ? $viewdefs['subpanels']['meta']['components'] : array(); } } $layoutDefsKey = !empty($layout_def_key) ? $layout_def_key : $this->_focus->module_dir; // convert sidecar subpanels to the array the SubpanelDefinitions are looking for if ($this->_focus instanceof SugarBean && !isModuleBWC($this->_focus->module_dir) && isset($viewdefs)) { require_once 'include/MetaDataManager/MetaDataConverter.php'; $metaDataConverter = new MetaDataConverter(); $layout_defs[$layoutDefsKey] = $metaDataConverter->toLegacySubpanelLayoutDefs($viewdefs, $this->_focus); } $this->layout_defs = $layout_defs[$layoutDefsKey]; } }
if (isset($_REQUEST['collation']) && !empty($_REQUEST['collation'])) { //kbrill Bug #14922 if (array_key_exists('collation', $sugar_config['dbconfigoption']) && $_REQUEST['collation'] != $sugar_config['dbconfigoption']['collation']) { $GLOBALS['db']->disconnect(); $GLOBALS['db']->connect(); } $cfg->config['dbconfigoption']['collation'] = $_REQUEST['collation']; } $cfg->populateFromPost(); $cfg->handleOverride(); if ($locale->invalidLocaleNameFormatUpgrade()) { $locale->removeInvalidLocaleNameFormatUpgradeNotice(); } // Metadata sections that have to be refreshed on `Save`. $refreshSections = array(MetaDataManager::MM_CURRENCIES, MetaDataManager::MM_LABELS, MetaDataManager::MM_ORDEREDLABELS); $mm = MetaDataManager::getManager(); $mm->refreshSectionCache($refreshSections); // Call `ping` API to refresh the metadata. echo "\n <script>\n var app = window.parent.SUGAR.App;\n app.api.call('read', app.api.buildURL('ping'));\n app.router.navigate('#bwc/index.php?module=Administration&action=index', {trigger:true, replace:true});\n </script>\n "; } else { /////////////////////////////////////////////////////////////////////////////// //// DB COLLATION $collationOptions = $GLOBALS['db']->getCollationList(); if (!empty($collationOptions)) { if (!isset($sugar_config['dbconfigoption']['collation'])) { $sugar_config['dbconfigoption']['collation'] = $GLOBALS['db']->getDefaultCollation(); } $sugar_smarty->assign('collationOptions', get_select_options_with_id(array_combine($collationOptions, $collationOptions), $sugar_config['dbconfigoption']['collation'])); } //// END DB COLLATION ///////////////////////////////////////////////////////////////////////////////
/** * @param $params * @return array */ protected function getRoleOptions($params) { $manager = MetaDataManager::getManager(); return $manager->getEditableDropdownFilter($params['dropdown_name'], $params['dropdown_role']); }
/** * Returns list of roles with marker indicating whether role specific metadata for the given dropdown field exists * * @param string $name Dropdown field name * @return array */ protected function getAvailableRoleList($name) { $manager = MetaDataManager::getManager(); return MBHelper::getAvailableRoleList(function (array $params) use($manager, $name) { return $manager->hasEditableDropdownFilter($name, $params['role']); }); }
/** * Get the beans ACL's to pass back any that differ * @param SugarBean $bean * @param array $fieldList * @return array */ public function getBeanAcl(SugarBean $bean, array $fieldList) { $acl = array('fields' => (object) array()); if (SugarACL::moduleSupportsACL($bean->module_dir)) { $mm = MetaDataManager::getManager($this->api->platform); $moduleAcl = $mm->getAclForModule($bean->module_dir, $this->api->user, false, true); $beanAcl = $mm->getAclForModule($bean->module_dir, $this->api->user, $bean, true); if ($beanAcl['_hash'] != $moduleAcl['_hash'] || !empty($fieldList)) { // diff the fields separately, they are usually empty anyway so we won't diff these often. $moduleAclFields = $moduleAcl['fields']; $beanAclFields = $beanAcl['fields']; // dont' need the fields here will append at the end unset($moduleAcl['fields']); unset($beanAcl['fields']); // don't need the hashes anymore unset($moduleAcl['_hash']); unset($beanAcl['_hash']); $acl = array_diff_assoc($beanAcl, $moduleAcl); $fieldAcls = array(); /** * Fields are different than module level acces * if fields is empty that means all access is granted * beanAclFields is empty and moduleAclFields is empty -> all access -> return empty * beanAclFields is empty and moduleAclFields is !empty -> all access -> return yes's * beanAclFields is !empty and moduleAclFields is empty -> beanAclFields access restrictions -> return beanAclFields * beanAclFields is !empty and moduleAclFields is !empty -> return all access = "Yes" from moduleAcl and unset any in beanAcl that is in ModuleAcl [don't dupe data] */ if (!empty($beanAclFields) && empty($moduleAclFields)) { $fieldAcls = $beanAclFields; } elseif (!empty($beanAclFields) && !empty($moduleAclFields)) { // we need the ones that are moduleAclFields but not in beanAclFields foreach ($moduleAclFields as $field => $aclActions) { foreach ($aclActions as $action => $access) { if (!isset($beanAclFields[$field][$action])) { $beanAclFields[$field][$action] = "yes"; } // if the bean action is set and it matches the access from module, we do not need to send it down if (isset($beanAclFields[$field][$action]) && $beanAclFields[$field][$action] == $access) { unset($beanAclFields[$field][$action]); } } } // cleanup BeanAclFields, we don't want to pass a field that doens't have actions foreach ($beanAclFields as $field => $actions) { if (empty($actions)) { unset($beanAclFields[$field]); } } $fieldAcls = $beanAclFields; } elseif (empty($beanAclFields) && !empty($moduleAclFields)) { // it is different because we now have access... foreach ($moduleAclFields as $field => $aclActions) { foreach ($aclActions as $action => $access) { $fieldAcls[$field][$action] = "yes"; } } } foreach ($fieldList as $fieldName) { if (empty($fieldAcls[$fieldName]) && isset($moduleAclFields[$fieldName])) { $fieldAcls[$fieldName] = $moduleAclFields[$fieldName]; } } $acl['fields'] = (object) $fieldAcls; } } return $acl; }