action.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. <?php
  2. /*
  3. @nom: action
  4. @auteur: Idleman (idleman@idleman.fr)
  5. @description: Page de gestion des évenements non liés a une vue particulière (appels ajax, requetes sans resultats etc...)
  6. */
  7. if(!ini_get('safe_mode')) @set_time_limit(0);
  8. require_once("common.php");
  9. ///@TODO: déplacer dans common.php?
  10. $commandLine = 'cli'==php_sapi_name();
  11. if ($commandLine) {
  12. $action = 'commandLine';
  13. } else {
  14. $action = @$_['action'];
  15. }
  16. ///@TODO: pourquoi ne pas refuser l'accès dès le début ?
  17. Plugin::callHook("action_pre_case", array(&$_,$myUser));
  18. //Execution du code en fonction de l'action
  19. switch ($action){
  20. case 'commandLine':
  21. case 'synchronize':
  22. require_once("SimplePie.class.php");
  23. $syncCode = $configurationManager->get('synchronisationCode');
  24. if ( false==$myUser
  25. && !$commandLine
  26. && !(isset($_['code'])
  27. && $configurationManager->get('synchronisationCode')!=null
  28. && $_['code']==$configurationManager->get('synchronisationCode')
  29. )
  30. ) {
  31. die(_t('YOU_MUST_BE_CONNECTED_ACTION'));
  32. }
  33. Functions::triggerDirectOutput();
  34. if (!$commandLine)
  35. echo '<html>
  36. <head>
  37. <link rel="stylesheet" href="./templates/'.$theme.'/css/style.css">
  38. </head>
  39. <body>
  40. <div class="sync">';
  41. $synchronisationType = $configurationManager->get('synchronisationType');
  42. $maxEvents = $configurationManager->get('feedMaxEvents');
  43. if('graduate'==$synchronisationType){
  44. // sélectionne les 10 plus vieux flux
  45. $feeds = $feedManager->loadAll(null,'lastupdate',defined('SYNC_GRAD_COUNT') ? SYNC_GRAD_COUNT : 10);
  46. $syncTypeStr = _t('SYNCHRONISATION_TYPE').' : '._t('GRADUATE_SYNCHRONISATION');
  47. }else{
  48. // sélectionne tous les flux, triés par le nom
  49. $feeds = $feedManager->populate('name');
  50. $syncTypeStr = _t('SYNCHRONISATION_TYPE').' : '._t('FULL_SYNCHRONISATION');
  51. }
  52. $currentDate = date('d/m/Y H:i:s');
  53. if (!$commandLine) {
  54. echo "<p>{$syncTypeStr} {$currentDate}</p>\n";
  55. echo "<dl>\n";
  56. } else {
  57. echo "{$syncTypeStr}\t{$currentDate}\n";
  58. }
  59. $nbErrors = 0;
  60. $nbOk = 0;
  61. $nbTotal = 0;
  62. $localTotal = 0; // somme de tous les temps locaux, pour chaque flux
  63. $nbTotalEvents = 0;
  64. $syncId = time();
  65. $enableCache = ($configurationManager->get('synchronisationEnableCache')=='')?0:$configurationManager->get('synchronisationEnableCache');
  66. $forceFeed = ($configurationManager->get('synchronisationForceFeed')=='')?0:$configurationManager->get('synchronisationForceFeed');
  67. foreach ($feeds as $feed) {
  68. $nbEvents = 0;
  69. $nbTotal++;
  70. $startLocal = microtime(true);
  71. $parseOk = $feed->parse($syncId,$nbEvents, $enableCache, $forceFeed);
  72. $parseTime = microtime(true)-$startLocal;
  73. $localTotal += $parseTime;
  74. $parseTimeStr = number_format($parseTime, 3);
  75. if ($parseOk) { // It's ok
  76. $errors = array();
  77. $nbTotalEvents += $nbEvents;
  78. $nbOk++;
  79. } else {
  80. // tableau au cas où il arrive plusieurs erreurs
  81. $errors = array($feed->getError());
  82. $nbErrors++;
  83. }
  84. $feedName = Functions::truncate($feed->getName(),30);
  85. $feedUrl = $feed->getUrl();
  86. $feedUrlTxt = Functions::truncate($feedUrl, 30);
  87. if ($commandLine) {
  88. echo date('d/m/Y H:i:s')."\t".$parseTimeStr."\t";
  89. echo "{$feedName}\t{$feedUrlTxt}\n";
  90. } else {
  91. if (!$parseOk) echo '<div class="errorSync">';
  92. echo "<dt><i>{$parseTimeStr}s</i> | <a href='{$feedUrl}'>{$feedName}</a></dt>\n";
  93. }
  94. foreach($errors as $error) {
  95. if ($commandLine)
  96. echo "$error\n";
  97. else
  98. echo "<dd>$error</dd>\n";
  99. }
  100. if (!$parseOk && !$commandLine) echo '</div>';
  101. // if ($commandLine) echo "\n";
  102. $feed->removeOldEvents($maxEvents, $syncId);
  103. }
  104. assert('$nbTotal==$nbOk+$nbErrors');
  105. $totalTime = microtime(true)-$start;
  106. assert('$totalTime>=$localTotal');
  107. $totalTimeStr = number_format($totalTime, 3);
  108. $currentDate = date('d/m/Y H:i:s');
  109. if ($commandLine) {
  110. echo "\t{$nbErrors}\t"._t('ERRORS')."\n";
  111. echo "\t{$nbOk}\t"._t('GOOD')."\n";
  112. echo "\t{$nbTotal}\t"._t('AT_TOTAL')."\n";
  113. echo "\t$currentDate\n";
  114. echo "\t$nbTotalEvents\n";
  115. echo "\t{$totalTimeStr}\t"._t('SECONDS')."\n";
  116. } else {
  117. echo "</dl>\n";
  118. echo "<div id='syncSummary'\n";
  119. echo "<p>"._t('SYNCHRONISATION_COMPLETE')."</p>\n";
  120. echo "<ul>\n";
  121. echo "<li>{$nbErrors} "._t('ERRORS')."\n";
  122. echo "<li>{$nbOk} "._t('GOOD')."\n";
  123. echo "<li>{$nbTotal} "._t('AT_TOTAL')."\n";
  124. echo "<li>{$totalTimeStr}\t"._t('SECONDS')."\n";
  125. echo "<li>{$nbTotalEvents} nouveaux articles\n";
  126. echo "</ul>\n";
  127. echo "</div>\n";
  128. }
  129. if (!$commandLine) {
  130. echo '</div></body></html>';
  131. }
  132. break;
  133. case 'readAll':
  134. if($myUser==false) exit(_t('YOU_MUST_BE_CONNECTED_ACTION'));
  135. $whereClause = array();
  136. $whereClause['unread'] = '1';
  137. if(isset($_['feed']))$whereClause['feed'] = $_['feed'];
  138. $eventManager->change(array('unread'=>'0'),$whereClause);
  139. header('location: ./index.php');
  140. break;
  141. case 'readFolder':
  142. if($myUser==false) exit(_t('YOU_MUST_BE_CONNECTED_ACTION'));
  143. $feeds = $feedManager->loadAllOnlyColumn('id',array('folder'=>$_['folder']));
  144. foreach($feeds as $feed){
  145. $eventManager->change(array('unread'=>'0'),array('feed'=>$feed->getId()));
  146. }
  147. header('location: ./index.php');
  148. break;
  149. case 'updateConfiguration':
  150. if($myUser==false) exit(_t('YOU_MUST_BE_CONNECTED_ACTION'));
  151. //Ajout des préférences et réglages
  152. $configurationManager->put('root',(substr($_['root'], strlen($_['root'])-1)=='/'?$_['root']:$_['root'].'/'));
  153. $configurationManager->put('articleDisplayAnonymous',$_['articleDisplayAnonymous']);
  154. $configurationManager->put('articlePerPages',$_['articlePerPages']);
  155. $configurationManager->put('articleDisplayLink',$_['articleDisplayLink']);
  156. $configurationManager->put('articleDisplayDate',$_['articleDisplayDate']);
  157. $configurationManager->put('articleDisplayAuthor',$_['articleDisplayAuthor']);
  158. $configurationManager->put('articleDisplayHomeSort',$_['articleDisplayHomeSort']);
  159. $configurationManager->put('articleDisplayFolderSort',$_['articleDisplayFolderSort']);
  160. $configurationManager->put('articleDisplayMode',$_['articleDisplayMode']);
  161. $configurationManager->put('synchronisationType',$_['synchronisationType']);
  162. $configurationManager->put('synchronisationEnableCache',$_['synchronisationEnableCache']);
  163. $configurationManager->put('synchronisationForceFeed',$_['synchronisationForceFeed']);
  164. $configurationManager->put('feedMaxEvents',$_['feedMaxEvents']);
  165. $userManager->change(array('login'=>$_['login']),array('id'=>$myUser->getId()));
  166. if(trim($_['password'])!='') {
  167. $salt = User::generateSalt();
  168. $userManager->change(array('password'=>User::encrypt($_['password'], $salt)),array('id'=>$myUser->getId()));
  169. /* /!\ En multi-utilisateur, il faudra changer l'information au
  170. niveau du compte lui-même et non au niveau du déploiement comme
  171. ici. C'est ainsi parce que c'est plus efficace de stocker le sel
  172. dans la config que dans le fichier de constantes, difficile à
  173. modifier. */
  174. $oldSalt = $configurationManager->get('cryptographicSalt');
  175. if (empty($oldSalt))
  176. /* Pendant la migration à ce système, les déploiements
  177. ne posséderont pas cette donnée. */
  178. $configurationManager->add('cryptographicSalt', $salt);
  179. else
  180. $configurationManager->change(array('value'=>$salt), array('key'=>'cryptographicSalt'));
  181. }
  182. header('location: ./settings.php#preferenceBloc');
  183. break;
  184. case 'purge':
  185. if($myUser==false) exit(_t('YOU_MUST_BE_CONNECTED_ACTION'));
  186. $eventManager->truncate();
  187. header('location: ./settings.php');
  188. break;
  189. case 'exportFeed':
  190. if($myUser==false) exit(_t('YOU_MUST_BE_CONNECTED_ACTION'));
  191. /*********************/
  192. /** Export **/
  193. /*********************/
  194. if(isset($_POST['exportButton'])){
  195. $opml = new Opml();
  196. $xmlStream = $opml->export();
  197. header('Content-Description: File Transfer');
  198. header('Content-Type: application/octet-stream');
  199. header('Content-Disposition: attachment; filename=leed-'.date('d-m-Y').'.opml');
  200. header('Content-Transfer-Encoding: binary');
  201. header('Expires: 0');
  202. header('Cache-Control: must-revalidate');
  203. header('Pragma: public');
  204. header('Content-Length: ' . strlen($xmlStream));
  205. /*
  206. //A decommenter dans le cas ou on a des pb avec ie
  207. if(preg_match('/msie|(microsoft internet explorer)/i', $_SERVER['HTTP_USER_AGENT'])){
  208. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  209. header('Pragma: public');
  210. }else{
  211. header('Pragma: no-cache');
  212. }
  213. */
  214. ob_clean();
  215. flush();
  216. echo $xmlStream;
  217. }
  218. break;
  219. case 'importForm':
  220. if($myUser==false) exit(_t('YOU_MUST_BE_CONNECTED_ACTION'));
  221. echo '<html style="height:auto;"><link rel="stylesheet" href="templates/'.$theme.'/css/style.css">
  222. <body style="height:auto;">
  223. <form action="action.php?action=importFeed" method="POST" enctype="multipart/form-data">
  224. <p>'._t('OPML_FILE').' : <input name="newImport" type="file"/> <button name="importButton">'._t('IMPORT').'</button></p>
  225. <p>'._t('IMPORT_COFFEE_TIME').'</p>
  226. </form>
  227. </body>
  228. </html>
  229. ';
  230. break;
  231. case 'synchronizeForm':
  232. if(isset($myUser) && $myUser!=false){
  233. echo '<link rel="stylesheet" href="templates/'.$theme.'/css/style.css">
  234. <a class="button" href="action.php?action=synchronize">'._t('SYNCHRONIZE_NOW').'</a>
  235. <p>'._t('SYNCHRONIZE_COFFEE_TIME').'</p>
  236. ';
  237. }else{
  238. echo _t('YOU_MUST_BE_CONNECTED_ACTION');
  239. }
  240. break;
  241. case 'changeFolderState':
  242. if($myUser==false) exit(_t('YOU_MUST_BE_CONNECTED_ACTION'));
  243. $folderManager->change(array('isopen'=>$_['isopen']),array('id'=>$_['id']));
  244. break;
  245. case 'importFeed':
  246. // On ne devrait pas mettre de style ici.
  247. echo "<html>
  248. <style>
  249. a {
  250. color:#F16529;
  251. }
  252. html,body{
  253. font-family:Verdana;
  254. font-size: 11px;
  255. }
  256. .error{
  257. background-color:#C94141;
  258. color:#ffffff;
  259. padding:5px;
  260. border-radius:5px;
  261. margin:10px 0px 10px 0px;
  262. box-shadow: 0 0 3px 0 #810000;
  263. }
  264. .error a{
  265. color:#ffffff;
  266. }
  267. </style>
  268. </style><body>
  269. \n";
  270. if($myUser==false) exit(_t('YOU_MUST_BE_CONNECTED_ACTION'));
  271. if(!isset($_POST['importButton'])) break;
  272. $opml = new Opml();
  273. echo "<h3>"._t('IMPORT')."</h3><p>"._t('PENDING')."</p>\n";
  274. try {
  275. $errorOutput = $opml->import($_FILES['newImport']['tmp_name']);
  276. } catch (Exception $e) {
  277. $errorOutput = array($e->getMessage());
  278. }
  279. if (empty($errorOutput)) {
  280. echo "<p>"._t('IMPORT_NO_PROBLEM')."</p>\n";
  281. } else {
  282. echo "<div class='error'>"._t('IMPORT_ERROR')."\n";
  283. foreach($errorOutput as $line) {
  284. echo "<p>$line</p>\n";
  285. }
  286. echo "</div>";
  287. }
  288. if (!empty($opml->alreadyKnowns)) {
  289. echo "<h3>"._t('IMPORT_FEED_ALREADY_KNOWN')." : </h3>\n<ul>\n";
  290. foreach($opml->alreadyKnowns as $alreadyKnown) {
  291. foreach($alreadyKnown as &$elt) $elt = htmlspecialchars($elt);
  292. $text = Functions::truncate($alreadyKnown->feedName, 60);
  293. echo "<li><a target='_parent' href='{$alreadyKnown->xmlUrl}'>"
  294. ."{$text}</a></li>\n";
  295. }
  296. echo "</ul>\n";
  297. }
  298. $syncLink = "action.php?action=synchronize&format=html";
  299. echo "<p>";
  300. echo "<a href='$syncLink' style='text-decoration:none;font-size:3em'>"
  301. ."↺</a>";
  302. echo "<a href='$syncLink'>"._t('CLIC_HERE_SYNC_IMPORT')."</a>";
  303. echo "<p></body></html>\n";
  304. break;
  305. case 'addFeed':
  306. if($myUser==false) exit(_t('YOU_MUST_BE_CONNECTED_ACTION'));
  307. require_once("SimplePie.class.php");
  308. if(!isset($_['newUrl'])) break;
  309. $newFeed = new Feed();
  310. $newFeed->setUrl(Functions::clean_url($_['newUrl']));
  311. if ($newFeed->notRegistered()) {
  312. ///@TODO: avertir l'utilisateur du doublon non ajouté
  313. $newFeed->getInfos();
  314. $newFeed->setFolder(
  315. (isset($_['newUrlCategory'])?$_['newUrlCategory']:1)
  316. );
  317. $newFeed->save();
  318. $enableCache = ($configurationManager->get('synchronisationEnableCache')=='')?0:$configurationManager->get('synchronisationEnableCache');
  319. $forceFeed = ($configurationManager->get('synchronisationForceFeed')=='')?0:$configurationManager->get('synchronisationForceFeed');
  320. $newFeed->parse(time(), $_, $enableCache, $forceFeed);
  321. Plugin::callHook("action_after_addFeed", array(&$newFeed));
  322. }
  323. header('location: ./settings.php#manageBloc');
  324. break;
  325. case 'changeFeedFolder':
  326. if($myUser==false) exit(_t('YOU_MUST_BE_CONNECTED_ACTION'));
  327. if(isset($_['feed'])){
  328. $feedManager->change(array('folder'=>$_['folder']),array('id'=>$_['feed']));
  329. }
  330. header('location: ./settings.php');
  331. break;
  332. case 'removeFeed':
  333. if($myUser==false) exit(_t('YOU_MUST_BE_CONNECTED_ACTION'));
  334. if(isset($_GET['id'])){
  335. $feedManager->delete(array('id'=>$_['id']));
  336. $eventManager->delete(array('feed'=>$_['id']));
  337. Plugin::callHook("action_after_removeFeed", array($_['id']));
  338. }
  339. header('location: ./settings.php');
  340. break;
  341. case 'addFolder':
  342. if($myUser==false) exit(_t('YOU_MUST_BE_CONNECTED_ACTION'));
  343. if(isset($_['newFolder'])){
  344. $folder = new Folder();
  345. if($folder->rowCount(array('name'=>$_['newFolder']))==0){
  346. $folder->setParent(-1);
  347. $folder->setIsopen(0);
  348. $folder->setName($_['newFolder']);
  349. $folder->save();
  350. }
  351. }
  352. header('location: ./settings.php');
  353. break;
  354. case 'renameFolder':
  355. if($myUser==false) exit(_t('YOU_MUST_BE_CONNECTED_ACTION'));
  356. if(isset($_['id'])){
  357. $folderManager->change(array('name'=>$_['name']),array('id'=>$_['id']));
  358. }
  359. break;
  360. case 'renameFeed':
  361. if($myUser==false) exit(_t('YOU_MUST_BE_CONNECTED_ACTION'));
  362. if(isset($_['id'])){
  363. $feedManager->change(array('name'=>$_['name'],'url'=>Functions::clean_url($_['url'])),array('id'=>$_['id']));
  364. }
  365. break;
  366. case 'removeFolder':
  367. if($myUser==false) exit(_t('YOU_MUST_BE_CONNECTED_ACTION'));
  368. if(isset($_['id']) && is_numeric($_['id']) && $_['id']>0){
  369. $eventManager->customExecute('DELETE FROM '.MYSQL_PREFIX.'event WHERE '.MYSQL_PREFIX.'event.feed in (SELECT '.MYSQL_PREFIX.'feed.id FROM '.MYSQL_PREFIX.'feed WHERE '.MYSQL_PREFIX.'feed.folder =\''.intval($_['id']).'\') ;');
  370. $feedManager->delete(array('folder'=>$_['id']));
  371. $folderManager->delete(array('id'=>$_['id']));
  372. }
  373. header('location: ./settings.php');
  374. break;
  375. case 'readContent':
  376. if($myUser==false) {
  377. $response_array['status'] = 'noconnect';
  378. $response_array['texte'] = _t('YOU_MUST_BE_CONNECTED_ACTION');
  379. header('Content-type: application/json');
  380. echo json_encode($response_array);
  381. exit();
  382. }
  383. if(isset($_['id'])){
  384. $event = $eventManager->load(array('id'=>$_['id']));
  385. $eventManager->change(array('unread'=>'0'),array('id'=>$_['id']));
  386. }
  387. break;
  388. case 'unreadContent':
  389. if($myUser==false) {
  390. $response_array['status'] = 'noconnect';
  391. $response_array['texte'] = _t('YOU_MUST_BE_CONNECTED_ACTION');
  392. header('Content-type: application/json');
  393. echo json_encode($response_array);
  394. exit();
  395. }
  396. if(isset($_['id'])){
  397. $event = $eventManager->load(array('id'=>$_['id']));
  398. $eventManager->change(array('unread'=>'1'),array('id'=>$_['id']));
  399. }
  400. break;
  401. case 'addFavorite':
  402. if($myUser==false) {
  403. $response_array['status'] = 'noconnect';
  404. $response_array['texte'] = _t('YOU_MUST_BE_CONNECTED_ACTION');
  405. header('Content-type: application/json');
  406. echo json_encode($response_array);
  407. exit();
  408. }
  409. $eventManager->change(array('favorite'=>'1'),array('id'=>$_['id']));
  410. break;
  411. case 'removeFavorite':
  412. if($myUser==false) {
  413. $response_array['status'] = 'noconnect';
  414. $response_array['texte'] = _t('YOU_MUST_BE_CONNECTED_ACTION');
  415. header('Content-type: application/json');
  416. echo json_encode($response_array);
  417. exit();
  418. }
  419. $eventManager->change(array('favorite'=>'0'),array('id'=>$_['id']));
  420. break;
  421. case 'login':
  422. define('RESET_PASSWORD_FILE', 'resetPassword');
  423. if (file_exists(RESET_PASSWORD_FILE)) {
  424. /* Pour réinitialiser le mot de passe :
  425. * créer le fichier RESET_PASSWORD_FILE vide.
  426. * Le nouveau mot de passe sera celui fourni à la connexion.
  427. */
  428. @unlink(RESET_PASSWORD_FILE);
  429. if (file_exists(RESET_PASSWORD_FILE)) {
  430. $message = 'Unable to remove "'.RESET_PASSWORD_FILE.'"!';
  431. /* Pas supprimable ==> on ne remet pas à zéro */
  432. } else {
  433. $resetPassword = $_['password'];
  434. assert('!empty($resetPassword)');
  435. $tmpUser = User::get($_['login']);
  436. if (false===$tmpUser) {
  437. $message = "Unknown user '{$_['login']}'! No password reset.";
  438. } else {
  439. $id = $tmpUser->getId();
  440. $salt = $configurationManager->get('cryptographicSalt');
  441. $userManager->change(
  442. array('password'=>User::encrypt($resetPassword, $salt)),
  443. array('id'=>$id)
  444. );
  445. $message = "User '{$_['login']}' (id=$id) Password reset to '$resetPassword'.";
  446. }
  447. }
  448. error_log($message);
  449. }
  450. if(isset($_['usr'])){
  451. $user = User::existAuthToken($_['usr']);
  452. if($user==false){
  453. exit("erreur identification : le compte est inexistant");
  454. }else{
  455. $_SESSION['currentUser'] = serialize($user);
  456. header('location: ./action.php?action=addFeed&newUrl='.$_['newUrl']);
  457. }
  458. }else{
  459. $salt = $configurationManager->get('cryptographicSalt');
  460. if (empty($salt)) $salt = '';
  461. $user = $userManager->exist($_['login'],$_['password'],$salt);
  462. if($user==false){
  463. exit("erreur identification : le compte est inexistant");
  464. }else{
  465. $_SESSION['currentUser'] = serialize($user);
  466. if (isset($_['rememberMe'])) $user->setStayConnected();
  467. }
  468. header('location: ./index.php');
  469. }
  470. break;
  471. case 'changePluginState':
  472. if($myUser==false) exit(_t('YOU_MUST_BE_CONNECTED_ACTION'));
  473. if($_['state']=='0'){
  474. Plugin::enabled($_['plugin']);
  475. }else{
  476. Plugin::disabled($_['plugin']);
  477. }
  478. header('location: ./settings.php#pluginBloc');
  479. break;
  480. case 'logout':
  481. User::delStayConnected();
  482. $_SESSION = array();
  483. session_unset();
  484. session_destroy();
  485. header('location: ./index.php');
  486. break;
  487. case 'displayOnlyUnreadFeedFolder':
  488. if($myUser==false) {
  489. $response_array['status'] = 'noconnect';
  490. $response_array['texte'] = _t('YOU_MUST_BE_CONNECTED_ACTION');
  491. header('Content-type: application/json');
  492. echo json_encode($response_array);
  493. exit();
  494. }
  495. $configurationManager->put('displayOnlyUnreadFeedFolder',$_['displayOnlyUnreadFeedFolder']);
  496. break;
  497. case 'displayFeedIsVerbose':
  498. if($myUser==false) {
  499. $response_array['status'] = 'noconnect';
  500. $response_array['texte'] = _t('YOU_MUST_BE_CONNECTED_ACTION');
  501. header('Content-type: application/json');
  502. echo json_encode($response_array);
  503. exit();
  504. }
  505. // changement du statut isverbose du feed
  506. $feed = new Feed();
  507. $feed = $feed->getById($_['idFeed']);
  508. $feed->setIsverbose(($_['displayFeedIsVerbose']=="0"?1:0));
  509. $feed->save();
  510. break;
  511. case 'optionFeedIsVerbose':
  512. if($myUser==false) {
  513. $response_array['status'] = 'noconnect';
  514. $response_array['texte'] = _t('YOU_MUST_BE_CONNECTED_ACTION');
  515. header('Content-type: application/json');
  516. echo json_encode($response_array);
  517. exit();
  518. }
  519. // changement du statut de l'option
  520. $configurationManager = new Configuration();
  521. $conf = $configurationManager->getAll();
  522. $configurationManager->put('optionFeedIsVerbose',($_['optionFeedIsVerbose']=="0"?0:1));
  523. break;
  524. case 'articleDisplayMode':
  525. if($myUser==false) {
  526. $response_array['status'] = 'noconnect';
  527. $response_array['texte'] = _t('YOU_MUST_BE_CONNECTED_ACTION');
  528. header('Content-type: application/json');
  529. echo json_encode($response_array);
  530. exit();
  531. }
  532. // chargement du content de l'article souhaité
  533. $newEvent = new Event();
  534. $event = $newEvent->getById($_['event_id']);
  535. if ($_['articleDisplayMode']=='content'){
  536. //error_log(print_r($_SESSION['events'],true));
  537. $content = $event->getContent();
  538. } else {
  539. $content = $event->getDescription();
  540. }
  541. echo $content;
  542. break;
  543. default:
  544. require_once("SimplePie.class.php");
  545. Plugin::callHook("action_post_case", array(&$_,$myUser));
  546. //exit('0');
  547. break;
  548. }
  549. ?>