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

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
// core webservices strings start here
$string['control_webservices'] = 'Switch ALL WebServices on or off: ';
$string['enabled'] = 'enabled';
$string['disabled'] = 'disabled';
$string['masterswitch'] = 'WebServices master switch';
$string['formatdate'] = '';
$string['protocolswitches'] = 'Switch On/Off Protocols';
......
......@@ -35,10 +35,6 @@ $string['friendsdescr'] = 'Friends control';
$string['updatedfriendcontrolsetting'] = 'Updated friends control';
$string['wysiwygdescr'] = 'HTML editor';
$string['on'] = 'On';
$string['off'] = 'Off';
$string['disabled'] = 'Disabled';
$string['enabled'] = 'Enabled';
$string['licensedefault'] = 'Default license';
$string['licensedefaultdescription'] = 'The default license for your content.';
......
......@@ -57,6 +57,15 @@ $string['imagexofy'] = 'Image {x} of {y}';
$string['clickformore'] = '(Press \'enter\' to display more information)';
$string['goto'] = 'Go to \'%s\'';
$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.
$string['complaint'] = 'Complaint';
$string['notifyadministrator'] = 'Notify administrator';
......@@ -68,12 +77,9 @@ $string['reportsent'] = 'Your report has been sent.';
$string['tabs'] = 'Tabs';
$string['tab'] = 'tab';
$string['selected'] = 'selected';
$string['disabled'] = 'disabled';
$string['admin'] = 'Admin';
$string['menu'] = 'Menu';
$string['no'] = 'No';
$string['yes'] = 'Yes';
$string['at'] = 'at';
$string['From'] = 'From';
$string['To'] = 'To';
......
......@@ -4298,3 +4298,39 @@ function can_use_skins($userid = null, $managesiteskin=false, $issiteview=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}
<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}
{$item.value|safe}
{/foreach}
......@@ -21,7 +21,13 @@ jQuery(function() {
}
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>
\ No newline at end of file
</script>
......@@ -25,6 +25,7 @@ $form = get_config_options_extended();
$smarty = smarty_core();
$smarty->assign('form', $form);
$smarty->assign('opened', param_alphanumext('open', ''));
$mainform = $smarty->fetch('auth:webservice:configform.tpl');
unset($smarty);
......@@ -59,7 +60,7 @@ function activate_webservices_submit(Pieform $form, $values) {
}
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) {
......@@ -67,7 +68,7 @@ function activate_webservice_proto_submit(Pieform $form, $values) {
$enabled = $values['enabled'] ? 0 : 1;
$proto = $values['protocol'];
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) {
......@@ -104,7 +105,7 @@ function webservices_function_groups_submit(Pieform $form, $values) {
}
// 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) {
......@@ -151,7 +152,7 @@ function webservices_token_submit(Pieform $form, $values) {
}
// 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) {
......@@ -210,7 +211,7 @@ function webservices_user_submit(Pieform $form, $values) {
}
// 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() {
'class' => 'linkbtn',
'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() {
'class' => 'linkbtn',
'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() {
'title' => ' ',
'class' => 'header',
'type' => 'html',
'value' => get_string('enabled', 'auth.webservice'),
'value' => get_string('enabled'),
),
'restricted' => array(
'title' => ' ',
......@@ -368,21 +369,21 @@ function service_fg_edit_form() {
'key' => $service->name,
);
$form['elements']['id'. $service->id . '_enabled'] = array(
'defaultvalue' => (($service->enabled == 1) ? 'checked' : ''),
'type' => 'checkbox',
'disabled' => true,
'value' => (($service->enabled == 1) ? display_icon('enabled') : display_icon('disabled')),
'type' => 'html',
'class' => 'center',
'key' => $service->name,
);
$form['elements']['id'. $service->id . '_restricted'] = array(
'defaultvalue' => (($service->restrictedusers == 1) ? 'checked' : ''),
'type' => 'checkbox',
'disabled' => true,
'value' => (($service->restrictedusers == 1) ? display_icon('enabled') : display_icon('disabled')),
'type' => 'html',
'class' => 'center',
'key' => $service->name,
);
$form['elements']['id'. $service->id . '_tokenusers'] = array(
'defaultvalue' => (($service->tokenusers == 1) ? 'checked' : ''),
'type' => 'checkbox',
'disabled' => true,
'value' => (($service->tokenusers == 1) ? display_icon('enabled') : display_icon('disabled')),
'type' => 'html',
'class' => 'center',
'key' => $service->name,
);
$functions = get_records_array('external_services_functions', 'externalserviceid', $service->id);
......@@ -509,7 +510,7 @@ function service_tokens_edit_form() {
'title' => ' ',
'class' => 'header',
'type' => 'html',
'value' => get_string('enabled', 'auth.webservice'),
'value' => get_string('enabled'),
),
'wssigenc' => array(
'title' => ' ',
......@@ -557,15 +558,15 @@ function service_tokens_edit_form() {
'key' => $token->token,
);
$form['elements']['id'. $token->tokenid . '_enabled'] = array(
'defaultvalue' => (($token->enabled == 1) ? 'checked' : ''),
'type' => 'checkbox',
'disabled' => true,
'value' => (($token->enabled == 1) ? display_icon('enabled') : display_icon('disabled')),
'type' => 'html',
'class' => 'center',
'key' => $token->token,
);
$form['elements']['id'. $token->tokenid . '_wssigenc'] = array(
'defaultvalue' => (($token->wssigenc == 1) ? 'checked' : ''),
'type' => 'checkbox',
'disabled' => true,
'value' => (($token->wssigenc == 1) ? display_icon('enabled') : display_icon('disabled')),
'type' => 'html',
'class' => 'center',
'key' => $token->token,
);
......@@ -710,7 +711,7 @@ function service_users_edit_form() {
'title' => ' ',
'class' => 'header',
'type' => 'html',
'value' => get_string('enabled', 'auth.webservice'),
'value' => get_string('enabled'),
),
'wssigenc' => array(
'title' => ' ',
......@@ -753,15 +754,15 @@ function service_users_edit_form() {
'key' => $user->id,
);
$form['elements']['id'. $user->id . '_enabled'] = array(
'defaultvalue' => (($user->enabled == 1) ? 'checked' : ''),
'type' => 'checkbox',
'disabled' => true,
'value' => (($user->enabled == 1) ? display_icon('enabled') : display_icon('disabled')),
'type' => 'html',
'class' => 'center',
'key' => $user->id,
);
$form['elements']['id'. $user->id . '_wssigenc'] = array(
'defaultvalue' => (($user->wssigenc == 1) ? 'checked' : ''),
'type' => 'checkbox',
'disabled' => true,
'value' => (($user->wssigenc == 1) ? display_icon('enabled') : display_icon('disabled')),
'type' => 'html',
'class' => 'center',
'key' => $user->id,
);
......@@ -900,6 +901,7 @@ function get_config_options_extended() {
'elements' => webservices_master_switch_form(),
'collapsible' => true,
'collapsed' => true,
'name' => 'activate_webservices',
),
// fieldset of protocol switches
......@@ -918,6 +920,7 @@ function get_config_options_extended() {
),
'collapsible' => true,
'collapsed' => true,
'name' => 'activate_webservices_protos',
),
// System Certificates
......@@ -951,6 +954,7 @@ function get_config_options_extended() {
),
'collapsible' => true,
'collapsed' => true,
'name' => 'activate_webservices_networking',
),
// fieldset for managing service function groups
......@@ -968,6 +972,7 @@ function get_config_options_extended() {
),
'collapsible' => true,
'collapsed' => true,
'name' => 'webservices_function_groups',
),
......@@ -986,6 +991,7 @@ function get_config_options_extended() {
),
'collapsible' => true,
'collapsed' => false,
'name' => 'webservices_token',
),
// fieldset for managing service tokens
......@@ -1003,6 +1009,7 @@ function get_config_options_extended() {
),
'collapsible' => true,
'collapsed' => false,
'name' => 'webservices_user',
),
);
$form = array(
......
......@@ -216,7 +216,7 @@ function webservice_server_edit_form($dbserver, $sopts, $iopts) {
);
$server_details['elements']['enabled'] = array(
'title' => get_string('enabled', 'auth.webservice'),
'title' => get_string('enabled'),
'defaultvalue' => (($dbserver->enabled == 1) ? 'checked' : ''),
'type' => 'checkbox',
'disabled' => true,
......@@ -332,7 +332,7 @@ function webservice_server_list_form($sopts, $iopts) {
'title' => ' ',
'class' => 'header',
'type' => 'html',
'value' => get_string('enabled', 'auth.webservice'),
'value' => get_string('enabled'),
),
'calback_uri' => array(
'title' => ' ',
......
......@@ -38,7 +38,7 @@ $functions =
'title' => ' ',
'class' => 'header',
'type' => 'html',
'value' => get_string('enabled', 'auth.webservice'),
'value' => get_string('enabled'),
),
'classname' => array(
'title' => ' ',
......@@ -113,7 +113,7 @@ $elements = array(
'class' => 'linkbtn',
'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(
'class' => 'linkbtn',
'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(
);
$token_details['elements']['enabled'] = array(
'title' => get_string('enabled', 'auth.webservice'),
'title' => get_string('enabled'),
'defaultvalue' => (($dbservice->enabled == 1) ? 'checked' : ''),
'type' => 'checkbox',
'disabled' => true,
......
......@@ -111,7 +111,7 @@ $serviceuser_details['elements']['service'] = array(
);
$serviceuser_details['elements']['enabled'] = array(
'title' => get_string('enabled', 'auth.webservice'),
'title' => get_string('enabled'),
'defaultvalue' => (($serviceenabled == 1) ? 'checked' : ''),
'type' => 'checkbox',
'disabled' => true,
......
......@@ -68,7 +68,7 @@ if (!empty($dbservices)) {
'title' => ' ',
'class' => 'header',
'type' => 'html',
'value' => get_string('enabled', 'auth.webservice'),
'value' => get_string('enabled'),
),
'token' => array(
'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