]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Feature #457 : import from pocket now import tags too 459/head
authorarnaudmm <arnaudmm@gmail.com>
Fri, 14 Feb 2014 12:59:27 +0000 (13:59 +0100)
committerarnaudmm <arnaudmm@gmail.com>
Thu, 20 Feb 2014 12:09:27 +0000 (13:09 +0100)
inc/poche/Poche.class.php

index 753bd7f077619959a08cc68355f8706d2d695bb6..b6b3b73f5bb51d5d2b5cf04e15a8ab853a169f24 100644 (file)
@@ -365,7 +365,7 @@ class Poche
     /**
      * Call action (mark as fav, archive, delete, etc.)
      */
-    public function action($action, Url $url, $id = 0, $import = FALSE, $autoclose = FALSE)
+    public function action($action, Url $url, $id = 0, $import = FALSE, $autoclose = FALSE, $tags = null)
     {
         switch ($action)
         {
@@ -461,8 +461,14 @@ class Poche
                 }
                 break;
             case 'add_tag' :
-                $tags = explode(',', $_POST['value']);
-                $entry_id = $_POST['entry_id'];
+                if($import){
+                    $entry_id = $id;
+                    $tags = explode(',', $tags);
+                }
+                else{
+                    $tags = explode(',', $_POST['value']);
+                    $entry_id = $_POST['entry_id'];
+                }
                 $entry = $this->store->retrieveOneById($entry_id, $this->user->getId());
                 if (!$entry) {
                     $this->messages->add('e', _('Article not found!'));
@@ -489,7 +495,9 @@ class Poche
                     # we assign the tag to the article
                     $this->store->setTagToEntry($tag_id, $entry_id);
                 }
-                Tools::redirect();
+                if(!$import) {
+                    Tools::redirect();
+                }
                 break;
             case 'remove_tag' :
                 $tag_id = $_GET['tag_id'];
@@ -852,14 +860,18 @@ class Poche
                 $a = $li->find('a');
                 $url = new Url(base64_encode($a[0]->href));
                 $this->action('add', $url, 0, TRUE);
+                $sequence = '';
+                if (STORAGE == 'postgres') {
+                    $sequence = 'entries_id_seq';
+                }
+                $last_id = $this->store->getLastId($sequence);
                 if ($read == '1') {
-                        $sequence = '';
-                        if (STORAGE == 'postgres') {
-                            $sequence = 'entries_id_seq';
-                        }
-                    $last_id = $this->store->getLastId($sequence);
                     $this->action('toggle_archive', $url, $last_id, TRUE);
                 }
+                $tags = $a[0]->tags;
+                if(!empty($tags)) {
+                    $this->action('add_tag',$url,$last_id,true,false,$tags);
+                }
             }
             
             # the second <ul> is for read links