]>
git.wh0rd.org - tt-rss.git/blob - plugins/updater/updater.php
2 class Updater
extends Plugin
{
7 function __construct($host) {
8 $this->link
= $host->get_link();
11 $host->add_hook($host::HOOK_PREFS_TAB
, $this);
14 function get_prefs_js() {
15 return file_get_contents(dirname(__FILE__
) . "/updater.js");
18 function hook_prefs_tab($args) {
19 if ($args != "prefPrefs") return;
21 if (($_SESSION["access_level"] >= 10 || SINGLE_USER_MODE
) && CHECK_FOR_NEW_VERSION
) {
22 print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Update Tiny Tiny RSS')."\">";
24 if ($_SESSION["pref_last_version_check"] +
86400 +
rand(-1000, 1000) < time()) {
25 $_SESSION["version_data"] = @check_for_update
($this->link
);
26 $_SESSION["pref_last_version_check"] = time();
29 if (is_array($_SESSION["version_data"])) {
30 $version = $_SESSION["version_data"]["version"];
31 print_notice(T_sprintf("New version of Tiny Tiny RSS is available (%s).", "<b>$version</b>"));
33 print "<p><button dojoType=\"dijit.form.Button\" onclick=\"return updateSelf()\">".
34 __('Update Tiny Tiny RSS')."</button></p>";
37 print_notice(__("Your Tiny Tiny RSS installation is up to date."));
43 function updateSelf() {
44 print "<form style='display : block' name='self_update_form' id='self_update_form'>";
46 print "<div class='error'>".__("Do not close this dialog until updating is finished. Backup your tt-rss directory before continuing.")."</div>";
48 print "<ul class='selfUpdateList' id='self_update_log'>";
49 print "<li>" . __("Ready to update.") . "</li>";
52 print "<div class='dlgButtons'>";
53 print "<button id=\"self_update_start_btn\" dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('updateSelfDlg').start()\" >".
54 __("Start update")."</button>";
55 print "<button id=\"self_update_stop_btn\" onclick=\"return dijit.byId('updateSelfDlg').close()\" dojoType=\"dijit.form.Button\">".
56 __("Close this window")."</button>";
61 function performUpdate() {
62 $step = (int) $_REQUEST["step"];
63 $params = json_decode($_REQUEST["params"], true);
64 $force = (bool) $_REQUEST["force"];
66 if (($_SESSION["access_level"] >= 10 || SINGLE_USER_MODE
) && CHECK_FOR_NEW_VERSION
) {
67 include "update_self.php";
69 print json_encode(update_self_step($this->link
, $step, $params, $force));