/** * Metadata fixes for the RLI Module * * - Removes the file that shows the RLI Module * - Removes the Studio File * - Hides the RLI module from the menu bar * - Removes the ACL Actions */ protected function fixRevenueLineItemModule() { // hide the RLI module from the quick create, this needs to be done first, so it's properly removed $this->toggleRevenueLineItemQuickCreate(false); // cleanup on the current request $GLOBALS['modInvisList'][] = 'RevenueLineItems'; if (isset($GLOBALS['moduleList']) && is_array($GLOBALS['moduleList'])) { foreach ($GLOBALS['moduleList'] as $key => $mod) { if ($mod === 'RevenueLineItems') { unset($GLOBALS['moduleList'][$key]); } } } if (SugarAutoLoader::fileExists($this->appExtFolder . '/Include/' . $this->rliModuleExtFile)) { SugarAutoLoader::unlink($this->appExtFolder . '/Include/' . $this->rliModuleExtFile); } if (SugarAutoLoader::fileExists($this->rliStudioFile)) { SugarAutoLoader::unlink($this->rliStudioFile); } if (SugarAutoLoader::fileExists($this->rliModuleExtFolder . '/Vardefs/' . $this->rliModuleExtVardefFile)) { SugarAutoLoader::unlink($this->rliModuleExtFolder . '/Vardefs/' . $this->rliModuleExtVardefFile); } // hide the RLI module in workflows $affected_modules = $this->toggleRevenueLineItemsLinkInWorkFlows(false); // hide the mega menu tab $this->setRevenueLineItemModuleTab(false); // handle the parent type field $this->setRevenueLineItemInParentRelateDropDown(false); // disable the ACLs on RevenueLineItems ACLAction::removeActions('RevenueLineItems'); // add the RLI module $affected_modules[] = 'RevenueLineItems'; return $affected_modules; }
public static function clearCache() { $file = sugar_cached('modules/unified_search_modules.php'); if (SugarAutoLoader::fileExists($file)) { SugarAutoLoader::unlink($file); } }
public function run() { $path = 'custom/Extension/application/Ext'; $file_name = 'project_unhide.php'; if (version_compare($this->to_version, '7.2.2.0', '=') && SugarAutoLoader::fileExists($path . '/Include/' . $file_name)) { $file_contents = ' <?php // WARNING: The contents of this file are auto-generated. $moduleList[] = \'Project\'; $moduleList[] = \'ProjectTask\'; if (isset($modInvisList) && is_array($modInvisList)) { foreach($modInvisList as $key => $mod) { if($mod == \'Project\' || $mod == \'ProjectTask\') { unset($modInvisList[$key]); } } } '; // enable the project module in the upgrade instance global $moduleList, $modInvisList; $moduleList[] = 'ProjectTask'; foreach ($modInvisList as $key => $mod) { if ($mod == 'Project' || $mod == 'ProjectTask') { unset($modInvisList[$key]); } } sugar_file_put_contents($path . '/Include/' . $file_name, $file_contents); } }
/** * Monitor constructor */ function Monitor($name = '', $monitorId = '', $metadata = '', $store = '') { if (empty($metadata) || !SugarAutoLoader::fileExists($metadata)) { $GLOBALS['log']->error($GLOBALS['app_strings']['ERR_MONITOR_FILE_MISSING'] . "({$metadata})"); throw new Exception($GLOBALS['app_strings']['ERR_MONITOR_FILE_MISSING'] . "({$metadata})"); } $this->name = $name; $this->metricsFile = $metadata; require $this->metricsFile; $fields = $dictionary[$this->name]['fields']; $this->table_name = !empty($dictionary[$this->name]['table']) ? $dictionary[$this->name]['table'] : $this->name; $this->metrics = array(); foreach ($fields as $field) { //We need to skip auto_increment fields; they are not real metrics //since they are generated by the database. if (isset($field['auto_increment'])) { continue; } $type = isset($field['dbType']) ? $field['dbType'] : $field['type']; $name = $field['name']; $this->metrics[$name] = new Metric($type, $name); } $this->monitor_id = $monitorId; $this->stores = $store; if (isset($this->metrics['session_id'])) { //set the value of the session id for 2 reasons: //1) it is the same value no matter where it is set //2) ensure it follows some filter rules. $this->setValue('session_id', $this->getSessionId()); } }
function build() { //we will assume that if the ListView.html file exists we will want to use that one if (SugarAutoLoader::fileExists('modules/' . $this->module . '/ListView.html')) { $this->type = 1; $this->lv = new ListView(); $this->template = 'modules/' . $this->module . '/ListView.html'; } else { $metadataFile = SugarAutoLoader::loadWithMetafiles($this->module, 'listviewdefs'); if ($metadataFile) { require $metadataFile; } SugarACL::listFilter($this->module, $listViewDefs[$this->module], array("owner_override" => true)); $this->lv = new ListViewSmarty(); $displayColumns = array(); if (!empty($_REQUEST['displayColumns'])) { foreach (explode('|', $_REQUEST['displayColumns']) as $num => $col) { if (!empty($listViewDefs[$this->module][$col])) { $displayColumns[$col] = $listViewDefs[$this->module][$col]; } } } else { if (isset($listViewDefs[$this->module])) { foreach ($listViewDefs[$this->module] as $col => $params) { if (!empty($params['default']) && $params['default']) { $displayColumns[$col] = $params; } } } } $this->lv->displayColumns = $displayColumns; $this->type = 2; $this->template = 'include/ListView/ListViewGeneric.tpl'; } }
/** * getQuickSearchDefaults * * This is a static function to get an instance of QuickSearchDefaults object * * @param array $lookup Array with custom files and class names for custom QuickSearchDefaults classes, optional * @return QuickSearchDefaults */ public static function getQuickSearchDefaults(array $lookup = array()) { $lookup['custom/include/QuickSearchDefaults.php'] = 'QuickSearchDefaultsCustom'; foreach ($lookup as $file => $klass) { if (SugarAutoLoader::fileExists($file)) { require_once $file; return new $klass(); } } return new QuickSearchDefaults(); }
function getJavascript() { global $action; if (!ACLController::moduleSupportsACL($this->module)) { return ''; } $script = "<SCRIPT>\n//BEGIN ACL JAVASCRIPT\n"; if ($action == 'DetailView') { if (!ACLController::checkAccess($this->module, 'edit', $this->is_owner)) { $script .= <<<EOQ \t\t\t\t\t\tif(typeof(document.DetailView) != 'undefined'){ \t\t\t\t\t\t\tif(typeof(document.DetailView.elements['Edit']) != 'undefined'){ \t\t\t\t\t\t\t\tdocument.DetailView.elements['Edit'].disabled = 'disabled'; \t\t\t\t\t\t\t} \t\t\t\t\t\t\tif(typeof(document.DetailView.elements['Duplicate']) != 'undefined'){ \t\t\t\t\t\t\t\tdocument.DetailView.elements['Duplicate'].disabled = 'disabled'; \t\t\t\t\t\t\t} \t\t\t\t\t\t} EOQ; } if (!ACLController::checkAccess($this->module, 'delete', $this->is_owner)) { $script .= <<<EOQ \t\t\t\t\t\tif(typeof(document.DetailView) != 'undefined'){ \t\t\t\t\t\t\tif(typeof(document.DetailView.elements['Delete']) != 'undefined'){ \t\t\t\t\t\t\t\tdocument.DetailView.elements['Delete'].disabled = 'disabled'; \t\t\t\t\t\t\t} \t\t\t\t\t\t} EOQ; } } if (SugarAutoLoader::fileExists('modules/' . $this->module . '/metadata/acldefs.php')) { include 'modules/' . $this->module . '/metadata/acldefs.php'; foreach ($acldefs[$this->module]['forms'] as $form_name => $form) { foreach ($form as $field_name => $field) { if ($field['app_action'] == $action) { switch ($form_name) { case 'by_id': $script .= $this->getFieldByIdScript($field_name, $field); break; case 'by_name': $script .= $this->getFieldByNameScript($field_name, $field); break; default: $script .= $this->getFieldByFormScript($form_name, $field_name, $field); break; } } } } } $script .= '</SCRIPT>'; return $script; }
/** * @see SugarView::display() */ public function display() { require_once 'include/connectors/utils/ConnectorUtils.php'; $source = $_REQUEST['source_id']; $sources = ConnectorUtils::getConnectors(); $modules_sources = ConnectorUtils::getDisplayConfig(); $enabled_modules = array(); $disabled_modules = array(); //Find all modules this source has been enabled for foreach ($modules_sources as $module => $mapping) { foreach ($modules_sources[$module] as $entry) { if ($entry == $source) { $enabled_modules[$module] = isset($GLOBALS['app_list_strings']['moduleList'][$module]) ? $GLOBALS['app_list_strings']['moduleList'][$module] : $module; } } } global $moduleList, $beanList; //Do filtering here? $count = 0; global $current_user; $access = $current_user->getDeveloperModules(); foreach (SugarAutoLoader::getDirFiles("modules", true) as $e) { //Strip the 'modules/' portion out from beginning of $e $e = substr($e, 8); if (empty($enabled_modules[$e]) && SugarAutoLoader::existingCustomOne("modules/{$e}/metadata/studio.php") && SugarAutoLoader::fileExists('modules/' . $e . '/metadata/detailviewdefs.php') && isset($GLOBALS['beanList'][$e]) && (in_array($e, $access) || is_admin($current_user))) { $disabled_modules[$e] = isset($GLOBALS['app_list_strings']['moduleList'][$e]) ? $GLOBALS['app_list_strings']['moduleList'][$e] : $e; } } $s = SourceFactory::getSource($source); // Not all sources can be connected to all modules $enabled_modules = $s->filterAllowedModules($enabled_modules); $disabled_modules = $s->filterAllowedModules($disabled_modules); asort($enabled_modules); asort($disabled_modules); //$enabled = $json->encode($enabled_modules); //$disabled = $json->encode($disabled_modules); //$script = "addTable('{$module}', '{$enabled}', '{$disabled}', '{$source}', '{$GLOBALS['theme']}');\n"; //$this->ss->assign('new_modules_sources', $modules_sources); //$this->ss->assign('dynamic_script', $script); $this->ss->assign('enabled_modules', $enabled_modules); $this->ss->assign('disabled_modules', $disabled_modules); $this->ss->assign('source_id', $source); $this->ss->assign('mod', $GLOBALS['mod_strings']); $this->ss->assign('APP', $GLOBALS['app_strings']); $this->ss->assign('theme', $GLOBALS['theme']); $this->ss->assign('external', !empty($sources[$source]['eapm'])); $this->ss->assign('externalOnly', !empty($sources[$source]['eapm']['only'])); // We don't want to tell the user to set the properties of the connector if there aren't any $fields = $s->getRequiredConfigFields(); $this->ss->assign('externalHasProperties', !empty($fields)); $this->ss->assign('externalChecked', !empty($sources[$source]['eapm']['enabled']) ? " checked" : ""); echo $this->ss->fetch($this->getCustomFilePathIfExists('modules/Connectors/tpls/display_properties.tpl')); }
/** * Prepares an instance of SDD for use with a given set * @param string $metadata Path to metadata file to consume */ function init($metadata) { if (is_string($metadata)) { if ($this->debugMode) { $this->debugOutput("Got metadata file [ {$metadata} ]"); } if (SugarAutoLoader::fileExists($metadata)) { $sugarDependentDropdown = array(); /* * The metadata file should be prepped in an associative array. * The array should be named "$sugarDependentDropdown". * * Examine: * "include/SugarDependentDropdown/metadata/dependentDropdown. * php" for a commented example. */ include $metadata; // provides $sugarDependentDropdown foreach ($sugarDependentDropdown as $key => $type) { if (is_array($type)) { foreach ($type as $k => $v) { if ($k == 'elements') { ksort($v); // order elements foreach ($v as $index => $element) { $v[$index] = $this->initElement($element, $type['always_merge']); } } // end Work with elements block $type[$k] = $v; } if (!$this->verifyMetadata($type)) { if ($this->debugMode) { $this->debugOutput("SugarRouting: metadata initialization failed. Please check your metadata source."); } } } $sugarDependentDropdown[$key] = $type; } // end foreach of metadata /* we made it through all checks so assign this to the output attribute */ $this->metadata = $sugarDependentDropdown; } else { if ($this->debugMode) { $this->debugOutput("SugarRouting could not find file [ {$metadata} ]"); } } } // end is_string(); }
/** * Find all modules with Portal metadata * * @return array List of Portal module names */ protected function getModules() { $modules = array(); foreach (SugarAutoLoader::getDirFiles("modules", true) as $mdir) { // strip modules/ from name $mname = substr($mdir, 8); if (SugarAutoLoader::fileExists("{$mdir}/clients/portal/")) { $modules[] = $mname; } } $modules[] = 'Users'; $modules[] = 'Filters'; return $modules; }
/** * DetailView constructor * This is the DetailView constructor responsible for processing the new * Meta-Data framework * * @param $module String value of module this detail view is for * @param $focus An empty sugarbean object of module * @param $id The record id to retrieve and populate data for * @param $metadataFile String value of file location to use in overriding default metadata file * @param tpl String value of file location to use in overriding default Smarty template */ function setup($module, $focus, $metadataFile = null, $tpl = 'include/DetailView/DetailView.tpl') { $this->th = new TemplateHandler(); $this->th->ss = $this->ss; $this->focus = $focus; $this->tpl = $tpl; $this->module = $module; $this->metadataFile = $metadataFile; if (isset($GLOBALS['sugar_config']['disable_vcr'])) { $this->showVCRControl = !$GLOBALS['sugar_config']['disable_vcr']; } if (!empty($this->metadataFile) && SugarAutoLoader::fileExists($this->metadataFile)) { include $this->metadataFile; } $this->defs = $viewdefs[$this->module][$this->view]; }
public function run() { // if we are coming from anything newer than 7, just bail if (version_compare($this->from_version, '7.0.0', '>')) { return; } if (!SugarAutoLoader::fileExists($this->file)) { # if we don't have a custom file, then bail return; } $viewdefs = null; include $this->file; if (!empty($viewdefs)) { $viewdefs = $this->fixFieldName($viewdefs); sugar_file_put_contents($this->file, "<?php\n\n \$viewdefs = " . var_export($viewdefs, true) . ";\n"); } $viewdefs = null; }
/** * This method looks up the helper class for the bean and will provide the default helper * if there is not one defined for that particular bean * * @param $api ServiceBase The API that will be associated to this helper class * This is used so the formatting functions can handle different * API's with varying formatting requirements. * @param $bean SugarBean Grab the helper module for this bean * @returns SugarBeanApiHelper A API helper class for beans */ public static function getHelper(ServiceBase $api, SugarBean $bean) { $module = $bean->module_dir; if (!isset(self::$moduleHelpers[$module])) { require_once 'data/SugarBeanApiHelper.php'; if (SugarAutoLoader::requireWithCustom('modules/' . $module . '/' . $module . 'ApiHelper.php')) { $moduleHelperClass = SugarAutoLoader::customClass($module . 'ApiHelper'); } elseif (SugarAutoLoader::fileExists('custom/data/SugarBeanApiHelper.php')) { require_once 'custom/data/SugarBeanApiHelper.php'; $moduleHelperClass = 'CustomSugarBeanApiHelper'; } else { $moduleHelperClass = 'SugarBeanApiHelper'; } self::$moduleHelpers[$module] = new $moduleHelperClass($api); } $moduleHelperClass = self::$moduleHelpers[$module]; return $moduleHelperClass; }
/** * Action SaveActivity */ protected function action_saveactivity() { $this->view = 'json'; if (!$this->retrieveCurrentBean('Save')) { return; } $module = $this->currentBean->module_dir; $bean = $this->currentBean; $path = "modules/{$bean->module_dir}/{$bean->object_name}FormBase.php"; if (!SugarAutoLoader::fileExists($path)) { $GLOBALS['log']->fatal("File {$bean->object_name}FormBase.php doesn't exist"); sugar_cleanup(true); } require_once $path; $FBObjectName = "{$bean->object_name}FormBase"; if (!class_exists($FBObjectName)) { $GLOBALS['log']->fatal("Class {$bean->object_name}FormBase doesn't exist"); sugar_cleanup(true); } $formBase = new $FBObjectName(); $isRecurring = false; if ($formBase->prepareRecurring()) { if ($limit = $formBase->checkRecurringLimitExceeded()) { $this->view_object_map['jsonData'] = $jsonData = array('access' => 'yes', 'limit_error' => 'true', 'limit' => $limit); return; } $isRecurring = true; } $bean = $formBase->handleSave('', false, false); if ($record = $bean->id) { $bean->retrieve($record); $jsonData = CalendarUtils::getBeanDataArray($bean); if ($isRecurring) { $jsonData = array_merge($jsonData, array('repeat' => $formBase->getRecurringCreated())); } if (!empty($_REQUEST['edit_all_recurrences'])) { $jsonData['edit_all_recurrences'] = 'true'; } } else { $jsonData = array('access' => 'no'); } $this->view_object_map['jsonData'] = $jsonData; }
/** * Runs through the views metadata directory to check for expected portal * files to verify if a given module is a portal module. * * This replaces the old file path checker that looked for * portal/modules/$module/metadata. We are now looking for * modules/$module/metadata/portal/views/(edit|list|detail).php * * @param string $module The module to check portal validity on * @return bool True if a portal/view/$type.php file was found */ function isPortalModule($module) { // If this module isn't studio enabled for portal, don't bother with the // rest of the validation if ($this->isStudioEnabled($module)) { // Create the path to search $path = "modules/{$module}/clients/portal/views/"; // Handle it // Bug 55003 - Notes showing as a portal module because it has non // standard layouts $views = SugarPortalModule::getViewFiles(); $viewFiles = array_keys($views); foreach ($viewFiles as $file) { $fullPath = $path . basename($file, '.php') . '/' . $file; if (SugarAutoLoader::fileExists($fullPath)) { return true; } } } return false; }
/** * loads SearchFields MetaData, sets member variables * * @param string $module moduleDir * @param bean $seedBean seed bean to use * @param string $tpl template to use, defaults to moduleDir/SearchForm.html * */ function SearchForm($module, $seedBean, $tpl = null) { global $app_strings; $this->module = $module; $searchFields = SugarAutoLoader::loadSearchFields($module); $this->searchFields = $searchFields[$module]; if (empty($tpl)) { if (!empty($GLOBALS['layout_edit_mode'])) { $this->tpl = sugar_cached('studio/custom/working/modules/' . $module . '/SearchForm.html'); } else { $this->tpl = get_custom_file_if_exists('modules/' . $module . '/SearchForm.html'); } } else { $this->tpl = $tpl; } $this->bean = $seedBean; $this->tabs = array(array('title' => $app_strings['LNK_BASIC_SEARCH'], 'link' => $module . '|basic_search', 'key' => $module . '|basic_search'), array('title' => $app_strings['LNK_ADVANCED_SEARCH'], 'link' => $module . '|advanced_search', 'key' => $module . '|advanced_search')); if (SugarAutoLoader::fileExists('modules/' . $this->module . '/index.php')) { $this->tabs[] = array('title' => $app_strings['LNK_SAVED_VIEWS'], 'link' => $module . '|saved_views', 'key' => $module . '|saved_views'); } }
function Sugar_Smarty() { if (!file_exists(SUGAR_SMARTY_DIR)) { mkdir_recursive(SUGAR_SMARTY_DIR, true); } if (!file_exists(SUGAR_SMARTY_DIR . 'templates_c')) { mkdir_recursive(SUGAR_SMARTY_DIR . 'templates_c', true); } if (!file_exists(SUGAR_SMARTY_DIR . 'configs')) { mkdir_recursive(SUGAR_SMARTY_DIR . 'configs', true); } if (!file_exists(SUGAR_SMARTY_DIR . 'cache')) { mkdir_recursive(SUGAR_SMARTY_DIR . 'cache', true); } $this->template_dir = '.'; $this->compile_dir = SUGAR_SMARTY_DIR . 'templates_c'; $this->config_dir = SUGAR_SMARTY_DIR . 'configs'; $this->cache_dir = SUGAR_SMARTY_DIR . 'cache'; $this->request_use_auto_globals = true; // to disable Smarty from using long arrays // Smarty will create subdirectories under the compiled templates and cache directories $this->use_sub_dirs = true; if (empty(self::$_plugins_dir)) { self::$_plugins_dir = array(); if (SugarAutoLoader::fileExists('custom/include/SugarSmarty/plugins')) { self::$_plugins_dir[] = 'custom/include/SugarSmarty/plugins'; } if (SugarAutoLoader::fileExists('custom/vendor/Smarty/plugins')) { self::$_plugins_dir[] = 'custom/vendor/Smarty/plugins'; } self::$_plugins_dir[] = 'include/SugarSmarty/plugins'; self::$_plugins_dir[] = 'vendor/Smarty/plugins'; } $this->plugins_dir = self::$_plugins_dir; $this->assign("VERSION_MARK", getVersionedPath('')); }
/** * This method checks to see if the configuration file exists and, if not, creates one by default * */ public function preDisplay() { global $app_strings; //Rebuild config file if it doesn't exist if (!file_exists($this->configFile)) { ModuleInstaller::handleBaseConfig(); } $this->ss->assign("configFile", $this->configFile); $config = ModuleInstaller::getBaseConfig(); $this->ss->assign('configHash', md5(serialize($config))); $sugarSidecarPath = ensureJSCacheFilesExist(); $this->ss->assign("sugarSidecarPath", $sugarSidecarPath); // TODO: come up with a better way to deal with the various JS files // littered in sidecar.tpl. $voodooFile = 'custom/include/javascript/voodoo.js'; if (SugarAutoLoader::fileExists($voodooFile)) { $this->ss->assign('voodooFile', $voodooFile); } //Load sidecar theme css $theme = new SidecarTheme(); $this->ss->assign("css_url", $theme->getCSSURL()); $this->ss->assign("developerMode", inDeveloperMode()); //Loading label $this->ss->assign('LBL_LOADING', $app_strings['LBL_ALERT_TITLE_LOADING']); $this->ss->assign('LBL_ENABLE_JAVASCRIPT', $app_strings['LBL_ENABLE_JAVASCRIPT']); $slFunctionsPath = inDeveloperMode() ? "cache/Expressions/functions_cache_debug.js" : "cache/Expressions/functions_cache.js"; if (!is_file($slFunctionsPath)) { $GLOBALS['updateSilent'] = true; include "include/Expressions/updatecache.php"; } $this->ss->assign("SLFunctionsPath", $slFunctionsPath); if (!empty($this->authorization)) { $this->ss->assign('appPrefix', $config['env'] . ":" . $config['appId'] . ":"); $this->ss->assign('authorization', $this->authorization); } }
/** * Get Sugar REST class name for input/return type * * @param string $name * @return string */ protected function _getTypeName($name) { if (empty($name)) { return 'SugarRest'; } $name = clean_string($name, 'ALPHANUM'); $type = ''; switch (strtolower($name)) { case 'json': $type = 'JSON'; break; case 'rss': $type = 'RSS'; break; case 'serialize': $type = 'Serialize'; break; } $classname = "SugarRest{$type}"; if (!SugarAutoLoader::fileExists('service/core/REST/' . $classname . '.php')) { return 'SugarRest'; } return $classname; }
/** * Creates the RestService object and reads in the metadata for the API */ public function __construct() { $apiSettings = array(); require 'include/api/metadata.php'; if (SugarAutoLoader::fileExists('custom/include/api/metadata.php')) { // Don't use requireWithCustom because we need the data out of it require 'custom/include/api/metadata.php'; } $this->min_version = $apiSettings['minVersion']; $this->max_version = $apiSettings['maxVersion']; $this->api_settings = $apiSettings; }
public function run() { if (SugarAutoLoader::fileExists('modules/Charts/Dashlets/MyForecastingChartDashlet/MyForecastingChartDashlet.php')) { $this->fileToDelete('modules/Charts/Dashlets/MyForecastingChartDashlet'); } }
function getDashlets($category = '') { global $app_strings, $current_language, $mod_strings; require_once $GLOBALS['sugar_config']['cache_dir'] . 'dashlets/dashlets.php'; $categories = array('module' => 'Module Views', 'portal' => 'Portal', 'charts' => 'Charts', 'tools' => 'Tools', 'misc' => 'Miscellaneous', 'web' => 'Web'); $dashletStrings = array(); $dashletsList = array(); if (!empty($category)) { $dashletsList[$categories[$category]] = array(); } else { $dashletsList['Module Views'] = array(); $dashletsList['Charts'] = array(); $dashletsList['Tools'] = array(); $dashletsList['Web'] = array(); } asort($dashletsFiles); foreach ($dashletsFiles as $className => $files) { if (!empty($files['meta']) && SugarAutoLoader::fileExists($files['meta'])) { require_once $files['meta']; // get meta file $directory = substr($files['meta'], 0, strrpos($files['meta'], '/') + 1); foreach (SugarAutoLoader::existing($directory . $files['class'] . '.' . $current_language . '.lang.php', $directory . $files['class'] . '.en_us.lang.php') as $file) { require $file; } // try to translate the string if (empty($dashletStrings[$files['class']][$dashletMeta[$files['class']]['title']])) { $title = $dashletMeta[$files['class']]['title']; } else { $title = $dashletStrings[$files['class']][$dashletMeta[$files['class']]['title']]; } // try to translate the string if (empty($dashletStrings[$files['class']][$dashletMeta[$files['class']]['description']])) { $description = $dashletMeta[$files['class']]['description']; } else { $description = $dashletStrings[$files['class']][$dashletMeta[$files['class']]['description']]; } // generate icon if (!empty($dashletMeta[$files['class']]['icon'])) { // here we'll support image inheritance if the supplied image has a path in it // i.e. $dashletMeta[$files['class']]['icon'] = 'themes/default/images/dog.gif' // in this case, we'll strip off the path information to check for the image existing // in the current theme. $imageName = SugarThemeRegistry::current()->getImageURL(basename($dashletMeta[$files['class']]['icon']), false); if (!empty($imageName)) { if (sugar_is_file($imageName)) { $icon = '<img src="' . $imageName . '" alt="" border="0" align="absmiddle" />'; } else { $icon = ''; } } } else { if (empty($dashletMeta[$files['class']]['module'])) { $icon = get_dashlets_dialog_icon('default'); } else { if (!in_array($dashletMeta[$files['class']]['module'], $GLOBALS['moduleList']) && !in_array($dashletMeta[$files['class']]['module'], $GLOBALS['modInvisList']) && !in_array('Activities', $GLOBALS['moduleList'])) { unset($dashletMeta[$files['class']]); continue; } else { $icon = get_dashlets_dialog_icon($dashletMeta[$files['class']]['module']); } } } // determine whether to display if (!empty($dashletMeta[$files['class']]['hidden']) && $dashletMeta[$files['class']]['hidden'] === true) { $displayDashlet = false; } elseif (!empty($dashletMeta[$files['class']]['module']) && (!in_array($dashletMeta[$files['class']]['module'], $GLOBALS['moduleList']) && !in_array($dashletMeta[$files['class']]['module'], $GLOBALS['modInvisList'])) && !in_array('Activities', $GLOBALS['moduleList'])) { $displayDashlet = false; } else { $displayDashlet = true; //check ACL ACCESS if (!empty($dashletMeta[$files['class']]['module'])) { if (!SugarACL::checkAccess($dashletMeta[$files['class']]['module'], 'view', array('owner_override' => true))) { $displayDashlet = false; } if (!SugarACL::checkAccess($dashletMeta[$files['class']]['module'], 'list', array('owner_override' => true))) { $displayDashlet = false; } } } if ($dashletMeta[$files['class']]['category'] == 'Charts') { $type = 'predefined_chart'; } else { $type = 'module'; } if ($displayDashlet && isset($dashletMeta[$files['class']]['dynamic_hide']) && $dashletMeta[$files['class']]['dynamic_hide']) { if (SugarAutoLoader::fileExists($files['file'])) { require_once $files['file']; if (class_exists($files['class'])) { $dashletClassName = $files['class']; $displayDashlet = call_user_func(array($files['class'], 'shouldDisplay')); } } } if ($displayDashlet) { $cell = array('title' => $title, 'description' => $description, 'onclick' => 'return SUGAR.mySugar.addDashlet(\'' . $className . '\', \'' . $type . '\', \'' . (!empty($dashletMeta[$files['class']]['module']) ? $dashletMeta[$files['class']]['module'] : '') . '\');', 'icon' => $icon, 'id' => $files['class'] . '_select'); if (!empty($category) && $dashletMeta[$files['class']]['category'] == $categories[$category]) { array_push($dashletsList[$categories[$category]], $cell); } else { if (empty($category)) { array_push($dashletsList[$dashletMeta[$files['class']]['category']], $cell); } } } } } if (!empty($category)) { asort($dashletsList[$categories[$category]]); } else { foreach ($dashletsList as $key => $value) { asort($dashletsList[$key]); } } $this->dashlets = $dashletsList; }
/** * Returns filter definition for the given dropdown field exactly as it's stored in metadata files, or empty array * in case if the definition is not found * * @param string $fieldName Dropdown field name * @param string $role Role ID * @return array */ protected function getRawFilter($fieldName, $role) { $path = 'custom/application/Ext/DropdownFilters/roles/' . $role . '/dropdownfilters.ext.php'; if (SugarAutoLoader::fileExists($path)) { $filters = $this->readDropdownFilterFile($path); if (isset($filters[$fieldName])) { return $filters[$fieldName]; } } return array(); }
public function action_updatewirelessenabledmodules() { require_once 'modules/Administration/Forms.php'; global $app_strings, $current_user, $moduleList; if (!is_admin($current_user)) { sugar_die($app_strings['ERR_NOT_ADMIN']); } require_once 'modules/Configurator/Configurator.php'; $configurator = new Configurator(); $configurator->saveConfig(); if (isset($_REQUEST['enabled_modules']) && !empty($_REQUEST['enabled_modules'])) { $updated_enabled_modules = array(); $wireless_module_registry = array(); $file = 'include/MVC/Controller/wireless_module_registry.php'; if (SugarAutoLoader::fileExists($file)) { require $file; } foreach (explode(',', $_REQUEST['enabled_modules']) as $moduleName) { $moduleDef = array_key_exists($moduleName, $wireless_module_registry) ? $wireless_module_registry[$moduleName] : array(); $updated_enabled_modules[$moduleName] = $moduleDef; } $filename = create_custom_directory('include/MVC/Controller/wireless_module_registry.php'); mkdir_recursive(dirname($filename)); write_array_to_file('wireless_module_registry', $updated_enabled_modules, $filename); foreach ($moduleList as $mod) { sugar_cache_clear("CONTROLLER_wireless_module_registry_{$mod}"); } //Users doesn't appear in the normal module list, but its value is cached on login. sugar_cache_clear("CONTROLLER_wireless_module_registry_Users"); sugar_cache_reset(); // Bug 59121 - Clear the metadata cache for the mobile platform MetaDataManager::refreshCache(array('mobile')); } echo "true"; }
/** * Check path with all extensions * @param string $imageName * @return string Existing image name or '' */ protected function checkAllExts($imageName) { if (SugarAutoLoader::fileExists($imageName)) { return $imageName; } $pathParts = pathinfo($imageName); if (!isset($pathParts['extension'])) { return ''; } foreach ($this->imageExtensions as $extension) { if ($pathParts['extension'] == $extension) { continue; } $imageName = $pathParts['dirname'] . '/' . $pathParts['filename'] . '.' . $extension; if (SugarAutoLoader::fileExists($imageName)) { return $imageName; } } return ''; }
function generateSearchWhere($module, $query) { //this function is similar with function prepareSearchForm() in view.list.php $seed = BeanFactory::newBean($module); if (SugarAutoLoader::fileExists('modules/' . $module . '/SearchForm.html')) { if (SugarAutoLoader::fileExists('modules/' . $module . '/metadata/SearchFields.php')) { require_once 'include/SearchForm/SearchForm.php'; $searchForm = new SearchForm($module, $seed); } elseif (!empty($_SESSION['export_where'])) { //bug 26026, sometimes some module doesn't have a metadata/SearchFields.php, the searchfrom is generated in the ListView.php. // Currently, massupdate will not generate the where sql. It will use the sql stored in the SESSION. But this will cause bug 24722, and it cannot be avoided now. $where = $_SESSION['export_where']; $whereArr = explode(" ", trim($where)); if ($whereArr[0] == trim('where')) { $whereClean = array_shift($whereArr); } $where = implode(" ", $whereArr); //rrs bug: 31329 - previously this was just returning $where, but the problem is the caller of this function //expects the results in an array, not just a string. So rather than fixing the caller, I felt it would be best for //the function to return the results in a standard format. $ret_array['where'] = $where; $ret_array['searchFields'] = array(); return $ret_array; } else { return; } } else { require_once 'include/SearchForm/SearchForm2.php'; $searchdefs_file = SugarAutoLoader::loadWithMetafiles($module, 'searchdefs'); if ($searchdefs_file) { require $searchdefs_file; } $searchFields = SugarAutoLoader::loadSearchFields($module); if (empty($searchdefs) || empty($searchFields)) { //for some modules, such as iframe, it has massupdate, but it doesn't have search function, the where sql should be empty. return; } $searchForm = getSearchForm($seed, $module); $searchForm->setup($searchdefs, $searchFields, 'SearchFormGeneric.tpl'); } $searchForm->populateFromArray(unserialize(base64_decode($query))); $where_clauses = $searchForm->generateSearchWhere(true, $module); if (count($where_clauses) > 0) { $where = '(' . implode(' ) AND ( ', $where_clauses) . ')'; } $GLOBALS['log']->info("Export Where Clause: {$where}"); $ret_array['where'] = $where; $ret_array['searchFields'] = $searchForm->searchFields; return $ret_array; }
function display_label($focus, $field) { global $dictionary; if (!SugarAutoLoader::fileExists('modules/' . $focus->module_dir . '/' . $focus->object_name . '.php')) { return $field; } $var_name = $dictionary[$focus->object_name]['fields'][$field]['vname']; $current_module_strings = return_module_language($current_language, $focus->object_name); if (!empty($current_module_strings[$var_name])) { return $current_module_strings[$var_name]; } else { return $field; } //end function display_label }
/** * This function is designed to cache references to field arrays that were previously stored in the * bean files and have since been moved to separate files. Was previously in include/CacheHandler.php * * @deprecated * @param $module_dir string the module directory * @param $module string the name of the module * @param $key string the type of field array we are referencing, i.e. list_fields, column_fields, required_fields **/ private function _loadCachedArray($module_dir, $module, $key) { static $moduleDefs = array(); $fileName = 'field_arrays.php'; $cache_key = "load_cached_array.{$module_dir}.{$module}.{$key}"; $result = sugar_cache_retrieve($cache_key); if (!empty($result)) { // Use SugarCache::EXTERNAL_CACHE_NULL_VALUE to store null values in the cache. if ($result == SugarCache::EXTERNAL_CACHE_NULL_VALUE) { return null; } return $result; } if (SugarAutoLoader::fileExists('modules/' . $module_dir . '/' . $fileName)) { // If the data was not loaded, try loading again.... if (!isset($moduleDefs[$module])) { include 'modules/' . $module_dir . '/' . $fileName; $moduleDefs[$module] = $fields_array; } // Now that we have tried loading, make sure it was loaded if (empty($moduleDefs[$module]) || empty($moduleDefs[$module][$module][$key])) { // It was not loaded.... Fail. Cache null to prevent future repeats of this calculation sugar_cache_put($cache_key, SugarCache::EXTERNAL_CACHE_NULL_VALUE); return null; } // It has been loaded, cache the result. sugar_cache_put($cache_key, $moduleDefs[$module][$module][$key]); return $moduleDefs[$module][$module][$key]; } // It was not loaded.... Fail. Cache null to prevent future repeats of this calculation sugar_cache_put($cache_key, SugarCache::EXTERNAL_CACHE_NULL_VALUE); return null; }
/** * Determines if the theme exists * * @return bool True if able to retrieve theme definition file in the file system. */ public function isDefined() { // We compile expected theme by if we found variables.php in the file system (in /custom/themes or /themes) $customThemeVars = $this->paths['custom'] . 'variables.php'; $baseThemeVars = $this->paths['base'] . 'variables.php'; return SugarAutoLoader::fileExists($customThemeVars) || SugarAutoLoader::fileExists($baseThemeVars); }
<?php if (!defined('sugarEntry') || !sugarEntry) { die('Not A Valid Entry Point'); } /* * Your installation or use of this SugarCRM file is subject to the applicable * terms available at * http://support.sugarcrm.com/06_Customer_Center/10_Master_Subscription_Agreements/. * If you do not agree to all of the applicable terms or do not have the * authority to bind the entity as an authorized representative, then do not * install or use this SugarCRM file. * * Copyright (C) SugarCRM Inc. All rights reserved. */ $defaultDashlets = array('MyCallsDashlet' => 'Calls', 'MyMeetingsDashlet' => 'Meetings', 'MyOpportunitiesDashlet' => 'Opportunities', 'MyAccountsDashlet' => 'Accounts', 'MyLeadsDashlet' => 'Leads'); $defaultSalesChartDashlets = array(translate('DEFAULT_REPORT_TITLE_6', 'Reports') => 'Opportunities'); $defaultSalesDashlets = array('MyPipelineBySalesStageDashlet' => 'Opportunities', 'MyOpportunitiesGaugeDashlet' => 'Opportunities', 'MyOpportunitiesDashlet' => 'Opportunities', 'MyClosedOpportunitiesDashlet' => 'Opportunities'); //Split up because of default ordering (35430) $defaultSalesDashlets2 = array('MyForecastingChartDashlet' => 'Forecasts'); $defaultMarketingChartDashlets = array(translate('DEFAULT_REPORT_TITLE_18', 'Reports') => 'Leads'); $defaultMarketingDashlets = array('CampaignROIChartDashlet' => 'Campaigns', 'MyLeadsDashlet' => 'Leads', 'TopCampaignsDashlet' => 'Campaigns'); $defaultSupportDashlets = array('MyCasesDashlet' => 'Cases', 'MyBugsDashlet' => 'Bugs'); $defaultSupportChartDashlets = array(translate('DEFAULT_REPORT_TITLE_7', 'Reports') => 'Cases', translate('DEFAULT_REPORT_TITLE_8', 'Reports') => 'Cases'); $defaultTrackingDashlets = array('TrackerDashlet' => 'Trackers', 'MyModulesUsedChartDashlet' => 'Trackers', 'MyTeamModulesUsedChartDashlet' => 'Trackers'); $defaultTrackingReportDashlets = array(translate('DEFAULT_REPORT_TITLE_27', 'Reports') => 'Trackers'); if (SugarAutoLoader::fileExists('custom/modules/Home/dashlets.php')) { include_once 'custom/modules/Home/dashlets.php'; }