aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/poche/Poche.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/poche/Poche.class.php')
-rw-r--r--inc/poche/Poche.class.php19
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 }