mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 20:50:21 +01:00
1) Don't force changepassword during loginas
2) Added weeks and years to format_time()
This commit is contained in:
parent
63013fb804
commit
5602f7cf2e
@ -1474,6 +1474,7 @@ $string['visibletostudents'] = 'Visible to $a';
|
|||||||
$string['warningdeleteresource'] = 'Warning: $a is referred in a resource. Would you like to update the resource?';
|
$string['warningdeleteresource'] = 'Warning: $a is referred in a resource. Would you like to update the resource?';
|
||||||
$string['webpage'] = 'Web page';
|
$string['webpage'] = 'Web page';
|
||||||
$string['week'] = 'Week';
|
$string['week'] = 'Week';
|
||||||
|
$string['weeks'] = 'weeks';
|
||||||
$string['weekhide'] = 'Hide this week from $a';
|
$string['weekhide'] = 'Hide this week from $a';
|
||||||
$string['weeklyoutline'] = 'Weekly outline';
|
$string['weeklyoutline'] = 'Weekly outline';
|
||||||
$string['weekshow'] = 'Show this week to $a';
|
$string['weekshow'] = 'Show this week to $a';
|
||||||
@ -1513,6 +1514,8 @@ $string['writinguserinfo'] = 'Writing users info';
|
|||||||
$string['wrongpassword'] = 'Incorrect password for this username';
|
$string['wrongpassword'] = 'Incorrect password for this username';
|
||||||
$string['xmldbeditor'] = 'XMLDB editor';
|
$string['xmldbeditor'] = 'XMLDB editor';
|
||||||
$string['yahooid'] = 'Yahoo ID';
|
$string['yahooid'] = 'Yahoo ID';
|
||||||
|
$string['year'] = 'year';
|
||||||
|
$string['years'] = 'years';
|
||||||
$string['yes'] = 'Yes';
|
$string['yes'] = 'Yes';
|
||||||
$string['youareabouttocreatezip'] = 'You are about to create a zip file containing';
|
$string['youareabouttocreatezip'] = 'You are about to create a zip file containing';
|
||||||
$string['youaregoingtorestorefrom'] = 'You are about to start the restore process for';
|
$string['youaregoingtorestorefrom'] = 'You are about to start the restore process for';
|
||||||
|
@ -59,6 +59,12 @@ define('SEPARATEGROUPS', 1);
|
|||||||
define('VISIBLEGROUPS', 2);
|
define('VISIBLEGROUPS', 2);
|
||||||
|
|
||||||
/// Date and time constants ///
|
/// Date and time constants ///
|
||||||
|
/**
|
||||||
|
* Time constant - the number of seconds in a year
|
||||||
|
*/
|
||||||
|
|
||||||
|
define('YEARSECS', 31536000);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Time constant - the number of seconds in a week
|
* Time constant - the number of seconds in a week
|
||||||
*/
|
*/
|
||||||
@ -900,15 +906,16 @@ function make_timestamp($year, $month=1, $day=1, $hour=0, $minute=0, $second=0,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Given an amount of time in seconds, returns string
|
* Given an amount of time in seconds, returns string
|
||||||
* formatted nicely as months, days, hours etc as needed
|
* formatted nicely as weeks, days, hours etc as needed
|
||||||
*
|
*
|
||||||
* @uses MINSECS
|
* @uses MINSECS
|
||||||
* @uses HOURSECS
|
* @uses HOURSECS
|
||||||
* @uses DAYSECS
|
* @uses DAYSECS
|
||||||
|
* @uses WEEKSECS
|
||||||
|
* @uses YEARSECS
|
||||||
* @param int $totalsecs ?
|
* @param int $totalsecs ?
|
||||||
* @param array $str ?
|
* @param array $str ?
|
||||||
* @return string
|
* @return string
|
||||||
* @todo Finish documenting this function
|
|
||||||
*/
|
*/
|
||||||
function format_time($totalsecs, $str=NULL) {
|
function format_time($totalsecs, $str=NULL) {
|
||||||
|
|
||||||
@ -923,9 +930,18 @@ function make_timestamp($year, $month=1, $day=1, $hour=0, $minute=0, $second=0,
|
|||||||
$str->mins = get_string('mins');
|
$str->mins = get_string('mins');
|
||||||
$str->sec = get_string('sec');
|
$str->sec = get_string('sec');
|
||||||
$str->secs = get_string('secs');
|
$str->secs = get_string('secs');
|
||||||
|
$str->year = get_string('year');
|
||||||
|
$str->years = get_string('years');
|
||||||
|
$str->week = get_string('week');
|
||||||
|
$str->weeks = get_string('weeks');
|
||||||
}
|
}
|
||||||
|
|
||||||
$days = floor($totalsecs/DAYSECS);
|
|
||||||
|
$years = floor($totalsecs/YEARSECS);
|
||||||
|
$remainder = $totalsecs - ($years*YEARSECS);
|
||||||
|
$weeks = floor($remainder/WEEKSECS);
|
||||||
|
$remainder = $totalsecs - ($weeks*WEEKSECS);
|
||||||
|
$days = floor($remainder/DAYSECS);
|
||||||
$remainder = $totalsecs - ($days*DAYSECS);
|
$remainder = $totalsecs - ($days*DAYSECS);
|
||||||
$hours = floor($remainder/HOURSECS);
|
$hours = floor($remainder/HOURSECS);
|
||||||
$remainder = $remainder - ($hours*HOURSECS);
|
$remainder = $remainder - ($hours*HOURSECS);
|
||||||
@ -936,17 +952,25 @@ function make_timestamp($year, $month=1, $day=1, $hour=0, $minute=0, $second=0,
|
|||||||
$sm = ($mins == 1) ? $str->min : $str->mins;
|
$sm = ($mins == 1) ? $str->min : $str->mins;
|
||||||
$sh = ($hours == 1) ? $str->hour : $str->hours;
|
$sh = ($hours == 1) ? $str->hour : $str->hours;
|
||||||
$sd = ($days == 1) ? $str->day : $str->days;
|
$sd = ($days == 1) ? $str->day : $str->days;
|
||||||
|
$sw = ($weeks == 1) ? $str->week : $str->weeks;
|
||||||
|
$sy = ($years == 1) ? $str->year : $str->years;
|
||||||
|
|
||||||
|
$oyears = '';
|
||||||
|
$oweeks = '';
|
||||||
$odays = '';
|
$odays = '';
|
||||||
$ohours = '';
|
$ohours = '';
|
||||||
$omins = '';
|
$omins = '';
|
||||||
$osecs = '';
|
$osecs = '';
|
||||||
|
|
||||||
|
if ($years) $oyears = $years .' '. $sy;
|
||||||
|
if ($weeks) $oweeks = $weeks .' '. $sw;
|
||||||
if ($days) $odays = $days .' '. $sd;
|
if ($days) $odays = $days .' '. $sd;
|
||||||
if ($hours) $ohours = $hours .' '. $sh;
|
if ($hours) $ohours = $hours .' '. $sh;
|
||||||
if ($mins) $omins = $mins .' '. $sm;
|
if ($mins) $omins = $mins .' '. $sm;
|
||||||
if ($secs) $osecs = $secs .' '. $ss;
|
if ($secs) $osecs = $secs .' '. $ss;
|
||||||
|
|
||||||
|
if ($years) return $oyears .' '. $oweeks;
|
||||||
|
if ($weeks) return $oweeks .' '. $odays;
|
||||||
if ($days) return $odays .' '. $ohours;
|
if ($days) return $odays .' '. $ohours;
|
||||||
if ($hours) return $ohours .' '. $omins;
|
if ($hours) return $ohours .' '. $omins;
|
||||||
if ($mins) return $omins .' '. $osecs;
|
if ($mins) return $omins .' '. $osecs;
|
||||||
@ -1635,9 +1659,9 @@ function require_login($courseorid=0, $autologinguest=true, $cm=null) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// check whether the user should be changing password
|
/// check whether the user should be changing password (but only if it is REALLY them)
|
||||||
$userauth = get_auth_plugin($USER->auth);
|
$userauth = get_auth_plugin($USER->auth);
|
||||||
if (!empty($USER->preference['auth_forcepasswordchange'])){
|
if (!empty($USER->preference['auth_forcepasswordchange']) && empty($USER->realuser)) {
|
||||||
if ($userauth->can_change_password()) {
|
if ($userauth->can_change_password()) {
|
||||||
$SESSION->wantsurl = $FULLME;
|
$SESSION->wantsurl = $FULLME;
|
||||||
if (empty($CFG->loginhttps)) {
|
if (empty($CFG->loginhttps)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user