aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xinc/poche/Poche.class.php21
-rwxr-xr-xinc/poche/Routing.class.php4
2 files changed, 15 insertions, 10 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index fd2600f3..30d42c61 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) {
diff --git a/inc/poche/Routing.class.php b/inc/poche/Routing.class.php
index 177b74d5..0d33cdc3 100755
--- a/inc/poche/Routing.class.php
+++ b/inc/poche/Routing.class.php
@@ -111,9 +111,7 @@ class Routing
111 $tag_id = (isset($_GET['tag_id']) ? intval($_GET['tag_id']) : 0); 111 $tag_id = (isset($_GET['tag_id']) ? intval($_GET['tag_id']) : 0);
112 $limit = (isset($_GET['limit']) ? intval($_GET['limit']) : 0); 112 $limit = (isset($_GET['limit']) ? intval($_GET['limit']) : 0);
113 $this->wallabag->generateFeeds($_GET['token'], filter_var($_GET['user_id'],FILTER_SANITIZE_NUMBER_INT), $tag_id, $_GET['type'], $limit); 113 $this->wallabag->generateFeeds($_GET['token'], filter_var($_GET['user_id'],FILTER_SANITIZE_NUMBER_INT), $tag_id, $_GET['type'], $limit);
114 } //elseif (ALLOW_REGISTER && isset($_GET['register'])) { 114 }
115 //$this->wallabag->register
116 //}
117 115
118 //allowed ONLY to logged in user 116 //allowed ONLY to logged in user
119 if (\Session::isLogged() === true) 117 if (\Session::isLogged() === true)