-
Notifications
You must be signed in to change notification settings - Fork 3
/
block_quickmail.php
99 lines (80 loc) · 3.56 KB
/
block_quickmail.php
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
<?php
// Written at Louisiana State University
require_once($CFG->dirroot . '/blocks/quickmail/lib.php');
class block_quickmail extends block_list {
function init() {
$this->title = quickmail::_s('pluginname');
}
function applicable_formats() {
return array('site' => false, 'my' => false, 'course-view' => true);
}
function has_config() {
return true;
}
function get_content() {
global $CFG, $COURSE, $OUTPUT;
if ($this->content !== NULL) {
return $this->content;
}
$this->content = new stdClass;
$this->content->items = array();
$this->content->icons = array();
$this->content->footer = '';
$context = get_context_instance(CONTEXT_COURSE, $COURSE->id);
$config = quickmail::load_config($COURSE->id);
$permission = has_capability('block/quickmail:cansend', $context);
$can_send = ($permission or !empty($config['allowstudents']));
$icon_class = array('class' => 'icon');
$cparam = array('courseid' => $COURSE->id);
if ($can_send) {
$send_email_str = quickmail::_s('composenew');
$send_email = html_writer::link(
new moodle_url('/blocks/quickmail/email.php', $cparam),
$send_email_str
);
$this->content->items[] = $send_email;
$this->content->icons[] = $OUTPUT->pix_icon('i/email', $send_email_str, 'moodle', $icon_class);
$signature_str = quickmail::_s('signature');
$signature = html_writer::link(
new moodle_url('/blocks/quickmail/signature.php', $cparam),
$signature_str
);
$this->content->items[] = $signature;
$this->content->icons[] = $OUTPUT->pix_icon('i/edit', $signature_str, 'moodle', $icon_class);
$draft_params = $cparam + array('type' => 'drafts');
$drafts_email_str = quickmail::_s('drafts');
$drafts = html_writer::link(
new moodle_url('/blocks/quickmail/emaillog.php', $draft_params),
$drafts_email_str
);
$this->content->items[] = $drafts;
$this->content->icons[] = $OUTPUT->pix_icon('i/settings', $drafts_email_str, 'moodle', $icon_class);
$history_str = quickmail::_s('history');
$history = html_writer::link(
new moodle_url('/blocks/quickmail/emaillog.php', $cparam),
$history_str
);
$this->content->items[] = $history;
$this->content->icons[] = $OUTPUT->pix_icon('i/settings', $history_str, 'moodle', $icon_class);
}
if (has_capability('block/quickmail:allowalternate', $context)) {
$alt_str = quickmail::_s('alternate');
$alt = html_writer::link(
new moodle_url('/blocks/quickmail/alternate.php', $cparam),
$alt_str
);
$this->content->items[] = $alt;
$this->content->icons[] = $OUTPUT->pix_icon('i/edit', $alt_str, 'moodle', $icon_class);
}
if (has_capability('block/quickmail:canconfig', $context)) {
$config_str = quickmail::_s('config');
$config = html_writer::link(
new moodle_url('/blocks/quickmail/config.php', $cparam),
$config_str
);
$this->content->items[] = $config;
$this->content->icons[] = $OUTPUT->pix_icon('i/settings', $config_str, 'moodle', $icon_class);
}
return $this->content;
}
}