本文整理汇总了PHP中sugar_cache_retrieve函数的典型用法代码示例。如果您正苦于以下问题:PHP sugar_cache_retrieve函数的具体用法?PHP sugar_cache_retrieve怎么用?PHP sugar_cache_retrieve使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sugar_cache_retrieve函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: LoadCachedArray
function LoadCachedArray($module_dir, $module, $key)
{
global $moduleDefs, $fileName;
$cache_key = "load_cached_array.{$module_dir}.{$module}.{$key}";
$result = sugar_cache_retrieve($cache_key);
if (!empty($result)) {
// Use EXTERNAL_CACHE_NULL_VALUE to store null values in the cache.
if ($result == EXTERNAL_CACHE_NULL_VALUE) {
return null;
}
return $result;
}
if (file_exists('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, 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, EXTERNAL_CACHE_NULL_VALUE);
return null;
}
示例2: _loadConfig
/**
* Load the view_<view>_config.php file which holds options used by the view.
*/
function _loadConfig(&$view, $type)
{
$view_config_custom = array();
$view_config_module = array();
$view_config_root_cstm = array();
$view_config_root = array();
$view_config_app = array();
$config_file_name = 'view.' . $type . '.config.php';
$view_config = sugar_cache_retrieve("VIEW_CONFIG_FILE_" . $view->module . "_TYPE_" . $type);
if (!$view_config) {
$view_config_all = array('actions' => array(), 'req_params' => array());
foreach (SugarAutoLoader::existingCustom('include/MVC/View/views/view.config.php', 'include/MVC/View/views/' . $config_file_name, 'modules/' . $view->module . '/views/' . $config_file_name) as $file) {
$view_config = array();
require $file;
if (!empty($view_config['actions'])) {
$view_config_all['actions'] = array_merge($view_config_all['actions'], $view_config['actions']);
}
if (!empty($view_config['req_params'])) {
$view_config_all['req_params'] = array_merge($view_config_all['req_params'], $view_config['req_params']);
}
}
$view_config = $view_config_all;
sugar_cache_put("VIEW_CONFIG_FILE_" . $view->module . "_TYPE_" . $type, $view_config);
}
$action = strtolower($view->action);
$config = null;
if (!empty($view_config['req_params'])) {
//try the params first
foreach ($view_config['req_params'] as $key => $value) {
if (!empty($_REQUEST[$key]) && $_REQUEST[$key] == "false") {
$_REQUEST[$key] = false;
}
if (!empty($_REQUEST[$key])) {
if (!is_array($value['param_value'])) {
if ($value['param_value'] == $_REQUEST[$key]) {
$config = $value['config'];
break;
}
} else {
foreach ($value['param_value'] as $v) {
if ($v == $_REQUEST[$key]) {
$config = $value['config'];
break;
}
}
}
}
}
}
if ($config == null && !empty($view_config['actions']) && !empty($view_config['actions'][$action])) {
$config = $view_config['actions'][$action];
}
if ($config != null) {
$view->options = $config;
}
}
示例3: retrieveSettings
function retrieveSettings($category = FALSE, $clean = false)
{
// declare a cache for all settings
$settings_cache = sugar_cache_retrieve('admin_settings_cache');
if ($clean) {
$settings_cache = array();
}
// Check for a cache hit
if (!empty($settings_cache)) {
$this->settings = $settings_cache;
if (!empty($this->settings[$category])) {
return $this;
}
}
if (!empty($category)) {
$query = "SELECT category, name, value FROM {$this->table_name} WHERE category = '{$category}'";
} else {
$query = "SELECT category, name, value FROM {$this->table_name}";
}
$result = $this->db->query($query, true, "Unable to retrieve system settings");
if (empty($result)) {
return NULL;
}
while ($row = $this->db->fetchByAssoc($result)) {
if ($row['category'] . "_" . $row['name'] == 'ldap_admin_password' || $row['category'] . "_" . $row['name'] == 'proxy_password') {
$this->settings[$row['category'] . "_" . $row['name']] = $this->decrypt_after_retrieve($row['value']);
} else {
$this->settings[$row['category'] . "_" . $row['name']] = $row['value'];
}
$this->settings[$row['category']] = true;
}
$this->settings[$category] = true;
if (!isset($this->settings["mail_sendtype"])) {
// outbound email settings
$oe = new OutboundEmail();
$oe->getSystemMailerSettings();
foreach ($oe->field_defs as $def) {
if (strpos($def, "mail_") !== false) {
$this->settings[$def] = $oe->{$def};
}
}
}
// At this point, we have built a new array that should be cached.
sugar_cache_put('admin_settings_cache', $this->settings);
return $this;
}
示例4: dnbServiceRequest
/**
* Checks cache for cached response else invoke api using makeRequest
* @param $cacheKey String
* @param $endPoint String
* @param $requestType String possible values GET or POST
* @return array
*/
private function dnbServiceRequest($cacheKey, $endPoint, $requestType)
{
$apiResponse = sugar_cache_retrieve($cacheKey);
//obtain results from dnb service if cache does not contain result
if (empty($apiResponse) || $apiResponse === SugarCache::EXTERNAL_CACHE_NULL_VALUE) {
$this->logger->debug('Cache does not contain' . $cacheKey);
$apiResponse = $this->makeRequest($requestType, $endPoint);
if (!$apiResponse['success']) {
$this->logger->error('D&B failed, reply said: ' . print_r($apiResponse, true));
return $apiResponse;
} else {
//cache the result if the dnb service response was a success
sugar_cache_put($cacheKey, $apiResponse, $this->cacheTTL);
$this->logger->debug('Cached ' . $cacheKey);
}
} else {
$this->logger->debug('Getting cached results for ' . $cacheKey);
}
return $apiResponse;
}
示例5: get_date_time_format
/**
* Get user datetime format.
*
* @param User $user user object, current user if not specified
* @return string
*/
public function get_date_time_format($user = null)
{
// BC fix - had (bool, user) signature before
if (!$user instanceof User) {
if (func_num_args() > 1) {
$user = func_get_arg(1);
if (!$user instanceof User) {
$user = null;
}
} else {
$user = null;
}
}
$cacheKey = $this->get_date_time_format_cache_key($user);
$cachedValue = sugar_cache_retrieve($cacheKey);
if (!empty($cachedValue)) {
return $cachedValue;
} else {
$value = $this->merge_date_time($this->get_date_format($user), $this->get_time_format($user));
sugar_cache_put($cacheKey, $value, 0);
return $value;
}
}
示例6: getMeetingsExternalApiDropDown
function getMeetingsExternalApiDropDown($focus = null, $name = null, $value = null, $view = null)
{
global $dictionary, $app_list_strings;
$cacheKeyName = 'meetings_type_drop_down';
$apiList = sugar_cache_retrieve($cacheKeyName);
if ($apiList === null) {
require_once 'include/externalAPI/ExternalAPIFactory.php';
$apiList = ExternalAPIFactory::getModuleDropDown('Meetings');
$apiList = array_merge(array('Sugar' => $GLOBALS['app_list_strings']['eapm_list']['Sugar']), $apiList);
sugar_cache_put($cacheKeyName, $apiList);
}
if (!empty($value) && empty($apiList[$value])) {
$apiList[$value] = $value;
}
//bug 46294: adding list of options to dropdown list (if it is not the default list)
if ($dictionary['Meeting']['fields']['type']['options'] != "eapm_list") {
$apiList = array_merge(getMeetingTypeOptions($dictionary, $app_list_strings), $apiList);
}
return $apiList;
}
示例7: get_register_value
function get_register_value($category, $name)
{
return sugar_cache_retrieve("{$category}:{$name}");
}
示例8: retrieveCssFilesInCache
/**
* Retrieve CSS files in cache. This method actually does:
* - Get file hashes from the cache.
* - If file hashes are found verify that the file exists.
* - If file hashes are not found try to retrieve some css files from the file system
*
* @return array Css files found in cache
*/
private function retrieveCssFilesInCache()
{
$filesInCache = array();
//First check if the file hashes are cached so we don't have to load the metadata manually to calculate it
$hashKey = $this->paths['hashKey'];
$hashArray = sugar_cache_retrieve($hashKey);
if (is_array($hashArray) && count($hashArray) === count($this->lessFilesToCompile)) {
foreach ($hashArray as $lessFile => $hash) {
$file = $this->getCssFileLocation($lessFile, $hash);
if (file_exists($file)) {
$filesInCache[$lessFile] = $hash;
}
}
} else {
/**
* Checks the filesystem for a generated css file
* This is useful on systems without a php memory cache
* or if the memory cache is filled
*/
$files = glob($this->paths['cache'] . '*.css', GLOB_NOSORT);
foreach ($files as $file) {
$nameParts = explode('_', pathinfo($file, PATHINFO_FILENAME));
$filesInCache[$nameParts[0]] = $nameParts[1];
}
}
return $filesInCache;
}
示例9: save
/**
* Saves the created strings
*
* Here, we cheat the system by storing our string overrides in the sugar_cache where
* we normally stored the cached language strings.
*/
public function save()
{
$language = $GLOBALS['current_language'];
if (isset($this->_strings['app_strings'])) {
$cache_key = 'app_strings.' . $language;
$app_strings = sugar_cache_retrieve($cache_key);
if (empty($app_strings)) {
$app_strings = return_application_language($language);
}
foreach ($this->_strings['app_strings'] as $key => $value) {
$app_strings[$key] = $value;
}
sugar_cache_put($cache_key, $app_strings);
$GLOBALS['app_strings'] = $app_strings;
}
if (isset($this->_strings['app_list_strings'])) {
$cache_key = 'app_list_strings.' . $language;
$app_list_strings = sugar_cache_retrieve($cache_key);
if (empty($app_list_strings)) {
$app_list_strings = return_app_list_strings_language($language);
}
foreach ($this->_strings['app_list_strings'] as $key => $value) {
$app_list_strings[$key] = $value;
}
sugar_cache_put($cache_key, $app_list_strings);
$GLOBALS['app_list_strings'] = $app_list_strings;
}
if (isset($this->_strings['mod_strings'])) {
foreach ($this->_strings['mod_strings'] as $module => $strings) {
$cache_key = LanguageManager::getLanguageCacheKey($module, $language);
$mod_strings = sugar_cache_retrieve($cache_key);
if (empty($mod_strings)) {
$mod_strings = return_module_language($language, $module);
}
foreach ($strings as $key => $value) {
$mod_strings[$key] = $value;
}
sugar_cache_put($cache_key, $mod_strings);
$GLOBALS['mod_strings'] = $mod_strings;
}
}
}
示例10: loadMapping
/**
* Generic load method to load mapping arrays.
*/
private function loadMapping($var, $merge = false)
{
${$var} = sugar_cache_retrieve("CONTROLLER_" . $var . "_" . $this->module);
if (!${$var}) {
if ($merge && !empty($this->{$var})) {
${$var} = $this->{$var};
} else {
${$var} = [];
}
if (file_exists($path = DOCROOT . "include/MVC/Controller/{$var}.php")) {
require $path;
}
if (file_exists($path = DOCROOT . "modules/{$this->module}/{$var}'.php")) {
require $path;
}
if (file_exists($path = DOCROOT . "custom/modules/{$this->module}/{$var}.php")) {
require $path;
}
if (file_exists($path = DOCROOT . "custom/include/MVC/Controller/{$var}.php")) {
require $path;
}
$varname = str_replace(" ", "", ucwords(str_replace("_", " ", $var)));
if (file_exists($path = DOCROOT . "custom/application/Ext/{$varname}/{$var}.ext.php")) {
require $path;
}
if (file_exists($path = DOCROOT . "custom/modules/{$this->module}/Ext/{$varname}/{$var}.ext.php")) {
require $path;
}
sugar_cache_put("CONTROLLER_" . $var . "_" . $this->module, ${$var});
}
$this->{$var} = ${$var};
}
示例11: loadMapping
/**
* Generic load method to load mapping arrays.
*/
private function loadMapping($var, $merge = false)
{
${$var} = sugar_cache_retrieve("CONTROLLER_" . $var . "_" . $this->module);
if (!${$var}) {
if ($merge && !empty($this->{$var})) {
${$var} = $this->{$var};
} else {
${$var} = array();
}
if (file_exists('include/MVC/Controller/' . $var . '.php')) {
require 'include/MVC/Controller/' . $var . '.php';
}
if (file_exists('modules/' . $this->module . '/' . $var . '.php')) {
require 'modules/' . $this->module . '/' . $var . '.php';
}
if (file_exists('custom/modules/' . $this->module . '/' . $var . '.php')) {
require 'custom/modules/' . $this->module . '/' . $var . '.php';
}
if (file_exists('custom/include/MVC/Controller/' . $var . '.php')) {
require 'custom/include/MVC/Controller/' . $var . '.php';
}
// entry_point_registry -> EntryPointRegistry
$varname = str_replace(" ", "", ucwords(str_replace("_", " ", $var)));
if (file_exists("custom/application/Ext/{$varname}/{$var}.ext.php")) {
require "custom/application/Ext/{$varname}/{$var}.ext.php";
}
if (file_exists("custom/modules/{$this->module}/Ext/{$varname}/{$var}.ext.php")) {
require "custom/modules/{$this->module}/Ext/{$varname}/{$var}.ext.php";
}
sugar_cache_put("CONTROLLER_" . $var . "_" . $this->module, ${$var});
}
$this->{$var} = ${$var};
}
示例12: checkDatabaseVersion
/**
* checkDatabaseVersion
* Check the db version sugar_version.php and compare to what the version is stored in the config table.
* Ensure that both are the same.
*/
function checkDatabaseVersion($dieOnFailure = true)
{
$row_count = sugar_cache_retrieve('checkDatabaseVersion_row_count');
if (empty($row_count)) {
global $sugar_db_version;
$version_query = 'SELECT count(*) as the_count FROM config WHERE category=\'info\' AND name=\'sugar_version\'';
if ($GLOBALS['db']->dbType == 'oci8') {
} else {
if ($GLOBALS['db']->dbType == 'mssql') {
$version_query .= " AND CAST(value AS varchar(8000)) = '{$sugar_db_version}'";
} else {
$version_query .= " AND value = '{$sugar_db_version}'";
}
}
$result = $GLOBALS['db']->query($version_query);
$row = $GLOBALS['db']->fetchByAssoc($result, -1, true);
$row_count = $row['the_count'];
sugar_cache_put('checkDatabaseVersion_row_count', $row_count);
}
if ($row_count == 0 && empty($GLOBALS['sugar_config']['disc_client'])) {
$sugar_version = $GLOBALS['sugar_version'];
if ($dieOnFailure) {
sugar_die("Sugar CRM {$sugar_version} Files May Only Be Used With A Sugar CRM {$sugar_db_version} Database.");
} else {
return false;
}
}
return true;
}
示例13: getLinkTypes
static function getLinkTypes()
{
static $linkTypeList = null;
// Fastest, already stored in the static variable
if ($linkTypeList != null) {
return $linkTypeList;
}
// Second fastest, stored in a cache somewhere
$linkTypeList = sugar_cache_retrieve('SugarFeedLinkType');
if ($linkTypeList != null) {
return $linkTypeList;
}
// Third fastest, already stored in a file
if (file_exists($GLOBALS['sugar_config']['cache_dir'] . 'modules/SugarFeed/linkTypeCache.php')) {
require_once $GLOBALS['sugar_config']['cache_dir'] . 'modules/SugarFeed/linkTypeCache.php';
sugar_cache_put('SugarFeedLinkType', $linkTypeList);
return $linkTypeList;
}
// Slow, have to actually collect the data
$baseDirs = array('custom/modules/SugarFeed/linkHandlers/', 'modules/SugarFeed/linkHandlers');
$linkTypeList = array();
foreach ($baseDirs as $dirName) {
if (!file_exists($dirName)) {
continue;
}
$d = dir($dirName);
while ($file = $d->read()) {
if ($file[0] == '.') {
continue;
}
if (substr($file, -4) == '.php') {
// We found one
$typeName = substr($file, 0, -4);
$linkTypeList[$typeName] = $typeName;
}
}
}
sugar_cache_put('SugarFeedLinkType', $linkTypeList);
if (!file_exists($GLOBALS['sugar_config']['cache_dir'] . 'modules/SugarFeed')) {
mkdir_recursive($GLOBALS['sugar_config']['cache_dir'] . 'modules/SugarFeed');
}
$fd = fopen($GLOBALS['sugar_config']['cache_dir'] . 'modules/SugarFeed/linkTypeCache.php', 'w');
fwrite($fd, '<' . "?php\n\n" . '$linkTypeList = ' . var_export($linkTypeList, true) . ';');
fclose($fd);
return $linkTypeList;
}
示例14: displayHeader
/**
* Displays the header on section of the page; basically everything before the content
*/
public function displayHeader()
{
global $theme;
global $max_tabs;
global $app_strings;
global $current_user;
global $sugar_config;
global $app_list_strings;
global $mod_strings;
global $current_language;
$GLOBALS['app']->headerDisplayed = true;
$themeObject = SugarThemeRegistry::current();
$theme = $themeObject->__toString();
$ss = new Sugar_Smarty();
$ss->assign("APP", $app_strings);
$ss->assign("THEME", $theme);
$ss->assign("THEME_IE6COMPAT", $themeObject->ie6compat ? 'true' : 'false');
$ss->assign("MODULE_NAME", $this->module);
// get browser title
$ss->assign("SYSTEM_NAME", $this->getBrowserTitle());
// get css
$css = $themeObject->getCSS();
if ($this->_getOption('view_print')) {
$css .= '<link rel="stylesheet" type="text/css" href="' . $themeObject->getCSSURL('print.css') . '" media="all" />';
}
$ss->assign("SUGAR_CSS", $css);
// get javascript
ob_start();
$this->renderJavascript();
$ss->assign("SUGAR_JS", ob_get_contents() . $themeObject->getJS());
ob_end_clean();
// get favicon
if (isset($GLOBALS['sugar_config']['default_module_favicon'])) {
$module_favicon = $GLOBALS['sugar_config']['default_module_favicon'];
} else {
$module_favicon = false;
}
$favicon = '';
if ($module_favicon) {
$favicon = $themeObject->getImageURL($this->module . '.gif', false);
}
if (!sugar_is_file($favicon) || !$module_favicon) {
$favicon = $themeObject->getImageURL('sugar_icon.ico', false);
}
$ss->assign('FAVICON_URL', getJSPath($favicon));
// build the shortcut menu
$shortcut_menu = array();
foreach ($this->getMenu() as $key => $menu_item) {
$shortcut_menu[$key] = array("URL" => $menu_item[0], "LABEL" => $menu_item[1], "MODULE_NAME" => $menu_item[2], "IMAGE" => $themeObject->getImage($menu_item[2], "alt='" . $menu_item[1] . "' border='0' align='absmiddle'"));
}
$ss->assign("SHORTCUT_MENU", $shortcut_menu);
// handle rtl text direction
if (isset($_REQUEST['RTL']) && $_REQUEST['RTL'] == 'RTL') {
$_SESSION['RTL'] = true;
}
if (isset($_REQUEST['LTR']) && $_REQUEST['LTR'] == 'LTR') {
unset($_SESSION['RTL']);
}
if (isset($_SESSION['RTL']) && $_SESSION['RTL']) {
$ss->assign("DIR", 'dir="RTL"');
}
// handle resizing of the company logo correctly on the fly
$companyLogoURL = $themeObject->getImageURL('company_logo.png');
$companyLogoURL_arr = explode('?', $companyLogoURL);
$companyLogoURL = $companyLogoURL_arr[0];
$company_logo_attributes = sugar_cache_retrieve('company_logo_attributes');
if (!empty($company_logo_attributes)) {
$ss->assign("COMPANY_LOGO_MD5", $company_logo_attributes[0]);
$ss->assign("COMPANY_LOGO_WIDTH", $company_logo_attributes[1]);
$ss->assign("COMPANY_LOGO_HEIGHT", $company_logo_attributes[2]);
} else {
// Always need to md5 the file
$ss->assign("COMPANY_LOGO_MD5", md5_file($companyLogoURL));
list($width, $height) = getimagesize($companyLogoURL);
if ($width > 212 || $height > 40) {
$resizePctWidth = ($width - 212) / 212;
$resizePctHeight = ($height - 40) / 40;
if ($resizePctWidth > $resizePctHeight) {
$resizeAmount = $width / 212;
} else {
$resizeAmount = $height / 40;
}
$ss->assign("COMPANY_LOGO_WIDTH", round($width * (1 / $resizeAmount)));
$ss->assign("COMPANY_LOGO_HEIGHT", round($height * (1 / $resizeAmount)));
} else {
$ss->assign("COMPANY_LOGO_WIDTH", $width);
$ss->assign("COMPANY_LOGO_HEIGHT", $height);
}
// Let's cache the results
sugar_cache_put('company_logo_attributes', array($ss->get_template_vars("COMPANY_LOGO_MD5"), $ss->get_template_vars("COMPANY_LOGO_WIDTH"), $ss->get_template_vars("COMPANY_LOGO_HEIGHT")));
}
$ss->assign("COMPANY_LOGO_URL", getJSPath($companyLogoURL) . "&logo_md5=" . $ss->get_template_vars("COMPANY_LOGO_MD5"));
// get the global links
$gcls = array();
$global_control_links = array();
require "include/globalControlLinks.php";
foreach ($global_control_links as $key => $value) {
//.........这里部分代码省略.........
示例15: loadMapping
/**
* Generic load method to load mapping arrays.
*/
private function loadMapping($var, $merge = false)
{
${$var} = sugar_cache_retrieve("CONTROLLER_" . $var . "_" . $this->module);
if (!${$var}) {
if ($merge && !empty($this->{$var})) {
${$var} = $this->{$var};
} else {
${$var} = array();
}
if (file_exists('include/MVC/Controller/' . $var . '.php')) {
require 'include/MVC/Controller/' . $var . '.php';
}
if (file_exists('modules/' . $this->module . '/' . $var . '.php')) {
require 'modules/' . $this->module . '/' . $var . '.php';
}
if (file_exists('custom/modules/' . $this->module . '/' . $var . '.php')) {
require 'custom/modules/' . $this->module . '/' . $var . '.php';
}
if (file_exists('custom/include/MVC/Controller/' . $var . '.php')) {
require 'custom/include/MVC/Controller/' . $var . '.php';
}
sugar_cache_put("CONTROLLER_" . $var . "_" . $this->module, ${$var});
}
$this->{$var} = ${$var};
}