entryController.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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', time ());
  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. $is_fav = Request::param ('is_favorite');
  66. if ($is_fav) {
  67. $is_fav = true;
  68. } else {
  69. $is_fav = false;
  70. }
  71. $entryDAO = new EntryDAO ();
  72. if ($id != false) {
  73. $entry = $entryDAO->searchById ($id);
  74. if ($entry != false) {
  75. $values = array (
  76. 'is_favorite' => $is_fav,
  77. 'lastUpdate' => time ()
  78. );
  79. $entryDAO->updateEntry ($entry->id (), $values);
  80. }
  81. }
  82. }
  83. public function optimizeAction() {
  84. // La table des entrées a tendance à grossir énormément
  85. // Cette action permet d'optimiser cette table permettant de grapiller un peu de place
  86. // Cette fonctionnalité n'est à appeler qu'occasionnellement
  87. $entryDAO = new EntryDAO();
  88. $entryDAO->optimizeTable();
  89. $notif = array (
  90. 'type' => 'good',
  91. 'content' => Translate::t ('optimization_complete')
  92. );
  93. Session::_param ('notification', $notif);
  94. Request::forward(array(
  95. 'c' => 'configure',
  96. 'a' => 'display'
  97. ), true);
  98. }
  99. }