Commit 8100eb08 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review
Browse files

Adjustments for the webservices index page (Bug #1396434)



- Changing the readonly checkboxes to be icon images
- adding a sitewide function display_icon() to render the ticks/crosses
- added a list of generic states to the mahara lang file
- tidied up the varying uses of enabled/disabled to use the generic ones

Change-Id: I009c6d54f0033dd46391c61387c84575536dcd4b
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 34226901
...@@ -52,8 +52,6 @@ $string['youmaynotregisterwithouttandc'] = 'You may not register unless you agre ...@@ -52,8 +52,6 @@ $string['youmaynotregisterwithouttandc'] = 'You may not register unless you agre
// core webservices strings start here // core webservices strings start here
$string['control_webservices'] = 'Switch ALL WebServices on or off: '; $string['control_webservices'] = 'Switch ALL WebServices on or off: ';
$string['enabled'] = 'enabled';
$string['disabled'] = 'disabled';
$string['masterswitch'] = 'WebServices master switch'; $string['masterswitch'] = 'WebServices master switch';
$string['formatdate'] = ''; $string['formatdate'] = '';
$string['protocolswitches'] = 'Switch On/Off Protocols'; $string['protocolswitches'] = 'Switch On/Off Protocols';
......
...@@ -35,10 +35,6 @@ $string['friendsdescr'] = 'Friends control'; ...@@ -35,10 +35,6 @@ $string['friendsdescr'] = 'Friends control';
$string['updatedfriendcontrolsetting'] = 'Updated friends control'; $string['updatedfriendcontrolsetting'] = 'Updated friends control';
$string['wysiwygdescr'] = 'HTML editor'; $string['wysiwygdescr'] = 'HTML editor';
$string['on'] = 'On';
$string['off'] = 'Off';
$string['disabled'] = 'Disabled';
$string['enabled'] = 'Enabled';
$string['licensedefault'] = 'Default license'; $string['licensedefault'] = 'Default license';
$string['licensedefaultdescription'] = 'The default license for your content.'; $string['licensedefaultdescription'] = 'The default license for your content.';
......
...@@ -57,6 +57,15 @@ $string['imagexofy'] = 'Image {x} of {y}'; ...@@ -57,6 +57,15 @@ $string['imagexofy'] = 'Image {x} of {y}';
$string['clickformore'] = '(Press \'enter\' to display more information)'; $string['clickformore'] = '(Press \'enter\' to display more information)';
$string['goto'] = 'Go to \'%s\''; $string['goto'] = 'Go to \'%s\'';
$string['gotomore'] = 'Read more...'; $string['gotomore'] = 'Read more...';
// generic switch state strings.
$string['on'] = 'On';
$string['off'] = 'Off';
$string['yes'] = 'Yes';
$string['no'] = 'No';
$string['true'] = 'True';
$string['false'] = 'False';
$string['enabled'] = 'Enabled';
$string['disabled'] = 'Disabled';
// Objectionable strings. // Objectionable strings.
$string['complaint'] = 'Complaint'; $string['complaint'] = 'Complaint';
$string['notifyadministrator'] = 'Notify administrator'; $string['notifyadministrator'] = 'Notify administrator';
...@@ -68,12 +77,9 @@ $string['reportsent'] = 'Your report has been sent.'; ...@@ -68,12 +77,9 @@ $string['reportsent'] = 'Your report has been sent.';
$string['tabs'] = 'Tabs'; $string['tabs'] = 'Tabs';
$string['tab'] = 'tab'; $string['tab'] = 'tab';
$string['selected'] = 'selected'; $string['selected'] = 'selected';
$string['disabled'] = 'disabled';
$string['admin'] = 'Admin'; $string['admin'] = 'Admin';
$string['menu'] = 'Menu'; $string['menu'] = 'Menu';
$string['no'] = 'No';
$string['yes'] = 'Yes';
$string['at'] = 'at'; $string['at'] = 'at';
$string['From'] = 'From'; $string['From'] = 'From';
$string['To'] = 'To'; $string['To'] = 'To';
......
...@@ -4298,3 +4298,39 @@ function can_use_skins($userid = null, $managesiteskin=false, $issiteview=false) ...@@ -4298,3 +4298,39 @@ function can_use_skins($userid = null, $managesiteskin=false, $issiteview=false)
} }
return false; return false;
} }
/**
* Display image icon based on name
*
* @param string $type Type of icon image to show
* @param string $id Optional id to add to the image
*
* @return string An <img> tag of the icon we want
*/
function display_icon($type, $id = false) {
global $THEME;
switch ($type) {
case 'on':
case 'yes':
case 'success':
case 'true':
case 'enabled':
$image = 'success.png';
break;
case 'off':
case 'no':
case 'fail':
case 'false':
case 'disabled':
$image = 'fail.png';
break;
}
$imageurl = $THEME->get_url('images/' . $image);
$html = '<img src="' . $imageurl . '" class="displayicon" alt="' . get_string($type) . '"';
if ($id) {
$html .= ' id="' . $id . '"';
}
$html .= '>';
return $html;
}
{foreach from=$form.elements item=element} {foreach from=$form.elements item=element}
<div class="pseudofieldset collapsible collapsed"> <div class="pseudofieldset collapsible collapsed">
<span class="pseudolegend"><h4><a href="">{$element.legend}</a></h4></span> <span class="pseudolegend"><h4 id="{$element.name}_pseudofieldset"><a href="">{$element.legend}</a></h4></span>
{foreach from=$element.elements item=item} {foreach from=$element.elements item=item}
{$item.value|safe} {$item.value|safe}
{/foreach} {/foreach}
...@@ -21,7 +21,13 @@ jQuery(function() { ...@@ -21,7 +21,13 @@ jQuery(function() {
} }
e.preventDefault(); e.preventDefault();
}); });
// Keep open current section after save/reload of page.
// Will reopen only the fieldset that had a form saved within it
var opened = '{$opened}';
if (opened !== '') {
jQuery('#' + opened + '_pseudofieldset').closest('div.pseudofieldset').removeClass('collapsed');
}
}); });
}); });
</script> </script>
\ No newline at end of file
...@@ -25,6 +25,7 @@ $form = get_config_options_extended(); ...@@ -25,6 +25,7 @@ $form = get_config_options_extended();
$smarty = smarty_core(); $smarty = smarty_core();
$smarty->assign('form', $form); $smarty->assign('form', $form);
$smarty->assign('opened', param_alphanumext('open', ''));
$mainform = $smarty->fetch('auth:webservice:configform.tpl'); $mainform = $smarty->fetch('auth:webservice:configform.tpl');
unset($smarty); unset($smarty);
...@@ -59,7 +60,7 @@ function activate_webservices_submit(Pieform $form, $values) { ...@@ -59,7 +60,7 @@ function activate_webservices_submit(Pieform $form, $values) {
} }
external_reload_webservices(); external_reload_webservices();
} }
redirect('/webservice/admin/index.php?plugintype=auth&pluginname=webservice&type=webservice'); redirect('/webservice/admin/index.php?open=activate_webservices');
} }
function activate_webservice_proto_submit(Pieform $form, $values) { function activate_webservice_proto_submit(Pieform $form, $values) {
...@@ -67,7 +68,7 @@ function activate_webservice_proto_submit(Pieform $form, $values) { ...@@ -67,7 +68,7 @@ function activate_webservice_proto_submit(Pieform $form, $values) {
$enabled = $values['enabled'] ? 0 : 1; $enabled = $values['enabled'] ? 0 : 1;
$proto = $values['protocol']; $proto = $values['protocol'];
set_config('webservice_'.$proto.'_enabled', $enabled); set_config('webservice_'.$proto.'_enabled', $enabled);
redirect('/webservice/admin/index.php?plugintype=auth&pluginname=webservice&type=webservice'); redirect('/webservice/admin/index.php?open=activate_webservices_protos');
} }
function webservices_function_groups_submit(Pieform $form, $values) { function webservices_function_groups_submit(Pieform $form, $values) {
...@@ -104,7 +105,7 @@ function webservices_function_groups_submit(Pieform $form, $values) { ...@@ -104,7 +105,7 @@ function webservices_function_groups_submit(Pieform $form, $values) {
} }
// default back to where we came from // default back to where we came from
redirect('/webservice/admin/index.php'); redirect('/webservice/admin/index.php?open=webservices_function_groups');
} }
function webservices_token_submit(Pieform $form, $values) { function webservices_token_submit(Pieform $form, $values) {
...@@ -151,7 +152,7 @@ function webservices_token_submit(Pieform $form, $values) { ...@@ -151,7 +152,7 @@ function webservices_token_submit(Pieform $form, $values) {
} }
// default back to where we came from // default back to where we came from
redirect('/webservice/admin/index.php'); redirect('/webservice/admin/index.php?open=webservices_token');
} }
function webservices_user_submit(Pieform $form, $values) { function webservices_user_submit(Pieform $form, $values) {
...@@ -210,7 +211,7 @@ function webservices_user_submit(Pieform $form, $values) { ...@@ -210,7 +211,7 @@ function webservices_user_submit(Pieform $form, $values) {
} }
// default back to where we came from // default back to where we came from
redirect('/webservice/admin/index.php'); redirect('/webservice/admin/index.php?open=webservices_user');
} }
/** /**
...@@ -247,7 +248,7 @@ function webservices_master_switch_form() { ...@@ -247,7 +248,7 @@ function webservices_master_switch_form() {
'class' => 'linkbtn', 'class' => 'linkbtn',
'value' => $enabled ? get_string('disable') : get_string('enable') 'value' => $enabled ? get_string('disable') : get_string('enable')
), ),
'state' => array('type' => 'html', 'value' => '[' . ($enabled ? get_string('enabled', 'auth.webservice') : get_string('disabled', 'auth.webservice')) . ']',), 'state' => array('type' => 'html', 'value' => '[' . ($enabled ? get_string('enabled') : get_string('disabled')) . ']',),
), ),
) )
), ),
...@@ -293,7 +294,7 @@ function webservices_protocol_switch_form() { ...@@ -293,7 +294,7 @@ function webservices_protocol_switch_form() {
'class' => 'linkbtn', 'class' => 'linkbtn',
'value' => $enabled ? get_string('disable') : get_string('enable') 'value' => $enabled ? get_string('disable') : get_string('enable')
), ),
'state' => array('type' => 'html', 'value' => '[' . ($enabled ? get_string('enabled', 'auth.webservice') : get_string('disabled', 'auth.webservice')) . ']',), 'state' => array('type' => 'html', 'value' => '[' . ($enabled ? get_string('enabled') : get_string('disabled')) . ']',),
), ),
))); )));
} }
...@@ -331,7 +332,7 @@ function service_fg_edit_form() { ...@@ -331,7 +332,7 @@ function service_fg_edit_form() {
'title' => ' ', 'title' => ' ',
'class' => 'header', 'class' => 'header',
'type' => 'html', 'type' => 'html',
'value' => get_string('enabled', 'auth.webservice'), 'value' => get_string('enabled'),
), ),
'restricted' => array( 'restricted' => array(
'title' => ' ', 'title' => ' ',
...@@ -368,21 +369,21 @@ function service_fg_edit_form() { ...@@ -368,21 +369,21 @@ function service_fg_edit_form() {
'key' => $service->name, 'key' => $service->name,
); );
$form['elements']['id'. $service->id . '_enabled'] = array( $form['elements']['id'. $service->id . '_enabled'] = array(
'defaultvalue' => (($service->enabled == 1) ? 'checked' : ''), 'value' => (($service->enabled == 1) ? display_icon('enabled') : display_icon('disabled')),
'type' => 'checkbox', 'type' => 'html',
'disabled' => true, 'class' => 'center',
'key' => $service->name, 'key' => $service->name,
); );
$form['elements']['id'. $service->id . '_restricted'] = array( $form['elements']['id'. $service->id . '_restricted'] = array(
'defaultvalue' => (($service->restrictedusers == 1) ? 'checked' : ''), 'value' => (($service->restrictedusers == 1) ? display_icon('enabled') : display_icon('disabled')),
'type' => 'checkbox', 'type' => 'html',
'disabled' => true, 'class' => 'center',
'key' => $service->name, 'key' => $service->name,
); );
$form['elements']['id'. $service->id . '_tokenusers'] = array( $form['elements']['id'. $service->id . '_tokenusers'] = array(
'defaultvalue' => (($service->tokenusers == 1) ? 'checked' : ''), 'value' => (($service->tokenusers == 1) ? display_icon('enabled') : display_icon('disabled')),
'type' => 'checkbox', 'type' => 'html',
'disabled' => true, 'class' => 'center',
'key' => $service->name, 'key' => $service->name,
); );
$functions = get_records_array('external_services_functions', 'externalserviceid', $service->id); $functions = get_records_array('external_services_functions', 'externalserviceid', $service->id);
...@@ -509,7 +510,7 @@ function service_tokens_edit_form() { ...@@ -509,7 +510,7 @@ function service_tokens_edit_form() {
'title' => ' ', 'title' => ' ',
'class' => 'header', 'class' => 'header',
'type' => 'html', 'type' => 'html',
'value' => get_string('enabled', 'auth.webservice'), 'value' => get_string('enabled'),
), ),
'wssigenc' => array( 'wssigenc' => array(
'title' => ' ', 'title' => ' ',
...@@ -557,15 +558,15 @@ function service_tokens_edit_form() { ...@@ -557,15 +558,15 @@ function service_tokens_edit_form() {
'key' => $token->token, 'key' => $token->token,
); );
$form['elements']['id'. $token->tokenid . '_enabled'] = array( $form['elements']['id'. $token->tokenid . '_enabled'] = array(
'defaultvalue' => (($token->enabled == 1) ? 'checked' : ''), 'value' => (($token->enabled == 1) ? display_icon('enabled') : display_icon('disabled')),
'type' => 'checkbox', 'type' => 'html',
'disabled' => true, 'class' => 'center',
'key' => $token->token, 'key' => $token->token,
); );
$form['elements']['id'. $token->tokenid . '_wssigenc'] = array( $form['elements']['id'. $token->tokenid . '_wssigenc'] = array(
'defaultvalue' => (($token->wssigenc == 1) ? 'checked' : ''), 'value' => (($token->wssigenc == 1) ? display_icon('enabled') : display_icon('disabled')),
'type' => 'checkbox', 'type' => 'html',
'disabled' => true, 'class' => 'center',
'key' => $token->token, 'key' => $token->token,
); );
...@@ -710,7 +711,7 @@ function service_users_edit_form() { ...@@ -710,7 +711,7 @@ function service_users_edit_form() {
'title' => ' ', 'title' => ' ',
'class' => 'header', 'class' => 'header',
'type' => 'html', 'type' => 'html',
'value' => get_string('enabled', 'auth.webservice'), 'value' => get_string('enabled'),
), ),
'wssigenc' => array( 'wssigenc' => array(
'title' => ' ', 'title' => ' ',
...@@ -753,15 +754,15 @@ function service_users_edit_form() { ...@@ -753,15 +754,15 @@ function service_users_edit_form() {
'key' => $user->id, 'key' => $user->id,
); );
$form['elements']['id'. $user->id . '_enabled'] = array( $form['elements']['id'. $user->id . '_enabled'] = array(
'defaultvalue' => (($user->enabled == 1) ? 'checked' : ''), 'value' => (($user->enabled == 1) ? display_icon('enabled') : display_icon('disabled')),
'type' => 'checkbox', 'type' => 'html',
'disabled' => true, 'class' => 'center',
'key' => $user->id, 'key' => $user->id,
); );
$form['elements']['id'. $user->id . '_wssigenc'] = array( $form['elements']['id'. $user->id . '_wssigenc'] = array(
'defaultvalue' => (($user->wssigenc == 1) ? 'checked' : ''), 'value' => (($user->wssigenc == 1) ? display_icon('enabled') : display_icon('disabled')),
'type' => 'checkbox', 'type' => 'html',
'disabled' => true, 'class' => 'center',
'key' => $user->id, 'key' => $user->id,
); );
...@@ -900,6 +901,7 @@ function get_config_options_extended() { ...@@ -900,6 +901,7 @@ function get_config_options_extended() {
'elements' => webservices_master_switch_form(), 'elements' => webservices_master_switch_form(),
'collapsible' => true, 'collapsible' => true,
'collapsed' => true, 'collapsed' => true,
'name' => 'activate_webservices',
), ),
// fieldset of protocol switches // fieldset of protocol switches
...@@ -918,6 +920,7 @@ function get_config_options_extended() { ...@@ -918,6 +920,7 @@ function get_config_options_extended() {
), ),
'collapsible' => true, 'collapsible' => true,
'collapsed' => true, 'collapsed' => true,
'name' => 'activate_webservices_protos',
), ),
// System Certificates // System Certificates
...@@ -951,6 +954,7 @@ function get_config_options_extended() { ...@@ -951,6 +954,7 @@ function get_config_options_extended() {
), ),
'collapsible' => true, 'collapsible' => true,
'collapsed' => true, 'collapsed' => true,
'name' => 'activate_webservices_networking',
), ),
// fieldset for managing service function groups // fieldset for managing service function groups
...@@ -968,6 +972,7 @@ function get_config_options_extended() { ...@@ -968,6 +972,7 @@ function get_config_options_extended() {
), ),
'collapsible' => true, 'collapsible' => true,
'collapsed' => true, 'collapsed' => true,
'name' => 'webservices_function_groups',
), ),
...@@ -986,6 +991,7 @@ function get_config_options_extended() { ...@@ -986,6 +991,7 @@ function get_config_options_extended() {
), ),
'collapsible' => true, 'collapsible' => true,
'collapsed' => false, 'collapsed' => false,
'name' => 'webservices_token',
), ),
// fieldset for managing service tokens // fieldset for managing service tokens
...@@ -1003,6 +1009,7 @@ function get_config_options_extended() { ...@@ -1003,6 +1009,7 @@ function get_config_options_extended() {
), ),
'collapsible' => true, 'collapsible' => true,
'collapsed' => false, 'collapsed' => false,
'name' => 'webservices_user',
), ),
); );
$form = array( $form = array(
......
...@@ -216,7 +216,7 @@ function webservice_server_edit_form($dbserver, $sopts, $iopts) { ...@@ -216,7 +216,7 @@ function webservice_server_edit_form($dbserver, $sopts, $iopts) {
); );
$server_details['elements']['enabled'] = array( $server_details['elements']['enabled'] = array(
'title' => get_string('enabled', 'auth.webservice'), 'title' => get_string('enabled'),
'defaultvalue' => (($dbserver->enabled == 1) ? 'checked' : ''), 'defaultvalue' => (($dbserver->enabled == 1) ? 'checked' : ''),
'type' => 'checkbox', 'type' => 'checkbox',
'disabled' => true, 'disabled' => true,
...@@ -332,7 +332,7 @@ function webservice_server_list_form($sopts, $iopts) { ...@@ -332,7 +332,7 @@ function webservice_server_list_form($sopts, $iopts) {
'title' => ' ', 'title' => ' ',
'class' => 'header', 'class' => 'header',
'type' => 'html', 'type' => 'html',
'value' => get_string('enabled', 'auth.webservice'), 'value' => get_string('enabled'),
), ),
'calback_uri' => array( 'calback_uri' => array(
'title' => ' ', 'title' => ' ',
......
...@@ -38,7 +38,7 @@ $functions = ...@@ -38,7 +38,7 @@ $functions =
'title' => ' ', 'title' => ' ',
'class' => 'header', 'class' => 'header',
'type' => 'html', 'type' => 'html',
'value' => get_string('enabled', 'auth.webservice'), 'value' => get_string('enabled'),
), ),
'classname' => array( 'classname' => array(
'title' => ' ', 'title' => ' ',
...@@ -113,7 +113,7 @@ $elements = array( ...@@ -113,7 +113,7 @@ $elements = array(
'class' => 'linkbtn', 'class' => 'linkbtn',
'value' => $enabled ? get_string('disable') : get_string('enable') 'value' => $enabled ? get_string('disable') : get_string('enable')
), ),
'state' => array('type' => 'html', 'value' => '[' . ($enabled ? get_string('enabled', 'auth.webservice') : get_string('disabled', 'auth.webservice')) . ']',), 'state' => array('type' => 'html', 'value' => '[' . ($enabled ? get_string('enabled') : get_string('disabled')) . ']',),
), ),
) )
), ),
...@@ -165,7 +165,7 @@ $elements = array( ...@@ -165,7 +165,7 @@ $elements = array(
'class' => 'linkbtn', 'class' => 'linkbtn',
'value' => $tokenusers ? get_string('disable') : get_string('enable') 'value' => $tokenusers ? get_string('disable') : get_string('enable')
), ),
'state' => array('type' => 'html', 'value' => '[' . ($tokenusers ? get_string('enabled', 'auth.webservice') : get_string('disabled', 'auth.webservice')) . ']',), 'state' => array('type' => 'html', 'value' => '[' . ($tokenusers ? get_string('enabled') : get_string('disabled')) . ']',),
), ),
) )
), ),
......
...@@ -95,7 +95,7 @@ $token_details['elements']['service'] = array( ...@@ -95,7 +95,7 @@ $token_details['elements']['service'] = array(
); );
$token_details['elements']['enabled'] = array( $token_details['elements']['enabled'] = array(
'title' => get_string('enabled', 'auth.webservice'), 'title' => get_string('enabled'),
'defaultvalue' => (($dbservice->enabled == 1) ? 'checked' : ''), 'defaultvalue' => (($dbservice->enabled == 1) ? 'checked' : ''),
'type' => 'checkbox', 'type' => 'checkbox',
'disabled' => true, 'disabled' => true,
......
...@@ -111,7 +111,7 @@ $serviceuser_details['elements']['service'] = array( ...@@ -111,7 +111,7 @@ $serviceuser_details['elements']['service'] = array(
); );
$serviceuser_details['elements']['enabled'] = array( $serviceuser_details['elements']['enabled'] = array(
'title' => get_string('enabled', 'auth.webservice'), 'title' => get_string('enabled'),
'defaultvalue' => (($serviceenabled == 1) ? 'checked' : ''), 'defaultvalue' => (($serviceenabled == 1) ? 'checked' : ''),
'type' => 'checkbox', 'type' => 'checkbox',
'disabled' => true, 'disabled' => true,
......
...@@ -68,7 +68,7 @@ if (!empty($dbservices)) { ...@@ -68,7 +68,7 @@ if (!empty($dbservices)) {
'title' => ' ', 'title' => ' ',
'class' => 'header', 'class' => 'header',
'type' => 'html', 'type' => 'html',
'value' => get_string('enabled', 'auth.webservice'), 'value' => get_string('enabled'),
), ),
'token' => array( 'token' => array(
'title' => ' ', 'title' => ' ',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment