public function configSave(ServiceBase $api, $args)
 {
     $module = 'dm_Duplicates';
     unset($args['__sugar_url']);
     //acl check, only allow if they are module admin
     if (!$api->user->isAdmin() && !$api->user->isDeveloperForModule($module)) {
         // No create access so we construct an error message and throw the exception
         $failed_module_strings = return_module_language($GLOBALS['current_language'], $module);
         $moduleName = $failed_module_strings['LBL_MODULE_NAME'];
         $args = null;
         if (!empty($moduleName)) {
             $args = array('moduleName' => $moduleName);
         }
         throw new SugarApiExceptionNotAuthorized($GLOBALS['app_strings']['EXCEPTION_CHANGE_MODULE_CONFIG_NOT_AUTHORIZED'], $args);
     }
     $admin = BeanFactory::getBean('Administration');
     $platform = 'base';
     foreach ($args as $name => $value) {
         if (is_array($value)) {
             $admin->saveSetting($module, $name, json_encode($value), $platform);
         } else {
             $admin->saveSetting($module, $name, $value, $platform);
         }
     }
     if ($this->skipMetadataRefresh === false) {
         MetaDataManager::refreshModulesCache(array($module));
     }
     return $admin->getConfigForModule($module, $platform, true);
 }
 public function run()
 {
     // somehow we missed quick create configuration on upgrade. here we update it too.
     if (version_compare($this->from_version, '7.6', '<') && is_file('custom/include/DashletContainer/Containers/DCActions.php')) {
         require_once 'modules/Administration/views/view.configureshortcutbar.php';
         $quickCreate = new ViewConfigureshortcutbar();
         $modules = $quickCreate->getQuickCreateModules();
         $needToUpdate = true;
         foreach (array_merge($modules['enabled'], $modules['disabled']) as $module => $definition) {
             // it means that someone already configured that so we don't need to do anything.
             if (is_file("custom/modules/{$module}/clients/base/menus/quickcreate/quickcreate.php")) {
                 $needToUpdate = false;
                 break;
             }
         }
         if ($needToUpdate) {
             $DCActions = array();
             require 'custom/include/DashletContainer/Containers/DCActions.php';
             $DCActions = array_flip($DCActions);
             $successful = $quickCreate->saveChangesToQuickCreateMetadata($modules['enabled'], $modules['disabled'], $DCActions);
             if ($successful) {
                 MetaDataManager::refreshSectionCache(array(MetaDataManager::MM_MODULES));
             }
         }
     }
     // Only run when coming from a version lower than 7.2.
     if (version_compare($this->from_version, '7.2', '<')) {
         $this->fixQuickCreateOrder();
     }
     // Only run when coming from a version lower than 7.6.
     if (version_compare($this->from_version, '7.6', '<')) {
         $this->addStickyResizableColumnsFlag('recordlist');
         $this->addStickyResizableColumnsFlag('history-summary');
     }
 }
Esempio n. 3
0
 /**
  * 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'];
 }
Esempio n. 4
0
 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');
 }
Esempio n. 5
0
 /**
  * This function allows a user with Forecasts admin rights to reset the Forecasts settings so that the Forecasts wizard
  * dialog will appear once again.
  *
  */
 public function action_resetSettings()
 {
     global $current_user;
     if ($current_user->isAdminForModule('Forecasts')) {
         $db = DBManagerFactory::getInstance();
         $db->query("UPDATE config SET value = '0' WHERE category = 'Forecasts' and name in ('is_setup', 'has_commits')");
         MetaDataManager::refreshModulesCache(array('Forecasts'));
         MetaDataManager::refreshSectionCache(array(MetaDataManager::MM_CONFIG));
         echo '<script>' . navigateToSidecar(buildSidecarRoute("Forecasts")) . ';</script>';
         exit;
     }
     $this->view = 'noaccess';
 }
Esempio n. 6
0
 function __construct()
 {
     parent::SugarView();
     global $current_user;
     if (!$current_user->isDeveloperForModule("Leads")) {
         die("Unauthorized Access to Administration");
     }
     $this->jsonHelper = getJSONobj();
     $this->parser = new ConvertLayoutMetadataParser("Contacts");
     if (isset($_REQUEST['updateConvertDef']) && $_REQUEST['updateConvertDef'] && !empty($_REQUEST['data'])) {
         $this->parser->updateConvertDef(object_to_array_recursive($this->jsonHelper->decode(html_entity_decode_utf8($_REQUEST['data']))));
         // clear the cache for this module only
         MetaDataManager::refreshModulesCache(array('Leads'));
     }
 }
 /**
  * Saves $data to the $name dropdown for the $role name
  *
  * @param $fieldName
  * @param $role
  * @param $data
  * @return boolean
  */
 public function handleSave($fieldName, $role, $data)
 {
     $path = $this->getFilePath($fieldName, $role);
     $dir = dirname($path);
     if (!SugarAutoLoader::ensureDir($dir)) {
         $GLOBALS['log']->error("ParserRoleDropDownFilter :: Cannot create directory {$dir}");
         return false;
     }
     $result = write_array_to_file("role_dropdown_filters['{$fieldName}']", $this->convertFormData($data), $path);
     if ($result) {
         $this->rebuildExtension($role);
         MetaDataManager::refreshSectionCache(MetaDataManager::MM_EDITDDFILTERS, array(), array('role' => $role));
     }
     return $result;
 }
Esempio n. 8
0
 function save($df)
 {
     // Bug 58560 - Set the group name since addresses are part of a group
     $this->group = $df->getDBName($this->name);
     require_once 'modules/ModuleBuilder/parsers/parser.label.php';
     $parser = new ParserLabel($df->getModuleName(), $df->getPackageName());
     // Clean up the labels so they more accurately reflect the actual field
     if (!empty($this->label_value)) {
         $labelValue = $this->label_value;
     } else {
         $labelValue = empty($_REQUEST['labelValue']) ? '' : $_REQUEST['labelValue'];
     }
     // If there is a label to use, space it here for use below
     if (!empty($labelValue)) {
         $labelValue .= ' ';
     }
     // To prevent mutilple calls to the metadata api cache rebuilder, queue
     MetaDataManager::enableCacheRefreshQueue();
     // To keep consistency with OOTB address groups, add Street to the fields
     foreach (array('Street', 'City', 'State', 'PostalCode', 'Country') as $addressFieldName) {
         $systemLabel = strtoupper("LBL_" . $this->name . '_' . $addressFieldName);
         // Use the entered label value as a prefix instead of the field name
         $parser->handleSave(array("label_" . $systemLabel => $labelValue . $addressFieldName), $GLOBALS['current_language']);
         if ($addressFieldName === 'Street') {
             $addressField = new TemplateAddressStreet();
             $addressField->len = 150;
         } else {
             $addressField = new TemplateField();
             $addressField->len = $addressFieldName === 'PostalCode' ? 20 : 100;
         }
         $addressField->name = $this->name . '_' . strtolower($addressFieldName);
         $addressField->label = $addressField->vname = $systemLabel;
         // Bug 58560 - Add the group to this field so it gets written to the custom vardefs
         $addressField->group = $this->group;
         // Maintain unified search setting for 'Street'
         $addressField->supports_unified_search = $addressField == 'Street';
         $addressField->save($df);
     }
     // Handle the metadata api update now
     MetaDataManager::runCacheRefreshQueue();
 }
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     require_once "include/JSON.php";
     $json = new JSON();
     global $mod_strings;
     $title = getClassicModuleTitle("Administration", array("<a href='index.php?module=Administration&action=index'>{$mod_strings['LBL_MODULE_NAME']}</a>", translate('LBL_CONFIGURE_SHORTCUT_BAR')), false);
     $msg = "";
     $GLOBALS['log']->info("Administration ConfigureShortcutBar view");
     $quickCreateModules = $this->getQuickCreateModules();
     //If save is set, save then let the user know if the save worked.
     if (!empty($_REQUEST['enabled_modules'])) {
         $toDecode = html_entity_decode($_REQUEST['enabled_modules'], ENT_QUOTES);
         // get the enabled
         $enabledModules = array_flip(json_decode($toDecode));
         $successful = $this->saveChangesToQuickCreateMetadata($quickCreateModules['enabled'], $quickCreateModules['disabled'], $enabledModules);
         if ($successful) {
             MetaDataManager::refreshSectionCache(array(MetaDataManager::MM_MODULES));
             echo "true";
         } else {
             echo translate("LBL_SAVE_FAILED");
         }
     } else {
         $enabled = $this->sortEnabledModules($quickCreateModules['enabled']);
         $enabled = $this->filterAndFormatModuleList($enabled);
         ksort($quickCreateModules['disabled']);
         $disabled = $this->filterAndFormatModuleList($quickCreateModules['disabled']);
         $this->ss->assign('APP', $GLOBALS['app_strings']);
         $this->ss->assign('MOD', $GLOBALS['mod_strings']);
         $this->ss->assign('title', $title);
         $this->ss->assign('enabled_modules', $json->encode($enabled));
         $this->ss->assign('disabled_modules', $json->encode($disabled));
         $this->ss->assign('description', translate("LBL_CONFIGURE_SHORTCUT_BAR"));
         $this->ss->assign('msg', $msg);
         $returnModule = !empty($_REQUEST['return_module']) ? $_REQUEST['return_module'] : 'Administration';
         $returnAction = !empty($_REQUEST['return_action']) ? $_REQUEST['return_action'] : 'index';
         $this->ss->assign('RETURN_MODULE', $returnModule);
         $this->ss->assign('RETURN_ACTION', $returnAction);
         echo $this->ss->fetch('modules/Administration/templates/ShortcutBar.tpl');
     }
 }
Esempio n. 10
0
 /**
  * Save the Individual Worksheet
  *
  * @return ForecastWorksheet
  * @throws SugarApiException
  */
 public function save()
 {
     require_once 'include/SugarFields/SugarFieldHandler.php';
     /* @var $seed ForecastWorksheet */
     $seed = BeanFactory::getBean("ForecastWorksheets");
     $seed->loadFromRow($this->args);
     $sfh = new SugarFieldHandler();
     foreach ($seed->field_defs as $properties) {
         $fieldName = $properties['name'];
         if (!isset($this->args[$fieldName])) {
             continue;
         }
         if (!$seed->ACLFieldAccess($fieldName, 'save')) {
             // No write access to this field, but they tried to edit it
             global $app_strings;
             throw new SugarApiException(string_format($app_strings['SUGAR_API_EXCEPTION_NOT_AUTHORIZED'], array($fieldName, $this->args['module'])));
         }
         $type = !empty($properties['custom_type']) ? $properties['custom_type'] : $properties['type'];
         $field = $sfh->getSugarField($type);
         if (!is_null($field)) {
             $field->save($seed, $this->args, $fieldName, $properties);
         }
     }
     // Check if this is the first commit, then save has_commits true to the config table
     $admin = BeanFactory::getBean('Administration');
     $settings = $admin->getConfigForModule('Forecasts');
     if (!isset($settings['has_commits']) || !$settings['has_commits']) {
         $admin->saveSetting('Forecasts', 'has_commits', true, 'base');
         MetaDataManager::refreshModulesCache(array('Forecasts'));
     }
     $seed->setWorksheetArgs($this->args);
     // we need to set the parent_type and parent_id so it finds it when we try and retrieve the old records
     $seed->parent_type = $this->getArg('parent_type');
     $seed->parent_id = $this->getArg('parent_id');
     $seed->saveWorksheet();
     // we have the id, just retrieve the record again
     $seed = BeanFactory::getBean("ForecastWorksheets", $this->getArg('record'));
     return $seed;
 }
 function build()
 {
     $modulesToBuild = array();
     if (!isset($this->relationships[$this->newRelationshipName])) {
         $GLOBALS['log']->fatal("Could not find a relationship by the name of {$this->newRelationshipName}, you will have to quick repair and rebuild to get the new relationship added.");
     } else {
         $newRel = $this->relationships[$this->newRelationshipName];
         $newRelDef = $newRel->getDefinition();
         $modulesToBuild[$newRelDef['rhs_module']] = true;
         $modulesToBuild[$newRelDef['lhs_module']] = true;
     }
     $basepath = "custom/Extension/modules";
     $this->activitiesToAdd = false;
     // and mark all as built so that the next time we come through we'll know and won't build again
     foreach ($this->relationships as $name => $relationship) {
         if ($relationship->readonly()) {
             continue;
         }
         $definition = $relationship->getDefinition();
         // activities will always appear on the rhs only - lhs will be always be this module in MB
         if (strtolower($definition['rhs_module']) == 'activities') {
             $this->activitiesToAdd = true;
             $relationshipName = $definition['relationship_name'];
             foreach (self::$activities as $activitiesSubModuleLower => $activitiesSubModuleName) {
                 $definition['rhs_module'] = $activitiesSubModuleName;
                 $definition['for_activities'] = true;
                 $definition['relationship_name'] = $relationshipName . '_' . $activitiesSubModuleLower;
                 $this->relationships[$definition['relationship_name']] = RelationshipFactory::newRelationship($definition);
             }
             unset($this->relationships[$name]);
         }
     }
     $GLOBALS['log']->info(get_class($this) . "->build(): installing relationships");
     $MBModStrings = $GLOBALS['mod_strings'];
     $adminModStrings = return_module_language('', 'Administration');
     // required by ModuleInstaller
     foreach ($this->relationships as $name => $relationship) {
         if ($relationship->readonly()) {
             continue;
         }
         $relationship->setFromStudio();
         $GLOBALS['mod_strings'] = $MBModStrings;
         $installDefs = parent::build($basepath, "<basepath>", array($name => $relationship));
         // and mark as built so that the next time we come through we'll know and won't build again
         $relationship->setReadonly();
         $this->relationships[$name] = $relationship;
         // now install the relationship - ModuleInstaller normally only does this as part of a package load where it installs the relationships defined in the manifest. However, we don't have a manifest or a package, so...
         // If we were to chose to just use the Extension mechanism, without using the ModuleInstaller install_...() methods, we must :
         // 1)   place the information for each side of the relationship in the appropriate Ext directory for the module, which means specific $this->save...() methods for DeployedRelationships, and
         // 2)   we must also manually add the relationship into the custom/application/Ext/TableDictionary/tabledictionary.ext.php file as install_relationship doesn't handle that (install_relationships which requires the manifest however does)
         //      Relationships must be in tabledictionary.ext.php for the Admin command Rebuild Relationships to reliably work:
         //      Rebuild Relationships looks for relationships in the modules vardefs.php, in custom/modules/<modulename>/Ext/vardefs/vardefs.ext.php, and in modules/TableDictionary.php and custom/application/Ext/TableDictionary/tabledictionary.ext.php
         //      if the relationship is not defined in one of those four places it could be deleted during a rebuilt, or during a module installation (when RebuildRelationships.php deletes all entries in the Relationships table)
         // So instead of doing this, we use common save...() methods between DeployedRelationships and UndeployedRelationships that will produce installDefs,
         // and rather than building a full manifest file to carry them, we manually add these installDefs to the ModuleInstaller, and then
         // individually call the appropriate ModuleInstaller->install_...() methods to take our relationship out of our staging area and expand it out to the individual module Ext areas
         $GLOBALS['mod_strings'] = $adminModStrings;
         require_once 'ModuleInstall/ModuleInstaller.php';
         $mi = new ModuleInstaller();
         $mi->id_name = 'custom' . $name;
         // provide the moduleinstaller with a unique name for this relationship - normally this value is set to the package key...
         $mi->installdefs = $installDefs;
         $mi->base_dir = $basepath;
         $mi->silent = true;
         VardefManager::clearVardef();
         $mi->install_relationships();
         $mi->install_languages();
         $mi->install_vardefs();
         $mi->install_layoutdefs();
         $mi->install_extensions();
         $mi->install_client_files();
     }
     $GLOBALS['mod_strings'] = $MBModStrings;
     // finally, restore the ModuleBuilder mod_strings
     // Anything that runs in-process needs to reload their vardefs
     $GLOBALS['reload_vardefs'] = true;
     // save out the updated definitions so that we keep track of the change in built status
     // sending false so we don't rebuild relationshsips for a third time.
     $this->save(false);
     $mi = new ModuleInstaller();
     $mi->silent = true;
     $mi->rebuild_relationships($modulesToBuild);
     // now clear all caches so that our changes are visible
     require_once 'modules/Administration/QuickRepairAndRebuild.php';
     $rac = new RepairAndClear();
     $rac->module_list = $modulesToBuild;
     $rac->clearJsFiles();
     $rac->clearVardefs();
     $rac->clearJsLangFiles();
     $rac->clearLanguageCache();
     $rac->rebuildExtensions(array_keys($modulesToBuild));
     $rac->clearVardefs();
     foreach ($rac->module_list as $moduleName => $ignore) {
         // Now rebuild the vardefs in memory
         $bean = BeanFactory::newBean($moduleName);
         VardefManager::loadVardef($bean->module_dir, $bean->object_name, true, array('bean' => $bean));
     }
     foreach (array_keys($modulesToBuild) as $module) {
         unset($GLOBALS['dictionary'][BeanFactory::getObjectName($module)]);
     }
     SugarRelationshipFactory::rebuildCache();
     MetaDataManager::refreshLanguagesCache(array($GLOBALS['current_language']));
     MetaDataManager::refreshSectionCache(array(MetaDataManager::MM_RELATIONSHIPS));
     MetaDataManager::refreshModulesCache(array_keys($modulesToBuild));
     $GLOBALS['log']->info(get_class($this) . "->build(): finished relationship installation");
 }
Esempio n. 12
0
 function uninstall($base_dir)
 {
     global $app_strings;
     $total_steps = 5;
     //min steps with no tasks
     $current_step = 0;
     $this->base_dir = $base_dir;
     $tasks = array('pre_uninstall', 'uninstall_relationships', 'uninstall_copy', 'uninstall_dcactions', 'uninstall_dashlets', 'uninstall_connectors', 'uninstall_layoutfields', 'uninstall_extensions', 'uninstall_global_search', 'uninstall_filters', 'disable_manifest_logichooks', 'post_uninstall');
     $total_steps += count($tasks);
     //now the real number of steps
     if (file_exists($this->base_dir . '/manifest.php')) {
         if (!$this->silent) {
             $current_step++;
             display_progress_bar('install', $current_step, $total_steps);
             echo '<div id ="displayLoglink" ><a href="#" onclick="toggleDisplay(\'displayLog\')">' . $app_strings['LBL_DISPLAY_LOG'] . '</a> </div><div id="displayLog" style="display:none">';
         }
         global $moduleList;
         $data = $this->readManifest();
         extract($data);
         $this->installdefs = $installdefs;
         $this->id_name = $this->installdefs['id'];
         $installed_modules = array();
         if (isset($this->installdefs['beans'])) {
             foreach ($this->installdefs['beans'] as $bean) {
                 $installed_modules[] = $bean['module'];
                 $this->uninstall_user_prefs($bean['module']);
             }
             $this->modulesInPackage = $installed_modules;
             $this->uninstall_beans($installed_modules);
             $this->uninstall_customizations($installed_modules);
             if (!$this->silent) {
                 $current_step++;
                 update_progress_bar('install', $total_steps, $total_steps);
             }
         }
         if (!$this->silent) {
             $current_step++;
             update_progress_bar('install', $current_step, $total_steps);
         }
         foreach ($tasks as $task) {
             $this->{$task}();
             $this->reset_file_cache();
             if (!$this->silent) {
                 $current_step++;
                 update_progress_bar('install', $current_step, $total_steps);
             }
         }
         if (isset($installdefs['custom_fields']) && (isset($GLOBALS['mi_remove_tables']) && $GLOBALS['mi_remove_tables'])) {
             $this->log(translate('LBL_MI_UN_CUSTOMFIELD'));
             $this->uninstall_custom_fields($installdefs['custom_fields']);
         }
         if (!$this->silent) {
             $current_step++;
             update_progress_bar('install', $current_step, $total_steps);
             echo '</div>';
         }
         //since we are passing $silent = true to rebuildAll() in that method it will set $this->silent = true, so
         //we need to save the setting to set it back after rebuildAll() completes.
         $silentBak = $this->silent;
         $this->rebuild_all(true);
         $this->silent = $silentBak;
         //#27877, If the request from MB redeploy a custom module , we will not remove the ACL actions for this package.
         if (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'DeployPackage') {
             $this->remove_acl_actions();
         }
         //end
         if (!$this->silent) {
             $current_step++;
             update_progress_bar('install', $current_step, $total_steps);
             echo '</div>';
         }
         $this->updateSystemTabs('Restore', $installed_modules);
         //clear the unified_search_module.php file
         require_once 'modules/Home/UnifiedSearchAdvanced.php';
         UnifiedSearchAdvanced::unlinkUnifiedSearchModulesFile();
         // Destroy all metadata caches and rebuild the base metadata. This
         // will cause a small amount of lag on subsequent requests for other
         // clients.
         MetaDataManager::clearAPICache(true, true);
         MetaDataManager::setupMetadata();
         require_once 'include/api/ServiceDictionaryRest.php';
         $dict = new ServiceDictionaryRest();
         $dict->buildAllDictionaries();
         $this->log('<br><b>' . translate('LBL_MI_COMPLETE') . '</b>');
         if (!$this->silent) {
             update_progress_bar('install', $total_steps, $total_steps);
         }
     } else {
         die("No manifest.php Defined In {$this->base_dir}/manifest.php");
     }
 }
 /**
  * Clears mobile and portal metadata caches that have been created by the API
  * to allow immediate rendering of changes at the client
  */
 protected function _clearCaches()
 {
     if ($this->implementation->isDeployed()) {
         MetaDataFiles::clearModuleClientCache($this->_moduleName, 'view');
         // Clear out the cache just for the platform we are on
         $client = empty($this->client) ? 'base' : $this->client;
         MetaDataManager::refreshModulesCache(array($this->_moduleName), array($client), $this->implementation->getParams());
         parent::_clearCaches();
     }
 }
Esempio n. 14
0
 /**
  * This function prebuilds the metadata cache
  *
  * The cache is prebuilt only for en_us and base platform for now.
  */
 public function prewarmCache()
 {
     //Now that installation is complete, we need to set this to false to have the caches build correctly
     $GLOBALS['installing'] = false;
     $this->log("Populating metadata cache");
     $GLOBALS['app_list_strings'] = return_app_list_strings_language('en_us');
     require_once 'include/MetaDataManager/MetaDataManager.php';
     MetaDataManager::setupMetadata(array('base'), array('en_us'));
     $this->log("Metadata cache populated");
 }
Esempio n. 15
0
 /**
  * Same as SugarBean::mark_deleted except clears api cache.
  * @param $id
  */
 public function mark_deleted($id)
 {
     sugar_cache_clear('currency_list');
     $return = parent::mark_deleted($id);
     // The per-module cache doesn't need to be cleared here
     MetaDataManager::refreshSectionCache(array(MetaDataManager::MM_CURRENCIES));
 }
Esempio n. 16
0
 /**
  * Processes layout field by collecting its display parameters and processing nested fields
  *
  * @param MetaDataManager $metaDataManager Metadata manager
  * @param array $field The field being processed
  * @param array $fieldDefs Field definitions of the module the layout belongs to
  * @param array $fields Resulting set of fields
  * @param array $displayParams Resulting display parameters
  */
 public function processLayoutField(MetaDataManager $metaDataManager, array $field, array $fieldDefs, array &$fields, array &$displayParams)
 {
     $isNamedField = isset($field['name']);
     if ($isNamedField) {
         $displayParams[$field['name']] = $field;
         unset($displayParams[$field['name']]['name']);
     }
     $fieldAttributes = array('fields', 'related_fields');
     foreach ($fieldAttributes as $attribute) {
         if (isset($field[$attribute]) && is_array($field[$attribute])) {
             $fields = array_merge($fields, $metaDataManager->getFieldNames($field[$attribute], $fieldDefs, $displayParams));
             if ($isNamedField) {
                 unset($displayParams[$field['name']][$attribute]);
             }
         }
     }
 }
 /**
  * Clears mobile and portal metadata caches that have been created by the API
  * to allow immediate rendering of changes at the client
  */
 protected function _clearCaches()
 {
     if ($this->implementation->isDeployed()) {
         // Installing and trying to refresh the modules cache is bad juju
         if (!empty($GLOBALS['installing'])) {
             // Use the clear NOW method so that if there is a cache it is wiped
             MetaDataManager::clearAPICache(true, true);
         } else {
             MetaDataManager::refreshModulesCache(array($this->_moduleName));
         }
         parent::_clearCaches();
     }
 }
 public function deploy($defs)
 {
     // We are saving to the custom file
     $savefile = $this->getMetadataFilename(MB_CUSTOMMETADATALOCATION);
     // Simple validation and sanity checking
     if (!is_dir(dirname($savefile))) {
         if (!sugar_mkdir(dirname($savefile), null, true)) {
             throw new Exception("Cannot create directory for {$savefile}");
         }
     }
     // Handle history
     if ($this->loadedMetadataFile === MB_HISTORYMETADATALOCATION) {
         $types = array(MB_WORKINGMETADATALOCATION, MB_CUSTOMMETADATALOCATION, MB_BASEMETADATALOCATION);
         foreach ($types as $type) {
             $file = $this->getMetadataFilename($type);
             if (file_exists($file)) {
                 $this->_history->append($file);
                 break;
             }
         }
     } else {
         $this->_history->append($this->loadedMetadataFile);
     }
     $this->_viewdefs = $defs;
     // Now save the actual data
     write_array_to_file("viewdefs['{$this->_moduleName}']['{$this->_viewClient}']['filter']['default']", $this->_viewdefs, $savefile);
     // Delete the working file if exists as we do in DeployedMetaDataImplementation
     $workingFilename = $this->getMetadataFilename(MB_WORKINGMETADATALOCATION);
     if (file_exists($workingFilename)) {
         SugarAutoLoader::unlink($workingFilename);
     }
     // clear the cache for this module
     MetaDataManager::refreshModulesCache(array($this->_moduleName));
 }
Esempio n. 19
0
 /**
  * Save function responsible executing all sub-save functions required to rename a module.
  *
  * @return void
  */
 public function save($redirect = TRUE)
 {
     global $locale;
     if (!empty($_REQUEST['dropdown_lang'])) {
         $this->selectedLanguage = $_REQUEST['dropdown_lang'];
     } else {
         $this->selectedLanguage = $locale->getAuthenticatedUserLanguage();
     }
     //Clear all relevant language caches
     $this->clearLanguageCaches();
     //Retrieve changes the user is requesting and store previous values for future use.
     $this->changedModules = $this->getChangedModules();
     // Queue the metadata manager so that writes and rewrites only happen once
     MetaDataManager::enableCacheRefreshQueue();
     //Change module, appStrings, subpanels, and related links.
     $this->changeAppStringEntries()->changeAllModuleModStrings()->renameAllRelatedLinks()->renameAllSubpanels()->renameAllDashlets()->changeStringsInRelatedModules()->changeGlobalAppStrings();
     // Run the metadata cache refresh queue so changes take effect
     MetaDataManager::runCacheRefreshQueue();
     //Refresh the page again so module tabs are changed as the save process happens after module tabs are already generated.
     if ($redirect) {
         echo "\n                <script>\n                    var app = window.parent.SUGAR.App;\n                    app.api.call('read', app.api.buildURL('ping'));\n                </script>";
     }
 }
Esempio n. 20
0
 /**
  * Add a set of labels to the language pack for a module, deployed or undeployed
  * 
  * @param string $language Language key, for example 'en_us'
  * @param array $labels The labels to add in the form of an array of System label => Display label pairs
  * @param string $moduleName Name of the module to which to add these labels
  * @param string $basepath Basepath to the file to be written to
  */
 public static function addLabels($language, $labels, $moduleName, $basepath = null)
 {
     $GLOBALS['log']->debug("ParserLabel->addLabels({$language}, \$labels, {$moduleName}, {$basepath});");
     $GLOBALS['log']->debug("\$labels:" . print_r($labels, true));
     $deployedModule = false;
     if (is_null($basepath)) {
         $deployedModule = true;
         $basepath = "custom/Extension/modules/{$moduleName}/Ext/Language";
         if (!SugarAutoLoader::fileExists($basepath)) {
             mkdir_recursive($basepath);
         }
     }
     $filename = "{$basepath}/{$language}.lang.php";
     $mod_strings = array();
     $changed = false;
     if (SugarAutoLoader::fileExists($basepath)) {
         if (SugarAutoLoader::fileExists($filename)) {
             // Get the current $mod_strings
             include $filename;
         }
         foreach ($labels as $key => $value) {
             if (!isset($mod_strings[$key]) || strcmp($value, $mod_strings[$key]) != 0) {
                 // Must match encoding used in view.labels.php
                 $mod_strings[$key] = to_html(strip_tags(from_html($value)));
                 $changed = true;
             }
         }
     } else {
         $changed = true;
     }
     if (!empty($mod_strings) && $changed) {
         $GLOBALS['log']->debug("ParserLabel->addLabels: writing new mod_strings to {$filename}");
         $GLOBALS['log']->debug("ParserLabel->addLabels: mod_strings=" . print_r($mod_strings, true));
         $write = "<?php\n// WARNING: The contents of this file are auto-generated.\n";
         // We can't use normal array writing here since multiple files can be
         // structured differently. This is dirty, yes, but necessary.
         foreach ($mod_strings as $k => $v) {
             $write .= "\$mod_strings['{$k}'] = " . var_export($v, 1) . ";\n";
         }
         if (!SugarAutoLoader::put($filename, $write, true)) {
             $GLOBALS['log']->fatal("Could not write {$filename}");
         } else {
             // if we have a cache to worry about, then clear it now
             if ($deployedModule) {
                 SugarCache::cleanOpcodes();
                 $GLOBALS['log']->debug("PaserLabel->addLabels: clearing language cache");
                 self::rebuildLanguageExtensions($language, $moduleName);
                 $cache_key = "module_language." . $language . $moduleName;
                 sugar_cache_clear($cache_key);
                 LanguageManager::clearLanguageCache($moduleName, $language);
                 MetaDataManager::refreshLanguagesCache($language);
             }
         }
     }
     return true;
 }
Esempio n. 21
0
 /**
  * Removes the metadata files for all known studio layouts.
  *
  * @return html output record of the files deleted
  */
 function removeCustomLayouts()
 {
     $module = StudioModuleFactory::getStudioModule($this->module);
     $sources = $module->getViewMetadataSources();
     $out = "";
     // list of existing platforms including BWC
     $platforms = MetaDataManager::getPlatformList();
     array_unshift($platforms, '');
     // Flag to tell the autoloader whether to save itself or not when done
     $saveMap = false;
     foreach ($sources as $view) {
         foreach ($platforms as $platform) {
             $file = MetaDataFiles::getDeployedFileName($view['type'], $this->module, MB_CUSTOMMETADATALOCATION, $platform);
             // Ensure we are working on files that the autoloader knows about
             if (SugarAutoLoader::fileExists($file)) {
                 // Since we are in a loop inside of a loop do NOT send the
                 // save flag as true to unlink() but be sure to save the file
                 // map after the process is finished so that all changes to
                 // the map are saved.
                 SugarAutoLoader::unlink($file);
                 $out .= "Removed layout {$view['type']}.php<br/>";
                 // Tell the autoloader to save itself
                 $saveMap = true;
             }
         }
     }
     // now clear the cache
     include_once 'include/TemplateHandler/TemplateHandler.php';
     TemplateHandler::clearCache($this->module);
     // If the file map needs saving, handle that now
     if ($saveMap) {
         SugarAutoLoader::saveMap();
     }
     return $out;
 }
Esempio n. 22
0
 /**
  * Update the metadata depending on what we are forecasting on
  *
  * @param String $forecast_by The Module that we are currently forecasting by
  */
 public function updateConfigWorksheetColumnsMetadata($forecast_by)
 {
     if ($forecast_by === 'RevenueLineItems') {
         $contents = "<?php\n\n";
         $key = "viewdefs['Forecasts']['base']['view']['config-worksheet-columns']['panels'][0]['fields']";
         foreach ($this->rli_worksheet_columns as $val) {
             $contents .= override_value_to_string_recursive2($key, $val['name'], $val, false);
         }
         sugar_file_put_contents($this->module_ext_path . DIRECTORY_SEPARATOR . $this->columns_ext_file, $contents);
     } else {
         if (SugarAutoLoader::fileExists($this->module_ext_path . DIRECTORY_SEPARATOR . $this->columns_ext_file)) {
             SugarAutoLoader::unlink($this->module_ext_path . DIRECTORY_SEPARATOR . $this->columns_ext_file);
         }
     }
     $this->runRebuildExtensions(array('Forecasts'));
     MetaDataManager::refreshModulesCache('Forecasts');
 }
Esempio n. 23
0
 /**
  * action_saveglobalsearchsettings
  *
  * This method handles saving the selected modules to display in the Global Search Settings.
  * It instantiates an instance of UnifiedSearchAdvanced and then calls the saveGlobalSearchSettings
  * method.
  *
  */
 public function action_saveglobalsearchsettings()
 {
     global $current_user, $app_strings;
     if (!is_admin($current_user)) {
         sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']);
     }
     try {
         require_once 'modules/Home/UnifiedSearchAdvanced.php';
         $unifiedSearchAdvanced = new UnifiedSearchAdvanced();
         $unifiedSearchAdvanced->saveGlobalSearchSettings();
         //Save FTS Settings
         $type = !empty($_REQUEST['type']) ? $_REQUEST['type'] : '';
         $host = !empty($_REQUEST['host']) ? $_REQUEST['host'] : '';
         $port = !empty($_REQUEST['port']) ? $_REQUEST['port'] : '';
         $ftsConfig = $this->mergeFtsConfig($type, array('port' => $port, 'host' => $host));
         $this->cfg = new Configurator();
         $this->cfg->config['full_text_engine'] = '';
         $this->cfg->saveConfig();
         $ftsConnectionValid = TRUE;
         if (!empty($type)) {
             //Check if the connection is valid on save:
             require_once 'include/SugarSearchEngine/SugarSearchEngineFactory.php';
             $searchEngine = SugarSearchEngineFactory::getInstance($type, $ftsConfig);
             $result = $searchEngine->getServerStatus();
             if (!$result['valid']) {
                 $ftsConnectionValid = FALSE;
             }
             // bug 54274 -- only bother with an override if we have data to place there, empty string breaks Sugar On-Demand!
             $ftsConfig['valid'] = $ftsConnectionValid;
             $this->cfg->config['full_text_engine'] = array($type => $ftsConfig);
             $this->cfg->handleOverride();
         }
         // Refresh the server info & module list sections of the metadata
         MetaDataManager::refreshSectionCache(array(MetaDataManager::MM_SERVERINFO, MetaDataManager::MM_MODULES));
         if (!$ftsConnectionValid) {
             echo $GLOBALS['mod_strings']['LBL_FTS_CONNECTION_INVALID'];
         } else {
             echo "true";
         }
     } catch (Exception $ex) {
         echo "false";
     }
 }
Esempio n. 24
0
    }
} else {
    $bottleMsg = $mod_strings['LBL_PERFORM_SUCCESS'];
}
installerHook('post_installModules');
installerHook('pre_handleMissingSmtpServerSettingsNotifications');
handleMissingSmtpServerSettingsNotifications();
installerHook('post_handleMissingSmtpServerSettingsNotifications');
// rebuild cache after all is said and done
installLog("Populating file cache");
SugarAutoLoader::buildCache();
// Build the base platform metadata caches after everything else is done.
installLog("Populating metadata cache");
MetaDataManager::enableCache();
$app_list_strings = return_app_list_strings_language('en_us');
MetaDataManager::setupMetadata(array('base'), array('en_us'));
// TODO: Remove the following. (See MAR-1314)
// Restore the activity stream behaviour.
Activity::enable();
installerHook('post_performSetup');
$out = <<<EOQ
<br><p><b>{$mod_strings['LBL_PERFORM_OUTRO_1']} {$setup_sugar_version} {$mod_strings['LBL_PERFORM_OUTRO_2']}</b></p>

{$mod_strings['LBL_PERFORM_OUTRO_3']} {$deltaTime} {$mod_strings['LBL_PERFORM_OUTRO_4']}<br />
{$memoryUsed}
{$errTcpip}
    </td>
</tr>
<tr>
<td align="right" colspan="2">
<hr>
Esempio n. 25
0
 /**
  * Temporarily disables metadata caching
  */
 public static function disableCache()
 {
     self::$isCacheEnabled = false;
 }
Esempio n. 26
0
 /**
  * Saves the company logo to the custom directory for the default theme, so all themes can use it
  *
  * @param string $path path to the image to set as the company logo image
  */
 function saveCompanyLogo($path)
 {
     $path = $this->checkTempImage($path);
     $logo = create_custom_directory(SugarThemeRegistry::current()->getDefaultImagePath() . '/company_logo.png');
     copy($path, $logo);
     SugarAutoLoader::addToMap($logo);
     sugar_cache_clear('company_logo_attributes');
     SugarThemeRegistry::clearAllCaches();
     SugarThemeRegistry::current()->clearImageCache('company_logo.png');
     MetaDataManager::refreshSectionCache(array(MetaDataManager::MM_LOGOURL));
 }
 /**
  * Retrieve white listed properties which shall be copied from server side
  * configurations to client side configurations.
  *
  * @return array Configuration properties.
  */
 protected function getConfigProperties()
 {
     $properties = parent::getConfigProperties();
     $properties['offlineEnabled'] = true;
     return $properties;
 }
Esempio n. 28
0
 /**
  * Gets the metadata manager for this user and platform
  *
  * @return MetaDataManager
  */
 protected function getMetadataManager()
 {
     return MetaDataManager::getManager(array($this->platform));
 }
Esempio n. 29
0
 /**
  * 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);
 }
Esempio n. 30
0
 public function action_listViewSave()
 {
     $GLOBALS['log']->info("action_listViewSave");
     if (isset($_REQUEST['PORTAL'])) {
         $this->view = 'portallistview';
         $parser = ParserFactory::getParser($this->view, $_REQUEST['view_module'], null, null, MB_PORTAL);
         //$parser->init ( $_REQUEST [ 'view_module' ] ) ; // removed init because MetaDataParsers don't use it
     } else {
         $packageName = isset($_REQUEST['view_package']) && strtolower($_REQUEST['view_package']) != 'studio' ? $_REQUEST['view_package'] : null;
         $subpanelName = !empty($_REQUEST['subpanel']) ? $_REQUEST['subpanel'] : null;
         $parser = ParserFactory::getParser($_REQUEST['view'], $_REQUEST['view_module'], $packageName, $subpanelName);
         $this->view = 'listView';
         // To make sure that dashlets can render customized list views on BWC
         // modules, we need to save list customizations for BWC modules in
         // the new style as well.
         if (isModuleBWC($_REQUEST['view_module']) && empty($packageName) && empty($subpanelName)) {
             $sidecarListParser = new SidecarListLayoutMetaDataParser(MB_SIDECARLISTVIEW, $_REQUEST['view_module'], null, 'base');
             $sidecarListParser->handleSave();
         }
     }
     // for backwards compatibility we need to parse the subpanel the old way as well
     // TODO: Remove this when all BWC Modules are converted
     if ($parser instanceof SidecarSubpanelLayoutMetaDataParser) {
         require_once 'modules/ModuleBuilder/parsers/views/SubpanelMetaDataParser.php';
         $oldSubpanelParser = new SubpanelMetaDataParser($subpanelName, $_REQUEST['view_module'], $packageName);
         $oldSubpanelParser->handleSave();
         unset($oldSubpanelParser);
     }
     $parser->handleSave();
     if (empty($packageName) && !empty($subpanelName)) {
         $rr = new RepairAndClear();
         $rr->show_output = false;
         $rr->rebuildExtensions();
     }
     // clear the cache for the linked module and requested module
     MetaDataManager::refreshModulesCache($parser->getAffectedModules());
 }