Skip to content

Commit

Permalink
MDL-30170 MNet peers administration - various usability improvements
Browse files Browse the repository at this point in the history
While fixing MDL-30170, the following tiny usability details were
improved along the way:

* the maximum length of the peer site title and the hostname is now
  validated (this was actually a real bug as the default value is pre-loaded
  from the peer) so the admin gets a nice validation error instead of
  the database write exception when trying to register a host with a
  longer site title.
* hard-coded English string 'All Hosts' is now localized
* the hostname link in the list of MNet peers leads to the peer itself
  • Loading branch information
mudrd8mz authored and stronk7 committed Dec 20, 2011
1 parent cac3efc commit 06f9aec
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
9 changes: 6 additions & 3 deletions admin/mnet/peer_forms.php
Expand Up @@ -38,9 +38,10 @@ function definition() {


$mform = $this->_form; $mform = $this->_form;


$mform->addElement('text', 'wwwroot', get_string('hostname', 'mnet')); $mform->addElement('text', 'wwwroot', get_string('hostname', 'mnet'), array('maxlength' => 255, 'size' => 50));
$mform->setType('wwwroot', PARAM_URL); $mform->setType('wwwroot', PARAM_URL);
$mform->addRule('wwwroot', null, 'required', null, 'client'); $mform->addRule('wwwroot', null, 'required', null, 'client');
$mform->addRule('wwwroot', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');


$mform->addElement('select', 'applicationid', get_string('applicationtype', 'mnet'), $mform->addElement('select', 'applicationid', get_string('applicationtype', 'mnet'),
$DB->get_records_menu('mnet_application', array(), 'id,display_name')); $DB->get_records_menu('mnet_application', array(), 'id,display_name'));
Expand Down Expand Up @@ -81,11 +82,13 @@ function definition() {
$mform->addElement('hidden', 'applicationid'); $mform->addElement('hidden', 'applicationid');
$mform->addElement('hidden', 'oldpublickey'); $mform->addElement('hidden', 'oldpublickey');


$mform->addElement('text', 'name', get_string('site')); $mform->addElement('text', 'name', get_string('site'), array('maxlength' => 80, 'size' => 50));
$mform->setType('name', PARAM_NOTAGS); $mform->setType('name', PARAM_NOTAGS);
$mform->addRule('name', get_string('maximumchars', '', 80), 'maxlength', 80, 'client');


$mform->addElement('text', 'wwwroot', get_string('hostname', 'mnet')); $mform->addElement('text', 'wwwroot', get_string('hostname', 'mnet'), array('maxlength' => 255, 'size' => 50));
$mform->setType('wwwroot', PARAM_URL); $mform->setType('wwwroot', PARAM_URL);
$mform->addRule('wwwroot', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');


$themes = array('' => get_string('forceno')); $themes = array('' => get_string('forceno'));
foreach (array_keys(get_plugin_list('theme')) as $themename) { foreach (array_keys(get_plugin_list('theme')) as $themename) {
Expand Down
7 changes: 4 additions & 3 deletions admin/mnet/peers.php
Expand Up @@ -240,7 +240,8 @@
} }
// process all hosts first since it's the easiest // process all hosts first since it's the easiest
if ($host->id == $CFG->mnet_all_hosts_id) { if ($host->id == $CFG->mnet_all_hosts_id) {
$table->data[] = array(html_writer::tag('a', $host->name, array('href'=>$hosturl)), '', '', ''); $table->data[] = array(html_writer::link($hosturl, get_string('allhosts', 'core_mnet')), '*', '', '');
continue;
} }


// populate the list of deleted hosts // populate the list of deleted hosts
Expand All @@ -252,11 +253,11 @@
if ($host->last_connect_time == 0) { if ($host->last_connect_time == 0) {
$last_connect = get_string('never'); $last_connect = get_string('never');
} else { } else {
$last_connect = date('H:i:s d/m/Y', $host->last_connect_time); $last_connect = userdate($host->last_connect_time, get_string('strftimedatetime', 'core_langconfig'));
} }
$table->data[] = array( $table->data[] = array(
html_writer::link($hosturl, $host->name), html_writer::link($hosturl, $host->name),
html_writer::link($hosturl, $host->wwwroot), html_writer::link($host->wwwroot, $host->wwwroot),
$last_connect, $last_connect,
$OUTPUT->single_button(new moodle_url('/admin/mnet/delete.php', array('hostid' => $host->id)), get_string('delete')) $OUTPUT->single_button(new moodle_url('/admin/mnet/delete.php', array('hostid' => $host->id)), get_string('delete'))
); );
Expand Down
3 changes: 3 additions & 0 deletions admin/settings/mnet.php
Expand Up @@ -22,6 +22,9 @@


$hosts = mnet_get_hosts(); $hosts = mnet_get_hosts();
foreach ($hosts as $host) { foreach ($hosts as $host) {
if ($host->id == $CFG->mnet_all_hosts_id) {
$host->name = get_string('allhosts', 'core_mnet');
}
$ADMIN->add('mnetpeercat', $ADMIN->add('mnetpeercat',
new admin_externalpage( new admin_externalpage(
'mnetpeer' . $host->id, 'mnetpeer' . $host->id,
Expand Down
3 changes: 2 additions & 1 deletion lang/en/mnet.php
Expand Up @@ -28,6 +28,7 @@
$string['addhost'] = 'Add host'; $string['addhost'] = 'Add host';
$string['addnewhost'] = 'Add a new host'; $string['addnewhost'] = 'Add a new host';
$string['addtoacl'] = 'Add to access control'; $string['addtoacl'] = 'Add to access control';
$string['allhosts'] = 'All hosts';
$string['allhosts_no_options'] = 'No options are available when viewing multiple hosts'; $string['allhosts_no_options'] = 'No options are available when viewing multiple hosts';
$string['allow'] = 'Allow'; $string['allow'] = 'Allow';
$string['applicationtype'] = 'Application type'; $string['applicationtype'] = 'Application type';
Expand Down Expand Up @@ -79,7 +80,7 @@
$string['hideremote'] = 'Hide remote users'; $string['hideremote'] = 'Hide remote users';
$string['host'] = 'host'; $string['host'] = 'host';
$string['hostcoursenotfound'] = 'Host or course not found'; $string['hostcoursenotfound'] = 'Host or course not found';
$string['hostdeleted'] = 'Ok - host deleted'; $string['hostdeleted'] = 'Host deleted';
$string['hostexists'] = 'A record already exists for a host with that hostname (it may be deleted). <a href="{$a}">click here</a> to edit that record.'; $string['hostexists'] = 'A record already exists for a host with that hostname (it may be deleted). <a href="{$a}">click here</a> to edit that record.';
$string['hostlist'] = 'List of networked hosts'; $string['hostlist'] = 'List of networked hosts';
$string['hostname'] = 'Hostname'; $string['hostname'] = 'Hostname';
Expand Down

0 comments on commit 06f9aec

Please sign in to comment.