prefs.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. <?php
  2. set_include_path(get_include_path() . PATH_SEPARATOR .
  3. dirname(__FILE__) ."/include");
  4. require_once "functions.php";
  5. function css_editor($link) {
  6. $user_css = get_pref($link, "USER_STYLESHEET");
  7. ?>
  8. <div class="modal-header">
  9. <button type="button" onclick="close_infobox()" class="close">&times;</button>
  10. <h3><?php echo __("Customize Theme") ?></h3>
  11. </div>
  12. <div class="modal-body">
  13. <div class="alert" id="mini-notice" style='display : none'>&nbsp;</div>
  14. <form class="form" id="prefs_css_form" onsubmit="return false;">
  15. <input type="hidden" name="op" value="prefs-save-css"/>
  16. <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>
  17. <textarea name="user_css" class="user-css"><?php echo $user_css ?></textarea>
  18. </form>
  19. </div>
  20. <div class="modal-footer">
  21. <button class="btn btn-primary" type="submit" onclick="save_css()"><?php echo __('Save & Reload') ?></button>
  22. <button class="btn" type="submit" onclick="show_prefs()"><?php echo __('Go back') ?></button></div>
  23. </div>
  24. </div>
  25. <?php
  26. }
  27. function print_servers($link, $id) {
  28. $result = db_query($link, "SELECT ttirc_servers.*,
  29. status,active_server
  30. FROM ttirc_servers,ttirc_connections
  31. WHERE connection_id = '$id' AND
  32. connection_id = ttirc_connections.id AND
  33. owner_uid = " . $_SESSION["uid"]);
  34. $lnum = 1;
  35. while ($line = db_fetch_assoc($result)) {
  36. $id = $line['id'];
  37. if ($line['status'] != CS_DISCONNECTED &&
  38. $line['server'] . ':' . $line['port'] == $line['active_server']) {
  39. $connected = __("(connected)");
  40. } else {
  41. $connected = '';
  42. }
  43. print "<li class='row' id='S-$id' server_id='$id'>";
  44. print "<input style='margin-right : 1em' type='checkbox' onchange='select_row(this)'
  45. row_id='S-$id'>";
  46. print $line['server'] . ":" . $line['port'] . " $connected";
  47. print "</li>";
  48. ++$lnum;
  49. }
  50. }
  51. function notification_editor($link) {
  52. $notify_on = json_decode(get_pref($link, "NOTIFY_ON"));
  53. if (!is_array($notify_on)) $notify_on = array();
  54. $nev_checked = array();
  55. foreach ($notify_on as $no) {
  56. $nev_checked[$no] = "checked";
  57. }
  58. ?>
  59. <div class="modal-header">
  60. <button type="button" onclick="close_infobox()" class="close">&times;</button>
  61. <h3><?php echo __("Notifications") ?></h3>
  62. </div>
  63. <div class="modal-body">
  64. <div id="mini-notice" class="alert" style='display : none'>&nbsp;</div>
  65. <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>
  66. <form class="form form-horizontal" id="prefs_notify_form" onsubmit="return false;">
  67. <input type="hidden" name="op" value="prefs-save-notify"/>
  68. <div class="control-group">
  69. <label class="control-label"><?php echo __('Notify events') ?></label>
  70. <div class="controls">
  71. <label class="checkbox" for="n_highlight"><?php echo __('Channel highlight') ?>
  72. <input name="notify_event[]" <?php echo $nev_checked[1] ?>
  73. id="n_highlight" type="checkbox" value="1">
  74. </label>
  75. <label class="checkbox" for="n_privmsg"><?php echo __('Private message') ?>
  76. <input name="notify_event[]" <?php echo $nev_checked[2] ?>
  77. id="n_privmsg" type="checkbox" value="2">
  78. </label>
  79. <label class="checkbox" for="n_connstat"><?php echo __('Connection status change') ?>
  80. <input name="notify_event[]" <?php echo $nev_checked[3] ?>
  81. id="n_connstat" type="checkbox" value="3">
  82. </label>
  83. <label class="checkbox" for="n_chanmsg"><?php echo __('Channel message') ?>
  84. <input name="notify_event[]" <?php echo $nev_checked[4] ?>
  85. id="n_chanmsg" type="checkbox" value="4">
  86. </label>
  87. </div>
  88. </div>
  89. </form>
  90. </div>
  91. <div class="modal-footer">
  92. <div style='float : left'>
  93. <button class="btn" type="submit" onclick="notify_enable()"><?php echo __('Enable notifications') ?></button></div>
  94. <button class="btn btn-primary" type="submit" onclick="save_notifications()"><?php echo __('Save') ?></button>
  95. <button class="btn" type="submit" onclick="show_prefs()"><?php echo __('Go back') ?></button></div>
  96. </div>
  97. </div>
  98. <?php
  99. }
  100. function connection_editor($link, $id) {
  101. $result = db_query($link, "SELECT * FROM ttirc_connections
  102. WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
  103. $line = db_fetch_assoc($result);
  104. if (sql_bool_to_bool($line['auto_connect'])) {
  105. $auto_connect_checked = 'checked';
  106. } else {
  107. $auto_connect_checked = '';
  108. }
  109. if (sql_bool_to_bool($line['visible'])) {
  110. $visible_checked = 'checked';
  111. } else {
  112. $visible_checked = '';
  113. }
  114. if (sql_bool_to_bool($line['permanent'])) {
  115. $permanent_checked = 'checked';
  116. } else {
  117. $permanent_checked = '';
  118. }
  119. if (sql_bool_to_bool($line['use_ssl'])) {
  120. $use_ssl_checked = 'checked';
  121. } else {
  122. $use_ssl_checked = '';
  123. }
  124. ?>
  125. <div class="modal-header">
  126. <button type="button" onclick="close_infobox()" class="close">&times;</button>
  127. <h3><?php echo __("Edit Connection") ?></h3>
  128. </div>
  129. <div class="modal-body">
  130. <div class="alert" id="mini-notice" style='display : none'>&nbsp;</div>
  131. <form class="form form-horizontal" id="prefs_conn_form" onsubmit="return false;">
  132. <input type="hidden" name="connection_id" value="<?php echo $id ?>"/>
  133. <input type="hidden" name="op" value="prefs-conn-save"/>
  134. <div class="control-group">
  135. <label class='control-label'><?php echo __('Title:') ?></label>
  136. <div class="controls">
  137. <input type="text" name="title" required="1" size="30" value="<?php echo $line['title'] ?>">
  138. </div>
  139. </div>
  140. <div class="control-group">
  141. <label class='control-label'><?php echo __('Server password:') ?></label>
  142. <div class="controls">
  143. <input type="text" name="server_password" size="30" type="password"
  144. value="<?php echo $line['server_password'] ?>">
  145. </div>
  146. </div>
  147. <div class="control-group">
  148. <label class="control-label"><?php echo __('Nickname:') ?></label>
  149. <div class="controls">
  150. <input type="text" name="nick" size="30" value="<?php echo $line['nick'] ?>">
  151. </div>
  152. </div>
  153. <div class="control-group">
  154. <label class='control-label'><?php echo __('Favorite channels:') ?></label>
  155. <div class="controls">
  156. <input type="text" name="autojoin" size="30" value="<?php echo $line['autojoin'] ?>">
  157. </div>
  158. </div>
  159. <div class="control-group">
  160. <label class='control-label'><?php echo __('Connect command:') ?></label>
  161. <div class="controls">
  162. <input type="text" name="connect_cmd" size="30" value="<?php echo $line['connect_cmd'] ?>">
  163. </div>
  164. </div>
  165. <div class="control-group">
  166. <label class='control-label'><?php echo __('Character set:') ?></label>
  167. <div class="controls">
  168. <?php print_select('encoding', $line['encoding'], get_iconv_encodings()) ?>
  169. </div>
  170. </div>
  171. <div class="control-group">
  172. <div class="controls">
  173. <label class="checkbox" for="pr_visible"><?php echo __('Enable connection') ?>
  174. <input name="visible" <?php echo $visible_checked ?>
  175. id="pr_visible" type="checkbox" value="1">
  176. </label>
  177. <label class="checkbox" for="pr_auto_connect"><?php echo __('Automatically connect') ?>
  178. <input name="auto_connect" <?php echo $auto_connect_checked ?>
  179. id="pr_auto_connect" type="checkbox" value="1">
  180. </label>
  181. <label class="checkbox" for="pr_permanent"><?php echo __('Stay connected permanently') ?>
  182. <input name="permanent" <?php echo $permanent_checked ?>
  183. id="pr_permanent" type="checkbox" value="1">
  184. </label>
  185. <label class="checkbox" for="pr_use_ssl"><?php echo __('Connect using SSL') ?>
  186. <input name="use_ssl" <?php echo $use_ssl_checked ?>
  187. id="pr_use_ssl" type="checkbox" value="1">
  188. </label>
  189. </div>
  190. </div>
  191. <button type="submit" style="display : none" onclick="save_conn()"></button>
  192. <h5><?php echo __('Servers') ?></h5>
  193. <ul id="servers-list" class="unstyled scrollable">
  194. <?php print_servers($link, $id); ?>
  195. </ul>
  196. </form>
  197. </div>
  198. <div class="modal-footer">
  199. <div style='float : left'>
  200. <button class="btn" onclick="create_server()"><?php echo __('Add server') ?></button>
  201. <button class="btn btn-danger" onclick="delete_server()"><?php echo __('Delete') ?></button>
  202. </div>
  203. <button class="btn btn-primary" type="submit" onclick="save_conn()"><?php echo __('Save') ?></button>
  204. <button class="btn" type="submit" onclick="show_prefs()"><?php echo __('Go back') ?></button></div>
  205. </div>
  206. </div>
  207. <?php
  208. }
  209. function print_connections($link) {
  210. $result = db_query($link, "SELECT * FROM ttirc_connections
  211. WHERE owner_uid = " . $_SESSION["uid"]);
  212. $lnum = 1;
  213. while ($line = db_fetch_assoc($result)) {
  214. $id = $line['id'];
  215. if ($line["status"] != "0") {
  216. $connected = __("(active)");
  217. } else {
  218. $connected = "";
  219. }
  220. print "<li class='row' id='C-$id' connection_id='$id'>";
  221. print "<input style=\"margin-right : 1em\" type='checkbox' onchange='select_row(this)'
  222. row_id='C-$id'>";
  223. print "<a href=\"#\" title=\"".__('Click to edit connection')."\"
  224. onclick=\"edit_connection($id)\">".
  225. $line['title']." $connected</a>";
  226. print "</li>";
  227. ++$lnum;
  228. }
  229. }
  230. function main_prefs($link) {
  231. $_SESSION["prefs_cache"] = false;
  232. $result = db_query($link, "SELECT * FROM ttirc_users WHERE
  233. id = " . $_SESSION["uid"]);
  234. $realname = db_fetch_result($result, 0, "realname");
  235. $nick = db_fetch_result($result, 0, "nick");
  236. $email = db_fetch_result($result, 0, "email");
  237. $quit_message = db_fetch_result($result, 0, "quit_message");
  238. if (sql_bool_to_bool(db_fetch_result($result, 0, "hide_join_part"))) {
  239. $hide_join_part_checked = 'checked';
  240. } else {
  241. $hide_join_part_checked = '';
  242. }
  243. $highlight_on = get_pref($link, "HIGHLIGHT_ON");
  244. $disable_image_preview_checked = get_pref($link, "DISABLE_IMAGE_PREVIEW") ? "checked" : "";
  245. ?>
  246. <div class="modal-header">
  247. <button type="button" onclick="close_infobox()" class="close">&times;</button>
  248. <h3><?php echo __("Preferences") ?></h3></div>
  249. <div class="modal-body">
  250. <form class="form form-horizontal" id="prefs_form" onsubmit="return false;">
  251. <div id="mini-notice" class="alert" style='display : none'>&nbsp;</div>
  252. <input type="hidden" name="op" value="prefs-save"/>
  253. <div class="control-group">
  254. <label class="control-label"><?php echo __('Real name:') ?></label>
  255. <div class="controls">
  256. <input type="text" name="realname" required="1" size="30" value="<?php echo $realname ?>">
  257. </div>
  258. </div>
  259. <div class="control-group">
  260. <label class="control-label"><?php echo __('Nickname:') ?></label>
  261. <div class="controls">
  262. <input type="text" name="nick" required="1" size="30" value="<?php echo $nick ?>">
  263. </div>
  264. </div>
  265. <div class="control-group">
  266. <label class="control-label"><?php echo __('E-mail:') ?></label>
  267. <div class="controls">
  268. <input type="text" name="email" required="1" size="30" value="<?php echo $email ?>">
  269. </div>
  270. </div>
  271. <div class="control-group">
  272. <label class="control-label"><?php echo __('Quit message:') ?></label>
  273. <div class="controls">
  274. <input type="text" name="quit_message" size="30" value="<?php echo $quit_message ?>">
  275. </div>
  276. </div>
  277. <div class="control-group">
  278. <label class="control-label"><?php echo __('Highlight on:') ?></label>
  279. <div class="controls">
  280. <input type="text" name="highlight_on" size="30" value="<?php echo $highlight_on ?>">
  281. </div>
  282. </div>
  283. <div class="control-group">
  284. <label class="control-label"><?php echo __('Theme:') ?></label>
  285. <div class="controls">
  286. <?php print_theme_select($link); ?>
  287. <a class="btn btn-info" href="#" onclick="customize_css()">
  288. <?php echo __("Customize") ?></a>
  289. </div>
  290. </div>
  291. <div class="control-group">
  292. <div class="controls">
  293. <a class="btn" href="#" onclick="configure_notifications()"><?php echo __('Configure desktop notifications') ?></a>
  294. </div>
  295. </div>
  296. <div class="control-group">
  297. <div class="controls">
  298. <label class="checkbox">
  299. <input name="hide_join_part" <?php echo $hide_join_part_checked ?>
  300. id="pr_hide_join_part" type="checkbox" value="1">
  301. <?php echo __('Do not highlight tabs on auxiliary messages') ?></label>
  302. <label class="checkbox">
  303. <input name="disable_image_preview" <?php echo $disable_image_preview_checked ?>
  304. id="pr_disable_image_preview" type="checkbox" value="1">
  305. <?php echo __('Disable inline image preview') ?></label>
  306. </div>
  307. </div>
  308. <div class="control-group">
  309. <label class="control-label"><?php echo __('Change password:') ?></label>
  310. <div class="controls">
  311. <input placeholder="<?php echo __("New password") ?>" type="text" name="new_password" type="password" size="30" value="">
  312. </div>
  313. </div>
  314. <div class="control-group">
  315. <label class="control-label"> </label>
  316. <div class="controls">
  317. <input placeholder="<?php echo __("Confirm password") ?>" type="text" name="confirm_password" type="password" size="30" value="">
  318. </div>
  319. </div>
  320. <h5><?php echo __('Connections') ?></h5>
  321. <ul class="scrollable unstyled" id="connections-list"><?php print_connections($link) ?></ul>
  322. </form>
  323. </div>
  324. <div class="modal-footer">
  325. <div style='float : left'>
  326. <button class="btn" onclick="create_connection()">
  327. <?php echo __('Create connection') ?></button class="btn">
  328. <button class="btn btn-danger" onclick="delete_connection()">
  329. <?php echo __('Delete') ?></button class="btn">
  330. </div>
  331. <button class="btn btn-primary" type="submit" onclick="save_prefs()">
  332. <?php echo __('Save') ?></button class="btn">
  333. <button class="btn" onclick="close_infobox()"><?php echo __('Close') ?></button>
  334. </div>
  335. <?php } ?>