[TASK] Cleanup EXT:taskcenter
[Packages/TYPO3.CMS.git] / typo3 / sysext / taskcenter / Classes / TaskStatus.php
1 <?php
2 namespace TYPO3\CMS\Taskcenter;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Http\AjaxRequestHandler;
18 use TYPO3\CMS\Core\Utility\GeneralUtility;
19
20 /**
21 * Status of tasks
22 *
23 * @author Georg Ringer <typo3@ringerge.org>
24 */
25 class TaskStatus {
26
27 /**
28 * Saves the section toggle state of tasks in the backend user's uc
29 *
30 * @param array $params Array of parameters from the AJAX interface, currently unused
31 * @param AjaxRequestHandler $ajaxObj Object of type AjaxRequestHandler
32 * @return void
33 */
34 public function saveCollapseState(array $params, AjaxRequestHandler $ajaxObj) {
35 // Remove 'el_' in the beginning which is needed for the saveSortingState()
36 $item = substr(htmlspecialchars(GeneralUtility::_POST('item')), 3);
37 $state = (bool)GeneralUtility::_POST('state');
38 $this->getBackendUserAuthentication()->uc['taskcenter']['states'][$item] = $state;
39 $this->getBackendUserAuthentication()->writeUC();
40 }
41
42 /**
43 * Saves the sorting order of tasks in the backend user's uc
44 *
45 * @param array $params Array of parameters from the AJAX interface, currently unused
46 * @param AjaxRequestHandler $ajaxObj Object of type AjaxRequestHandler
47 * @return void
48 */
49 public function saveSortingState(array $params, AjaxRequestHandler $ajaxObj) {
50 $sort = array();
51 $items = explode('&', GeneralUtility::_POST('data'));
52 foreach ($items as $item) {
53 $sort[] = substr($item, 12);
54 }
55 $this->getBackendUserAuthentication()->uc['taskcenter']['sorting'] = serialize($sort);
56 $this->getBackendUserAuthentication()->writeUC();
57 }
58
59 /**
60 * Returns BackendUserAuthentication
61 *
62 * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
63 */
64 protected function getBackendUserAuthentication() {
65 return $GLOBALS['BE_USER'];
66 }
67
68 }