static function buildActionCache($silent = true) { if (!is_dir(ActionFactory::$action_directory)) { return false; } // First get a list of all the files in this directory. $entries = array(); $actions = array(); $javascript = ""; foreach (SugarAutoLoader::getFilesCustom(ActionFactory::$action_directory) as $path) { $entry = basename($path); if (strtolower(substr($entry, -4)) != ".php" || in_array($entry, ActionFactory::$exclude_files)) { continue; } require_once $path; $className = substr($entry, 0, strlen($entry) - 4); $actionName = call_user_func(array($className, "getActionName")); $actions[$actionName] = array('class' => $className, 'file' => $path); $javascript .= call_user_func(array($className, "getJavascriptClass")); if (!$silent) { echo "added action {$actionName} <br/>"; } } if (empty($actions)) { return ""; } create_cache_directory("Expressions/actions_cache.php"); write_array_to_file('actions', $actions, sugar_cached('Expressions/actions_cache.php')); ActionFactory::$loaded_actions = $actions; return $javascript; }
public function setUp() { //Just need base class but its abstract so we use the google implementation for this test. $this->extAPI = new ExtAPIGoogle(); $this->fileData1 = sugar_cached('unittest'); file_put_contents($this->fileData1, "Unit test for mime type"); }
public function tearDown() { $GLOBALS['db']->query("DELETE FROM contacts WHERE id= '{$this->_contact->id}'"); unset($this->_contact); if ($this->_hasUnifiedSearchModulesConfig) { copy(sugar_cached('modules/unified_search_modules.php.bak'), sugar_cached('modules/unified_search_modules.php')); unlink(sugar_cached('modules/unified_search_modules.php.bak')); } else { unlink(sugar_cached('modules/unified_search_modules.php')); } if ($this->_hasUnifiedSearchModulesDisplay) { copy('custom/modules/unified_search_modules_display.php.bak', 'custom/modules/unified_search_modules_display.php'); unlink('custom/modules/unified_search_modules_display.php.bak'); } else { unlink('custom/modules/unified_search_modules_display.php'); } SugarTestUserUtilities::removeAllCreatedAnonymousUsers(); if (isset($_REQUEST['module'])) { unset($_REQUEST['module']); } if (isset($_REQUEST['query_string'])) { unset($_REQUEST['query_string']); } if (isset($_REQUEST['enabled_modules'])) { unset($_REQUEST['enabled_modules']); } }
public function run() { if (is_file(sugar_cached('dashlets/dashlets.php'))) { unlink(sugar_cached('dashlets/dashlets.php')); } require_once 'include/Dashlets/DashletCacheBuilder.php'; $dc = new DashletCacheBuilder(); $dc->buildCache(); }
public function setUp() { $this->testdir = sugar_cached("tests/include/utils/ziptest"); sugar_mkdir($this->testdir . '/testarchive', null, true); sugar_touch($this->testdir . '/testarchive/testfile1.txt'); sugar_touch($this->testdir . '/testarchive/testfile2.txt'); sugar_touch($this->testdir . '/testarchive/testfile3.txt'); sugar_mkdir($this->testdir . '/testarchiveoutput', null, true); }
function extractFile($zip_file, $file_in_zip) { global $base_tmp_upgrade_dir; if (empty($base_tmp_upgrade_dir)) { $base_tmp_upgrade_dir = sugar_cached("upgrades/temp"); } $my_zip_dir = mk_temp_dir($base_tmp_upgrade_dir); unzip_file($zip_file, $file_in_zip, $my_zip_dir); return "{$my_zip_dir}/{$file_in_zip}"; }
public static function extractFile($zip_file, $file_in_zip) { global $base_tmp_upgrade_dir; if (empty($base_tmp_upgrade_dir)) { $base_tmp_upgrade_dir = sugar_cached("upgrades/temp"); } $my_zip_dir = mk_temp_dir($base_tmp_upgrade_dir); register_shutdown_function('rmdir_recursive', $my_zip_dir); unzip_file($zip_file, $file_in_zip, $my_zip_dir); return "{$my_zip_dir}/{$file_in_zip}"; }
public function setUp() { if (!class_exists('ZipArchive')) { $this->markTestSkipped('ZipArchive class not loaded'); } $this->testdir = sugar_cached("tests/include/utils/ziptest"); sugar_mkdir($this->testdir . '/testarchive', null, true); sugar_touch($this->testdir . '/testarchive/testfile1.txt'); sugar_touch($this->testdir . '/testarchive/testfile2.txt'); sugar_touch($this->testdir . '/testarchive/testfile3.txt'); sugar_mkdir($this->testdir . '/testarchiveoutput', null, true); }
function create_cache_directory($file) { $paths = explode('/', $file); $dir = rtrim(sugar_cached(""), '/'); if (!file_exists($dir)) { sugar_mkdir($dir, 0775); } for ($i = 0; $i < sizeof($paths) - 1; $i++) { $dir .= '/' . $paths[$i]; if (!file_exists($dir)) { sugar_mkdir($dir, 0775); } } return $dir . '/' . $paths[sizeof($paths) - 1]; }
function __construct() { global $sugar_config; $config = HTMLPurifier_Config::createDefault(); if (!is_dir(sugar_cached("htmlclean"))) { create_cache_directory("htmlclean/"); } $config->set('HTML.Doctype', 'XHTML 1.0 Transitional'); $config->set('Core.Encoding', 'UTF-8'); $hidden_tags = array('script' => true, 'style' => true, 'title' => true, 'head' => true); $config->set('Core.HiddenElements', $hidden_tags); $config->set('Cache.SerializerPath', sugar_cached("htmlclean")); $config->set('URI.Base', $sugar_config['site_url']); $config->set('CSS.Proprietary', true); $config->set('HTML.TidyLevel', 'light'); $config->set('HTML.ForbiddenElements', array('body' => true, 'html' => true)); $config->set('AutoFormat.RemoveEmpty', false); $config->set('Cache.SerializerPermissions', 0775); // for style //$config->set('Filter.ExtractStyleBlocks', true); $config->set('Filter.ExtractStyleBlocks.TidyImpl', false); // can't use csstidy, GPL if (!empty($GLOBALS['sugar_config']['html_allow_objects'])) { // for object $config->set('HTML.SafeObject', true); // for embed $config->set('HTML.SafeEmbed', true); } $config->set('Output.FlashCompat', true); // for iframe and xmp $config->set('Filter.Custom', array(new HTMLPurifier_Filter_Xmp())); // for link $config->set('HTML.DefinitionID', 'Sugar HTML Def'); $config->set('HTML.DefinitionRev', 2); $config->set('Cache.SerializerPath', sugar_cached('htmlclean/')); // IDs are namespaced $config->set('Attr.EnableID', true); $config->set('Attr.IDPrefix', 'sugar_text_'); if ($def = $config->maybeGetRawHTMLDefinition()) { $form = $def->addElement('link', 'Flow', 'Empty', 'Core', array('href*' => 'URI', 'rel' => 'Enum#stylesheet', 'type' => 'Enum#text/css')); $iframe = $def->addElement('iframe', 'Flow', 'Optional: #PCDATA | Flow | Block', 'Core', array('src*' => 'URI', 'frameborder' => 'Enum#0,1', 'marginwidth' => 'Pixels', 'marginheight' => 'Pixels', 'scrolling' => 'Enum#|yes,no,auto', 'align' => 'Enum#top,middle,bottom,left,right,center', 'height' => 'Length', 'width' => 'Length')); $iframe->excludes = array('iframe'); } $uri = $config->getDefinition('URI'); $uri->addFilter(new SugarURIFilter(), $config); HTMLPurifier_URISchemeRegistry::instance()->register('cid', new HTMLPurifier_URIScheme_cid()); $this->purifier = new HTMLPurifier($config); }
function display() { global $app_strings, $current_user, $mod_strings, $theme, $beanList, $beanFiles; if (!is_file($cachefile = sugar_cached('Expressions/functionmap.php'))) { $GLOBALS['updateSilent'] = true; include 'include/Expressions/updatecache.php'; } include $cachefile; require_once 'include/JSON.php'; $desc = ""; if (!empty($_REQUEST['function']) && !empty($FUNCTION_MAP[$_REQUEST['function']])) { $func_def = $FUNCTION_MAP[$_REQUEST['function']]; require_once $func_def['src']; $class = new ReflectionClass($func_def['class']); $doc = $class->getDocComment(); if (!empty($doc)) { //Remove the javadoc style comment *'s $desc = preg_replace("/((\\/\\*+)|(\\*+\\/)|(\n\\s*\\*)[^\\/])/", "", $doc); } else { if (isset($mod_strings['func_descriptions'][$_REQUEST['function']])) { $desc = $mod_strings['func_descriptions'][$_REQUEST['function']]; } else { $seed = $func_def['class']; $count = call_user_func(array($seed, "getParamCount")); $type = call_user_func(array($seed, "getParameterTypes")); $desc = $_REQUEST['function'] . "("; if ($count == -1) { $desc .= $type . ", ..."; } else { for ($i = 0; $i < $count; $i++) { if ($i != 0) { $desc .= ", "; } if (is_array($type)) { $desc .= $type[$i] . ($i + 1); } else { $desc .= $type . ($i + 1); } } } $desc .= ")"; } } } else { $desc = "function not found"; } echo json_encode(array("func" => empty($_REQUEST['function']) ? "" : $_REQUEST['function'], "desc" => $desc)); }
public function testSugarCacheFile() { if (file_exists(sugar_cached("testevil.php"))) { @unlink(sugar_cached("testevil.php")); } $obj = 'test'; try { $obj = unserialize('O:14:"SugarCacheFile":3:{s:13:"_cacheChanged";b:1;s:14:"_cacheFileName";s:12:"testevil.php";s:11:"_localStore";b:1;}'); } catch (Exception $e) { $obj = null; } $this->assertNull($obj); unset($obj); // call dtor if object created $this->assertFileNotExists(sugar_cached("testevil.php")); }
public function __construct() { $this->queue = new SugarJobQueue(); $this->lockfile = sugar_cached("modules/Schedulers/lastrun"); if (!empty($GLOBALS['sugar_config']['cron']['max_cron_jobs'])) { $this->max_jobs = $GLOBALS['sugar_config']['cron']['max_cron_jobs']; } if (!empty($GLOBALS['sugar_config']['cron']['max_cron_runtime'])) { $this->max_runtime = $GLOBALS['sugar_config']['cron']['max_cron_runtime']; } if (isset($GLOBALS['sugar_config']['cron']['min_cron_interval'])) { $this->min_interval = $GLOBALS['sugar_config']['cron']['min_cron_interval']; } if (isset($GLOBALS['sugar_config']['cron']['enforce_runtime'])) { $this->enforceHardLimit = $GLOBALS['sugar_config']['cron']['enforce_runtime']; } }
/** * Retrieves the requested js language file, building it if it doesn't exist. */ function getJSLanguage() { require_once 'include/language/jsLanguage.php'; global $app_list_strings; if (empty($_REQUEST['lang'])) { echo "No language specified"; return; } $lang = clean_path($_REQUEST['lang']); $languages = get_languages(); if (!preg_match("/^\\w\\w_\\w\\w\$/", $lang) || !isset($languages[$lang])) { if (!preg_match("/^\\w\\w_\\w\\w\$/", $lang)) { echo "did not match regex<br/>"; } else { echo "{$lang} was not in list . <pre>" . print_r($languages, true) . "</pre>"; } echo "Invalid language specified"; return; } if (empty($_REQUEST['module']) || $_REQUEST['module'] === 'app_strings') { $file = sugar_cached('jsLanguage/') . $lang . '.js'; if (!sugar_is_file($file)) { $jsLanguage = new jsLanguage(); $jsLanguage->createAppStringsCache($lang); } } else { $module = clean_path($_REQUEST['module']); $fullModuleList = array_merge($GLOBALS['moduleList'], $GLOBALS['modInvisList']); if (!isset($app_list_strings['moduleList'][$module]) && !in_array($module, $fullModuleList)) { echo "Invalid module specified"; return; } $file = sugar_cached('jsLanguage/') . $module . "/" . $lang . '.js'; if (!sugar_is_file($file)) { jsLanguage::createModuleStringsCache($module, $lang); } } //Setup cache headers header("Content-Type: application/javascript"); header("Cache-Control: max-age=31556940, private"); header("Pragma: "); header("Expires: " . gmdate('D, d M Y H:i:s \\G\\M\\T', time() + 31556940)); readfile($file); }
/** * loads SearchFields MetaData, sets member variables * * @param string $module moduleDir * @param bean $seedBean seed bean to use * @param string $tpl template to use, defaults to moduleDir/SearchForm.html * */ function SearchForm($module, $seedBean, $tpl = null) { global $app_strings; $this->module = $module; $searchFields = SugarAutoLoader::loadSearchFields($module); $this->searchFields = $searchFields[$module]; if (empty($tpl)) { if (!empty($GLOBALS['layout_edit_mode'])) { $this->tpl = sugar_cached('studio/custom/working/modules/' . $module . '/SearchForm.html'); } else { $this->tpl = get_custom_file_if_exists('modules/' . $module . '/SearchForm.html'); } } else { $this->tpl = $tpl; } $this->bean = $seedBean; $this->tabs = array(array('title' => $app_strings['LNK_BASIC_SEARCH'], 'link' => $module . '|basic_search', 'key' => $module . '|basic_search'), array('title' => $app_strings['LNK_ADVANCED_SEARCH'], 'link' => $module . '|advanced_search', 'key' => $module . '|advanced_search')); if (SugarAutoLoader::fileExists('modules/' . $this->module . '/index.php')) { $this->tabs[] = array('title' => $app_strings['LNK_SAVED_VIEWS'], 'link' => $module . '|saved_views', 'key' => $module . '|saved_views'); } }
public function tearDown() { if (isset($GLOBALS['listViewDefs'])) { unset($GLOBALS['listViewDefs']); } if (isset($GLOBALS['viewdefs'])) { unset($GLOBALS['viewdefs']); } unset($GLOBALS['app_list_strings']); unset($GLOBALS['app_strings']); unset($GLOBALS['mod_strings']); if (!empty($this->unified_search_modules_content)) { file_put_contents(sugar_cached('modules/unified_search_modules.php'), $this->unified_search_modules_content); } $GLOBALS['db']->query("DELETE FROM accounts WHERE name like 'UNIT TEST%' "); $GLOBALS['db']->query("DELETE FROM opportunities WHERE name like 'UNIT TEST%' "); $GLOBALS['db']->query("DELETE FROM contacts WHERE first_name like 'UNIT TEST%' "); $GLOBALS['db']->query("DELETE FROM calls WHERE name like 'UNIT TEST%' "); $GLOBALS['db']->query("DELETE FROM tasks WHERE name like 'UNIT TEST%' "); $GLOBALS['db']->query("DELETE FROM meetings WHERE name like 'UNIT TEST%' "); }
function addDashlet() { if (!is_file(sugar_cached('dashlets/dashlets.php'))) { require_once 'include/Dashlets/DashletCacheBuilder.php'; $dc = new DashletCacheBuilder(); $dc->buildCache(); } require_once sugar_cached('dashlets/dashlets.php'); global $current_user; if (isset($_REQUEST['id'])) { $pages = $current_user->getPreference('pages', $this->type); $dashlets = $current_user->getPreference('dashlets', $this->type); $guid = create_guid(); $options = array(); if (isset($_REQUEST['type']) && $_REQUEST['type'] == 'web') { $dashlet_module = 'Home'; require_once 'include/Dashlets/DashletRssFeedTitle.php'; $options['url'] = $_REQUEST['type_module']; $webDashlet = new DashletRssFeedTitle($options['url']); $options['title'] = $webDashlet->generateTitle(); unset($webDashlet); } elseif (!empty($_REQUEST['type_module'])) { $dashlet_module = $_REQUEST['type_module']; } elseif (isset($dashletsFiles[$_REQUEST['id']]['module'])) { $dashlet_module = $dashletsFiles[$_REQUEST['id']]['module']; } else { $dashlet_module = 'Home'; } $dashlets[$guid] = array('className' => $dashletsFiles[$_REQUEST['id']]['class'], 'module' => $dashlet_module, 'options' => $options, 'fileLocation' => $dashletsFiles[$_REQUEST['id']]['file']); if (!array_key_exists('current_tab', $_SESSION)) { $_SESSION["current_tab"] = '0'; } array_unshift($pages[$_SESSION['current_tab']]['columns'][0]['dashlets'], $guid); $current_user->setPreference('dashlets', $dashlets, 0, $this->type); echo $guid; } else { echo 'ofdaops'; } }
function process_page() { global $theme; global $mod_strings; global $app_strings; global $currentModule; global $current_language; global $current_module_strings; if (!is_file(sugar_cached('jsLanguage/WorkFlow/') . $GLOBALS['current_language'] . '.js')) { require_once 'include/language/jsLanguage.php'; jsLanguage::createModuleStringsCache('WorkFlow', $GLOBALS['current_language']); } $javascript_language_files = getVersionedScript("cache/jsLanguage/WorkFlow/{$GLOBALS['current_language']}.js", $GLOBALS['sugar_config']['js_lang_version']); $current_module_strings = return_module_language($current_language, 'WorkFlowAlertShells'); $ListView = new ListView(); $header_text = ''; if (isset($_REQUEST['workflow_id'])) { $workflow = BeanFactory::getBean('WorkFlow', $_REQUEST['workflow_id']); //TODO GET ALL ALERTS HERE //$focus_alerts_list = $workflow->get_linked_beans('wf_alerts','WorkFlowAlertShell'); $alerts = BeanFactory::getBean('WorkFlowAlertShells'); $current_module_strings = return_module_language($current_language, $alerts->module_dir); insert_popup_header($theme); $ListView->initNewXTemplate('modules/WorkFlowAlertShells/Popup_picker.html', $current_module_strings); $ListView->xTemplateAssign("WORKFLOW_ID", $workflow->id); $ListView->xTemplateAssign("JAVASCRIPT_LANGUAGE_FILES", $javascript_language_files); $ListView->xTemplateAssign("RETURN_URL", "&return_module=" . $currentModule . "&return_action=DetailView&return_id={$workflow->id}"); $ListView->xTemplateAssign("EDIT_INLINE_PNG", SugarThemeRegistry::current()->getImage('edit_inline', 'align="absmiddle" border="0"', null, null, '.gif', $app_strings['LNK_EDIT'])); $ListView->xTemplateAssign("DELETE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline', 'align="absmiddle" border="0"', null, null, '.gif', $app_strings['LNK_REMOVE'])); $ListView->setHeaderTitle($current_module_strings['LBL_MODULE_NAME_COMBO'] . $header_text); //$ListView->setHeaderText($button); //$ListView->setQuery("workflow_alertshells.alert_type = 'Email'","","", "ALERT"); $list = $alerts->get_list("", "workflow_alertshells.alert_type = 'Email'"); $display_list = $this->cullFromList($list['list'], $workflow->base_module, $workflow->type); $ListView->processListViewTwo($display_list, "main", "ALERT"); insert_popup_footer(); } }
public function testSilentUpgradeSessionVars() { require_once 'modules/UpgradeWizard/uw_utils.php'; $varsCacheFileName = sugar_cached("/silentUpgrader/silentUpgradeCache.php"); $loaded = loadSilentUpgradeVars(); $this->assertTrue($loaded, "Could not load the silent upgrade vars"); global $silent_upgrade_vars_loaded; $this->assertTrue(!empty($silent_upgrade_vars_loaded), "\$silent_upgrade_vars_loaded array should not be empty"); $set = setSilentUpgradeVar('SDizzle', 'BSnizzle'); $this->assertTrue($set, "Could not set a silent upgrade var"); $get = getSilentUpgradeVar('SDizzle'); $this->assertEquals('BSnizzle', $get, "Unexpected value when getting silent upgrade var before resetting"); $write = writeSilentUpgradeVars(); $this->assertTrue($write, "Could not write the silent upgrade vars to the cache file. Function returned false"); $this->assertFileExists($varsCacheFileName, "Cache file doesn't exist after call to writeSilentUpgradeVars()"); $output = shell_exec("php {$this->externalTestFileName}"); $this->assertEquals('BSnizzle', $output, "Running custom script didn't successfully retrieve the value"); $remove = removeSilentUpgradeVarsCache(); $this->assertTrue(empty($silent_upgrade_vars_loaded), "Silent upgrade vars variable should have been unset in removeSilentUpgradeVarsCache() call"); $this->assertFileNotExists($varsCacheFileName, "Cache file exists after call to removeSilentUpgradeVarsCache()"); $get = getSilentUpgradeVar('SDizzle'); $this->assertNotEquals('BSnizzle', $get, "Unexpected value when getting silent upgrade var after resetting"); }
/** * This method will look for a file modules_post_install.php in the root directory and based on the * contents of this file, it will silently install any modules as specified in this array. */ function post_install_modules() { if (is_file('modules_post_install.php')) { global $current_user, $mod_strings; $current_user = new User(); $current_user->is_admin = '1'; require_once 'ModuleInstall/PackageManager/PackageManager.php'; require_once 'modules_post_install.php'; //we now have the $modules_to_install array in memory $pm = new PackageManager(); $old_mod_strings = $mod_strings; foreach ($modules_to_install as $module_to_install) { if (is_file($module_to_install)) { $pm->performSetup($module_to_install, 'module', false); $file_to_install = sugar_cached('upload/upgrades/module/') . basename($module_to_install); $_REQUEST['install_file'] = $file_to_install; $pm->performInstall($file_to_install); } } $mod_strings = $old_mod_strings; } }
function preflightCheckJsonDiffFiles($persistence) { global $sugar_version; global $mod_strings; if (empty($sugar_version)) { require 'sugar_version.php'; } // get md5 sums $md5_string = array(); $finalZipDir = $persistence['unzip_dir'] . '/' . $persistence['zip_from_dir']; if (is_file(getcwd() . '/files.md5')) { require getcwd() . '/files.md5'; } // initialize pass array $manualDiff = array(); // file preflight checks logThis('verifying md5 checksums for files...'); $cache_html_files = findAllFilesRelative(sugar_cached("layout"), array()); foreach ($persistence['upgrade_files'] as $file) { if (strpos($file, '.md5')) { continue; } // skip md5 file // normalize file paths $file = clean_path($file); // check that we can move/delete the upgraded file if (!is_writable($file)) { $errors[] = $mod_strings['ERR_UW_FILE_NOT_WRITABLE'] . ": " . $file; } // check that destination files are writable $destFile = getcwd() . str_replace($finalZipDir, '', $file); if (is_file($destFile)) { // of course it needs to exist first... if (!is_writable($destFile)) { $errors[] = $mod_strings['ERR_UW_FILE_NOT_WRITABLE'] . ": " . $destFile; } } /////////////////////////////////////////////////////////////////////// //// DIFFS // compare md5s and build up a manual merge list $targetFile = clean_path("." . str_replace(getcwd(), '', $destFile)); $targetMd5 = '0'; if (is_file($destFile)) { if (strpos($targetFile, '.php')) { // handle PHP files that were hit with the security regex $filesize = filesize($destFile); if ($filesize > 0) { $fileContents = file_get_contents($destFile); $targetMd5 = md5($fileContents); } } else { $targetMd5 = md5_file($destFile); } } if (isset($md5_string[$targetFile]) && $md5_string[$targetFile] != $targetMd5) { logThis('found a file with a differing md5: [' . $targetFile . ']'); $manualDiff[] = $destFile; } //// END DIFFS /////////////////////////////////////////////////////////////////////// echo "."; } logThis('md5 verification done.'); $persistence['manual'] = $manualDiff; $persistence['diff_errors'] = $errors; return $persistence; }
} //delete cache/modules before rebuilding the relations //Clean modules from cache $cachedir = sugar_cached('modules'); if (is_dir($cachedir)) { $allModFiles = array(); $allModFiles = findAllFiles($cachedir, $allModFiles); foreach ($allModFiles as $file) { //$file_md5_ref = str_replace(clean_path(getcwd()),'',$file); if (file_exists($file)) { unlink($file); } } } //delete cache/themes $cachedir = sugar_cached('themes'); if (is_dir($cachedir)) { $allModFiles = array(); $allModFiles = findAllFiles($cachedir, $allModFiles); foreach ($allModFiles as $file) { //$file_md5_ref = str_replace(clean_path(getcwd()),'',$file); if (file_exists($file)) { unlink($file); } } } ob_start(); if (!isset($_REQUEST['silent'])) { $_REQUEST['silent'] = true; } else { if (isset($_REQUEST['silent']) && $_REQUEST['silent'] != true) {
* * 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. If the display of the logo is not reasonably feasible for * technical reasons, the Appropriate Legal Notices must display the words * "Powered by SugarCRM". ********************************************************************************/ //Request object must have these property values: // Module: module name, this module should have a file called TreeData.php // Function: name of the function to be called in TreeData.php, the function will be called statically. // PARAM prefixed properties: array of these property/values will be passed to the function as parameter. require_once 'include/JSON.php'; require_once 'include/upload_file.php'; $GLOBALS['log']->debug(print_r($_FILES, true)); $file_ext_allow = FALSE; if (!is_dir($cachedir = sugar_cached('images/'))) { mkdir_recursive($cachedir); } // cn: bug 11012 - fixed some MIME types not getting picked up. Also changed array iterator. $imgType = array('image/gif', 'image/png', 'image/x-png', 'image/bmp', 'image/jpeg', 'image/jpg', 'image/pjpeg'); $ret = array(); foreach ($_FILES as $k => $file) { if (in_array(strtolower($_FILES[$k]['type']), $imgType)) { $dest = $cachedir . $_FILES[$k]['name']; if (is_uploaded_file($_FILES[$k]['tmp_name'])) { move_uploaded_file($_FILES[$k]['tmp_name'], $dest); $ret[] = $dest; } } } if (!empty($ret)) {
function action_saveconfig() { global $current_user; if (!is_admin($current_user)) { sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']); } $configurator = new Configurator(); if ($configurator->saveConfig() === false) { $this->errors = ['company_logo' => $configurator->getError()]; $this->view = 'edit'; return; } $focus = new Administration(); $focus->saveConfig(); // Clear the Contacts file b/c portal flag affects rendering if (file_exists($cachedfile = sugar_cached('modules/Contacts/EditView.tpl'))) { unlink($cachedfile); } SugarApplication::redirect('index.php?module=Administration&action=index'); }
//////////////////////////////////////////////////////// $form = new XTemplate('modules/WorkFlowTriggerShells/CreateStepFilter.html'); $js_include = getVersionedScript('cache/include/javascript/sugar_grp1.js') . getVersionedScript('include/workflow/jutils.js'); $log->debug("using file modules/WorkFlowTriggerShells/CreateStepFilter.html"); //Bug 12335: We need to include the javascript language file first. And also the language file in WorkFlow is needed. if (!is_file(sugar_cached('jsLanguage/') . $GLOBALS['current_language'] . '.js')) { require_once 'include/language/jsLanguage.php'; jsLanguage::createAppStringsCache($GLOBALS['current_language']); } $javascript_language_files = getVersionedScript("cache/jsLanguage/{$GLOBALS['current_language']}.js", $GLOBALS['sugar_config']['js_lang_version']); if (!is_file(sugar_cached('jsLanguage/') . $this->module . '/' . $GLOBALS['current_language'] . '.js')) { require_once 'include/language/jsLanguage.php'; jsLanguage::createModuleStringsCache($this->module, $GLOBALS['current_language']); } $javascript_language_files .= getVersionedScript("cache/jsLanguage/{$this->module}/{$GLOBALS['current_language']}.js", $GLOBALS['sugar_config']['js_lang_version']); if (!is_file(sugar_cached('jsLanguage/WorkFlow/') . $GLOBALS['current_language'] . '.js')) { require_once 'include/language/jsLanguage.php'; jsLanguage::createModuleStringsCache('WorkFlow', $GLOBALS['current_language']); } $javascript_language_files .= getVersionedScript("cache/jsLanguage/WorkFlow/{$GLOBALS['current_language']}.js", $GLOBALS['sugar_config']['js_lang_version']); $the_javascript = "<script type='text/javascript' language='JavaScript'>\n"; $the_javascript .= "function set_return() {\n"; $the_javascript .= " window.opener.document.EditView.submit();"; $the_javascript .= "}\n"; $the_javascript .= "</script>\n"; $form->assign("MOD", $mod_strings); $form->assign("APP", $app_strings); $form->assign('JS_INCLUDE', $js_include); $form->assign("JAVASCRIPT_LANGUAGE_FILES", $javascript_language_files); $form->assign("MODULE_NAME", $currentModule); $form->assign("GRIDLINE", $gridline);
/** * wrapper function to return the html code containing the chart in a div * * @param string $name name of the div * string $xmlFile location of the XML file * string $style optional additional styles for the div * @return string returns the html code through smarty */ function display($name, $xmlFile, $width = '320', $height = '480', $resize = false) { // generate strings for chart if it does not exist global $current_language, $theme, $sugar_config, $app_strings; $this->app_strings = $app_strings; $this->chartStringsXML = sugar_cached("xml/") . 'chart_strings.' . $current_language . '.lang.xml'; if (!file_exists($this->chartStringsXML)) { $this->generateChartStrings($this->chartStringsXML); } $templateFile = ""; return $templateFile; }
if (isset($logged_user['id']) && $logged_user['id'] != null) { //do nothing $current_user->retrieve($logged_user['id']); } else { echo "Not an admin user in users table. Please provide an admin user\n"; exit(1); } } else { echo "*******************************************************************************\n"; echo "*** ERROR: 4th parameter must be a valid admin user.\n"; echo $usage; echo "FAILURE\n"; exit(1); } /////retrieve admin user $unzip_dir = sugar_cached("upgrades/temp"); $install_file = $sugar_config['upload_dir'] . "/upgrades/patch/" . basename($argv[1]); sugar_mkdir($sugar_config['upload_dir'] . "/upgrades/patch", 0775, true); $_SESSION['unzip_dir'] = $unzip_dir; $_SESSION['install_file'] = $install_file; $_SESSION['zip_from_dir'] = $zip_from_dir; mkdir_recursive($unzip_dir); if (!is_dir($unzip_dir)) { fwrite(STDERR, "\n{$unzip_dir} is not an available directory\nFAILURE\n"); exit(1); } unzip($argv[1], $unzip_dir); // mimic standard UW by copy patch zip to appropriate dir copy($argv[1], $install_file); //// END UPGRADE PREP ///////////////////////////////////////////////////////////////////////////////
/** * saves the actual binary file of a given attachment * @param object attach Note object that is attached to the binary file * @param string msgNo Message Number on IMAP/POP3 server * @param string thisBc Breadcrumb to navigate email structure to find the content * @param object part IMAP standard object that contains the "parts" of this section of email * @param bool $forDisplay */ function saveAttachmentBinaries($attach, $msgNo, $thisBc, $part, $forDisplay) { // decide where to place the file temporarily $uploadDir = $forDisplay ? "{$this->EmailCachePath}/{$this->id}/attachments/" : "upload://"; // decide what name to save file as $fileName = $attach->id; // download the attachment if we didn't do it yet if (!file_exists($uploadDir . $fileName)) { $msgPartRaw = imap_fetchbody($this->conn, $msgNo, $thisBc); // deal with attachment encoding and decode the text string $msgPart = $this->handleTranserEncoding($msgPartRaw, $part->encoding); if (file_put_contents($uploadDir . $fileName, $msgPart)) { $GLOBALS['log']->debug('InboundEmail saved attachment file: ' . $attach->filename); } else { $GLOBALS['log']->debug('InboundEmail could not create attachment file: ' . $attach->filename . " - temp file target: [ {$uploadDir}{$fileName} ]"); return; } } $this->tempAttachment[$fileName] = urldecode($attach->filename); // if all was successful, feel for inline and cache Note ID for display: if (strtolower($part->disposition) == 'inline' && in_array($part->subtype, $this->imageTypes) || $part->type == 5) { if (copy($uploadDir . $fileName, sugar_cached("images/{$fileName}.") . strtolower($part->subtype))) { $id = substr($part->id, 1, -1); //strip <> around $this->inlineImages[$id] = $attach->id . "." . strtolower($part->subtype); } else { $GLOBALS['log']->debug('InboundEmail could not copy ' . $uploadDir . $fileName . ' to cache'); } } }
/** * Given a list of modules to search and a search string, return the id, module_name, along with the fields * We will support Accounts, Bug Tracker, Cases, Contacts, Leads, Opportunities, Project, ProjectTask, Quotes * * @param string $session - Session ID returned by a previous call to login. * @param string $search_string - string to search * @param string[] $modules - array of modules to query * @param int $offset - a specified offset in the query * @param int $max_results - max number of records to return * @param string $assigned_user_id - a user id to filter all records by, leave empty to exclude the filter * @param string[] $select_fields - An array of fields to return. If empty the default return fields will be from the active list view defs. * @param bool $unified_search_only - A boolean indicating if we should only search against those modules participating in the unified search. * @param bool $favorites - A boolean indicating if we should only search against records marked as favorites. * @return Array return_search_result - Array('Accounts' => array(array('name' => 'first_name', 'value' => 'John', 'name' => 'last_name', 'value' => 'Do'))) * @exception 'SoapFault' -- The SOAP error, if any */ function search_by_module($session, $search_string, $modules, $offset, $max_results, $assigned_user_id = '', $select_fields = array(), $unified_search_only = TRUE, $favorites = FALSE) { $GLOBALS['log']->info('Begin: SugarWebServiceImpl->search_by_module'); global $beanList, $beanFiles; global $sugar_config, $current_language; $error = new SoapError(); $output_list = array(); if (!self::$helperObject->checkSessionAndModuleAccess($session, 'invalid_session', '', '', '', $error)) { $error->set_error('invalid_login'); $GLOBALS['log']->error('End: SugarWebServiceImpl->search_by_module - FAILED on checkSessionAndModuleAccess'); return; } global $current_user; if ($max_results > 0) { $sugar_config['list_max_entries_per_page'] = $max_results; } require_once 'modules/Home/UnifiedSearchAdvanced.php'; require_once 'include/utils.php'; $usa = new UnifiedSearchAdvanced(); if (!file_exists($cachefile = sugar_cached('modules/unified_search_modules.php'))) { $usa->buildCache(); } include $cachefile; $modules_to_search = array(); $unified_search_modules['Users'] = array('fields' => array()); $unified_search_modules['ProjectTask'] = array('fields' => array()); //If we are ignoring the unified search flag within the vardef we need to re-create the search fields. This allows us to search //against a specific module even though it is not enabled for the unified search within the application. if (!$unified_search_only) { foreach ($modules as $singleModule) { if (!isset($unified_search_modules[$singleModule])) { $newSearchFields = array('fields' => self::$helperObject->generateUnifiedSearchFields($singleModule)); $unified_search_modules[$singleModule] = $newSearchFields; } } } foreach ($unified_search_modules as $module => $data) { if (in_array($module, $modules)) { $modules_to_search[$module] = $beanList[$module]; } // if } // foreach $GLOBALS['log']->info('SugarWebServiceImpl->search_by_module - search string = ' . $search_string); if (!empty($search_string) && isset($search_string)) { $search_string = trim($GLOBALS['db']->quote(securexss(from_html(clean_string($search_string, 'UNIFIED_SEARCH'))))); foreach ($modules_to_search as $name => $beanName) { $where_clauses_array = array(); $unifiedSearchFields = array(); foreach ($unified_search_modules[$name]['fields'] as $field => $def) { $unifiedSearchFields[$name][$field] = $def; $unifiedSearchFields[$name][$field]['value'] = $search_string; } require_once $beanFiles[$beanName]; $seed = new $beanName(); require_once 'include/SearchForm/SearchForm2.php'; if ($beanName == "User" || $beanName == "ProjectTask") { if (!self::$helperObject->check_modules_access($current_user, $seed->module_dir, 'read')) { continue; } // if if (!$seed->ACLAccess('ListView')) { continue; } // if } if ($beanName != "User" && $beanName != "ProjectTask") { $searchForm = new SearchForm($seed, $name); $searchForm->setup(array($name => array()), $unifiedSearchFields, '', 'saved_views'); $where_clauses = $searchForm->generateSearchWhere(); require_once 'include/SearchForm/SearchForm2.php'; $searchForm = new SearchForm($seed, $name); $searchForm->setup(array($name => array()), $unifiedSearchFields, '', 'saved_views'); $where_clauses = $searchForm->generateSearchWhere(); $emailQuery = false; $where = ''; if (count($where_clauses) > 0) { $where = '(' . implode(' ) OR ( ', $where_clauses) . ')'; } $mod_strings = return_module_language($current_language, $seed->module_dir); if (count($select_fields) > 0) { $filterFields = $select_fields; } else { if (file_exists('custom/modules/' . $seed->module_dir . '/metadata/listviewdefs.php')) { require_once 'custom/modules/' . $seed->module_dir . '/metadata/listviewdefs.php'; } else { require_once 'modules/' . $seed->module_dir . '/metadata/listviewdefs.php'; } $filterFields = array(); foreach ($listViewDefs[$seed->module_dir] as $colName => $param) { if (!empty($param['default']) && $param['default'] == true) { $filterFields[] = strtolower($colName); } } if (!in_array('id', $filterFields)) { $filterFields[] = 'id'; } } //Pull in any db fields used for the unified search query so the correct joins will be added $selectOnlyQueryFields = array(); foreach ($unifiedSearchFields[$name] as $field => $def) { if (isset($def['db_field']) && !in_array($field, $filterFields)) { $filterFields[] = $field; $selectOnlyQueryFields[] = $field; } } //Add the assigned user filter if applicable if (!empty($assigned_user_id) && isset($seed->field_defs['assigned_user_id'])) { $ownerWhere = $seed->getOwnerWhere($assigned_user_id); $where = "({$where}) AND {$ownerWhere}"; } if ($beanName == "Employee") { $where = "({$where}) AND users.deleted = 0 AND users.is_group = 0 AND users.employee_status = 'Active'"; } $list_params = array(); $ret_array = $seed->create_new_list_query('', $where, $filterFields, $list_params, 0, '', true, $seed, true); if (empty($params) or !is_array($params)) { $params = array(); } if (!isset($params['custom_select'])) { $params['custom_select'] = ''; } if (!isset($params['custom_from'])) { $params['custom_from'] = ''; } if (!isset($params['custom_where'])) { $params['custom_where'] = ''; } if (!isset($params['custom_order_by'])) { $params['custom_order_by'] = ''; } $main_query = $ret_array['select'] . $params['custom_select'] . $ret_array['from'] . $params['custom_from'] . $ret_array['where'] . $params['custom_where'] . $ret_array['order_by'] . $params['custom_order_by']; } else { if ($beanName == "User") { $filterFields = array('id', 'user_name', 'first_name', 'last_name', 'email_address'); $main_query = "select users.id, ea.email_address, users.user_name, first_name, last_name from users "; $main_query = $main_query . " LEFT JOIN email_addr_bean_rel eabl ON eabl.bean_module = '{$seed->module_dir}'\n LEFT JOIN email_addresses ea ON (ea.id = eabl.email_address_id) "; $main_query = $main_query . "where ((users.first_name like '{$search_string}') or (users.last_name like '{$search_string}') or (users.user_name like '{$search_string}') or (ea.email_address like '{$search_string}')) and users.deleted = 0 and users.is_group = 0 and users.employee_status = 'Active'"; } // if if ($beanName == "ProjectTask") { $filterFields = array('id', 'name', 'project_id', 'project_name'); $main_query = "select {$seed->table_name}.project_task_id id,{$seed->table_name}.project_id, {$seed->table_name}.name, project.name project_name from {$seed->table_name} "; $seed->add_team_security_where_clause($main_query); $main_query .= "LEFT JOIN teams ON {$seed->table_name}.team_id=teams.id AND (teams.deleted=0) "; $main_query .= "LEFT JOIN project ON {$seed->table_name}.project_id = project.id "; $main_query .= "where {$seed->table_name}.name like '{$search_string}%'"; } // if } // else $GLOBALS['log']->info('SugarWebServiceImpl->search_by_module - query = ' . $main_query); if ($max_results < -1) { $result = $seed->db->query($main_query); } else { if ($max_results == -1) { $limit = $sugar_config['list_max_entries_per_page']; } else { $limit = $max_results; } $result = $seed->db->limitQuery($main_query, $offset, $limit + 1); } $rowArray = array(); while ($row = $seed->db->fetchByAssoc($result)) { $nameValueArray = array(); foreach ($filterFields as $field) { if (in_array($field, $selectOnlyQueryFields)) { continue; } $nameValue = array(); if (isset($row[$field])) { $nameValueArray[$field] = self::$helperObject->get_name_value($field, $row[$field]); } // if } // foreach $rowArray[] = $nameValueArray; } // while $output_list[] = array('name' => $name, 'records' => $rowArray); } // foreach $GLOBALS['log']->info('End: SugarWebServiceImpl->search_by_module'); return array('entry_list' => $output_list); } // if return array('entry_list' => $output_list); }
}else{ $options_str .=' >'. $row['name'] .'</option>'; } } //populate the dropdown $xtpl->assign("MKT_DROP_DOWN",$options_str); */ //add chart $seps = array("-", "/"); $dates = array(date($GLOBALS['timedate']->dbDayFormat), $GLOBALS['timedate']->dbDayFormat); $dateFileNameSafe = str_replace($seps, "_", $dates); $cache_file_name_roi = $current_user->getUserPrivGuid() . "_campaign_response_by_roi_" . $dateFileNameSafe[0] . "_" . $dateFileNameSafe[1] . ".xml"; $chart = new campaign_charts(); //ob_start(); //if marketing id has been selected, then set "latest_marketing_id" to the selected value //latest marketing id will be passed in to filter the charts and subpanels if (!empty($selected_marketing_id)) { $latest_marketing_id = $selected_marketing_id; } if (empty($latest_marketing_id) || $latest_marketing_id === 'all') { $xtpl->assign("MY_CHART_ROI", $chart->campaign_response_roi_popup($app_list_strings['roi_type_dom'], $app_list_strings['roi_type_dom'], $campaign_id, sugar_cached("xml/") . $cache_file_name_roi, true)); } else { $xtpl->assign("MY_CHART_ROI", $chart->campaign_response_roi_popup($app_list_strings['roi_type_dom'], $app_list_strings['roi_type_dom'], $campaign_id, sugar_cached("xml/") . $cache_file_name_roi, true)); } //$output_html .= ob_get_contents(); //ob_end_clean(); //_ppd($xtpl); //end chart $xtpl->parse("main"); $xtpl->out("main");