-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdetails.php
More file actions
163 lines (154 loc) · 5.35 KB
/
details.php
File metadata and controls
163 lines (154 loc) · 5.35 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Module_Chatjs extends Module {
public $version = '1.0';
public $st_namespace = "chatjs";
public $st_name = "chatjs";
public $st_slug = "chatjs";
public function info() {
return array(
'name' => array(
'en' => 'Chat JS',
'es' => 'Chat JS'
),
'description' => array(
'en' => 'Chat system builded with Javascript',
'es' => 'Sistema de Chat construido con Javascript'
),
'frontend' => true,
'backend' => true,
'menu' => 'content',
'sections' => array(
'chat' => array(
'name' => 'chatjs:chat',
'uri' => 'admin/chatjs'
)
)
);
}
public function install() {
/** To install the system we need to create the messages stream * */
$this->streams->streams->add_stream(
$this->st_name, $this->st_slug, $this->st_namespace, 'chatjs_'
);
/** Lets create some fields for the messages Stream * */
$fields = array(
array(
'name' => 'Message',
'slug' => 'message',
'namespace' => $this->st_namespace,
'type' => 'text',
'assign' => $this->st_slug,
'required' => true
),
array(
'name' => 'is Guest',
'slug' => 'is_gest',
'namespace' => $this->st_namespace,
'type' => 'text',
'assign' => $this->st_slug,
'required' => true
),
array(
'name' => 'Guest Name',
'slug' => 'guest_name',
'namespace' => $this->st_namespace,
'type' => 'text',
'assign' => $this->st_slug,
'required' => false
),
array(
'name' => 'datetime',
'slug' => 'chat_datetime',
'namespace' => $this->st_namespace,
'type' => 'text',
'assign' => $this->st_slug,
'required' => false
)
);
$this->streams->fields->add_fields($fields);
/** Now lets create a banned ips stream to be able to ban ips * */
$this->streams->streams->add_stream(
'banned_ips', 'banned_ips', $this->st_namespace, 'chatjs_'
);
/** now lets add some fields to the banned ip table * */
$fields_ip = array(
array(
'name' => 'IP',
'slug' => 'ip_chat',
'namespace' => $this->st_namespace,
'type' => 'text',
'assign' => 'banned_ips',
'required' => true
)
);
$this->streams->fields->add_fields($fields_ip);
/** Now lets create a banned users stream to be able to ban users **/
$this->streams->streams->add_stream(
'banned_users', 'banned_users', $this->st_namespace, 'chatjs_'
);
/** now lets add some fields to the banned user table * */
$fields_u = array(
array(
'name' => 'User',
'slug' => 'user_b',
'namespace' => $this->st_namespace,
'type' => 'user',
'assign' => 'banned_users',
'required' => true
)
);
$this->streams->fields->add_fields($fields_u);
/** now lets create the active users table **/
$this->streams->streams->add_stream(
'active_users', 'active_users', $this->st_namespace, 'chatjs_'
);
/** now lets add some fields to the active user table * */
$fields_u_a = array(
array(
'name' => 'User ID',
'slug' => 'user_id_c',
'namespace' => $this->st_namespace,
'type' => 'user',
'assign' => 'active_users',
'required' => true
),
array(
'name' => 'User IP',
'slug' => 'user_b_ip',
'namespace' => $this->st_namespace,
'type' => 'text',
'assign' => 'active_users',
'required' => true
),
array(
'name' => 'last_activity',
'slug' => 'last_activity_u_a',
'namespace' => $this->st_namespace,
'type' => 'text',
'assign' => 'active_users',
'required' => true
),
array(
'name' => 'user_nick_c',
'slug' => 'user_nick_c',
'namespace' => $this->st_namespace,
'type' => 'text',
'assign' => 'active_users',
'required' => false
)
);
$this->streams->fields->add_fields($fields_u_a);
return true;
}
public function uninstall() {
$this->streams->utilities->remove_namespace($this->st_namespace);
return true;
}
public function upgrade($old_version) {
return true;
}
public function help() {
return "Please see te website documentation";
}
}