aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rwxr-xr-xinc/poche/Poche.class.php69
-rwxr-xr-xinc/poche/Routing.class.php3
2 files changed, 56 insertions, 16 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index 75766919..8b0d3a19 100755
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -180,6 +180,13 @@ class Poche
180 } 180 }
181 } 181 }
182 182
183 // if there are tags, add them to the new article
184 if (isset($_GET['tags'])) {
185 $_POST['value'] = $_GET['tags'];
186 $_POST['entry_id'] = $last_id;
187 $this->action('add_tag', $url);
188 }
189
183 $this->messages->add('s', _('the link has been added successfully')); 190 $this->messages->add('s', _('the link has been added successfully'));
184 } 191 }
185 else { 192 else {
@@ -194,18 +201,31 @@ class Poche
194 } 201 }
195 break; 202 break;
196 case 'delete': 203 case 'delete':
197 $msg = 'delete link #' . $id; 204 if (isset($_GET['search'])) {
198 if ($this->store->deleteById($id, $this->user->getId())) { 205 //when we want to apply a delete to a search
199 if (DOWNLOAD_PICTURES) { 206 $tags = array($_GET['search']);
200 Picture::removeDirectory(ABS_PATH . $id); 207 $allentry_ids = $this->store->search($tags[0], $this->user->getId());
208 $entry_ids = array();
209 foreach ($allentry_ids as $eachentry) {
210 $entry_ids[] = $eachentry[0];
201 } 211 }
202 $this->messages->add('s', _('the link has been deleted successfully')); 212 } else { // delete a single article
213 $entry_ids = array($id);
203 } 214 }
204 else { 215 foreach($entry_ids as $id) {
205 $this->messages->add('e', _('the link wasn\'t deleted')); 216 $msg = 'delete link #' . $id;
206 $msg = 'error : can\'t delete link #' . $id; 217 if ($this->store->deleteById($id, $this->user->getId())) {
218 if (DOWNLOAD_PICTURES) {
219 Picture::removeDirectory(ABS_PATH . $id);
220 }
221 $this->messages->add('s', _('the link has been deleted successfully'));
222 }
223 else {
224 $this->messages->add('e', _('the link wasn\'t deleted'));
225 $msg = 'error : can\'t delete link #' . $id;
226 }
227 Tools::logm($msg);
207 } 228 }
208 Tools::logm($msg);
209 Tools::redirect('?'); 229 Tools::redirect('?');
210 break; 230 break;
211 case 'toggle_fav' : 231 case 'toggle_fav' :
@@ -220,8 +240,21 @@ class Poche
220 } 240 }
221 break; 241 break;
222 case 'toggle_archive' : 242 case 'toggle_archive' :
223 $this->store->archiveById($id, $this->user->getId()); 243 if (isset($_GET['tag_id'])) {
224 Tools::logm('archive link #' . $id); 244 //when we want to archive a whole tag
245 $tag_id = $_GET['tag_id'];
246 $allentry_ids = $this->store->retrieveEntriesByTag($tag_id, $this->user->getId());
247 $entry_ids = array();
248 foreach ($allentry_ids as $eachentry) {
249 $entry_ids[] = $eachentry[0];
250 }
251 } else { //archive a single article
252 $entry_ids = array($id);
253 }
254 foreach($entry_ids as $id) {
255 $this->store->archiveById($id, $this->user->getId());
256 Tools::logm('archive link #' . $id);
257 }
225 if ( Tools::isAjaxRequest() ) { 258 if ( Tools::isAjaxRequest() ) {
226 echo 1; 259 echo 1;
227 exit; 260 exit;
@@ -753,10 +786,11 @@ class Poche
753 * 786 *
754 * @param $token 787 * @param $token
755 * @param $user_id 788 * @param $user_id
756 * @param $tag_id 789 * @param $tag_id if $type is 'tag', the id of the tag to generate feed for
757 * @param string $type 790 * @param string $type the type of feed to generate
791 * @param int $limit the maximum number of items (0 means all)
758 */ 792 */
759 public function generateFeeds($token, $user_id, $tag_id, $type = 'home') 793 public function generateFeeds($token, $user_id, $tag_id, $type = 'home', $limit = 0)
760 { 794 {
761 $allowed_types = array('home', 'fav', 'archive', 'tag'); 795 $allowed_types = array('home', 'fav', 'archive', 'tag');
762 $config = $this->store->getConfigUser($user_id); 796 $config = $this->store->getConfigUser($user_id);
@@ -783,8 +817,13 @@ class Poche
783 $entries = $this->store->getEntriesByView($type, $user_id); 817 $entries = $this->store->getEntriesByView($type, $user_id);
784 } 818 }
785 819
820 // if $limit is set to zero, use all entries
821 if (0 == $limit) {
822 $limit = count($entries);
823 }
786 if (count($entries) > 0) { 824 if (count($entries) > 0) {
787 foreach ($entries as $entry) { 825 for ($i = 0; $i < min(count($entries), $limit); $i++) {
826 $entry = $entries[$i];
788 $newItem = $feed->createNewItem(); 827 $newItem = $feed->createNewItem();
789 $newItem->setTitle($entry['title']); 828 $newItem->setTitle($entry['title']);
790 $newItem->setSource(Tools::getPocheUrl() . '?view=view&amp;id=' . $entry['id']); 829 $newItem->setSource(Tools::getPocheUrl() . '?view=view&amp;id=' . $entry['id']);
diff --git a/inc/poche/Routing.class.php b/inc/poche/Routing.class.php
index 5acd08ba..be06a433 100755
--- a/inc/poche/Routing.class.php
+++ b/inc/poche/Routing.class.php
@@ -102,7 +102,8 @@ class Routing
102 $this->wallabag->login($this->referer); 102 $this->wallabag->login($this->referer);
103 } elseif (isset($_GET['feed']) && isset($_GET['user_id'])) { 103 } elseif (isset($_GET['feed']) && isset($_GET['user_id'])) {
104 $tag_id = (isset($_GET['tag_id']) ? intval($_GET['tag_id']) : 0); 104 $tag_id = (isset($_GET['tag_id']) ? intval($_GET['tag_id']) : 0);
105 $this->wallabag->generateFeeds($_GET['token'], filter_var($_GET['user_id'],FILTER_SANITIZE_NUMBER_INT), $tag_id, $_GET['type']); 105 $limit = (isset($_GET['limit']) ? intval($_GET['limit']) : 0);
106 $this->wallabag->generateFeeds($_GET['token'], filter_var($_GET['user_id'],FILTER_SANITIZE_NUMBER_INT), $tag_id, $_GET['type'], $limit);
106 } 107 }
107 108
108 //allowed ONLY to logged in user 109 //allowed ONLY to logged in user