entryController.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 (Translate::t ('access_denied')))
  8. );
  9. }
  10. $this->params = array ();
  11. $this->redirect = false;
  12. $ajax = Request::param ('ajax');
  13. if ($ajax) {
  14. $this->view->_useLayout (false);
  15. }
  16. }
  17. public function lastAction () {
  18. $ajax = Request::param ('ajax');
  19. if (!$ajax && $this->redirect) {
  20. Request::forward (array (
  21. 'c' => 'index',
  22. 'a' => 'index',
  23. 'params' => $this->params
  24. ), true);
  25. } else {
  26. Request::_param ('ajax');
  27. }
  28. }
  29. public function readAction () {
  30. $this->redirect = true;
  31. $id = Request::param ('id');
  32. $is_read = Request::param ('is_read');
  33. $get = Request::param ('get');
  34. $nextGet = Request::param ('nextGet', $get);
  35. $dateMax = Request::param ('dateMax', 0);
  36. $is_read = !!$is_read;
  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' => $nextGet);
  47. } elseif ($typeGet == 'f') {
  48. $entryDAO->markReadFeed ($get, $is_read, $dateMax);
  49. $this->params = array ('get' => $nextGet);
  50. }
  51. }
  52. // notif
  53. $notif = array (
  54. 'type' => 'good',
  55. 'content' => Translate::t ('feeds_marked_read')
  56. );
  57. Session::_param ('notification', $notif);
  58. } else {
  59. $entryDAO->updateEntry ($id, array ('is_read' => $is_read));
  60. }
  61. }
  62. public function bookmarkAction () {
  63. $this->redirect = true;
  64. $id = Request::param ('id');
  65. if ($id) {
  66. $entryDAO = new EntryDAO ();
  67. $values = array (
  68. 'is_favorite' => (bool)(Request::param ('is_favorite')),
  69. );
  70. $entryDAO->updateEntry ($id, $values);
  71. }
  72. }
  73. public function optimizeAction() {
  74. // La table des entrées a tendance à grossir énormément
  75. // Cette action permet d'optimiser cette table permettant de grapiller un peu de place
  76. // Cette fonctionnalité n'est à appeler qu'occasionnellement
  77. $entryDAO = new EntryDAO();
  78. $entryDAO->optimizeTable();
  79. $notif = array (
  80. 'type' => 'good',
  81. 'content' => Translate::t ('optimization_complete')
  82. );
  83. Session::_param ('notification', $notif);
  84. Request::forward(array(
  85. 'c' => 'configure',
  86. 'a' => 'display'
  87. ), true);
  88. }
  89. }