diff options
Diffstat (limited to 'inc/poche')
-rwxr-xr-x | inc/poche/Poche.class.php | 55 |
1 files changed, 44 insertions, 11 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index a29cb327..20897c61 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; |