Proyectos de Subversion Moodle

Rev

Rev 1 | Rev 602 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 601
Línea 30... Línea 30...
30
 * Class definition for the Message My Teacher block
30
 * Class definition for the Message My Teacher block
31
 *
31
 *
32
 * @copyright  2010-2012 Tauntons College, UK. 2012 Onwards Mark Johnson
32
 * @copyright  2010-2012 Tauntons College, UK. 2012 Onwards Mark Johnson
33
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
33
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
34
 */
34
 */
35
class block_messageteacher extends block_base {
35
class block_messageteacher extends block_base
-
 
36
{
Línea 36... Línea 37...
36
 
37
 
37
    /**
38
    /**
38
     * Initialise the block title.
39
     * Initialise the block title.
39
     */
40
     */
-
 
41
    public function init()
40
    public function init() {
42
    {
41
        $this->title = get_string('pluginname', 'block_messageteacher');
43
        $this->title = get_string('pluginname', 'block_messageteacher');
Línea 42... Línea 44...
42
    }
44
    }
43
 
45
 
44
    /**
46
    /**
45
     * Set applicable formats, any page except My Moodle.
47
     * Set applicable formats, any page except My Moodle.
-
 
48
     */
46
     */
49
    public function applicable_formats()
47
    public function applicable_formats() {
50
    {
Línea 48... Línea 51...
48
          return array('all' => true, 'my' => false);
51
        return array('all' => true, 'my' => false);
49
    }
52
    }
50
 
53
 
51
    /**
54
    /**
52
     * Enable block config.
55
     * Enable block config.
53
     *
56
     *
-
 
57
     * @return true
54
     * @return true
58
     */
55
     */
59
    public function has_config()
Línea 56... Línea 60...
56
    public function has_config() {
60
    {
57
        return true;
61
        return true;
58
    }
62
    }
59
 
63
 
60
    /**
64
    /**
61
     * Gets a list of "teachers" with the defined role, and displays a link to message each
65
     * Gets a list of "teachers" with the defined role, and displays a link to message each
-
 
66
     *
62
     *
67
     * @return stdClass
Línea 63... Línea 68...
63
     * @return stdClass
68
     */
64
     */
69
    public function get_content()
65
    public function get_content() {
70
    {
Línea 91... Línea 96...
91
                $where .= ' OR (c.instanceid = ? AND c.contextlevel = ?))';
96
                $where .= ' OR (c.instanceid = ? AND c.contextlevel = ?))';
92
            } else {
97
            } else {
93
                $where .= ')';
98
                $where .= ')';
94
            }
99
            }
95
            $params = array_merge($params, array($USER->id), $uparams);
100
            $params = array_merge($params, array($USER->id), $uparams);
96
            $where .= ' AND userid != ? AND roleid '.$usql;
101
            $where .= ' AND userid != ? AND roleid ' . $usql;
97
            $order = ' ORDER BY u.firstname ASC, u.lastname';
102
            $order = ' ORDER BY u.firstname ASC, u.lastname';
Línea 98... Línea 103...
98
 
103
 
99
            if ($teachers = $DB->get_records_sql($select.$from.$where.$order, $params)) {
104
            if ($teachers = $DB->get_records_sql($select . $from . $where . $order, $params)) {
100
                if ($usegroups && $coursehasgroups) {
105
                if ($usegroups && $coursehasgroups) {
101
                    try {
106
                    try {
102
                        $groupteachers = array();
107
                        $groupteachers = array();
103
                        $usergroupings = groups_get_user_groups($COURSE->id, $USER->id);
108
                        $usergroupings = groups_get_user_groups($COURSE->id, $USER->id);
Línea 129... Línea 134...
129
                    }
134
                    }
130
                }
135
                }
Línea 131... Línea 136...
131
 
136
 
132
                $items = array();
137
                $items = array();
133
                foreach ($teachers as $teacher) {
138
                foreach ($teachers as $teacher) {
134
                    $urlparams = array (
139
                    $urlparams = array(
135
                        'courseid' => $COURSE->id,
140
                        'courseid' => $COURSE->id,
136
                        'referurl' => $this->page->url->out(),
141
                        'referurl' => $this->page->url->out(),
137
                        'recipientid' => $teacher->id
142
                        'recipientid' => $teacher->id
138
                    );
143
                    );
Línea 143... Línea 148...
143
                        $picture->link = false;
148
                        $picture->link = false;
144
                        $picture->size = 50;
149
                        $picture->size = 50;
145
                        $picture = $OUTPUT->render($picture);
150
                        $picture = $OUTPUT->render($picture);
146
                    }
151
                    }
147
                    $name = html_writer::tag('span', fullname($teacher));
152
                    $name = html_writer::tag('span', fullname($teacher));
-
 
153
                    $email = html_writer::tag('span', $teacher->email, ['class' => 'teacher-email']);
148
                    $attrs = [
154
                    $attrs = [
149
                        'href' => $url,
155
                        'href' => $url,
150
                        'class' => 'messageteacher_link',
156
                        'class' => 'messageteacher_link',
151
                        'data-courseid' => $COURSE->id,
157
                        'data-courseid' => $COURSE->id,
152
                        'data-referurl' => $this->page->url->out(),
158
                        'data-referurl' => $this->page->url->out(),
153
                        'data-recipientid' => $teacher->id
159
                        'data-recipientid' => $teacher->id
154
                    ];
160
                    ];
155
                    $items[] = html_writer::tag('a', $picture.$name, $attrs);
161
                    $items[] = html_writer::tag('a', $picture . $name . '<br>' . $email, $attrs);
156
                }
162
                }
157
                $this->content->text = html_writer::alist($items, [
163
                $this->content->text = html_writer::alist($items, [
158
                    'data-contextid' => $this->context->id,
164
                    'data-contextid' => $this->context->id,
159
                    'data-appendurl' => get_config('block_messageteacher', 'appendurl'),
165
                    'data-appendurl' => get_config('block_messageteacher', 'appendurl'),
160
                    'data-referurl' => $this->page->url->out(),
166
                    'data-referurl' => $this->page->url->out(),