-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e3f778b
commit 2d1b215
Showing
165 changed files
with
1,800 additions
and
1,796 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
|
||
/** | ||
* Block Microsoft block | ||
* | ||
* @package block_microsoft | ||
* @author James McQuillan <[email protected]> | ||
* @author Lai Wei <[email protected]> | ||
|
@@ -24,12 +25,13 @@ | |
*/ | ||
|
||
use local_o365\feature\coursesync\utils; | ||
use local_onenote\api\base; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
require_once($CFG->dirroot.'/blocks/microsoft/lib.php'); | ||
require_once($CFG->dirroot.'/auth/oidc/lib.php'); | ||
require_once($CFG->dirroot.'/local/o365/lib.php'); | ||
require_once($CFG->dirroot . '/blocks/microsoft/lib.php'); | ||
require_once($CFG->dirroot . '/auth/oidc/lib.php'); | ||
require_once($CFG->dirroot . '/local/o365/lib.php'); | ||
|
||
/** | ||
* Microsoft Block. | ||
|
@@ -58,7 +60,7 @@ public function has_config() { | |
/** | ||
* Get the content of the block. | ||
* | ||
* @return stdClass|stdObject|null | ||
* @return stdClass|null | ||
*/ | ||
public function get_content() { | ||
global $USER, $DB; | ||
|
@@ -160,8 +162,7 @@ protected function get_course_content() { | |
|
||
if ($iscoursecontext && $coursesyncenabled && $iscoursesyncenabled) { | ||
$canmanage = (has_capability('local/o365:managegroups', $this->page->context) === true) ? true : false; | ||
$canview = (is_enrolled($this->page->context) && has_capability('local/o365:viewgroups', $this->page->context)) ? | ||
true : false; | ||
$canview = is_enrolled($this->page->context) && has_capability('local/o365:viewgroups', $this->page->context); | ||
|
||
if ($canmanage === true || $canview === true) { | ||
[$courseheader, $o365record] = $this->get_course_header_and_o365object($courseid); | ||
|
@@ -269,9 +270,9 @@ protected function get_user_content_connected() { | |
$o365config = get_config('local_o365'); | ||
$html = ''; | ||
|
||
$user = $DB->get_record('user', array('id' => $USER->id)); | ||
$user = $DB->get_record('user', ['id' => $USER->id]); | ||
$langconnected = get_string('o365connected', 'block_microsoft', $user); | ||
$html .= '<h5>'.$langconnected.'</h5>'; | ||
$html .= '<h5>' . $langconnected . '</h5>'; | ||
|
||
$odburl = get_config('local_o365', 'odburl'); | ||
$o365object = $DB->get_record('local_o365_objects', ['type' => 'user', 'moodleid' => $USER->id]); | ||
|
@@ -284,13 +285,13 @@ protected function get_user_content_connected() { | |
|
||
if (!empty($odburl) && !empty($this->globalconfig->settings_showmydelve)) { | ||
if (!empty($o365object)) { | ||
$delveurl = 'https://'.$odburl.'/_layouts/15/me.aspx?u='.$o365object->objectid.'&v=work'; | ||
$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')); | ||
$picturehtml = $OUTPUT->user_picture($user, ['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. | ||
|
@@ -313,7 +314,7 @@ protected function get_user_content_connected() { | |
if (!empty($coursespsite)) { | ||
$spsite = \local_o365\rest\sharepoint::get_tokenresource(); | ||
if (!empty($spsite)) { | ||
$spurl = $spsite.'/'.$coursespsite->siteurl; | ||
$spurl = $spsite . '/' . $coursespsite->siteurl; | ||
$spattrs = ['class' => 'servicelink block_microsoft_sharepoint', 'target' => '_blank']; | ||
$items[] = html_writer::link($spurl, $sharepointstr, $spattrs); | ||
$items[] = '<hr/>'; | ||
|
@@ -358,7 +359,7 @@ protected function get_user_content_connected() { | |
]; | ||
$stronedrive = get_string('linkonedrive', 'block_microsoft'); | ||
if (!empty($odburl)) { | ||
$items[] = html_writer::link('https://'.$odburl, $stronedrive, $odbattrs); | ||
$items[] = html_writer::link('https://' . $odburl, $stronedrive, $odbattrs); | ||
} | ||
} | ||
|
||
|
@@ -386,7 +387,7 @@ protected function get_user_content_connected() { | |
|
||
// My Sways. | ||
if (!empty($this->globalconfig->settings_showsways) && !empty($userupn)) { | ||
$swayurl = 'https://www.sway.com/my?auth_pvr=OrgId&auth_upn='.$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); | ||
} | ||
|
@@ -406,9 +407,9 @@ protected function get_user_content_connected() { | |
} | ||
|
||
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')) { | ||
|| 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'); | ||
|
@@ -465,6 +466,7 @@ protected function get_user_content_not_connected() { | |
} | ||
|
||
$html .= html_writer::alist($items); | ||
|
||
return $html; | ||
} | ||
|
||
|
@@ -480,18 +482,20 @@ protected function get_content_o365download() { | |
|
||
$url = get_config('block_microsoft', 'settings_geto365link'); | ||
$str = get_string('install_office', 'block_microsoft'); | ||
|
||
return [ | ||
html_writer::link($url, $str, ['class' => 'servicelink block_microsoft_downloado365', 'target' => '_blank']), | ||
html_writer::link($url, $str, | ||
['class' => 'servicelink block_microsoft_downloado365', 'target' => '_blank']), | ||
]; | ||
} | ||
|
||
/** | ||
* Get the user's Moodle OneNote Notebook. | ||
* | ||
* @param \local_onenote\api\base $onenoteapi A constructed OneNote API to use. | ||
* @param base $onenoteapi A constructed OneNote API to use. | ||
* @return array Array of information about the user's OneNote notebook used for Moodle. | ||
*/ | ||
protected function get_onenote_notebook(\local_onenote\api\base $onenoteapi) { | ||
protected function get_onenote_notebook(base $onenoteapi) { | ||
$moodlenotebook = null; | ||
for ($i = 0; $i < 2; $i++) { | ||
$notebooks = $onenoteapi->get_items_list(''); | ||
|
@@ -510,6 +514,7 @@ protected function get_onenote_notebook(\local_onenote\api\base $onenoteapi) { | |
break; | ||
} | ||
} | ||
|
||
return $moodlenotebook; | ||
} | ||
|
||
|
@@ -532,21 +537,20 @@ protected function render_onenote() { | |
'onclick' => 'window.open(this.href,\'_blank\'); return false;', | ||
'class' => 'servicelink block_microsoft_onenote', | ||
]; | ||
|
||
return html_writer::link($url->out(false), $stropennotebook, $linkattrs); | ||
} | ||
|
||
$action = optional_param('action', '', PARAM_TEXT); | ||
try { | ||
$onenoteapi = \local_onenote\api\base::getinstance(); | ||
$onenoteapi = base::getinstance(); | ||
$output = ''; | ||
if ($onenoteapi->is_logged_in()) { | ||
// Add the "save to onenote" button if we are on an assignment page. | ||
$onassignpage = ($this->page->cm | ||
&& $this->page->cm->modname == 'assign' | ||
&& $action == 'editsubmission') ? true : false; | ||
$onassignpage = $this->page->cm && $this->page->cm->modname == 'assign' && $action == 'editsubmission'; | ||
if ($onassignpage === true && $onenoteapi->is_student($this->page->cm->id, $USER->id)) { | ||
$workstr = get_string('workonthis', 'block_microsoft'); | ||
$output .= $onenoteapi->render_action_button($workstr, $this->page->cm->id).'<br /><br />'; | ||
$output .= $onenoteapi->render_action_button($workstr, $this->page->cm->id) . '<br /><br />'; | ||
} | ||
// Find moodle notebook, create if not found. | ||
$moodlenotebook = null; | ||
|
@@ -570,13 +574,16 @@ protected function render_onenote() { | |
$output .= get_string('error_nomoodlenotebook', 'block_microsoft'); | ||
} | ||
} | ||
|
||
return $output; | ||
} catch (moodle_exception $e) { | ||
if (class_exists('\local_o365\utils')) { | ||
\local_o365\utils::debug($e->getMessage(), __METHOD__, $e); | ||
} | ||
return '<span class="block_microsoft_onenote servicelink">'.get_string('linkonenote_unavailable', 'block_microsoft') | ||
.'<br /><small>'.get_string('contactadmin', 'block_microsoft').'</small></span>'; | ||
|
||
return '<span class="block_microsoft_onenote servicelink">' . | ||
get_string('linkonenote_unavailable', 'block_microsoft') . '<br /><small>' . | ||
get_string('contactadmin', 'block_microsoft') . '</small></span>'; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.