entryController.php 2.6 KB

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