entryController.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 (
  19. 'c' => 'index',
  20. 'a' => 'index',
  21. 'params' => $this->params
  22. ), true);
  23. } else {
  24. Request::_param ('ajax');
  25. }
  26. }
  27. public function readAction () {
  28. $id = Request::param ('id');
  29. $is_read = Request::param ('is_read');
  30. $get = Request::param ('get');
  31. $dateMax = Request::param ('dateMax', time ());
  32. if ($is_read) {
  33. $is_read = true;
  34. } else {
  35. $is_read = false;
  36. }
  37. $entryDAO = new EntryDAO ();
  38. if ($id == false) {
  39. if (!$get) {
  40. $entryDAO->markReadEntries ($is_read, $dateMax);
  41. } else {
  42. $typeGet = $get[0];
  43. $get = substr ($get, 2);
  44. if ($typeGet == 'c') {
  45. $entryDAO->markReadCat ($get, $is_read, $dateMax);
  46. $this->params = array ('get' => 'c_' . $get);
  47. } elseif ($typeGet == 'f') {
  48. $entryDAO->markReadFeed ($get, $is_read, $dateMax);
  49. $this->params = array ('get' => 'f_' . $get);
  50. }
  51. }
  52. // notif
  53. $notif = array (
  54. 'type' => 'good',
  55. 'content' => 'Les flux ont été marqués comme lu'
  56. );
  57. Session::_param ('notification', $notif);
  58. } else {
  59. $entryDAO->updateEntry ($id, array ('is_read' => $is_read));
  60. }
  61. }
  62. public function bookmarkAction () {
  63. $id = Request::param ('id');
  64. $is_fav = Request::param ('is_favorite');
  65. if ($is_fav) {
  66. $is_fav = true;
  67. } else {
  68. $is_fav = false;
  69. }
  70. $entryDAO = new EntryDAO ();
  71. if ($id != false) {
  72. $entry = $entryDAO->searchById ($id);
  73. if ($entry != false) {
  74. $values = array (
  75. 'is_favorite' => $is_fav,
  76. );
  77. $entryDAO->updateEntry ($entry->id (), $values);
  78. }
  79. }
  80. }
  81. }