38 public $config_vars = Array();
44 public $config_file =
'';
59 parent::__construct();
60 $this->name = ucwords(str_replace(
'_',
' ', get_class($this)));
76 public function save($vars, $backup_existing=FALSE, $send_message=TRUE)
79 trigger_localised_error(
'SYS0026', E_USER_WARNING, $this->name);
84 if (file_exists($this->config_file)) {
85 require_once $this->config_file;
88 $changed_vars = Array();
90 foreach ($this->config_vars as $var_name => $data) {
92 $current_value = (defined($var_name)) ? constant($var_name) : $data[
'default'];
93 if ($data[
'editable'] && isset($vars[$var_name]) && $current_value !== $vars[$var_name]) {
97 $default_type = gettype($data[
'default']);
99 $value = $vars[$var_name];
101 $changed_vars[$var_name] = Array(
'old' => $current_value,
'new' => $value);
104 $value = $current_value;
114 $str =
'<'.
"?php\n".ob_get_contents().
'?'.
">\n";
118 if ($backup_existing && file_exists($this->config_file)) {
123 $old_version = $this->config_file.
'.'.$i;
124 }
while (file_exists($old_version));
126 if (!copy($this->config_file, $old_version)) {
133 echo
"----------------------------------\n".($str).
"----------------------------------\n";
135 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
137 if (!create_directory(dirname($this->config_file))) {
142 if (!string_to_file($str, $this->config_file)) {
147 if ($changed_vars && $send_message) {
148 $ms = $GLOBALS[
'SQ_SYSTEM']->getMessagingService();
150 foreach ($changed_vars as $var_name => $values) {
151 $message_body = $var_name.
' changed from '.var_export($values[
'old'],
true).
' to '.var_export($values[
'new'],
true).
"\n";
152 $config_name = ucwords(str_replace(
'_',
' ', get_class($this)));
154 'setting' => $var_name,
155 'old_value' => var_export($values[
'old'],
true),
156 'new_value' => var_export($values[
'new'],
true),
158 $message = $ms->newMessage(Array(),
'config.'.get_class_lower($this), $msg_reps);
159 $ms->enqueueMessage($message);
183 echo
"define('", $var_name,
"', ";
208 return 'You are not allowed to acquire the lock on '.$this->name;
210 return $GLOBALS[
'SQ_SYSTEM']->acquireLock(get_class_lower($this));
238 return $GLOBALS[
'SQ_SYSTEM']->releaseLock(get_class_lower($this));
253 return $GLOBALS[
'SQ_SYSTEM']->updateLock(get_class_lower($this));
267 return $GLOBALS[
'SQ_SYSTEM']->getLockInfo(get_class_lower($this));
280 if (!isset($GLOBALS[
'SQ_SYSTEM']))
return TRUE;
281 if (!$GLOBALS[
'SQ_SYSTEM']->runLevelEnables(SQ_SECURITY_PERMISSIONS)) {
286 if (!empty($lock_info) && $lock_info[
'userid'] == $GLOBALS[
'SQ_SYSTEM']->currentUserId()) {
308 if (is_null($this->config_file) === FALSE) {
309 require_once $this->config_file;
313 'system_config' =>
'system_configuration',
314 'squiz_server_config' =>
'squiz_server_configuration',
315 'apache_config' =>
'apache_configuration',
316 'hipo_config' =>
'hipo_configuration',
317 'external_tools_config' =>
'external_tools_configuration',
318 'password_rules_config' =>
'password_rules_configuration',
319 'messaging_service_config' =>
'messaging_service_configuration',
320 'proxy_authentication_config' =>
'proxy_configuration',
321 'context_config' =>
'context_configuration',
324 if ($o->_persistant_get_vars[
'config_screen'] = $map_array[$o->_persistant_get_vars[
'config_screen']]) {
325 $config_screen = $o->_persistant_get_vars[
'config_screen'];
329 $have_lock = (!empty($lock) && $GLOBALS[
'SQ_SYSTEM']->currentUserId() == $lock[
'userid']);
333 $o->openSection(translate(
'locking_/_editing'));
336 <table border=
"0" cellspacing=
"3" cellpadding=
"1">
339 <?php sq_print_icon(sq_web_path(
'lib').
'/web/images/icons/'.((empty($lock)) ?
'un' :
'').
'locked.png', 16, 16); ?>
342 <p
class=
"sq-lock-message">
347 $user = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($lock[
'userid']);
351 require_once SQ_FUDGE_PATH.
'/general/datetime.inc';
352 $expires_in = easy_time_total(($lock[
'expires'] - $now), TRUE);
353 if (!$expires_in) $expires_in =
'1 second';
354 $expires_in = translate(
'due_to_expire', $expires_in);
356 echo translate(
'release_lock', translate(
'release_lock_button'), translate($config_screen));
362 echo translate(
'acquire_lock', translate(
'acquire_lock_button'), translate($config_screen));
367 submit_button(
'sq_lock_release_manual', translate(
'release_lock_button'),
'set_hidden_field("process_form", "0");',
'accesskey="r"');
370 submit_button(
'sq_lock_acquire', translate(
'acquire_lock_button'),
'set_hidden_field("process_form", "0");',
'accesskey="a"');
397 if (!empty($_POST[
'process_form'])) {
399 if (!empty($_POST[get_class_lower($this)])) {
400 $saved = $this->
save($_POST[get_class_lower($this)]);
404 if (!empty($_POST[
'sq_lock_release']) || !empty($_POST[
'sq_lock_release_manual'])) {
409 if (!empty($_POST[
'sq_lock_acquire'])) {
415 if ($saved) $o->setRedirect($o->getCurrentLocation());