entryController.php 1.9 KB

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