diff options
Diffstat (limited to 'inc/poche')
-rwxr-xr-x | inc/poche/Database.class.php | 20 | ||||
-rwxr-xr-x | inc/poche/Poche.class.php | 26 |
2 files changed, 43 insertions, 3 deletions
diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php index 65675afe..4f55a7fe 100755 --- a/inc/poche/Database.class.php +++ b/inc/poche/Database.class.php | |||
@@ -421,6 +421,26 @@ class Database { | |||
421 | return $id; | 421 | return $id; |
422 | } | 422 | } |
423 | 423 | ||
424 | public function getPreviousArticle($id, $user_id) | ||
425 | { | ||
426 | $sql = "SELECT id FROM entries WHERE id = (SELECT max(id) FROM entries WHERE id < ?) AND user_id=? AND is_read=0"; | ||
427 | $params = array($id, $user_id); | ||
428 | $query = $this->executeQuery($sql, $params); | ||
429 | $id_entry = $query->fetchAll(); | ||
430 | $id = $id_entry[0][0]; | ||
431 | return $id; | ||
432 | } | ||
433 | |||
434 | public function getNextArticle($id, $user_id) | ||
435 | { | ||
436 | $sql = "SELECT id FROM entries WHERE id = (SELECT min(id) FROM entries WHERE id > ?) AND user_id=? AND is_read=0"; | ||
437 | $params = array($id, $user_id); | ||
438 | $query = $this->executeQuery($sql, $params); | ||
439 | $id_entry = $query->fetchAll(); | ||
440 | $id = $id_entry[0][0]; | ||
441 | return $id; | ||
442 | } | ||
443 | |||
424 | 444 | ||
425 | public function updateContent($id, $content, $user_id) | 445 | public function updateContent($id, $content, $user_id) |
426 | { | 446 | { |
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 30d42c61..18e1d051 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php | |||
@@ -310,11 +310,16 @@ class Poche | |||
310 | if ( Tools::isAjaxRequest() ) { | 310 | if ( Tools::isAjaxRequest() ) { |
311 | echo 1; | 311 | echo 1; |
312 | exit; | 312 | exit; |
313 | } | 313 | } else { |
314 | else { | ||
315 | Tools::redirect(); | 314 | Tools::redirect(); |
316 | } | 315 | } |
317 | break; | 316 | break; |
317 | case 'archive_and_next' : | ||
318 | $nextid = $this->store->getNextArticle($id, $this->user->getId()); | ||
319 | $this->store->archiveById($id, $this->user->getId()); | ||
320 | Tools::logm('archive link #' . $id); | ||
321 | Tools::redirect('?view=view&id=' . $nextid); | ||
322 | break; | ||
318 | case 'archive_all' : | 323 | case 'archive_all' : |
319 | $this->store->archiveAll($this->user->getId()); | 324 | $this->store->archiveAll($this->user->getId()); |
320 | Tools::logm('archive all links'); | 325 | Tools::logm('archive all links'); |
@@ -516,6 +521,20 @@ class Poche | |||
516 | $flattr->checkItem($entry['url'], $entry['id']); | 521 | $flattr->checkItem($entry['url'], $entry['id']); |
517 | } | 522 | } |
518 | 523 | ||
524 | # previous and next | ||
525 | $previous = FALSE; | ||
526 | $previous_id = $this->store->getPreviousArticle($id, $this->user->getId()); | ||
527 | $next = FALSE; | ||
528 | $next_id = $this->store->getNextArticle($id, $this->user->getId()); | ||
529 | |||
530 | if ($this->store->retrieveOneById($previous_id, $this->user->getId())) { | ||
531 | $previous = TRUE; | ||
532 | } | ||
533 | if ($this->store->retrieveOneById($next_id, $this->user->getId())) { | ||
534 | $next = TRUE; | ||
535 | } | ||
536 | $navigate = $arrayName = array('previous' => $previous, 'previousid' => $previous_id, 'next' => $next, 'nextid' => $next_id); | ||
537 | |||
519 | # tags | 538 | # tags |
520 | $tags = $this->store->retrieveTagsByEntry($entry['id']); | 539 | $tags = $this->store->retrieveTagsByEntry($entry['id']); |
521 | 540 | ||
@@ -523,7 +542,8 @@ class Poche | |||
523 | 'entry' => $entry, | 542 | 'entry' => $entry, |
524 | 'content' => $content, | 543 | 'content' => $content, |
525 | 'flattr' => $flattr, | 544 | 'flattr' => $flattr, |
526 | 'tags' => $tags | 545 | 'tags' => $tags, |
546 | 'navigate' => $navigate | ||
527 | ); | 547 | ); |
528 | } | 548 | } |
529 | else { | 549 | else { |