aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/poche
diff options
context:
space:
mode:
Diffstat (limited to 'inc/poche')
-rwxr-xr-xinc/poche/Poche.class.php21
1 files changed, 14 insertions, 7 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index 9424e3ff..6a48f2ad 100755
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -200,27 +200,34 @@ class Poche
200 200
201 //search for possible duplicate 201 //search for possible duplicate
202 $duplicate = NULL; 202 $duplicate = NULL;
203 $duplicate = $this->store->retrieveOneByURL($url->getUrl(), $this->user->getId()); 203 $clean_url = $url->getUrl();
204 204
205 $last_id = $this->store->add($url->getUrl(), $title, $body, $this->user->getId()); 205 // Clean URL to remove parameters from feedburner and all this stuff. Taken from Shaarli.
206 $i=strpos($clean_url,'&utm_source='); if ($i!==false) $clean_url=substr($clean_url,0,$i);
207 $i=strpos($clean_url,'?utm_source='); if ($i!==false) $clean_url=substr($clean_url,0,$i);
208 $i=strpos($clean_url,'#xtor=RSS-'); if ($i!==false) $clean_url=substr($clean_url,0,$i);
209
210 $duplicate = $this->store->retrieveOneByURL($clean_url, $this->user->getId());
211
212 $last_id = $this->store->add($clean_url, $title, $body, $this->user->getId());
206 if ( $last_id ) { 213 if ( $last_id ) {
207 Tools::logm('add link ' . $url->getUrl()); 214 Tools::logm('add link ' . $clean_url);
208 if (DOWNLOAD_PICTURES) { 215 if (DOWNLOAD_PICTURES) {
209 $content = Picture::filterPicture($body, $url->getUrl(), $last_id); 216 $content = Picture::filterPicture($body, $clean_url, $last_id);
210 Tools::logm('updating content article'); 217 Tools::logm('updating content article');
211 $this->store->updateContent($last_id, $content, $this->user->getId()); 218 $this->store->updateContent($last_id, $content, $this->user->getId());
212 } 219 }
213 220
214 if ($duplicate != NULL) { 221 if ($duplicate != NULL) {
215 // 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 222 // 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
216 Tools::logm('link ' . $url->getUrl() . ' is a duplicate'); 223 Tools::logm('link ' . $clean_url . ' is a duplicate');
217 // 1) - preserve tags and favorite, then drop old entry 224 // 1) - preserve tags and favorite, then drop old entry
218 $this->store->reassignTags($duplicate['id'], $last_id); 225 $this->store->reassignTags($duplicate['id'], $last_id);
219 if ($duplicate['is_fav']) { 226 if ($duplicate['is_fav']) {
220 $this->store->favoriteById($last_id, $this->user->getId()); 227 $this->store->favoriteById($last_id, $this->user->getId());
221 } 228 }
222 if ($this->store->deleteById($duplicate['id'], $this->user->getId())) { 229 if ($this->store->deleteById($duplicate['id'], $this->user->getId())) {
223 Tools::logm('previous link ' . $url->getUrl() .' entry deleted'); 230 Tools::logm('previous link ' . $clean_url .' entry deleted');
224 } 231 }
225 } 232 }
226 233
@@ -235,7 +242,7 @@ class Poche
235 } 242 }
236 else { 243 else {
237 $this->messages->add('e', _('error during insertion : the link wasn\'t added')); 244 $this->messages->add('e', _('error during insertion : the link wasn\'t added'));
238 Tools::logm('error during insertion : the link wasn\'t added ' . $url->getUrl()); 245 Tools::logm('error during insertion : the link wasn\'t added ' . $clean_url);
239 } 246 }
240 247
241 if ($autoclose == TRUE) { 248 if ($autoclose == TRUE) {