]>
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 images 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 = $_POST["old_password"]; | |
64 | $new_pw = $_POST["new_password"]; | |
65 | $con_pw = $_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(",", $_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 | $pref_name = $pref_name; | |
103 | $value = $_POST[$pref_name]; | |
104 | ||
105 | if ($pref_name == 'DIGEST_PREFERRED_TIME') { | |
106 | if (get_pref('DIGEST_PREFERRED_TIME') != $value) { | |
107 | ||
108 | $sth = $this->pdo->prepare("UPDATE ttrss_users SET | |
109 | last_digest_sent = NULL WHERE id = ?"); | |
110 | $sth->execute([$_SESSION['uid']]); | |
111 | ||
112 | } | |
113 | } | |
114 | ||
115 | if ($pref_name == "USER_LANGUAGE") { | |
116 | if ($_SESSION["language"] != $value) { | |
117 | $need_reload = true; | |
118 | } | |
119 | } | |
120 | ||
121 | set_pref($pref_name, $value); | |
122 | } | |
123 | ||
124 | if ($need_reload) { | |
125 | print "PREFS_NEED_RELOAD"; | |
126 | } else { | |
127 | print __("The configuration was saved."); | |
128 | } | |
129 | } | |
130 | ||
131 | function changeemail() { | |
132 | ||
133 | $email = $_POST["email"]; | |
134 | $full_name = $_POST["full_name"]; | |
135 | $active_uid = $_SESSION["uid"]; | |
136 | ||
137 | $sth = $this->pdo->prepare("UPDATE ttrss_users SET email = ?, | |
138 | full_name = ? WHERE id = ?"); | |
139 | $sth->execute([$email, $full_name, $active_uid]); | |
140 | ||
141 | print __("Your personal data has been saved."); | |
142 | ||
143 | return; | |
144 | } | |
145 | ||
146 | function resetconfig() { | |
147 | ||
148 | $_SESSION["prefs_op_result"] = "reset-to-defaults"; | |
149 | ||
150 | $sth = $this->pdo->query("DELETE FROM ttrss_user_prefs | |
151 | WHERE (profile = :profile OR (:profile IS NULL AND profile IS NULL)) | |
152 | AND owner_uid = :uid"); | |
153 | $sth->execute([":profile" => $_SESSION['profile'], ":uid" => $_SESSION['uid']]); | |
154 | ||
155 | initialize_user_prefs($_SESSION["uid"], $_SESSION["profile"]); | |
156 | ||
157 | echo __("Your preferences are now set to default values."); | |
158 | } | |
159 | ||
160 | function index() { | |
161 | ||
162 | global $access_level_names; | |
163 | ||
164 | $prefs_blacklist = array("ALLOW_DUPLICATE_POSTS", "STRIP_UNSAFE_TAGS", "REVERSE_HEADLINES", | |
165 | "SORT_HEADLINES_BY_FEED_DATE", "DEFAULT_ARTICLE_LIMIT", | |
166 | "FEEDS_SORT_BY_UNREAD"); | |
167 | ||
168 | /* "FEEDS_SORT_BY_UNREAD", "HIDE_READ_FEEDS", "REVERSE_HEADLINES" */ | |
169 | ||
170 | $profile_blacklist = array("ALLOW_DUPLICATE_POSTS", "PURGE_OLD_DAYS", | |
171 | "PURGE_UNREAD_ARTICLES", "DIGEST_ENABLE", "DIGEST_CATCHUP", | |
172 | "BLACKLISTED_TAGS", "ENABLE_API_ACCESS", "UPDATE_POST_ON_CHECKSUM_CHANGE", | |
173 | "DEFAULT_UPDATE_INTERVAL", "USER_TIMEZONE", "SORT_HEADLINES_BY_FEED_DATE", | |
174 | "SSL_CERT_SERIAL", "DIGEST_PREFERRED_TIME"); | |
175 | ||
176 | ||
177 | $_SESSION["prefs_op_result"] = ""; | |
178 | ||
179 | print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">"; | |
180 | print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Personal data / Authentication')."\">"; | |
181 | ||
182 | print "<form dojoType=\"dijit.form.Form\" id=\"changeUserdataForm\">"; | |
183 | ||
184 | print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\"> | |
185 | evt.preventDefault(); | |
186 | if (this.validate()) { | |
187 | notify_progress('Saving data...', true); | |
188 | ||
189 | new Ajax.Request('backend.php', { | |
190 | parameters: dojo.objectToQuery(this.getValues()), | |
191 | onComplete: function(transport) { | |
192 | notify_callback2(transport); | |
193 | } }); | |
194 | ||
195 | } | |
196 | </script>"; | |
197 | ||
198 | print "<table width=\"100%\" class=\"prefPrefsList\">"; | |
199 | ||
200 | print "<h2>" . __("Personal data") . "</h2>"; | |
201 | ||
202 | $sth = $this->pdo->prepare("SELECT email,full_name,otp_enabled, | |
203 | access_level FROM ttrss_users | |
204 | WHERE id = ?"); | |
205 | $sth->execute([$_SESSION["uid"]]); | |
206 | $row = $sth->fetch(); | |
207 | ||
208 | $email = htmlspecialchars($row["email"]); | |
209 | $full_name = htmlspecialchars($row["full_name"]); | |
210 | $otp_enabled = sql_bool_to_bool($row["otp_enabled"]); | |
211 | ||
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>"; | |
215 | ||
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>"; | |
218 | ||
219 | if (!SINGLE_USER_MODE && !$_SESSION["hide_hello"]) { | |
220 | ||
221 | $access_level = $row["access_level"]; | |
222 | print "<tr><td width=\"40%\">".__('Access level')."</td>"; | |
223 | print "<td>" . $access_level_names[$access_level] . "</td></tr>"; | |
224 | } | |
225 | ||
226 | print "</table>"; | |
227 | ||
228 | print_hidden("op", "pref-prefs"); | |
229 | print_hidden("method", "changeemail"); | |
230 | ||
231 | print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">". | |
232 | __("Save data")."</button>"; | |
233 | ||
234 | print "</form>"; | |
235 | ||
236 | if ($_SESSION["auth_module"]) { | |
237 | $authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]); | |
238 | } else { | |
239 | $authenticator = false; | |
240 | } | |
241 | ||
242 | if ($authenticator && method_exists($authenticator, "change_password")) { | |
243 | ||
244 | print "<h2>" . __("Password") . "</h2>"; | |
245 | ||
246 | print "<div style='display : none' id='pwd_change_infobox'></div>"; | |
247 | ||
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) { | |
260 | ||
261 | $('pwd_change_infobox').innerHTML = | |
262 | transport.responseText.replace('ERROR: ', ''); | |
263 | ||
264 | } else { | |
265 | $('pwd_change_infobox').innerHTML = | |
266 | transport.responseText.replace('ERROR: ', ''); | |
267 | ||
268 | var warn = $('default_pass_warning'); | |
269 | if (warn) Element.hide(warn); | |
270 | } | |
271 | ||
272 | new Effect.Appear('pwd_change_infobox'); | |
273 | ||
274 | }}); | |
275 | this.reset(); | |
276 | } | |
277 | </script>"; | |
278 | ||
279 | if ($otp_enabled) { | |
280 | print_notice(__("Changing your current password will disable OTP.")); | |
281 | } | |
282 | ||
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 | ||
299 | print_hidden("op", "pref-prefs"); | |
300 | print_hidden("method", "changepassword"); | |
301 | ||
302 | print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">". | |
303 | __("Change password")."</button>"; | |
304 | ||
305 | print "</form>"; | |
306 | ||
307 | if ($_SESSION["auth_module"] == "auth_internal") { | |
308 | ||
309 | print "<h2>" . __("One time passwords / Authenticator") . "</h2>"; | |
310 | ||
311 | if ($otp_enabled) { | |
312 | ||
313 | print_notice(__("One time passwords are currently enabled. Enter your current password below to disable.")); | |
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 | ||
345 | print_hidden("op", "pref-prefs"); | |
346 | print_hidden("method", "otpdisable"); | |
347 | ||
348 | print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">". | |
349 | __("Disable OTP")."</button>"; | |
350 | ||
351 | print "</form>"; | |
352 | ||
353 | } else if (function_exists("imagecreatefromstring")) { | |
354 | ||
355 | print_warning(__("You will need a compatible Authenticator to use this. Changing your password would automatically disable OTP.")); | |
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 | ||
365 | print_hidden("op", "pref-prefs"); | |
366 | print_hidden("method", "otpenable"); | |
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) { | |
376 | notify(''); | |
377 | if (transport.responseText.indexOf('ERROR:') == 0) { | |
378 | notify_error(transport.responseText.replace('ERROR:', '')); | |
379 | } else { | |
380 | window.location.reload(); | |
381 | } | |
382 | } }); | |
383 | ||
384 | } | |
385 | </script>"; | |
386 | ||
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 | ||
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>"; | |
399 | ||
400 | print "<tr><td colspan=\"2\">"; | |
401 | ||
402 | print "</td></tr><tr><td colspan=\"2\">"; | |
403 | ||
404 | print "</td></tr>"; | |
405 | print "</table>"; | |
406 | ||
407 | print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">". | |
408 | __("Enable OTP")."</button>"; | |
409 | ||
410 | print "</form>"; | |
411 | ||
412 | } else { | |
413 | ||
414 | print_notice(__("PHP GD functions are required for OTP support.")); | |
415 | ||
416 | } | |
417 | ||
418 | } | |
419 | } | |
420 | ||
421 | PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, | |
422 | "hook_prefs_tab_section", "prefPrefsAuth"); | |
423 | ||
424 | print "</div>"; #pane | |
425 | ||
426 | print "<div dojoType=\"dijit.layout.AccordionPane\" selected=\"true\" title=\"".__('Preferences')."\">"; | |
427 | ||
428 | print "<form dojoType=\"dijit.form.Form\" id=\"changeSettingsForm\">"; | |
429 | ||
430 | print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt, quit\"> | |
431 | if (evt) evt.preventDefault(); | |
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; | |
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 | } | |
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"]) { | |
457 | print_notice(__("Some preferences are only available in default profile.")); | |
458 | } | |
459 | ||
460 | if ($_SESSION["profile"]) { | |
461 | initialize_user_prefs($_SESSION["uid"], $_SESSION["profile"]); | |
462 | } else { | |
463 | initialize_user_prefs($_SESSION["uid"]); | |
464 | } | |
465 | ||
466 | $sth = $this->pdo->prepare("SELECT DISTINCT | |
467 | ttrss_user_prefs.pref_name,value,type_name, | |
468 | ttrss_prefs_sections.order_id, | |
469 | def_value,section_id | |
470 | FROM ttrss_prefs,ttrss_prefs_types,ttrss_prefs_sections,ttrss_user_prefs | |
471 | WHERE type_id = ttrss_prefs_types.id AND | |
472 | (profile = :profile OR (:profile IS NULL AND profile IS NULL)) AND | |
473 | section_id = ttrss_prefs_sections.id AND | |
474 | ttrss_user_prefs.pref_name = ttrss_prefs.pref_name AND | |
475 | owner_uid = :uid | |
476 | ORDER BY ttrss_prefs_sections.order_id,pref_name"); | |
477 | $sth->execute([":uid" => $_SESSION['uid'], ":profile" => $_SESSION['profile']]); | |
478 | ||
479 | $lnum = 0; | |
480 | ||
481 | $active_section = ""; | |
482 | ||
483 | $listed_boolean_prefs = array(); | |
484 | ||
485 | while ($line = $sth->fetch()) { | |
486 | ||
487 | if (in_array($line["pref_name"], $prefs_blacklist)) { | |
488 | continue; | |
489 | } | |
490 | ||
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 | ||
501 | if ($_SESSION["profile"] && in_array($line["pref_name"], | |
502 | $profile_blacklist)) { | |
503 | continue; | |
504 | } | |
505 | ||
506 | if ($active_section != $line["section_id"]) { | |
507 | ||
508 | if ($active_section != "") { | |
509 | print "</table>"; | |
510 | } | |
511 | ||
512 | print "<table width=\"100%\" class=\"prefPrefsList\">"; | |
513 | ||
514 | $active_section = $line["section_id"]; | |
515 | ||
516 | print "<tr><td colspan=\"3\"><h3>".$section_name."</h3></td></tr>"; | |
517 | ||
518 | $lnum = 0; | |
519 | } | |
520 | ||
521 | print "<tr>"; | |
522 | ||
523 | print "<td width=\"40%\" class=\"prefName\" id=\"$pref_name\">"; | |
524 | print "<label for='CB_$pref_name'>"; | |
525 | print $short_desc; | |
526 | print "</label>"; | |
527 | ||
528 | if ($help_text) print "<div class=\"prefHelp\">".__($help_text)."</div>"; | |
529 | ||
530 | print "</td>"; | |
531 | ||
532 | print "<td class=\"prefValue\">"; | |
533 | ||
534 | if ($pref_name == "USER_LANGUAGE") { | |
535 | print_select_hash($pref_name, $value, get_translations(), | |
536 | "style='width : 220px; margin : 0px' dojoType='dijit.form.Select'"); | |
537 | ||
538 | } else if ($pref_name == "USER_TIMEZONE") { | |
539 | ||
540 | $timezones = explode("\n", file_get_contents("lib/timezones.txt")); | |
541 | ||
542 | print_select($pref_name, $value, $timezones, 'dojoType="dijit.form.FilteringSelect"'); | |
543 | } else if ($pref_name == "USER_STYLESHEET") { | |
544 | ||
545 | print "<button dojoType=\"dijit.form.Button\" | |
546 | onclick=\"customizeCSS()\">" . __('Customize') . "</button>"; | |
547 | ||
548 | } else if ($pref_name == "USER_CSS_THEME") { | |
549 | ||
550 | $themes = array_merge(glob("themes/*.php"), glob("themes/*.css"), glob("themes.local/*.css")); | |
551 | $themes = array_map("basename", $themes); | |
552 | $themes = array_filter($themes, "theme_valid"); | |
553 | asort($themes); | |
554 | ||
555 | if (!theme_valid($value)) $value = "default.php"; | |
556 | ||
557 | print_select($pref_name, $value, $themes, | |
558 | 'dojoType="dijit.form.Select"'); | |
559 | ||
560 | ||
561 | } else if ($pref_name == "DEFAULT_UPDATE_INTERVAL") { | |
562 | ||
563 | global $update_intervals_nodefault; | |
564 | ||
565 | print_select_hash($pref_name, $value, $update_intervals_nodefault, | |
566 | 'dojoType="dijit.form.Select"'); | |
567 | ||
568 | } else if ($type_name == "bool") { | |
569 | ||
570 | array_push($listed_boolean_prefs, $pref_name); | |
571 | ||
572 | $checked = ($value == "true") ? "checked=\"checked\"" : ""; | |
573 | ||
574 | if ($pref_name == "PURGE_UNREAD_ARTICLES" && FORCE_ARTICLE_PURGE != 0) { | |
575 | $disabled = "disabled=\"1\""; | |
576 | $checked = "checked=\"checked\""; | |
577 | } else { | |
578 | $disabled = ""; | |
579 | } | |
580 | ||
581 | print "<input type='checkbox' name='$pref_name' $checked $disabled | |
582 | dojoType='dijit.form.CheckBox' id='CB_$pref_name' value='1'>"; | |
583 | ||
584 | } else if (array_search($pref_name, array('FRESH_ARTICLE_MAX_AGE', | |
585 | 'PURGE_OLD_DAYS', 'LONG_DATE_FORMAT', 'SHORT_DATE_FORMAT')) !== false) { | |
586 | ||
587 | $regexp = ($type_name == 'integer') ? 'regexp="^\d*$"' : ''; | |
588 | ||
589 | if ($pref_name == "PURGE_OLD_DAYS" && FORCE_ARTICLE_PURGE != 0) { | |
590 | $disabled = "disabled=\"1\""; | |
591 | $value = FORCE_ARTICLE_PURGE; | |
592 | } else { | |
593 | $disabled = ""; | |
594 | } | |
595 | ||
596 | print "<input dojoType=\"dijit.form.ValidationTextBox\" | |
597 | required=\"1\" $regexp $disabled | |
598 | name=\"$pref_name\" value=\"$value\">"; | |
599 | ||
600 | } else if ($pref_name == "SSL_CERT_SERIAL") { | |
601 | ||
602 | print "<input dojoType=\"dijit.form.ValidationTextBox\" | |
603 | id=\"SSL_CERT_SERIAL\" readonly=\"1\" | |
604 | name=\"$pref_name\" value=\"$value\">"; | |
605 | ||
606 | $cert_serial = htmlspecialchars(get_ssl_certificate_id()); | |
607 | $has_serial = ($cert_serial) ? "false" : "true"; | |
608 | ||
609 | print "<br/>"; | |
610 | ||
611 | print " <button dojoType=\"dijit.form.Button\" disabled=\"$has_serial\" | |
612 | onclick=\"insertSSLserial('$cert_serial')\">" . | |
613 | __('Register') . "</button>"; | |
614 | ||
615 | print " <button dojoType=\"dijit.form.Button\" | |
616 | onclick=\"insertSSLserial('')\">" . | |
617 | __('Clear') . "</button>"; | |
618 | ||
619 | } else if ($pref_name == 'DIGEST_PREFERRED_TIME') { | |
620 | print "<input dojoType=\"dijit.form.ValidationTextBox\" | |
621 | id=\"$pref_name\" regexp=\"[012]?\d:\d\d\" placeHolder=\"12:00\" | |
622 | name=\"$pref_name\" value=\"$value\"><div class=\"insensitive\">". | |
623 | T_sprintf("Current server time: %s (UTC)", date("H:i")) . "</div>"; | |
624 | } else { | |
625 | $regexp = ($type_name == 'integer') ? 'regexp="^\d*$"' : ''; | |
626 | ||
627 | print "<input dojoType=\"dijit.form.ValidationTextBox\" | |
628 | $regexp | |
629 | name=\"$pref_name\" value=\"$value\">"; | |
630 | } | |
631 | ||
632 | print "</td>"; | |
633 | ||
634 | print "</tr>"; | |
635 | ||
636 | $lnum++; | |
637 | } | |
638 | ||
639 | print "</table>"; | |
640 | ||
641 | $listed_boolean_prefs = htmlspecialchars(join(",", $listed_boolean_prefs)); | |
642 | ||
643 | print_hidden("boolean_prefs", "$listed_boolean_prefs"); | |
644 | ||
645 | PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, | |
646 | "hook_prefs_tab_section", "prefPrefsPrefsInside"); | |
647 | ||
648 | print '</div>'; # inside pane | |
649 | print '<div dojoType="dijit.layout.ContentPane" region="bottom">'; | |
650 | ||
651 | print_hidden("op", "pref-prefs"); | |
652 | print_hidden("method", "saveconfig"); | |
653 | ||
654 | print "<div dojoType=\"dijit.form.ComboButton\" type=\"submit\"> | |
655 | <span>".__('Save configuration')."</span> | |
656 | <div dojoType=\"dijit.DropDownMenu\"> | |
657 | <div dojoType=\"dijit.MenuItem\" | |
658 | onclick=\"dijit.byId('changeSettingsForm').onSubmit(null, true)\">". | |
659 | __("Save and exit preferences")."</div> | |
660 | </div> | |
661 | </div>"; | |
662 | ||
663 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return editProfiles()\">". | |
664 | __('Manage profiles')."</button> "; | |
665 | ||
666 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return validatePrefsReset()\">". | |
667 | __('Reset to defaults')."</button>"; | |
668 | ||
669 | print " "; | |
670 | ||
671 | PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, | |
672 | "hook_prefs_tab_section", "prefPrefsPrefsOutside"); | |
673 | ||
674 | print "</form>"; | |
675 | print '</div>'; # inner pane | |
676 | print '</div>'; # border container | |
677 | ||
678 | print "</div>"; #pane | |
679 | ||
680 | print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Plugins')."\">"; | |
681 | ||
682 | print_notice(__("You will need to reload Tiny Tiny RSS for plugin changes to take effect.")); | |
683 | ||
684 | if (ini_get("open_basedir") && function_exists("curl_init") && !defined("NO_CURL")) { | |
685 | print_warning("Your PHP configuration has open_basedir restrictions enabled. Some plugins relying on CURL for functionality may not work correctly."); | |
686 | } | |
687 | ||
688 | print "<form dojoType=\"dijit.form.Form\" id=\"changePluginsForm\">"; | |
689 | ||
690 | print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\"> | |
691 | evt.preventDefault(); | |
692 | if (this.validate()) { | |
693 | notify_progress('Saving data...', true); | |
694 | ||
695 | new Ajax.Request('backend.php', { | |
696 | parameters: dojo.objectToQuery(this.getValues()), | |
697 | onComplete: function(transport) { | |
698 | notify(''); | |
699 | if (confirm(__('Selected plugins have been enabled. Reload?'))) { | |
700 | window.location.reload(); | |
701 | } | |
702 | } }); | |
703 | ||
704 | } | |
705 | </script>"; | |
706 | ||
707 | print_hidden("op", "pref-prefs"); | |
708 | print_hidden("method", "setplugins"); | |
709 | ||
710 | print "<table width='100%' class='prefPluginsList'>"; | |
711 | ||
712 | print "<tr><td colspan='5'><h3>".__("System plugins")."</h3>". | |
713 | format_notice(__("System plugins are enabled in <strong>config.php</strong> for all users.")). | |
714 | "</td></tr>"; | |
715 | ||
716 | print "<tr class=\"title\"> | |
717 | <td width=\"5%\"> </td> | |
718 | <td width='10%'>".__('Plugin')."</td> | |
719 | <td width=''>".__('Description')."</td> | |
720 | <td width='5%'>".__('Version')."</td> | |
721 | <td width='10%'>".__('Author')."</td></tr>"; | |
722 | ||
723 | $system_enabled = array_map("trim", explode(",", PLUGINS)); | |
724 | $user_enabled = array_map("trim", explode(",", get_pref("_ENABLED_PLUGINS", $_SESSION['uid']))); | |
725 | ||
726 | $tmppluginhost = new PluginHost(); | |
727 | $tmppluginhost->load_all($tmppluginhost::KIND_ALL, $_SESSION["uid"], true); | |
728 | $tmppluginhost->load_data(true); | |
729 | ||
730 | foreach ($tmppluginhost->get_plugins() as $name => $plugin) { | |
731 | $about = $plugin->about(); | |
732 | ||
733 | if ($about[3]) { | |
734 | if (in_array($name, $system_enabled)) { | |
735 | $checked = "checked='1'"; | |
736 | } else { | |
737 | $checked = ""; | |
738 | } | |
739 | ||
740 | print "<tr>"; | |
741 | ||
742 | print "<td align='center'><input disabled='1' | |
743 | dojoType=\"dijit.form.CheckBox\" $checked | |
744 | type=\"checkbox\"></td>"; | |
745 | ||
746 | $plugin_icon = $checked ? "plugin.png" : "plugin_disabled.png"; | |
747 | ||
748 | print "<td><label><img src='images/$plugin_icon' alt=''> $name</label></td>"; | |
749 | print "<td>" . htmlspecialchars($about[1]); | |
750 | if (@$about[4]) { | |
751 | print " — <a target=\"_blank\" rel=\"noopener noreferrer\" class=\"visibleLink\" | |
752 | href=\"".htmlspecialchars($about[4])."\">".__("more info")."</a>"; | |
753 | } | |
754 | print "</td>"; | |
755 | print "<td>" . htmlspecialchars(sprintf("%.2f", $about[0])) . "</td>"; | |
756 | print "<td>" . htmlspecialchars($about[2]) . "</td>"; | |
757 | ||
758 | if (count($tmppluginhost->get_all($plugin)) > 0) { | |
759 | if (in_array($name, $system_enabled)) { | |
760 | print "<td><a href='#' onclick=\"clearPluginData('$name')\" | |
761 | class='visibleLink'>".__("Clear data")."</a></td>"; | |
762 | } | |
763 | } | |
764 | ||
765 | print "</tr>"; | |
766 | ||
767 | } | |
768 | } | |
769 | ||
770 | print "<tr><td colspan='4'><h3>".__("User plugins")."</h3></td></tr>"; | |
771 | ||
772 | print "<tr class=\"title\"> | |
773 | <td width=\"5%\"> </td> | |
774 | <td width='10%'>".__('Plugin')."</td> | |
775 | <td width=''>".__('Description')."</td> | |
776 | <td width='5%'>".__('Version')."</td> | |
777 | <td width='10%'>".__('Author')."</td></tr>"; | |
778 | ||
779 | ||
780 | foreach ($tmppluginhost->get_plugins() as $name => $plugin) { | |
781 | $about = $plugin->about(); | |
782 | ||
783 | if (!$about[3]) { | |
784 | ||
785 | if (in_array($name, $system_enabled)) { | |
786 | $checked = "checked='1'"; | |
787 | $disabled = "disabled='1'"; | |
788 | $rowclass = ''; | |
789 | } else if (in_array($name, $user_enabled)) { | |
790 | $checked = "checked='1'"; | |
791 | $disabled = ""; | |
792 | $rowclass = "Selected"; | |
793 | } else { | |
794 | $checked = ""; | |
795 | $disabled = ""; | |
796 | $rowclass = ''; | |
797 | } | |
798 | ||
799 | print "<tr class='$rowclass'>"; | |
800 | ||
801 | $plugin_icon = $checked ? "plugin.png" : "plugin_disabled.png"; | |
802 | ||
803 | print "<td align='center'><input id='FPCHK-$name' name='plugins[]' value='$name' onclick='toggleSelectRow2(this);' | |
804 | dojoType=\"dijit.form.CheckBox\" $checked $disabled | |
805 | type=\"checkbox\"></td>"; | |
806 | ||
807 | print "<td><label for='FPCHK-$name'><img src='images/$plugin_icon' alt=''> $name</label></td>"; | |
808 | print "<td><label for='FPCHK-$name'>" . htmlspecialchars($about[1]) . "</label>"; | |
809 | if (@$about[4]) { | |
810 | print " — <a target=\"_blank\" rel=\"noopener noreferrer\" class=\"visibleLink\" | |
811 | href=\"".htmlspecialchars($about[4])."\">".__("more info")."</a>"; | |
812 | } | |
813 | print "</td>"; | |
814 | ||
815 | print "<td>" . htmlspecialchars(sprintf("%.2f", $about[0])) . "</td>"; | |
816 | print "<td>" . htmlspecialchars($about[2]) . "</td>"; | |
817 | ||
818 | if (count($tmppluginhost->get_all($plugin)) > 0) { | |
819 | if (in_array($name, $system_enabled) || in_array($name, $user_enabled)) { | |
820 | print "<td><a href='#' onclick=\"clearPluginData('$name')\" class='visibleLink'>".__("Clear data")."</a></td>"; | |
821 | } | |
822 | } | |
823 | ||
824 | print "</tr>"; | |
825 | ||
826 | ||
827 | ||
828 | } | |
829 | ||
830 | } | |
831 | ||
832 | print "</table>"; | |
833 | ||
834 | print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">". | |
835 | __("Enable selected plugins")."</button></p>"; | |
836 | ||
837 | print "</form>"; | |
838 | ||
839 | print "</div>"; #pane | |
840 | ||
841 | PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, | |
842 | "hook_prefs_tab", "prefPrefs"); | |
843 | ||
844 | print "</div>"; #container | |
845 | } | |
846 | ||
847 | function toggleAdvanced() { | |
848 | $_SESSION["prefs_show_advanced"] = !$_SESSION["prefs_show_advanced"]; | |
849 | } | |
850 | ||
851 | function otpqrcode() { | |
852 | require_once "lib/otphp/vendor/base32.php"; | |
853 | require_once "lib/otphp/lib/otp.php"; | |
854 | require_once "lib/otphp/lib/totp.php"; | |
855 | require_once "lib/phpqrcode/phpqrcode.php"; | |
856 | ||
857 | $sth = $this->pdo->prepare("SELECT login,salt,otp_enabled | |
858 | FROM ttrss_users | |
859 | WHERE id = ?"); | |
860 | $sth->execute([$_SESSION['uid']]); | |
861 | ||
862 | if ($row = $sth->fetch()) { | |
863 | ||
864 | $base32 = new Base32(); | |
865 | ||
866 | $login = $row["login"]; | |
867 | $otp_enabled = sql_bool_to_bool($row["otp_enabled"]); | |
868 | ||
869 | if (!$otp_enabled) { | |
870 | $secret = $base32->encode(sha1($row["salt"])); | |
871 | ||
872 | QRcode::png("otpauth://totp/".urlencode($login). | |
873 | "?secret=$secret&issuer=".urlencode("Tiny Tiny RSS")); | |
874 | ||
875 | } | |
876 | } | |
877 | } | |
878 | ||
879 | function otpenable() { | |
880 | require_once "lib/otphp/vendor/base32.php"; | |
881 | require_once "lib/otphp/lib/otp.php"; | |
882 | require_once "lib/otphp/lib/totp.php"; | |
883 | ||
884 | $password = $_REQUEST["password"]; | |
885 | $otp = $_REQUEST["otp"]; | |
886 | ||
887 | $authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]); | |
888 | ||
889 | if ($authenticator->check_password($_SESSION["uid"], $password)) { | |
890 | ||
891 | $sth = $this->pdo->query("SELECT salt | |
892 | FROM ttrss_users | |
893 | WHERE id = ?"); | |
894 | $sth->execute([$_SESSION['uid']]); | |
895 | ||
896 | if ($row = $sth->fetch()) { | |
897 | ||
898 | $base32 = new Base32(); | |
899 | ||
900 | $secret = $base32->encode(sha1($row["salt"])); | |
901 | $topt = new \OTPHP\TOTP($secret); | |
902 | ||
903 | $otp_check = $topt->now(); | |
904 | ||
905 | if ($otp == $otp_check) { | |
906 | $sth = $this->pdo->prepare("UPDATE ttrss_users | |
907 | SET otp_enabled = true WHERE id = ?"); | |
908 | ||
909 | $sth->execute([$_SESSION['uid']]); | |
910 | ||
911 | print "OK"; | |
912 | } else { | |
913 | print "ERROR:".__("Incorrect one time password"); | |
914 | } | |
915 | } | |
916 | ||
917 | } else { | |
918 | print "ERROR:".__("Incorrect password"); | |
919 | } | |
920 | ||
921 | } | |
922 | ||
923 | function otpdisable() { | |
924 | $password = $_REQUEST["password"]; | |
925 | ||
926 | $authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]); | |
927 | ||
928 | if ($authenticator->check_password($_SESSION["uid"], $password)) { | |
929 | ||
930 | $sth = $this->pdo->prepare("UPDATE ttrss_users SET otp_enabled = false WHERE | |
931 | id = ?"); | |
932 | $sth->execute([$_SESSION['uid']]); | |
933 | ||
934 | print "OK"; | |
935 | } else { | |
936 | print "ERROR: ".__("Incorrect password"); | |
937 | } | |
938 | ||
939 | } | |
940 | ||
941 | function setplugins() { | |
942 | if (is_array($_REQUEST["plugins"])) | |
943 | $plugins = join(",", $_REQUEST["plugins"]); | |
944 | else | |
945 | $plugins = ""; | |
946 | ||
947 | set_pref("_ENABLED_PLUGINS", $plugins, $_SESSION["uid"]); | |
948 | } | |
949 | ||
950 | function clearplugindata() { | |
951 | $name = $_REQUEST["name"]; | |
952 | ||
953 | PluginHost::getInstance()->clear_data(PluginHost::getInstance()->get_plugin($name)); | |
954 | } | |
955 | ||
956 | function customizeCSS() { | |
957 | $value = get_pref("USER_STYLESHEET"); | |
958 | ||
959 | $value = str_replace("<br/>", "\n", $value); | |
960 | ||
961 | 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")); | |
962 | ||
963 | print_hidden("op", "rpc"); | |
964 | print_hidden("method", "setpref"); | |
965 | print_hidden("key", "USER_STYLESHEET"); | |
966 | ||
967 | print "<table width='100%'><tr><td>"; | |
968 | print "<textarea dojoType=\"dijit.form.SimpleTextarea\" | |
969 | style='font-size : 12px; width : 98%; height: 200px;' | |
970 | placeHolder='body#ttrssMain { font-size : 14px; };' | |
971 | name='value'>$value</textarea>"; | |
972 | print "</td></tr></table>"; | |
973 | ||
974 | print "<div class='dlgButtons'>"; | |
975 | print "<button dojoType=\"dijit.form.Button\" | |
976 | onclick=\"dijit.byId('cssEditDlg').execute()\">".__('Save')."</button> "; | |
977 | print "<button dojoType=\"dijit.form.Button\" | |
978 | onclick=\"dijit.byId('cssEditDlg').hide()\">".__('Cancel')."</button>"; | |
979 | print "</div>"; | |
980 | ||
981 | } | |
982 | ||
983 | function editPrefProfiles() { | |
984 | print "<div dojoType=\"dijit.Toolbar\">"; | |
985 | ||
986 | print "<div dojoType=\"dijit.form.DropDownButton\">". | |
987 | "<span>" . __('Select')."</span>"; | |
988 | print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; | |
989 | print "<div onclick=\"selectTableRows('prefFeedProfileList', 'all')\" | |
990 | dojoType=\"dijit.MenuItem\">".__('All')."</div>"; | |
991 | print "<div onclick=\"selectTableRows('prefFeedProfileList', 'none')\" | |
992 | dojoType=\"dijit.MenuItem\">".__('None')."</div>"; | |
993 | print "</div></div>"; | |
994 | ||
995 | print "<div style=\"float : right\">"; | |
996 | ||
997 | print "<input name=\"newprofile\" dojoType=\"dijit.form.ValidationTextBox\" | |
998 | required=\"1\"> | |
999 | <button dojoType=\"dijit.form.Button\" | |
1000 | onclick=\"dijit.byId('profileEditDlg').addProfile()\">". | |
1001 | __('Create profile')."</button></div>"; | |
1002 | ||
1003 | print "</div>"; | |
1004 | ||
1005 | $sth = $this->pdo->prepare("SELECT title,id FROM ttrss_settings_profiles | |
1006 | WHERE owner_uid = ? ORDER BY title"); | |
1007 | $sth->execute([$_SESSION['uid']]); | |
1008 | ||
1009 | print "<div class=\"prefProfileHolder\">"; | |
1010 | ||
1011 | print "<form id=\"profile_edit_form\" onsubmit=\"return false\">"; | |
1012 | ||
1013 | print "<table width=\"100%\" class=\"prefFeedProfileList\" | |
1014 | cellspacing=\"0\" id=\"prefFeedProfileList\">"; | |
1015 | ||
1016 | print "<tr class=\"placeholder\" id=\"FCATR-0\">"; #odd | |
1017 | ||
1018 | print "<td width='5%' align='center'><input | |
1019 | id='FCATC-0' | |
1020 | onclick='toggleSelectRow2(this);' | |
1021 | dojoType=\"dijit.form.CheckBox\" | |
1022 | type=\"checkbox\"></td>"; | |
1023 | ||
1024 | if (!$_SESSION["profile"]) { | |
1025 | $is_active = __("(active)"); | |
1026 | } else { | |
1027 | $is_active = ""; | |
1028 | } | |
1029 | ||
1030 | print "<td><span>" . | |
1031 | __("Default profile") . " $is_active</span></td>"; | |
1032 | ||
1033 | print "</tr>"; | |
1034 | ||
1035 | $lnum = 1; | |
1036 | ||
1037 | while ($line = $sth->fetch()) { | |
1038 | ||
1039 | $profile_id = $line["id"]; | |
1040 | $this_row_id = "id=\"FCATR-$profile_id\""; | |
1041 | ||
1042 | print "<tr class=\"placeholder\" $this_row_id>"; | |
1043 | ||
1044 | $edit_title = htmlspecialchars($line["title"]); | |
1045 | ||
1046 | print "<td width='5%' align='center'><input | |
1047 | onclick='toggleSelectRow2(this);' | |
1048 | id='FCATC-$profile_id' | |
1049 | dojoType=\"dijit.form.CheckBox\" | |
1050 | type=\"checkbox\"></td>"; | |
1051 | ||
1052 | if ($_SESSION["profile"] == $line["id"]) { | |
1053 | $is_active = __("(active)"); | |
1054 | } else { | |
1055 | $is_active = ""; | |
1056 | } | |
1057 | ||
1058 | print "<td><span dojoType=\"dijit.InlineEditBox\" | |
1059 | width=\"300px\" autoSave=\"false\" | |
1060 | profile-id=\"$profile_id\">" . $edit_title . | |
1061 | "<script type=\"dojo/method\" event=\"onChange\" args=\"item\"> | |
1062 | var elem = this; | |
1063 | dojo.xhrPost({ | |
1064 | url: 'backend.php', | |
1065 | content: {op: 'rpc', method: 'saveprofile', | |
1066 | value: this.value, | |
1067 | id: this.srcNodeRef.getAttribute('profile-id')}, | |
1068 | load: function(response) { | |
1069 | elem.attr('value', response); | |
1070 | } | |
1071 | }); | |
1072 | </script> | |
1073 | </span> $is_active</td>"; | |
1074 | ||
1075 | print "</tr>"; | |
1076 | ||
1077 | ++$lnum; | |
1078 | } | |
1079 | ||
1080 | print "</table>"; | |
1081 | print "</form>"; | |
1082 | print "</div>"; | |
1083 | ||
1084 | print "<div class='dlgButtons'> | |
1085 | <div style='float : left'> | |
1086 | <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('profileEditDlg').removeSelected()\">". | |
1087 | __('Remove selected profiles')."</button> | |
1088 | <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('profileEditDlg').activateProfile()\">". | |
1089 | __('Activate profile')."</button> | |
1090 | </div>"; | |
1091 | ||
1092 | print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('profileEditDlg').hide()\">". | |
1093 | __('Close this window')."</button>"; | |
1094 | print "</div>"; | |
1095 | ||
1096 | } | |
1097 | ||
1098 | private function getShortDesc($pref_name) { | |
1099 | if (isset($this->pref_help[$pref_name])) { | |
1100 | return $this->pref_help[$pref_name][0]; | |
1101 | } | |
1102 | return ""; | |
1103 | } | |
1104 | ||
1105 | private function getHelpText($pref_name) { | |
1106 | if (isset($this->pref_help[$pref_name])) { | |
1107 | return $this->pref_help[$pref_name][1]; | |
1108 | } | |
1109 | return ""; | |
1110 | } | |
1111 | ||
1112 | private function getSectionName($id) { | |
1113 | if (isset($this->pref_sections[$id])) { | |
1114 | return $this->pref_sections[$id]; | |
1115 | } | |
1116 | ||
1117 | return ""; | |
1118 | } | |
1119 | } |