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