/** * Move the preference to external tool config * * @param string $prefs_file The preferences file to upgrade * * @return boolean * @access public */ function _movePreference($prefs_file) { // Start the upgrade if (!file_exists($prefs_file)) { echo "Preference file not found\n"; return FALSE; } //end if include_once $prefs_file; if (isset($preferences['tool_clear_squid_cache'])) { $vars['SQ_TOOL_SQUID_CACHE_HOSTNAMES'] = $preferences['tool_clear_squid_cache']['SQ_SQUID_CACHE_HOSTNAMES']['default']; $vars['SQ_TOOL_SQUID_CACHE_PATH'] = $preferences['tool_clear_squid_cache']['SQ_SQUID_CACHE_PATH']['default']; $vars['SQ_TOOL_SQUID_CACHE_PORT'] = $preferences['tool_clear_squid_cache']['SQ_SQUID_CACHE_PORT']['default']; $vars['SQ_TOOL_SQUID_CACHE_OPTION'] = $preferences['tool_clear_squid_cache']['SQ_SQUID_CACHE_OPTION']['default']; $vars['SQ_TOOL_SQUID_CACHE_SLASH'] = $preferences['tool_clear_squid_cache']['SQ_SQUID_CACHE_SLASH']['default']; $vars['SQ_TOOL_SQUID_URL_PORT'] = $preferences['tool_clear_squid_cache']['SQ_SQUID_URL_PORT']['default']; require_once SQ_INCLUDE_PATH . '/external_tools_config.inc'; $cfg = new External_Tools_Config(); if (!$cfg->save($vars, FALSE, TRUE)) { echo "Preference tool_clear_squid_cache can not be saved\n"; return FALSE; } } else { echo "Preference not found\n"; return TRUE; } // Cleanup unset($preferences); // Finish echo 'Done' . "\n"; return TRUE; }
$trigger_manager = $GLOBALS['SQ_SYSTEM']->am->getSystemAsset('trigger_manager'); $children = $trigger_manager->getTriggerList(); foreach ($children as $trigger_data) { $trigger = $trigger_manager->getAsset($trigger_data['id']); $actions = $trigger->attr('actions'); foreach ($actions as $index => $action) { if (isset($action['type']) && $action['type'] == 'trigger_action_create_file_asset') { if (!empty($action['data']['file_path'])) { $allowed_filepaths[] = trim($action['data']['file_path']); } } } //end foreach } //end foreach // Add those file paths to the white list if (!empty($allowed_filepaths)) { echo "\nSetting 'SQ_TOOL_AUTHORISED_PATHS' based on the existing 'Create File Asset' trigger actions... "; // Save into the External tool config file $root_user = $GLOBALS['SQ_SYSTEM']->am->getSystemAsset('root_user'); $GLOBALS['SQ_SYSTEM']->setCurrentUser($root_user); $GLOBALS['SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED); include_once SQ_INCLUDE_PATH . '/external_tools_config.inc'; $tools_config = new External_Tools_Config(); $vars = array('SQ_TOOL_AUTHORISED_PATHS' => implode("\n", $allowed_filepaths)); $result = $tools_config->save($vars, TRUE, FALSE); $GLOBALS['SQ_SYSTEM']->restoreRunLevel(); $GLOBALS['SQ_SYSTEM']->restoreCurrentUser(); echo $result ? 'Done.' : 'Failed'; echo "\n"; }