Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7649467
make mrbs multiple, remove cron, add scheduled task, add edit_form.php
fschuett Nov 10, 2017
5e6194c
added instance, added upgrade code, added title to config
fschuett Nov 14, 2017
efbfc08
use global config for initial settings to instance
fschuett Nov 14, 2017
bb65b44
make import more eloquent
fschuett Nov 15, 2017
4ce6518
first part to make mrbs use mdl_roles for access
fschuett Nov 15, 2017
f6cb5de
remove usage of global config
fschuett Nov 15, 2017
0f762a3
some debugging fixes
fschuett Nov 15, 2017
129ad5b
add instance to some urls, where it was still missing
fschuett Nov 15, 2017
f79f471
PAGE->context was not set
fschuett Nov 15, 2017
07eb04e
use context_block instead of context_system
fschuett Nov 15, 2017
33365a9
Merge branch 'mdl_roles' into instances
fschuett Nov 15, 2017
205910a
Add linkname, install contextlevels
fschuett Nov 16, 2017
0adb085
fix some errors
fschuett Nov 16, 2017
3eb75c9
fix configuration not existing error
fschuett Nov 16, 2017
6696c5d
announce changes in README.txt
fschuett Nov 17, 2017
0763d08
Merge branch 'master' of https://github.com/arborrow/moodle-block_mrb…
fschuett Nov 18, 2017
68a0125
fix version number
fschuett Nov 18, 2017
ede97cd
use default_instance for compatibility reason
fschuett Nov 25, 2017
11bad89
some fixes for default instance
fschuett Nov 26, 2017
cbfc0c3
fixed install error
fschuett Nov 26, 2017
c361534
add multiple instances to mrbs
fschuett Nov 26, 2017
f5e2975
Merge branch 'instances' of github.com:fschuett/moodle-block_tbs into…
fschuett Nov 26, 2017
7fe7622
add multiple instances to mrbs
fschuett Nov 26, 2017
3b4645b
Merge branch 'instances' of github.com:fschuett/moodle-block_tbs into…
fschuett Nov 26, 2017
c003e2e
fix: use global config for default instance
fschuett Jul 11, 2019
3b8686c
php7 deprecated: named constructor
fschuett Nov 13, 2019
c27636c
moodle 3.7 use OUTPUT for print_textarea, split lines
fschuett Nov 13, 2019
ecf3594
fix required array param message
fschuett Nov 13, 2019
477b91a
fix updatefreerooms.js - variable name error
fschuett Nov 14, 2019
5028afd
session cookie handling removed, is done by moodle anyway
fschuett Nov 14, 2019
39d023c
php7: initialize array with "array()"
fschuett Nov 26, 2019
b6339d5
Merge branch 'master' into mix
Oct 28, 2022
d60b90f
Fixed constructor for PHP 7
NunesGodinho Oct 6, 2017
2029237
Fix repeat entry handling + cookie debugging warning
davosmith Dec 8, 2018
a18284f
Update view_entry.php
der-martin85 Feb 4, 2024
9473909
Merge pull request #1 from der-martin85/instances
fschuett Feb 4, 2024
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
12 changes: 11 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Hence, use this block at your own risk.
* Changes *

2022-03-19 - PHP 7+, 8+ compatibility fixes; Moodle 3.8+ compatibility fixes.
2017-11-17 - Make multiple instances available in MRBS
2017-11-17 - Make MRBS honor course roles: student <-> Viewer, editingteacher <-> Editor, manager <-> Admin
2014-06-09 - Fixed compatibility with M2.7
2014-06-09 - Confirmed compatibility with M2.6, fixed roomsearch with periods disabled, removal of deprecated 'ereg_replace' funcion (minor warning message).
2013-06-23 - New capability 'block/mrbs:ignoremaxadvancedays' - allows admin users to bypass the 'max_advance_days' restriction.
Expand Down Expand Up @@ -63,6 +65,9 @@ Because of changes in the way that MRBS handles database calls (they switched in

In April 2011, Davo Smith ( http://www.davodev.co.uk ), commissioned by Synergy Learning ( http://www.synergy-learning.com/ ) and Landesmedienzentrum Baden-Württemberg (http://www.lmz-bw.de/ ), updated this block to work with Moodle 2.0. This built upon some earlier work by Stephen Bourget, but included updating the block to make use of the Moodle database functionality (for increased security and compatibility with all Moodle supported databases), as well as a number of minor bug fixes, security improvements and general code-cleaning.

In November 2017, Frank Schütte ( http://www.gymnasium-himmelsthuer.de ), added code to host multiple instances of MRBS and the ability to
assign manager role locally to MRBS instance to administer it.

* MRBS Block - Installation *

1) Save the zip file somewhere onto your local computer and extract all the files
Expand All @@ -78,7 +83,12 @@ In April 2011, Davo Smith ( http://www.davodev.co.uk ), commissioned by Synergy
Details about making use of these capabilities is found at: http://docs.moodle.org/en/MRBS_block#Installation
Three roles are automatically created during installation - 'mrbsviewer', 'mrbseditor' and 'mrbsadmin'. Assigning users these roles at the system level will allow them the appropriate level of access to the MRBS system.

6) The MRBS block is primarily intended for use on the Moodle front page (it works on other pages, but note that each instance of the block links to the same set of bookings - it is not possible to create independent sets of bookings by adding the block to multiple pages)
In the multiple instance code, there is a change to use moodle roles assigned locally to each instance of the MRBS. So course students are
capable of viewing MRBS, editing teachers are capable of editing MRBS, and manager (assigned locally to block) are able to administer
the MRBS.

6) The MRBS block is now useful not only on the front page but also in course pages. Each instance of the block links to it's own set
of areas, rooms and bookings and can have it's own viewers, editors and administrators.

* MRBS Block - unconfirmed capability *

Expand Down
75 changes: 58 additions & 17 deletions block_mrbs.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

class block_mrbs extends block_base {

function init() {
Expand All @@ -30,42 +29,84 @@ function applicable_formats() {
return array('all' => true);
}

function specialization() {
if($this->config == null) {
$this->config = get_config('block/mrbs');
$this->config->title = get_string('newmrbsblock','block_mrbs');
$this->config->linkname = get_string('accessmrbs','blockmrbs');
$this->instance_config_commit();
}
$this->title = isset($this->config->title) ? format_string($this->config->title) : format_string(get_string('newmrbsblock', 'block_mrbs'));
}

function instance_allow_multiple() {
return true;
}

function get_content() {
global $CFG, $OUTPUT;

if ($this->content !== null) {
return $this->content;
}

$cfg_mrbs = get_config('block/mrbs');

$context = context_system::instance();
$context = context_block::instance($this->instance->id);

if (has_capability('block/mrbs:viewmrbs', $context) or has_capability('block/mrbs:editmrbs', $context) or has_capability('block/mrbs:administermrbs', $context)) {
if (isset($CFG->block_mrbs_serverpath)) {
$serverpath = $CFG->block_mrbs_serverpath;
if (isset($this->instance->linkname)) {
$go = $this->instance->linkname;
} else {
$serverpath = $CFG->wwwroot.'/blocks/mrbs/web';
$go = get_string('accessmrbs', 'block_mrbs');
}
$go = get_string('accessmrbs', 'block_mrbs');
$icon = $OUTPUT->pix_icon('web', '', 'block_mrbs');
$target = '';
if ($cfg_mrbs->newwindow) {
if (isset($this->config->newwindow) and $this->config->newwindow) {
$target = ' target="_blank" ';
}
$this->content = new stdClass();
$this->content->text = '<a href="'.$serverpath.'/index.php" '.$target.'>'.$icon.' &nbsp;'.$go.'</a>';
if (isset($this->config->serverpath) && $this->config->serverpath != "") {
$serverpath = $this->config->serverpath;
} else {
$serverpath = $CFG->wwwroot.'/blocks/mrbs/web';
}
if (isset($this->instance->id)) {
$instance = $this->instance->id;
} else {
throw new \coding_error("Instance id must be set<br/>\n");
}
$this->content = new stdClass;
$this->content->text = '<a href="'.$serverpath.'/index.php?instance='.$instance.'" '.$target.'>'.$icon.' &nbsp;'.$go.'</a>';
$this->content->footer = '';
return $this->content;
}

return null;
}

function cron() {
global $CFG;
include($CFG->dirroot.'/blocks/mrbs/import.php');

return true;

function instance_config_save($data, $nolongerused = false) {
// modify type of select fields to be int
$data->newwindow = intval($data->newwindow);
$data->enable_periods = intval($data->enable_periods);
if ($data->enable_periods == 0) {
$data->morningstarts = intval($data->morningstarts);
$data->morningstarts_min = intval($data->morningstarts_min);
$data->eveningends = intval($data->eveningends);
$data->eveningends_min = intval($data->eveningends_min);
}
$data->weekstarts = intval($data->weekstarts);
$data->dateformat = intval($data->dateformat);
$data->timeformat = intval($data->timeformat);
$data->view_week_number = intval($data->view_week_number);
$data->times_right_side = intval($data->times_right_side);
$data->javascript_cursor = intval($data->javascript_cursor);
$data->show_plus_link = intval($data->show_plus_link);
$data->mail_admin_on_bookings = intval($data->mail_admin_on_bookings);
$data->mail_area_admin_on_bookings = intval($data->mail_area_admin_on_bookings);
$data->mail_room_admin_on_bookings = intval($data->mail_room_admin_on_bookings);
$data->mail_admin_on_delete = intval($data->mail_admin_on_delete);
$data->mail_admin_all = intval($data->mail_admin_all);
$data->mail_details = intval($data->mail_details);
$data->mail_booker = intval($data->mail_booker);
parent::instance_config_save($data, $nolongerused);
}

}
9 changes: 6 additions & 3 deletions classes/event/booking_created.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static function get_name() {
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has updated a new booking in '{$this->other['room']}' for '{$this->other['name']}'";
return "The user with id '$this->userid' has updated a new booking for '{$this->other['instance']}' in '{$this->other['room']}' for '{$this->other['name']}'";
}

/**
Expand All @@ -72,7 +72,7 @@ public function get_description() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/blocks/mrbs/web/view_entry.php', array('id' => $this->objectid));
return new \moodle_url('/blocks/mrbs/web/view_entry.php', array('instance' => $this->other['instance'], 'id' => $this->objectid));
}

/**
Expand All @@ -82,11 +82,14 @@ public function get_url() {
*/
protected function get_legacy_logdata() {
global $CFG;
return array(SITEID, 'mrbs', 'add booking', $CFG->wwwroot.'blocks/mrbs/web/view_entry.php?id='.$this->objectid,
return array(SITEID, 'mrbs', 'add booking', $CFG->wwwroot.'blocks/mrbs/web/view_entry.php?instance='.$this->other['instance'].'&id='.$this->objectid,
$this->other['name']);
}

protected function validate_data() {
if (!isset($this->other['instance'])) {
throw new \coding_exception('Must specify the instance of the booking as \'other[\'instance\']\'');
}
if (!isset($this->other['name'])) {
throw new \coding_exception('Must specify the name of the booking as \'other[\'name\']\'');
}
Expand Down
9 changes: 6 additions & 3 deletions classes/event/booking_updated.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static function get_name() {
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has updated a booking in '{$this->other['room']}' for '{$this->other['name']}'";
return "The user with id '$this->userid' has updated a booking for '{$this->other['instance']}'in '{$this->other['room']}' for '{$this->other['name']}'";
}

/**
Expand All @@ -72,7 +72,7 @@ public function get_description() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/blocks/mrbs/web/view_entry.php', array('id' => $this->objectid));
return new \moodle_url('/blocks/mrbs/web/view_entry.php', array('instance' => $this->other['instance'], 'id' => $this->objectid));
}

/**
Expand All @@ -82,11 +82,14 @@ public function get_url() {
*/
protected function get_legacy_logdata() {
global $CFG;
return array(SITEID, 'mrbs', 'edit booking', $CFG->wwwroot.'blocks/mrbs/web/view_entry.php?id='.$this->objectid,
return array(SITEID, 'mrbs', 'edit booking', $CFG->wwwroot.'blocks/mrbs/web/view_entry.php?instance='.$this->other['instance'].'&id='.$this->objectid,
$this->other['name']);
}

protected function validate_data() {
if (!isset($this->other['instance'])) {
throw new \coding_exception('Must specify the instance of the booking as \'other[\'instance\']\'');
}
if (!isset($this->other['name'])) {
throw new \coding_exception('Must specify the name of the booking as \'other[\'name\']\'');
}
Expand Down
38 changes: 38 additions & 0 deletions classes/task/mrbs_import.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?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/>.

/**
* The block_mrbs booking created event.
*
* @package block_mrbs
* @copyright 2014 Davo Smith <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace block_mrbs\task;

class mrbs_import extends \core\task\scheduled_task {
public function get_name() {
return get_string('mrbs:import', 'block_mrbs');
}

public function execute() {
global $CFG;
include($CFG->dirroot.'/blocks/mrbs/import.php');

return true;
}
}
Loading