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