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