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