Skip to content

Commit

Permalink
MDL-30170 MNet peers administration - highlight the undelete widget
Browse files Browse the repository at this point in the history
The patch highlights the undelete radio selector at the host edit form.
It moves it to the end of the form (near the submit button) and displays
an explanation above the radio selector.

Also, the list of deleted hosts is now displayed below the table of
active peers at the Manage peers page.

The data returned by mnet_get_hosts() function now contain the deleted
status, too. It is possible to obtain deleted hosts from that function
now.
  • Loading branch information
mudrd8mz committed Dec 15, 2011
1 parent 40f4b5c commit 9e710a2
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 37 deletions.
23 changes: 13 additions & 10 deletions admin/mnet/peer_forms.php
Expand Up @@ -96,15 +96,6 @@ function definition() {
$mform->addElement('textarea', 'public_key', get_string('publickey', 'mnet'), array('rows' => 17, 'cols' => 100, 'class' => 'smalltext')); $mform->addElement('textarea', 'public_key', get_string('publickey', 'mnet'), array('rows' => 17, 'cols' => 100, 'class' => 'smalltext'));
$mform->setType('public_key', PARAM_PEM); $mform->setType('public_key', PARAM_PEM);


if ($mnet_peer && !empty($mnet_peer->deleted)) {
$radioarray = array();
$radioarray[] = MoodleQuickForm::createElement('radio', 'deleted', '', get_string('yes'), 1);
$radioarray[] = MoodleQuickForm::createElement('radio', 'deleted', '', get_string('no'), 0);
$mform->addGroup($radioarray, 'radioar', get_string('deleted'), array(' '), false);
} else {
$mform->addElement('hidden', 'deleted');
}

// finished with form controls, now the static informational stuff // finished with form controls, now the static informational stuff
if ($mnet_peer && !empty($mnet_peer->bootstrapped)) { if ($mnet_peer && !empty($mnet_peer->bootstrapped)) {
$expires = ''; $expires = '';
Expand Down Expand Up @@ -140,7 +131,19 @@ function definition() {
} }
} }


$mform->addElement('static', 'certdetails', get_string('certdetails', 'mnet'), $OUTPUT->box('<pre>' . $credstr . '</pre>')); $mform->addElement('static', 'certdetails', get_string('certdetails', 'mnet'),
$OUTPUT->box('<pre>' . $credstr . '</pre>', 'generalbox certdetails'));
}

if ($mnet_peer && !empty($mnet_peer->deleted)) {
$radioarray = array();
$radioarray[] = MoodleQuickForm::createElement('static', 'deletedinfo', '',
$OUTPUT->container(get_string('deletedhostinfo', 'mnet'), 'deletedhostinfo'));
$radioarray[] = MoodleQuickForm::createElement('radio', 'deleted', '', get_string('yes'), 1);
$radioarray[] = MoodleQuickForm::createElement('radio', 'deleted', '', get_string('no'), 0);
$mform->addGroup($radioarray, 'radioar', get_string('deleted'), array(' ', ' '), false);
} else {
$mform->addElement('hidden', 'deleted');
} }


// finished with static stuff, print save button // finished with static stuff, print save button
Expand Down
16 changes: 15 additions & 1 deletion admin/mnet/peers.php
Expand Up @@ -190,7 +190,7 @@


// normal flow - just display all hosts with links // normal flow - just display all hosts with links
echo $OUTPUT->header(); echo $OUTPUT->header();
$hosts = mnet_get_hosts(); $hosts = mnet_get_hosts(true);


// print the table to display the register all hosts setting // print the table to display the register all hosts setting
$table = new html_table(); $table = new html_table();
Expand Down Expand Up @@ -231,11 +231,21 @@
); );
$table->wrap = array('nowrap', 'nowrap', 'nowrap', 'nowrap'); $table->wrap = array('nowrap', 'nowrap', 'nowrap', 'nowrap');
$baseurl = new moodle_url('/admin/mnet/peers.php'); $baseurl = new moodle_url('/admin/mnet/peers.php');
$deleted = array();
foreach($hosts as $host) { foreach($hosts as $host) {
$hosturl = new moodle_url($baseurl, array('hostid' => $host->id)); $hosturl = new moodle_url($baseurl, array('hostid' => $host->id));
if (trim($host->name) === '') {
// should not happen but...
$host->name = '???';
}
// 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::tag('a', $host->name, array('href'=>$hosturl)), '', '', '');
}

// populate the list of deleted hosts
if ($host->deleted) {
$deleted[] = html_writer::link($hosturl, $host->name);
continue; continue;
} }


Expand All @@ -253,6 +263,10 @@
} }
echo html_writer::table($table); echo html_writer::table($table);


if ($deleted) {
echo $OUTPUT->box(get_string('deletedhosts', 'core_mnet', join(', ', $deleted)), 'deletedhosts');
}

// finally, print the initial form to add a new host // finally, print the initial form to add a new host
echo $OUTPUT->box_start(); echo $OUTPUT->box_start();
echo $OUTPUT->heading(get_string('addnewhost', 'mnet'), 3); echo $OUTPUT->heading(get_string('addnewhost', 'mnet'), 3);
Expand Down
2 changes: 2 additions & 0 deletions lang/en/mnet.php
Expand Up @@ -47,6 +47,8 @@
$string['databaseerror'] = 'Could not write details to the database.'; $string['databaseerror'] = 'Could not write details to the database.';
$string['deleteaserver'] = 'Deleting a server'; $string['deleteaserver'] = 'Deleting a server';
$string['deletehost'] = 'Delete host'; $string['deletehost'] = 'Delete host';
$string['deletedhostinfo'] = 'This host has been deleted. If you want to undelete it, switch the deleted status back to \'No\'.';
$string['deletedhosts'] = 'Deleted hosts: {$a}';
$string['deletekeycheck'] = 'Are you absolutely sure you want to delete this key?'; $string['deletekeycheck'] = 'Are you absolutely sure you want to delete this key?';
$string['deleteoutoftime'] = 'Your 60-second window for deleting this key has expired. Please start again.'; $string['deleteoutoftime'] = 'Your 60-second window for deleting this key has expired. Please start again.';
$string['deleteuserrecord'] = 'SSO ACL: delete record for user \'{$a->user}\' from {$a->host}.'; $string['deleteuserrecord'] = 'SSO ACL: delete record for user \'{$a->user}\' from {$a->host}.';
Expand Down
44 changes: 18 additions & 26 deletions mnet/lib.php
Expand Up @@ -645,36 +645,28 @@ function mnet_profile_field_options() {




/** /**
* Return information about all the current hosts * Returns information about MNet peers
* This is basically just a resultset.
* *
* @param bool $withdeleted should the deleted peers be returned too
* @return array * @return array
*/ */
function mnet_get_hosts() { function mnet_get_hosts($withdeleted = false) {
global $CFG, $DB; global $CFG, $DB;
return $DB->get_records_sql(' SELECT
h.id, $sql = "SELECT h.id, h.deleted, h.wwwroot, h.ip_address, h.name, h.public_key, h.public_key_expires,
h.wwwroot, h.transport, h.portno, h.last_connect_time, h.last_log_id, h.applicationid,
h.ip_address, a.name as app_name, a.display_name as app_display_name, a.xmlrpc_server_url
h.name, FROM {mnet_host} h
h.public_key, JOIN {mnet_application} a ON h.applicationid = a.id
h.public_key_expires, WHERE h.id <> ?";
h.transport,
h.portno, if (!$withdeleted) {
h.last_connect_time, $sql .= " AND h.deleted = 0";
h.last_log_id, }
h.applicationid,
a.name as app_name, $sql .= " ORDER BY h.deleted, h.name, h.id";
a.display_name as app_display_name,
a.xmlrpc_server_url return $DB->get_records_sql($sql, array($CFG->mnet_localhost_id));
FROM
{mnet_host} h,
{mnet_application} a
WHERE
h.id <> ? AND
h.deleted = 0 AND
h.applicationid=a.id',
array($CFG->mnet_localhost_id));
} }




Expand Down
5 changes: 5 additions & 0 deletions theme/base/style/admin.css
Expand Up @@ -206,3 +206,8 @@
#page-admin-plugins #plugins-control-panel .disabled .availability {background-color:#eee;} #page-admin-plugins #plugins-control-panel .disabled .availability {background-color:#eee;}
#page-admin-plugins #plugins-control-panel .extension .source {background-color:#f3f2aa;} #page-admin-plugins #plugins-control-panel .extension .source {background-color:#f3f2aa;}
#page-admin-plugins #plugins-control-panel .msg td {text-align:center;} #page-admin-plugins #plugins-control-panel .msg td {text-align:center;}

/** MNet networking */
#page-admin-mnet-peers .box.deletedhosts {margin-bottom:1em;font-size:80%;}
#page-admin-mnet-peers .mform .certdetails {background-color:white;}
#page-admin-mnet-peers .mform .deletedhostinfo {background-color:#ffd3d9;border 2px solid #eeaaaa;padding:4px;margin-bottom:5px;}

0 comments on commit 9e710a2

Please sign in to comment.