entryController.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. if ($typeGet == 'c') {
  45. $entryDAO->markReadCat ($get, $idMax);
  46. $this->params = array ('get' => $nextGet);
  47. } elseif ($typeGet == 'f') {
  48. $entryDAO->markReadFeed ($get, $idMax);
  49. $this->params = array ('get' => $nextGet);
  50. }
  51. }
  52. $notif = array (
  53. 'type' => 'good',
  54. 'content' => Translate::t ('feeds_marked_read')
  55. );
  56. Session::_param ('notification', $notif);
  57. } else {
  58. $entryDAO->markRead ($id, $is_read);
  59. }
  60. }
  61. public function bookmarkAction () {
  62. $this->redirect = true;
  63. $id = Request::param ('id');
  64. if ($id) {
  65. $entryDAO = new EntryDAO ();
  66. $entryDAO->markFavorite ($id, Request::param ('is_favorite'));
  67. }
  68. }
  69. public function optimizeAction() {
  70. // La table des entrées a tendance à grossir énormément
  71. // Cette action permet d'optimiser cette table permettant de grapiller un peu de place
  72. // Cette fonctionnalité n'est à appeler qu'occasionnellement
  73. $entryDAO = new EntryDAO();
  74. $entryDAO->optimizeTable();
  75. touch(DATA_PATH . '/touch.txt');
  76. $notif = array (
  77. 'type' => 'good',
  78. 'content' => Translate::t ('optimization_complete')
  79. );
  80. Session::_param ('notification', $notif);
  81. Request::forward(array(
  82. 'c' => 'configure',
  83. 'a' => 'display'
  84. ), true);
  85. }
  86. }