-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblock_onlineclasses.php
More file actions
127 lines (99 loc) · 4.29 KB
/
Copy pathblock_onlineclasses.php
File metadata and controls
127 lines (99 loc) · 4.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?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/>.
/**
* onlineclasses block caps.
*
* @package block_onlineclasses
* @copyright Michael Gardener <mgardener@cissq.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
class block_onlineclasses extends block_base {
function init() {
$this->title = get_string('pluginname', 'block_onlineclasses');
}
public function specialization() {
if (!empty($this->config->blocktitle)) {
$this->title = $this->config->blocktitle;
} else {
$this->title = get_string('pluginname', 'block_onlineclasses');
}
}
function get_content() {
global $CFG, $OUTPUT, $USER, $DB, $COURSE;
if ($this->content !== null) {
return $this->content;
}
if (empty($this->instance)) {
$this->content = '';
return $this->content;
}
$this->content = new stdClass();
$this->content->items = array();
$this->content->icons = array();
$this->content->footer = '';
$this->content->text = '';
/*
$context = get_context_instance(CONTEXT_COURSE, $this->course->id);
$isteacher = has_capability('moodle/grade:viewall', $context);
if (!$isteacher) {
return $this->content;
}
*/
if ($COURSE->id == SITEID) {
return $this->content;
}
// user/index.php expect course context, so get one if page has module context.
$currentcontext = $this->page->context->get_course_context(false);
if (empty($currentcontext)) {
return $this->content;
}
$isteacher = has_capability('moodle/grade:viewall', $currentcontext);
if ($isteacher) {
$this->content->text .= '<div class="onlineclasses_button center"><form action="' . $CFG->wwwroot . '/blocks/onlineclasses/meetings.php?courseid='.$COURSE->id.'" method="post">
<button class="onlineclasses_button btn btn-large btn-block btn-primary" type="submit" value="Submit">'.get_string('schedulenewmeeting', 'block_onlineclasses').'</button>
</form>
</div>';
}
if ($meetings = $DB->get_records_select("onlineclasses_meeting", "starttime > ". time().' AND courseid = '.$COURSE->id)) {
$this->content->text .= '<div class="onlineclasses_upcomingevent">'.get_string('upcomingmeeting', 'block_onlineclasses').'</div>';
foreach ($meetings as $meeting) {
$this->content->text .= '<div class="onlineclasses_upcomingevents"><a target="_blank" onclick="return confirm(\'Do you want to join meeting?\')" href="' . $meeting->joinurl . '">' . $meeting->subject . '</a><br/>'.date('l, F j, Y \a\t g:i A', $meeting->starttime).'</div>';
}
}
if ($isteacher) {
$this->content->text .= '<div class="onlineclasses_button center">
<a href="' . $CFG->wwwroot . '/blocks/onlineclasses/token.php?authorize=1&courseid='.$COURSE->id.'">'.get_string('settings', 'block_onlineclasses').'</a>
</div>';
}
return $this->content;
}
public function applicable_formats() {
return array('all' => true);
}
public function instance_allow_multiple() {
return false;
}
function has_config() {
return true;
}
public function cron() {
global $CFG, $DB;
mtrace( "BLOCK OnlineClasses" );
$today = time();
return true;
}
}