in block_microsoft.php [291:454]
protected function get_user_content_connected() {
global $DB, $CFG, $SESSION, $USER, $OUTPUT;
$o365config = get_config('local_o365');
$html = '';
$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']) || isset($aadsync['tzsynconlogin']))) {
$this->page->requires->jquery();
$this->page->requires->js('/blocks/microsoft/js/microsoft.js');
$this->page->requires->js_init_call('microsoft_update_profile', array($CFG->wwwroot));
}
$user = $DB->get_record('user', array('id' => $USER->id));
$langconnected = get_string('o365connected', 'block_microsoft', $user);
$html .= '<h5>'.$langconnected.'</h5>';
$odburl = get_config('local_o365', 'odburl');
$o365object = $DB->get_record('local_o365_objects', ['type' => 'user', 'moodleid' => $USER->id]);
if (!empty($o365object) && !empty($o365object->metadata)) {
$metadata = json_decode($o365object->metadata, true);
if (!empty($metadata['odburl'])) {
$odburl = $metadata['odburl'];
}
}
if (!empty($odburl) && !empty($this->globalconfig->settings_showmydelve)) {
if (!empty($o365object)) {
$delveurl = 'https://'.$odburl.'/_layouts/15/me.aspx?u='.$o365object->objectid.'&v=work';
}
}
if (!empty($user->picture)) {
$html .= '<div class="profilepicture">';
$picturehtml = $OUTPUT->user_picture($user, array('size' => 100, 'class' => 'block_microsoft_profile'));
$profileurl = new moodle_url('/user/profile.php', ['id' => $USER->id]);
if (!empty($delveurl)) {
// If "My Delve" is enabled, clicking the user picture should take you to their Delve page.
$picturehtml = str_replace($profileurl->out(), $delveurl, $picturehtml);
}
$html .= $picturehtml;
$html .= '</div>';
}
$items = [];
$userupn = \local_o365\utils::get_o365_upn($USER->id);
if ($this->page->context instanceof \context_course && $this->page->context->instanceid !== SITEID) {
// Course SharePoint Site.
if (!empty($this->globalconfig->settings_showcoursespsite) && !empty($o365config->sharepointlink)) {
$sharepointstr = get_string('linksharepoint', 'block_microsoft');
$coursespsite = $DB->get_record('local_o365_coursespsite', ['courseid' => $this->page->context->instanceid]);
if (!empty($coursespsite)) {
$spsite = \local_o365\rest\sharepoint::get_tokenresource();
if (!empty($spsite)) {
$spurl = $spsite.'/'.$coursespsite->siteurl;
$spattrs = ['class' => 'servicelink block_microsoft_sharepoint', 'target' => '_blank'];
$items[] = html_writer::link($spurl, $sharepointstr, $spattrs);
$items[] = '<hr/>';
}
}
}
}
// My Delve URL.
if (!empty($delveurl)) {
$delveattrs = ['class' => 'servicelink block_microsoft_delve', 'target' => '_blank'];
$delvestr = get_string('linkmydelve', 'block_microsoft');
$items[] = html_writer::link($delveurl, $delvestr, $delveattrs);
}
// My email.
if (!empty($this->globalconfig->settings_showemail)) {
$emailurl = 'https://outlook.office365.com/';
$emailattrs = ['class' => 'servicelink block_microsoft_outlook', 'target' => '_blank'];
$emailstr = get_string('linkemail', 'block_microsoft');
$items[] = html_writer::link($emailurl, $emailstr, $emailattrs);
}
// My Forms URL.
if (!empty($this->globalconfig->settings_showmyforms)) {
$formsattrs = ['class' => 'servicelink block_microsoft_forms', 'target' => '_blank'];
$formsstr = get_string('linkmyforms', 'block_microsoft');
$formsurl = get_string('settings_showmyforms_default', 'block_microsoft');
if (!empty($odburl)) {
$items[] = html_writer::link($formsurl, $formsstr, $formsattrs);
}
}
// My OneNote Notebook.
$items[] = $this->render_onenote();
// My OneDrive.
if (!empty($this->globalconfig->settings_showonedrive)) {
$odbattrs = [
'target' => '_blank',
'class' => 'servicelink block_microsoft_onedrive',
];
$stronedrive = get_string('linkonedrive', 'block_microsoft');
if (!empty($odburl)) {
$items[] = html_writer::link('https://'.$odburl, $stronedrive, $odbattrs);
}
}
// Microsoft Stream.
if (!empty($this->globalconfig->settings_showmsstream)) {
$streamurl = 'https://web.microsoftstream.com/?noSignUpCheck=1';
$streamattrs = ['target' => '_blank', 'class' => 'servicelink block_microsoft_msstream'];
$items[] = html_writer::link($streamurl, get_string('linkmsstream', 'block_microsoft'), $streamattrs);
}
// Microsoft Teams.
if (!empty($this->globalconfig->settings_showmsteams)) {
$teamsurl = 'https://teams.microsoft.com/_';
$teamsattrs = ['target' => '_blank', 'class' => 'servicelink block_microsoft_msteams'];
$items[] = html_writer::link($teamsurl, get_string('linkmsteams', 'block_microsoft'), $teamsattrs);
}
// My Sways.
if (!empty($this->globalconfig->settings_showsways) && !empty($userupn)) {
$swayurl = 'https://www.sway.com/my?auth_pvr=OrgId&auth_upn='.$userupn;
$swayattrs = ['target' => '_blank', 'class' => 'servicelink block_microsoft_sway'];
$items[] = html_writer::link($swayurl, get_string('linksways', 'block_microsoft'), $swayattrs);
}
// Configure Outlook Sync.
if (!empty($this->globalconfig->settings_showoutlooksync)) {
$outlookurl = new moodle_url('/local/o365/ucp.php?action=calendar');
$outlookstr = get_string('linkoutlook', 'block_microsoft');
$items[] = html_writer::link($outlookurl, $outlookstr, ['class' => 'servicelink block_microsoft_outlook']);
}
// Preferences.
if (!empty($this->globalconfig->settings_showpreferences)) {
$prefsurl = new moodle_url('/local/o365/ucp.php');
$prefsstr = get_string('linkprefs', 'block_microsoft');
$items[] = html_writer::link($prefsurl, $prefsstr, ['class' => 'servicelink block_microsoft_preferences']);
}
if (auth_oidc_connectioncapability($USER->id, 'connect') === true
|| auth_oidc_connectioncapability($USER->id, 'disconnect') === true
|| local_o365_connectioncapability($USER->id, 'link')
|| local_o365_connectioncapability($USER->id, 'unlink')) {
if (!empty($this->globalconfig->settings_showmanageo365conection)) {
$connecturl = new moodle_url('/local/o365/ucp.php', ['action' => 'connection']);
$connectstr = get_string('linkconnection', 'block_microsoft');
$items[] = html_writer::link($connecturl, $connectstr, ['class' => 'servicelink block_microsoft_connection']);
}
}
// Download Microsoft 365.
$downloadlinks = $this->get_content_o365download();
foreach ($downloadlinks as $link) {
$items[] = $link;
}
$html .= html_writer::alist($items);
return $html;
}