entryController.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. class entryController extends ActionController {
  3. public function readAction () {
  4. $id = Request::param ('id');
  5. $is_read = Request::param ('is_read');
  6. if ($is_read) {
  7. $is_read = true;
  8. } else {
  9. $is_read = false;
  10. }
  11. $entryDAO = new EntryDAO ();
  12. if ($id == false) {
  13. $entries = $entryDAO->listNotReadEntries ();
  14. } else {
  15. $entry = $entryDAO->searchById ($id);
  16. $entries = $entry !== false ? array ($entry) : array ();
  17. }
  18. foreach ($entries as $entry) {
  19. $values = array (
  20. 'is_read' => $is_read,
  21. );
  22. $entryDAO->updateEntry ($entry->id (), $values);
  23. }
  24. Request::forward (array (), true);
  25. }
  26. public function bookmarkAction () {
  27. $id = Request::param ('id');
  28. $is_fav = Request::param ('is_favorite');
  29. if ($is_fav) {
  30. $is_fav = true;
  31. } else {
  32. $is_fav = false;
  33. }
  34. $entryDAO = new EntryDAO ();
  35. if ($id != false) {
  36. $entry = $entryDAO->searchById ($id);
  37. if ($entry != false) {
  38. $values = array (
  39. 'is_favorite' => $is_fav,
  40. );
  41. $entryDAO->updateEntry ($entry->id (), $values);
  42. }
  43. }
  44. Request::forward (array (), true);
  45. }
  46. }