function save($file, $data) { mkdir_recursive($file); $fh = fopen($file, 'w') or print "can't open file"; fwrite($fh, $data); fclose($fh); }
public static function setupFiles($modules, $files, $custom_directory) { self::$modules = $modules; self::$files = $files; self::$has_dir = array(); foreach (self::$modules as $module) { if (!file_exists("custom/modules/{$module}/metadata")) { mkdir_recursive("custom/modules/{$module}/metadata", true); } if (file_exists("custom/modules/{$module}")) { self::$has_dir[$module] = true; } foreach (self::$files as $file) { if (file_exists("custom/modules/{$module}/metadata/{$file}")) { copy("custom/modules/{$module}/metadata/{$file}.php", "custom/modules/{$module}/metadata/{$file}.php.bak"); } if (file_exists("custom/modules/{$module}/metadata/{$file}.php.suback.php")) { copy("custom/modules/{$module}/metadata/{$file}.php.suback.php", "custom/modules/{$module}/metadata/{$file}.php.suback.bak"); } if (file_exists("{$custom_directory}/custom/modules/{$module}/metadata/{$file}.php")) { copy("{$custom_directory}/custom/modules/{$module}/metadata/{$file}.php", "custom/modules/{$module}/metadata/{$file}.php"); } } //foreach } //foreach }
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'; }
public function setUp() { if (file_exists('custom/modules/Opportunities/metadata/SearchFields.php')) { $this->hasExistingCustomSearchFields = true; copy('custom/modules/Opportunities/metadata/SearchFields.php', 'custom/modules/Opportunities/metadata/SearchFields.php.bak'); unlink('custom/modules/Opportunities/metadata/SearchFields.php'); } else { if (!file_exists('custom/modules/Opportunities/metadata')) { mkdir_recursive('custom/modules/Opportunities/metadata'); } } //Setup Opportunities module and date_closed field $_REQUEST['view_module'] = 'Opportunities'; $_REQUEST['name'] = 'date_closed'; $templateDate = new TemplateDate(); $templateDate->enable_range_search = true; $templateDate->populateFromPost(); include 'custom/modules/Opportunities/metadata/SearchFields.php'; //Prepare SearchForm $seed = new Opportunity(); $module = 'Opportunities'; $this->searchForm = new SearchForm($seed, $module); $this->searchForm->searchFields = array('range_date_closed' => array('query_type' => 'default', 'enable_range_search' => 1, 'is_date_field' => 1, 'value' => '[this_year]', 'operator' => 'this_year'), 'start_range_date_closed' => array('query_type' => 'default', 'enable_range_search' => 1, 'is_date_field' => 1), 'end_range_date_closed' => array('query_type' => 'default', 'enable_range_search' => 1, 'is_date_field' => 1), 'range_amount' => array('query_type' => 'default', 'enable_range_search' => true), 'start_range_amount' => array('query_type' => 'default', 'enable_range_search' => true), 'end_range_amount' => array('query_type' => 'default', 'enable_range_search' => true)); $this->originalDbType = $GLOBALS['db']->dbType; }
public function download($save_to_file, $post_data = array()) { // DOWNLOAD USES CURL AS GUZZLE DOWNLOAD DOES NOT WORK // http://stackoverflow.com/questions/16939794/copy-remote-file-using-guzzle // https://gist.github.com/romainneutron/5340930 if ($save_to_file != false) { $dn = dirname($save_to_file); if (!is_dir($dn)) { mkdir_recursive($dn); } if (is_dir($dn)) { $url = $this->url; if (function_exists('set_time_limit')) { @set_time_limit(0); } $fp = fopen($save_to_file, 'w+'); //This is the file where we save the information $ch = curl_init(str_replace(' ', '%20', $url)); //Here is the file we are downloading, replace spaces with %20 curl_setopt($ch, CURLOPT_TIMEOUT, 120); curl_setopt($ch, CURLOPT_FILE, $fp); // write curl response to file curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_exec($ch); // get curl response curl_close($ch); fclose($fp); } } }
function __construct($previewFilename) { $GLOBALS['log']->debug(get_class($this) . "->__construct( {$previewFilename} )"); $this->_previewFilename = $previewFilename; $this->_list = array(); $this->_dirname = dirname($this->_previewFilename); // create the history directory if it does not already exist if (!is_dir($this->_dirname)) { mkdir_recursive($this->_dirname); } $this->_basename = basename($this->_previewFilename); // Reconstruct the history from the saved files foreach (scandir($this->_dirname) as $filename) { if ($filename != "." && $filename != "..") { // history files are of the form {$basename}_{$timestamp} if (preg_match('/(' . $this->_basename . ')_(.*)/', $filename, $matches) == 1) { $this->_list[$matches[2]] = $matches[2]; } } } // now sort the files, oldest first if (count($this->_list) > 0) { ksort($this->_list); } }
public function __construct($previewFilename) { $GLOBALS['log']->debug(get_class($this) . "->__construct( {$previewFilename} )"); $this->_previewFilename = $previewFilename; $this->_list = array(); $this->_basename = basename($this->_previewFilename); $this->_dirname = dirname($this->_previewFilename); $this->_historyLimit = isset($GLOBALS['sugar_config']['studio_max_history']) ? $GLOBALS['sugar_config']['studio_max_history'] : 50; // create the history directory if it does not already exist if (!is_dir($this->_dirname)) { mkdir_recursive($this->_dirname); } else { // Reconstruct the history from the saved files $filenameList = glob($this->getFileByTimestamp('*')); if (!empty($filenameList)) { foreach ($filenameList as $filename) { if (preg_match('/(\\d+)$/', $filename, $match)) { $this->_list[] = $match[1]; } } } } // now sort the files, oldest first if (count($this->_list) > 0) { sort($this->_list); } }
function setUp() { $this->modules = array('Leads'); $this->has_dir = array(); foreach ($this->modules as $module) { if (!file_exists("custom/modules/{$module}/metadata")) { mkdir_recursive("custom/modules/{$module}/metadata", true); } if (file_exists("custom/modules/{$module}")) { $this->has_dir[$module] = true; } $files = array('detailviewdefs', 'editviewdefs'); foreach ($files as $file) { if (file_exists("custom/modules/{$module}/metadata/{$file}")) { copy("custom/modules/{$module}/metadata/{$file}.php", "custom/modules/{$module}/metadata/{$file}.php.bak"); } if (file_exists("custom/modules/{$module}/metadata/{$file}.php.suback.php")) { copy("custom/modules/{$module}/metadata/{$file}.php.suback.php", "custom/modules/{$module}/metadata/{$file}.php.suback.bak"); } if (file_exists("tests/modules/UpgradeWizard/SugarMerge/metadata_files/custom/modules/{$module}/metadata/{$file}.php")) { copy("tests/modules/UpgradeWizard/SugarMerge/metadata_files/custom/modules/{$module}/metadata/{$file}.php", "custom/modules/{$module}/metadata/{$file}.php"); } } //foreach } //foreach }
public function setUp() { global $beanList, $beanFiles, $dictionary; //Add entries to simulate custom module $beanList['Bug44030_TestPerson'] = 'Bug44030_TestPerson'; $beanFiles['Bug44030_TestPerson'] = 'modules/Bug44030_TestPerson/Bug44030_TestPerson.php'; VardefManager::loadVardef('Contacts', 'Contact'); $dictionary['Bug44030_TestPerson'] = $dictionary['Contact']; //Copy over custom SearchFields.php file if (!file_exists('custom/modules/Bug44030_TestPerson/metadata')) { mkdir_recursive('custom/modules/Bug44030_TestPerson/metadata'); } if ($fh = @fopen('custom/modules/Bug44030_TestPerson/metadata/SearchFields.php', 'w+')) { $string = <<<EOQ <?php \$searchFields['Bug44030_TestPerson']['email'] = array( 'query_type' => 'default', 'operator' => 'subquery', 'subquery' => 'SELECT eabr.bean_id FROM email_addr_bean_rel eabr JOIN email_addresses ea ON (ea.id = eabr.email_address_id) WHERE eabr.deleted=0 AND ea.email_address LIKE', 'db_field' => array('id',), 'vname' =>'LBL_ANY_EMAIL', ); ?> EOQ; fputs($fh, $string); fclose($fh); } //Remove the cached unified_search_modules.php file $this->unified_search_modules_file = $GLOBALS['sugar_config']['cache_dir'] . 'modules/unified_search_modules.php'; if (file_exists($this->unified_search_modules_file)) { copy($this->unified_search_modules_file, $this->unified_search_modules_file . '.bak'); unlink($this->unified_search_modules_file); } }
public function __construct() { parent::__construct(); if (!file_exists(SUGAR_SMARTY_DIR)) { mkdir_recursive(SUGAR_SMARTY_DIR, true); } if (!file_exists(SUGAR_SMARTY_DIR . 'templates_c')) { mkdir_recursive(SUGAR_SMARTY_DIR . 'templates_c', true); } if (!file_exists(SUGAR_SMARTY_DIR . 'configs')) { mkdir_recursive(SUGAR_SMARTY_DIR . 'configs', true); } if (!file_exists(SUGAR_SMARTY_DIR . 'cache')) { mkdir_recursive(SUGAR_SMARTY_DIR . 'cache', true); } $this->template_dir = '.'; $this->compile_dir = SUGAR_SMARTY_DIR . 'templates_c'; $this->config_dir = SUGAR_SMARTY_DIR . 'configs'; $this->cache_dir = SUGAR_SMARTY_DIR . 'cache'; $this->request_use_auto_globals = true; // to disable Smarty from using long arrays if (file_exists('custom/include/Smarty/plugins')) { $plugins_dir[] = 'custom/include/Smarty/plugins'; } $plugins_dir[] = 'include/Smarty/plugins'; $this->plugins_dir = $plugins_dir; $this->assign("VERSION_MARK", getVersionedPath('')); }
function Sugar_Smarty() { if (!file_exists(SUGAR_SMARTY_DIR)) { mkdir_recursive(SUGAR_SMARTY_DIR, true); } if (!file_exists(SUGAR_SMARTY_DIR . 'templates_c')) { mkdir_recursive(SUGAR_SMARTY_DIR . 'templates_c', true); } if (!file_exists(SUGAR_SMARTY_DIR . 'configs')) { mkdir_recursive(SUGAR_SMARTY_DIR . 'configs', true); } if (!file_exists(SUGAR_SMARTY_DIR . 'cache')) { mkdir_recursive(SUGAR_SMARTY_DIR . 'cache', true); } $this->template_dir = '.'; $this->compile_dir = SUGAR_SMARTY_DIR . 'templates_c'; $this->config_dir = SUGAR_SMARTY_DIR . 'configs'; $this->cache_dir = SUGAR_SMARTY_DIR . 'cache'; $this->request_use_auto_globals = true; // to disable Smarty from using long arrays $plugins_dir = array('include/Smarty/plugins'); if (file_exists('custom/include/Smarty/plugins')) { $plugins_dir[] = 'custom/include/Smarty/plugins'; } $this->plugins_dir = $plugins_dir; }
function getTableRow($record, $value, $formType) { global $preSaveTempId, $SETTINGS, $menu; $prefixText = @$this->fieldPrefix; $description = @$this->description; if ($prefixText) { $prefixText .= "<br/>"; } // create uploadList url $uploadList = "?menu=" . urlencode($menu) . "&action=uploadList" . "&fieldName=" . urlencode($this->name) . "&num=" . urlencode(@$_REQUEST['num']) . "&preSaveTempId=" . urlencode($preSaveTempId) . "&formType=" . urlencode($formType); // create uploadLink url $uploadLink = "?menu=" . urlencode($menu) . "&action=uploadForm" . "&fieldName=" . urlencode($this->name) . "&num=" . urlencode(@$_REQUEST['num']) . "&preSaveTempId=" . urlencode($preSaveTempId) . "&TB_iframe=true&height=350&width=700&modal=true"; // error checking $errors = ''; $uploadDir = @$this->useCustomUploadDir ? $this->customUploadDir : $SETTINGS['uploadDir']; if (!file_exists($uploadDir)) { mkdir_recursive($uploadDir, 0755); } // create upload dir (if not possible, dir not exists error will show below) if (!file_exists($uploadDir)) { $errors .= "Upload directory '" . htmlencode($uploadDir) . "' doesn't exist!.<br/>\n"; } elseif (!is_writable($uploadDir)) { $errors .= "Upload directory '" . htmlencode($uploadDir) . "' isn't writable!.<br/>\n"; } // display errors if ($errors) { $html = <<<__HTML__ <tr> <td valign="top"><br/>{$this->label}<br/></td> <td><div id='alert'><span>{$errors}</span></div></td> </tr> __HTML__; return $html; } // display field $html = ''; $html .= "<tr>\n"; $html .= " <td style='vertical-align: top'>{$this->label}</td>\n"; $html .= " <td>\n"; $html .= " {$prefixText}\n"; $html .= " <iframe id='{$this->name}_iframe' src='{$uploadList}' height='100' width='100%' frameborder='0' class='uploadIframe'></iframe><br/>\n"; // show upload buttons if ($formType == 'edit') { $html .= " <div style='position: relative; height: 24px;'>\n"; $html .= " <div style='position: absolute; top: 6px; width: 100%; text-align: center;'>\n"; $html .= " <a href='{$uploadLink}' class='thickbox'><b>" . t('Add or Upload File(s)') . "</b></a>\n"; $html .= " </div>\n"; $html .= " <div style='position: absolute; z-index: 1; width: 100%; text-align: center;'>\n"; $html .= " <div id='{$this->name}_uploadButton'></div>\n"; $html .= " </div>\n"; $html .= " </div>\n"; $html .= $this->_getFlashUploaderHTML(); } else { $html .= "<br/>"; } $html .= " </td>\n"; $html .= "</tr>\n"; return $html; }
public static function setUpBeforeClass() { $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser(); $GLOBALS['current_user']->is_admin = "1"; $GLOBALS['current_language'] = "en_us"; $GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']); $GLOBALS['mod_strings'] = return_module_language($GLOBALS['current_language'], 'Administration'); mkdir_recursive("cache/ExtTest"); }
public function setUp() { if (file_exists($this->file)) { $this->customConnectors = file_get_contents($this->file); } else { mkdir_recursive('custom/modules/Connectors/metadata'); file_put_contents($this->file, '<?php '); } }
function setUp() { if (file_exists($this->tableDictionaryExtFile1)) { copy($this->tableDictionaryExtFile1, $this->tableDictionaryExtFile1 . '.backup'); unlink($this->tableDictionaryExtFile1); } else { if (!file_exists('custom/Extension/application/Ext/TableDictionary')) { mkdir_recursive('custom/Extension/application/Ext/TableDictionary'); } } if ($fh = @fopen($this->tableDictionaryExtFile1, 'w+')) { $string = <<<EOQ <?php //WARNING: The contents of this file are auto-generated include('custom/metadata/bug43208Test_productsMetaData.php'); //WARNING: The contents of this file are auto-generated include('custom/Extension/application/Ext/TableDictionary/Bug43208_module.php'); ?> EOQ; fputs($fh, $string); fclose($fh); } if (file_exists($this->tableDictionaryExtFile2)) { copy($this->tableDictionaryExtFile2, $this->tableDictionaryExtFile2 . '.backup'); unlink($this->tableDictionaryExtFile2); } else { if (!file_exists('custom/application/Ext/TableDictionary')) { mkdir_recursive('custom/application/Ext/TableDictionary'); } } if ($fh = @fopen($this->tableDictionaryExtFile2, 'w+')) { $string = <<<EOQ <?php //WARNING: The contents of this file are auto-generated include('custom/metadata/bug43208Test_productsMetaData.php'); //WARNING: The contents of this file are auto-generated include('custom/Extension/application/Ext/TableDictionary/Bug43208_module.php'); ?> EOQ; fputs($fh, $string); fclose($fh); } if ($fh = @fopen($this->corruptExtModuleFile, 'w+')) { $string = <<<EOQ <?php //WARNING: The contents of this file are auto-generated \tinclude( "custom/metadata/bug43208Test_productsMetaData.php" ); ?> EOQ; fputs($fh, $string); fclose($fh); } }
function setUp() { if (file_exists($this->custom_path . '/connectors.php')) { $this->custom_contents = file_get_contents($this->custom_path . '/connectors.php'); unlink($this->custom_path . '/connectors.php'); } else { mkdir_recursive($this->custom_path); } }
/** * Migrate the old custom dropdown filters into the new location. * Will no-op if the destination directory already exists */ public function moveDropdownFilters() { $src_dir = 'custom/include/dropdown_filters'; $dst_dir = 'custom/Extension/application/Ext/DropdownFilters'; if (is_dir($src_dir) && !file_exists($dst_dir)) { mkdir_recursive('custom/Extension/application/Ext'); rename($src_dir, $dst_dir); } }
public function setUp() { $this->mock = new Bug49991SugarViewMock(); mkdir_recursive('custom/modules/Connectors/tpls'); if (file_exists('custom/modules/Connectors/tpls/source_properties.tpl')) { $this->sourceBackup = file_get_contents('custom/modules/Connectors/tpls/source_properties.tpl'); } copy('modules/Connectors/tpls/source_properties.tpl', 'custom/modules/Connectors/tpls/source_properties.tpl'); }
public function setUp() { $GLOBALS['app'] = new SugarApplication(); $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser(); $this->sugar_config_old = $GLOBALS['sugar_config']; $_REQUEST['user_name'] = 'foo'; $_REQUEST['user_password'] = '******'; $_SESSION['authenticated_user_id'] = true; $_SESSION['hasExpiredPassword'] = false; $_SESSION['isMobile'] = null; $GLOBALS['sugar_config']['authenticationClass'] = 'SAMLAuthenticate'; $GLOBALS['sugar_config']['SAML_X509Cert'] = 'Bug50936_X509Cert'; //Create the custom directory if it does not exist if (!is_dir('custom/modules/Users/authentication/SAMLAuthenticate')) { mkdir_recursive('custom/modules/Users/authentication/SAMLAuthenticate'); } $contents = <<<EOQ <?php require(get_custom_file_if_exists('modules/Users/authentication/SAMLAuthenticate/settings.php')); require('modules/Users/authentication/SAMLAuthenticate/lib/onelogin/saml.php'); \$authrequest = new SamlAuthRequest(get_saml_settings()); \$url = \$authrequest->create(); echo \$url; EOQ; file_put_contents('custom/modules/Users/authentication/SAMLAuthenticate/index.php', $contents); $contents = <<<EOQ <?php function get_saml_settings() { // this function should be modified to return the SAML settings for the current use \$settings = new SamlSettings(); // when using Service Provider Initiated SSO (starting at index.php), this URL asks the IdP to authenticate the user. \$settings->idp_sso_target_url = 'www.sugarcrm.com'; // the certificate for the users account in the IdP \$settings->x509certificate = \$GLOBALS['sugar_config']['SAML_X509Cert']; // The URL where to the SAML Response/SAML Assertion will be posted \$settings->assertion_consumer_service_url = \$GLOBALS['sugar_config']['site_url']. "/index.php?module=Users&action=Authenticate"; // Name of this application \$settings->issuer = "php-saml"; // Tells the IdP to return the email address of the current user \$settings->name_identifier_format = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"; return \$settings; } ?> EOQ; if (file_exists('custom/modules/Users/authentication/SAMLAuthenticate/settings.php')) { $this->customContents = file_get_contents('custom/modules/Users/authentication/SAMLAuthenticate/settings.php'); } file_put_contents('custom/modules/Users/authentication/SAMLAuthenticate/settings.php', $contents); }
/** * Scan Smarty plugins directories and relocate custom plugins to correct location */ public function replaceCustomSmartyPlugins() { // Step 1: scan vendor/Smarty/plugin directory to get a list of system plugins $vendorSmartyPluginsList = array(); $vendorSmartyPluginsPath = 'vendor/Smarty/plugins/'; $failedToCopySmartyPluginsList = array(); $customSmartyPluginsPaths = array('include/Smarty/plugins/', 'custom/include/Smarty/plugins/'); $includeSmartyPluginsPath = 'include/SugarSmarty/plugins/'; $correctCustomSmartyPluginsPath = 'custom/include/SugarSmarty/plugins/'; if (is_dir($vendorSmartyPluginsPath)) { $iter = new FilesystemIterator($vendorSmartyPluginsPath, FilesystemIterator::UNIX_PATHS); foreach ($iter as $item) { if ($item->getFileName() == '.' || $item->getFileName() == '..' || $item->isDir() || $item->getExtension() != 'php') { continue; } $filename = $item->getFilename(); $vendorSmartyPluginsList[] = $filename; } } // Step 2: scan custom plugin directories and relocate ONLY custom plugins to correct location foreach ($customSmartyPluginsPaths as $customSmartyPluginsPath) { if (is_dir($customSmartyPluginsPath)) { $iter = new FilesystemIterator($customSmartyPluginsPath, FilesystemIterator::UNIX_PATHS); foreach ($iter as $item) { if ($item->getFilename() == '.' || $item->getFilename() == '..' || $item->isDir() || $item->getExtension() != 'php') { continue; } $file = $item->getPathname(); if (!in_array($item->getFilename(), $vendorSmartyPluginsList) && !is_file($includeSmartyPluginsPath . $item->getFilename())) { $this->log("Copy custom plugin {$file} to {$correctCustomSmartyPluginsPath}"); if (!sugar_is_dir($correctCustomSmartyPluginsPath)) { mkdir_recursive($correctCustomSmartyPluginsPath); } if (copy_recursive($file, $correctCustomSmartyPluginsPath . $item->getFilename())) { $this->upgrader->fileToDelete($file); } else { $failedToCopySmartyPluginsList[] = $file; } } } } } //Step 3: remove all files from custom Smarty plugins destinations except the {$correctCustomSmartyPluginsPath} if (empty($failedToCopySmartyPluginsList)) { foreach ($customSmartyPluginsPaths as $customSmartyPluginsPath) { if (is_dir($customSmartyPluginsPath)) { $this->log("Path {$customSmartyPluginsPath} is deleted from custom plugins directory due to a relocation of vendors"); rmdir_recursive($customSmartyPluginsPath); } } } else { foreach ($failedToCopySmartyPluginsList as $failedToCopySmartyPluginsItem) { $this->log("File {$failedToCopySmartyPluginsItem} cannot be copied to new location automatically"); } } }
public function setUp() { if (!is_dir('custom/modules/Import/maps')) { mkdir_recursive('custom/modules/Import/maps'); } file_put_contents($this->customMappingFile, '<?php class ImportMapCustomTestImportToken { } '); file_put_contents($this->customMappingFile2, '<?php class ImportMapTestImportToken { } '); file_put_contents($this->customMappingFile3, '<?php class ImportMapOther { } '); file_put_contents($this->outOfBoxTestFile, '<?php class ImportMapTestImportTokenOutOfBox { } '); }
function setUp() { SugarTestHelper::setUp('app_strings'); if (file_exists($this->custom_path . '/connectors.php')) { $this->custom_contents = file_get_contents($this->custom_path . '/connectors.php'); unlink($this->custom_path . '/connectors.php'); } else { mkdir_recursive($this->custom_path); } }
public function setUp() { if (file_exists('custom/modules/Accounts/metadata/SearchFields.php')) { copy('custom/modules/Accounts/metadata/SearchFields.php', 'custom/modules/Accounts/metadata/SearchFields.php.bak'); } else { if (!file_exists('custom/modules/Accounts/metadata')) { mkdir_recursive('custom/modules/Accounts/metadata'); } } }
public function setUp() { if (file_exists('custom/modules/Opportunities/metadata/SearchFields.php')) { $this->hasExistingCustomSearchFields = true; copy('custom/modules/Opportunities/metadata/SearchFields.php', 'custom/modules/Opportunities/metadata/SearchFields.php.bak'); unlink('custom/modules/Opportunities/metadata/SearchFields.php'); } else { if (!file_exists('custom/modules/Opportunities/metadata')) { mkdir_recursive('custom/modules/Opportunities/metadata'); } } }
function prepSystemForUpgradeSilent() { global $subdirs; global $cwd; global $sugar_config; // make sure dirs exist foreach ($subdirs as $subdir) { if (!is_dir($sugar_config['upload_dir'] . "/upgrades/{$subdir}")) { mkdir_recursive($sugar_config['upload_dir'] . "/upgrades/{$subdir}"); } } }
public function setUp() { mkdir_recursive('custom/include/SugarCharts/CustomSugarChartFactory'); $the_string = <<<EOQ <?php require_once("include/SugarCharts/JsChart.php"); class CustomSugarChartFactory extends JsChart { \t \tfunction __construct() { \t\tparent::__construct(); \t} \t \tfunction getChartResources() { \t\treturn ' \t\t<link type="text/css" href="'.getJSPath('include/SugarCharts/Jit/css/base.css').'" rel="stylesheet" /> \t\t<!--[if IE]><script language="javascript" type="text/javascript" src="'.getJSPath('include/SugarCharts/Jit/js/Jit/Extras/excanvas.js').'"></script><![endif]--> \t\t<script language="javascript" type="text/javascript" src="'.getJSPath('include/SugarCharts/Jit/js/Jit/jit.js').'"></script> \t\t<script language="javascript" type="text/javascript" src="'.getJSPath('include/SugarCharts/Jit/js/sugarCharts.js').'"></script> \t\t'; \t} \t \tfunction getMySugarChartResources() { \t\treturn ' \t\t<script language="javascript" type="text/javascript" src="'.getJSPath('include/SugarCharts/Jit/js/mySugarCharts.js').'"></script> \t\t'; \t} \t \tfunction display(\$name, \$xmlFile, \$width='320', \$height='480', \$resize=false) { \t \t\tparent::display(\$name, \$xmlFile, \$width, \$height, \$resize); \t\treturn \$this->ss->fetch('include/SugarCharts/Jit/tpls/chart.tpl');\t \t} \t \tfunction getDashletScript(\$id,\$xmlFile="") { \t\t \t\tparent::getDashletScript(\$id,\$xmlFile); \t\treturn \$this->ss->fetch('include/SugarCharts/Jit/tpls/DashletGenericChartScript.tpl'); \t} } ?> EOQ; $fp = sugar_fopen('custom/include/SugarCharts/CustomSugarChartFactory/CustomSugarChartFactory.php', "w"); fwrite($fp, $the_string); fclose($fp); }
function processBackupForm() { global $backup_dir; global $backup_zip; global $input_disabled; global $run; global $mod_strings; $errors = array(); // process "run" commands if (isset($_REQUEST['run']) && $_REQUEST['run'] != "") { $run = $_REQUEST['run']; $backup_dir = $_REQUEST['backup_dir']; $backup_zip = $_REQUEST['backup_zip']; if ($run == "confirm") { if ($backup_dir == "") { $errors[] = $mod_strings['LBL_BACKUP_DIRECTORY_ERROR']; } if ($backup_zip == "") { $errors[] = $mod_strings['LBL_BACKUP_FILENAME_ERROR']; } if (sizeof($errors) > 0) { return $errors; } if (!is_dir($backup_dir)) { if (!mkdir_recursive($backup_dir)) { $errors[] = $mod_strings['LBL_BACKUP_DIRECTORY_EXISTS']; } } if (!is_writable($backup_dir)) { $errors[] = $mod_strings['LBL_BACKUP_DIRECTORY_NOT_WRITABLE']; } if (is_file("{$backup_dir}/{$backup_zip}")) { $errors[] = $mod_strings['LBL_BACKUP_FILE_EXISTS']; } if (is_dir("{$backup_dir}/{$backup_zip}")) { $errors[] = $mod_strings['LBL_BACKUP_FILE_AS_SUB']; } if (sizeof($errors) == 0) { $run = "confirmed"; $input_disabled = "readonly"; } } else { if ($run == "confirmed") { ini_set("memory_limit", "-1"); ini_set("max_execution_time", "0"); zip_dir(".", "{$backup_dir}/{$backup_zip}"); $run = "done"; } } } return $errors; }
/** * backup * Private method to handle backing up the file to custom/backup directory * * @param $file File or directory to backup to custom/backup directory */ protected function backup($file) { $basename = basename($file); $basepath = str_replace($basename, '', $file); if (!empty($basepath) && !file_exists('custom/backup/' . $basepath)) { mkdir_recursive('custom/backup/' . $basepath); } if (is_dir($file)) { copy_recursive($file, 'custom/backup/' . $file); } else { copy($file, 'custom/backup/' . $file); } }
function lock($expire_seconds) { $lock_file = $this->_get_cache_file() . '.lock'; if (!is_dir(dirname($lock_file))) { mkdir_recursive(dirname($lock_file)); } $fh = fopen($lock_file, "w"); flock($fh, LOCK_EX); $result = fwrite($fh, time() + $expire_seconds); flock($fh, LOCK_UN); fclose($fh); return $result !== FALSE; }
/** * @return boolean true if data was written to filesystem, otherwise false. */ function set(&$object) { $cache_file = $this->_get_cache_file(); if (!is_dir(dirname($cache_file))) { mkdir_recursive(dirname($cache_file)); } $fh = fopen($cache_file, "w"); flock($fh, LOCK_EX); $result = fwrite($fh, serialize($object)); flock($fh, LOCK_UN); fclose($fh); return $result !== FALSE; }