Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moodle
moodle
Commits
d2aa3e05
Commit
d2aa3e05
authored
Jul 27, 2020
by
Juan Leyva
Browse files
MDL-69283 webservice: New external setting for forcing timezone
parent
5486b031
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/externallib.php
View file @
d2aa3e05
...
@@ -1217,6 +1217,9 @@ class external_settings {
...
@@ -1217,6 +1217,9 @@ class external_settings {
/** @var string The session lang */
/** @var string The session lang */
private
$lang
=
''
;
private
$lang
=
''
;
/** @var string The timezone to use during this WS request */
private
$timezone
=
''
;
/**
/**
* Constructor - protected - can not be instanciated
* Constructor - protected - can not be instanciated
*/
*/
...
@@ -1337,6 +1340,24 @@ class external_settings {
...
@@ -1337,6 +1340,24 @@ class external_settings {
public
function
get_lang
()
{
public
function
get_lang
()
{
return
$this
->
lang
;
return
$this
->
lang
;
}
}
/**
* Set timezone
*
* @param string $timezone
*/
public
function
set_timezone
(
$timezone
)
{
$this
->
timezone
=
$timezone
;
}
/**
* Get timezone
*
* @return string
*/
public
function
get_timezone
()
{
return
$this
->
timezone
;
}
}
}
/**
/**
...
...
webservice/lib.php
View file @
d2aa3e05
...
@@ -1160,6 +1160,7 @@ abstract class webservice_server implements webservice_server_interface {
...
@@ -1160,6 +1160,7 @@ abstract class webservice_server implements webservice_server_interface {
'fileurl'
=>
array
(
'default'
=>
true
,
'type'
=>
PARAM_BOOL
),
'fileurl'
=>
array
(
'default'
=>
true
,
'type'
=>
PARAM_BOOL
),
'filter'
=>
array
(
'default'
=>
false
,
'type'
=>
PARAM_BOOL
),
'filter'
=>
array
(
'default'
=>
false
,
'type'
=>
PARAM_BOOL
),
'lang'
=>
array
(
'default'
=>
''
,
'type'
=>
PARAM_LANG
),
'lang'
=>
array
(
'default'
=>
''
,
'type'
=>
PARAM_LANG
),
'timezone'
=>
array
(
'default'
=>
''
,
'type'
=>
PARAM_TIMEZONE
),
);
);
// Load the external settings with the web service settings.
// Load the external settings with the web service settings.
...
@@ -1235,7 +1236,7 @@ abstract class webservice_base_server extends webservice_server {
...
@@ -1235,7 +1236,7 @@ abstract class webservice_base_server extends webservice_server {
* @uses die
* @uses die
*/
*/
public
function
run
()
{
public
function
run
()
{
global
$CFG
,
$SESSION
;
global
$CFG
,
$USER
,
$SESSION
;
// we will probably need a lot of memory in some functions
// we will probably need a lot of memory in some functions
raise_memory_limit
(
MEMORY_EXTRA
);
raise_memory_limit
(
MEMORY_EXTRA
);
...
@@ -1287,6 +1288,12 @@ abstract class webservice_base_server extends webservice_server {
...
@@ -1287,6 +1288,12 @@ abstract class webservice_base_server extends webservice_server {
}
}
}
}
// Change timezone only in sites where it isn't forced.
$newtimezone
=
$settings
->
get_timezone
();
if
(
!
empty
(
$newtimezone
)
&&
(
!
isset
(
$CFG
->
forcetimezone
)
||
$CFG
->
forcetimezone
==
99
))
{
$USER
->
timezone
=
$newtimezone
;
}
// finally, execute the function - any errors are catched by the default exception handler
// finally, execute the function - any errors are catched by the default exception handler
$this
->
execute
();
$this
->
execute
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment