Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 58 additions & 26 deletions block_microsoft.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ public function get_content() {
$this->content->text .= $this->get_user_content_connected();
} else {
$connection = $DB->get_record('local_o365_connections', ['muserid' => $USER->id]);
if (!empty($connection) && (auth_oidc_connectioncapability($USER->id, 'connect') ||
local_o365_connectioncapability($USER->id, 'link'))) {
if (
!empty($connection) && (auth_oidc_connectioncapability($USER->id, 'connect') ||
local_o365_connectioncapability($USER->id, 'link'))
) {
$uselogin = (!empty($connection->uselogin)) ? true : false;
$this->content->text .= $this->get_user_content_matched($connection->entraidupn, $uselogin);
} else {
Expand Down Expand Up @@ -153,10 +155,15 @@ protected function get_course_content() {
$coursesyncsetting = get_config('local_o365', 'coursesync');
$allowedmanageteamsyncpercourse = get_config('local_o365', 'course_sync_per_course');
if ($coursesyncsetting == 'oncustom' && $allowedmanageteamsyncpercourse) {
$configuresyncurl = new moodle_url('/blocks/microsoft/configure_sync.php',
['course' => $courseid]);
$items[] = html_writer::link($configuresyncurl, get_string('configure_sync', 'block_microsoft'),
['class' => 'servicelink block_microsoft_sync']);
$configuresyncurl = new moodle_url(
'/blocks/microsoft/configure_sync.php',
['course' => $courseid]
);
$items[] = html_writer::link(
$configuresyncurl,
get_string('configure_sync', 'block_microsoft'),
['class' => 'servicelink block_microsoft_sync']
);
}
}

Expand All @@ -178,38 +185,51 @@ protected function get_course_content() {

$url = new moodle_url($microsoft365urls[$feature]);
$resourcename = get_string('course_feature_' . $feature, 'block_microsoft');
$items[] = html_writer::link($url, $resourcename,
['target' => '_blank', 'class' => 'servicelink block_microsoft_' . $feature]);
$items[] = html_writer::link(
$url,
$resourcename,
['target' => '_blank', 'class' => 'servicelink block_microsoft_' . $feature]
);
}

// Link to course reset options.
if (has_capability('moodle/course:reset', $this->page->context)) {
switch (get_config('local_o365', 'course_reset_teams')) {
case COURSE_SYNC_RESET_SITE_SETTING_PER_COURSE:
// Allow user to configure reset actions.
$configurereseturl = new moodle_url('/blocks/microsoft/configure_reset.php',
['course' => $courseid]);
$items[] = html_writer::link($configurereseturl,
$configurereseturl = new moodle_url(
'/blocks/microsoft/configure_reset.php',
['course' => $courseid]
);
$items[] = html_writer::link(
$configurereseturl,
get_string('configure_reset', 'block_microsoft'),
['class' => 'servicelink block_microsoft_reset']);
['class' => 'servicelink block_microsoft_reset']
);

break;
case COURSE_SYNC_RESET_SITE_SETTING_DISCONNECT_AND_CREATE_NEW:
// Force archive, show notification.
$items[] = html_writer::span(get_string('course_reset_disconnect_and_create_new',
'block_microsoft'), 'servicelink block_microsoft_reset');
$items[] = html_writer::span(get_string(
'course_reset_disconnect_and_create_new',
'block_microsoft'
), 'servicelink block_microsoft_reset');

break;
case COURSE_SYNC_RESET_SITE_SETTING_DISCONNECT_ONLY:
// Force disconnect, show notification.
$items[] = html_writer::span(get_string('course_reset_disconnect_only', 'block_microsoft'),
'servicelink block_microsoft_reset');
$items[] = html_writer::span(
get_string('course_reset_disconnect_only', 'block_microsoft'),
'servicelink block_microsoft_reset'
);

break;
default:
// Force do nothing, show notification.
$items[] = html_writer::span(get_string('course_reset_do_nothing', 'block_microsoft'),
'servicelink block_microsoft_reset');
$items[] = html_writer::span(
get_string('course_reset_do_nothing', 'block_microsoft'),
'servicelink block_microsoft_reset'
);
}
}
}
Expand All @@ -232,8 +252,12 @@ private function get_course_header_and_o365object(int $courseid) {
$o365record = null;

if (utils::is_course_sync_enabled($courseid)) {
if ($o365record = $DB->get_record('local_o365_objects',
['type' => 'group', 'subtype' => 'course', 'moodleid' => $courseid])) {
if (
$o365record = $DB->get_record(
'local_o365_objects',
['type' => 'group', 'subtype' => 'course', 'moodleid' => $courseid]
)
) {
[$subtypesql, $params] = $DB->get_in_or_equal(['courseteam', 'teamfromgroup'], SQL_PARAMS_NAMED);
$params['type'] = 'group';
$params['moodleid'] = $courseid;
Expand Down Expand Up @@ -374,8 +398,11 @@ protected function get_user_content_connected() {
if (!empty($this->globalconfig->settings_showmsstream)) {
$streamclassicurl = 'https://web.microsoftstream.com/?noSignUpCheck=1';
$streamclassicattrs = ['target' => '_blank', 'class' => 'servicelink block_microsoft_msstream'];
$items[] = html_writer::link($streamclassicurl, get_string('linkmsstreamclassic', 'block_microsoft'),
$streamclassicattrs);
$items[] = html_writer::link(
$streamclassicurl,
get_string('linkmsstreamclassic', 'block_microsoft'),
$streamclassicattrs
);
}

// Microsoft Teams.
Expand Down Expand Up @@ -406,10 +433,12 @@ protected function get_user_content_connected() {
$items[] = html_writer::link($prefsurl, $prefsstr, ['class' => 'servicelink block_microsoft_preferences']);
}

if (auth_oidc_connectioncapability($USER->id, 'connect') === true
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')) {
|| 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');
Expand Down Expand Up @@ -507,8 +536,11 @@ protected function get_content_o365download() {
$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']
),
];
}

Expand Down
61 changes: 27 additions & 34 deletions forms.php → classes/form/course_configure_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Define forms used by the plugin.
* Form to configure course reset actions.
*
* @package block_microsoft
* @author Lai Wei <lai.wei@enovation.ie>
Expand All @@ -28,31 +28,6 @@
require_once($CFG->libdir . '/formslib.php');
require_once($CFG->dirroot . '/local/o365/lib.php');

/**
* Form to configure course sync options.
*/
class block_microsoft_course_sync_form extends moodleform {
/**
* Form definition.
*/
protected function definition() {
$mform = $this->_form;

$mform->addElement('hidden', 'course');
$mform->setType('course', PARAM_INT);

// Sync options.
$syncoptions = [
MICROSOFT365_COURSE_SYNC_DISABLED => get_string('course_sync_option_disabled', 'block_microsoft'),
MICROSOFT365_COURSE_SYNC_ENABLED => get_string('course_sync_option_enabled', 'block_microsoft'),
];
$mform->addElement('select', 'sync', get_string('course_sync_option', 'block_microsoft'), $syncoptions);
$mform->setDefault('sync', MICROSOFT365_COURSE_SYNC_DISABLED);

$this->add_action_buttons();
}
}

/**
* Form to configure course reset actions.
*/
Expand All @@ -67,19 +42,37 @@ protected function definition() {
$mform->setType('course', PARAM_INT);

$resetoptions = [];
$resetoptions[] = $mform->createElement('radio', 'reset_setting', '',
get_string('reset_option_do_nothing', 'block_microsoft'), COURSE_SYNC_RESET_COURSE_SETTING_DO_NOTHING);
$resetoptions[] = $mform->createElement(
'radio',
'reset_setting',
'',
get_string('reset_option_do_nothing', 'block_microsoft'),
COURSE_SYNC_RESET_COURSE_SETTING_DO_NOTHING
);
$coursesyncsetting = get_config('local_o365', 'coursesync');
if ($coursesyncsetting == 'oncustom') {
$resetoptions[] = $mform->createElement('radio', 'reset_setting', '',
$resetoptions[] = $mform->createElement(
'radio',
'reset_setting',
'',
get_string('reset_option_disconnect_only', 'block_microsoft'),
COURSE_SYNC_RESET_COURSE_SETTING_DISCONNECT_ONLY);
COURSE_SYNC_RESET_COURSE_SETTING_DISCONNECT_ONLY
);
}
$resetoptions[] = $mform->createElement('radio', 'reset_setting', '',
$resetoptions[] = $mform->createElement(
'radio',
'reset_setting',
'',
get_string('reset_option_disconnect_and_create_new', 'block_microsoft'),
COURSE_SYNC_RESET_COURSE_SETTING_DISCONNECT_AND_CREATE_NEW);
$mform->addGroup($resetoptions, 'resetsettinggroup', get_string('course_reset_option', 'block_microsoft'),
'<br/>', false);
COURSE_SYNC_RESET_COURSE_SETTING_DISCONNECT_AND_CREATE_NEW
);
$mform->addGroup(
$resetoptions,
'resetsettinggroup',
get_string('course_reset_option', 'block_microsoft'),
'<br/>',
false
);
$mform->setDefault('reset_setting', COURSE_SYNC_RESET_COURSE_SETTING_DO_NOTHING);

$this->add_action_buttons();
Expand Down
54 changes: 54 additions & 0 deletions classes/form/course_sync_form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Form to configure course sync options.
*
* @package block_microsoft
* @author Lai Wei <lai.wei@enovation.ie>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @copyright (C) 2021 onwards Microsoft, Inc. (http://microsoft.com/)
*/

defined('MOODLE_INTERNAL') || die();

require_once($CFG->libdir . '/formslib.php');
require_once($CFG->dirroot . '/local/o365/lib.php');

/**
* Form to configure course sync options.
*/
class block_microsoft_course_sync_form extends moodleform {
/**
* Form definition.
*/
protected function definition() {
$mform = $this->_form;

$mform->addElement('hidden', 'course');
$mform->setType('course', PARAM_INT);

// Sync options.
$syncoptions = [
MICROSOFT365_COURSE_SYNC_DISABLED => get_string('course_sync_option_disabled', 'block_microsoft'),
MICROSOFT365_COURSE_SYNC_ENABLED => get_string('course_sync_option_enabled', 'block_microsoft'),
];
$mform->addElement('select', 'sync', get_string('course_sync_option', 'block_microsoft'), $syncoptions);
$mform->setDefault('sync', MICROSOFT365_COURSE_SYNC_DISABLED);

$this->add_action_buttons();
}
}
1 change: 0 additions & 1 deletion classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
*/
class provider implements
\core_privacy\local\metadata\null_provider {

/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
Expand Down
12 changes: 8 additions & 4 deletions configure_reset.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@

use local_o365\feature\coursesync\utils;

require_once(__DIR__.'/../../config.php');
require_once(__DIR__ . '/../../config.php');
require_once($CFG->dirroot . '/local/o365/lib.php');
require_once($CFG->dirroot . '/blocks/microsoft/lib.php');
require_once($CFG->dirroot . '/blocks/microsoft/forms.php');
require_once($CFG->dirroot . '/blocks/microsoft/classes/form/course_configure_form.php');

$courseid = required_param('course', PARAM_INT);
$coursecontext = context_course::instance($courseid);
Expand All @@ -55,8 +55,12 @@
throw new moodle_exception('error_reset_setting_not_managed_per_course', 'block_microsoft', $redirecturl);
}

if (!$o365object = $DB->get_record('local_o365_objects',
['type' => 'group', 'subtype' => 'course', 'moodleid' => $courseid])) {
if (
!$o365object = $DB->get_record(
'local_o365_objects',
['type' => 'group', 'subtype' => 'course', 'moodleid' => $courseid]
)
) {
throw new moodle_exception('error_connected_team_missing', 'block_microsoft', $redirecturl);
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions configure_sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
* @copyright (C) 2021 onwards Microsoft, Inc. (http://microsoft.com/)
*/

require_once(__DIR__.'/../../config.php');
require_once($CFG->dirroot . '/blocks/microsoft/forms.php');
require_once(__DIR__ . '/../../config.php');
require_once($CFG->dirroot . '/blocks/microsoft/classes/form/course_sync_form.php');
require_once($CFG->dirroot . '/blocks/microsoft/lib.php');
require_once($CFG->dirroot . '/local/o365/lib.php');

Expand Down
2 changes: 1 addition & 1 deletion db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
function xmldb_block_microsoft_upgrade($oldversion) {
if ($oldversion < 2015111912) {
$existingshowoutlooksyncsetting = get_config('block_microsoft', 'settings_showoutlooksync');
if ($existingshowoutlooksyncsetting != 0 ) {
if ($existingshowoutlooksyncsetting != 0) {
add_to_config_log('settings_showoutlooksync', $existingshowoutlooksyncsetting, 0, 'block_microsoft');
}
set_config('settings_showoutlooksync', 0, 'block_microsoft');
Expand Down
6 changes: 3 additions & 3 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2025040810;
$plugin->version = 2025040815;
$plugin->requires = 2025040800;
$plugin->release = '5.0.2';
$plugin->release = '5.0.4';
$plugin->component = 'block_microsoft';
$plugin->maturity = MATURITY_STABLE;
$plugin->dependencies = [
'local_o365' => 2025040810,
'local_o365' => 2025040820,
];