function get_system_tabs() { global $moduleList; static $system_tabs_result = null; // if the value is not already cached, then retrieve it. if (empty($system_tabs_result)) { $administration = new Administration(); $administration->retrieveSettings('MySettings'); if (isset($administration->settings) && isset($administration->settings['MySettings_tab'])) { $tabs = $administration->settings['MySettings_tab']; $trimmed_tabs = trim($tabs); //make sure serialized string is not empty if (!empty($trimmed_tabs)) { $tabs = base64_decode($tabs); $tabs = unserialize($tabs); //Ensure modules saved in the prefences exist. foreach ($tabs as $id => $tab) { if (!in_array($tab, $moduleList)) { unset($tabs[$id]); } } ACLController::filterModuleList($tabs); $tabs = $this->get_key_array($tabs); $system_tabs_result = $tabs; } else { $system_tabs_result = $this->get_key_array($moduleList); } } else { $system_tabs_result = $this->get_key_array($moduleList); } } return $system_tabs_result; }
function SugarFeedDashlet($id, $def = null) { global $current_user, $app_strings, $app_list_strings; require 'modules/SugarFeed/metadata/dashletviewdefs.php'; $this->myItemsOnly = false; parent::DashletGeneric($id, $def); $this->myItemsOnly = false; $this->isConfigurable = true; $this->hasScript = true; $pattern = array(); $pattern[] = "/-/"; $pattern[] = "/[0-9]/"; $replacements = array(); $replacements[] = ''; $replacements[] = ''; $this->idjs = preg_replace($pattern, $replacements, $this->id); // Add in some default categories. $this->categories['ALL'] = translate('LBL_ALL', 'SugarFeed'); // Need to get the rest of the active SugarFeed modules $module_list = SugarFeed::getActiveFeedModules(); // Translate the category names if (!is_array($module_list)) { $module_list = array(); } foreach ($module_list as $module) { if ($module == 'UserFeed') { // Fake module, need to translate specially $this->categories[$module] = translate('LBL_USER_FEED', 'SugarFeed'); } else { $this->categories[$module] = $app_list_strings['moduleList'][$module]; } } // Need to add the external api's here $this->externalAPIList = ExternalAPIFactory::getModuleDropDown('SugarFeed', true); if (!is_array($this->externalAPIList)) { $this->externalAPIList = array(); } foreach ($this->externalAPIList as $apiObj => $apiName) { $this->categories[$apiObj] = $apiName; } if (empty($def['title'])) { $this->title = translate('LBL_HOMEPAGE_TITLE', 'SugarFeed'); } if (!empty($def['rows'])) { $this->displayRows = $def['rows']; } if (!empty($def['categories'])) { $this->selectedCategories = $def['categories']; } if (!empty($def['userfeed_created'])) { $this->userfeed_created = $def['userfeed_created']; } $this->searchFields = $dashletData['SugarFeedDashlet']['searchFields']; $this->columns = $dashletData['SugarFeedDashlet']['columns']; $catCount = count($this->categories); ACLController::filterModuleList($this->categories, false); if (count($this->categories) < $catCount) { if (!empty($this->selectedCategories)) { ACLController::filterModuleList($this->selectedCategories, true); } else { $this->selectedCategories = array_keys($this->categories); unset($this->selectedCategories[0]); } } $this->seedBean = new SugarFeed(); }
function get_user_module_list($user) { $GLOBALS['log']->info('Begin: SoapHelperWebServices->get_user_module_list'); global $app_list_strings, $current_language; $app_list_strings = return_app_list_strings_language($current_language); $modules = query_module_access_list($user); ACLController::filterModuleList($modules, false); global $modInvisList, $modInvisListActivities; foreach ($modInvisList as $invis) { $modules[$invis] = 'read_only'; } if (isset($modules['Calendar']) || $modules['Activities']) { foreach ($modInvisListActivities as $invis) { $modules[$invis] = $invis; } } $actions = ACLAction::getUserActions($user->id, true); foreach ($actions as $key => $value) { if (isset($value['module']) && $value['module']['access']['aclaccess'] < ACL_ALLOW_ENABLED) { if ($value['module']['access']['aclaccess'] == ACL_ALLOW_DISABLED) { unset($modules[$key]); } else { $modules[$key] = 'read_only'; } // else } else { $modules[$key] = ''; } // else } // foreach $GLOBALS['log']->info('End: SoapHelperWebServices->get_user_module_list'); return $modules; }
function ACLFilter() { ACLController::filterModuleList($GLOBALS['moduleList']); }
function get_user_module_list($user) { global $app_list_strings, $current_language, $beanList, $beanFiles; $app_list_strings = return_app_list_strings_language($current_language); $modules = query_module_access_list($user); ACLController::filterModuleList($modules, false); global $modInvisList; foreach ($modInvisList as $invis) { $modules[$invis] = 'read_only'; } $actions = ACLAction::getUserActions($user->id, true); foreach ($actions as $key => $value) { if (isset($value['module']) && $value['module']['access']['aclaccess'] < ACL_ALLOW_ENABLED) { if ($value['module']['access']['aclaccess'] == ACL_ALLOW_DISABLED) { unset($modules[$key]); } else { $modules[$key] = 'read_only'; } // else } else { $modules[$key] = ''; } // else } // foreach //Remove all modules that don't have a beanFiles entry associated with it foreach ($modules as $module_name => $module) { if (isset($beanList[$module_name])) { $class_name = $beanList[$module_name]; if (empty($beanFiles[$class_name])) { unset($modules[$module_name]); } } else { unset($modules[$module_name]); } } return $modules; }
function ACLFilter() { ACLController::filterModuleList($GLOBALS['moduleList']); ACLController::filterModuleList($GLOBALS['modInvisListActivities']); }
//if the theme is changed $_SESSION['theme_changed'] = false; if (isset($_REQUEST['usertheme'])) { $_SESSION['theme_changed'] = true; $_SESSION['authenticated_user_theme'] = clean_string($_REQUEST['usertheme']); $theme = clean_string($_REQUEST['usertheme']); } //if the language is changed if (isset($_REQUEST['userlanguage'])) { $_SESSION['theme_changed'] = true; $_SESSION['authenticated_user_language'] = clean_string($_REQUEST['userlanguage']); $current_language = clean_string($_REQUEST['userlanguage']); } $GLOBALS['log']->debug('Current theme is: ' . $theme); ACLController::filterModuleList($moduleList); ACLController::filterModuleList($modInvisListActivities); //TODO move this code into $theme/header.php so that we can be within the <DOCTYPE xxx> and <HTML> tags. if (empty($_REQUEST['to_pdf']) && empty($_REQUEST['to_csv'])) { echo '<script type="text/javascript" src="include/javascript/cookie.js?s=' . $sugar_version . '&c=' . $sugar_config['js_custom_version'] . '"></script>'; echo '<link rel="stylesheet" type="text/css" media="all" href="themes/' . $theme . '/calendar-win2k-cold-1.css?s=' . $sugar_version . '&c=' . $sugar_config['js_custom_version'] . '">'; echo '<script>jscal_today = ' . 1000 * strtotime($timedate->handle_offset(gmdate('Y-m-d H:i:s', gmmktime()), 'Y-m-d H:i:s')) . '; if(typeof app_strings == "undefined") app_strings = new Array();</script>'; echo '<script type="text/javascript" src="jscalendar/calendar.js?s=' . $sugar_version . '&c=' . $sugar_config['js_custom_version'] . '"></script>'; echo '<script type="text/javascript" src="jscalendar/lang/calendar-en.js?s=' . $sugar_version . '&c=' . $sugar_config['js_custom_version'] . '"></script>'; echo '<script type="text/javascript" src="jscalendar/calendar-setup_3.js?s=' . $sugar_version . '&c=' . $sugar_config['js_custom_version'] . '"></script>'; echo '<script src="include/javascript/yui/YAHOO.js?s=' . $sugar_version . '&c=' . $sugar_config['js_custom_version'] . '"></script>'; echo '<script src="include/javascript/yui/log.js?s=' . $sugar_version . '&c=' . $sugar_config['js_custom_version'] . '"></script>'; echo '<script src="include/javascript/yui/dom.js?s=' . $sugar_version . '&c=' . $sugar_config['js_custom_version'] . '"></script>'; echo '<script src="include/javascript/yui/event.js?s=' . $sugar_version . '&c=' . $sugar_config['js_custom_version'] . '"></script>'; echo '<script src="include/javascript/yui/animation.js?s=' . $sugar_version . '&c=' . $sugar_config['js_custom_version'] . '"></script>'; echo '<script src="include/javascript/yui/connection.js?s=' . $sugar_version . '&c=' . $sugar_config['js_custom_version'] . '"></script>'; echo '<script src="include/javascript/yui/dragdrop.js?s=' . $sugar_version . '&c=' . $sugar_config['js_custom_version'] . '"></script>';
/** * This function is used to hand off the global search to the built-in SugarSearchEngine (aka SugarSpot) * @param $api ServiceBase The API class of the request * @param $args array The arguments array passed in from the API * @param $searchEngine SugarSearchEngine The SugarSpot search engine created using the Factory in the caller * @param $options array An array of options to pass through to the search engine, they get translated to the $searchOptions array so you can see exactly what gets passed through * @return array Two elements, 'records' the list of returned records formatted through FormatBean, and 'next_offset' which will indicate to the user if there are additional records to be returned. */ public function globalSearchSpot(ServiceBase $api, array $args, $searchEngine, array $options) { require_once 'modules/Home/UnifiedSearchAdvanced.php'; $searchOptions = array('modules' => $options['moduleList'], 'current_module' => $options['primaryModule'], 'return_beans' => true, 'my_items' => $options['my_items'], 'favorites' => $options['favorites'], 'orderBy' => $options['orderBy'], 'fields' => $options['fieldFilters'], 'selectFields' => $options['selectFields'], 'limitPerModule' => $options['limitPerModule'], 'allowEmptySearch' => true, 'distinct' => 'DISTINCT', 'return_beans' => true); if (isset($options['deleted'])) { $searchOptions['deleted'] = $options['deleted']; } $multiModule = false; if (empty($options['moduleList']) || count($options['moduleList']) == 0 || count($options['moduleList']) > 1) { $multiModule = true; } if (empty($options['moduleList'])) { require_once 'modules/ACL/ACLController.php'; $usa = new UnifiedSearchAdvanced(); $moduleList = $usa->getUnifiedSearchModules(); // get the module names [array keys] $moduleList = array_keys($moduleList); // filter based on User Access if Blank $ACL = new ACLController(); // moduleList is passed by reference $ACL->filterModuleList($moduleList); $searchOptions['modules'] = $options['moduleList'] = $moduleList; } if (!empty($options['searchFields'])) { $customWhere = array(); foreach ($options['moduleList'] as $module) { $seed = BeanFactory::getBean($module); $fields = array_keys($seed->field_defs); $existingfields = array_intersect($fields, $options['searchFields']); if (!empty($existingfields)) { $customTable = $seed->get_custom_table_name(); $table = $seed->table_name; foreach ($existingfields as $field) { if (!isset($seed->field_defs[$field]['unified_search']) || $seed->field_defs[$field]['unified_search'] !== true) { continue; } $prefix = $table; if (isset($GLOBALS['dictionary'][$seed->object_name]['custom_fields'][$field])) { $prefix = $customTable; } if (!isset($seed->field_defs[$field]['source']) || $seed->field_defs[$field]['source'] != 'non-db') { $customWhere[$module][] = "{$prefix}.{$field} LIKE '{$options['query']}%'"; } } if (isset($customWhere[$module])) { $searchOptions['custom_where_module'][$module] = '(' . implode(' OR ', $customWhere[$module]) . ')'; } } } } $offset = $options['offset']; // One for luck. // Well, actually it's so that we know that there are additional results $limit = $options['limit'] + 1; if ($multiModule && $options['offset'] != 0) { // With more than one module, there is no way to do offsets for real, so we have to fake it. $limit = $limit + $offset; $offset = 0; } if (!$multiModule) { // It's not multi-module, the per-module limit should be the same as the master limit $searchOptions['limitPerModule'] = $limit; } if (isset($options['custom_select'])) { $searchOptions['custom_select'] = $options['custom_select']; } if (isset($options['custom_from'])) { $searchOptions['custom_from'] = $options['custom_from']; } if (isset($options['custom_where'])) { $searchOptions['custom_where'] = $options['custom_where']; } $results = $searchEngine->search($options['query'], $offset, $limit, $searchOptions); $returnedRecords = array(); $api->action = 'list'; foreach ($results as $module => $moduleResults) { if (!is_array($moduleResults['data'])) { continue; } $moduleArgs = $args; // Need to override the filter arg so that it looks like something formatBean expects if (!empty($options['fieldFilters'][$module])) { $moduleFields = $options['fieldFilters'][$module]; } else { if (!empty($options['fieldFilters']['_default'])) { $moduleFields = $options['fieldFilters']['_default']; } else { $moduleFields = array(); } } $moduleArgs['fields'] = implode(',', $moduleFields); foreach ($moduleResults['data'] as $record) { $formattedRecord = $this->formatBean($api, $moduleArgs, $record); $formattedRecord['_module'] = $module; // The SQL based search engine doesn't know how to score records, so set it to 1 $formattedRecord['_search']['score'] = 1.0; $returnedRecords[] = $formattedRecord; } } if ($multiModule) { // Need to re-sort the results because the DB search engine clumps them together per-module $this->resultSetSortData = $options['orderByArray']; usort($returnedRecords, array($this, 'resultSetSort')); } if ($multiModule && $options['offset'] != 0) { // The merged module mess leaves us in a bit of a pickle with offsets and limits if (count($returnedRecords) > $options['offset'] + $options['limit']) { $nextOffset = $options['offset'] + $options['limit']; } else { $nextOffset = -1; } $returnedRecords = array_slice($returnedRecords, $options['offset'], $options['limit']); } else { // Otherwise, offsets and limits should work. if (count($returnedRecords) > $options['limit']) { $nextOffset = $options['offset'] + $options['limit']; } else { $nextOffset = -1; } $returnedRecords = array_slice($returnedRecords, 0, $options['limit']); } if ($options['offset'] === 'end') { $nextOffset = -1; } return array('next_offset' => $nextOffset, 'records' => $returnedRecords); }
function get_user_module_list($user) { $GLOBALS['log']->info('Begin: SoapHelperWebServices->get_user_module_list'); global $app_list_strings, $current_language; $app_list_strings = return_app_list_strings_language($current_language); $modules = query_module_access_list($user); ACLController::filterModuleList($modules, false); global $modInvisList, $modInvisListActivities; foreach ($modInvisList as $invis) { $modules[$invis] = 'read_only'; } if (isset($modules['Calendar']) || $modules['Activities']) { foreach ($modInvisListActivities as $invis) { $modules[$invis] = $invis; } } $GLOBALS['log']->info('End: SoapHelperWebServices->get_user_module_list'); return $modules; }
function get_user_module_list($user) { global $app_list_strings; $app_list_strings = return_app_list_strings_language($current_language); $modules = query_module_access_list($user); ACLController::filterModuleList($modules, false); global $modInvisList, $modInvisListActivities; foreach ($modInvisList as $invis) { $modules[$invis] = 'read_only'; } if (isset($modules['Calendar']) || $modules['Activities']) { foreach ($modInvisListActivities as $invis) { $modules[$invis] = $invis; } } return $modules; }