-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathblock_gchat.php
More file actions
76 lines (64 loc) · 1.99 KB
/
Copy pathblock_gchat.php
File metadata and controls
76 lines (64 loc) · 1.99 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
<?php
/**
* Global Chat block class implementation
*
* @package block_gchat
* @copyright 2012 Bruno Sampaio
*/
class block_gchat extends block_list {
function init() {
$this->title = get_string('pluginname', 'block_gchat');
}
function get_content() {
global $CFG, $OUTPUT, $PAGE, $DB, $USER;
require_once(__DIR__ . '/lib.php');
if($this->content !== NULL) {
return $this->content;
}
if (isloggedin() and !isguestuser()) {
$this->title = get_string('pluginname', 'block_gchat');
$this->content = new stdClass;
$this->content->icons = '';
$this->content->items = array();
$this->content->footer = '';
$this->content->items[] =
'<img class="icon" src="'.$OUTPUT->image_url('i/loading_small').'" />'.
get_string('loading', 'block_gchat').'...';
// Init javascript
$data = array(
block_gchat_get_server_name(),
block_gchat_get_server_port(),
$CFG->wwwroot,
block_gchat_get_chat_container(),
array('id' => $USER->id, 'name' => $USER->firstname.' '.$USER->lastname),
array(
'close' => array(
'img' => (string) $OUTPUT->image_url('close', 'block_gchat'),
'visibility' => 1
),
'minimize' => array(
'img' => (string) $OUTPUT->image_url('minimize', 'block_gchat'),
'visibility' => 1
),
'maximize' => array(
'img' => (string) $OUTPUT->image_url('maximize', 'block_gchat'),
'visibility' => 0
)
)
);
$jsmodule = array(
'name' => 'module',
'fullpath' => '/blocks/gchat/module.js',
'requires' => array('base', 'io', 'node', 'json', 'selector'),
'strings' => array(
array('send-message', 'block_gchat'),
array('no-support', 'block_gchat'),
array('no-users', 'block_gchat'),
array('connection-lost', 'block_gchat')
)
);
$PAGE->requires->js_init_call('M.block_gchat.init', $data, false, $jsmodule);
}
return $this->content;
}
}