]> git.wh0rd.org - tt-rss.git/blame - classes/pref/prefs.php
set otp field to autocomplete=off
[tt-rss.git] / classes / pref / prefs.php
CommitLineData
1395083e 1<?php
dfad9d7a 2
369dbc19 3class Pref_Prefs extends Handler_Protected {
1395083e 4
dfad9d7a
AD
5 private $pref_help = array();
6 private $pref_sections = array();
7
8484ce22 8 function csrf_ignore($method) {
9d76e754 9 $csrf_ignored = array("index", "updateself", "customizecss", "editprefprofiles");
8484ce22
AD
10
11 return array_search($method, $csrf_ignored) !== false;
12 }
13
dfad9d7a
AD
14 function __construct($link, $args) {
15 parent::__construct($link, $args);
16
17 $this->pref_sections = array(
18 1 => __('General'),
19 2 => __('Interface'),
20 3 => __('Advanced'),
21 4 => __('Digest')
22 );
23
24 $this->pref_help = array(
9db8e607 25 "ALLOW_DUPLICATE_POSTS" => array(__("Allow duplicate articles"), ""),
5f462963 26 "AUTO_ASSIGN_LABELS" => array(__("Assign articles to labels automatically"), ""),
9db8e607
AD
27 "BLACKLISTED_TAGS" => array(__("Blacklisted tags"), __("When auto-detecting tags in articles these tags will not be applied (comma-separated list).")),
28 "CDM_AUTO_CATCHUP" => array(__("Automatically mark articles as read"), __("This option enables marking articles as read automatically while you scroll article list.")),
5f462963 29 "CDM_EXPANDED" => array(__("Automatically expand articles in combined mode"), ""),
dfad9d7a 30 "COMBINED_DISPLAY_MODE" => array(__("Combined feed display"), __("Display expanded list of feed articles, instead of separate displays for headlines and article content")),
5f462963
AD
31 "CONFIRM_FEED_CATCHUP" => array(__("Confirm marking feed as read"), ""),
32 "DEFAULT_ARTICLE_LIMIT" => array(__("Amount of articles to display at once"), ""),
723bcdb2 33 "DEFAULT_UPDATE_INTERVAL" => array(__("Default feed update interval"), __("Shortest interval at which a feed will be checked for updates regardless of update method")),
5f462963 34 "DIGEST_CATCHUP" => array(__("Mark articles in e-mail digest as read"), ""),
9db8e607 35 "DIGEST_ENABLE" => array(__("Enable e-mail digest"), __("This option enables sending daily digest of new (and unread) headlines on your configured e-mail address")),
dfad9d7a 36 "DIGEST_PREFERRED_TIME" => array(__("Try to send digests around specified time"), __("Uses UTC timezone")),
9db8e607 37 "ENABLE_API_ACCESS" => array(__("Enable API access"), __("Allows external clients to access this account through the API")),
5f462963
AD
38 "ENABLE_FEED_CATS" => array(__("Enable feed categories"), ""),
39 "FEEDS_SORT_BY_UNREAD" => array(__("Sort feeds by unread articles count"), ""),
40 "FRESH_ARTICLE_MAX_AGE" => array(__("Maximum age of fresh articles (in hours)"), ""),
41 "HIDE_READ_FEEDS" => array(__("Hide feeds with no unread articles"), ""),
9db8e607 42 "HIDE_READ_SHOWS_SPECIAL" => array(__("Show special feeds when hiding read feeds"), ""),
5f462963 43 "LONG_DATE_FORMAT" => array(__("Long date format"), ""),
dfad9d7a 44 "ON_CATCHUP_SHOW_NEXT_FEED" => array(__("On catchup show next feed"), __("Automatically open next feed with unread articles after marking one as read")),
5f462963
AD
45 "PURGE_OLD_DAYS" => array(__("Purge articles after this number of days (0 - disables)"), ""),
46 "PURGE_UNREAD_ARTICLES" => array(__("Purge unread articles"), ""),
47 "REVERSE_HEADLINES" => array(__("Reverse headline order (oldest first)"), ""),
48 "SHORT_DATE_FORMAT" => array(__("Short date format"), ""),
49 "SHOW_CONTENT_PREVIEW" => array(__("Show content preview in headlines list"), ""),
dfad9d7a
AD
50 "SORT_HEADLINES_BY_FEED_DATE" => array(__("Sort headlines by feed date"), __("Use feed-specified date to sort headlines instead of local import date.")),
51 "SSL_CERT_SERIAL" => array(__("Login with an SSL certificate"), __("Click to register your SSL client certificate with tt-rss")),
5f462963 52 "STRIP_IMAGES" => array(__("Do not embed images in articles"), ""),
dfad9d7a 53 "STRIP_UNSAFE_TAGS" => array(__("Strip unsafe tags from articles"), __("Strip all but most common HTML tags when reading articles.")),
dfad9d7a 54 "USER_STYLESHEET" => array(__("Customize stylesheet"), __("Customize CSS stylesheet to your liking")),
5f462963 55 "USER_TIMEZONE" => array(__("User timezone"), ""),
8ef9645d
AD
56 "VFEED_GROUP_BY_FEED" => array(__("Group headlines in virtual feeds"), __("Special feeds, labels, and categories are grouped by originating feeds")),
57 "USER_CSS_THEME" => array(__("Select theme"), __("Select one of the available CSS themes"))
dfad9d7a
AD
58 );
59 }
60
1395083e
AD
61 function changepassword() {
62
63 $old_pw = $_POST["old_password"];
64 $new_pw = $_POST["new_password"];
65 $con_pw = $_POST["confirm_password"];
66
67 if ($old_pw == "") {
68 print "ERROR: ".__("Old password cannot be blank.");
69 return;
70 }
71
72 if ($new_pw == "") {
73 print "ERROR: ".__("New password cannot be blank.");
74 return;
75 }
76
77 if ($new_pw != $con_pw) {
78 print "ERROR: ".__("Entered passwords do not match.");
79 return;
80 }
81
0f28f81f
AD
82 global $pluginhost;
83 $authenticator = $pluginhost->get_plugin($_SESSION["auth_module"]);
1395083e 84
d5fd183d
AD
85 if (method_exists($authenticator, "change_password")) {
86 print $authenticator->change_password($_SESSION["uid"], $old_pw, $new_pw);
098df83b 87 } else {
d5fd183d 88 print "ERROR: ".__("Function not supported by authentication module.");
098df83b 89 }
1395083e
AD
90 }
91
92 function saveconfig() {
93
94 $_SESSION["prefs_cache"] = false;
95
451ff722
AD
96 $boolean_prefs = explode(",", $_POST["boolean_prefs"]);
97
98 foreach ($boolean_prefs as $pref) {
99 if (!isset($_POST[$pref])) $_POST[$pref] = 'false';
100 }
101
29c8fa08
AD
102 $need_reload = false;
103
1395083e
AD
104 foreach (array_keys($_POST) as $pref_name) {
105
3972bf59
AD
106 $pref_name = db_escape_string($this->link, $pref_name);
107 $value = db_escape_string($this->link, $_POST[$pref_name]);
1395083e 108
1b9b19af
AD
109 if ($pref_name == 'DIGEST_PREFERRED_TIME') {
110 if (get_pref($this->link, 'DIGEST_PREFERRED_TIME') != $value) {
111
112 db_query($this->link, "UPDATE ttrss_users SET
113 last_digest_sent = NULL WHERE id = " . $_SESSION['uid']);
114
115 }
116 }
117
29c8fa08
AD
118 if ($pref_name == "language") {
119 if ($_SESSION["language"] != $value) {
120 setcookie("ttrss_lang", $value,
121 time() + SESSION_COOKIE_LIFETIME);
122 $_SESSION["language"] = $value;
123
124 $need_reload = true;
125 }
126 } else {
127 set_pref($this->link, $pref_name, $value);
128 }
1395083e
AD
129
130 }
131
29c8fa08
AD
132 if ($need_reload) {
133 print "PREFS_NEED_RELOAD";
134 } else {
135 print __("The configuration was saved.");
136 }
1395083e
AD
137 }
138
139 function getHelp() {
140
3972bf59 141 $pref_name = db_escape_string($this->link, $_REQUEST["pn"]);
1395083e
AD
142
143 $result = db_query($this->link, "SELECT help_text FROM ttrss_prefs
144 WHERE pref_name = '$pref_name'");
145
146 if (db_num_rows($result) > 0) {
147 $help_text = db_fetch_result($result, 0, "help_text");
148 print $help_text;
149 } else {
150 printf(__("Unknown option: %s"), $pref_name);
151 }
152 }
153
154 function changeemail() {
155
3972bf59
AD
156 $email = db_escape_string($this->link, $_POST["email"]);
157 $full_name = db_escape_string($this->link, $_POST["full_name"]);
1395083e
AD
158
159 $active_uid = $_SESSION["uid"];
160
161 db_query($this->link, "UPDATE ttrss_users SET email = '$email',
162 full_name = '$full_name' WHERE id = '$active_uid'");
163
164 print __("Your personal data has been saved.");
165
166 return;
167 }
168
169 function resetconfig() {
170
171 $_SESSION["prefs_op_result"] = "reset-to-defaults";
172
173 if ($_SESSION["profile"]) {
174 $profile_qpart = "profile = '" . $_SESSION["profile"] . "'";
175 } else {
176 $profile_qpart = "profile IS NULL";
177 }
178
179 db_query($this->link, "DELETE FROM ttrss_user_prefs
180 WHERE $profile_qpart AND owner_uid = ".$_SESSION["uid"]);
181
182 initialize_user_prefs($this->link, $_SESSION["uid"], $_SESSION["profile"]);
bf878338
AD
183
184 echo __("Your preferences are now set to default values.");
1395083e
AD
185 }
186
187 function index() {
188
189 global $access_level_names;
190
8aa01d79 191 $prefs_blacklist = array("STRIP_UNSAFE_TAGS", "REVERSE_HEADLINES",
f17cac6b 192 "SORT_HEADLINES_BY_FEED_DATE", "DEFAULT_ARTICLE_LIMIT");
33b3db33
AD
193
194 /* "FEEDS_SORT_BY_UNREAD", "HIDE_READ_FEEDS", "REVERSE_HEADLINES" */
1395083e
AD
195
196 $profile_blacklist = array("ALLOW_DUPLICATE_POSTS", "PURGE_OLD_DAYS",
197 "PURGE_UNREAD_ARTICLES", "DIGEST_ENABLE", "DIGEST_CATCHUP",
198 "BLACKLISTED_TAGS", "ENABLE_API_ACCESS", "UPDATE_POST_ON_CHECKSUM_CHANGE",
199 "DEFAULT_UPDATE_INTERVAL", "USER_TIMEZONE", "SORT_HEADLINES_BY_FEED_DATE",
6d9455e9 200 "SSL_CERT_SERIAL", "DIGEST_PREFERRED_TIME");
1395083e
AD
201
202
d4c64ecc 203 $_SESSION["prefs_op_result"] = "";
1395083e 204
d4c64ecc
AD
205 print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">";
206 print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Personal data / Authentication')."\">";
1395083e 207
d4c64ecc 208 print "<form dojoType=\"dijit.form.Form\" id=\"changeUserdataForm\">";
1395083e 209
d4c64ecc
AD
210 print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
211 evt.preventDefault();
212 if (this.validate()) {
213 notify_progress('Saving data...', true);
1395083e 214
d4c64ecc
AD
215 new Ajax.Request('backend.php', {
216 parameters: dojo.objectToQuery(this.getValues()),
217 onComplete: function(transport) {
218 notify_callback2(transport);
219 } });
1395083e 220
d4c64ecc
AD
221 }
222 </script>";
1395083e 223
d4c64ecc 224 print "<table width=\"100%\" class=\"prefPrefsList\">";
1395083e 225
fb70f26e
AD
226 print "<h2>" . __("Personal data") . "</h2>";
227
228 $result = db_query($this->link, "SELECT email,full_name,otp_enabled,
d4c64ecc
AD
229 access_level FROM ttrss_users
230 WHERE id = ".$_SESSION["uid"]);
1395083e 231
d4c64ecc
AD
232 $email = htmlspecialchars(db_fetch_result($result, 0, "email"));
233 $full_name = htmlspecialchars(db_fetch_result($result, 0, "full_name"));
fb70f26e 234 $otp_enabled = sql_bool_to_bool(db_fetch_result($result, 0, "otp_enabled"));
1395083e 235
d4c64ecc
AD
236 print "<tr><td width=\"40%\">".__('Full name')."</td>";
237 print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" name=\"full_name\" required=\"1\"
238 value=\"$full_name\"></td></tr>";
1395083e 239
d4c64ecc
AD
240 print "<tr><td width=\"40%\">".__('E-mail')."</td>";
241 print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" name=\"email\" required=\"1\" value=\"$email\"></td></tr>";
1395083e 242
0d421af8 243 if (!SINGLE_USER_MODE && !$_SESSION["hide_hello"]) {
949b1a94 244
d4c64ecc
AD
245 $access_level = db_fetch_result($result, 0, "access_level");
246 print "<tr><td width=\"40%\">".__('Access level')."</td>";
247 print "<td>" . $access_level_names[$access_level] . "</td></tr>";
248 }
1395083e 249
d4c64ecc 250 print "</table>";
1395083e 251
d4c64ecc
AD
252 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
253 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"changeemail\">";
1395083e 254
d4c64ecc
AD
255 print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">".
256 __("Save data")."</button>";
1395083e 257
d4c64ecc 258 print "</form>";
1395083e 259
0f28f81f
AD
260 if ($_SESSION["auth_module"]) {
261 global $pluginhost;
262
263 $authenticator = $pluginhost->get_plugin($_SESSION["auth_module"]);
264
d5fd183d
AD
265 } else {
266 $authenticator = false;
267 }
268
269 if ($authenticator && method_exists($authenticator, "change_password")) {
1395083e 270
fb70f26e
AD
271 print "<h2>" . __("Password") . "</h2>";
272
1395083e
AD
273 $result = db_query($this->link, "SELECT id FROM ttrss_users
274 WHERE id = ".$_SESSION["uid"]." AND pwd_hash
275 = 'SHA1:5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8'");
276
277 if (db_num_rows($result) != 0) {
278 print format_warning(__("Your password is at default value, please change it."), "default_pass_warning");
279 }
280
281 print "<form dojoType=\"dijit.form.Form\">";
282
283 print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
284 evt.preventDefault();
285 if (this.validate()) {
286 notify_progress('Changing password...', true);
287
288 new Ajax.Request('backend.php', {
289 parameters: dojo.objectToQuery(this.getValues()),
290 onComplete: function(transport) {
291 notify('');
292 if (transport.responseText.indexOf('ERROR: ') == 0) {
293 notify_error(transport.responseText.replace('ERROR: ', ''));
294 } else {
295 notify_info(transport.responseText);
296 var warn = $('default_pass_warning');
297 if (warn) Element.hide(warn);
298 }
299 }});
300 this.reset();
301 }
302 </script>";
303
3ca8af7f 304 if ($otp_enabled) {
9a73994c 305 print_notice(__("Changing your current password will disable OTP."));
3ca8af7f
AD
306 }
307
1395083e
AD
308 print "<table width=\"100%\" class=\"prefPrefsList\">";
309
310 print "<tr><td width=\"40%\">".__("Old password")."</td>";
311 print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\" name=\"old_password\"></td></tr>";
312
313 print "<tr><td width=\"40%\">".__("New password")."</td>";
314
315 print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\"
316 name=\"new_password\"></td></tr>";
317
318 print "<tr><td width=\"40%\">".__("Confirm password")."</td>";
319
320 print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\" name=\"confirm_password\"></td></tr>";
321
322 print "</table>";
323
324 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
325 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"changepassword\">";
326
327 print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">".
328 __("Change password")."</button>";
329
330 print "</form>";
331
0f28f81f 332 if ($_SESSION["auth_module"] == "auth_internal") {
fb70f26e
AD
333
334 print "<h2>" . __("One time passwords / Authenticator") . "</h2>";
335
336 if ($otp_enabled) {
337
9a73994c 338 print_notice(__("One time passwords are currently enabled. Enter your current password below to disable."));
3ca8af7f
AD
339
340 print "<form dojoType=\"dijit.form.Form\">";
341
342 print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
343 evt.preventDefault();
344 if (this.validate()) {
345 notify_progress('Disabling OTP', true);
346
347 new Ajax.Request('backend.php', {
348 parameters: dojo.objectToQuery(this.getValues()),
349 onComplete: function(transport) {
350 notify('');
351 if (transport.responseText.indexOf('ERROR: ') == 0) {
352 notify_error(transport.responseText.replace('ERROR: ', ''));
353 } else {
354 window.location.reload();
355 }
356 }});
357 this.reset();
358 }
359 </script>";
360
361 print "<table width=\"100%\" class=\"prefPrefsList\">";
362
363 print "<tr><td width=\"40%\">".__("Enter your password")."</td>";
364
365 print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\"
366 name=\"password\"></td></tr>";
367
368 print "</table>";
369
370 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
371 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"otpdisable\">";
372
373 print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">".
374 __("Disable OTP")."</button>";
375
376 print "</form>";
fb70f26e
AD
377
378 } else {
379
380 print "<p>".__("You will need a compatible Authenticator to use this. Changing your password would automatically disable OTP.") . "</p>";
381
382 print "<p>".__("Scan the following code by the Authenticator application:")."</p>";
383
384 $csrf_token = $_SESSION["csrf_token"];
385
386 print "<img src=\"backend.php?op=pref-prefs&method=otpqrcode&csrf_token=$csrf_token\">";
387
388 print "<form dojoType=\"dijit.form.Form\" id=\"changeOtpForm\">";
389
390 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
3ca8af7f 391 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"otpenable\">";
fb70f26e
AD
392
393 print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
394 evt.preventDefault();
395 if (this.validate()) {
396 notify_progress('Saving data...', true);
397
398 new Ajax.Request('backend.php', {
399 parameters: dojo.objectToQuery(this.getValues()),
400 onComplete: function(transport) {
3ca8af7f
AD
401 notify('');
402 if (transport.responseText.indexOf('ERROR: ') == 0) {
403 notify_error(transport.responseText.replace('ERROR: ', ''));
404 } else {
405 window.location.reload();
406 }
fb70f26e
AD
407 } });
408
409 }
410 </script>";
411
3ca8af7f
AD
412 print "<table width=\"100%\" class=\"prefPrefsList\">";
413
414 print "<tr><td width=\"40%\">".__("Enter your password")."</td>";
415
416 print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\"
417 name=\"password\"></td></tr>";
418
419 print "<tr><td colspan=\"2\">";
420
fb70f26e
AD
421 print "<input dojoType=\"dijit.form.CheckBox\" required=\"1\"
422 type=\"checkbox\" id=\"enable_otp\" name=\"enable_otp\"/> ";
423 print "<label for=\"enable_otp\">".__("I have scanned the code and would like to enable OTP")."</label>";
424
3ca8af7f
AD
425 print "</td></tr><tr><td colspan=\"2\">";
426
427 print "</td></tr>";
428 print "</table>";
429
fb70f26e 430 print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">".
3ca8af7f 431 __("Enable OTP")."</button>";
fb70f26e
AD
432
433 print "</form>";
434
435 }
436
437 }
1395083e
AD
438 }
439
699daf58
AD
440 global $pluginhost;
441 $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB_SECTION,
442 "hook_prefs_tab_section", "prefPrefsAuth");
443
d4c64ecc
AD
444 print "</div>"; #pane
445
1395083e
AD
446 print "<div dojoType=\"dijit.layout.AccordionPane\" selected=\"true\" title=\"".__('Preferences')."\">";
447
448 print "<form dojoType=\"dijit.form.Form\" id=\"changeSettingsForm\">";
449
122e9d78
AD
450 print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt, quit\">
451 if (evt) evt.preventDefault();
1395083e
AD
452 if (this.validate()) {
453 console.log(dojo.objectToQuery(this.getValues()));
454
455 new Ajax.Request('backend.php', {
456 parameters: dojo.objectToQuery(this.getValues()),
457 onComplete: function(transport) {
458 var msg = transport.responseText;
29c8fa08
AD
459 if (quit) {
460 gotoMain();
461 } else {
462 if (msg == 'PREFS_NEED_RELOAD') {
463 window.location.reload();
464 } else {
465 notify_info(msg);
466 }
467 }
1395083e
AD
468 } });
469 }
470 </script>";
471
472 print '<div dojoType="dijit.layout.BorderContainer" gutters="false">';
473
474 print '<div dojoType="dijit.layout.ContentPane" region="center" style="overflow-y : auto">';
475
476 if ($_SESSION["profile"]) {
9a73994c 477 print_notice(__("Some preferences are only available in default profile."));
1395083e
AD
478 }
479
480 if ($_SESSION["profile"]) {
481 initialize_user_prefs($this->link, $_SESSION["uid"], $_SESSION["profile"]);
482 $profile_qpart = "profile = '" . $_SESSION["profile"] . "'";
483 } else {
484 initialize_user_prefs($this->link, $_SESSION["uid"]);
485 $profile_qpart = "profile IS NULL";
486 }
487
744a1b00 488 /* if ($_SESSION["prefs_show_advanced"])
f9ebb32c
AD
489 $access_query = "true";
490 else
744a1b00
AD
491 $access_query = "(access_level = 0 AND section_id != 3)"; */
492
493 $access_query = 'true';
f9ebb32c 494
ddb575c7 495 $result = db_query($this->link, "SELECT DISTINCT
dfad9d7a 496 ttrss_user_prefs.pref_name,value,type_name,
f9ebb32c 497 ttrss_prefs_sections.order_id,
dfad9d7a 498 def_value,section_id
1395083e
AD
499 FROM ttrss_prefs,ttrss_prefs_types,ttrss_prefs_sections,ttrss_user_prefs
500 WHERE type_id = ttrss_prefs_types.id AND
501 $profile_qpart AND
502 section_id = ttrss_prefs_sections.id AND
503 ttrss_user_prefs.pref_name = ttrss_prefs.pref_name AND
f9ebb32c 504 $access_query AND
1395083e 505 owner_uid = ".$_SESSION["uid"]."
dfad9d7a 506 ORDER BY ttrss_prefs_sections.order_id,pref_name");
1395083e
AD
507
508 $lnum = 0;
509
510 $active_section = "";
511
451ff722
AD
512 $listed_boolean_prefs = array();
513
1395083e
AD
514 while ($line = db_fetch_assoc($result)) {
515
516 if (in_array($line["pref_name"], $prefs_blacklist)) {
517 continue;
518 }
519
dfad9d7a
AD
520 $type_name = $line["type_name"];
521 $pref_name = $line["pref_name"];
522 $section_name = $this->getSectionName($line["section_id"]);
523 $value = $line["value"];
524
525 $short_desc = $this->getShortDesc($pref_name);
526 $help_text = $this->getHelpText($pref_name);
527
528 if (!$short_desc) continue;
529
1395083e
AD
530 if ($_SESSION["profile"] && in_array($line["pref_name"],
531 $profile_blacklist)) {
532 continue;
533 }
534
dfad9d7a 535 if ($active_section != $line["section_id"]) {
1395083e
AD
536
537 if ($active_section != "") {
538 print "</table>";
539 }
540
541 print "<table width=\"100%\" class=\"prefPrefsList\">";
542
dfad9d7a 543 $active_section = $line["section_id"];
1395083e 544
dfad9d7a 545 print "<tr><td colspan=\"3\"><h3>".$section_name."</h3></td></tr>";
1395083e 546
1395083e 547 $lnum = 0;
29c8fa08
AD
548
549 if ($active_section == 2) {
550 print "<tr>";
551
552 print "<td width=\"40%\" class=\"prefName\">";
553 print "<label>";
554 print __("Language:");
555 print "</label>";
556
557 print "<td>";
558 print_select_hash("language", $_COOKIE["ttrss_lang"], get_translations(),
559 "style='width : 220px; margin : 0px' dojoType='dijit.form.Select'");
560 print "</td>";
561 print "</tr>";
562 }
563
1395083e
AD
564 }
565
566 print "<tr>";
567
451ff722
AD
568 print "<td width=\"40%\" class=\"prefName\" id=\"$pref_name\">";
569 print "<label for='CB_$pref_name'>";
dfad9d7a 570 print $short_desc;
451ff722 571 print "</label>";
1395083e
AD
572
573 if ($help_text) print "<div class=\"prefHelp\">".__($help_text)."</div>";
574
575 print "</td>";
576
577 print "<td class=\"prefValue\">";
578
579 if ($pref_name == "USER_TIMEZONE") {
580
581 $timezones = explode("\n", file_get_contents("lib/timezones.txt"));
582
583 print_select($pref_name, $value, $timezones, 'dojoType="dijit.form.FilteringSelect"');
584 } else if ($pref_name == "USER_STYLESHEET") {
585
586 print "<button dojoType=\"dijit.form.Button\"
587 onclick=\"customizeCSS()\">" . __('Customize') . "</button>";
588
5d40efc9
AD
589 } else if ($pref_name == "USER_CSS_THEME") {
590
591 $themes = array_map("basename", glob("themes/*.css"));
592
593 print_select($pref_name, $value, $themes,
594 'dojoType="dijit.form.Select"');
595
596
1395083e
AD
597 } else if ($pref_name == "DEFAULT_UPDATE_INTERVAL") {
598
599 global $update_intervals_nodefault;
600
601 print_select_hash($pref_name, $value, $update_intervals_nodefault,
602 'dojoType="dijit.form.Select"');
603
604 } else if ($type_name == "bool") {
605
451ff722
AD
606 array_push($listed_boolean_prefs, $pref_name);
607
608 $checked = ($value == "true") ? "checked=\"checked\"" : "";
1395083e
AD
609
610 if ($pref_name == "PURGE_UNREAD_ARTICLES" && FORCE_ARTICLE_PURGE != 0) {
611 $disabled = "disabled=\"1\"";
451ff722 612 $checked = "checked=\"checked\"";
1395083e
AD
613 } else {
614 $disabled = "";
615 }
616
451ff722
AD
617 print "<input type='checkbox' name='$pref_name' $checked $disabled
618 dojoType='dijit.form.CheckBox' id='CB_$pref_name' value='1'>";
1395083e 619
f17cac6b 620 } else if (array_search($pref_name, array('FRESH_ARTICLE_MAX_AGE',
1395083e
AD
621 'PURGE_OLD_DAYS', 'LONG_DATE_FORMAT', 'SHORT_DATE_FORMAT')) !== false) {
622
623 $regexp = ($type_name == 'integer') ? 'regexp="^\d*$"' : '';
624
625 if ($pref_name == "PURGE_OLD_DAYS" && FORCE_ARTICLE_PURGE != 0) {
626 $disabled = "disabled=\"1\"";
627 $value = FORCE_ARTICLE_PURGE;
628 } else {
629 $disabled = "";
630 }
631
632 print "<input dojoType=\"dijit.form.ValidationTextBox\"
633 required=\"1\" $regexp $disabled
634 name=\"$pref_name\" value=\"$value\">";
635
636 } else if ($pref_name == "SSL_CERT_SERIAL") {
637
638 print "<input dojoType=\"dijit.form.ValidationTextBox\"
639 id=\"SSL_CERT_SERIAL\" readonly=\"1\"
640 name=\"$pref_name\" value=\"$value\">";
641
642 $cert_serial = htmlspecialchars(get_ssl_certificate_id());
643 $has_serial = ($cert_serial) ? "false" : "true";
644
645 print " <button dojoType=\"dijit.form.Button\" disabled=\"$has_serial\"
646 onclick=\"insertSSLserial('$cert_serial')\">" .
647 __('Register') . "</button>";
648
649 print " <button dojoType=\"dijit.form.Button\"
650 onclick=\"insertSSLserial('')\">" .
651 __('Clear') . "</button>";
652
76c843a9 653 } else if ($pref_name == 'DIGEST_PREFERRED_TIME') {
61c1812f 654 print "<input dojoType=\"dijit.form.ValidationTextBox\"
1b92f543 655 id=\"$pref_name\" regexp=\"[012]?\d:\d\d\" placeHolder=\"12:00\"
61c1812f 656 name=\"$pref_name\" value=\"$value\"><div class=\"insensitive\">".
8eba830f 657 T_sprintf("Current server time: %s (UTC)", date("H:i")) . "</div>";
1395083e
AD
658 } else {
659 $regexp = ($type_name == 'integer') ? 'regexp="^\d*$"' : '';
660
661 print "<input dojoType=\"dijit.form.ValidationTextBox\"
662 $regexp
663 name=\"$pref_name\" value=\"$value\">";
664 }
665
666 print "</td>";
667
668 print "</tr>";
669
670 $lnum++;
671 }
672
673 print "</table>";
674
451ff722
AD
675 $listed_boolean_prefs = htmlspecialchars(join(",", $listed_boolean_prefs));
676
677 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"boolean_prefs\" value=\"$listed_boolean_prefs\">";
678
699daf58
AD
679 global $pluginhost;
680 $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB_SECTION,
681 "hook_prefs_tab_section", "prefPrefsPrefsInside");
682
1395083e
AD
683 print '</div>'; # inside pane
684 print '<div dojoType="dijit.layout.ContentPane" region="bottom">';
685
686 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
687 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"saveconfig\">";
688
122e9d78
AD
689 print "<div dojoType=\"dijit.form.ComboButton\" type=\"submit\">
690 <span>".__('Save configuration')."</span>
691 <div dojoType=\"dijit.DropDownMenu\">
692 <div dojoType=\"dijit.MenuItem\"
693 onclick=\"dijit.byId('changeSettingsForm').onSubmit(null, true)\">".
694 __("Save and exit preferences")."</div>
695 </div>
696 </div>";
1395083e
AD
697
698 print "<button dojoType=\"dijit.form.Button\" onclick=\"return editProfiles()\">".
699 __('Manage profiles')."</button> ";
700
701 print "<button dojoType=\"dijit.form.Button\" onclick=\"return validatePrefsReset()\">".
702 __('Reset to defaults')."</button>";
703
f9ebb32c
AD
704 print "&nbsp;";
705
744a1b00 706 /* $checked = $_SESSION["prefs_show_advanced"] ? "checked='1'" : "";
f9ebb32c
AD
707
708 print "<input onclick='toggleAdvancedPrefs()'
709 id='prefs_show_advanced'
710 dojoType=\"dijit.form.CheckBox\"
711 $checked
712 type=\"checkbox\"></input>
713 <label for='prefs_show_advanced'>" .
744a1b00 714 __("Show additional preferences") . "</label>"; */
f9ebb32c 715
699daf58
AD
716 global $pluginhost;
717 $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB_SECTION,
718 "hook_prefs_tab_section", "prefPrefsPrefsOutside");
719
de612e7a 720 print "</form>";
1395083e
AD
721 print '</div>'; # inner pane
722 print '</div>'; # border container
de612e7a
AD
723
724 print "</div>"; #pane
725
4e53956a
AD
726 if ($_SESSION["access_level"] == 10) {
727
728 print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Error Log')."\">";
729 print "<h2>".__("Error Log")."</h2>";
730
731 $result = db_query($this->link, "SELECT errno, errstr, filename, lineno,
732 created_at, login FROM ttrss_error_log
733 LEFT JOIN ttrss_users ON (owner_uid = ttrss_users.id)
734 ORDER BY ttrss_error_log.id DESC
735 LIMIT 100");
736
737 print "<p><table width=\"100%\" cellspacing=\"10\" class=\"prefErrorLog\">";
738
739 print "<tr class=\"title\">
740 <td width='5%'>".__("Error")."</td>
741 <td>".__("Filename")."</td>
742 <td>".__("Message")."</td>
743 <td width='5%'>".__("User")."</td>
744 <td width='5%'>".__("Date")."</td>
745 </tr>";
746
747 while ($line = db_fetch_assoc($result)) {
748 print "<tr class=\"errrow\">";
749
750 foreach ($line as $k => $v) {
751 $line[$k] = htmlspecialchars($v);
752 }
753
754 print "<td class='errno'>" . Logger::$errornames[$line["errno"]] . " (" . $line["errno"] . ")</td>";
755 print "<td class='filename'>" . $line["filename"] . ":" . $line["lineno"] . "</td>";
756 print "<td class='errstr'>" . $line["errstr"] . "</td>";
757 print "<td class='login'>" . $line["login"] . "</td>";
758
759 print "<td class='timestamp'>" .
760 make_local_datetime($this->link,
761 $line["created_at"], false) . "</td>";
762
763 print "</tr>";
764 }
765
766 print "</table>";
767
768 print "</div>";
769 }
770
de612e7a
AD
771 print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Plugins')."\">";
772
773 print "<h2>".__("Plugins")."</h2>";
774
6deafe90 775 print "<p>" . __("You will need to reload Tiny Tiny RSS for plugin changes to take effect.") . "</p>";
65f85248 776
6deafe90 777 print_notice(__("Download more plugins at tt-rss.org <a class=\"visibleLink\" target=\"_blank\" href=\"http://tt-rss.org/forum/viewforum.php?f=22\">forums</a> or <a target=\"_blank\" class=\"visibleLink\" href=\"http://tt-rss.org/wiki/Plugins\">wiki</a>."));
de612e7a
AD
778
779 print "<form dojoType=\"dijit.form.Form\" id=\"changePluginsForm\">";
780
781 print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
782 evt.preventDefault();
783 if (this.validate()) {
784 notify_progress('Saving data...', true);
785
786 new Ajax.Request('backend.php', {
787 parameters: dojo.objectToQuery(this.getValues()),
788 onComplete: function(transport) {
789 notify('');
790 if (confirm(__('Selected plugins have been enabled. Reload?'))) {
791 window.location.reload();
792 }
793 } });
794
795 }
796 </script>";
797
798 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
799 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setplugins\">";
800
65d1e250 801 print "<table width='100%' class='prefPluginsList'>";
de612e7a
AD
802
803 print "<tr><td colspan='4'><h3>".__("System plugins")."</h3></td></tr>";
804
805 print "<tr class=\"title\">
806 <td width=\"5%\">&nbsp;</td>
807 <td width='10%'>".__('Plugin')."</td>
808 <td width=''>".__('Description')."</td>
809 <td width='5%'>".__('Version')."</td>
810 <td width='10%'>".__('Author')."</td></tr>";
811
812 $system_enabled = array_map("trim", explode(",", PLUGINS));
813 $user_enabled = array_map("trim", explode(",", get_pref($this->link, "_ENABLED_PLUGINS")));
814
5d9abb1e
AD
815 $tmppluginhost = new PluginHost($this->link);
816 $tmppluginhost->load_all($tmppluginhost::KIND_ALL, $_SESSION["uid"]);
817 $tmppluginhost->load_data(true);
de612e7a
AD
818
819 foreach ($tmppluginhost->get_plugins() as $name => $plugin) {
d2a421e3 820 $about = $plugin->about();
de612e7a 821
23be0bd3 822 if ($about[3] && strpos($name, "example") === FALSE) {
de612e7a
AD
823 if (in_array($name, $system_enabled)) {
824 $checked = "checked='1'";
825 } else {
826 $checked = "";
827 }
828
829 print "<tr>";
830
831 print "<td align='center'><input disabled='1'
832 dojoType=\"dijit.form.CheckBox\" $checked
833 type=\"checkbox\"></td>";
834
835 print "<td>$name</td>";
bb5e1a32
AD
836 print "<td>" . htmlspecialchars($about[1]);
837 if (@$about[4]) {
838 print " &mdash; <a target=\"_blank\" class=\"visibleLink\"
839 href=\"".htmlspecialchars($about[4])."\">".__("more info")."</a>";
840 }
841 print "</td>";
de612e7a
AD
842 print "<td>" . htmlspecialchars(sprintf("%.2f", $about[0])) . "</td>";
843 print "<td>" . htmlspecialchars($about[2]) . "</td>";
844
5d9abb1e 845 if (count($tmppluginhost->get_all($plugin)) > 0) {
81c54e3d
AD
846 if (in_array($name, $system_enabled)) {
847 print "<td><a href='#' onclick=\"clearPluginData('$name')\"
848 class='visibleLink'>".__("Clear data")."</a></td>";
849 }
5d9abb1e
AD
850 }
851
de612e7a
AD
852 print "</tr>";
853
854 }
855 }
856
857 print "<tr><td colspan='4'><h3>".__("User plugins")."</h3></td></tr>";
858
859 print "<tr class=\"title\">
860 <td width=\"5%\">&nbsp;</td>
861 <td width='10%'>".__('Plugin')."</td>
862 <td width=''>".__('Description')."</td>
863 <td width='5%'>".__('Version')."</td>
864 <td width='10%'>".__('Author')."</td></tr>";
865
866
867 foreach ($tmppluginhost->get_plugins() as $name => $plugin) {
d2a421e3 868 $about = $plugin->about();
de612e7a 869
23be0bd3 870 if (!$about[3] && strpos($name, "example") === FALSE) {
de612e7a
AD
871
872 if (in_array($name, $system_enabled)) {
873 $checked = "checked='1'";
874 $disabled = "disabled='1'";
65d1e250 875 $rowclass = '';
de612e7a
AD
876 } else if (in_array($name, $user_enabled)) {
877 $checked = "checked='1'";
878 $disabled = "";
65d1e250 879 $rowclass = "Selected";
de612e7a
AD
880 } else {
881 $checked = "";
882 $disabled = "";
65d1e250 883 $rowclass = '';
de612e7a
AD
884 }
885
65d1e250 886 print "<tr class='$rowclass'>";
de612e7a
AD
887
888 print "<td align='center'><input id='FPCHK-$name' name='plugins[]' value='$name' onclick='toggleSelectRow2(this);'
889 dojoType=\"dijit.form.CheckBox\" $checked $disabled
890 type=\"checkbox\"></td>";
891
65d1e250 892 print "<td><label for='FPCHK-$name'>$name</label></td>";
bb5e1a32
AD
893 print "<td><label for='FPCHK-$name'>" . htmlspecialchars($about[1]) . "</label>";
894 if (@$about[4]) {
895 print " &mdash; <a target=\"_blank\" class=\"visibleLink\"
896 href=\"".htmlspecialchars($about[4])."\">".__("more info")."</a>";
897 }
898 print "</td>";
899
de612e7a
AD
900 print "<td>" . htmlspecialchars(sprintf("%.2f", $about[0])) . "</td>";
901 print "<td>" . htmlspecialchars($about[2]) . "</td>";
902
5d9abb1e 903 if (count($tmppluginhost->get_all($plugin)) > 0) {
81c54e3d
AD
904 if (in_array($name, $system_enabled) || in_array($name, $user_enabled)) {
905 print "<td><a href='#' onclick=\"clearPluginData('$name')\" class='visibleLink'>".__("Clear data")."</a></td>";
906 }
5d9abb1e
AD
907 }
908
de612e7a
AD
909 print "</tr>";
910
911
912
913 }
914
915 }
916
917 print "</table>";
918
919 print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">".
920 __("Enable selected plugins")."</button></p>";
921
1395083e
AD
922 print "</form>";
923
924 print "</div>"; #pane
27211afe 925
6065f3ad
AD
926 global $pluginhost;
927 $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB,
928 "hook_prefs_tab", "prefPrefs");
929
1395083e
AD
930 print "</div>"; #container
931 }
27211afe 932
f9ebb32c
AD
933 function toggleAdvanced() {
934 $_SESSION["prefs_show_advanced"] = !$_SESSION["prefs_show_advanced"];
935 }
fb70f26e
AD
936
937 function otpqrcode() {
938 require_once "lib/otphp/vendor/base32.php";
939 require_once "lib/otphp/lib/otp.php";
940 require_once "lib/otphp/lib/totp.php";
941 require_once "lib/phpqrcode/phpqrcode.php";
942
973392b9 943 $result = db_query($this->link, "SELECT login,salt,otp_enabled
fb70f26e
AD
944 FROM ttrss_users
945 WHERE id = ".$_SESSION["uid"]);
946
947 $base32 = new Base32();
948
949 $login = db_fetch_result($result, 0, "login");
973392b9 950 $otp_enabled = sql_bool_to_bool(db_fetch_result($result, 0, "otp_enabled"));
fb70f26e 951
973392b9
AD
952 if (!$otp_enabled) {
953 $secret = $base32->encode(sha1(db_fetch_result($result, 0, "salt")));
954 $topt = new \OTPHP\TOTP($secret);
955 print QRcode::png($topt->provisioning_uri($login));
956 }
fb70f26e
AD
957 }
958
3ca8af7f 959 function otpenable() {
3972bf59 960 $password = db_escape_string($this->link, $_REQUEST["password"]);
3ca8af7f
AD
961 $enable_otp = $_REQUEST["enable_otp"] == "on";
962
0f28f81f
AD
963 global $pluginhost;
964 $authenticator = $pluginhost->get_plugin($_SESSION["auth_module"]);
965
3ca8af7f
AD
966 if ($authenticator->check_password($_SESSION["uid"], $password)) {
967
968 if ($enable_otp) {
969 db_query($this->link, "UPDATE ttrss_users SET otp_enabled = true WHERE
970 id = " . $_SESSION["uid"]);
971
972 print "OK";
973 }
974 } else {
975 print "ERROR: ".__("Incorrect password");
976 }
fb70f26e 977
3ca8af7f
AD
978 }
979
980 function otpdisable() {
3972bf59 981 $password = db_escape_string($this->link, $_REQUEST["password"]);
3ca8af7f 982
0f28f81f
AD
983 global $pluginhost;
984 $authenticator = $pluginhost->get_plugin($_SESSION["auth_module"]);
3ca8af7f
AD
985
986 if ($authenticator->check_password($_SESSION["uid"], $password)) {
987
988 db_query($this->link, "UPDATE ttrss_users SET otp_enabled = false WHERE
fb70f26e 989 id = " . $_SESSION["uid"]);
3ca8af7f
AD
990
991 print "OK";
992 } else {
993 print "ERROR: ".__("Incorrect password");
fb70f26e 994 }
3ca8af7f 995
fb70f26e 996 }
de612e7a
AD
997
998 function setplugins() {
f4c02a15
AD
999 if (is_array($_REQUEST["plugins"]))
1000 $plugins = join(",", $_REQUEST["plugins"]);
1001 else
1002 $plugins = "";
de612e7a
AD
1003
1004 set_pref($this->link, "_ENABLED_PLUGINS", $plugins);
1005 }
5d9abb1e
AD
1006
1007 function clearplugindata() {
3972bf59 1008 $name = db_escape_string($this->link, $_REQUEST["name"]);
5d9abb1e
AD
1009
1010 global $pluginhost;
1011 $pluginhost->clear_data($pluginhost->get_plugin($name));
1012 }
00e34741
AD
1013
1014 function customizeCSS() {
1015 $value = get_pref($this->link, "USER_STYLESHEET");
1016
1017 $value = str_replace("<br/>", "\n", $value);
1018
1019 print_notice(T_sprintf("You can override colors, fonts and layout of your currently selected theme with custom CSS declarations here. <a target=\"_blank\" class=\"visibleLink\" href=\"%s\">This file</a> can be used as a baseline.", "tt-rss.css"));
1020
1021 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
1022 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setpref\">";
1023 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"key\" value=\"USER_STYLESHEET\">";
1024
1025 print "<table width='100%'><tr><td>";
1026 print "<textarea dojoType=\"dijit.form.SimpleTextarea\"
1027 style='font-size : 12px; width : 100%; height: 200px;'
1028 placeHolder='body#ttrssMain { font-size : 14px; };'
1029 name='value'>$value</textarea>";
1030 print "</td></tr></table>";
1031
1032 print "<div class='dlgButtons'>";
1033 print "<button dojoType=\"dijit.form.Button\"
1034 onclick=\"dijit.byId('cssEditDlg').execute()\">".__('Save')."</button> ";
1035 print "<button dojoType=\"dijit.form.Button\"
1036 onclick=\"dijit.byId('cssEditDlg').hide()\">".__('Cancel')."</button>";
1037 print "</div>";
1038
1039 }
1040
9d76e754
AD
1041 function editPrefProfiles() {
1042 print "<div dojoType=\"dijit.Toolbar\">";
1043
1044 print "<div dojoType=\"dijit.form.DropDownButton\">".
1045 "<span>" . __('Select')."</span>";
1046 print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
1047 print "<div onclick=\"selectTableRows('prefFeedProfileList', 'all')\"
1048 dojoType=\"dijit.MenuItem\">".__('All')."</div>";
1049 print "<div onclick=\"selectTableRows('prefFeedProfileList', 'none')\"
1050 dojoType=\"dijit.MenuItem\">".__('None')."</div>";
1051 print "</div></div>";
1052
1053 print "<div style=\"float : right\">";
1054
1055 print "<input name=\"newprofile\" dojoType=\"dijit.form.ValidationTextBox\"
1056 required=\"1\">
1057 <button dojoType=\"dijit.form.Button\"
1058 onclick=\"dijit.byId('profileEditDlg').addProfile()\">".
1059 __('Create profile')."</button></div>";
1060
1061 print "</div>";
1062
1063 $result = db_query($this->link, "SELECT title,id FROM ttrss_settings_profiles
1064 WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
1065
1066 print "<div class=\"prefProfileHolder\">";
1067
1068 print "<form id=\"profile_edit_form\" onsubmit=\"return false\">";
1069
1070 print "<table width=\"100%\" class=\"prefFeedProfileList\"
1071 cellspacing=\"0\" id=\"prefFeedProfileList\">";
1072
1073 print "<tr class=\"placeholder\" id=\"FCATR-0\">"; #odd
1074
1075 print "<td width='5%' align='center'><input
1076 id='FCATC-0'
1077 onclick='toggleSelectRow2(this);'
1078 dojoType=\"dijit.form.CheckBox\"
1079 type=\"checkbox\"></td>";
1080
1081 if (!$_SESSION["profile"]) {
1082 $is_active = __("(active)");
1083 } else {
1084 $is_active = "";
1085 }
1086
1087 print "<td><span>" .
1088 __("Default profile") . " $is_active</span></td>";
1089
1090 print "</tr>";
1091
1092 $lnum = 1;
1093
1094 while ($line = db_fetch_assoc($result)) {
1095
1096 $class = ($lnum % 2) ? "even" : "odd";
1097
1098 $profile_id = $line["id"];
1099 $this_row_id = "id=\"FCATR-$profile_id\"";
1100
1101 print "<tr class=\"placeholder\" $this_row_id>";
1102
1103 $edit_title = htmlspecialchars($line["title"]);
1104
1105 print "<td width='5%' align='center'><input
1106 onclick='toggleSelectRow2(this);'
1107 id='FCATC-$profile_id'
1108 dojoType=\"dijit.form.CheckBox\"
1109 type=\"checkbox\"></td>";
1110
1111 if ($_SESSION["profile"] == $line["id"]) {
1112 $is_active = __("(active)");
1113 } else {
1114 $is_active = "";
1115 }
1116
1117 print "<td><span dojoType=\"dijit.InlineEditBox\"
1118 width=\"300px\" autoSave=\"false\"
1119 profile-id=\"$profile_id\">" . $edit_title .
1120 "<script type=\"dojo/method\" event=\"onChange\" args=\"item\">
1121 var elem = this;
1122 dojo.xhrPost({
1123 url: 'backend.php',
1124 content: {op: 'rpc', method: 'saveprofile',
1125 value: this.value,
1126 id: this.srcNodeRef.getAttribute('profile-id')},
1127 load: function(response) {
1128 elem.attr('value', response);
1129 }
1130 });
1131 </script>
1132 </span> $is_active</td>";
1133
1134 print "</tr>";
1135
1136 ++$lnum;
1137 }
1138
1139 print "</table>";
1140 print "</form>";
1141 print "</div>";
1142
1143 print "<div class='dlgButtons'>
1144 <div style='float : left'>
1145 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('profileEditDlg').removeSelected()\">".
1146 __('Remove selected profiles')."</button>
1147 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('profileEditDlg').activateProfile()\">".
1148 __('Activate profile')."</button>
1149 </div>";
1150
1151 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('profileEditDlg').hide()\">".
1152 __('Close this window')."</button>";
1153 print "</div>";
1154
1155 }
1156
dfad9d7a
AD
1157 private function getShortDesc($pref_name) {
1158 if (isset($this->pref_help[$pref_name])) {
1159 return $this->pref_help[$pref_name][0];
1160 }
1161 return "";
1162 }
9d76e754 1163
dfad9d7a
AD
1164 private function getHelpText($pref_name) {
1165 if (isset($this->pref_help[$pref_name])) {
1166 return $this->pref_help[$pref_name][1];
1167 }
1168 return "";
1169 }
1170
1171 private function getSectionName($id) {
1172 if (isset($this->pref_sections[$id])) {
1173 return $this->pref_sections[$id];
1174 }
1175
1176 return "";
1177 }
1395083e
AD
1178}
1179?>