Fixed issue: #10817 DAU WS-Module warning
[Packages/TYPO3.CMS.git] / typo3 / sysext / workspaces / Classes / Controller / ReviewController.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2010 Steffen Ritter (steffen@typo3.org)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27
28 class Tx_Workspaces_Controller_ReviewController extends Tx_Workspaces_Controller_AbstractController {
29
30 /**
31 * Renders the review module user dependent with all workspaces.
32 * The module will show all records of one workspace.
33 *
34 * @return void
35 */
36 public function indexAction() {
37 $wsService = t3lib_div::makeInstance('tx_Workspaces_Service_Workspaces');
38 $this->view->assign('showGrid', !($GLOBALS['BE_USER']->workspace === 0 && !$GLOBALS['BE_USER']->isAdmin()));
39 $this->view->assign('showAllWorkspaceTab', $GLOBALS['BE_USER']->isAdmin());
40 $this->view->assign('pageUid', t3lib_div::_GP('id'));
41 $this->view->assign('showLegend', !($GLOBALS['BE_USER']->workspace === 0 && !$GLOBALS['BE_USER']->isAdmin()));
42
43 $wsList = $wsService->getAvailableWorkspaces();
44 $activeWorkspace = $GLOBALS['BE_USER']->workspace;
45
46 if (!$GLOBALS['BE_USER']->isAdmin()) {
47 $wsCur = array($activeWorkspace => true);
48 $wsList = array_intersect_key($wsList, $wsCur);
49 } else {
50 $wsList = $wsService->getAvailableWorkspaces();
51 if (strlen(t3lib_div::_GP('workspace'))) {
52 $switchWs = (int) t3lib_div::_GP('workspace');
53 if (in_array($switchWs, array_keys($wsList))) {
54 $activeWorkspace = $switchWs;
55 } elseif ($switchWs == tx_Workspaces_Service_Workspaces::SELECT_ALL_WORKSPACES) {
56 $activeWorkspace = tx_Workspaces_Service_Workspaces::SELECT_ALL_WORKSPACES;
57 }
58 }
59 }
60 $this->view->assign('workspaceList', $wsList);
61 $this->view->assign('activeWorkspaceUid', $activeWorkspace);
62 $GLOBALS['BE_USER']->setAndSaveSessionData('tx_workspace_activeWorkspace', $activeWorkspace);
63 }
64
65 /**
66 * Renders the review module for admins.
67 * The module will show all records of all workspaces.
68 *
69 * @return void
70 */
71 public function fullIndexAction() {
72 if (!$GLOBALS['BE_USER']->isAdmin()) {
73 $this->redirect('index');
74 } else {
75 $wsService = t3lib_div::makeInstance('tx_Workspaces_Service_Workspaces');
76 $this->view->assign('pageUid', t3lib_div::_GP('id'));
77 $this->view->assign('showGrid', true);
78 $this->view->assign('showLegend', true);
79 $this->view->assign('showAllWorkspaceTab', $GLOBALS['BE_USER']->isAdmin());
80 $this->view->assign('workspaceList', $wsService->getAvailableWorkspaces());
81 $this->view->assign('activeWorkspaceUid', tx_Workspaces_Service_Workspaces::SELECT_ALL_WORKSPACES);
82 $GLOBALS['BE_USER']->setAndSaveSessionData('tx_workspace_activeWorkspace', tx_Workspaces_Service_Workspaces::SELECT_ALL_WORKSPACES);
83 }
84 }
85
86 /**
87 * Renders the review module for a single page. This is used within the
88 * workspace-preview frame.
89 *
90 * @return void
91 */
92 public function singleIndexAction() {
93
94 $wsService = t3lib_div::makeInstance('tx_Workspaces_Service_Workspaces');
95 $wsList = $wsService->getAvailableWorkspaces();
96 $activeWorkspace = $GLOBALS['BE_USER']->workspace;
97
98 $wsCur = array($activeWorkspace => true);
99 $wsList = array_intersect_key($wsList, $wsCur);
100
101 $this->view->assign('pageUid', t3lib_div::_GP('id'));
102 $this->view->assign('showGrid', true);
103 $this->view->assign('showAllWorkspaceTab', false);
104 $this->view->assign('workspaceList', $wsList);
105 }
106
107
108 /**
109 * Initializes the controller before invoking an action method.
110 *
111 * @return void
112 */
113 protected function initializeAction() {
114 parent::initializeAction();
115
116 if (tx_Workspaces_Service_Workspaces::isOldStyleWorkspaceUsed()) {
117 $message = t3lib_div::makeInstance(
118 't3lib_FlashMessage',
119 $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xml:warning.oldStyleWorkspaceInUser'),
120 '',
121 t3lib_FlashMessage::WARNING
122 );
123
124 t3lib_FlashMessageQueue::addMessage($message);
125 }
126
127 $this->pageRenderer->loadExtJS();
128 $this->pageRenderer->enableExtJSQuickTips();
129 $this->pageRenderer->enableExtJsDebug();
130
131 // Load JavaScript:
132 $this->pageRenderer->addExtDirectCode();
133 $this->pageRenderer->addJsFile($this->backPath . 'ajax.php?ajaxID=ExtDirect::getAPI&namespace=TYPO3.Workspaces', NULL, FALSE);
134
135 $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/flashmessages.js');
136 $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/Ext.grid.RowExpander.js');
137 $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/Ext.app.SearchField.js');
138 $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/Ext.ux.FitToParent.js');
139
140 $resourcePath = t3lib_extMgm::extRelPath('workspaces') . 'Resources/Public/JavaScript/';
141
142 $this->pageRenderer->addCssFile($resourcePath . 'gridfilters/css/GridFilters.css');
143 $this->pageRenderer->addCssFile($resourcePath . 'gridfilters/css/RangeMenu.css');
144
145 $jsFiles = array(
146 'gridfilters/menu/RangeMenu.js',
147 'gridfilters/menu/ListMenu.js',
148 'gridfilters/GridFilters.js',
149 'gridfilters/filter/Filter.js',
150 'gridfilters/filter/StringFilter.js',
151 'gridfilters/filter/DateFilter.js',
152 'gridfilters/filter/ListFilter.js',
153 'gridfilters/filter/NumericFilter.js',
154 'gridfilters/filter/BooleanFilter.js',
155 'gridfilters/filter/BooleanFilter.js',
156
157 'configuration.js',
158 'helpers.js',
159 'actions.js',
160 'component.js',
161 'toolbar.js',
162 'grid.js',
163 'workspaces.js',
164 );
165
166 foreach ($jsFiles as $jsFile) {
167 $this->pageRenderer->addJsFile($resourcePath . $jsFile);
168 }
169 }
170 }
171
172
173 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/workspaces/Classes/Controller/ReviewController.php']) {
174 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/workspaces/Classes/Controller/ReviewController.php']);
175 }
176
177 ?>