]>
Commit | Line | Data |
---|---|---|
1395083e | 1 | <?php |
369dbc19 | 2 | class Pref_Prefs extends Handler_Protected { |
1395083e | 3 | |
8484ce22 | 4 | function csrf_ignore($method) { |
27211afe | 5 | $csrf_ignored = array("index", "updateself"); |
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 | ||
d5fd183d AD |
31 | $module_class = "auth_" . $_SESSION["auth_module"]; |
32 | $authenticator = new $module_class($this->link); | |
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 | ||
45 | $orig_theme = get_pref($this->link, "_THEME_ID"); | |
46 | ||
47 | foreach (array_keys($_POST) as $pref_name) { | |
48 | ||
49 | $pref_name = db_escape_string($pref_name); | |
50 | $value = db_escape_string($_POST[$pref_name]); | |
51 | ||
1b9b19af AD |
52 | if ($pref_name == 'DIGEST_PREFERRED_TIME') { |
53 | if (get_pref($this->link, 'DIGEST_PREFERRED_TIME') != $value) { | |
54 | ||
55 | db_query($this->link, "UPDATE ttrss_users SET | |
56 | last_digest_sent = NULL WHERE id = " . $_SESSION['uid']); | |
57 | ||
58 | } | |
59 | } | |
60 | ||
1395083e AD |
61 | set_pref($this->link, $pref_name, $value); |
62 | ||
63 | } | |
64 | ||
65 | if ($orig_theme != get_pref($this->link, "_THEME_ID")) { | |
66 | print "PREFS_THEME_CHANGED"; | |
67 | } else { | |
68 | print __("The configuration was saved."); | |
69 | } | |
70 | } | |
71 | ||
72 | function getHelp() { | |
73 | ||
74 | $pref_name = db_escape_string($_REQUEST["pn"]); | |
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 | ||
89 | $email = db_escape_string($_POST["email"]); | |
90 | $full_name = db_escape_string($_POST["full_name"]); | |
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"]); | |
116 | ||
117 | print "PREFS_THEME_CHANGED"; | |
118 | } | |
119 | ||
120 | function index() { | |
121 | ||
122 | global $access_level_names; | |
123 | ||
124 | $prefs_blacklist = array("HIDE_READ_FEEDS", "FEEDS_SORT_BY_UNREAD", | |
125 | "STRIP_UNSAFE_TAGS"); | |
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 | |
d4c64ecc AD |
157 | $result = db_query($this->link, "SELECT email,full_name, |
158 | access_level FROM ttrss_users | |
159 | WHERE id = ".$_SESSION["uid"]); | |
1395083e | 160 | |
d4c64ecc AD |
161 | $email = htmlspecialchars(db_fetch_result($result, 0, "email")); |
162 | $full_name = htmlspecialchars(db_fetch_result($result, 0, "full_name")); | |
1395083e | 163 | |
d4c64ecc AD |
164 | print "<tr><td width=\"40%\">".__('Full name')."</td>"; |
165 | print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" name=\"full_name\" required=\"1\" | |
166 | value=\"$full_name\"></td></tr>"; | |
1395083e | 167 | |
d4c64ecc AD |
168 | print "<tr><td width=\"40%\">".__('E-mail')."</td>"; |
169 | print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" name=\"email\" required=\"1\" value=\"$email\"></td></tr>"; | |
1395083e | 170 | |
0d421af8 | 171 | if (!SINGLE_USER_MODE && !$_SESSION["hide_hello"]) { |
949b1a94 | 172 | |
d4c64ecc AD |
173 | $access_level = db_fetch_result($result, 0, "access_level"); |
174 | print "<tr><td width=\"40%\">".__('Access level')."</td>"; | |
175 | print "<td>" . $access_level_names[$access_level] . "</td></tr>"; | |
176 | } | |
1395083e | 177 | |
d4c64ecc | 178 | print "</table>"; |
1395083e | 179 | |
d4c64ecc AD |
180 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">"; |
181 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"changeemail\">"; | |
1395083e | 182 | |
d4c64ecc AD |
183 | print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">". |
184 | __("Save data")."</button>"; | |
1395083e | 185 | |
d4c64ecc | 186 | print "</form>"; |
1395083e | 187 | |
d5fd183d AD |
188 | if ($_SESSION["auth_module"]) { |
189 | $module_class = "auth_" . $_SESSION["auth_module"]; | |
190 | $authenticator = new $module_class($this->link); | |
191 | } else { | |
192 | $authenticator = false; | |
193 | } | |
194 | ||
195 | if ($authenticator && method_exists($authenticator, "change_password")) { | |
1395083e | 196 | |
1395083e AD |
197 | $result = db_query($this->link, "SELECT id FROM ttrss_users |
198 | WHERE id = ".$_SESSION["uid"]." AND pwd_hash | |
199 | = 'SHA1:5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8'"); | |
200 | ||
201 | if (db_num_rows($result) != 0) { | |
202 | print format_warning(__("Your password is at default value, please change it."), "default_pass_warning"); | |
203 | } | |
204 | ||
205 | print "<form dojoType=\"dijit.form.Form\">"; | |
206 | ||
207 | print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\"> | |
208 | evt.preventDefault(); | |
209 | if (this.validate()) { | |
210 | notify_progress('Changing password...', true); | |
211 | ||
212 | new Ajax.Request('backend.php', { | |
213 | parameters: dojo.objectToQuery(this.getValues()), | |
214 | onComplete: function(transport) { | |
215 | notify(''); | |
216 | if (transport.responseText.indexOf('ERROR: ') == 0) { | |
217 | notify_error(transport.responseText.replace('ERROR: ', '')); | |
218 | } else { | |
219 | notify_info(transport.responseText); | |
220 | var warn = $('default_pass_warning'); | |
221 | if (warn) Element.hide(warn); | |
222 | } | |
223 | }}); | |
224 | this.reset(); | |
225 | } | |
226 | </script>"; | |
227 | ||
228 | print "<table width=\"100%\" class=\"prefPrefsList\">"; | |
229 | ||
230 | print "<tr><td width=\"40%\">".__("Old password")."</td>"; | |
231 | print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\" name=\"old_password\"></td></tr>"; | |
232 | ||
233 | print "<tr><td width=\"40%\">".__("New password")."</td>"; | |
234 | ||
235 | print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\" | |
236 | name=\"new_password\"></td></tr>"; | |
237 | ||
238 | print "<tr><td width=\"40%\">".__("Confirm password")."</td>"; | |
239 | ||
240 | print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\" name=\"confirm_password\"></td></tr>"; | |
241 | ||
242 | print "</table>"; | |
243 | ||
244 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">"; | |
245 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"changepassword\">"; | |
246 | ||
247 | print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">". | |
248 | __("Change password")."</button>"; | |
249 | ||
250 | print "</form>"; | |
251 | ||
1395083e AD |
252 | } |
253 | ||
d4c64ecc AD |
254 | print "</div>"; #pane |
255 | ||
1395083e AD |
256 | print "<div dojoType=\"dijit.layout.AccordionPane\" selected=\"true\" title=\"".__('Preferences')."\">"; |
257 | ||
258 | print "<form dojoType=\"dijit.form.Form\" id=\"changeSettingsForm\">"; | |
259 | ||
260 | print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\"> | |
261 | evt.preventDefault(); | |
262 | if (this.validate()) { | |
263 | console.log(dojo.objectToQuery(this.getValues())); | |
264 | ||
265 | new Ajax.Request('backend.php', { | |
266 | parameters: dojo.objectToQuery(this.getValues()), | |
267 | onComplete: function(transport) { | |
268 | var msg = transport.responseText; | |
269 | if (msg.match('PREFS_THEME_CHANGED')) { | |
270 | window.location.reload(); | |
271 | } else { | |
272 | notify_info(msg); | |
273 | } | |
274 | } }); | |
275 | } | |
276 | </script>"; | |
277 | ||
278 | print '<div dojoType="dijit.layout.BorderContainer" gutters="false">'; | |
279 | ||
280 | print '<div dojoType="dijit.layout.ContentPane" region="center" style="overflow-y : auto">'; | |
281 | ||
282 | if ($_SESSION["profile"]) { | |
283 | print_notice("Some preferences are only available in default profile."); | |
284 | } | |
285 | ||
286 | if ($_SESSION["profile"]) { | |
287 | initialize_user_prefs($this->link, $_SESSION["uid"], $_SESSION["profile"]); | |
288 | $profile_qpart = "profile = '" . $_SESSION["profile"] . "'"; | |
289 | } else { | |
290 | initialize_user_prefs($this->link, $_SESSION["uid"]); | |
291 | $profile_qpart = "profile IS NULL"; | |
292 | } | |
293 | ||
f9ebb32c AD |
294 | if ($_SESSION["prefs_show_advanced"]) |
295 | $access_query = "true"; | |
296 | else | |
297 | $access_query = "(access_level = 0 AND section_id != 3)"; | |
298 | ||
ddb575c7 | 299 | $result = db_query($this->link, "SELECT DISTINCT |
1395083e | 300 | ttrss_user_prefs.pref_name,short_desc,help_text,value,type_name, |
f9ebb32c | 301 | ttrss_prefs_sections.order_id, |
1395083e AD |
302 | section_name,def_value,section_id |
303 | FROM ttrss_prefs,ttrss_prefs_types,ttrss_prefs_sections,ttrss_user_prefs | |
304 | WHERE type_id = ttrss_prefs_types.id AND | |
305 | $profile_qpart AND | |
306 | section_id = ttrss_prefs_sections.id AND | |
307 | ttrss_user_prefs.pref_name = ttrss_prefs.pref_name AND | |
f9ebb32c | 308 | $access_query AND |
1395083e AD |
309 | short_desc != '' AND |
310 | owner_uid = ".$_SESSION["uid"]." | |
f9ebb32c | 311 | ORDER BY ttrss_prefs_sections.order_id,short_desc"); |
1395083e AD |
312 | |
313 | $lnum = 0; | |
314 | ||
315 | $active_section = ""; | |
316 | ||
317 | while ($line = db_fetch_assoc($result)) { | |
318 | ||
319 | if (in_array($line["pref_name"], $prefs_blacklist)) { | |
320 | continue; | |
321 | } | |
322 | ||
323 | if ($_SESSION["profile"] && in_array($line["pref_name"], | |
324 | $profile_blacklist)) { | |
325 | continue; | |
326 | } | |
327 | ||
328 | if ($active_section != $line["section_name"]) { | |
329 | ||
330 | if ($active_section != "") { | |
331 | print "</table>"; | |
332 | } | |
333 | ||
334 | print "<table width=\"100%\" class=\"prefPrefsList\">"; | |
335 | ||
336 | $active_section = $line["section_name"]; | |
337 | ||
338 | print "<tr><td colspan=\"3\"><h3>".__($active_section)."</h3></td></tr>"; | |
339 | ||
340 | if ($line["section_id"] == 2) { | |
341 | print "<tr><td width=\"40%\">".__("Select theme")."</td>"; | |
342 | ||
343 | $user_theme = get_pref($this->link, "_THEME_ID"); | |
344 | $themes = get_all_themes(); | |
345 | ||
346 | print "<td><select name=\"_THEME_ID\" dojoType=\"dijit.form.Select\">"; | |
347 | print "<option value='Default'>".__('Default')."</option>"; | |
348 | print "<option value='----------------' disabled=\"1\">--------</option>"; | |
349 | ||
350 | foreach ($themes as $t) { | |
351 | $base = $t['base']; | |
352 | $name = $t['name']; | |
353 | ||
354 | if ($base == $user_theme) { | |
355 | $selected = "selected=\"1\""; | |
356 | } else { | |
357 | $selected = ""; | |
358 | } | |
359 | ||
360 | print "<option $selected value='$base'>$name</option>"; | |
361 | ||
362 | } | |
363 | ||
364 | print "</select></td></tr>"; | |
365 | } | |
366 | $lnum = 0; | |
367 | } | |
368 | ||
369 | print "<tr>"; | |
370 | ||
371 | $type_name = $line["type_name"]; | |
372 | $pref_name = $line["pref_name"]; | |
373 | $value = $line["value"]; | |
374 | $def_value = $line["def_value"]; | |
375 | $help_text = $line["help_text"]; | |
376 | ||
377 | print "<td width=\"40%\" class=\"prefName\" id=\"$pref_name\">" . __($line["short_desc"]); | |
378 | ||
379 | if ($help_text) print "<div class=\"prefHelp\">".__($help_text)."</div>"; | |
380 | ||
381 | print "</td>"; | |
382 | ||
383 | print "<td class=\"prefValue\">"; | |
384 | ||
385 | if ($pref_name == "USER_TIMEZONE") { | |
386 | ||
387 | $timezones = explode("\n", file_get_contents("lib/timezones.txt")); | |
388 | ||
389 | print_select($pref_name, $value, $timezones, 'dojoType="dijit.form.FilteringSelect"'); | |
390 | } else if ($pref_name == "USER_STYLESHEET") { | |
391 | ||
392 | print "<button dojoType=\"dijit.form.Button\" | |
393 | onclick=\"customizeCSS()\">" . __('Customize') . "</button>"; | |
394 | ||
395 | } else if ($pref_name == "DEFAULT_ARTICLE_LIMIT") { | |
396 | ||
397 | $limits = array(15, 30, 45, 60); | |
398 | ||
399 | print_select($pref_name, $value, $limits, | |
400 | 'dojoType="dijit.form.Select"'); | |
401 | ||
402 | } else if ($pref_name == "DEFAULT_UPDATE_INTERVAL") { | |
403 | ||
404 | global $update_intervals_nodefault; | |
405 | ||
406 | print_select_hash($pref_name, $value, $update_intervals_nodefault, | |
407 | 'dojoType="dijit.form.Select"'); | |
408 | ||
409 | } else if ($type_name == "bool") { | |
410 | ||
411 | if ($value == "true") { | |
412 | $value = __("Yes"); | |
413 | } else { | |
414 | $value = __("No"); | |
415 | } | |
416 | ||
417 | if ($pref_name == "PURGE_UNREAD_ARTICLES" && FORCE_ARTICLE_PURGE != 0) { | |
418 | $disabled = "disabled=\"1\""; | |
419 | $value = __("Yes"); | |
420 | } else { | |
421 | $disabled = ""; | |
422 | } | |
423 | ||
424 | print_radio($pref_name, $value, __("Yes"), array(__("Yes"), __("No")), | |
425 | $disabled); | |
426 | ||
427 | } else if (array_search($pref_name, array('FRESH_ARTICLE_MAX_AGE', 'DEFAULT_ARTICLE_LIMIT', | |
428 | 'PURGE_OLD_DAYS', 'LONG_DATE_FORMAT', 'SHORT_DATE_FORMAT')) !== false) { | |
429 | ||
430 | $regexp = ($type_name == 'integer') ? 'regexp="^\d*$"' : ''; | |
431 | ||
432 | if ($pref_name == "PURGE_OLD_DAYS" && FORCE_ARTICLE_PURGE != 0) { | |
433 | $disabled = "disabled=\"1\""; | |
434 | $value = FORCE_ARTICLE_PURGE; | |
435 | } else { | |
436 | $disabled = ""; | |
437 | } | |
438 | ||
439 | print "<input dojoType=\"dijit.form.ValidationTextBox\" | |
440 | required=\"1\" $regexp $disabled | |
441 | name=\"$pref_name\" value=\"$value\">"; | |
442 | ||
443 | } else if ($pref_name == "SSL_CERT_SERIAL") { | |
444 | ||
445 | print "<input dojoType=\"dijit.form.ValidationTextBox\" | |
446 | id=\"SSL_CERT_SERIAL\" readonly=\"1\" | |
447 | name=\"$pref_name\" value=\"$value\">"; | |
448 | ||
449 | $cert_serial = htmlspecialchars(get_ssl_certificate_id()); | |
450 | $has_serial = ($cert_serial) ? "false" : "true"; | |
451 | ||
452 | print " <button dojoType=\"dijit.form.Button\" disabled=\"$has_serial\" | |
453 | onclick=\"insertSSLserial('$cert_serial')\">" . | |
454 | __('Register') . "</button>"; | |
455 | ||
456 | print " <button dojoType=\"dijit.form.Button\" | |
457 | onclick=\"insertSSLserial('')\">" . | |
458 | __('Clear') . "</button>"; | |
459 | ||
76c843a9 | 460 | } else if ($pref_name == 'DIGEST_PREFERRED_TIME') { |
61c1812f | 461 | print "<input dojoType=\"dijit.form.ValidationTextBox\" |
1b92f543 | 462 | id=\"$pref_name\" regexp=\"[012]?\d:\d\d\" placeHolder=\"12:00\" |
61c1812f | 463 | name=\"$pref_name\" value=\"$value\"><div class=\"insensitive\">". |
8eba830f | 464 | T_sprintf("Current server time: %s (UTC)", date("H:i")) . "</div>"; |
1395083e AD |
465 | } else { |
466 | $regexp = ($type_name == 'integer') ? 'regexp="^\d*$"' : ''; | |
467 | ||
468 | print "<input dojoType=\"dijit.form.ValidationTextBox\" | |
469 | $regexp | |
470 | name=\"$pref_name\" value=\"$value\">"; | |
471 | } | |
472 | ||
473 | print "</td>"; | |
474 | ||
475 | print "</tr>"; | |
476 | ||
477 | $lnum++; | |
478 | } | |
479 | ||
480 | print "</table>"; | |
481 | ||
482 | print '</div>'; # inside pane | |
483 | print '<div dojoType="dijit.layout.ContentPane" region="bottom">'; | |
484 | ||
485 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">"; | |
486 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"saveconfig\">"; | |
487 | ||
488 | print "<button dojoType=\"dijit.form.Button\" type=\"submit\">". | |
489 | __('Save configuration')."</button> "; | |
490 | ||
491 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return editProfiles()\">". | |
492 | __('Manage profiles')."</button> "; | |
493 | ||
494 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return validatePrefsReset()\">". | |
495 | __('Reset to defaults')."</button>"; | |
496 | ||
f9ebb32c AD |
497 | print " "; |
498 | ||
499 | $checked = $_SESSION["prefs_show_advanced"] ? "checked='1'" : ""; | |
500 | ||
501 | print "<input onclick='toggleAdvancedPrefs()' | |
502 | id='prefs_show_advanced' | |
503 | dojoType=\"dijit.form.CheckBox\" | |
504 | $checked | |
505 | type=\"checkbox\"></input> | |
506 | <label for='prefs_show_advanced'>" . | |
507 | __("Show additional preferences") . "</label>"; | |
508 | ||
1395083e AD |
509 | print '</div>'; # inner pane |
510 | print '</div>'; # border container | |
1395083e AD |
511 | print "</form>"; |
512 | ||
513 | print "</div>"; #pane | |
27211afe AD |
514 | |
515 | ||
516 | if (($_SESSION["access_level"] >= 10 || SINGLE_USER_MODE) && CHECK_FOR_NEW_VERSION) { | |
517 | print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Update Tiny Tiny RSS')."\">"; | |
518 | ||
519 | if ($_SESSION["pref_last_version_check"] + 86400 + rand(-1000, 1000) < time()) { | |
520 | $_SESSION["version_data"] = @check_for_update($this->link); | |
521 | $_SESSION["pref_last_version_check"] = time(); | |
522 | } | |
523 | ||
524 | if (is_array($_SESSION["version_data"])) { | |
525 | $version = $_SESSION["version_data"]["version"]; | |
526 | print_notice(T_sprintf("New version of Tiny Tiny RSS is available (%s).", "<b>$version</b>")); | |
527 | ||
528 | print "<p><button dojoType=\"dijit.form.Button\" onclick=\"return updateSelf()\">". | |
529 | __('Update Tiny Tiny RSS')."</button></p>"; | |
530 | ||
531 | } else { | |
12806125 | 532 | print_notice(__("Your Tiny Tiny RSS installation is up to date.")); |
27211afe AD |
533 | } |
534 | ||
535 | print "</div>"; #pane | |
536 | } | |
537 | ||
1395083e AD |
538 | print "</div>"; #container |
539 | } | |
27211afe AD |
540 | |
541 | function updateSelf() { | |
542 | print "<form style='display : block' name='self_update_form' id='self_update_form'>"; | |
543 | ||
544 | print "<div class='error'>".__("Do not close this dialog until updating is finished. Backup your tt-rss directory before continuing.")."</div>"; | |
545 | ||
808dd053 AD |
546 | print "<ul class='selfUpdateList' id='self_update_log'>"; |
547 | print "<li>" . __("Ready to update.") . "</li>"; | |
548 | print "</ul>"; | |
27211afe AD |
549 | |
550 | print "<div class='dlgButtons'>"; | |
551 | print "<button id=\"self_update_start_btn\" dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('updateSelfDlg').start()\" >". | |
552 | __("Start update")."</button>"; | |
808dd053 | 553 | print "<button id=\"self_update_stop_btn\" onclick=\"return dijit.byId('updateSelfDlg').close()\" dojoType=\"dijit.form.Button\">". |
27211afe AD |
554 | __("Close this window")."</button>"; |
555 | print "</div>"; | |
556 | print "</form>"; | |
557 | } | |
558 | ||
559 | function performUpdate() { | |
808dd053 AD |
560 | $step = (int) $_REQUEST["step"]; |
561 | $params = json_decode($_REQUEST["params"], true); | |
562 | $force = (bool) $_REQUEST["force"]; | |
563 | ||
27211afe AD |
564 | if (($_SESSION["access_level"] >= 10 || SINGLE_USER_MODE) && CHECK_FOR_NEW_VERSION) { |
565 | include "update_self.php"; | |
808dd053 AD |
566 | |
567 | print json_encode(update_self_step($this->link, $step, $params, $force)); | |
27211afe AD |
568 | } |
569 | } | |
570 | ||
f9ebb32c AD |
571 | function toggleAdvanced() { |
572 | $_SESSION["prefs_show_advanced"] = !$_SESSION["prefs_show_advanced"]; | |
573 | } | |
1395083e AD |
574 | } |
575 | ?> |