/** @var string The session lang */
private $lang = '';
+ /** @var string The timezone to use during this WS request */
+ private $timezone = '';
+
/**
* Constructor - protected - can not be instanciated
*/
public function get_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;
+ }
}
/**
'fileurl' => array('default' => true, 'type' => PARAM_BOOL),
'filter' => array('default' => false, 'type' => PARAM_BOOL),
'lang' => array('default' => '', 'type' => PARAM_LANG),
+ 'timezone' => array('default' => '', 'type' => PARAM_TIMEZONE),
);
// Load the external settings with the web service settings.
* @uses die
*/
public function run() {
- global $CFG, $SESSION;
+ global $CFG, $USER, $SESSION;
// we will probably need a lot of memory in some functions
raise_memory_limit(MEMORY_EXTRA);
}
}
+ // 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
$this->execute();