]> git.wh0rd.org - tt-rss.git/blobdiff - classes/pref_feeds.php
implement experimental personal data import
[tt-rss.git] / classes / pref_feeds.php
index 783d29f791b3cb5b8a9906b2a58742731dd1ad53..f5cb6e64983866840c312934d0dbedd889fd1135 100644 (file)
@@ -1,5 +1,12 @@
 <?php
 class Pref_Feeds extends Protected_Handler {
+
+       function csrf_ignore($method) {
+               $csrf_ignored = array("index", "getfeedtree", "add", "editcats", "editfeed");
+
+               return array_search($method, $csrf_ignored) !== false;
+       }
+
        function batch_edit_cbox($elem, $label = false) {
                print "<input type=\"checkbox\" title=\"".__("Check to enable field")."\"
                        onchange=\"dijit.byId('feedEditDlg').toggleField(this, '$elem', '$label')\">";
@@ -441,12 +448,10 @@ class Pref_Feeds extends Protected_Handler {
                        $checked = "";
                }
 
-               if (SIMPLEPIE_CACHE_IMAGES) {
-                       print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"cache_images\"
-                       name=\"cache_images\"
+               print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"cache_images\"
+               name=\"cache_images\"
                        $checked>&nbsp;<label for=\"cache_images\">".
-                       __('Cache images locally (SimplePie only)')."</label>";
-               }
+               __('Cache images locally')."</label>";
 
                $mark_unread_on_update = sql_bool_to_bool(db_fetch_result($result, 0, "mark_unread_on_update"));
 
@@ -648,16 +653,13 @@ class Pref_Feeds extends Protected_Handler {
 
                print "&nbsp;"; $this->batch_edit_cbox("always_display_enclosures", "always_display_enclosures_l");
 
-               if (SIMPLEPIE_CACHE_IMAGES) {
-                       print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"cache_images\"
-                               name=\"cache_images\"
-                               dojoType=\"dijit.form.CheckBox\">&nbsp;<label class='insensitive' id=\"cache_images_l\"
-                               for=\"cache_images\">".
-                       __('Cache images locally')."</label>";
+               print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"cache_images\"
+                       name=\"cache_images\"
+                       dojoType=\"dijit.form.CheckBox\">&nbsp;<label class='insensitive' id=\"cache_images_l\"
+                       for=\"cache_images\">".
+               __('Cache images locally')."</label>";
 
-
-                       print "&nbsp;"; $this->batch_edit_cbox("cache_images", "cache_images_l");
-               }
+               print "&nbsp;"; $this->batch_edit_cbox("cache_images", "cache_images_l");
 
                print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"mark_unread_on_update\"
                        name=\"mark_unread_on_update\"
@@ -686,11 +688,11 @@ class Pref_Feeds extends Protected_Handler {
        }
 
        function batchEditSave() {
-               return editsaveops(true);
+               return $this->editsaveops(true);
        }
 
        function editSave() {
-               return editsaveops(false);
+               return $this->editsaveops(false);
        }
 
        function editsaveops($batch) {
@@ -734,13 +736,9 @@ class Pref_Feeds extends Protected_Handler {
                        $category_qpart_nocomma = "";
                }
 
-               if (SIMPLEPIE_CACHE_IMAGES) {
-                       $cache_images_qpart = "cache_images = $cache_images,";
-               } else {
-                       $cache_images_qpart = "";
-               }
+               $cache_images_qpart = "cache_images = $cache_images,";
 
-               if ($method == "editSave") {
+               if (!$batch) {
 
                        $result = db_query($this->link, "UPDATE ttrss_feeds SET
                                $category_qpart
@@ -759,7 +757,7 @@ class Pref_Feeds extends Protected_Handler {
                                update_method = '$update_method'
                                WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
 
-               } else if ($batch) {
+               } else {
                        $feed_data = array();
 
                        foreach (array_keys($_POST) as $k) {
@@ -1400,26 +1398,26 @@ class Pref_Feeds extends Protected_Handler {
 
                print "</div>"; # feeds pane
 
-               print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('OPML')."\">";
+               print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Import and export')."\">";
 
-               print "<p>" . __("Using OPML you can export and import your feeds and Tiny Tiny RSS settings.") . " ";
+               print "<h2>" . __("OPML") . "</h2>";
 
-               print "<span class=\"insensitive\">" . __("Note: Only main settings profile can be migrated using OPML.") . "</span>";
+               print "<h3>" . __("Import") . "</h3>";
 
-               print "</p>";
+               print "<p>" . __("Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings.") . " ";
 
-               print "<h3>" . __("Import") . "</h3>";
+               print __("Only main settings profile can be migrated using OPML.") . "</p>";
 
-               print "<br/><iframe id=\"upload_iframe\"
+               print "<iframe id=\"upload_iframe\"
                        name=\"upload_iframe\" onload=\"opmlImportComplete(this)\"
                        style=\"width: 400px; height: 100px; display: none;\"></iframe>";
 
                print "<form  name=\"opml_form\" style='display : block' target=\"upload_iframe\"
                        enctype=\"multipart/form-data\" method=\"POST\"
-                               action=\"backend.php\">
+                       action=\"backend.php\">
                        <input id=\"opml_file\" name=\"opml_file\" type=\"file\">&nbsp;
                        <input type=\"hidden\" name=\"op\" value=\"dlg\">
-                       <input type=\"hidden\" name=\"id\" value=\"importOpml\">
+                       <input type=\"hidden\" name=\"method\" value=\"importOpml\">
                        <button dojoType=\"dijit.form.Button\" onclick=\"return opmlImport();\" type=\"submit\">" .
                        __('Import') . "</button>";
 
@@ -1437,12 +1435,37 @@ class Pref_Feeds extends Protected_Handler {
 
                print "<p>".__('Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.') . " ";
 
-               print "<span class=\"insensitive\">" . __("Note: Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds.") .                         "</span>" . "</p>";
+               print __("Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds.") . "</p>";
 
                print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('pubOPMLUrl')\">".
                        __('Display URL')."</button> ";
 
 
+               print "<h2>" . __("Article archive") . "</h2>";
+
+               print "<p>" . __("You can export your Starred and Archived articles using neutral storage format. Please note that import and export of such data is only supported between same tt-rss versions.") . "</p>";
+
+               print "<h3>" . __("Export") . "</h3>";
+
+               print "<button dojoType=\"dijit.form.Button\" onclick=\"return exportData()\">".
+                       __('Export my data')."</button> ";
+
+               print "<h3>" . __("Import") . "</h3>";
+
+               print "<iframe id=\"data_upload_iframe\"
+                       name=\"data_upload_iframe\" onload=\"dataImportComplete(this)\"
+                       style=\"width: 400px; height: 100px; display: none;\"></iframe>";
+
+               print "<form  name=\"opml_form\" style='display : block' target=\"data_upload_iframe\"
+                       enctype=\"multipart/form-data\" method=\"POST\"
+                       action=\"backend.php\">
+                       <input id=\"export_file\" name=\"export_file\" type=\"file\">&nbsp;
+                       <input type=\"hidden\" name=\"op\" value=\"dlg\">
+                       <input type=\"hidden\" name=\"method\" value=\"dataimport\">
+                       <button dojoType=\"dijit.form.Button\" onclick=\"return importData();\" type=\"submit\">" .
+                       __('Import') . "</button>";
+
+
                print "</div>"; # pane
 
                if (strpos($_SERVER['HTTP_USER_AGENT'], "Firefox") !== false) {