public function setUp() { SugarTestHelper::setUp('current_user', array(true, 1)); SugarTestHelper::setUp('app_list_strings'); SugarTestHelper::setUp('beanFiles'); SugarTestHelper::setUp('beanList'); parent::setUp(); $this->relationships = new DeployedRelationships('Products'); $definition = array('lhs_module' => 'Accounts', 'relationship_type' => 'one-to-many', 'rhs_module' => 'ProjectTask'); $this->relationship = RelationshipFactory::newRelationship($definition); $this->relationships->add($this->relationship); $this->relationships->save(); $this->relationships->build(); SugarTestHelper::setUp('relation', array('Accounts', 'ProjectTask')); $searchDefs = array('layout' => array('advanced_search' => array($this->relationship->getName() . '_name' => array('type' => 'relate', 'link' => true, 'label' => '', 'id' => strtoupper($this->relationship->getJoinKeyLHS()), 'width' => '10%', 'default' => true, 'name' => $this->relationship->getName() . '_name'))), 'templateMeta' => array('maxColumns' => '3', 'maxColumnsBasic' => '4', 'widths' => array('label' => '10', 'field' => '30'))); // Add new field to advanced search layout if (file_exists("custom/modules/ProjectTask/metadata/searchdefs.php")) { $this->_savedSearchDefs = file_get_contents("custom/modules/ProjectTask/metadata/searchdefs.php"); } write_array_to_file("searchdefs['ProjectTask']", $searchDefs, 'custom/modules/ProjectTask/metadata/searchdefs.php'); if (file_exists("modules/ProjectTask/metadata/SearchFields.php")) { $this->_savedSearchFields = file_get_contents("modules/ProjectTask/metadata/SearchFields.php"); } write_array_to_file("searchFields['ProjectTask']", $this->_localSearchFields['ProjectTask'], 'modules/ProjectTask/metadata/SearchFields.php'); // Creates linked test account, project and project task $this->_project = SugarTestProjectUtilities::createProject(); $this->_account = SugarTestAccountUtilities::createAccount(); $projectTaskData = array('project_id' => $this->_project->id, 'parent_task_id' => '', 'project_task_id' => '1', 'percent_complete' => '0', 'name' => 'Test Task 1', 'duration_unit' => 'Days', 'duration' => '1'); $this->_projectTask = SugarTestProjectTaskUtilities::createProjectTask($projectTaskData); $this->_projectTask->{$this->relationship->getName()}->add($this->_account); $this->_projectTask->save(); }
public function run() { if (!version_compare($this->from_version, '7.5.1.0', '<')) { // only need to run this upgrading from pre 7.5.1 versions return; } // get custom modules $customModules = array(); $customFiles = glob('modules' . DIRECTORY_SEPARATOR . '*' . DIRECTORY_SEPARATOR . '*_sugar.php', GLOB_NOSORT); // file header $header = file_get_contents('modules/ModuleBuilder/MB/header.php'); // iterate custom modules foreach ($customFiles as $customFile) { $moduleName = str_replace('_sugar', '', pathinfo($customFile, PATHINFO_FILENAME)); $modulePath = pathinfo($customFile, PATHINFO_DIRNAME) . DIRECTORY_SEPARATOR . 'metadata' . DIRECTORY_SEPARATOR . 'subpanels'; $layoutFiles = glob($modulePath . DIRECTORY_SEPARATOR . '*.php', GLOB_NOSORT); // iterate layout file foreach ($layoutFiles as $layoutFile) { include $layoutFile; if (isset($subpanel_layout) && isset($subpanel_layout['list_fields']) && isset($subpanel_layout['list_fields']['email1'])) { $subpanel_layout['list_fields']['email'] = $subpanel_layout['list_fields']['email1']; $subpanel_layout['list_fields']['email']['name'] = 'email'; unset($subpanel_layout['list_fields']['email1']); write_array_to_file('subpanel_layout', $subpanel_layout, $layoutFile, 'w', $header); } } } }
public function setUp() { global $argv; if (isset($argv)) { $this->original_argv = $argv; } $this->current_working_dir = getcwd(); if (file_exists('config_si.php')) { $this->has_original_config_si_file = true; copy('config_si.php', 'config_si.php.bug40129'); } else { $this->has_original_config_si_file = false; copy('config.php', 'config_si.php'); } $sugar_config_si = array('setup_db_host_name' => 'localhost', 'setup_db_database_name' => 'pineapple', 'setup_db_drop_tables' => 0, 'setup_db_create_database' => 1, 'setup_db_pop_demo_data' => false, 'setup_site_admin_user_name' => 'admin', 'setup_site_admin_password' => 'a', 'setup_db_create_sugarsales_user' => 0, 'setup_db_admin_user_name' => 'root', 'setup_db_admin_password' => '', 'setup_db_sugarsales_user' => 'root', 'setup_db_sugarsales_password' => '', 'setup_db_type' => 'mysql', 'setup_license_key_users' => 100, 'setup_license_key_expire_date' => '2010-12-25', 'setup_license_key_oc_licences' => 1, 'setup_license_key' => 'internal sugar user 20100224', 'setup_site_url' => 'http://localhost/pineapple/build/rome/builds/ent/sugarcrm', 'setup_system_name' => 'pineapple', 'default_currency_iso4217' => 'USD', 'default_currency_name' => 'US Dollars', 'default_currency_significant_digits' => '2', 'default_currency_symbol' => '$', 'default_date_format' => 'Y-m-d', 'default_time_format' => 'H:i', 'default_decimal_seperator' => '.', 'default_export_charset' => 'ISO-8859-1', 'default_language' => 'en_us', 'default_locale_name_format' => 's f l', 'default_number_grouping_seperator' => ',', 'export_delimiter' => ',', 'disable_count_query' => true, 'external_cache_disabled_apc' => true, 'external_cache_disabled_zend' => true, 'external_cache_disabled_memcache' => true, 'external_cache_disabled' => true); write_array_to_file("sugar_config_si", $sugar_config_si, 'config_si.php'); if (file_exists('config.php')) { copy('config.php', 'config.php.bug40129'); include 'config.php'; // remove items since merge_config_si_settings does not merge existing keys foreach ($sugar_config_si as $k => $v) { unset($sugar_config[$k]); } write_array_to_file("sugar_config", $sugar_config, 'config.php'); } }
public function run() { if (!version_compare($this->from_version, '7.2.1', '<')) { // only needed for upgrades from pre-7.2.1 return; } if (!file_exists("custom/include/Sugarpdf/sugarpdf_default.php")) { return; } require "custom/include/Sugarpdf/sugarpdf_default.php"; $rewrite = false; foreach ($this->config_keys as $key) { if (empty($sugarpdf_default[$key])) { continue; } if (strncmp($sugarpdf_default[$key], "include/tcpdf/", 14) === 0) { $sugarpdf_default[$key] = str_replace("include/tcpdf/", "vendor/tcpdf/", $sugarpdf_default[$key]); $rewrite = true; } } if ($rewrite) { $this->log("Writing fixed custom/include/Sugarpdf/sugarpdf_default.php"); write_array_to_file("sugarpdf_default", $sugarpdf_default, "custom/include/Sugarpdf/sugarpdf_default.php"); } }
public function run() { if (version_compare($this->from_version, '7.0', '>=')) { return; } $files = $this->getFilesToProcess(); foreach ($files as $file) { if (!file_exists($file)) { return; } $needUpdate = false; require $file; if (isset($viewdefs['Quotes']['DetailView']['templateMeta']['form']['buttons'])) { $source = $viewdefs['Quotes']['DetailView']['templateMeta']['form']['buttons']; foreach ($source as $i => $item) { if (isset($item['customCode']) && strpos($item['customCode'], 'LBL_VIEW_PDF_BUTTON_LABEL') !== false) { unset($source[$i]); $needUpdate = true; } } if ($needUpdate) { if ($source) { $viewdefs['Quotes']['DetailView']['templateMeta']['form']['buttons'] = array_values($source); } else { unset($viewdefs['Quotes']['DetailView']['templateMeta']['form']['buttons']); } } } if ($needUpdate) { $this->backupFile($file); $this->log("Removed Print as PDF link in {$file}"); write_array_to_file("viewdefs", $viewdefs, $file); } } }
/** * Takes in the request params from a save request and processes * them for the save. * * @param REQUEST params $params */ function saveTabGroups($params) { $tabGroups = array(); $selected_lang = !empty($params['dropdown_lang']) ? $params['dropdown_lang'] : $_SESSION['authenticated_user_language']; for ($count = 0; isset($params['slot_' . $count]); $count++) { if ($params['delete_' . $count] == 1) { continue; } $index = $params['slot_' . $count]; $labelID = !empty($params['tablabelid_' . $index]) ? $params['tablabelid_' . $index] : 'LBL_GROUPTAB' . $count . '_' . time(); $labelValue = $params['tablabel_' . $index]; if (empty($GLOBALS['app_strings'][$labelID]) || $GLOBALS['app_strings'][$labelID] != $labelValue) { $contents = return_custom_app_list_strings_file_contents($selected_lang); $new_contents = replace_or_add_app_string($labelID, $labelValue, $contents); save_custom_app_list_strings_contents($new_contents, $selected_lang); $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]; } } sugar_cache_put('app_strings', $GLOBALS['app_strings']); $newFile = create_custom_directory('include/tabConfig.php'); write_array_to_file("GLOBALS['tabStructure']", $tabGroups, $newFile); $GLOBALS['tabStructure'] = $tabGroups; }
public function run() { if (!version_compare($this->from_version, '7.0', '<')) { // only need to run this upgrading from pre 7.0 versions return; } // get singular module names $my_list_strings = return_app_list_strings_language($GLOBALS['current_language']); $moduleSingular = $my_list_strings['moduleListSingular']; // get custom modules $customModules = array(); $customFiles = glob('modules' . DIRECTORY_SEPARATOR . '*' . DIRECTORY_SEPARATOR . '*_sugar.php', GLOB_NOSORT); // file header $header = file_get_contents('modules/ModuleBuilder/MB/header.php'); // iterate custom modules foreach ($customFiles as $customFile) { $moduleName = str_replace('_sugar', '', pathinfo($customFile, PATHINFO_FILENAME)); $modulePath = pathinfo($customFile, PATHINFO_DIRNAME) . DIRECTORY_SEPARATOR . 'language'; $langFiles = glob($modulePath . DIRECTORY_SEPARATOR . '*.lang.php', GLOB_NOSORT); // iterate language file foreach ($langFiles as $langFile) { // add LBL_MODULE_NAME_SINGULAR if not already there unset($mod_strings); include $langFile; if (isset($mod_strings) && !isset($mod_strings['LBL_MODULE_NAME_SINGULAR']) && isset($moduleSingular[$moduleName])) { $mod_strings['LBL_MODULE_NAME_SINGULAR'] = $moduleSingular[$moduleName]; write_array_to_file('mod_strings', $mod_strings, $langFile, 'w', $header); } } } }
public function run() { if (version_compare($this->from_version, '6.6.2', '>=')) { return; } $files = $this->getFilesToProcess(); foreach ($files as $file) { if (!file_exists($file)) { return; } require $file; if (isset($viewdefs['Quotes']['DetailView']['templateMeta']['form']['links'])) { $data = $viewdefs['Quotes']['DetailView']['templateMeta']['form']['links']; if (count($data) == 1 && strpos($data[0], '$LAYOUT_OPTIONS')) { unset($viewdefs['Quotes']['DetailView']['templateMeta']['form']['links']); } else { foreach ($data as $i => $value) { if (strpos($value, '$LAYOUT_OPTIONS')) { // array_splice() for deleting and re-indexing. array_splice($viewdefs['Quotes']['DetailView']['templateMeta']['form']['links'], $i, 1); } } } } $this->log("Removed obsolete LAYOUT_OPTIONS in {$file}"); write_array_to_file("viewdefs", $viewdefs, $file); } }
/** * Builds the cache of Dashlets by scanning the system */ function buildCache() { global $beanList; $dashletFiles = array(); $dashletFilesCustom = array(); getFiles($dashletFiles, 'modules', '/^.*\\/Dashlets\\/[^\\.]*\\.php$/'); getFiles($dashletFilesCustom, 'custom/modules', '/^.*\\/Dashlets\\/[^\\.]*\\.php$/'); $cacheDir = create_cache_directory('dashlets/'); $allDashlets = array_merge($dashletFiles, $dashletFilesCustom); $dashletFiles = array(); foreach ($allDashlets as $num => $file) { if (substr_count($file, '.meta') == 0) { // ignore meta data files $class = substr($file, strrpos($file, '/') + 1, -4); $dashletFiles[$class] = array(); $dashletFiles[$class]['file'] = $file; $dashletFiles[$class]['class'] = $class; if (is_file(preg_replace('/(.*\\/.*)(\\.php)/Uis', '$1.meta$2', $file))) { // is there an associated meta data file? $dashletFiles[$class]['meta'] = preg_replace('/(.*\\/.*)(\\.php)/Uis', '$1.meta$2', $file); require $dashletFiles[$class]['meta']; if (isset($dashletMeta[$class]['module'])) { $dashletFiles[$class]['module'] = $dashletMeta[$class]['module']; } } $filesInDirectory = array(); getFiles($filesInDirectory, substr($file, 0, strrpos($file, '/')), '/^.*\\/Dashlets\\/[^\\.]*\\.icon\\.(jpg|jpeg|gif|png)$/i'); if (!empty($filesInDirectory)) { $dashletFiles[$class]['icon'] = $filesInDirectory[0]; // take the first icon we see } } } write_array_to_file('dashletsFiles', $dashletFiles, $cacheDir . 'dashlets.php'); }
public function setUp() { global $argv; if (isset($argv)) { $this->original_argv = $argv; } $this->current_working_dir = getcwd(); $sugar_config_si = array('disable_count_query' => true, 'external_cache_disabled_apc' => true, 'external_cache_disabled_zend' => true, 'external_cache_disabled_memcache' => true, 'external_cache_disabled' => true); if (file_exists('config.php')) { copy('config.php', 'config.php.bug37214'); include 'config.php'; // remove items since merge_config_si_settings does not merge existing keys foreach ($sugar_config_si as $k => $v) { unset($sugar_config[$k]); } write_array_to_file("sugar_config", $sugar_config, 'config.php'); } if (file_exists('config_si.php')) { $this->has_original_config_si_file = true; copy('config_si.php', 'config_si.php.bug37214'); } else { $this->has_original_config_si_file = false; copy('config.php', 'config_si.php'); } write_array_to_file("sugar_config_si", $sugar_config_si, 'config_si.php'); }
function get_user_info() { $app_id = $_POST['app_id']; $ajax_response = array('msg' => ''); if (!file_exists($app_id . '_access_token')) { $ajax_response['msg'] = 'access_token not exist'; echo json_encode($ajax_response); } //获取关注者openid列表 $url = 'https://api.weixin.qq.com/cgi-bin/user/get?access_token=' . L($app_id . '_access_token') . '&next_openid=owogBtzPp97oFlUuhKTjPfO7jMq8'; $ret_array = json_decode(http_get($url), true); $file_name = $app_id . '_user_openid_list'; //write_array_to_file($file_name, $ret_array['data']['openid'], $file_name); $ret_array['next_openid'] = 'owogBt8P7Ik7X_toVjFx0pdbd7ds'; while ($ret_array['next_openid'] != '') { $url = 'https://api.weixin.qq.com/cgi-bin/user/get?access_token=' . L($app_id . '_access_token') . '&next_openid=' . $ret_array['next_openid']; $ret_array = json_decode(http_get($url), true); print_r($ret_array); die; write_array_to_file($file_name, $ret_array['data']['openid'], $file_name); } $ajax_response['msg'] = 'get user amount successful'; $ajax_response['amount'] = $ret_array['total']; echo json_encode($ajax_response); }
public function run() { if (version_compare($this->from_version, '7.2.0', '<') || version_compare($this->from_version, '7.2.2', '>=')) { // only need to run this upgrading from 7.2.0 or 7.2.1 return; } $file = 'custom/modules/Emails/clients/base/views/subpanel-for-accounts/subpanel-for-accounts.php'; if (!file_exists($file)) { return; } require $file; $rewrite = false; if (isset($viewdefs['Emails']['base']['view']['subpanel-for-accounts']['panels'][0]['fields'])) { foreach ($viewdefs['Emails']['base']['view']['subpanel-for-accounts']['panels'][0]['fields'] as &$field) { if (isset($field['name']) && $field['name'] == 'name') { if (!isset($field['link'])) { $field['link'] = true; $rewrite = true; } } } } if ($rewrite) { $this->log('Adding link=true to subpanel-for-accounts.php'); write_array_to_file("viewdefs['Emails']['base']['view']['subpanel-for-accounts']", $viewdefs['Emails']['base']['view']['subpanel-for-accounts'], $file); } }
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 run() { // Only run this when coming from a version lower than 7.2.0 if (version_compare($this->from_version, '7.2', '>=')) { return; } // Find all the classes we want to convert. $customModules = $this->getCustomModules(); foreach ($customModules as $moduleName) { $path = $this->getModuleLangPath($moduleName); if (file_exists($path)) { $mod_strings = array(); require $path; $labels = $this->compileLabels($moduleName, $this->missingLabels); $missingLabels = array_diff($labels, array_keys($mod_strings)); if (!empty($missingLabels)) { $this->upgrader->log('FixCustomModuleLabels: Missing import labels for ' . $moduleName . ' module - ' . var_export($missingLabels, true)); $header = file_get_contents('modules/ModuleBuilder/MB/header.php'); $translations = $this->translateLabels($missingLabels, $mod_strings, $moduleName); $this->upgrader->backupFile($path); write_array_to_file('mod_strings', $translations, $path, 'w', $header); $this->upgrader->log('FixCustomModuleLabels: Module ' . $moduleName . '. Saving Complete'); } } } return true; }
public function setUp() { parent::setUp(); //If somehow this package already exists copy it if (file_exists('custom/modules/' . $this->package)) { $this->packageExists = true; mkdir_recursive('custom/modules/' . $this->package . '_bak'); copy_recursive('custom/modules/' . $this->package, 'custom/modules/' . $this->package . '_bak'); } //Make the custom package directory and simulate copying the file in mkdir_recursive('custom/modules/' . $this->package . '/Ext/WirelessLayoutdefs'); $theArray = array($this->package => array('subpanel_setup' => array($this->package . '_accounts' => array('order' => 100, 'module' => 'Contacts', 'subpanel_name' => 'default', 'title_key' => 'LBL_BUG48784TEST', 'get_subpanel_data' => 'Bug48748Test')))); $theFile = 'custom/modules/' . $this->package . '/Ext/WirelessLayoutdefs/wireless.subpaneldefs.ext.php'; write_array_to_file('layout_defs', $theArray, $theFile); sugar_chmod('custom/modules/' . $this->package . '/Ext/WirelessLayoutdefs/wireless.subpaneldefs.ext.php', 0655); global $beanList, $beanFiles, $current_user; //$beanList['Contacts'] = 'Contact'; //$beanFiles['Bug48784Mock'] = 'modules/Contacts/Contact.php'; //Create an anonymous user for login purposes/ $current_user = SugarTestUserUtilities::createAnonymousUser(); $current_user->status = 'Active'; $current_user->is_admin = 1; $current_user->save(); $GLOBALS['db']->commit(); // Making sure we commit any changes before continuing $_SESSION['avail_modules'][$this->package] = 'write'; }
function install_aod() { require_once 'modules/Administration/Administration.php'; global $sugar_config; $sugar_config['aod']['enable_aod'] = true; ksort($sugar_config); write_array_to_file('sugar_config', $sugar_config, 'config.php'); }
/** * When uninstall module delete our config */ public static function del_config() { global $sugar_config; foreach (self::$officeConfigFields as $key) { if (isset($sugar_config[$key])) { unset($sugar_config[$key]); } } ksort($sugar_config); write_array_to_file('sugar_config', $sugar_config, 'config.php'); }
function disableSoftPhone(&$bean, $event, $args) { $clients_list = array(); $clients_list_file_path = 'custom/include/Twilio/clients_list.php'; if (file_exists($clients_list_file_path)) { include $clients_list_file_path; } if (isset($clients_list[md5($bean->id)])) { unset($clients_list[md5($bean->id)]); $write_result = write_array_to_file('clients_list', $clients_list, $clients_list_file_path); } }
public function setUp() { if (file_exists($this->studio_file)) { //This really shouldn't be happening, but just in case... $this->has_notification_studio_file = true; $this->backup_file = $this->studio_file . '.' . gmmktime() . '.bak'; copy($this->studio_file, $this->backup_file); } else { //Create the test file write_array_to_file("test", array(), $this->studio_file); } }
function install_colourSelector() { require_once 'modules/Administration/Administration.php'; global $sugar_config; $sugar_config['colourselector']['version'] = '1.1.0'; if (!isset($sugar_config['colourselector']['navbar'])) { $sugar_config['colourselector']['navbar'] = '#121212'; } if (!isset($sugar_config['colourselector']['navbarfont'])) { $sugar_config['colourselector']['navbarfont'] = '#cccccc'; } if (!isset($sugar_config['colourselector']['navbarlinkhover'])) { $sugar_config['colourselector']['navbarlinkhover'] = '#cccccc'; } if (!isset($sugar_config['colourselector']['pageheader'])) { $sugar_config['colourselector']['pageheader'] = '#f10202'; } if (!isset($sugar_config['colourselector']['pagelink'])) { $sugar_config['colourselector']['pagelink'] = '#f10202'; } if (!isset($sugar_config['colourselector']['dashlet'])) { $sugar_config['colourselector']['dashlet'] = '#777777'; } if (!isset($sugar_config['colourselector']['button1'])) { $sugar_config['colourselector']['button1'] = '#ffffff'; } if (!isset($sugar_config['colourselector']['buttonhover'])) { $sugar_config['colourselector']['buttonhover'] = '#ffffff'; } if (!isset($sugar_config['colourselector']['buttoncolour'])) { $sugar_config['colourselector']['buttoncolour'] = '#121212'; } if (!isset($sugar_config['colourselector']['buttoncolourhover'])) { $sugar_config['colourselector']['buttoncolourhover'] = '#ffffff'; } if (!isset($sugar_config['colourselector']['navbarlihover'])) { $sugar_config['colourselector']['navbarlihover'] = '#565656'; } if (!isset($sugar_config['colourselector']['bavbarhover'])) { $sugar_config['colourselector']['bavbarhover'] = '#ffffff'; } if (!isset($sugar_config['colourselector']['dropdownmenu'])) { $sugar_config['colourselector']['dropdownmenu'] = '#333333'; } if (!isset($sugar_config['colourselector']['dropdownmenulink'])) { $sugar_config['colourselector']['dropdownmenulink'] = '#cccccc'; } ksort($sugar_config); write_array_to_file('sugar_config', $sugar_config, 'config.php'); }
function checkResourceSettings() { if (file_exists(getcwd() . '/config.php')) { require getcwd() . '/config.php'; } global $sugar_config; if (!isset($sugar_config['resource_management'])) { $sugar_config['resource_management'] = array('special_query_limit' => 50000, 'special_query_modules' => array(0 => 'Reports', 1 => 'Export', 2 => 'Import', 3 => 'Administration', 4 => 'Sync'), 'default_limit' => 1000); ksort($sugar_config); if (is_writable('config.php') && write_array_to_file("sugar_config", $sugar_config, 'config.php')) { //writing to the file } } }
/** * Saves $data to the $name dropdown for the $role name * * @param $fieldName * @param $role * @param $data * @return boolean */ public function handleSave($fieldName, $role, $data) { $path = $this->getFilePath($fieldName, $role); $dir = dirname($path); if (!SugarAutoLoader::ensureDir($dir)) { $GLOBALS['log']->error("ParserRoleDropDownFilter :: Cannot create directory {$dir}"); return false; } $result = write_array_to_file("role_dropdown_filters['{$fieldName}']", $this->convertFormData($data), $path); if ($result) { $this->rebuildExtension($role); MetaDataManager::refreshSectionCache(MetaDataManager::MM_EDITDDFILTERS, array(), array('role' => $role)); } return $result; }
public function setUp() { if (file_exists($this->save_file)) { //This really shouldn't be happening, but just in case... $this->has_save_file = true; $this->backup_file = $this->save_file . '.' . gmmktime() . '.bak'; copy($this->save_file, $this->backup_file); } else { if (!file_exists('modules/DocumentRevisions')) { mkdir_recursive('modules/DocumentRevisions'); } //Create the test file write_array_to_file("test", array(), $this->save_file); } }
function install_ss() { //eggsurplus: set up default config options require_once 'sugar_version.php'; require_once 'modules/Administration/Administration.php'; global $sugar_config; /** If this is the first install set some default settings */ if (!array_key_exists('securitysuite_additive', $sugar_config)) { // save securitysuite_additive setting $sugar_config['securitysuite_additive'] = true; // save securitysuite_user_role_precedence setting $sugar_config['securitysuite_user_role_precedence'] = true; // save securitysuite_user_popup setting $sugar_config['securitysuite_user_popup'] = true; // save securitysuite_popup_select setting $sugar_config['securitysuite_popup_select'] = false; // save securitysuite_inherit_creator setting $sugar_config['securitysuite_inherit_creator'] = true; // save securitysuite_inherit_parent setting $sugar_config['securitysuite_inherit_parent'] = true; // save securitysuite_inherit_assigned setting $sugar_config['securitysuite_inherit_assigned'] = true; // save securitysuite_strict_rights setting $sugar_config['securitysuite_strict_rights'] = false; //ksort($sugar_config); //write_array_to_file('sugar_config', $sugar_config, 'config.php'); } if (!array_key_exists('securitysuite_strict_rights', $sugar_config)) { // save securitysuite_strict_rights setting $sugar_config['securitysuite_strict_rights'] = true; //ksort($sugar_config); //write_array_to_file('sugar_config', $sugar_config, 'config.php'); } if (!array_key_exists('securitysuite_filter_user_list', $sugar_config)) { // save securitysuite_filter_user_list setting $sugar_config['securitysuite_filter_user_list'] = false; //ksort($sugar_config); //write_array_to_file('sugar_config', $sugar_config, 'config.php'); } if (!isset($GLOBALS['sugar_config']['addAjaxBannedModules'])) { $GLOBALS['sugar_config']['addAjaxBannedModules'] = array(); } $GLOBALS['sugar_config']['addAjaxBannedModules'][] = 'SecurityGroups'; $sugar_config['securitysuite_version'] = '6.5.17'; ksort($sugar_config); write_array_to_file('sugar_config', $sugar_config, 'config.php'); installSSHooks(); }
public function setUp() { $this->user = SugarTestUserUtilities::createAnonymousUser(); $GLOBALS['current_user'] = $this->user; //Setup logichook files if (file_exists($this->casesHookFile)) { $this->hasCustomCasesLogicHookFile = true; copy($this->casesHookFile, $this->casesHookFile . '.bak'); } $hook_array['after_relationship_add'][] = array(1, 'Cases increment count', $this->casesCountFile, 'CaseCount', 'countMe'); write_array_to_file("hook_array", $hook_array, $this->casesHookFile); $this->useOutputBuffering = false; LogicHook::refreshHooks(); //now write out the script that the logichook executes. This will keep track of times called global $hookRunCount; $hookRunCount = 0; $fileCont = '<?php class CaseCount { function countMe($bean, $event, $arguments){ global $hookRunCount; if($event =="after_relationship_add" && $arguments["module"]=="Cases" && $arguments["related_module"]=="Emails") $hookRunCount++; }}?>'; file_put_contents($this->casesCountFile, $fileCont); //setup test account for case $this->account = new Account(); $this->account->name = 'test account for bug 39855'; $this->account->assigned_user_id = 'SugarUser'; $this->account->save(); //create case $this->case = new aCase(); $this->case->name = 'test case for unitTest 49784'; $this->case->account_id = $this->account->id; $this->case->status = 'New'; $this->case->save(); //retrieve so we have latest info (case number) $this->case->retrieve($this->case->id); //create email with case in subject $this->email = new Email(); $this->email->type = 'inbound'; $this->email->status = 'unread'; $this->email->from_addr_name = $this->email->cleanEmails("*****@*****.**"); $this->email->to_addrs_names = $this->email->cleanEmails("*****@*****.**"); $this->email->cc_addrs_names = $this->email->cleanEmails("*****@*****.**"); $this->email->name = 'RE: [CASE:' . $this->case->case_number . '] ' . $this->case->name; $this->email->save(); }
public function setUp() { //Setup mock logic hook files if (file_exists($this->modulesHookFile)) { $this->hasCustomModulesLogicHookFile = true; copy($this->modulesHookFile, $this->modulesHookFile . '.bak'); } else { write_array_to_file("test", array(), $this->modulesHookFile); } if (file_exists($this->contactsHookFile)) { $this->hasCustomContactLogicHookFile = true; copy($this->contactsHookFile, $this->contactsHookFile . '.bak'); } else { write_array_to_file("test", array(), $this->contactsHookFile); } $this->useOutputBuffering = false; }
function saveSearchFields($searchFields) { if (!empty($this->packageName)) { $header = file_get_contents('modules/ModuleBuilder/MB/header.php'); if (!file_exists("custom/modulebuilder/packages/{$this->packageName}/modules/{$this->moduleName}/metadata/SearchFields.php")) { mkdir_recursive("custom/modulebuilder/packages/{$this->packageName}/modules/{$this->moduleName}/metadata"); } write_array_to_file("searchFields['{$this->packageKey}_{$this->moduleName}']", $searchFields["{$this->packageKey}_{$this->moduleName}"], "custom/modulebuilder/packages/{$this->packageName}/modules/{$this->moduleName}/metadata/SearchFields.php", 'w', $header); } else { $header = file_get_contents('modules/ModuleBuilder/MB/header.php'); if (!file_exists("custom/modules/{$this->moduleName}/metadata/SearchFields.php")) { mkdir_recursive("custom/modules/{$this->moduleName}/metadata"); } write_array_to_file("searchFields['{$this->moduleName}']", $searchFields[$this->moduleName], "custom/modules/{$this->moduleName}/metadata/SearchFields.php", 'w', $header); } $this->searchFields = $searchFields; }
/** * retrives the system's private key; will build one if not found, but anything encrypted before is gone... * @param string type * @return string key */ function blowfishGetKey($type) { $key = array(); $type = str_rot13($type); $keyCache = "{$GLOBALS['sugar_config']['cache_dir']}blowfish/{$type}.php"; // build cache dir if needed if (!file_exists($GLOBALS['sugar_config']['cache_dir'] . 'blowfish')) { mkdir_recursive($GLOBALS['sugar_config']['cache_dir'] . 'blowfish'); } // get key from cache, or build if not exists if (file_exists($keyCache)) { include $keyCache; } else { // create a key $key[0] = create_guid(); write_array_to_file('key', $key, $keyCache); } return $key[0]; }
public function setUp() { global $argv; if (isset($argv)) { $this->original_argv = $argv; } $this->current_working_dir = getcwd(); if (file_exists('config.php')) { copy('config.php', 'config.php.bug37214'); } if (file_exists($this->current_working_dir . DIRECTORY_SEPARATOR . 'config_si.php')) { $this->has_original_config_si_file = true; copy($this->current_working_dir . DIRECTORY_SEPARATOR . 'config_si.php', $this->current_working_dir . DIRECTORY_SEPARATOR . 'config_si.php.bug37214'); } else { $this->has_original_config_si_file = false; copy('config.php', $this->current_working_dir . DIRECTORY_SEPARATOR . 'config_si.php'); } $sugar_config_si = array('disable_count_query' => true, 'external_cache_disabled_apc' => true, 'external_cache_disabled_zend' => true, 'external_cache_disabled_memcache' => true, 'external_cache_disabled' => true); write_array_to_file("sugar_config_si", $sugar_config_si, $this->current_working_dir . DIRECTORY_SEPARATOR . 'config_si.php'); }
/** * @return string * @throws Exception */ protected function getPidFilePath() { $cachePath = config('crm.cache_dir') . 'modules/Schedulers'; $pid = 'pid.php'; $pidFilePath = $cachePath . DIRECTORY_SEPARATOR . $pid; if (!is_dir($cachePath)) { mkdir_recursive($cachePath); } if (!is_file($pidFilePath)) { if (!is_writable($cachePath)) { throw new Exception('Scheduler cannot write PID file. Please check permissions on ' . $pidFilePath); } write_array_to_file('timestamp', [strtotime(date('H:i'))], $pidFilePath); } else { if (!is_writable($pidFilePath)) { throw new Exception('Scheduler cannot read the PID file. Please check permissions on ' . $pidFilePath); } } return $pidFilePath; }