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