Skip to content

Commit

Permalink
add option to sync timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
weilai-irl committed Oct 9, 2020
1 parent 70a712c commit 79a23c5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
3 changes: 2 additions & 1 deletion block_microsoft.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ protected function get_content_connected() {
$aadsync = get_config('local_o365', 'aadsync');
$aadsync = array_flip(explode(',', $aadsync));
// Only profile sync once for each session.
if (empty($SESSION->block_microsoft_profilesync) && isset($aadsync['photosynconlogin'])) {
if (empty($SESSION->block_microsoft_profilesync) &&
(isset($aadsync['photosynconlogin']) || isset($aadsync['tzsynconlogin']))) {
$PAGE->requires->jquery();
$PAGE->requires->js('/blocks/microsoft/js/microsoft.js');
$PAGE->requires->js_init_call('microsoft_update_profile', array($CFG->wwwroot));
Expand Down
19 changes: 13 additions & 6 deletions update.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,16 @@
$aadsync = get_config('local_o365', 'aadsync');
$aadsync = array_flip(explode(',', $aadsync));
// Only profile sync once for each session.
if (empty($SESSION->block_microsoft_profilesync) && isset($aadsync['photosynconlogin'])) {
$PAGE->requires->jquery();
$usersync = new \local_o365\feature\usersync\main();
$usersync->assign_photo($USER->id, null);
$SESSION->block_microsoft_profilesync = true;
}
if (empty($SESSION->block_microsoft_profilesync)) {
if (isset($aadsync['photosynconlogin']) || isset($aadsync['tzsynconlogin'])) {
$PAGE->requires->jquery();
$usersync = new \local_o365\feature\usersync\main();
if (isset($aadsync['photosynconlogin'])) {
$usersync->assign_photo($USER->id, null);
}
if (isset($aadsync['tzsynconlogin'])) {
$usersync->sync_timezone($USER->id, null);
}
$SESSION->block_microsoft_profilesync = true;
}
}

0 comments on commit 79a23c5

Please sign in to comment.