diff --git a/calendar/lib.php b/calendar/lib.php index d64e8e9c61f..ff8fe336f89 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -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.' » '; - + $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); } -} \ No newline at end of file +} diff --git a/lang/en/error.php b/lang/en/error.php index 47c4e4ef772..ed23282aca7 100755 --- a/lang/en/error.php +++ b/lang/en/error.php @@ -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'; diff --git a/mod/chat/gui_basic/index.php b/mod/chat/gui_basic/index.php index fab3f4ebb99..425be29d6c7 100644 --- a/mod/chat/gui_basic/index.php +++ b/mod/chat/gui_basic/index.php @@ -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 diff --git a/mod/chat/gui_header_js/index.php b/mod/chat/gui_header_js/index.php index e6cd0b5d77b..8da232bfa32 100644 --- a/mod/chat/gui_header_js/index.php +++ b/mod/chat/gui_header_js/index.php @@ -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 diff --git a/mod/chat/lang/en/chat.php b/mod/chat/lang/en/chat.php index 402ec584211..46467291c63 100644 --- a/mod/chat/lang/en/chat.php +++ b/mod/chat/lang/en/chat.php @@ -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'; diff --git a/mod/chat/lib.php b/mod/chat/lib.php index fc3ed494336..6df859d2ca8 100644 --- a/mod/chat/lib.php +++ b/mod/chat/lib.php @@ -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); } } } diff --git a/mod/chat/view.php b/mod/chat/view.php index d9dd33d51ea..1033edcf298 100644 --- a/mod/chat/view.php +++ b/mod/chat/view.php @@ -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 "
$strnextsession: ".userdate($chat->chattime).' ('.usertimezone($USER->timezone).')
'; + $now = time(); + $span = $chat->chattime - $now; + if ($chat->chattime and $chat->schedule and ($span>0)) { // A chat is scheduled + echo ''; + echo get_string('sessionstart', 'chat', format_time($span)); + echo '
'; } if (empty($USER->screenreader)) {