mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-24941, fixed nopermission error when student entering scheduled chat session
This commit is contained in:
parent
5bf725440c
commit
1d5bd3d2ed
@ -269,9 +269,9 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
|
||||
} else if ($event->userid) { // User event
|
||||
$popupicon = 'c/user';
|
||||
}
|
||||
|
||||
|
||||
$dayhref->set_anchor('event_'.$event->id);
|
||||
|
||||
|
||||
$popupcontent .= html_writer::start_tag('div');
|
||||
$popupcontent .= $OUTPUT->pix_icon($popupicon, $popupalt);
|
||||
$popupcontent .= html_writer::link($dayhref, format_string($event->name, true));
|
||||
@ -955,7 +955,7 @@ function calendar_time_representation($time) {
|
||||
* @param int $d
|
||||
* @param int $m
|
||||
* @param int $y
|
||||
* @return moodle_url
|
||||
* @return moodle_url
|
||||
*/
|
||||
function calendar_get_link_href($linkbase, $d, $m, $y) {
|
||||
if (empty($linkbase)) {
|
||||
@ -1016,7 +1016,7 @@ function calendar_get_link_previous($text, $linkbase, $d, $m, $y, $accesshide=fa
|
||||
|
||||
/**
|
||||
* Build and return a next month HTML link, with an arrow.
|
||||
*
|
||||
*
|
||||
* @param string $text The text label.
|
||||
* @param string|moodle_url $linkbase The URL stub.
|
||||
* @param int $d $m $y Day of month, month and year numbers.
|
||||
@ -1549,7 +1549,7 @@ function calendar_format_event_time($event, $now, $linkparams = null, $usecommon
|
||||
} else {
|
||||
$url = calendar_get_link_href(new moodle_url(CALENDAR_URL.'view.php', $linkparams), $enddate['mday'], $enddate['mon'], $enddate['year']);
|
||||
$eventtime = html_writer::link($url, $daystart).$timestart.' <strong>»</strong> ';
|
||||
|
||||
|
||||
$url = calendar_get_link_href(new moodle_url(CALENDAR_URL.'view.php', $linkparams), $startdate['mday'], $startdate['mon'], $startdate['year']);
|
||||
$eventtime .= html_writer::link($url, $dayend).$timeend;
|
||||
}
|
||||
@ -1947,8 +1947,9 @@ class calendar_event {
|
||||
* @see update_event()
|
||||
*
|
||||
* @param stdClass $data
|
||||
* @param boolean $checkcapability if moodle should check calendar managing capability or not
|
||||
*/
|
||||
public function update($data) {
|
||||
public function update($data, $checkcapability=true) {
|
||||
global $CFG, $DB, $USER;
|
||||
|
||||
foreach ($data as $key=>$value) {
|
||||
@ -1960,8 +1961,10 @@ class calendar_event {
|
||||
|
||||
if (empty($this->properties->id) || $this->properties->id < 1) {
|
||||
|
||||
if (!calendar_add_event_allowed($this->properties)) {
|
||||
print_error('nopermissions');
|
||||
if ($checkcapability) {
|
||||
if (!calendar_add_event_allowed($this->properties)) {
|
||||
print_error('nopermissiontoupdatecalendar');
|
||||
}
|
||||
}
|
||||
|
||||
if ($usingeditor) {
|
||||
@ -2055,8 +2058,10 @@ class calendar_event {
|
||||
return true;
|
||||
} else {
|
||||
|
||||
if(!calendar_edit_event_allowed($this->properties)) {
|
||||
print_error('nopermissions');
|
||||
if ($checkcapability) {
|
||||
if(!calendar_edit_event_allowed($this->properties)) {
|
||||
print_error('nopermissiontoupdatecalendar');
|
||||
}
|
||||
}
|
||||
|
||||
if ($usingeditor) {
|
||||
@ -2504,4 +2509,4 @@ class calendar_information {
|
||||
$block->title = get_string('monthlyview', 'calendar');
|
||||
$renderer->add_pretend_calendar_block($block, BLOCK_POS_RIGHT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -379,6 +379,7 @@ $string['nopermissiontomanagegroup'] = 'You do not have the required permissions
|
||||
$string['nopermissiontorate'] = 'Rating of items not allowed!';
|
||||
$string['nopermissiontoshow'] = 'No permission to see this!';
|
||||
$string['nopermissiontounlock'] = 'No permission to unlock!';
|
||||
$string['nopermissiontoupdatecalendar'] = 'Sorry, but you do not currently have permissions to update calendar event';
|
||||
$string['nopermissiontoviewgrades'] = 'Can not view grades.';
|
||||
$string['nopermissiontoviewletergrade'] = 'Missing permission to view letter grades';
|
||||
$string['nopermissiontoviewpage'] = 'You are not allowed to look at this page';
|
||||
|
@ -42,7 +42,7 @@ if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
require_login($course->id, false, $cm);
|
||||
require_capability('mod/chat:chat',$context);
|
||||
require_capability('mod/chat:chat', $context);
|
||||
$PAGE->set_pagelayout('base');
|
||||
|
||||
/// Check to see if groups are being used here
|
||||
|
@ -28,7 +28,7 @@ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
require_login($course->id, false, $cm);
|
||||
|
||||
require_capability('mod/chat:chat',$context);
|
||||
require_capability('mod/chat:chat', $context);
|
||||
|
||||
/// Check to see if groups are being used here
|
||||
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used
|
||||
|
@ -110,6 +110,7 @@ $string['serverip'] = 'Server ip';
|
||||
$string['servermax'] = 'Max users';
|
||||
$string['serverport'] = 'Server port';
|
||||
$string['sessions'] = 'Chat sessions';
|
||||
$string['sessionstart'] = 'Chat session will be start in: {$a}';
|
||||
$string['strftimemessage'] = '%H:%M';
|
||||
$string['studentseereports'] = 'Everyone can view past sessions';
|
||||
$string['studentseereports_help'] = 'If set to No, only users have mod/chat:readlog capability are able to see the chat logs';
|
||||
|
@ -733,7 +733,7 @@ function chat_update_chat_times($chatid=0) {
|
||||
if ($event->id = $DB->get_field_select('event', 'id', $cond, $params)) {
|
||||
$event->timestart = $chat->chattime;
|
||||
$calendarevent = calendar_event::load($event->id);
|
||||
$calendarevent->update($event);
|
||||
$calendarevent->update($event, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,9 +17,9 @@
|
||||
|
||||
/// This page prints a particular instance of chat
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../config.php');
|
||||
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
|
||||
require_once($CFG->dirroot . '/mod/chat/lib.php');
|
||||
require_once($CFG->libdir.'/completionlib.php');
|
||||
require_once($CFG->libdir . '/completionlib.php');
|
||||
|
||||
$id = optional_param('id', 0, PARAM_INT);
|
||||
$c = optional_param('c', 0, PARAM_INT);
|
||||
@ -109,12 +109,16 @@ if ($chat->intro) {
|
||||
echo $OUTPUT->box(format_module_intro('chat', $chat, $cm->id), 'generalbox', 'intro');
|
||||
}
|
||||
|
||||
if (has_capability('mod/chat:chat',$context)) {
|
||||
if (has_capability('mod/chat:chat', $context)) {
|
||||
/// Print the main part of the page
|
||||
echo $OUTPUT->box_start('generalbox', 'enterlink');
|
||||
|
||||
if ($chat->chattime and $chat->schedule) { // A chat is scheduled
|
||||
echo "<p class=\"nextchatsession\">$strnextsession: ".userdate($chat->chattime).' ('.usertimezone($USER->timezone).')</p>';
|
||||
$now = time();
|
||||
$span = $chat->chattime - $now;
|
||||
if ($chat->chattime and $chat->schedule and ($span>0)) { // A chat is scheduled
|
||||
echo '<p>';
|
||||
echo get_string('sessionstart', 'chat', format_time($span));
|
||||
echo '</p>';
|
||||
}
|
||||
|
||||
if (empty($USER->screenreader)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user