Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-30170 MNet peers administration - highlight the undelete widget

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...
commit cac3efc3e288e14cfd1e3375abbba2279496a0c0 1 parent 1835502
David Mudrák mudrd8mz authored stronk7 committed
23 admin/mnet/peer_forms.php
@@ -96,15 +96,6 @@ function definition() {
96 96 $mform->addElement('textarea', 'public_key', get_string('publickey', 'mnet'), array('rows' => 17, 'cols' => 100, 'class' => 'smalltext'));
97 97 $mform->setType('public_key', PARAM_PEM);
98 98
99   - if ($mnet_peer && !empty($mnet_peer->deleted)) {
100   - $radioarray = array();
101   - $radioarray[] = MoodleQuickForm::createElement('radio', 'deleted', '', get_string('yes'), 1);
102   - $radioarray[] = MoodleQuickForm::createElement('radio', 'deleted', '', get_string('no'), 0);
103   - $mform->addGroup($radioarray, 'radioar', get_string('deleted'), array(' '), false);
104   - } else {
105   - $mform->addElement('hidden', 'deleted');
106   - }
107   -
108 99 // finished with form controls, now the static informational stuff
109 100 if ($mnet_peer && !empty($mnet_peer->bootstrapped)) {
110 101 $expires = '';
@@ -140,7 +131,19 @@ function definition() {
140 131 }
141 132 }
142 133
143   - $mform->addElement('static', 'certdetails', get_string('certdetails', 'mnet'), $OUTPUT->box('<pre>' . $credstr . '</pre>'));
  134 + $mform->addElement('static', 'certdetails', get_string('certdetails', 'mnet'),
  135 + $OUTPUT->box('<pre>' . $credstr . '</pre>', 'generalbox certdetails'));
  136 + }
  137 +
  138 + if ($mnet_peer && !empty($mnet_peer->deleted)) {
  139 + $radioarray = array();
  140 + $radioarray[] = MoodleQuickForm::createElement('static', 'deletedinfo', '',
  141 + $OUTPUT->container(get_string('deletedhostinfo', 'mnet'), 'deletedhostinfo'));
  142 + $radioarray[] = MoodleQuickForm::createElement('radio', 'deleted', '', get_string('yes'), 1);
  143 + $radioarray[] = MoodleQuickForm::createElement('radio', 'deleted', '', get_string('no'), 0);
  144 + $mform->addGroup($radioarray, 'radioar', get_string('deleted'), array(' ', ' '), false);
  145 + } else {
  146 + $mform->addElement('hidden', 'deleted');
144 147 }
145 148
146 149 // finished with static stuff, print save button
16 admin/mnet/peers.php
@@ -190,7 +190,7 @@
190 190
191 191 // normal flow - just display all hosts with links
192 192 echo $OUTPUT->header();
193   -$hosts = mnet_get_hosts();
  193 +$hosts = mnet_get_hosts(true);
194 194
195 195 // print the table to display the register all hosts setting
196 196 $table = new html_table();
@@ -231,11 +231,21 @@
231 231 );
232 232 $table->wrap = array('nowrap', 'nowrap', 'nowrap', 'nowrap');
233 233 $baseurl = new moodle_url('/admin/mnet/peers.php');
  234 +$deleted = array();
234 235 foreach($hosts as $host) {
235 236 $hosturl = new moodle_url($baseurl, array('hostid' => $host->id));
  237 + if (trim($host->name) === '') {
  238 + // should not happen but...
  239 + $host->name = '???';
  240 + }
236 241 // process all hosts first since it's the easiest
237 242 if ($host->id == $CFG->mnet_all_hosts_id) {
238 243 $table->data[] = array(html_writer::tag('a', $host->name, array('href'=>$hosturl)), '', '', '');
  244 + }
  245 +
  246 + // populate the list of deleted hosts
  247 + if ($host->deleted) {
  248 + $deleted[] = html_writer::link($hosturl, $host->name);
239 249 continue;
240 250 }
241 251
@@ -253,6 +263,10 @@
253 263 }
254 264 echo html_writer::table($table);
255 265
  266 +if ($deleted) {
  267 + echo $OUTPUT->box(get_string('deletedhosts', 'core_mnet', join(', ', $deleted)), 'deletedhosts');
  268 +}
  269 +
256 270 // finally, print the initial form to add a new host
257 271 echo $OUTPUT->box_start();
258 272 echo $OUTPUT->heading(get_string('addnewhost', 'mnet'), 3);
2  lang/en/mnet.php
@@ -47,6 +47,8 @@
47 47 $string['databaseerror'] = 'Could not write details to the database.';
48 48 $string['deleteaserver'] = 'Deleting a server';
49 49 $string['deletehost'] = 'Delete host';
  50 +$string['deletedhostinfo'] = 'This host has been deleted. If you want to undelete it, switch the deleted status back to \'No\'.';
  51 +$string['deletedhosts'] = 'Deleted hosts: {$a}';
50 52 $string['deletekeycheck'] = 'Are you absolutely sure you want to delete this key?';
51 53 $string['deleteoutoftime'] = 'Your 60-second window for deleting this key has expired. Please start again.';
52 54 $string['deleteuserrecord'] = 'SSO ACL: delete record for user \'{$a->user}\' from {$a->host}.';
44 mnet/lib.php
@@ -645,36 +645,28 @@ function mnet_profile_field_options() {
645 645
646 646
647 647 /**
648   - * Return information about all the current hosts
649   - * This is basically just a resultset.
  648 + * Returns information about MNet peers
650 649 *
  650 + * @param bool $withdeleted should the deleted peers be returned too
651 651 * @return array
652 652 */
653   -function mnet_get_hosts() {
  653 +function mnet_get_hosts($withdeleted = false) {
654 654 global $CFG, $DB;
655   - return $DB->get_records_sql(' SELECT
656   - h.id,
657   - h.wwwroot,
658   - h.ip_address,
659   - h.name,
660   - h.public_key,
661   - h.public_key_expires,
662   - h.transport,
663   - h.portno,
664   - h.last_connect_time,
665   - h.last_log_id,
666   - h.applicationid,
667   - a.name as app_name,
668   - a.display_name as app_display_name,
669   - a.xmlrpc_server_url
670   - FROM
671   - {mnet_host} h,
672   - {mnet_application} a
673   - WHERE
674   - h.id <> ? AND
675   - h.deleted = 0 AND
676   - h.applicationid=a.id',
677   - array($CFG->mnet_localhost_id));
  655 +
  656 + $sql = "SELECT h.id, h.deleted, h.wwwroot, h.ip_address, h.name, h.public_key, h.public_key_expires,
  657 + h.transport, h.portno, h.last_connect_time, h.last_log_id, h.applicationid,
  658 + a.name as app_name, a.display_name as app_display_name, a.xmlrpc_server_url
  659 + FROM {mnet_host} h
  660 + JOIN {mnet_application} a ON h.applicationid = a.id
  661 + WHERE h.id <> ?";
  662 +
  663 + if (!$withdeleted) {
  664 + $sql .= " AND h.deleted = 0";
  665 + }
  666 +
  667 + $sql .= " ORDER BY h.deleted, h.name, h.id";
  668 +
  669 + return $DB->get_records_sql($sql, array($CFG->mnet_localhost_id));
678 670 }
679 671
680 672
5 theme/base/style/admin.css
@@ -201,3 +201,8 @@
201 201 #page-admin-plugins #plugins-control-panel .disabled .availability {background-color:#eee;}
202 202 #page-admin-plugins #plugins-control-panel .extension .source {background-color:#f3f2aa;}
203 203 #page-admin-plugins #plugins-control-panel .msg td {text-align:center;}
  204 +
  205 +/** MNet networking */
  206 +#page-admin-mnet-peers .box.deletedhosts {margin-bottom:1em;font-size:80%;}
  207 +#page-admin-mnet-peers .mform .certdetails {background-color:white;}
  208 +#page-admin-mnet-peers .mform .deletedhostinfo {background-color:#ffd3d9;border 2px solid #eeaaaa;padding:4px;margin-bottom:5px;}

0 comments on commit cac3efc

Please sign in to comment.
Something went wrong with that request. Please try again.