Commit 26850344 authored by Plugins bot's avatar Plugins bot

PLUGIN-23307 theme_boost_o365teams: cibot precheck request

parent 8ee6f493
# Installation
Copy the content of the repository into theme/boost_o365teams directory.
Follow https://docs.moodle.org/35/en/Installing_plugins#Installing_manually_at_the_server .
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
define(['jquery'], function ($) {
return {
init: function() {
if (window.location == window.parent.location) {
// not in iframe, show page elements
$('nav.navbar').show();
$('nav.navbar').css('display', 'flex');
$('div#nav-drawer').show();
$('section[data-region="blocks-column"]').show();
$('footer#page-footer').show();
$('div#course_page_title').css('display', 'none');
$('.popupicon').css('display', 'none');
} else {
// in iframe, hide page elements
$('body.drawer-open-left').css('margin-left', '0');
$('div#page').css('margin-top', '0');
$('section#region-main.has-blocks').css('width', '100%');
$('div#page-wrapper').css('margin-bottom', '0');
$('div.context-header-settings-menu').remove();
$('div.region-main-settings-menu').remove();
$('div.region_main_settings_menu_proxy').remove();
$('div.action-menu-trigger').remove();
$('div.ml-auto').remove();
$('a.printicon').remove();
$('header#page-header').css('display', 'none');
$('.activityinstance a').click(function() {
$(this).attr('target', '_blank');
});
$('.modtype_assign .activityinstance a').click(function() {
$(this).attr('target', '_self');
});
$('.modtype_quiz .activityinstance a').click(function() {
$(this).attr('target', '_self');
});
$('#page-mod-assign-view .submissionlinks a').click(function() {
$(this).attr('target', '_blank');
});
$('.quizattempt .singlebutton form').click(function() {
$(this).attr('target', '_blank');
$(this).attr('method', 'get');
});
}
$("body").fadeIn(150);
}
}
});
define(['jquery'], function($) {
return {
init: function() {
microsoftTeams.initialize();
microsoftTeams.getContext(function (context) {
theme = context.theme;
$("body").addClass("theme_" + theme);
});
microsoftTeams.registerOnThemeChangeHandler(function (theme) {
$("body").removeClass("theme_default");
$("body").removeClass("theme_dark");
$("body").removeClass("theme_contrast");
$("body").addClass("theme_" + theme);
});
}
}
});
<?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/>.
namespace theme_boost_o365teams\output;
use coding_exception;
use html_writer;
use tabobject;
use tabtree;
use custom_menu_item;
use custom_menu;
use block_contents;
use navigation_node;
use action_link;
use stdClass;
use moodle_url;
use preferences_groups;
use action_menu;
use help_icon;
use single_button;
use paging_bar;
use context_course;
use pix_icon;
defined('MOODLE_INTERNAL') || die;
class core_renderer extends \theme_boost\output\core_renderer {
/**
* Return header html.
* The header section includes custom content security policy setting, as well as reference to Microsoft teams JS
* lib.
*
* @return string
*/
public function standard_head_html() {
$output = parent::standard_head_html();
$output .= "<meta http-equiv=\"Content-Security-Policy\" content=\"default-src *; style-src 'self'
'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://statics.teams.microsoft.com;
font-src data: *\">\n";
$output .= "<script src=\"https://statics.teams.microsoft.com/sdk/v1.0/js/MicrosoftTeams.min.js\"></script>\n";
return $output;
}
/**
* Return HTML that shows logged in user link.
*
* @return string
* @throws \moodle_exception
*/
public function user_link() {
global $USER, $OUTPUT;
if (!empty($USER->id)) {
$profilepagelink = new moodle_url('/user/profile.php',
array('id' => $USER->id));
$profilepic = $OUTPUT->user_picture($USER, array('size' => 26, 'link' => false));
$userfullname = fullname($USER);
$piclink = html_writer::link($profilepagelink, $profilepic,
array('target' => '_blank', 'class' => 'user_details'));
$userprofile = html_writer::link($profilepagelink, $userfullname,
array('target' => '_blank'));
return $piclink . $userprofile;
} else {
return "";
}
}
/**
* Return page footer.
* Page footer contains JS calls to microsoft Teams JS lib.
*
* @return string
*/
public function footer() {
$footer = parent::footer();
$js = 'microsoftTeams.initialize();';
$footer .= html_writer::script($js);
return $footer;
}
/**
* Return HTML for feedback link.
*
* @return string
* @throws coding_exception
*/
public function feedback_link() {
$feedbacklink = '';
// Hardcoded URL.
$feedbacklinksetting = 'https://microsoftteams.uservoice.com/forums/916759-moodle';
if ($feedbacklinksetting) {
$feedbacklink = html_writer::link($feedbacklinksetting,
html_writer::tag('span',
get_string('feedback', 'theme_boost_o365teams')),
array('target' => '_blank', 'class' => 'feedbacklink',
'title' => get_string('share_feedback', 'theme_boost_o365teams')));
}
return $feedbacklink;
}
/**
* Return page footer stamp.
* Stamp is from user upload in theme settings, or Moodle logo if not uploaded.
*
* @return string
* @throws \moodle_exception
*/
public function get_footer_stamp() {
global $CFG, $PAGE, $OUTPUT;
if (!empty($PAGE->theme->setting_file_url('footer_stamp', 'footer_stamp'))) {
$fileurl = $PAGE->theme->setting_file_url('footer_stamp', 'footer_stamp');
// Get a URL suitable for moodle_url.
$relativebaseurl = preg_replace('|^https?://|i', '//', $CFG->wwwroot);
$relativefileurl = str_replace($relativebaseurl, '', $fileurl);
$url = new moodle_url($relativefileurl);
$img = html_writer::empty_tag('img', array("src" => $url));
$coursepageurl = $this->page->url;
$stamp = html_writer::link($coursepageurl, $img, array('target' => '_blank', 'class' => 'stamp'));
} else {
$img = html_writer::empty_tag('img', array("src" => $OUTPUT->image_url('moodlelogo', 'theme')));
$coursepageurl = $this->page->url;
$stamp = html_writer::link($coursepageurl, $img, array('target' => '_blank', 'class' => 'stamp'));
}
return $stamp;
}
}
<?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/>.
/**
* Boost o365teams.
*
* @package theme_boost_o365teams
* @copyright 2018 Enovation Solutions
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once(__DIR__ . '/lib.php');
$THEME->name = 'boost_o365teams';
$THEME->sheets = ['custom'];
$THEME->editor_sheets = [];
$THEME->parents = ['boost'];
$THEME->enable_dock = false;
$THEME->yuicssmodules = array();
$THEME->rendererfactory = 'theme_overridden_renderer_factory';
$THEME->requiredblocks = '';
$THEME->addblockposition = BLOCK_ADDBLOCK_POSITION_FLATNAV;
$THEME->layouts = [
// Most backwards compatible layout without the blocks - this is the layout used by default.
'base' => array(
'file' => 'columns1.php',
'regions' => array(),
),
// Standard layout with blocks, this is recommended for most pages with general information.
'standard' => array(
'file' => 'columns2.php',
'regions' => array('side-pre'),
'defaultregion' => 'side-pre',
),
// Main course page.
'course' => array(
'file' => 'columns2.php',
'regions' => array('side-pre'),
'defaultregion' => 'side-pre',
'options' => array('langmenu' => true),
),
'coursecategory' => array(
'file' => 'columns2.php',
'regions' => array('side-pre'),
'defaultregion' => 'side-pre',
),
// Part of course, typical for modules - default page layout if $cm specified in require_login().
'incourse' => array(
'file' => 'columns2.php',
'regions' => array('side-pre'),
'defaultregion' => 'side-pre',
),
// The site home page.
'frontpage' => array(
'file' => 'columns2.php',
'regions' => array('side-pre'),
'defaultregion' => 'side-pre',
'options' => array('nonavbar' => true),
),
// Server administration scripts.
'admin' => array(
'file' => 'columns2.php',
'regions' => array('side-pre'),
'defaultregion' => 'side-pre',
),
// My dashboard page.
'mydashboard' => array(
'file' => 'columns2.php',
'regions' => array('side-pre'),
'defaultregion' => 'side-pre',
'options' => array('nonavbar' => true, 'langmenu' => true),
),
// My public page.
'mypublic' => array(
'file' => 'columns2.php',
'regions' => array('side-pre'),
'defaultregion' => 'side-pre',
),
'login' => array(
'file' => 'login.php',
'regions' => array(),
'options' => array('langmenu' => true),
),
// Pages that appear in pop-up windows - no navigation, no blocks, no header.
'popup' => array(
'file' => 'columns1.php',
'regions' => array(),
'options' => array('nofooter' => true, 'nonavbar' => true),
),
// No blocks and minimal footer - used for legacy frame layouts only!
'frametop' => array(
'file' => 'columns1.php',
'regions' => array(),
'options' => array('nofooter' => true, 'nocoursefooter' => true),
),
// Embeded pages, like iframe/object embeded in moodleform - it needs as much space as possible.
'embedded' => array(
'file' => 'embedded.php',
'regions' => array()
),
// Used during upgrade and install, and for the 'This site is undergoing maintenance' message.
// This must not have any blocks, links, or API calls that would lead to database or cache interaction.
// Please be extremely careful if you are modifying this layout.
'maintenance' => array(
'file' => 'maintenance.php',
'regions' => array(),
),
// Should display the content and basic headers only.
'print' => array(
'file' => 'columns1.php',
'regions' => array(),
'options' => array('nofooter' => true, 'nonavbar' => false),
),
// The pagelayout used when a redirection is occuring.
'redirect' => array(
'file' => 'embedded.php',
'regions' => array(),
),
// The pagelayout used for reports.
'report' => array(
'file' => 'columns2.php',
'regions' => array('side-pre'),
'defaultregion' => 'side-pre',
),
// The pagelayout used for safebrowser and securewindow.
'secure' => array(
'file' => 'secure.php',
'regions' => array('side-pre'),
'defaultregion' => 'side-pre'
)
];
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
<?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/>.
/**
* Boost o365teams.
*
* @package theme_boost_o365teams
* @copyright 2018 Enovation Solutions
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$string['choosereadme'] = 'Boost o365teams is a modern highly-customisable theme. This theme is intended to be used directly, or as a parent theme when creating new themes utilising Bootstrap 4.';
$string['pluginname'] = 'Boost Office365 Teams';
$string['region-side-pre'] = 'Right';
$string['placementfrontpage'] = 'Front page';
$string['editcourse'] = 'Edit course';
$string['share_feedback'] = 'Share feedback';
$string['feedback'] = 'Feedback';
$string['edit_course'] = 'Edit course in browser window';
$string['open_course'] = 'Open course in browser window';
$string['navigatereturn'] = 'Return to quiz menu';
$string['configtitle'] = 'Boost Office365 Teams';
$string['generalsettings'] = 'General settings';
$string['showteamfeedbacklink'] = 'Show feedback link';
$string['showteamfeedbacklink_desc'] = 'If enabled, a link to leave feedback to Moodle Microsoft 365 integration will be shown when a Moodle tab is opened in Teams.';
$string['advancedsettings'] = 'Advanced settings';
$string['footer_stamp_title'] = "Tabs Footer Stamp";
$string['footer_stamp_desc'] = "Displays Image or logo at bottom right of tabs.<br/>(Max-Height: 60px)";
<?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/>.
/**
* A two column layout for the boost theme.
*
* @package theme_boost_o365teams
* @copyright 2018 Enovation Solutions
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
user_preference_allow_ajax_update('drawer-open-nav', PARAM_ALPHA);
require_once($CFG->libdir . '/behat/lib.php');
if (isloggedin()) {
$navdraweropen = (get_user_preferences('drawer-open-nav', 'true') == 'true');
} else {
$navdraweropen = false;
}
$extraclasses = [];
if ($navdraweropen) {
$extraclasses[] = 'drawer-open-left';
}
$bodyattributes = $OUTPUT->body_attributes($extraclasses);
$blockshtml = $OUTPUT->blocks('side-pre');
$hasblocks = strpos($blockshtml, 'data-block=') !== false;
$showfeedback = get_config('theme_boost_o365teams', 'showteamfeedbacklink');
$regionmainsettingsmenu = $OUTPUT->region_main_settings_menu();
$coursepage = $CFG->wwwroot . '/course/view.php?id=' . $PAGE->course->id;
$url = $PAGE->url;
$iscourseoverview = false;
if ((strpos($url, 'course/view.php') !== false) && (strpos($url, 'section=') == false)) {
$iscourseoverview = false;
} else {
$iscourseoverview = true;
}
$templatecontext = [
'sitename' => format_string($SITE->shortname, true, ['context' => context_course::instance(SITEID), "escape" => false]),
'output' => $OUTPUT,
'sidepreblocks' => $blockshtml,
'hasblocks' => $hasblocks,
'showfeedback' => $showfeedback,
'bodyattributes' => $bodyattributes,
'navdraweropen' => $navdraweropen,
'regionmainsettingsmenu' => $regionmainsettingsmenu,
'hasregionmainsettingsmenu' => !empty($regionmainsettingsmenu),
'course_page' => $coursepage,
'is_course_overview' => $iscourseoverview,
];
$templatecontext['flatnavigation'] = $PAGE->flatnav;
echo $OUTPUT->render_from_template('theme_boost_o365teams/columns2', $templatecontext);
<?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/>.
/**
* A login page layout for the boost theme.
*
* @package theme_boost_o365teams
* @copyright 2018 Enovation Solutions
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$bodyattributes = $OUTPUT->body_attributes();
$templatecontext = [
'sitename' => format_string($SITE->shortname, true, ['context' => context_course::instance(SITEID), "escape" => false]),
'output' => $OUTPUT,
'bodyattributes' => $bodyattributes
];
echo $OUTPUT->render_from_template('theme_boost_o365teams/login', $templatecontext);
<?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/>.
/**
* Boost o365teams.
*
* @package theme_boost_o365teams
* @copyright 2018 Enovation Solutions
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
use theme_boost_o365teams\css_processor;
/**
* Serve any files associated with the theme settings.
*
* @param stdClass $course
* @param stdClass $cm
* @param context $context
* @param string $filearea
* @param array $args
* @param bool $forcedownload
* @param array $options
* @return bool
*/
function theme_boost_o365teams_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array()) {
static $theme;
if (empty($theme)) {
$theme = theme_config::load('boost_o365teams');
}
if ($context->contextlevel == CONTEXT_SYSTEM) {
if ($filearea === 'footer_stamp') {
return $theme->setting_file_serve('footer_stamp', $args, $forcedownload, $options);
} else {
send_file_not_found();
}
} else {
send_file_not_found();
}
}