entryController.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. $idMax = Request::param ('idMax', 0);
  36. $is_read = !!$is_read;
  37. $entryDAO = new EntryDAO ();
  38. if ($id == false) {
  39. if (!$get) {
  40. $entryDAO->markReadEntries ($idMax);
  41. } else {
  42. $typeGet = $get[0];
  43. $get = substr ($get, 2);
  44. switch ($typeGet) {
  45. case 'c':
  46. $entryDAO->markReadCat ($get, $idMax);
  47. break;
  48. case 'f':
  49. $entryDAO->markReadFeed ($get, $idMax);
  50. break;
  51. case 's':
  52. $entryDAO->markReadEntries ($idMax, true);
  53. break;
  54. case 'a':
  55. $entryDAO->markReadEntries ($idMax);
  56. break;
  57. }
  58. $this->params = array ('get' => $nextGet);
  59. }
  60. $notif = array (
  61. 'type' => 'good',
  62. 'content' => Translate::t ('feeds_marked_read')
  63. );
  64. Session::_param ('notification', $notif);
  65. } else {
  66. $entryDAO->markRead ($id, $is_read);
  67. }
  68. }
  69. public function bookmarkAction () {
  70. $this->redirect = true;
  71. $id = Request::param ('id');
  72. if ($id) {
  73. $entryDAO = new EntryDAO ();
  74. $entryDAO->markFavorite ($id, Request::param ('is_favorite'));
  75. }
  76. }
  77. public function optimizeAction() {
  78. // La table des entrées a tendance à grossir énormément
  79. // Cette action permet d'optimiser cette table permettant de grapiller un peu de place
  80. // Cette fonctionnalité n'est à appeler qu'occasionnellement
  81. $entryDAO = new EntryDAO();
  82. $entryDAO->optimizeTable();
  83. invalidateHttpCache();
  84. $notif = array (
  85. 'type' => 'good',
  86. 'content' => Translate::t ('optimization_complete')
  87. );
  88. Session::_param ('notification', $notif);
  89. Request::forward(array(
  90. 'c' => 'configure',
  91. 'a' => 'display'
  92. ), true);
  93. }
  94. }