Skip to content
Browse files

Merge branch 'MDL-30170-mnet-undelete_21_STABLE' of git://github.com/…

…mudrd8mz/moodle into MOODLE_21_STABLE
  • Loading branch information...
2 parents 65f3793 + e0eb0af commit 7f50276ea01c03150a5b3a858358063399b81687 @stronk7 stronk7 committed Dec 20, 2011
Showing with 68 additions and 44 deletions.
  1. +19 −13 admin/mnet/peer_forms.php
  2. +19 −4 admin/mnet/peers.php
  3. +3 −0 admin/settings/mnet.php
  4. +4 −1 lang/en/mnet.php
  5. +18 −26 mnet/lib.php
  6. +5 −0 theme/base/style/admin.css
View
32 admin/mnet/peer_forms.php
@@ -38,9 +38,10 @@ function definition() {
$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->addRule('wwwroot', null, 'required', null, 'client');
+ $mform->addRule('wwwroot', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$mform->addElement('select', 'applicationid', get_string('applicationtype', 'mnet'),
$DB->get_records_menu('mnet_application', array(), 'id,display_name'));
@@ -81,11 +82,13 @@ function definition() {
$mform->addElement('hidden', 'applicationid');
$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->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->addRule('wwwroot', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$themes = array('' => get_string('forceno'));
foreach (array_keys(get_plugin_list('theme')) as $themename) {
@@ -96,15 +99,6 @@ function definition() {
$mform->addElement('textarea', 'public_key', get_string('publickey', 'mnet'), array('rows' => 17, 'cols' => 100, 'class' => 'smalltext'));
$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
if ($mnet_peer && !empty($mnet_peer->bootstrapped)) {
$expires = '';
@@ -140,7 +134,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
View
23 admin/mnet/peers.php
@@ -190,7 +190,7 @@
// normal flow - just display all hosts with links
echo $OUTPUT->header();
-$hosts = mnet_get_hosts();
+$hosts = mnet_get_hosts(true);
// print the table to display the register all hosts setting
$table = new html_table();
@@ -231,28 +231,43 @@
);
$table->wrap = array('nowrap', 'nowrap', 'nowrap', 'nowrap');
$baseurl = new moodle_url('/admin/mnet/peers.php');
+$deleted = array();
foreach($hosts as $host) {
$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
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
+ if ($host->deleted) {
+ $deleted[] = html_writer::link($hosturl, $host->name);
continue;
}
if ($host->last_connect_time == 0) {
$last_connect = get_string('never');
} 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(
html_writer::link($hosturl, $host->name),
- html_writer::link($hosturl, $host->wwwroot),
+ html_writer::link($host->wwwroot, $host->wwwroot),
$last_connect,
$OUTPUT->single_button(new moodle_url('/admin/mnet/delete.php', array('hostid' => $host->id)), get_string('delete'))
);
}
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
echo $OUTPUT->box_start();
echo $OUTPUT->heading(get_string('addnewhost', 'mnet'), 3);
View
3 admin/settings/mnet.php
@@ -22,6 +22,9 @@
$hosts = mnet_get_hosts();
foreach ($hosts as $host) {
+ if ($host->id == $CFG->mnet_all_hosts_id) {
+ $host->name = get_string('allhosts', 'core_mnet');
+ }
$ADMIN->add('mnetpeercat',
new admin_externalpage(
'mnetpeer' . $host->id,
View
5 lang/en/mnet.php
@@ -28,6 +28,7 @@
$string['addhost'] = 'Add host';
$string['addnewhost'] = 'Add a new host';
$string['addtoacl'] = 'Add to access control';
+$string['allhosts'] = 'All hosts';
$string['allhosts_no_options'] = 'No options are available when viewing multiple hosts';
$string['allow'] = 'Allow';
$string['applicationtype'] = 'Application type';
@@ -47,6 +48,8 @@
$string['databaseerror'] = 'Could not write details to the database.';
$string['deleteaserver'] = 'Deleting a server';
$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['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}.';
@@ -77,7 +80,7 @@
$string['hideremote'] = 'Hide remote users';
$string['host'] = 'host';
$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['hostlist'] = 'List of networked hosts';
$string['hostname'] = 'Hostname';
View
44 mnet/lib.php
@@ -645,36 +645,28 @@ function mnet_profile_field_options() {
/**
- * Return information about all the current hosts
- * This is basically just a resultset.
+ * Returns information about MNet peers
*
+ * @param bool $withdeleted should the deleted peers be returned too
* @return array
*/
-function mnet_get_hosts() {
+function mnet_get_hosts($withdeleted = false) {
global $CFG, $DB;
- return $DB->get_records_sql(' SELECT
- h.id,
- h.wwwroot,
- h.ip_address,
- h.name,
- h.public_key,
- h.public_key_expires,
- h.transport,
- h.portno,
- h.last_connect_time,
- h.last_log_id,
- h.applicationid,
- a.name as app_name,
- a.display_name as app_display_name,
- a.xmlrpc_server_url
- FROM
- {mnet_host} h,
- {mnet_application} a
- WHERE
- h.id <> ? AND
- h.deleted = 0 AND
- h.applicationid=a.id',
- array($CFG->mnet_localhost_id));
+
+ $sql = "SELECT h.id, h.deleted, h.wwwroot, h.ip_address, h.name, h.public_key, h.public_key_expires,
+ h.transport, h.portno, h.last_connect_time, h.last_log_id, h.applicationid,
+ a.name as app_name, a.display_name as app_display_name, a.xmlrpc_server_url
+ FROM {mnet_host} h
+ JOIN {mnet_application} a ON h.applicationid = a.id
+ WHERE h.id <> ?";
+
+ if (!$withdeleted) {
+ $sql .= " AND h.deleted = 0";
+ }
+
+ $sql .= " ORDER BY h.deleted, h.name, h.id";
+
+ return $DB->get_records_sql($sql, array($CFG->mnet_localhost_id));
}
View
5 theme/base/style/admin.css
@@ -206,3 +206,8 @@
#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 .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 7f50276

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