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