]> git.wh0rd.org Git - tt-rss.git/commitdiff
implement experimental web-based updater
authorAndrew Dolgov <fox@fakecake.org>
Thu, 23 Aug 2012 16:23:19 +0000 (20:23 +0400)
committerAndrew Dolgov <fox@fakecake.org>
Thu, 23 Aug 2012 16:23:19 +0000 (20:23 +0400)
classes/pref/prefs.php
include/functions.php
js/prefs.js
tt-rss.css

index ff8a17cdb9614e0cc30a58fcc90332e78add49b8..e30a82575082defa8fece2d5baffc1ad2e9486db 100644 (file)
@@ -2,7 +2,7 @@
 class Pref_Prefs extends Handler_Protected {
 
        function csrf_ignore($method) {
-               $csrf_ignored = array("index");
+               $csrf_ignored = array("index", "updateself");
 
                return array_search($method, $csrf_ignored) !== false;
        }
@@ -489,11 +489,60 @@ class Pref_Prefs extends Handler_Protected {
 
                print '</div>'; # inner pane
                print '</div>'; # border container
-
                print "</form>";
 
                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(__("You are currently using latest version of Tiny Tiny RSS. Update not required."));
+                       }
+
+                       print "</div>"; #pane
+               }
+
                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 "<pre class='selfUpdateList' id='self_update_log'>";
+               print __("Ready to update.")."\n";
+               print "</pre>";
+
+               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 onclick=\"return dijit.byId('updateSelfDlg').close()\" dojoType=\"dijit.form.Button\">".
+                       __("Close this window")."</button>";
+               print "</div>";
+               print "</form>";
+       }
+
+       function performUpdate() {
+               if (($_SESSION["access_level"] >= 10 || SINGLE_USER_MODE) && CHECK_FOR_NEW_VERSION) {
+                       include "update_self.php";
+                       update_self($this->link, true);
+               }
+       }
+
 }
 ?>
index 69b481ac46c5c46b192722d34b10e891c5f6e341..b2e9e8992f1e09afd7052939dd821fa756a8ae98 100644 (file)
                                $data['new_version_available'] = (int) ($new_version_details != false);
 
                                $_SESSION["last_version_check"] = time();
+                               $_SESSION["version_data"] = $new_version_details;
                }
 
                return $data;
index f7a68bf6de237c8bd80ee22fdc9930083fc8174b..10e33f701b2a1fe6a9c5c306bcd85c7aae3cde49 100644 (file)
@@ -2130,3 +2130,50 @@ 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() {
+                               dijit.byId("self_update_start_btn").attr("disabled", true);
+                               notify_progress("Loading, please wait...", true);
+                               new Ajax.Request("backend.php", {
+                               parameters: "?op=pref-prefs&method=performUpdate",
+                               onComplete: function(transport) {
+                                       try {
+                                               notify('');
+                                               $("self_update_log").innerHTML = transport.responseText;
+                                               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();
+                               }
+                       },
+                       href: query});
+
+               dialog.show();
+       } catch (e) {
+               exception_error("batchSubscribe", e);
+       }
+}
+
index b3ba4315f653b329b6a067b165035fe1f2d43055..abc6050bf329d9eda174965f0c3723b759ef623b 100644 (file)
@@ -678,6 +678,17 @@ ul.feedErrorsList {
        padding : 5px;
 }
 
+pre.selfUpdateList {
+       height : 200px;
+       font-size : 10px;
+       overflow : auto;
+       list-style-type : none;
+       border : 1px solid #c0c0c0;
+       background-color : #ecf4ff;
+       margin : 0px 0px 5px 0px;
+       padding : 5px;
+}
+
 ul.feedErrorsList em {
        color : gray;
 }