52 $is_root = $GLOBALS[
'SQ_SYSTEM']->userRoot();
53 $is_admin = ($is_root || $GLOBALS[
'SQ_SYSTEM']->userSystemAdmin());
57 $GLOBALS[
'SQ_SYSTEM']->paintLogin(translate(
'login'), translate(
'cannot_access_asset', $owner->name));
63 $o->setHeading(translate(
'system_configuration'), sq_get_icon($o->filesPath(
'/images/icons/header/system_config.png'), 20, 20,
'System Configuration'));
64 $o->setPageTitle(translate(
'system_configuration'));
65 $o->addHiddenField(
'config_posted',
'1');
71 if (empty($_REQUEST[
'config_screen'])) {
72 $active_screen =
'system_config';
73 $_REQUEST[
'config_screen'] = $active_screen;
75 $active_screen = $_REQUEST[
'config_screen'];
79 $o->addFormActionGetVar(
'config_screen', $active_screen);
85 $o->addFormActionGetVar(
'config_screen', $active_screen, TRUE);
86 $current_location = $o->getCurrentLocation();
87 list($current_loc_base, $current_loc_query) = explode(
'?', $current_location);
88 $config_screens = Array(
89 'system_config' => translate(
'system_configuration'),
90 'squiz_server_config' => translate(
'squiz_server_configuration'),
91 'apache_config' => translate(
'apache_configuration'),
92 'hipo_config' => translate(
'hipo_configuration'),
93 'external_tools_config' => translate(
'external_tools_configuration'),
94 'user_prefs' => translate(
'global_preferences'),
95 'password_rules_config' => translate(
'password_rules_configuration'),
96 'messaging_service_config' => translate(
'messaging_service_configuration'),
97 'proxy_authentication_config' => translate(
'proxy_configuration'),
98 'context_config' => translate(
'context_configuration'),
99 'locks' => translate(
'active_locks'),
102 foreach ($config_screens as $screen_code => $screen_name) {
103 $url = replace_query_string_vars(Array(
'config_screen' => rawurlencode($screen_code)), $current_loc_base, $current_loc_query);
104 $o->addStaticScreen($url, $screen_name);
108 switch ($active_screen) {
109 case 'system_config' :
110 case 'squiz_server_config' :
111 case 'apache_config' :
113 case 'external_tools_config' :
114 case 'password_rules_config' :
115 case 'session_rules_config' :
116 case 'messaging_service_config' :
117 case 'proxy_authentication_config' :
118 case 'context_config':
122 switch ($active_screen) {
123 case 'system_config' :
124 require_once SQ_INCLUDE_PATH.
'/system_config.inc';
127 case 'squiz_server_config' :
128 require_once SQ_SYSTEM_ROOT.
'/core/server/squiz_server_config.inc';
131 case 'apache_config' :
132 require_once SQ_INCLUDE_PATH.
'/apache_config.inc';
136 require_once SQ_SYSTEM_ROOT.
'/core/hipo/hipo_config.inc';
139 case 'external_tools_config' :
140 require_once SQ_INCLUDE_PATH.
'/external_tools_config.inc';
143 case 'password_rules_config' :
144 require_once SQ_INCLUDE_PATH.
'/password_rules_config.inc';
147 case 'session_rules_config' :
148 require_once SQ_INCLUDE_PATH.
'/session_rules_config.inc';
149 $config =
new Session_Rules_Config();
151 case 'messaging_service_config' :
152 require_once SQ_INCLUDE_PATH.
'/messaging_service_config.inc';
155 case 'proxy_authentication_config' :
156 require_once SQ_INCLUDE_PATH.
'/proxy_authentication_config.inc';
159 case 'context_config' :
160 require_once SQ_INCLUDE_PATH.
'/context_config.inc';
165 if (!empty($_POST[
'config_posted'])) {
166 $config->processBackend($o);
169 $config->paintBackend($o);
177 if (!empty($_POST[
'config_posted'])) {
189 trigger_localised_error(
'SYS0076', E_USER_WARNING, $active_screen);
205 $lock_code = get_class($this).
'_user_prefs';
206 $lock = $GLOBALS[
'SQ_SYSTEM']->getLockInfo($lock_code);
207 $have_lock = (!empty($lock) && $GLOBALS[
'SQ_SYSTEM']->currentUserId() == $lock[
'userid']);
209 $is_admin = ($GLOBALS[
'SQ_SYSTEM']->userRoot() || $GLOBALS[
'SQ_SYSTEM']->userSystemAdmin());
211 $o->openSection(translate(
'locking_/_editing'));
214 <table border=
"0" cellspacing=
"3" cellpadding=
"1">
217 <?php sq_print_icon(sq_web_path(
'lib').
'/web/images/icons/'.((empty($lock)) ?
'un' :
'').
'locked.png', 16, 16); ?>
220 <p
class=
"sq-lock-message">
225 $user = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($lock[
'userid']);
229 require_once SQ_FUDGE_PATH.
'/general/datetime.inc';
230 $expires_in = easy_time_total(($lock[
'expires'] - $now),
true);
231 if (!$expires_in) $expires_in =
'1 second';
232 $expires_in = translate(
'due_to_expire', $expires_in);
234 echo translate(
'release_lock', translate(
'release_lock_button'), translate(
'user_preferences'));
240 echo translate(
'acquire_lock', translate(
'acquire_lock_button'), translate(
'user_preferences'));
245 submit_button(
'sq_lock_release_manual', translate(
'release_lock_button'),
'set_hidden_field("process_form", "0");',
'accesskey="r"');
248 submit_button(
'sq_lock_acquire', translate(
'acquire_lock_button'),
'set_hidden_field("process_form", "0");',
'accesskey="a"');
258 include SQ_DATA_PATH.
'/private/conf/preferences.inc';
260 foreach ($preferences as $type_code => $pref_vars) {
261 $o->openSection($GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($type_code,
'name').
' '.translate(
'preferences'));
264 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset($type_code);
266 $path = SQ_SYSTEM_ROOT.
'/'.$GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($type_code,
'dir').
'/'.$type_code.
'_prefs.inc';
268 $pref_name = $type_code.
'_Prefs';
269 $prefs =
new $pref_name();
270 $prefs->paintBackend($o, $have_lock);
274 if ($have_lock) $o->commitButton(
'',
true);
289 $is_admin = ($GLOBALS[
'SQ_SYSTEM']->userRoot() || $GLOBALS[
'SQ_SYSTEM']->userSystemAdmin());
291 $lock_code = get_class($this).
'_user_prefs';
292 $lock = $GLOBALS[
'SQ_SYSTEM']->getLockInfo($lock_code);
293 $have_lock = (!empty($lock) && $GLOBALS[
'SQ_SYSTEM']->currentUserId() == $lock[
'userid']);
295 if (!empty($_POST[
'process_form'])) {
297 include SQ_DATA_PATH.
'/private/conf/preferences.inc';
298 $new_preferences = $preferences;
300 foreach ($preferences as $type_code => $pref_vars) {
302 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset($type_code);
304 $path = SQ_SYSTEM_ROOT.
'/'.$GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($type_code,
'dir').
'/'.$type_code.
'_prefs.inc';
306 $pref_name = $type_code.
'_Prefs';
307 $prefs =
new $pref_name();
308 if ($prefs->processBackend($o, $have_lock)) {
309 $new_preferences[$type_code] = $prefs->pref_vars;
315 $changed_vars = Array();
316 foreach ($preferences as $type_code => $pref_data) {
317 foreach ($pref_data as $var_name => $var_data) {
318 $current_value = $preferences[$type_code][$var_name][
'default'];
319 $new_value = $new_preferences[$type_code][$var_name][
'default'];
321 if ($current_value !== $new_value) {
322 $changed_vars[$var_name] = Array(
'old' => $current_value,
'new' => $new_value,
'type_code' => $type_code);
328 $str =
'<'.
'?php $preferences = '.var_export($new_preferences,
true).
'; ?'.
'>';
329 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
330 if (!string_to_file($str, SQ_DATA_PATH.
'/private/conf/preferences.inc')) {
335 $ms = $GLOBALS[
'SQ_SYSTEM']->getMessagingService();
337 foreach ($changed_vars as $var_name => $values) {
339 'type_code' => ucwords(str_replace(
'_',
' ', $values[
'type_code'])),
340 'setting' => $var_name,
341 'old_value' => var_export($values[
'old'],
true),
342 'new_value' => var_export($values[
'new'],
true),
344 $message = $ms->newMessage(Array(),
'prefs.system', $msg_reps);
345 $ms->enqueueMessage($message);
355 if (!empty($_POST[
'sq_lock_release']) || !empty($_POST[
'sq_lock_release_manual'])) {
356 $GLOBALS[
'SQ_SYSTEM']->releaseLock($lock_code);
360 if (!empty($_POST[
'sq_lock_acquire']) && $is_admin) {
361 $GLOBALS[
'SQ_SYSTEM']->acquireLock($lock_code);
380 $class_name =
'locking_method_'.SQ_CONF_LOCKING_METHOD;
381 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset($class_name);
382 $current_time = time();
385 if (eval(
'return '.$class_name.
'::supportsGetActiveLocks();') === FALSE) {
386 $o->openSection(translate(
'active_locks'));
387 $o->openField(translate(
'system_config_active_locks_no_support', SQ_CONF_LOCKING_METHOD));
392 $db_locks = eval(
'return '.$class_name.
'::getActiveLocks(NULL);');
394 }
catch (Exception $e) {
395 return 'Unable to get active locks, '.$e->getMessage();
398 if (empty($db_locks)) {
399 $o->openSection(translate(
'active_locks'));
400 $o->openField(translate(
'no_active_locks'));
406 $active_locks = Array();
407 $asset_info_ids = Array();
408 foreach ($db_locks as $lock) {
409 $lockid = $lock[
'lockid'];
410 if (substr($lockid, 0, 6) !=
'asset.')
continue;
411 $lockid = substr($lockid, 6);
412 $lock_type = substr($lockid, strrpos($lockid,
'.') + 1);
413 $assetid = substr($lockid, 0, strrpos($lockid,
'.'));
416 if (!$GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid,
'', TRUE))
continue;
418 $active_locks[$lock[
'userid']][
'locks'][$assetid][$lock_type] = $lock[
'expires'];
420 if (!isset($active_locks[$lock[
'userid']][
'num_locks'])) $active_locks[$lock[
'userid']][
'num_locks'] = 0;
421 $active_locks[$lock[
'userid']][
'num_locks']++;
423 $asset_info_ids[$lock[
'userid']] = $lock[
'userid'];
424 $asset_info_ids[$assetid] = $assetid;
427 $asset_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(array_keys($asset_info_ids));
429 require_once SQ_FUDGE_PATH.
'/general/datetime.inc';
431 $o->openSection(translate(
'active_locks'));
434 <table
class=
"sq-backend-table">
436 <td
class=
"sq-backend-table-header"><?php echo translate(
'user'); ?></td>
437 <td
class=
"sq-backend-table-header"><?php echo translate(
'lock_type'); ?></td>
438 <td
class=
"sq-backend-table-header"><?php echo translate(
'maps_held_at'); ?></td>
439 <td
class=
"sq-backend-table-header"><?php echo translate(
'expires'); ?></td>
442 foreach ($active_locks as $userid => $locks) {
443 $printed_header =
false;
444 foreach ($locks[
'locks'] as $assetid => $lock_info) {
445 foreach ($lock_info as $lock_type => $expires) {
449 if (!$printed_header) {
451 <td
class=
"sq-backend-table-cell" rowspan=
"<?php echo $locks['num_locks']; ?>">
453 if (isset($asset_info[$userid])) {
454 $name = $asset_info[$userid][
'name'];
455 $type = $asset_info[$userid][
'type_code'];
457 $asset = &$GLOBALS[
'SQ_SYSTEM']->am->getAsset($userid);
458 $name = $asset->name;
459 $type = $asset->type();
460 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($asset);
463 <script language=
"JavaScript" type=
"text/javascript">sq_print_icon(
"<?php echo $GLOBALS['SQ_SYSTEM']->am->getAssetIconURL($type); ?>",
"16",
"16",
"");</script>
464 <acronym title=
"<?php echo ucwords(str_replace('_', ' ', $type)); ?> - <?php echo $userid; ?>"><?php echo $name; ?></acronym>
467 $printed_header =
true;
471 <td
class=
"sq-backend-table-cell">
472 <?php echo $lock_type; ?>
474 <td
class=
"sq-backend-table-cell">
476 if (isset($asset_info[$assetid])) {
477 $name = $asset_info[$assetid][
'name'];
478 $type = $asset_info[$assetid][
'type_code'];
480 $asset = &$GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
481 $name = $asset->name;
482 $type = $asset->type();
483 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($asset);
486 <script language=
"JavaScript" type=
"text/javascript">sq_print_icon(
"<?php echo $GLOBALS['SQ_SYSTEM']->am->getAssetIconURL($type); ?>",
"16",
"16",
"");</script>
487 <acronym title=
"<?php echo ucwords(str_replace('_', ' ', $type)); ?> - <?php echo $assetid; ?>"><?php echo $name; ?></acronym>
489 <td
class=
"sq-backend-table-cell">
491 $expires_in = easy_time_total((strtotime($expires) - $current_time),
true);
492 if (!$expires_in) $expires_in =
'1 second';
493 echo translate(
'due_to_expire', $expires_in);