diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 0d99bd93577..f5bc7a8d5fa 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -432,6 +432,7 @@ $string['enrolledincoursenot'] = 'Not enrolled in course \"$a\"'; $string['enrollfirst'] = 'You have to enrol in one of the courses before you can use the site activities'; $string['enrolme'] = 'Enrol me in this course'; $string['enrolmentconfirmation'] = 'You are about to enrol yourself as a member of this course.
Are you sure you wish to do this?'; +$string['enrolmentend'] = 'Enrolment Ends'; $string['enrolmentkey'] = 'Enrolment key'; $string['enrolmentkeyfrom'] = 'This course requires an \'enrolment key\' - a one-time
password that you should have received from $a'; @@ -442,6 +443,7 @@ $string['enrolmentnewuser'] = '$a->user has enrolled in course \"$a->course\"'; $string['enrolmentnointernal'] = 'Manual enrolments are currently not enabled'; $string['enrolmentnotyet'] = 'Sorry, you can not access this course until
$a'; $string['enrolments'] = 'Enrolments'; +$string['enrolmentstart'] = 'Enrolment Started'; $string['enrolperiod'] = 'Enrolment duration'; $string['entercourse'] = 'Click to enter this course'; $string['enteremailaddress'] = 'Enter in your email address to reset your @@ -461,6 +463,8 @@ $string['existingcreators'] = 'Existing course creators'; $string['existingstudents'] = 'Enrolled students'; $string['existingteachers'] = 'Existing teachers'; $string['explanation'] = 'Explanation'; +$string['extendenrol'] = 'Extend enrolment'; +$string['extendperiod'] = 'Extended period'; $string['failedloginattempts'] = '$a->attempts failed logins since your last login'; $string['failedloginattemptsall'] = '$a->attempts failed logins for $a->accounts accounts'; $string['feedback'] = 'Feedback'; @@ -803,6 +807,7 @@ $string['newusers'] = 'New users'; $string['next'] = 'Next'; $string['no'] = 'No'; $string['nobody'] = 'Nobody'; +$string['nochange'] = 'No change'; $string['nocoursesfound'] = 'No courses were found with the words \'$a\''; $string['nocoursesyet'] = 'No courses in this category'; $string['nodstpresets'] = 'The administrator has not enabled Daylight Savings Time support.'; diff --git a/user/action_redir.php b/user/action_redir.php new file mode 100644 index 00000000000..1d76b8a56d6 --- /dev/null +++ b/user/action_redir.php @@ -0,0 +1,34 @@ + $v) { + $pass = $pass || preg_match('/^user(\d+)$/',$k); +} +if (!$pass) { + die(); +} + +header("Location: $CFG->wwwroot/user/" . $_GET['formaction'] . '?' . $_SERVER['QUERY_STRING']); +?> \ No newline at end of file diff --git a/user/extendenrol.php b/user/extendenrol.php new file mode 100644 index 00000000000..faa44e38f18 --- /dev/null +++ b/user/extendenrol.php @@ -0,0 +1,73 @@ +id); + +if (!isteacheredit($course->id)) { + error("You must be an editing teacher in this course, or an admin"); +} + +if ($users && ($form = data_submitted() and confirm_sesskey())) { + if (count($form->userid) != count($form->extendperiod)) { + error('Parameters malformation', $CFG->wwwroot.'/user/index.php?id='.$id); + } + + foreach ($form->userid as $k => $v) { + if ($student = get_record('user_students', 'userid', $v, 'course', $id)) { + enrol_student($v, $id, $student->timestart, $student->timeend + $form->extendperiod[$k]); + } + } + + redirect("$CFG->wwwroot/user/index.php?id=$id", get_string('changessaved')); +} + +/// Print headers + +if ($course->category) { + print_header("$course->shortname: ".get_string('extendenrol'), $course->fullname, + "id\">$course->shortname -> ". + get_string('extendenrol'), "", "", true, " ", navmenu($course)); +} else { + print_header("$course->shortname: ".get_string('extendenrol'), $course->fullname, + get_string('extendenrol'), "", "", true, " ", navmenu($course)); +} + +for ($i=1; $i<=365; $i++) { + $seconds = $i * 86400; + $periodmenu[$seconds] = get_string('numdays', '', $i); +} + +print_heading(get_string('extendenrol')); +echo "
\n"; +echo ''; +echo ''; +$table->head = array (get_string('fullname'), get_string('enrolmentstart'), get_string('enrolmentend'), get_string('extendperiod')); +$table->align = array ('left', 'center', 'center', 'center'); +$table->width = "600"; +$timeformat = get_string('strftimedate'); +$nochange = get_string('nochange'); +foreach ($_GET as $k => $v) { + if (preg_match('/^user(\d+)$/',$k,$m)) { + if (!($user = get_record_sql("SELECT * FROM {$CFG->prefix}user u INNER JOIN {$CFG->prefix}user_students s ON u.id=s.userid WHERE u.id={$m[1]}"))) { + continue; + } + $table->data[] = array( + fullname($user, true), + userdate($user->timestart, $timeformat), + userdate($user->timeend, $timeformat), + ''.choose_from_menu($periodmenu, "extendperiod[{$m[1]}]", "0", $nochange, '', '0', true) + ); + } +} +print_table($table); +echo "\n
\n
\n"; + +print_footer($course); +?> \ No newline at end of file diff --git a/user/index.php b/user/index.php index 85fd3e275f8..653c1ffbbcb 100644 --- a/user/index.php +++ b/user/index.php @@ -243,8 +243,18 @@ $guest = get_guest(); $exceptions[] = $guest->id; - $tablecolumns = array('picture', 'fullname', 'city', 'country', 'lastaccess',''); - $tableheaders = array('', get_string('fullname'), get_string('city'), get_string('country'), get_string('lastaccess'), ($isteacher) ? get_string('select') : ''); + $tablecolumns = array('picture', 'fullname', 'city', 'country', 'lastaccess'); + $tableheaders = array('', get_string('fullname'), get_string('city'), get_string('country'), get_string('lastaccess')); + + if ($course->enrolperiod) { + $tablecolumns[] = 'timeend'; + $tableheaders[] = get_string('enrolmentend'); + } + + if ($isteacher) { + $tablecolumns[] = ''; + $tableheaders[] = get_string('select'); + } $table = new flexible_table('user-index-students'); @@ -277,6 +287,7 @@ else { $select = 'SELECT u.id, u.username, u.firstname, u.lastname, u.email, u.city, u.country, u.picture, u.lang, u.timezone, u.emailstop, u.maildisplay, s.timeaccess AS lastaccess '; + $select .= $course->enrolperiod?', s.timeend ':''; $from = 'FROM '.$CFG->prefix.'user u LEFT JOIN '.$CFG->prefix.'user_students s ON s.userid = u.id '; $where = 'WHERE s.course = '.$course->id.' AND u.deleted = 0 '; } @@ -332,9 +343,37 @@ } if ($isteacher) { - echo '
'; + echo ' + +'; + echo ''; echo ''; echo ''; + echo ''; } if ($fullmode) { // Print simple listing @@ -400,6 +439,7 @@ } else { $countrysort = (strpos($sort, 'country') !== false); + $timeformat = get_string('strftimedate'); if (!empty($students)) { foreach ($students as $student) { if ($student->lastaccess) { @@ -420,15 +460,20 @@ } } - $table->add_data(array ( + $data = array ( //'', print_user_picture($student->id, $course->id, $student->picture, false, true), ''.fullname($student).'', $student->city, $country, - $lastaccess, - ($isteacher ? '' : '') - )); + $lastaccess); + if ($course->enrolperiod) { + $data[] = userdate($student->timeend, $timeformat); + } + if ($isteacher) { + $data[] = ''; + } + $table->add_data($data); } } @@ -438,11 +483,15 @@ } if ($isteacher) { - echo '
'; - echo ''; - echo ''; - $displaylist[1] = get_string('messageselectadd'); - choose_from_menu ($displaylist, "messageselect", "", get_string("withselectedusers"), "javascript:document.messageselect.submit()"); + echo '
'; + echo ' '; + echo ' '; + $displaylist['messageselect.php'] = get_string('messageselectadd'); + if ($course->enrolperiod) { + $displaylist['extendenrol.php'] = get_string('extendenrol'); + } + choose_from_menu ($displaylist, "formaction", "", get_string("withselectedusers"), "this.form.submit();", ""); + echo ''; } diff --git a/user/messageselect.php b/user/messageselect.php index be9a7ef4e76..9ade64b2a94 100644 --- a/user/messageselect.php +++ b/user/messageselect.php @@ -35,8 +35,8 @@ $count = 0; - foreach ($_POST as $k => $v) { - if (preg_match('/email(\d+)/',$k,$m)) { + foreach ($_GET as $k => $v) { + if (preg_match('/^user(\d+)$/',$k,$m)) { if (!array_key_exists($m[1],$SESSION->emailto[$id])) { if ($user = get_record_select('user','id = '.$m[1],'id,firstname,lastname,idnumber,email,emailstop,mailformat')) { $SESSION->emailto[$id][$m[1]] = $user;