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