summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--classes/pref/prefs.php53
-rw-r--r--js/prefs.js68
-rw-r--r--plugins/updater/README.txt1
-rw-r--r--plugins/updater/updater.js69
-rw-r--r--plugins/updater/updater.php76
5 files changed, 146 insertions, 121 deletions
diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php
index 013d589ca..db7a3e04f 100644
--- a/classes/pref/prefs.php
+++ b/classes/pref/prefs.php
@@ -627,29 +627,6 @@ class Pref_Prefs extends Handler_Protected {
print "</div>"; #pane
-
- if (($_SESSION["access_level"] >= 10 || SINGLE_USER_MODE) && CHECK_FOR_NEW_VERSION) {
- print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Update Tiny Tiny RSS')."\">";
-
- if ($_SESSION["pref_last_version_check"] + 86400 + rand(-1000, 1000) < time()) {
- $_SESSION["version_data"] = @check_for_update($this->link);
- $_SESSION["pref_last_version_check"] = time();
- }
-
- if (is_array($_SESSION["version_data"])) {
- $version = $_SESSION["version_data"]["version"];
- print_notice(T_sprintf("New version of Tiny Tiny RSS is available (%s).", "<b>$version</b>"));
-
- print "<p><button dojoType=\"dijit.form.Button\" onclick=\"return updateSelf()\">".
- __('Update Tiny Tiny RSS')."</button></p>";
-
- } else {
- print_notice(__("Your Tiny Tiny RSS installation is up to date."));
- }
-
- print "</div>"; #pane
- }
-
global $pluginhost;
$pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB,
"hook_prefs_tab", "prefPrefs");
@@ -657,36 +634,6 @@ class Pref_Prefs extends Handler_Protected {
print "</div>"; #container
}
- function updateSelf() {
- print "<form style='display : block' name='self_update_form' id='self_update_form'>";
-
- print "<div class='error'>".__("Do not close this dialog until updating is finished. Backup your tt-rss directory before continuing.")."</div>";
-
- print "<ul class='selfUpdateList' id='self_update_log'>";
- print "<li>" . __("Ready to update.") . "</li>";
- print "</ul>";
-
- print "<div class='dlgButtons'>";
- print "<button id=\"self_update_start_btn\" dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('updateSelfDlg').start()\" >".
- __("Start update")."</button>";
- print "<button id=\"self_update_stop_btn\" onclick=\"return dijit.byId('updateSelfDlg').close()\" dojoType=\"dijit.form.Button\">".
- __("Close this window")."</button>";
- print "</div>";
- print "</form>";
- }
-
- function performUpdate() {
- $step = (int) $_REQUEST["step"];
- $params = json_decode($_REQUEST["params"], true);
- $force = (bool) $_REQUEST["force"];
-
- if (($_SESSION["access_level"] >= 10 || SINGLE_USER_MODE) && CHECK_FOR_NEW_VERSION) {
- include "update_self.php";
-
- print json_encode(update_self_step($this->link, $step, $params, $force));
- }
- }
-
function toggleAdvanced() {
$_SESSION["prefs_show_advanced"] = !$_SESSION["prefs_show_advanced"];
}
diff --git a/js/prefs.js b/js/prefs.js
index 1d21e0cd5..51d8412fc 100644
--- a/js/prefs.js
+++ b/js/prefs.js
@@ -2208,74 +2208,6 @@ function batchSubscribe() {
}
}
-function updateSelf() {
- try {
- var query = "backend.php?op=pref-prefs&method=updateSelf";
-
- if (dijit.byId("updateSelfDlg"))
- dijit.byId("updateSelfDlg").destroyRecursive();
-
- var dialog = new dijit.Dialog({
- id: "updateSelfDlg",
- title: __("Update Tiny Tiny RSS"),
- style: "width: 600px",
- closable: false,
- performUpdate: function(step) {
- dijit.byId("self_update_start_btn").attr("disabled", true);
- dijit.byId("self_update_stop_btn").attr("disabled", true);
-
- notify_progress("Loading, please wait...", true);
- new Ajax.Request("backend.php", {
- parameters: "?op=pref-prefs&method=performUpdate&step=" + step +
- "&params=" + param_escape(JSON.stringify(dialog.attr("update-params"))),
- onComplete: function(transport) {
- try {
- rv = JSON.parse(transport.responseText);
- if (rv) {
- notify('');
-
- rv['log'].each(function(line) {
- $("self_update_log").innerHTML += "<li>" + line + "</li>";
- });
-
- dialog.attr("update-params", rv['params']);
-
- if (!rv['stop']) {
- window.setTimeout("dijit.byId('updateSelfDlg').performUpdate("+(step+1)+")", 500);
- } else {
- dijit.byId("self_update_stop_btn").attr("disabled", false);
- }
-
- } else {
- console.log(transport.responseText);
- notify_error("Received invalid data from server.");
- }
-
- dialog.attr("updated", true);
- } catch (e) {
- exception_error("updateSelf/inner", e);
- }
- } });
- },
- close: function() {
- if (dialog.attr("updated")) {
- window.location.reload();
- } else {
- dialog.hide();
- }
- },
- start: function() {
- if (prompt(__("Live updating is considered experimental. Backup your tt-rss directory before continuing. Please type 'yes' to continue.")) == 'yes') {
- dialog.performUpdate(0);
- }
- },
- href: query});
-
- dialog.show();
- } catch (e) {
- exception_error("batchSubscribe", e);
- }
-}
function toggleAdvancedPrefs() {
try {
diff --git a/plugins/updater/README.txt b/plugins/updater/README.txt
new file mode 100644
index 000000000..083a19f71
--- /dev/null
+++ b/plugins/updater/README.txt
@@ -0,0 +1 @@
+Updates tt-rss installation to latest version.
diff --git a/plugins/updater/updater.js b/plugins/updater/updater.js
new file mode 100644
index 000000000..17452d734
--- /dev/null
+++ b/plugins/updater/updater.js
@@ -0,0 +1,69 @@
+function updateSelf() {
+ try {
+ var query = "backend.php?op=pluginhandler&plugin=updater&method=updateSelf";
+
+ if (dijit.byId("updateSelfDlg"))
+ dijit.byId("updateSelfDlg").destroyRecursive();
+
+ var dialog = new dijit.Dialog({
+ id: "updateSelfDlg",
+ title: __("Update Tiny Tiny RSS"),
+ style: "width: 600px",
+ closable: false,
+ performUpdate: function(step) {
+ dijit.byId("self_update_start_btn").attr("disabled", true);
+ dijit.byId("self_update_stop_btn").attr("disabled", true);
+
+ notify_progress("Loading, please wait...", true);
+ new Ajax.Request("backend.php", {
+ parameters: "?op=pluginhandler&plugin=updater&method=performUpdate&step=" + step +
+ "&params=" + param_escape(JSON.stringify(dialog.attr("update-params"))),
+ onComplete: function(transport) {
+ try {
+ rv = JSON.parse(transport.responseText);
+ if (rv) {
+ notify('');
+
+ rv['log'].each(function(line) {
+ $("self_update_log").innerHTML += "<li>" + line + "</li>";
+ });
+
+ dialog.attr("update-params", rv['params']);
+
+ if (!rv['stop']) {
+ window.setTimeout("dijit.byId('updateSelfDlg').performUpdate("+(step+1)+")", 500);
+ } else {
+ dijit.byId("self_update_stop_btn").attr("disabled", false);
+ }
+
+ } else {
+ console.log(transport.responseText);
+ notify_error("Received invalid data from server.");
+ }
+
+ dialog.attr("updated", true);
+ } catch (e) {
+ exception_error("updateSelf/inner", e);
+ }
+ } });
+ },
+ close: function() {
+ if (dialog.attr("updated")) {
+ window.location.reload();
+ } else {
+ dialog.hide();
+ }
+ },
+ start: function() {
+ if (prompt(__("Live updating is considered experimental. Backup your tt-rss directory before continuing. Please type 'yes' to continue.")) == 'yes') {
+ dialog.performUpdate(0);
+ }
+ },
+ href: query});
+
+ dialog.show();
+ } catch (e) {
+ exception_error("batchSubscribe", e);
+ }
+}
+
diff --git a/plugins/updater/updater.php b/plugins/updater/updater.php
new file mode 100644
index 000000000..f88ebe409
--- /dev/null
+++ b/plugins/updater/updater.php
@@ -0,0 +1,76 @@
+<?php
+class Updater extends Plugin {
+
+ private $link;
+ private $host;
+
+ function __construct($host) {
+ $this->link = $host->get_link();
+ $this->host = $host;
+
+ $host->add_hook($host::HOOK_PREFS_TAB, $this);
+ }
+
+ function get_prefs_js() {
+ return file_get_contents(dirname(__FILE__) . "/updater.js");
+ }
+
+ function hook_prefs_tab($args) {
+ if ($args != "prefPrefs") return;
+
+ if (($_SESSION["access_level"] >= 10 || SINGLE_USER_MODE) && CHECK_FOR_NEW_VERSION) {
+ print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Update Tiny Tiny RSS')."\">";
+
+ if ($_SESSION["pref_last_version_check"] + 86400 + rand(-1000, 1000) < time()) {
+ $_SESSION["version_data"] = @check_for_update($this->link);
+ $_SESSION["pref_last_version_check"] = time();
+ }
+
+ if (is_array($_SESSION["version_data"])) {
+ $version = $_SESSION["version_data"]["version"];
+ print_notice(T_sprintf("New version of Tiny Tiny RSS is available (%s).", "<b>$version</b>"));
+
+ print "<p><button dojoType=\"dijit.form.Button\" onclick=\"return updateSelf()\">".
+ __('Update Tiny Tiny RSS')."</button></p>";
+
+ } else {
+ print_notice(__("Your Tiny Tiny RSS installation is up to date."));
+ }
+
+ print "</div>"; #pane
+ }
+
+ function updateSelf() {
+ print "<form style='display : block' name='self_update_form' id='self_update_form'>";
+
+ print "<div class='error'>".__("Do not close this dialog until updating is finished. Backup your tt-rss directory before continuing.")."</div>";
+
+ print "<ul class='selfUpdateList' id='self_update_log'>";
+ print "<li>" . __("Ready to update.") . "</li>";
+ print "</ul>";
+
+ print "<div class='dlgButtons'>";
+ print "<button id=\"self_update_start_btn\" dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('updateSelfDlg').start()\" >".
+ __("Start update")."</button>";
+ print "<button id=\"self_update_stop_btn\" onclick=\"return dijit.byId('updateSelfDlg').close()\" dojoType=\"dijit.form.Button\">".
+ __("Close this window")."</button>";
+ print "</div>";
+ print "</form>";
+ }
+
+ function performUpdate() {
+ $step = (int) $_REQUEST["step"];
+ $params = json_decode($_REQUEST["params"], true);
+ $force = (bool) $_REQUEST["force"];
+
+ if (($_SESSION["access_level"] >= 10 || SINGLE_USER_MODE) && CHECK_FOR_NEW_VERSION) {
+ include "update_self.php";
+
+ print json_encode(update_self_step($this->link, $step, $params, $force));
+ }
+ }
+
+
+ }
+}
+?>