TYPO3 CMS  TYPO3_8-7
AjaxController.php
Go to the documentation of this file.
1 <?php
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 
20 
25 {
34  public function switchWorkspaceAction(ServerRequestInterface $request, ResponseInterface $response)
35  {
36  $parsedBody = $request->getParsedBody();
37  $queryParams = $request->getQueryParams();
38  $workspaceId = (int)(isset($parsedBody['workspaceId']) ? $parsedBody['workspaceId'] : $queryParams['workspaceId']);
39  $pageId = (int)(isset($parsedBody['pageId']) ? $parsedBody['pageId'] : $queryParams['pageId']);
40  $finalPageUid = 0;
41  $originalPageId = $pageId;
42 
43  $this->getBackendUser()->setWorkspace($workspaceId);
44 
45  while ($pageId) {
47  'pages',
48  $pageId,
49  '*',
50  ' AND pages.t3ver_wsid IN (0, ' . $workspaceId . ')'
51  );
52  if ($page) {
53  if ($this->getBackendUser()->doesUserHaveAccess($page, 1)) {
54  break;
55  }
56  } else {
57  $page = BackendUtility::getRecord('pages', $pageId);
58  }
59  $pageId = $page['pid'];
60  }
61 
62  if (isset($page['uid'])) {
63  $finalPageUid = (int)$page['uid'];
64  }
65 
66  $ajaxResponse = [
68  'workspaceId' => $workspaceId,
69  'pageId' => ($finalPageUid && $originalPageId == $finalPageUid) ? null : $finalPageUid
70  ];
71  $response->getBody()->write(json_encode($ajaxResponse));
72  return $response;
73  }
74 
78  protected function getBackendUser()
79  {
80  return $GLOBALS['BE_USER'];
81  }
82 }
static getRecordWSOL( $table, $uid, $fields=' *', $where='', $useDeleteClause=true, $unsetMovePointers=false)
switchWorkspaceAction(ServerRequestInterface $request, ResponseInterface $response)
static getRecord($table, $uid, $fields=' *', $where='', $useDeleteClause=true)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']