MDL-22787 MNet enrolment: Removing legacy client side scripts and their strings

This commit is contained in:
David Mudrak 2010-07-17 22:33:31 +00:00
parent ef75ea6c1c
commit 8ed6e35c7a
5 changed files with 0 additions and 543 deletions

View file

@ -1,104 +0,0 @@
<form id="assignform" method="post" action="">
<div id="trustedhosts"><!-- See theme/standard/styles_layout.css #trustedhosts .generaltable for rules -->
<input type="hidden" name="previoussearch" value="<?php p($previoussearch) ?>" />
<input type="hidden" name="courseid" value="<?php p($courseid) ?>" />
<input type="hidden" name="host" value="<?php p($mnet_peer->id) ?>" />
<input type="hidden" name="sesskey" value="<?php p(sesskey()) ?>" />
<table class="generaltable" border="0" cellpadding="5" cellspacing="0">
<tr>
<td valign="top">
<?php print_string('existingusers', 'role', count($mnetenrolledusers)); ?>
</td>
<td></td>
<td valign="top">
<?php print_string('potentialusers', 'role', $availablecount); ?>
</td>
</tr>
<tr>
<td valign="top">
<select name="removeselect[]" size="20" id="removeselect" multiple="multiple"
onfocus="getElementById('assignform').add.disabled=true;
getElementById('assignform').remove.disabled=false;
getElementById('assignform').addselect.selectedIndex=-1;">
<?php
foreach ($mnetenrolledusers as $enrolleduser) {
$fullname = fullname($enrolleduser, true);
echo "<option value=\"$enrolleduser->id\">".s($fullname)." (".s($enrolleduser->rolename).")</option>\n";
}
?>
</select></td>
<td valign="top">
<br />
<input name="add" type="submit" id="add" value="&larr;" />
<br />
<input name="remove" type="submit" id="remove" value="&rarr;" />
<br />
</td>
<td valign="top">
<select name="addselect[]" size="20" id="addselect" multiple="multiple"
onfocus="getElementById('assignform').add.disabled=false;
getElementById('assignform').remove.disabled=true;
getElementById('assignform').removeselect.selectedIndex=-1;">
<?php
if (!empty($searchtext)) {
echo "<optgroup label=\"$strsearchresults (" . $availablecount . ")\">\n";
foreach ($availableusers as $user) {
if (!isset($enrolledusers[$user->id])) {
$fullname = fullname($user, true);
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
}
}
echo "</optgroup>\n";
} else {
if ($availablecount > MAX_USERS_PER_PAGE) {
echo '<optgroup label="'.get_string('toomanytoshow').'"><option></option></optgroup>'."\n"
.'<optgroup label="'.get_string('trysearching').'"><option></option></optgroup>'."\n";
} else {
foreach ($availableusers as $user) {
$fullname = fullname($user, true);
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
}
}
}
?>
</select>
<br />
<input type="text" name="searchtext" size="30" value="<?php p($searchtext, true) ?>"
onfocus ="getElementById('assignform').add.disabled=true;
getElementById('assignform').remove.disabled=true;
getElementById('assignform').removeselect.selectedIndex=-1;
getElementById('assignform').addselect.selectedIndex=-1;"
onkeydown = "var keyCode = event.which ? event.which : event.keyCode;
if (keyCode == 13) {
getElementById('assignform').previoussearch.value=1;
getElementById('assignform').submit();
} " />
<input name="search" id="search" type="submit" value="<?php p($strsearch) ?>" />
<?php
if (!empty($searchusers)) {
echo '<input name="showall" id="showall" type="submit" value="'.$strshowall.'" />'."\n";
}
?>
</td>
</tr>
<tr>
<td valign="top"><?php print_string('otherenrolledusers', 'mnet'); ?>:<br />
<ul>
<?php
foreach ($remtenrolledusers as $enrolleduser) {
$fullname = fullname($enrolleduser, true);
print '<li>'
. s($fullname) . ' (' . s($enrolleduser->rolename) . ') '
. s($enrolleduser->enroltype)."</li>\n";
}
?></ul></td>
<td valign="top"></td>
<td valign="top"></td>
</tr>
</table>
</div>
</form>

View file

@ -1,316 +0,0 @@
<?PHP
// enrol_config.php - allows admin to edit all enrolment variables
// Yes, enrol is correct English spelling.
die('TODO: MDL-22787 mnet enrolments are not reimplemented yet, sorry.');
require_once(dirname(__FILE__) . "/../../config.php");
require_once($CFG->libdir.'/adminlib.php');
include_once($CFG->dirroot.'/mnet/xmlrpc/client.php');
if (!confirm_sesskey()) {
print_error('confirmsesskeybad', 'error');
}
admin_externalpage_setup('mnetenrol');
$enrolment = enrol_get_plugin('mnet');
$mnethostid = required_param('host', PARAM_INT);
$courseid = required_param('courseid', PARAM_INT);
$mnet_peer = new mnet_peer();
if (!$mnet_peer->set_id($mnethostid)) {
print_error('hostcoursenotfound','mnet');
}
$course = $DB->get_record('mnet_enrol_course', array('id'=>$courseid, 'hostid'=>$mnet_peer->id));
if (empty($course)) {
print_error('hostcoursenotfound','mnet');
}
define("MAX_USERS_PER_PAGE", 5000);
$add = optional_param('add', 0, PARAM_BOOL);
$remove = optional_param('remove', 0, PARAM_BOOL);
$showall = optional_param('showall', 0, PARAM_BOOL);
$searchtext = optional_param('searchtext', '', PARAM_RAW); // search string
$previoussearch = optional_param('previoussearch', 0, PARAM_BOOL);
$userid = optional_param('userid', 0, PARAM_INT); // needed for user tabs
$errors = array();
$previoussearch = ($searchtext != '') or ($previoussearch) ? 1:0;
$baseurl = "remote_enrolment.php?courseid={$course->id}&amp;host={$mnet_peer->id}";
if (!empty($userid)) {
$baseurl .= '&amp;userid='.$userid;
}
/// Process incoming role assignment
if ($frm = data_submitted()) {
if ($add and !empty($frm->addselect) and confirm_sesskey()) {
$timemodified = time();
foreach ($frm->addselect as $adduser) {
if (!$adduser = clean_param($adduser, PARAM_INT)) {
continue;
}
if (! $enrolment->req_enrol_user($adduser, $course->id)) {
$errors[] = "Could not add user with id $adduser to course {$course->id}!";
}
}
} else if ($remove and !empty($frm->removeselect) and confirm_sesskey()) {
foreach ($frm->removeselect as $removeuser) {
$removeuser = clean_param($removeuser, PARAM_INT);
if (! $enrolment->req_unenrol_user($removeuser, $course->id)) {
$errors[] = "Could not remove user with id $removeuser from course {$course->id}!";
}
}
} else if ($showall) {
$searchtext = '';
$previoussearch = 0;
}
}
/// Prepare data for users / enrolled users panes
/// Create a new request object
$mnet_request = new mnet_xmlrpc_client();
/// Pass it the path to the method that we want to execute
$mnet_request->set_method('enrol/mnet/enrol.php/course_enrolments');
$mnet_request->add_param($course->remoteid, 'int');
$mnet_request->send($mnet_peer);
$raw_all_enrolled_users = $mnet_request->response;
unset($mnet_request);
$all_enrolled_users = array();
if (!empty($raw_all_enrolled_users)) {
// Try to repair keying of remote users array, numeric usernames get lost in the fracas
foreach ($raw_all_enrolled_users as $username => $userdetails) {
if (empty($userdetails['username']) || !is_numeric($username)) {
//Not able to repair, or no need to repair
$all_enrolled_users[$username] = $userdetails;
} else {
$all_enrolled_users[$userdetails['username']] = $userdetails;
}
}
}
$timemodified = array();
/// List all the users (homed on this server) who are enrolled on the course
/// This will include mnet-enrolled users, and those who have enrolled
/// themselves, etc.
if (is_array($all_enrolled_users) && count($all_enrolled_users)) {
list($select, $params) = $DB->get_in_or_equal(array_keys($all_enrolled_users), SQL_PARAMS_NAMED, 'un0');
$select = " u.username $select AND ";
} else {
$all_enrolled_users = array();
$params = array();
$select = '';
}
/// Synch our mnet_enrol_assignments with remote server
$sql = "
SELECT
u.id,
u.firstname,
u.lastname,
u.username,
u.email,
a.enroltype,
a.id as enrolid,
COALESCE(a.hostid, 0) as wehaverecord,
a.courseid
FROM
{user} u
LEFT JOIN
{mnet_enrol_assignments} a
ON
a.userid = u.id AND a.courseid=:courseid
WHERE
$select
u.deleted = 0 AND
u.confirmed = 1 AND
u.mnethostid = :mnetid
ORDER BY
u.firstname ASC,
u.lastname ASC";
$params['courseid'] = $courseid;
$params['mnetid'] = $CFG->mnet_localhost_id;
if (!$enrolledusers = $DB->get_records_sql($sql, $params)) {
$enrolledusers = array();
}
foreach($enrolledusers as $user) {
// if this user is not remotely enrolled....
if (!array_key_exists($user->username, $all_enrolled_users)) {
// check to see if we have a record of enrolment and delete it if it's there
if ( $user->wehaverecord) {
$DB->delete_record('mnet_enrol_assignments', array('id'=>$user->enrolid));
}
// and keep going
continue;
}
$dataobj = new stdClass();
$dataobj->userid = $user->id;
$dataobj->hostid = $mnet_peer->id;
$dataobj->courseid = $courseid;
$dataobj->rolename = $all_enrolled_users[$user->username]['name'];
$dataobj->enroltype = $all_enrolled_users[$user->username]['enrol'];
if ($user->wehaverecord == 0) {
$dataobj->enroltime = $all_enrolled_users[$user->username]['timemodified'];
$dataobj->id = $DB->insert_record('mnet_enrol_assignments', $dataobj);
} elseif (array_key_exists($user->username, $all_enrolled_users)) {
$dataobj->id = $user->enrolid;
$DB->update_record('mnet_enrol_assignments', $dataobj);
}
}
unset($enrolledusers);
// Read about our remote enrolments in 2 sets
// first, get the remote enrolments done via enrol/mnet $mnetenrolledusers
// second, get the remote enrolments done with other plugins $remtenrolledusers
// NOTE: both arrays are keyed on the userid!
$sql = "
SELECT
u.id,
u.firstname,
u.lastname,
a.rolename,
a.enroltype,
a.courseid
FROM
{user} u,
{mnet_enrol_assignments} a
WHERE
a.userid = u.id AND
a.courseid=:courseid AND
a.enroltype = 'mnet' AND
u.deleted = 0 AND
u.confirmed = 1 AND
u.mnethostid = :mnetid
ORDER BY
u.firstname ASC,
u.lastname ASC";
$params = array();
$params['courseid'] = $courseid;
$params['mnetid'] = $CFG->mnet_localhost_id;
if (!$mnetenrolledusers = $DB->get_records_sql($sql, $params)) {
$mnetenrolledusers = array();
}
$sql = "
SELECT
u.id,
u.firstname,
u.lastname,
a.rolename,
a.enroltype,
a.courseid
FROM
{user} u,
{mnet_enrol_assignments} a
WHERE
a.userid = u.id AND
a.courseid=:courseid AND
a.enroltype != 'mnet' AND
u.deleted = 0 AND
u.confirmed = 1 AND
u.mnethostid = :mnetid
ORDER BY
u.firstname ASC,
u.lastname ASC";
$params = array();
$params['courseid'] = $courseid;
$params['mnetid'] = $CFG->mnet_localhost_id;
if (!$remtenrolledusers = $DB->get_records_sql($sql, $params)) {
$remtenrolledusers = array();
}
$params = array();
$select = '';
$exclude = array_merge(array_keys($mnetenrolledusers), array_keys($remtenrolledusers));
$exclude[] = 0;
$select = 'AND u.username!=\'guest\' AND u.id NOT IN ('. join(',',$exclude) .') ';
unset($exclude);
$searchtext = trim($searchtext);
if ($searchtext !== '') { // Search for a subset of remaining users
$LIKE = $DB->sql_ilike();
$FULLNAME = $DB->sql_fullname();
$select .= " AND ($FULLNAME $LIKE :search1 OR email $LIKE :search2) ";
$params['search1'] = "%$searchtext%";
$params['search2'] = "%$searchtext%";
}
$sql = ("SELECT id, firstname, lastname, email
FROM {user} u
WHERE deleted = 0 AND confirmed = 1
AND mnethostid = :mnetid
$select
ORDER BY lastname ASC, firstname ASC");
$params['mnetid'] = $CFG->mnet_localhost_id;
$availableusers = $DB->get_recordset_sql($sql, $params, 0, MAX_USERS_PER_PAGE);
$sql = ("SELECT COUNT('x')
FROM {user} u
WHERE deleted = 0 AND confirmed = 1
AND mnethostid = :mnetid
$select");
$availablecount = $DB->count_records_sql($sql, $params);
/// Print the page
/// get language strings
$str = get_strings(array('configuration', 'users', 'administration'));
/// Get some language strings
$strpotentialusers = get_string('potentialusers', 'role');
$strexistingusers = get_string('existingusers', 'role');
$straction = get_string('assignroles', 'role');
$strroletoassign = get_string('roletoassign', 'role');
$strcurrentcontext = get_string('currentcontext', 'role');
$strsearch = get_string('search');
$strshowall = get_string('showall');
$strparticipants = get_string('participants');
$strsearchresults = get_string('searchresults');
echo $OUTPUT->header();
echo $OUTPUT->box('<strong>' . s($mnet_peer->name) . ' : '
. format_string($course->shortname) .' '. format_string($course->fullname)
. '</strong><br />'
. get_string("enrolcourseenrol_desc", "mnet"));
echo "<hr />";
include(dirname(__FILE__).'/enr_course_enrol.html');
if (!empty($errors)) {
$msg = '<p>';
foreach ($errors as $e) {
$msg .= $e.'<br />';
}
$msg .= '</p>';
echo $OUTPUT->notification($msg);
}
echo $OUTPUT->footer();

View file

@ -1,56 +0,0 @@
<?PHP
// enrol_config.php - allows admin to edit all enrolment variables
// Yes, enrol is correct English spelling.
die('TODO: ment enrolments are not reimplemented yet, sorry.');
require_once(dirname(__FILE__) . "/../../config.php");
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->dirroot.'/mnet/lib.php');
if (!confirm_sesskey()) {
print_error('confirmsesskeybad', 'error');
}
admin_externalpage_setup('mnetenrol');
$enrolment = enrol_get_plugin('mnet');
$mnethost = required_param('host', PARAM_INT);
$host = $DB->get_record('mnet_host', array('id'=>$mnethost));
$courses = $enrolment->fetch_remote_courses($mnethost);
/// Print the page
echo $OUTPUT->header();
echo $OUTPUT->box('<strong>' . s($host->name) . ' </strong><br />'
. get_string("enrolcourses_desc", "mnet"));
echo '<hr />';
echo '<div id="trustedhosts"><!-- See theme/standard/styles_layout.css #trustedhosts .generaltable for rules -->'
. '<table class="generaltable">';
$icon = "<img src=\"" . $OUTPUT->pix_url('i/course') . "\"".
" class=\"icon\" alt=\"".get_string("course")."\" />";
foreach ($courses as $course) {
$link = "$CFG->wwwroot/$CFG->admin/mnet/enr_course_enrol.php?"
. "host={$mnethost}&amp;courseid={$course->id}&amp;sesskey=".sesskey();
echo '<tr>'
. "<td>$icon</td>"
. "<td><a href=\"$link\">".format_string($course->fullname). "</a></td>"
. '</tr><tr>'
. '<td></td>'
. '<td>'.format_string($course->shortname). ' - ' .format_string($course->cat_name).'</td>'
. '</tr><tr>'
. '<td></td>'
. "<td align=\"left\" >{$course->summary}</td>"
. '</tr>';
}
echo '</table></div>';
echo $OUTPUT->footer();

View file

@ -1,58 +0,0 @@
<?PHP
// enrol_config.php - allows admin to edit all enrollment variables
// Yes, enrol is correct English spelling.
require_once(dirname(__FILE__) . "/../../config.php");
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->dirroot.'/mnet/lib.php');
die('TODO: MDL-22787 mnet enrolments are not reimplemented yet, sorry.');
admin_externalpage_setup('mnetenrol');
$enrolment = enrol_get_plugin('mnet');
/// Otherwise fill and print the form.
/// get language strings
echo $OUTPUT->header();
echo $OUTPUT->box(get_string("remoteenrolhosts_desc", "mnet"));
echo '<hr />';
if (empty($CFG->mnet_dispatcher_mode) || $CFG->mnet_dispatcher_mode !== 'strict') {
echo $OUTPUT->box(get_string('mnetdisabled','mnet'));
}
echo '<div id="trustedhosts"><!-- See theme/standard/styles_layout.css #trustedhosts .generaltable for rules -->'
. '<table cellspacing="0" cellpadding="5" id="hosts" class="generaltable generalbox" >'
. '<tr>'
. '<th class="header c0"> '.get_string('host', 'mnet').' </th>'
. '<th class="header c1"> '.get_string('enrolments', 'mnet').' </th>'
. '<th class="header c2"> '.get_string('courses', 'mnet').' </th>'
// . '<th class="header c3"> &nbsp; </th>'
. '</tr>';
$hosts = $enrolment->list_remote_servers();
foreach ($hosts as $host) {
$coursesurl = "$CFG->wwwroot/$CFG->admin/mnet/enr_courses.php?host={$host->id}&amp;sesskey=".sesskey();
$coursecount = $DB->get_field_sql("SELECT COUNT(id) FROM {mnet_enrol_course} WHERE hostid=?", array($host->id));
if (empty($coursecount)) {
$coursecount = '?';
}
$enrolcount = $DB->get_field_sql("SELECT COUNT(id) FROM {mnet_enrol_assignments} WHERE hostid=?", array($host->id));
echo '<tr>'
. "<td><a href=\"{$coursesurl}\">{$host->name}</a></td>"
. "<td align=\"center\" >$enrolcount</td>"
. "<td align=\"center\" >$coursecount - <a href=\"{$coursesurl}\">".get_string('editenrolments', 'mnet')."</a></td>"
// TODO: teach report/log/index.php to show per-host-logs
// . '<td align="center" ><a href="$CFG->wwwroot/$CFG->admin/report/log/index.php?course_host={$host->id}">'
// . get_string('logs', 'mnet').'</a> </td>'
. '</tr>';
}
echo '</table>'
. '</div>';
echo $OUTPUT->footer();

View file

@ -56,15 +56,7 @@ $string['deletewrongkeyvalue'] = 'An error has occurred. If you were not trying
$string['deny'] = 'Deny';
$string['description'] = 'Description';
$string['duplicate_usernames'] = 'We failed to create an index on the columns "mnethostid" and "username" in your user table.<br />This can occur when you have <a href="{$a}" target="_blank">duplicate usernames in your user table</a>.<br />Your upgrade should still complete successfully. Click on the link above, and instructions on fixing this problem will appear in a new window. You can attend to that at the end of the upgrade.<br />';
$string['editenrolments'] = 'enrol';
$string['enabled_for_all'] = '(This service has been enabled for all hosts).';
$string['enrolcourseenrol_desc'] = 'Enrol/unenrol users from this course using Moodle Network enrolments.
Note that users may have been enrolled in this course via other enrolment
methods if the remote hosts allows them. Such enrolments are listed under
<em>Other enrolled users</em>';
$string['enrolcourses_desc'] = 'Courses offered for remote enrolment by this host.';
$string['enrollingincourse'] = 'Enrolling in course {$a->course} on host {$a->host}<br />';
$string['enrolments'] = 'enrolments';
$string['enterausername'] = 'Please enter a username, or a list of usernames separated by commas.';
$string['error7020'] = 'This error normally occurs if the remote site has created a record for you with the wrong wwwroot, for example, http://yoursite.com instead of http://www.yoursite.com. You should contact the administrator of the remote site with your wwwroot (as specified in config.php) asking her to update her record for your host.';
$string['error7022'] = 'The message you sent to the remote site was encrypted properly, but not signed. This is very unexpected; you should probably file a bug if this occurs (giving as much information as possible about the Moodle versions in question, etc.';
@ -135,7 +127,6 @@ $string['methodsignature'] = 'Method signature for {$a}';
$string['mnet'] = 'Moodle Networking';
$string['mnet_concatenate_strings'] = 'Concatenate (up to) 3 strings and return the result';
$string['mnetdisabled'] = 'Moodle Network is <strong>disabled</strong>.';
$string['mnetenrol'] = 'Enrolments';
$string['mnetidprovider'] = 'MNET ID Provider';
$string['mnetidproviderdesc'] = 'You can use this facility to retrieve a link that you can log in at, if you can provide the correct email address to match the username you previously tried to log in with.';
$string['mnetidprovidermsg'] = 'You should be able to login at your {$a} provider.';