diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2014-02-18 15:29:40 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2014-02-18 15:29:40 +0100 |
commit | 970cfb11661e20027ef4c6b3912dfe2dbafb8c0b (patch) | |
tree | f84989877616550814e9e46a5316f6e95126951a /inc/poche/Poche.class.php | |
parent | 6285e57c49bd06ed52ab997f0dc767576b7da126 (diff) | |
parent | 488fc63b67312640dcac68a324794ec4a591ba6d (diff) | |
download | wallabag-970cfb11661e20027ef4c6b3912dfe2dbafb8c0b.tar.gz wallabag-970cfb11661e20027ef4c6b3912dfe2dbafb8c0b.tar.zst wallabag-970cfb11661e20027ef4c6b3912dfe2dbafb8c0b.zip |
Merge pull request #460 from mariroz/dev
duplicate check added. fix of issue #400
Diffstat (limited to 'inc/poche/Poche.class.php')
-rw-r--r-- | inc/poche/Poche.class.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index d0e2de1f..76169297 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php | |||
@@ -374,6 +374,11 @@ class Poche | |||
374 | $title = ($content['rss']['channel']['item']['title'] != '') ? $content['rss']['channel']['item']['title'] : _('Untitled'); | 374 | $title = ($content['rss']['channel']['item']['title'] != '') ? $content['rss']['channel']['item']['title'] : _('Untitled'); |
375 | $body = $content['rss']['channel']['item']['description']; | 375 | $body = $content['rss']['channel']['item']['description']; |
376 | 376 | ||
377 | //search for possible duplicate if not in import mode | ||
378 | if (!$import) { | ||
379 | $duplicate = $this->store->retrieveOneByURL($url->getUrl(), $this->user->getId()); | ||
380 | } | ||
381 | |||
377 | if ($this->store->add($url->getUrl(), $title, $body, $this->user->getId())) { | 382 | if ($this->store->add($url->getUrl(), $title, $body, $this->user->getId())) { |
378 | Tools::logm('add link ' . $url->getUrl()); | 383 | Tools::logm('add link ' . $url->getUrl()); |
379 | $sequence = ''; | 384 | $sequence = ''; |
@@ -386,6 +391,20 @@ class Poche | |||
386 | Tools::logm('updating content article'); | 391 | Tools::logm('updating content article'); |
387 | $this->store->updateContent($last_id, $content, $this->user->getId()); | 392 | $this->store->updateContent($last_id, $content, $this->user->getId()); |
388 | } | 393 | } |
394 | |||
395 | if ($duplicate != NULL) { | ||
396 | // duplicate exists, so, older entry needs to be deleted (as new entry should go to the top of list), BUT favorite mark and tags should be preserved | ||
397 | Tools::logm('link ' . $url->getUrl() . ' is a duplicate'); | ||
398 | // 1) - preserve tags and favorite, then drop old entry | ||
399 | $this->store->reassignTags($duplicate['id'], $last_id); | ||
400 | if ($duplicate['is_fav']) { | ||
401 | $this->store->favoriteById($last_id, $this->user->getId()); | ||
402 | } | ||
403 | if ($this->store->deleteById($duplicate['id'], $this->user->getId())) { | ||
404 | Tools::logm('previous link ' . $url->getUrl() .' entry deleted'); | ||
405 | } | ||
406 | } | ||
407 | |||
389 | if (!$import) { | 408 | if (!$import) { |
390 | $this->messages->add('s', _('the link has been added successfully')); | 409 | $this->messages->add('s', _('the link has been added successfully')); |
391 | } | 410 | } |