forked from saggim/Tiny-Tiny-IRC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprefs.php
437 lines (335 loc) · 13.5 KB
/
prefs.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
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
<?php
set_include_path(get_include_path() . PATH_SEPARATOR .
dirname(__FILE__) ."/include");
require_once "functions.php";
function css_editor($link) {
$user_css = get_pref($link, "USER_STYLESHEET");
?>
<div class="modal-header">
<button type="button" onclick="close_infobox()" class="close">×</button>
<h3><?php echo __("Customize Theme") ?></h3>
</div>
<div class="modal-body">
<div class="alert" id="mini-notice" style='display : none'> </div>
<form class="form" id="prefs_css_form" onsubmit="return false;">
<input type="hidden" name="op" value="prefs-save-css"/>
<span class="muted"><?php echo T_sprintf("You can override colors, fonts and layout of your currently selected theme with custom CSS declarations here. <a target=\"_blank\" href=\"%s\">This file</a> can be used as a baseline.", "tt-irc.css") ?></span>
<textarea name="user_css" class="user-css"><?php echo $user_css ?></textarea>
</form>
</div>
<div class="modal-footer">
<button class="btn btn-primary" type="submit" onclick="save_css()"><?php echo __('Save & Reload') ?></button>
<button class="btn" type="submit" onclick="show_prefs()"><?php echo __('Go back') ?></button></div>
</div>
</div>
<?php
}
function print_servers($link, $id) {
$result = db_query($link, "SELECT ttirc_servers.*,
status,active_server
FROM ttirc_servers,ttirc_connections
WHERE connection_id = '$id' AND
connection_id = ttirc_connections.id AND
owner_uid = " . $_SESSION["uid"]);
$lnum = 1;
while ($line = db_fetch_assoc($result)) {
$id = $line['id'];
if ($line['status'] != CS_DISCONNECTED &&
$line['server'] . ':' . $line['port'] == $line['active_server']) {
$connected = __("(connected)");
} else {
$connected = '';
}
print "<li class='row' id='S-$id' server_id='$id'>";
print "<input style='margin-right : 1em' type='checkbox' onchange='select_row(this)'
row_id='S-$id'>";
print $line['server'] . ":" . $line['port'] . " $connected";
print "</li>";
++$lnum;
}
}
function notification_editor($link) {
$notify_on = json_decode(get_pref($link, "NOTIFY_ON"));
if (!is_array($notify_on)) $notify_on = array();
$nev_checked = array();
foreach ($notify_on as $no) {
$nev_checked[$no] = "checked";
}
?>
<div class="modal-header">
<button type="button" onclick="close_infobox()" class="close">×</button>
<h3><?php echo __("Notifications") ?></h3>
</div>
<div class="modal-body">
<div id="mini-notice" class="alert" style='display : none'> </div>
<span class="muted"><?php echo T_sprintf("Desktop notifications are only shown for events happening in background channels or when your Tiny Tiny IRC window is unfocused.") ?></span>
<form class="form form-horizontal" id="prefs_notify_form" onsubmit="return false;">
<input type="hidden" name="op" value="prefs-save-notify"/>
<div class="control-group">
<label class="control-label"><?php echo __('Notify events') ?></label>
<div class="controls">
<label class="checkbox" for="n_highlight"><?php echo __('Channel highlight') ?>
<input name="notify_event[]" <?php echo $nev_checked[1] ?>
id="n_highlight" type="checkbox" value="1">
</label>
<label class="checkbox" for="n_privmsg"><?php echo __('Private message') ?>
<input name="notify_event[]" <?php echo $nev_checked[2] ?>
id="n_privmsg" type="checkbox" value="2">
</label>
<label class="checkbox" for="n_connstat"><?php echo __('Connection status change') ?>
<input name="notify_event[]" <?php echo $nev_checked[3] ?>
id="n_connstat" type="checkbox" value="3">
</label>
<label class="checkbox" for="n_chanmsg"><?php echo __('Channel message') ?>
<input name="notify_event[]" <?php echo $nev_checked[4] ?>
id="n_chanmsg" type="checkbox" value="4">
</label>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<div style='float : left'>
<button class="btn" type="submit" onclick="notify_enable()"><?php echo __('Enable notifications') ?></button></div>
<button class="btn btn-primary" type="submit" onclick="save_notifications()"><?php echo __('Save') ?></button>
<button class="btn" type="submit" onclick="show_prefs()"><?php echo __('Go back') ?></button></div>
</div>
</div>
<?php
}
function connection_editor($link, $id) {
$result = db_query($link, "SELECT * FROM ttirc_connections
WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
$line = db_fetch_assoc($result);
if (sql_bool_to_bool($line['auto_connect'])) {
$auto_connect_checked = 'checked';
} else {
$auto_connect_checked = '';
}
if (sql_bool_to_bool($line['visible'])) {
$visible_checked = 'checked';
} else {
$visible_checked = '';
}
if (sql_bool_to_bool($line['permanent'])) {
$permanent_checked = 'checked';
} else {
$permanent_checked = '';
}
if (sql_bool_to_bool($line['use_ssl'])) {
$use_ssl_checked = 'checked';
} else {
$use_ssl_checked = '';
}
?>
<div class="modal-header">
<button type="button" onclick="close_infobox()" class="close">×</button>
<h3><?php echo __("Edit Connection") ?></h3>
</div>
<div class="modal-body">
<div class="alert" id="mini-notice" style='display : none'> </div>
<form class="form form-horizontal" id="prefs_conn_form" onsubmit="return false;">
<input type="hidden" name="connection_id" value="<?php echo $id ?>"/>
<input type="hidden" name="op" value="prefs-conn-save"/>
<div class="control-group">
<label class='control-label'><?php echo __('Title:') ?></label>
<div class="controls">
<input type="text" name="title" required="1" size="30" value="<?php echo $line['title'] ?>">
</div>
</div>
<div class="control-group">
<label class='control-label'><?php echo __('Server password:') ?></label>
<div class="controls">
<input type="text" name="server_password" size="30" type="password"
value="<?php echo $line['server_password'] ?>">
</div>
</div>
<div class="control-group">
<label class="control-label"><?php echo __('Nickname:') ?></label>
<div class="controls">
<input type="text" name="nick" size="30" value="<?php echo $line['nick'] ?>">
</div>
</div>
<div class="control-group">
<label class='control-label'><?php echo __('Favorite channels:') ?></label>
<div class="controls">
<input type="text" name="autojoin" size="30" value="<?php echo $line['autojoin'] ?>">
</div>
</div>
<div class="control-group">
<label class='control-label'><?php echo __('Connect command:') ?></label>
<div class="controls">
<input type="text" name="connect_cmd" size="30" value="<?php echo $line['connect_cmd'] ?>">
</div>
</div>
<div class="control-group">
<label class='control-label'><?php echo __('Character set:') ?></label>
<div class="controls">
<?php print_select('encoding', $line['encoding'], get_iconv_encodings()) ?>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox" for="pr_visible"><?php echo __('Enable connection') ?>
<input name="visible" <?php echo $visible_checked ?>
id="pr_visible" type="checkbox" value="1">
</label>
<label class="checkbox" for="pr_auto_connect"><?php echo __('Automatically connect') ?>
<input name="auto_connect" <?php echo $auto_connect_checked ?>
id="pr_auto_connect" type="checkbox" value="1">
</label>
<label class="checkbox" for="pr_permanent"><?php echo __('Stay connected permanently') ?>
<input name="permanent" <?php echo $permanent_checked ?>
id="pr_permanent" type="checkbox" value="1">
</label>
<label class="checkbox" for="pr_use_ssl"><?php echo __('Connect using SSL') ?>
<input name="use_ssl" <?php echo $use_ssl_checked ?>
id="pr_use_ssl" type="checkbox" value="1">
</label>
</div>
</div>
<button type="submit" style="display : none" onclick="save_conn()"></button>
<h5><?php echo __('Servers') ?></h5>
<ul id="servers-list" class="unstyled scrollable">
<?php print_servers($link, $id); ?>
</ul>
</form>
</div>
<div class="modal-footer">
<div style='float : left'>
<button class="btn" onclick="create_server()"><?php echo __('Add server') ?></button>
<button class="btn btn-danger" onclick="delete_server()"><?php echo __('Delete') ?></button>
</div>
<button class="btn btn-primary" type="submit" onclick="save_conn()"><?php echo __('Save') ?></button>
<button class="btn" type="submit" onclick="show_prefs()"><?php echo __('Go back') ?></button></div>
</div>
</div>
<?php
}
function print_connections($link) {
$result = db_query($link, "SELECT * FROM ttirc_connections
WHERE owner_uid = " . $_SESSION["uid"]);
$lnum = 1;
while ($line = db_fetch_assoc($result)) {
$id = $line['id'];
if ($line["status"] != "0") {
$connected = __("(active)");
} else {
$connected = "";
}
print "<li class='row' id='C-$id' connection_id='$id'>";
print "<input style=\"margin-right : 1em\" type='checkbox' onchange='select_row(this)'
row_id='C-$id'>";
print "<a href=\"#\" title=\"".__('Click to edit connection')."\"
onclick=\"edit_connection($id)\">".
$line['title']." $connected</a>";
print "</li>";
++$lnum;
}
}
function main_prefs($link) {
$_SESSION["prefs_cache"] = false;
$result = db_query($link, "SELECT * FROM ttirc_users WHERE
id = " . $_SESSION["uid"]);
$realname = db_fetch_result($result, 0, "realname");
$nick = db_fetch_result($result, 0, "nick");
$email = db_fetch_result($result, 0, "email");
$quit_message = db_fetch_result($result, 0, "quit_message");
if (sql_bool_to_bool(db_fetch_result($result, 0, "hide_join_part"))) {
$hide_join_part_checked = 'checked';
} else {
$hide_join_part_checked = '';
}
$highlight_on = get_pref($link, "HIGHLIGHT_ON");
$disable_image_preview_checked = get_pref($link, "DISABLE_IMAGE_PREVIEW") ? "checked" : "";
?>
<div class="modal-header">
<button type="button" onclick="close_infobox()" class="close">×</button>
<h3><?php echo __("Preferences") ?></h3></div>
<div class="modal-body">
<form class="form form-horizontal" id="prefs_form" onsubmit="return false;">
<div id="mini-notice" class="alert" style='display : none'> </div>
<input type="hidden" name="op" value="prefs-save"/>
<div class="control-group">
<label class="control-label"><?php echo __('Real name:') ?></label>
<div class="controls">
<input type="text" name="realname" required="1" size="30" value="<?php echo $realname ?>">
</div>
</div>
<div class="control-group">
<label class="control-label"><?php echo __('Nickname:') ?></label>
<div class="controls">
<input type="text" name="nick" required="1" size="30" value="<?php echo $nick ?>">
</div>
</div>
<div class="control-group">
<label class="control-label"><?php echo __('E-mail:') ?></label>
<div class="controls">
<input type="text" name="email" required="1" size="30" value="<?php echo $email ?>">
</div>
</div>
<div class="control-group">
<label class="control-label"><?php echo __('Quit message:') ?></label>
<div class="controls">
<input type="text" name="quit_message" size="30" value="<?php echo $quit_message ?>">
</div>
</div>
<div class="control-group">
<label class="control-label"><?php echo __('Highlight on:') ?></label>
<div class="controls">
<input type="text" name="highlight_on" size="30" value="<?php echo $highlight_on ?>">
</div>
</div>
<div class="control-group">
<label class="control-label"><?php echo __('Theme:') ?></label>
<div class="controls">
<?php print_theme_select($link); ?>
<a class="btn btn-info" href="#" onclick="customize_css()">
<?php echo __("Customize") ?></a>
</div>
</div>
<div class="control-group">
<div class="controls">
<a class="btn" href="#" onclick="configure_notifications()"><?php echo __('Configure desktop notifications') ?></a>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input name="hide_join_part" <?php echo $hide_join_part_checked ?>
id="pr_hide_join_part" type="checkbox" value="1">
<?php echo __('Do not highlight tabs on auxiliary messages') ?></label>
<label class="checkbox">
<input name="disable_image_preview" <?php echo $disable_image_preview_checked ?>
id="pr_disable_image_preview" type="checkbox" value="1">
<?php echo __('Disable inline image preview') ?></label>
</div>
</div>
<div class="control-group">
<label class="control-label"><?php echo __('Change password:') ?></label>
<div class="controls">
<input placeholder="<?php echo __("New password") ?>" type="text" name="new_password" type="password" size="30" value="">
</div>
</div>
<div class="control-group">
<label class="control-label"> </label>
<div class="controls">
<input placeholder="<?php echo __("Confirm password") ?>" type="text" name="confirm_password" type="password" size="30" value="">
</div>
</div>
<h5><?php echo __('Connections') ?></h5>
<ul class="scrollable unstyled" id="connections-list"><?php print_connections($link) ?></ul>
</form>
</div>
<div class="modal-footer">
<div style='float : left'>
<button class="btn" onclick="create_connection()">
<?php echo __('Create connection') ?></button class="btn">
<button class="btn btn-danger" onclick="delete_connection()">
<?php echo __('Delete') ?></button class="btn">
</div>
<button class="btn btn-primary" type="submit" onclick="save_prefs()">
<?php echo __('Save') ?></button class="btn">
<button class="btn" onclick="close_infobox()"><?php echo __('Close') ?></button>
</div>
<?php } ?>