entryController.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. class entryController extends ActionController {
  3. public function firstAction () {
  4. if (login_is_conf ($this->view->conf) && !is_logged ()) {
  5. Error::error (
  6. 403,
  7. array ('error' => array ('Vous n\'avez pas le droit d\'accéder à cette page'))
  8. );
  9. }
  10. $ajax = Request::param ('ajax');
  11. if ($ajax) {
  12. $this->view->_useLayout (false);
  13. }
  14. }
  15. public function lastAction () {
  16. $ajax = Request::param ('ajax');
  17. if (!$ajax) {
  18. Request::forward (array (), true);
  19. } else {
  20. Request::_param ('ajax');
  21. }
  22. }
  23. public function readAction () {
  24. $id = Request::param ('id');
  25. $is_read = Request::param ('is_read');
  26. if ($is_read) {
  27. $is_read = true;
  28. } else {
  29. $is_read = false;
  30. }
  31. $values = array (
  32. 'is_read' => $is_read,
  33. );
  34. $entryDAO = new EntryDAO ();
  35. if ($id == false) {
  36. $entryDAO->updateEntries ($values);
  37. // notif
  38. $notif = array (
  39. 'type' => 'good',
  40. 'content' => 'Tous les flux ont été marqués comme lu'
  41. );
  42. Session::_param ('notification', $notif);
  43. } else {
  44. $entryDAO->updateEntry ($id, $values);
  45. }
  46. }
  47. public function bookmarkAction () {
  48. $id = Request::param ('id');
  49. $is_fav = Request::param ('is_favorite');
  50. if ($is_fav) {
  51. $is_fav = true;
  52. } else {
  53. $is_fav = false;
  54. }
  55. $entryDAO = new EntryDAO ();
  56. if ($id != false) {
  57. $entry = $entryDAO->searchById ($id);
  58. if ($entry != false) {
  59. $values = array (
  60. 'is_favorite' => $is_fav,
  61. );
  62. $entryDAO->updateEntry ($entry->id (), $values);
  63. }
  64. }
  65. }
  66. }