public function testStoreClearCacheKeyAndRetrieve()
 {
     sugar_cache_put($this->_cacheKey1, $this->_cacheValue1);
     sugar_cache_put($this->_cacheKey2, $this->_cacheValue2);
     sugar_cache_clear($this->_cacheKey1);
     $this->assertNotEquals($this->_cacheValue1, sugar_cache_retrieve($this->_cacheKey1));
     $this->assertEquals($this->_cacheValue2, sugar_cache_retrieve($this->_cacheKey2));
 }
Esempio n. 2
0
 public function setUp()
 {
     if (!is_dir('custom/include/language')) {
         @mkdir('custom/include/language', 0777, true);
     }
     sugar_cache_clear('app_list_strings.en_us');
     sugar_cache_clear('app_list_strings.fr_test');
 }
Esempio n. 3
0
 public function tearDown()
 {
     unlink('include/language/fr_test.lang.php');
     unlink('include/language/de_test.lang.php');
     sugar_cache_clear('app_list_strings.en_us');
     sugar_cache_clear('app_list_strings.fr_test');
     sugar_cache_clear('app_list_strings.de_test');
     if (isset($this->_backup_default_language)) {
         $sugar_config['default_language'] = $this->_backup_default_language;
     }
 }
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
 public function tearDown()
 {
     $_REQUEST = array();
     sugar_cache_clear('mod_strings.en_us');
     if (file_exists('custom/modules/' . $this->module . '/language/en_us.lang.php')) {
         unlink('custom/modules/' . $this->module . '/language/en_us.lang.php');
     }
     if (file_exists('custom/modules/' . $this->add_module . '/language/en_us.lang.php')) {
         unlink('custom/modules/' . $this->add_module . '/language/en_us.lang.php');
     }
     SugarTestHelper::tearDown();
     parent::tearDown();
 }
Esempio n. 6
0
 function display()
 {
     global $mod_strings, $export_module, $current_language, $theme, $current_user;
     echo get_module_title("Activities", $mod_strings['LBL_MODULE_TITLE'], true);
     $mod_strings = return_module_language($current_language, 'Calls');
     // Overload the export module since the user got here by clicking the "Activities" tab
     $export_module = "Calls";
     $_REQUEST['module'] = 'Calls';
     $controller = ControllerFactory::getController('Calls');
     $controller->loadBean();
     $controller->preProcess();
     $controller->process();
     //Manipulate view directly to not display header, js and footer again
     $view = ViewFactory::loadView($controller->view, $controller->module, $controller->bean, $controller->view_object_map);
     $view->options['show_header'] = false;
     $view->options['show_title'] = false;
     $view->options['show_javascript'] = false;
     $view->process();
     if ($GLOBALS['external_cache_enabled']) {
         sugar_cache_clear('VIEW_CONFIG_FILE_Calls_TYPE_list');
     }
     die;
 }
Esempio n. 7
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. 8
0
 function action_DeployPackage()
 {
     if (defined('TEMPLATE_URL')) {
         sugar_cache_reset();
         SugarTemplateUtilities::disableCache();
     }
     $mb = new ModuleBuilder();
     $load = $_REQUEST['package'];
     $message = $GLOBALS['mod_strings']['LBL_MODULE_DEPLOYED'];
     if (!empty($load)) {
         $zip = $mb->getPackage($load);
         require_once 'ModuleInstall/PackageManager/PackageManager.php';
         $pm = new PackageManager();
         $info = $mb->packages[$load]->build(false);
         mkdir_recursive($GLOBALS['sugar_config']['cache_dir'] . '/upload/upgrades/module/');
         rename($info['zip'], $GLOBALS['sugar_config']['cache_dir'] . '/' . 'upload/upgrades/module/' . $info['name'] . '.zip');
         copy($info['manifest'], $GLOBALS['sugar_config']['cache_dir'] . '/' . 'upload/upgrades/module/' . $info['name'] . '-manifest.php');
         $_REQUEST['install_file'] = $GLOBALS['sugar_config']['cache_dir'] . '/' . 'upload/upgrades/module/' . $info['name'] . '.zip';
         $GLOBALS['mi_remove_tables'] = false;
         $pm->performUninstall($load);
         //#23177 , js cache clear
         clearAllJsAndJsLangFilesWithoutOutput();
         //#30747, clear the cache in memoy
         $cache_key = 'app_list_strings.' . $GLOBALS['current_language'];
         sugar_cache_clear($cache_key);
         sugar_cache_reset();
         //clear end
         $pm->performInstall($_REQUEST['install_file']);
     }
     echo 'complete';
 }
Esempio n. 9
0
 function action_DeployPackage()
 {
     global $current_user;
     if (defined('TEMPLATE_URL')) {
         sugar_cache_reset();
         SugarTemplateUtilities::disableCache();
     }
     //increment etag for menu so the new module shows up when the AJAX UI reloads
     $current_user->incrementETag("mainMenuETag");
     $mb = new ModuleBuilder();
     $load = $_REQUEST['package'];
     $message = $GLOBALS['mod_strings']['LBL_MODULE_DEPLOYED'];
     if (!empty($load)) {
         $zip = $mb->getPackage($load);
         require_once 'ModuleInstall/PackageManager/PackageManager.php';
         $pm = new PackageManager();
         $info = $mb->packages[$load]->build(false);
         $uploadDir = $pm->upload_dir . '/upgrades/module/';
         mkdir_recursive($uploadDir);
         rename($info['zip'], $uploadDir . $info['name'] . '.zip');
         copy($info['manifest'], $uploadDir . $info['name'] . '-manifest.php');
         $_REQUEST['install_file'] = $uploadDir . $info['name'] . '.zip';
         $GLOBALS['mi_remove_tables'] = false;
         $pm->performUninstall($load);
         //#23177 , js cache clear
         clearAllJsAndJsLangFilesWithoutOutput();
         //#30747, clear the cache in memory
         $cache_key = 'app_list_strings.' . $GLOBALS['current_language'];
         sugar_cache_clear($cache_key);
         sugar_cache_reset();
         //clear end
         $pm->performInstall($_REQUEST['install_file'], true);
         //clear the unified_search_module.php file
         require_once 'modules/Home/UnifiedSearchAdvanced.php';
         UnifiedSearchAdvanced::unlinkUnifiedSearchModulesFile();
         //bug 44269 - start
         //clear workflow admin modules cache
         if (isset($_SESSION['get_workflow_admin_modules_for_user'])) {
             unset($_SESSION['get_workflow_admin_modules_for_user']);
         }
         //clear "is_admin_for_module" cache
         $sessionVar = 'MLA_' . $current_user->user_name;
         foreach ($mb->packages as $package) {
             foreach ($package->modules as $module) {
                 $_SESSION[$sessionVar][$package->name . '_' . $module->name] = true;
             }
         }
         //recreate acl cache
         $actions = ACLAction::getUserActions($current_user->id, true);
         //bug 44269 - end
     }
     echo 'complete';
 }
Esempio n. 10
0
/**
 * @return bool
 * @param app_list_strings array
 * @desc Saves the app_list_strings to file in the 'custom' dir.
 */
function save_custom_app_list_strings(&$app_list_strings, $language)
{
    $return_value = false;
    $dirname = 'custom/include/language';
    $dir_exists = is_dir($dirname);
    if (!$dir_exists) {
        $dir_exists = create_include_lang_dir($dirname);
    }
    if ($dir_exists) {
        $filename = "{$dirname}/{$language}.lang.php";
        $handle = @sugar_fopen($filename, 'wt');
        if ($handle) {
            $contents = create_dropdown_lang_pak_contents($app_list_strings, $language);
            if (fwrite($handle, $contents)) {
                $return_value = true;
                $GLOBALS['log']->info("Successful write to: {$filename}");
            }
            fclose($handle);
        } else {
            $GLOBALS['log']->info("Unable to write edited language pak to file: {$filename}");
        }
    } else {
        $GLOBALS['log']->info("Unable to create dir: {$dirname}");
    }
    if ($return_value) {
        $cache_key = 'app_list_strings.' . $language;
        sugar_cache_clear($cache_key);
    }
    return $return_value;
}
Esempio n. 11
0
 public function action_SaveLabel()
 {
     if (!empty($_REQUEST['view_module']) && !empty($_REQUEST['labelValue'])) {
         $_REQUEST["label_" . $_REQUEST['label']] = $_REQUEST['labelValue'];
         // Since the following loop will change aspects of the $_REQUEST
         // array read it into a copy to preserve state on $_REQUEST
         $req = $_REQUEST;
         foreach (ModuleBuilder::getModuleAliases($_REQUEST['view_module']) as $key) {
             $req['view_module'] = $key;
             $parser = new ParserLabel($req['view_module'], isset($req['view_package']) ? $req['view_package'] : null);
             $parser->handleSave($req, $GLOBALS['current_language']);
             // Clear the language cache to make sure the view picks up the latest
             $cache_key = LanguageManager::getLanguageCacheKey($req['view_module'], $GLOBALS['current_language']);
             sugar_cache_clear($cache_key);
         }
         MetaDataManager::refreshSectionCache(MetaDataManager::MM_LABELS);
         MetaDataManager::refreshSectionCache(MetaDataManager::MM_ORDEREDLABELS);
     }
     $this->view = 'modulefields';
 }
 /**
  * Remove the language cache files from cache/modules/<module>/language
  */
 public function clearLanguageCache()
 {
     global $mod_strings;
     if ($this->show_output) {
         echo "<h3>{$mod_strings['LBL_QR_CLEARLANG']}</h3>";
     }
     //clear cache using the list $module_list_from_cache
     if (!empty($this->module_list) && is_array($this->module_list)) {
         if (in_array(translate('LBL_ALL_MODULES'), $this->module_list)) {
             LanguageManager::clearLanguageCache();
         } else {
             //use the modules selected thrut the select list.
             foreach ($this->module_list as $module_name) {
                 LanguageManager::clearLanguageCache($module_name);
             }
         }
     }
     // Clear app* cache values too
     if (!empty($GLOBALS['sugar_config']['languages'])) {
         $languages = $GLOBALS['sugar_config']['languages'];
     } else {
         $languages = array($GLOBALS['current_language'] => $GLOBALS['current_language']);
     }
     foreach (array_keys($languages) as $language) {
         sugar_cache_clear('app_strings.' . $language);
         sugar_cache_clear('app_list_strings.' . $language);
     }
 }
Esempio n. 13
0
 public function testBuildMergeLink()
 {
     $this->_lvd->seed = new stdClass();
     $this->_lvd->seed->module_dir = 'foobarfoobar';
     $GLOBALS['current_user']->setPreference('mailmerge_on', 'on');
     $settings_cache = sugar_cache_retrieve('admin_settings_cache');
     if (empty($settings_cache)) {
         $settings_cache = array();
     }
     $settings_cache['system_mailmerge_on'] = true;
     sugar_cache_put('admin_settings_cache', $settings_cache);
     $output = $this->_lvd->buildMergeLink(array('foobarfoobar' => 'foobarfoobar'));
     $this->assertContains("index.php?action=index&module=MailMerge&entire=true", $output);
     sugar_cache_clear('admin_settings_cache');
 }
Esempio n. 14
0
 /**
  * PRIVATE function used within clearLanguageCache so we do not repeat logic
  * @param string module_dir the module_dir to clear
  * @param string lang the name of the language file we are clearing this is for sugar_cache
  */
 function _clearCache($module_dir = '', $lang)
 {
     if (!empty($module_dir) && !empty($lang)) {
         $file = sugar_cached('modules/') . $module_dir . '/language/' . $lang . '.lang.php';
         if (file_exists($file)) {
             unlink($file);
             $key = self::getLanguageCacheKey($module_dir, $lang);
             sugar_cache_clear($key);
         }
     }
 }
Esempio n. 15
0
 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";
 }
Esempio n. 16
0
 /**
  * Destructor
  * Here we'll write out the internal file path caches to an external cache of some sort.
  */
 public function __destruct()
 {
     // Bug 28309 - Set the current directory to one which we expect it to be (i.e. the root directory of the install
     set_include_path(realpath(dirname(__FILE__) . '/../..') . PATH_SEPARATOR . get_include_path());
     chdir(realpath(dirname(__FILE__) . '/../..'));
     // Bug 30807/30808 - Re-setup the external cache since the object isn't there when calling this method.
     $GLOBALS['external_cache_checked'] = false;
     check_cache();
     // clear out the cache on destroy if we are asked to
     if ($this->_clearCacheOnDestroy) {
         if (is_file($GLOBALS['sugar_config']['cache_dir'] . $this->getFilePath() . '/pathCache.php')) {
             unlink($GLOBALS['sugar_config']['cache_dir'] . $this->getFilePath() . '/pathCache.php');
         }
         if ($GLOBALS['external_cache_enabled'] && $GLOBALS['external_cache_type'] != 'base-in-memory') {
             sugar_cache_clear('theme_' . $this->dirName . '_jsCache');
             sugar_cache_clear('theme_' . $this->dirName . '_cssCache');
             sugar_cache_clear('theme_' . $this->dirName . '_imageCache');
             sugar_cache_clear('theme_' . $this->dirName . '_templateCache');
         }
     } elseif (!inDeveloperMode()) {
         // push our cache into the sugar cache
         if ($GLOBALS['external_cache_enabled'] && $GLOBALS['external_cache_type'] != 'base-in-memory') {
             // only update the caches if they have been changed in this request
             if (count($this->_jsCache) != $this->_initialCacheSize['jsCache']) {
                 sugar_cache_put('theme_' . $this->dirName . '_jsCache', $this->_jsCache);
             }
             if (count($this->_cssCache) != $this->_initialCacheSize['cssCache']) {
                 sugar_cache_put('theme_' . $this->dirName . '_cssCache', $this->_cssCache);
             }
             if (count($this->_imageCache) != $this->_initialCacheSize['imageCache']) {
                 sugar_cache_put('theme_' . $this->dirName . '_imageCache', $this->_imageCache);
             }
             if (count($this->_templateCache) != $this->_initialCacheSize['templateCache']) {
                 sugar_cache_put('theme_' . $this->dirName . '_templateCache', $this->_templateCache);
             }
         } elseif (count($this->_jsCache) != $this->_initialCacheSize['jsCache'] || count($this->_cssCache) != $this->_initialCacheSize['cssCache'] || count($this->_imageCache) != $this->_initialCacheSize['imageCache'] || count($this->_templateCache) != $this->_initialCacheSize['templateCache']) {
             sugar_file_put_contents(create_cache_directory($this->getFilePath() . '/pathCache.php'), serialize(array('jsCache' => $this->_jsCache, 'cssCache' => $this->_cssCache, 'imageCache' => $this->_imageCache, 'templateCache' => $this->_templateCache)));
         }
     } elseif ($GLOBALS['external_cache_enabled']) {
         sugar_cache_clear('theme_' . $this->dirName . '_jsCache');
         sugar_cache_clear('theme_' . $this->dirName . '_cssCache');
         sugar_cache_clear('theme_' . $this->dirName . '_imageCache');
         sugar_cache_clear('theme_' . $this->dirName . '_templateCache');
     }
 }
Esempio n. 17
0
 /**
  * PRIVATE function used within clearVardefCache so we do not repeat logic
  * @param string module_dir the module_dir to clear
  * @param string object_name the name of the object we are clearing this is for sugar_cache
  */
 function _clearCache($module_dir = '', $object_name = '')
 {
     if (!empty($module_dir) && !empty($object_name)) {
         if ($object_name == 'aCase') {
             $object_name = 'Case';
         }
         $file = $GLOBALS['sugar_config']['cache_dir'] . 'modules/' . $module_dir . '/' . $object_name . 'vardefs.php';
         if (file_exists($file)) {
             unlink($file);
             $key = "VardefManager.{$module_dir}.{$object_name}";
             sugar_cache_clear($key);
         }
     }
 }
Esempio n. 18
0
 function save($check_notify = FALSE)
 {
     sugar_cache_clear('currency_list');
     return parent::save($check_notify);
 }
Esempio n. 19
0
 function saveSetting($category, $key, $value)
 {
     $result = $this->db->query("SELECT count(*) AS the_count FROM config WHERE category = '{$category}' AND name = '{$key}'");
     $row = $this->db->fetchByAssoc($result, -1, true);
     $row_count = $row['the_count'];
     if ($category . "_" . $key == 'ldap_admin_password' || $category . "_" . $key == 'proxy_password') {
         $value = $this->encrpyt_before_save($value);
     }
     if ($row_count == 0) {
         $result = $this->db->query("INSERT INTO config (value, category, name) VALUES ('{$value}','{$category}', '{$key}')");
     } else {
         $result = $this->db->query("UPDATE config SET value = '{$value}' WHERE category = '{$category}' AND name = '{$key}'");
     }
     sugar_cache_clear('admin_settings_cache');
     return $this->db->getAffectedRowCount();
 }
Esempio n. 20
0
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU Affero General Public License version 3.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
 * reasonably feasible for  technical reasons, the Appropriate Legal Notices must
 * display the words  "Powered by SugarCRM" and "Supercharged by SuiteCRM".
 ********************************************************************************/
/*********************************************************************************
 * Description:  Saves an Account record and then redirects the browser to the
 * defined return URL.
 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
 * All Rights Reserved.
 * Contributor(s): ______________________________________..
 ********************************************************************************/
$focus = new EmailTemplate();
require_once 'include/formbase.php';
$focus = populateFromPost('', $focus);
require_once 'modules/EmailTemplates/EmailTemplateFormBase.php';
$form = new EmailTemplateFormBase();
sugar_cache_clear('select_array:' . $focus->object_name . 'namebase_module=\'' . $focus->base_module . '\'name');
if (isset($_REQUEST['inpopupwindow']) and $_REQUEST['inpopupwindow'] == true) {
    $focus = $form->handleSave('', false, false);
    //do not redirect.
    $body1 = "\n\t\t<script type='text/javascript'>\n\t\t\tfunction refreshTemplates() {\n\t\t\t\twindow.opener.refresh_email_template_list('{$focus->id}','{$focus->name}')\n\t\t\t\twindow.close();\n\t\t\t}\n\n\t\t\trefreshTemplates();\n\t\t</script>";
    echo $body1;
} else {
    $form->handleSave('', true, false, true, 'download');
}
Esempio n. 21
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);
     mkdir_recursive('custom/' . SugarThemeRegistry::current()->getDefaultImagePath(), true);
     copy($path, 'custom/' . SugarThemeRegistry::current()->getDefaultImagePath() . '/company_logo.png');
     sugar_cache_clear('company_logo_attributes');
     SugarThemeRegistry::clearAllCaches();
 }
Esempio n. 22
0
 static function addLabels($language, $labels, $moduleName, $basepath = null, $forRelationshipLabel = false)
 {
     $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/modules/{$moduleName}/language";
         if ($forRelationshipLabel) {
             $basepath = "custom/modules/{$moduleName}/Ext/Language";
         }
         if (!is_dir($basepath)) {
             mkdir_recursive($basepath);
         }
     }
     $filename = "{$basepath}/{$language}.lang.php";
     if ($forRelationshipLabel) {
         $filename = "{$basepath}/{$language}.lang.ext.php";
     }
     $dir_exists = is_dir($basepath);
     $mod_strings = array();
     if ($dir_exists) {
         if (file_exists($filename)) {
             // obtain $mod_strings
             include $filename;
         } else {
             if ($forRelationshipLabel) {
                 $fh = fopen($filename, 'a');
                 fclose($fh);
             }
         }
     } else {
         return false;
     }
     $changed = false;
     //$charset = (isset($app_strings['LBL_CHARSET'])) ? $app_strings['LBL_CHARSET'] : $GLOBALS['sugar_config']['default_charset'] ;
     foreach ($labels as $key => $value) {
         if (!isset($mod_strings[$key]) || strcmp($value, $mod_strings[$key]) != 0) {
             $mod_strings[$key] = to_html(strip_tags(from_html($value)));
             // must match encoding used in view.labels.php
             $changed = true;
         }
     }
     if ($changed) {
         $GLOBALS['log']->debug("ParserLabel->addLabels: writing new mod_strings to {$filename}");
         $GLOBALS['log']->debug("ParserLabel->addLabels: mod_strings=" . print_r($mod_strings, true));
         if (!write_array_to_file("mod_strings", $mod_strings, $filename)) {
             $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");
                 $cache_key = "module_language." . $language . $moduleName;
                 sugar_cache_clear($cache_key);
                 LanguageManager::clearLanguageCache($moduleName, $language);
             }
         }
     }
     return true;
 }
Esempio n. 23
0
 function install($base_dir, $is_upgrade = false, $previous_version = '')
 {
     if (defined('TEMPLATE_URL')) {
         SugarTemplateUtilities::disableCache();
     }
     if (defined('MODULE_INSTALLER_PACKAGE_SCAN') && MODULE_INSTALLER_PACKAGE_SCAN || !empty($GLOBALS['sugar_config']['moduleInstaller']['packageScan'])) {
         $this->ms->scanPackage($base_dir);
         if ($this->ms->hasIssues()) {
             $this->ms->displayIssues();
             sugar_cleanup(true);
         }
     }
     // workaround for bug 45812 - refresh vardefs cache before unpacking to avoid partial vardefs in cache
     global $beanList;
     foreach ($this->modules as $module_name) {
         if (!empty($beanList[$module_name])) {
             $objectName = BeanFactory::getObjectName($module_name);
             VardefManager::loadVardef($module_name, $objectName);
         }
     }
     global $app_strings, $mod_strings;
     $this->base_dir = $base_dir;
     $total_steps = 5;
     //minimum number of steps with no tasks
     $current_step = 0;
     $tasks = array('pre_execute', 'install_copy', 'install_extensions', 'install_images', 'install_dcactions', 'install_dashlets', 'install_connectors', 'install_layoutfields', 'install_relationships', 'enable_manifest_logichooks', 'post_execute', 'reset_opcodes');
     $total_steps += count($tasks);
     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="document.getElementById(\'displayLog\').style.display=\'\'">' . $app_strings['LBL_DISPLAY_LOG'] . '</a> </div><div id="displayLog" style="display:none">';
         }
         include $this->base_dir . '/manifest.php';
         if ($is_upgrade && !empty($previous_version)) {
             //check if the upgrade path exists
             if (!empty($upgrade_manifest)) {
                 if (!empty($upgrade_manifest['upgrade_paths'])) {
                     if (!empty($upgrade_manifest['upgrade_paths'][$previous_version])) {
                         $installdefs = $upgrade_manifest['upgrade_paths'][$previous_version];
                     } else {
                         $errors[] = 'No Upgrade Path Found in manifest.';
                         $this->abort($errors);
                     }
                     //fi
                 }
                 //fi
             }
             //fi
         }
         //fi
         $this->id_name = $installdefs['id'];
         $this->installdefs = $installdefs;
         if (!$this->silent) {
             $current_step++;
             update_progress_bar('install', $current_step, $total_steps);
         }
         foreach ($tasks as $task) {
             $this->{$task}();
             if (!$this->silent) {
                 $current_step++;
                 update_progress_bar('install', $current_step, $total_steps);
             }
         }
         $this->install_beans($this->installed_modules);
         if (!$this->silent) {
             $current_step++;
             update_progress_bar('install', $total_steps, $total_steps);
         }
         if (isset($installdefs['custom_fields'])) {
             $this->log(translate('LBL_MI_IN_CUSTOMFIELD'));
             $this->install_custom_fields($installdefs['custom_fields']);
         }
         if (!$this->silent) {
             $current_step++;
             update_progress_bar('install', $current_step, $total_steps);
             echo '</div>';
         }
         if (!$this->silent) {
             $current_step++;
             update_progress_bar('install', $current_step, $total_steps);
             echo '</div>';
         }
         $selectedActions = array('clearTpls', 'clearJsFiles', 'clearDashlets', 'clearVardefs', 'clearJsLangFiles', 'rebuildAuditTables', 'repairDatabase');
         VardefManager::clearVardef();
         global $beanList, $beanFiles, $moduleList;
         if (file_exists('custom/application/Ext/Include/modules.ext.php')) {
             include 'custom/application/Ext/Include/modules.ext.php';
         }
         require_once "modules/Administration/upgrade_custom_relationships.php";
         upgrade_custom_relationships($this->installed_modules);
         $this->rebuild_all(true);
         require_once 'modules/Administration/QuickRepairAndRebuild.php';
         $rac = new RepairAndClear();
         $rac->repairAndClearAll($selectedActions, $this->installed_modules, true, false);
         $this->rebuild_relationships();
         UpdateSystemTabs('Add', $this->tab_modules);
         //Clear out all the langauge cache files.
         clearAllJsAndJsLangFilesWithoutOutput();
         $cache_key = 'app_list_strings.' . $GLOBALS['current_language'];
         sugar_cache_clear($cache_key);
         sugar_cache_reset();
         //clear the unified_search_module.php file
         require_once 'modules/Home/UnifiedSearchAdvanced.php';
         UnifiedSearchAdvanced::unlinkUnifiedSearchModulesFile();
         $this->log('<br><b>' . translate('LBL_MI_COMPLETE') . '</b>');
     } else {
         die("No \$installdefs Defined In {$this->base_dir}/manifest.php");
     }
 }
Esempio n. 24
0
 static function flushBackendCache()
 {
     // This function will flush the cache files used for the module list and the link type lists
     sugar_cache_clear('SugarFeedModules');
     if (file_exists($GLOBALS['sugar_config']['cache_dir'] . 'modules/SugarFeed/moduleCache.php')) {
         unlink($GLOBALS['sugar_config']['cache_dir'] . 'modules/SugarFeed/moduleCache.php');
     }
     sugar_cache_clear('SugarFeedLinkType');
     if (file_exists($GLOBALS['sugar_config']['cache_dir'] . 'modules/SugarFeed/linkTypeCache.php')) {
         unlink($GLOBALS['sugar_config']['cache_dir'] . 'modules/SugarFeed/linkTypeCache.php');
     }
 }
 /**
  * Clear the language string cache in sugar_cache, which will get rid of our
  * language file overrides.
  */
 protected function clearLangCache()
 {
     $language = $GLOBALS['current_language'];
     if (isset($this->_strings['app_strings'])) {
         $cache_key = 'app_strings.' . $language;
         sugar_cache_clear($cache_key);
     }
     if (isset($this->_strings['app_list_strings'])) {
         $cache_key = 'app_list_strings.' . $language;
         sugar_cache_clear($cache_key);
     }
     if (isset($this->_strings['mod_strings'])) {
         foreach ($this->_strings['mod_strings'] as $module => $strings) {
             $cache_key = LanguageManager::getLanguageCacheKey($module, $language);
             sugar_cache_clear($cache_key);
         }
     }
 }
Esempio n. 26
0
 /**
  * Clears the API metadata cache of all cache files
  *
  * @param bool $deleteModuleClientCache Should we also delete the client file cache of the modules
  * @param string $workingDirectory directory to chdir into before starting the clears
  * @static
  */
 public static function clearAPICacheOnShutdown($deleteModuleClientCache = true, $workingDirectory = "")
 {
     if (!self::getCacheHasBeenCleared()) {
         //shutdown functions are not always called from the same working directory as the script that registered it
         //Need to chdir to ensure we can find the correct files
         if (!empty($workingDirectory)) {
             chdir($workingDirectory);
         }
         if ($deleteModuleClientCache) {
             // Delete this first so there is no race condition between deleting a metadata cache
             // and the module client cache being stale.
             MetaDataFiles::clearModuleClientCache();
         }
         // Wipe out any files from the metadata cache directory
         $metadataFiles = glob(sugar_cached('api/metadata/') . '*');
         if (is_array($metadataFiles)) {
             foreach ($metadataFiles as $metadataFile) {
                 // This removes the file and the reference from the map. This does
                 // NOT save the file map since that would be expensive in a loop
                 // of many deletes.
                 unlink($metadataFile);
             }
         }
         static::clearCacheTable();
         // clear the platform cache from sugar_cache to avoid out of date data as well as platform component files
         $platforms = self::getPlatformList();
         foreach ($platforms as $platform) {
             $platformKey = $platform == "base" ? "base" : implode(",", array($platform, "base"));
             $hashKey = "metadata:{$platformKey}:hash";
             sugar_cache_clear($hashKey);
             $jsFiles = glob(sugar_cached("javascript/{$platform}/") . '*');
             if (is_array($jsFiles)) {
                 foreach ($jsFiles as $jsFile) {
                     unlink($jsFile);
                 }
             }
         }
     }
 }
Esempio n. 27
0
$setup_site_admin_user_name = $_SESSION['setup_site_admin_user_name'];
$setup_site_admin_password = $_SESSION['setup_site_admin_password'];
$setup_site_guid = isset($_SESSION['setup_site_specify_guid']) && $_SESSION['setup_site_specify_guid'] != '' ? $_SESSION['setup_site_guid'] : '';
$setup_site_url = $_SESSION['setup_site_url'];
$parsed_url = parse_url($setup_site_url);
$setup_site_host_name = $parsed_url['host'];
$setup_site_log_dir = isset($_SESSION['setup_site_custom_log_dir']) ? $_SESSION['setup_site_log_dir'] : '.';
$setup_site_log_file = 'sugarcrm.log';
// may be an option later
$setup_site_session_path = isset($_SESSION['setup_site_custom_session_path']) ? $_SESSION['setup_site_session_path'] : '';
$setup_site_log_level = 'fatal';
sugar_cache_clear('TeamSetsCache');
if (file_exists($cache_dir . 'modules/Teams/TeamSetCache.php')) {
    unlink($cache_dir . 'modules/Teams/TeamSetCache.php');
}
sugar_cache_clear('TeamSetsMD5Cache');
if (file_exists($cache_dir . 'modules/Teams/TeamSetMD5Cache.php')) {
    unlink($cache_dir . 'modules/Teams/TeamSetMD5Cache.php');
}
$langHeader = get_language_header();
$out = <<<EOQ
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html {$langHeader}>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   <meta http-equiv="Content-Script-Type" content="text/javascript">
   <meta http-equiv="Content-Style-Type" content="text/css">
    <title>{$mod_strings['LBL_WIZARD_TITLE']} {$mod_strings['LBL_PERFORM_TITLE']}</title>
   <link REL="SHORTCUT ICON" HREF="{$icon}">
   <link rel="stylesheet" href="{$css}" type="text/css" />
   <script type="text/javascript" src="{$common}"></script>
Esempio n. 28
0
 /**
  * Takes in the request params from a save request and processes 
  * them for the save.
  *
  * @param REQUEST params  $params
  */
 function saveTabGroups($params)
 {
     //#30205
     global $sugar_config;
     //Get the selected tab group language
     $grouptab_lang = !empty($params['grouptab_lang']) ? $params['grouptab_lang'] : $_SESSION['authenticated_user_language'];
     $tabGroups = array();
     $selected_lang = !empty($params['dropdown_lang']) ? $params['dropdown_lang'] : $_SESSION['authenticated_user_language'];
     $slot_count = $params['slot_count'];
     $completedIndexes = array();
     for ($count = 0; $count < $slot_count; $count++) {
         if ($params['delete_' . $count] == 1 || !isset($params['slot_' . $count])) {
             continue;
         }
         $index = $params['slot_' . $count];
         if (isset($completedIndexes[$index])) {
             continue;
         }
         $labelID = !empty($params['tablabelid_' . $index]) ? $params['tablabelid_' . $index] : 'LBL_GROUPTAB' . $count . '_' . time();
         $labelValue = $params['tablabel_' . $index];
         $app_strings = return_application_language($grouptab_lang);
         if (empty($app_strings[$labelID]) || $app_strings[$labelID] != $labelValue) {
             $contents = return_custom_app_list_strings_file_contents($grouptab_lang);
             $new_contents = replace_or_add_app_string($labelID, $labelValue, $contents);
             save_custom_app_list_strings_contents($new_contents, $grouptab_lang);
             $languages = get_languages();
             foreach ($languages as $language => $langlabel) {
                 if ($grouptab_lang == $language) {
                     continue;
                 }
                 $app_strings = return_application_language($language);
                 if (!isset($app_strings[$labelID])) {
                     $contents = return_custom_app_list_strings_file_contents($language);
                     $new_contents = replace_or_add_app_string($labelID, $labelValue, $contents);
                     save_custom_app_list_strings_contents($new_contents, $language);
                 }
             }
             $app_strings[$labelID] = $labelValue;
         }
         $tabGroups[$labelID] = array('label' => $labelID);
         $tabGroups[$labelID]['modules'] = array();
         for ($subcount = 0; isset($params[$index . '_' . $subcount]); $subcount++) {
             $tabGroups[$labelID]['modules'][] = $params[$index . '_' . $subcount];
         }
         $completedIndexes[$index] = true;
     }
     // Force a rebuild of the app language
     sugar_cache_clear('app_strings.' . $grouptab_lang);
     $newFile = create_custom_directory('include/tabConfig.php');
     write_array_to_file("GLOBALS['tabStructure']", $tabGroups, $newFile);
     $GLOBALS['tabStructure'] = $tabGroups;
 }
Esempio n. 29
0
function clear_register_value($category, $name)
{
    return sugar_cache_clear("{$category}:{$name}");
}
Esempio n. 30
0
 /**
  * PRIVATE function used within clearVardefCache so we do not repeat logic
  * @param string module_dir the module_dir to clear
  * @param string object_name the name of the object we are clearing this is for sugar_cache
  */
 static function _clearCache($module_dir = '', $object_name = '')
 {
     if (!empty($module_dir) && !empty($object_name)) {
         //Some modules like cases have a bean name that doesn't match the object name
         if (empty($GLOBALS['dictionary'][$object_name])) {
             $newName = BeanFactory::getObjectName($module_dir);
             $object_name = $newName != false ? $newName : $object_name;
         }
         $file = sugar_cached('modules/') . $module_dir . '/' . $object_name . 'vardefs.php';
         if (file_exists($file)) {
             unlink($file);
             $key = "VardefManager.{$module_dir}.{$object_name}";
             sugar_cache_clear($key);
         }
     }
 }