2 namespace TYPO3\CMS\Core\Authentication;
49 'filemounts' => array()
94 'webmount_list' =>
'',
95 'filemount_list' =>
'',
96 'file_permissions' =>
'',
98 'tables_select' =>
'',
99 'tables_modify' =>
'',
100 'pagetypes_select' =>
'',
101 'non_exclude_fields' =>
'',
102 'explicit_allowdeny' =>
'',
103 'allowed_languages' =>
'',
104 'workspace_perms' =>
'',
105 'custom_options' =>
''
219 'deleted' =>
'deleted',
220 'disabled' =>
'disable',
221 'starttime' =>
'starttime',
222 'endtime' =>
'endtime'
284 'interfaceSetup' =>
'',
286 'moduleData' => array(),
288 'thumbnailsByDefault' => 1,
289 'emailMeAtLogin' => 0,
290 'startModule' =>
'help_AboutmodulesAboutmodules',
291 'hideSubmoduleIcons' => 0,
294 'edit_docModuleUpload' =>
'1',
296 'navFrameResizable' => 0,
297 'resizeTextareas' => 1,
298 'resizeTextareas_MaxHeight' => 500,
299 'resizeTextareas_Flexible' => 0
307 parent::__construct();
308 $this->name = self::getCookieName();
309 $this->loginType =
'BE';
310 $this->OS = TYPO3_OS;
321 return is_array($this->user) && ($this->user[
'admin'] & 1) == 1;
334 $groupId = (int)$groupId;
335 if ($this->groupList && $groupId) {
359 return ($userPerms & $perms) == $perms;
380 if (!
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'lockBeUserToDBmounts'] || $this->
isAdmin()) {
386 if ($checkRec[
'pid'] == -1) {
387 $id = (int)$checkRec[
't3ver_oid'];
395 foreach ($rL as $v) {
396 if ($v[
'uid'] && in_array($v[
'uid'], $wM)) {
402 throw new \RuntimeException(
'Access Error: This page is not within your DB-mounts', 1294586445);
419 throw new \RuntimeException(
'Fatal Error: This module "' . $conf[
'name'] .
'" is not enabled in TBE_MODULES', 1294586446);
425 !empty($conf[
'workspaces'])
426 && \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded(
'workspaces')
432 throw new \RuntimeException(
'Workspace Error: This module "' . $conf[
'name'] .
'" is not available under the current workspace', 1294586447);
437 if (!$conf[
'access'] || $this->
isAdmin()) {
442 if (!strstr($conf[
'access'],
'admin') && $conf[
'name']) {
443 $acs = $this->
check(
'modules', $conf[
'name']);
445 if (!$acs && $exitOnError) {
446 throw new \RuntimeException(
'Access Error: You don\'t have access to this module.', 1294586448);
469 if (is_array($this->user)) {
473 $perms = (int)$perms;
475 $str =
' (' .
'(pages.perms_everybody & ' . $perms .
' = ' . $perms .
')' .
' OR (pages.perms_userid = '
476 . $this->user[
'uid'] .
' AND pages.perms_user & ' . $perms .
' = ' . $perms .
')';
478 if ($this->groupList) {
480 $str .=
' OR (pages.perms_groupid in (' . $this->groupList .
') AND pages.perms_group & '
481 . $perms .
' = ' . $perms .
')';
487 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_userauthgroup.php'][
'getPagePermsClause'])) {
488 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_userauthgroup.php'][
'getPagePermsClause'] as $_funcRef) {
489 $_params = array(
'currentClause' => $str,
'perms' => $perms);
520 isset($row[
'perms_userid']) && isset($row[
'perms_user']) && isset($row[
'perms_groupid'])
521 && isset($row[
'perms_group']) && isset($row[
'perms_everybody']) && isset($this->groupList)
523 if ($this->user[
'uid'] == $row[
'perms_userid']) {
524 $out |= $row[
'perms_user'];
527 $out |= $row[
'perms_group'];
529 $out |= $row[
'perms_everybody'];
534 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_userauthgroup.php'][
'calcPerms'])) {
535 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_userauthgroup.php'][
'calcPerms'] as $_funcRef) {
538 'outputPermissions' => $out
553 return (
bool)$this->uc[
'edit_RTE'];
566 public function check($type, $value)
568 if (isset($this->groupData[$type])) {
592 if ((
string)$value ===
'') {
596 if (preg_match(
'/[:|,]/', $value)) {
600 $testValue = $table .
':' . $field .
':' . $value;
603 switch ((
string)$authMode) {
604 case 'explicitAllow':
615 if (is_array(
$GLOBALS[
'TCA'][$table]) && is_array(
$GLOBALS[
'TCA'][$table][
'columns'][$field])) {
616 $items =
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'][
'items'];
617 if (is_array($items)) {
618 foreach ($items as $iCfg) {
619 if ((
string)$iCfg[1] === (
string)$value && $iCfg[4]) {
620 switch ((
string)$iCfg[4]) {
651 if (trim($this->groupData[
'allowed_languages']) !==
'') {
652 $langValue = (int)$langValue;
654 if ($langValue != -1 && !$this->
check(
'allowed_languages', $langValue)) {
672 if (isset(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transForeignTable'])) {
673 $l10nTable =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transForeignTable'];
674 $pointerField =
$GLOBALS[
'TCA'][$l10nTable][
'ctrl'][
'transOrigPointerField'];
675 $pointerValue = $record[
'uid'];
678 $pointerField =
$GLOBALS[
'TCA'][$l10nTable][
'ctrl'][
'transOrigPointerField'];
679 $pointerValue = $record[$pointerField] > 0 ? $record[$pointerField] : $record[
'uid'];
682 if (is_array($recordLocalizations)) {
683 foreach ($recordLocalizations as $localization) {
684 $recordLocalizationAccess = $recordLocalizationAccess
686 if (!$recordLocalizationAccess) {
692 return $recordLocalizationAccess;
710 public function recordEditAccessInternals($table, $idOrRow, $newRecord =
false, $deletedRecord =
false, $checkFullLanguageAccess =
false)
712 if (!isset(
$GLOBALS[
'TCA'][$table])) {
720 if (!is_array($idOrRow)) {
721 if ($deletedRecord) {
726 if (!is_array($idOrRow)) {
727 $this->errorMsg =
'ERROR: Record could not be fetched.';
732 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']) {
734 if (isset($idOrRow[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']])) {
736 $this->errorMsg =
'ERROR: Language was not allowed.';
739 $checkFullLanguageAccess && $idOrRow[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']] == 0
742 $this->errorMsg =
'ERROR: Related/affected language was not allowed.';
746 $this->errorMsg =
'ERROR: The "languageField" field named "'
747 .
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField'] .
'" was not found in testing record!';
751 isset(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transForeignTable']) && $checkFullLanguageAccess &&
757 if (is_array(
$GLOBALS[
'TCA'][$table][
'columns'])) {
758 foreach (
$GLOBALS[
'TCA'][$table][
'columns'] as $fieldName => $fieldValue) {
759 if (isset($idOrRow[$fieldName])) {
761 $fieldValue[
'config'][
'type'] ===
'select' && $fieldValue[
'config'][
'authMode']
762 && $fieldValue[
'config'][
'authMode_enforce'] ===
'strict'
764 if (!$this->
checkAuthMode($table, $fieldName, $idOrRow[$fieldName], $fieldValue[
'config'][
'authMode'])) {
765 $this->errorMsg =
'ERROR: authMode "' . $fieldValue[
'config'][
'authMode']
766 .
'" failed for field "' . $fieldName .
'" with value "'
767 . $idOrRow[$fieldName] .
'" evaluated';
775 if (!$newRecord &&
$GLOBALS[
'TCA'][$table][
'ctrl'][
'editlock']) {
776 if (isset($idOrRow[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'editlock']])) {
777 if ($idOrRow[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'editlock']]) {
778 $this->errorMsg =
'ERROR: Record was locked for editing. Only admin users can change this state.';
782 $this->errorMsg =
'ERROR: The "editLock" field named "' .
$GLOBALS[
'TCA'][$table][
'ctrl'][
'editlock']
783 .
'" was not found in testing record!';
790 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_userauthgroup.php'][
'recordEditAccessInternals'])) {
791 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_userauthgroup.php'][
'recordEditAccessInternals'] as $funcRef) {
794 'idOrRow' => $idOrRow,
795 'newRecord' => $newRecord
816 public function isPSet($compiledPermissions, $tableName, $actionType =
'')
820 }
elseif ($tableName ==
'pages') {
821 switch ($actionType) {
869 if ($this->workspace !== 0) {
870 if (!is_array($recData)) {
874 'pid' . (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS'] ?
',t3ver_wsid,t3ver_stage' :
'')
877 if (is_array($recData)) {
880 if ((
int)$recData[
'pid'] === -1) {
882 if (!
$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) {
883 return 'Versioning disabled for table';
884 }
elseif ((
int)$recData[
't3ver_wsid'] !== $this->workspace) {
886 return 'Workspace ID of record didn\'t match current workspace';
891 :
'User\'s access level did not allow for editing';
901 :
'Stage for versioning root point and users access level did not allow for editing';
904 return 'Online record was not in versionized branch!';
926 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) {
927 if (!is_array($recData)) {
930 if (is_array($recData)) {
931 if ((
int)$recData[
'pid'] === -1) {
934 return 'Not an offline version';
940 return 'Table does not support versioning.';
960 $this->workspace === 0
961 || $this->workspaceRec[
'live_edit'] && !
$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']
962 ||
$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS_alwaysAllowLiveEdit']
1008 $this->workspace !== 0
1009 &&
$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS'] && $recpid >= 0
1033 if ($this->workspace !== 0 && \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded(
'workspaces')) {
1034 $stage = (int)$stage;
1038 if (
$workspaceRec[
'custom_stages'] > 0 && $stage !== 0 && $stage !== -10) {
1043 $stat[
'_ACCESS'] ===
'owner'
1044 || $stat[
'_ACCESS'] ===
'member'
1050 foreach ($this->userGroupsUID as $groupUid) {
1052 $stat[
'_ACCESS'] ===
'owner'
1053 || $stat[
'_ACCESS'] ===
'member'
1059 }
elseif ($stage == -10 || $stage == -20) {
1060 if ($stat[
'_ACCESS'] ===
'owner') {
1066 $memberStageLimit = $this->workspaceRec[
'review_stage_edit'] ? 1 : 0;
1068 $stat[
'_ACCESS'] ===
'owner'
1069 || $stat[
'_ACCESS'] ===
'reviewer' && $stage <= 1
1070 || $stat[
'_ACCESS'] ===
'member' && $stage <= $memberStageLimit
1101 switch ($wsAccess[
'uid']) {
1125 if ($this->workspace > 0 && (
int)$this->workspaceRec[
'swap_modes'] === 2) {
1142 if (!is_array($config)) {
1146 $TSConf = array(
'value' => null,
'properties' => null);
1150 if (count($parts) > 1 && $parts[1] !==
'') {
1152 if (is_array($config[$key .
'.'])) {
1153 $TSConf = $this->
getTSConfig($parts[1], $config[$key .
'.']);
1156 $TSConf[
'value'] = $config[$key];
1157 $TSConf[
'properties'] = $config[$key .
'.'];
1173 return $TSConf[
'value'];
1186 return $TSConf[
'properties'];
1199 return (
string)$this->groupData[
'webmounts'] !=
'' ? explode(
',', $this->groupData[
'webmounts']) : array();
1211 if (empty($mountPointUids)) {
1216 $mountPointUids = array_merge($currentWebMounts, $mountPointUids);
1218 $this->groupData[
'webmounts'] = implode(
',', array_unique($mountPointUids));
1231 $alertPopup = $this->
getTSConfig(
'options.alertPopups');
1232 if (empty($alertPopup[
'value'])) {
1236 $alertPopup = (int)$alertPopup[
'value'];
1239 return ($alertPopup & $bitmask) == $bitmask;
1254 if ($this->user[
'uid']) {
1257 $this->dataLists[
'modList'] = $this->user[
'userMods'];
1259 $this->dataLists[
'allowed_languages'] = $this->user[
'allowed_languages'];
1261 $this->dataLists[
'workspace_perms'] = $this->user[
'workspace_perms'];
1263 $this->dataLists[
'webmount_list'] = $this->user[
'db_mountpoints'];
1265 $this->dataLists[
'filemount_list'] = $this->user[
'file_mountpoints'];
1267 $this->dataLists[
'file_permissions'] = $this->user[
'file_permissions'];
1269 $this->TSdataArray[] = $this->
addTScomment(
'From $GLOBALS["TYPO3_CONF_VARS"]["BE"]["defaultUserTSconfig"]:')
1270 .
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'defaultUserTSconfig'];
1273 $this->TSdataArray[] = $this->
addTScomment(
'"admin" user presets:') .
'
1274 admPanel.enable.all = 1
1276 if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded(
'sys_note')) {
1277 $this->TSdataArray[] =
'
1278 // Setting defaults for sys_note author / email...
1279 TCAdefaults.sys_note.author = ' . $this->user[
'realName'] .
'
1280 TCAdefaults.sys_note.email = ' . $this->user[
'email'] .
'
1286 if (!empty($this->user[$this->usergroup_column])) {
1289 $this->
fetchGroups($this->user[$this->usergroup_column]);
1293 $this->userGroupsUID = array_reverse(array_unique(array_reverse($this->includeGroupArray)));
1297 $this->groupList = implode(
',', $this->userGroupsUID);
1301 $this->TSdataArray[] = $this->
addTScomment(
'USER TSconfig field') . $this->user[
'TSconfig'];
1303 $this->TSdataArray = \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::checkIncludeLines_array($this->TSdataArray);
1305 $this->userTS_text = implode(LF .
'[GLOBAL]' . LF, $this->TSdataArray);
1306 if (!$this->userTS_dontGetCached) {
1309 $res = $parseObj->parseTSconfig($this->userTS_text,
'userTS');
1311 $this->userTS = $res[
'TSconfig'];
1312 $this->userTSUpdated = (bool)$res[
'cached'];
1316 $hash = md5(
'userTS:' . $this->userTS_text);
1317 $cachedContent = BackendUtility::getHash($hash);
1318 if (is_array($cachedContent) && !$this->userTS_dontGetCached) {
1319 $this->userTS = $cachedContent;
1322 $parseObj->parse($this->userTS_text);
1323 $this->userTS = $parseObj->setup;
1324 BackendUtility::storeHash($hash, $this->userTS,
'BE_USER_TSconfig');
1326 $this->userTSUpdated =
true;
1332 $this->dataLists[
'webmount_list'] =
'0,' . $this->dataLists[
'webmount_list'];
1337 $this->groupData[
'tables_select'] =
GeneralUtility::uniqueList($this->dataLists[
'tables_modify'] .
',' . $this->dataLists[
'tables_select']);
1345 $this->groupData[
'workspace_perms'] = $this->dataLists[
'workspace_perms'];
1348 if (trim($this->groupData[
'webmounts']) !==
'') {
1349 $webmounts = explode(
',', $this->groupData[
'webmounts']);
1352 $where =
'deleted=0 AND uid IN (' . $this->groupData[
'webmounts'] .
') AND ' . $this->
getPagePermsClause(1);
1353 $MProws = $this->db->exec_SELECTgetRows(
'uid',
'pages', $where,
'',
'',
'',
'uid');
1354 foreach ($webmounts as $idx => $mountPointUid) {
1356 if ($mountPointUid > 0 && !isset($MProws[$mountPointUid])) {
1357 unset($webmounts[$idx]);
1361 $this->groupData[
'webmounts'] = implode(
',', $webmounts);
1380 $lockToDomain_SQL =
' AND (lockToDomain=\'\' OR lockToDomain IS NULL OR lockToDomain=' . $this->db->fullQuoteStr(
GeneralUtility::getIndpEnv(
'HTTP_HOST'), $this->usergroup_table) .
')';
1381 $grList = $this->db->cleanIntList($grList);
1382 $whereSQL =
'deleted=0 AND hidden=0 AND pid=0 AND uid IN (' . $grList .
')' . $lockToDomain_SQL;
1384 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_userauthgroup.php'][
'fetchGroupQuery'])) {
1385 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_userauthgroup.php'][
'fetchGroupQuery'] as $classRef) {
1387 if (method_exists($hookObj,
'fetchGroupQuery_processQuery')) {
1388 $whereSQL = $hookObj->fetchGroupQuery_processQuery($this, $grList, $idList, $whereSQL);
1392 $res = $this->db->exec_SELECTquery(
'*', $this->usergroup_table, $whereSQL);
1394 while ($row = $this->db->sql_fetch_assoc($res)) {
1395 $this->userGroups[$row[
'uid']] = $row;
1397 $this->db->sql_free_result($res);
1399 foreach (explode(
',', $grList) as $uid) {
1401 $row = $this->userGroups[$uid];
1405 if (trim($row[
'subgroup'])) {
1409 $this->
fetchGroups($theList, $idList .
',' . $uid);
1412 $this->includeGroupArray[] = $uid;
1413 $this->includeHierarchy[] = $idList;
1414 $this->TSdataArray[] = $this->
addTScomment(
'Group "' . $row[
'title'] .
'" [' . $row[
'uid'] .
'] TSconfig field:') . $row[
'TSconfig'];
1417 $this->dataLists[
'webmount_list'] .=
',' . $row[
'db_mountpoints'];
1421 $this->dataLists[
'filemount_list'] .=
',' . $row[
'file_mountpoints'];
1424 $this->dataLists[
'modList'] .=
',' . $row[
'groupMods'];
1425 $this->dataLists[
'tables_select'] .=
',' . $row[
'tables_select'];
1426 $this->dataLists[
'tables_modify'] .=
',' . $row[
'tables_modify'];
1427 $this->dataLists[
'pagetypes_select'] .=
',' . $row[
'pagetypes_select'];
1428 $this->dataLists[
'non_exclude_fields'] .=
',' . $row[
'non_exclude_fields'];
1429 $this->dataLists[
'explicit_allowdeny'] .=
',' . $row[
'explicit_allowdeny'];
1430 $this->dataLists[
'allowed_languages'] .=
',' . $row[
'allowed_languages'];
1431 $this->dataLists[
'custom_options'] .=
',' . $row[
'custom_options'];
1432 $this->dataLists[
'file_permissions'] .=
',' . $row[
'file_permissions'];
1434 $this->dataLists[
'workspace_perms'] |= $row[
'workspace_perms'];
1437 if ($idList ===
'' && !$this->firstMainGroup) {
1438 $this->firstMainGroup = $uid;
1443 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_userauthgroup.php'][
'fetchGroups_postProcessing'])) {
1444 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_userauthgroup.php'][
'fetchGroups_postProcessing'] as $_funcRef) {
1464 if ((
string)$cList != (
string)$this->user[
'usergroup_cached_list']) {
1465 $this->db->exec_UPDATEquery(
'be_users',
'uid=' . (
int)$this->user[
'uid'], array(
'usergroup_cached_list' => $cList));
1475 protected function initializeFileStorages()
1477 $this->fileStorages = array();
1482 $storageObjects = $storageRepository->findAll();
1483 foreach ($storageObjects as $storageObject) {
1484 $this->fileStorages[$storageObject->getUid()] = $storageObject;
1490 if (!array_key_exists((
int)$row[
'base'], $this->fileStorages)) {
1491 $storageObject = $storageRepository->findByUid($row[
'base']);
1492 if ($storageObject) {
1493 $this->fileStorages[$storageObject->getUid()] = $storageObject;
1511 $categoryMountPoints =
'';
1514 if (is_array($this->userGroups)) {
1515 foreach ($this->userGroups as $group) {
1516 if ($group[
'category_perms']) {
1517 $categoryMountPoints .=
',' . $group[
'category_perms'];
1523 if ($this->user[
'category_perms']) {
1524 $categoryMountPoints .=
',' . $this->user[
'category_perms'];
1529 $categoryMountPoints = array_filter($categoryMountPoints);
1530 $categoryMountPoints = array_unique($categoryMountPoints);
1532 return $categoryMountPoints;
1544 static $fileMountRecordCache = array();
1546 if (!empty($fileMountRecordCache)) {
1547 return $fileMountRecordCache;
1554 if ($this->workspace > 0 && !empty($this->workspaceRec[
'file_mountpoints'])) {
1556 $fileMounts = array_intersect($fileMounts, $workspaceFileMounts);
1559 if (!empty($fileMounts)) {
1560 $orderBy = isset(
$GLOBALS[
'TCA'][
'sys_filemounts'][
'ctrl'][
'default_sortby'])
1561 ? $this->db->stripOrderBy(
$GLOBALS[
'TCA'][
'sys_filemounts'][
'ctrl'][
'default_sortby'])
1563 $fileMountRecords = $this->db->exec_SELECTgetRows(
1566 'deleted=0 AND hidden=0 AND pid=0 AND uid IN (' . implode(
',', $fileMounts) .
')',
1570 foreach ($fileMountRecords as $fileMount) {
1571 $fileMountRecordCache[$fileMount[
'base'] . $fileMount[
'path']] = $fileMount;
1576 $readOnlyMountPoints = trim(
$GLOBALS[
'BE_USER']->
getTSConfigVal(
'options.folderTree.altElementBrowserMountPoints'));
1577 if ($readOnlyMountPoints) {
1581 $defaultStorageRow = $this->db->exec_SELECTgetSingleRow(
'uid',
'sys_file_storage', $whereClause);
1583 foreach ($readOnlyMountPointArray as $readOnlyMountPoint) {
1585 if (count($readOnlyMountPointConfiguration) === 2) {
1587 $storageUid = (int)$readOnlyMountPointConfiguration[0];
1588 $path = $readOnlyMountPointConfiguration[1];
1590 if (empty($defaultStorageRow)) {
1591 throw new \RuntimeException(
'Read only mount points have been defined in User TsConfig without specific storage, but a default storage could not be resolved.', 1404472382);
1594 $storageUid = $defaultStorageRow[
'uid'];
1595 $path = $readOnlyMountPointConfiguration[0];
1597 $fileMountRecordCache[$storageUid . $path] = array(
1598 'base' => $storageUid,
1608 if ($this->workspace <= 0 || empty($this->workspaceRec[
'file_mountpoints'])) {
1610 if (
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'userHomePath']) {
1611 list($userHomeStorageUid, $userHomeFilter) = explode(
':',
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'userHomePath'], 2);
1612 $userHomeStorageUid = (int)$userHomeStorageUid;
1613 $userHomeFilter =
'/' . ltrim($userHomeFilter,
'/');
1614 if ($userHomeStorageUid > 0) {
1616 $path = $userHomeFilter . $this->user[
'uid'] .
'_' . $this->user[
'username'] .
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'userUploadDir'];
1617 $fileMountRecordCache[$userHomeStorageUid . $path] = array(
1618 'base' => $userHomeStorageUid,
1619 'title' => $this->user[
'username'],
1621 'read_only' =>
false,
1622 'user_mount' =>
true
1625 $path = $userHomeFilter . $this->user[
'uid'] .
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'userUploadDir'];
1626 $fileMountRecordCache[$userHomeStorageUid . $path] = array(
1627 'base' => $userHomeStorageUid,
1628 'title' => $this->user[
'username'],
1630 'read_only' =>
false,
1631 'user_mount' =>
true
1637 if ((is_array($this->user) && $this->user[
'options'] &
Permission::PAGE_EDIT) == 2 &&
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'groupHomePath'] !=
'') {
1639 list($groupHomeStorageUid, $groupHomeFilter) = explode(
':',
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'groupHomePath'], 2);
1640 $groupHomeStorageUid = (int)$groupHomeStorageUid;
1641 $groupHomeFilter =
'/' . ltrim($groupHomeFilter,
'/');
1642 if ($groupHomeStorageUid > 0) {
1644 $path = $groupHomeFilter . $groupData[
'uid'];
1645 $fileMountRecordCache[$groupHomeStorageUid . $path] = array(
1646 'base' => $groupHomeStorageUid,
1647 'title' => $groupData[
'title'],
1649 'read_only' =>
false,
1650 'user_mount' =>
true
1657 return $fileMountRecordCache;
1671 if ($this->fileStorages === null) {
1672 $this->initializeFileStorages();
1687 if ($this->uc[
'showHiddenFilesAndFolders']) {
1688 \TYPO3\CMS\Core\Resource\Filter\FileNameFilter::setShowHiddenFilesAndFolders(
true);
1731 if (!isset($this->filePermissions)) {
1735 'readFile' =>
false,
1736 'writeFile' =>
false,
1737 'copyFile' =>
false,
1738 'moveFile' =>
false,
1739 'renameFile' =>
false,
1740 'unzipFile' =>
false,
1741 'deleteFile' =>
false,
1743 'addFolder' =>
false,
1744 'readFolder' =>
false,
1745 'writeFolder' =>
false,
1746 'copyFolder' =>
false,
1747 'moveFolder' =>
false,
1748 'renameFolder' =>
false,
1749 'deleteFolder' =>
false,
1750 'recursivedeleteFolder' =>
false
1757 $userGroupRecordPermissions,
1764 $permissionsTsConfig = $this->
getTSConfigProp(
'permissions.file.default');
1765 if (!empty($permissionsTsConfig)) {
1767 $permissionsTsConfig,
1793 $storageFilePermissions = $this->
getTSConfigProp(
'permissions.file.storage.' . $storageObject->getUid());
1794 if (!empty($storageFilePermissions)) {
1796 $storageFilePermissions,
1797 function ($value, $permission) use (&$finalUserPermissions) {
1798 $finalUserPermissions[$permission] = (bool)$value;
1803 return $finalUserPermissions;
1823 public function getDefaultUploadFolder($pid = null, $table = null, $field = null)
1825 $uploadFolder = $this->
getTSConfigVal(
'options.defaultUploadFolder');
1826 if ($uploadFolder) {
1827 $uploadFolder = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFolderObjectFromCombinedIdentifier($uploadFolder);
1830 if ($storage->isDefault() && $storage->isWritable()) {
1832 $uploadFolder = $storage->getDefaultFolder();
1833 if ($uploadFolder->checkActionPermission(
'add')) {
1836 $uploadFolder = null;
1837 }
catch (\TYPO3\CMS\Core\Resource\Exception $folderAccessException) {
1843 if (!$uploadFolder instanceof \TYPO3\CMS\Core\Resource\Folder) {
1846 if ($storage->isWritable()) {
1848 $uploadFolder = $storage->getDefaultFolder();
1849 if ($uploadFolder->checkActionPermission(
'add')) {
1852 $uploadFolder = null;
1853 }
catch (\TYPO3\CMS\Core\Resource\Exception $folderAccessException) {
1862 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_userauthgroup.php'][
'getDefaultUploadFolder'])) {
1863 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_userauthgroup.php'][
'getDefaultUploadFolder'] as $_funcRef) {
1865 'uploadFolder' => $uploadFolder,
1874 if ($uploadFolder instanceof \TYPO3\CMS\Core\Resource\Folder) {
1875 return $uploadFolder;
1891 $defaultTemporaryFolder = null;
1892 $defaultFolder = $this->getDefaultUploadFolder();
1894 if ($defaultFolder !==
false) {
1895 $tempFolderName =
'_temp_';
1896 $createFolder = !$defaultFolder->hasFolder($tempFolderName);
1897 if ($createFolder ===
true) {
1899 $defaultTemporaryFolder = $defaultFolder->createFolder($tempFolderName);
1900 }
catch (\TYPO3\CMS\Core\Resource\
Exception $folderAccessException) {
1903 $defaultTemporaryFolder = $defaultFolder->getSubfolder($tempFolderName);
1907 return $defaultTemporaryFolder;
1918 $delimiter =
'# ***********************************************';
1919 $out = $delimiter . LF;
1921 foreach ($lines as $v) {
1922 $out .=
'# ' . $v . LF;
1924 $out .= $delimiter . LF;
1941 if ($allowed_languages = $this->
getTSConfigVal(
'options.workspaces.allowed_languages.' . $this->workspace)) {
1942 $this->groupData[
'allowed_languages'] = $allowed_languages;
1954 $dbMountpoints = trim($this->workspaceRec[
'db_mountpoints']);
1955 if ($this->workspace > 0 && $dbMountpoints !=
'') {
1956 $filteredDbMountpoints = array();
1966 foreach ($dbMountpoints as $mpId) {
1968 $filteredDbMountpoints[] = $mpId;
1972 $filteredDbMountpoints = array_unique($filteredDbMountpoints);
1973 $this->groupData[
'webmounts'] = implode(
',', $filteredDbMountpoints);
1984 public function checkWorkspace($wsRec, $fields =
'uid,title,adminusers,members,reviewers,publish_access,stagechg_notification')
1988 if (!is_array($wsRec)) {
1989 switch ((
string)$wsRec) {
1991 $wsRec = array(
'uid' => $wsRec);
1994 if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded(
'workspaces')) {
1995 $wsRec = $this->db->exec_SELECTgetSingleRow($fields,
2005 if (is_array($wsRec)) {
2007 return array_merge($wsRec, array(
'_ACCESS' =>
'admin'));
2009 switch ((
string)$wsRec[
'uid']) {
2012 ? array_merge($wsRec, array(
'_ACCESS' =>
'online'))
2018 return array_merge($wsRec, array(
'_ACCESS' =>
'owner'));
2021 foreach ($this->userGroupsUID as $groupUid) {
2023 return array_merge($wsRec, array(
'_ACCESS' =>
'owner'));
2028 return array_merge($wsRec, array(
'_ACCESS' =>
'reviewer'));
2031 foreach ($this->userGroupsUID as $groupUid) {
2033 return array_merge($wsRec, array(
'_ACCESS' =>
'reviewer'));
2038 return array_merge($wsRec, array(
'_ACCESS' =>
'member'));
2041 foreach ($this->userGroupsUID as $groupUid) {
2043 return array_merge($wsRec, array(
'_ACCESS' =>
'member'));
2061 if (!isset($this->checkWorkspaceCurrent_cache)) {
2062 $this->checkWorkspaceCurrent_cache = $this->
checkWorkspace($this->workspace);
2080 $this->checkWorkspaceCurrent_cache = null;
2082 if ((
int)$this->workspace !== (
int)$this->user[
'workspace_id']) {
2084 $this->db->exec_UPDATEquery(
'be_users',
'uid=' . (
int)$this->user[
'uid'], array(
'workspace_id' => $this->user[
'workspace_id']));
2085 $this->
simplelog(
'User changed workspace to "' . $this->workspace .
'"');
2100 if ($workspaceRecord) {
2101 $this->workspaceRec = $workspaceRecord;
2102 $this->workspace = (int)$workspaceId;
2117 $this->workspaceRec = $this->
checkWorkspace($this->workspace,
'*');
2128 $this->user[
'workspace_preview'] = $previewState;
2129 $this->db->exec_UPDATEquery(
'be_users',
'uid=' . (
int)$this->user[
'uid'], array(
'workspace_preview' => $this->user[
'workspace_preview']));
2141 $defaultWorkspace = -99;
2142 if (!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded(
'workspaces') || $this->
checkWorkspace(0)) {
2144 $defaultWorkspace = 0;
2147 $defaultWorkspace = -1;
2148 }
elseif (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded(
'workspaces')) {
2150 $workspaces = $this->db->exec_SELECTgetRows(
'uid,title,adminusers,members,reviewers',
'sys_workspace',
'pid=0' .
BackendUtility::deleteClause(
'sys_workspace'),
'',
'title');
2151 foreach ($workspaces as $rec) {
2153 $defaultWorkspace = $rec[
'uid'];
2158 return $defaultWorkspace;
2179 public function writelog($type, $action, $error, $details_nr, $details, $data, $tablename =
'', $recuid =
'', $recpid =
'', $event_pid = -1, $NEWid =
'', $userId = 0)
2183 if (!empty($this->user[
'ses_backuserid'])) {
2184 $userId = $this->user[
'ses_backuserid'];
2185 }
elseif (!empty($this->user[
'uid'])) {
2186 $userId = $this->user[
'uid'];
2190 $fields_values = array(
2191 'userid' => (
int)$userId,
2192 'type' => (
int)$type,
2193 'action' => (
int)$action,
2194 'error' => (
int)$error,
2195 'details_nr' => (
int)$details_nr,
2196 'details' => $details,
2197 'log_data' => serialize($data),
2198 'tablename' => $tablename,
2199 'recuid' => (
int)$recuid,
2202 'event_pid' => (
int)$event_pid,
2204 'workspace' => $this->workspace
2206 $this->db->exec_INSERTquery(
'sys_log', $fields_values);
2207 return $this->db->sql_insert_id();
2218 public function simplelog($message, $extKey =
'', $error = 0)
2220 return $this->
writelog(4, 0, $error, 0, ($extKey ?
'[' . $extKey .
'] ' :
'') . $message, array());
2239 $theTimeBack =
$GLOBALS[
'EXEC_TIME'] - $secondsBack;
2240 $res = $this->db->exec_SELECTquery(
'tstamp',
'sys_log',
'type=255 AND action=4 AND tstamp>' . (
int)$theTimeBack,
'',
'tstamp DESC',
'1');
2241 if ($testRow = $this->db->sql_fetch_assoc($res)) {
2242 $theTimeBack = $testRow[
'tstamp'];
2244 $this->db->sql_free_result($res);
2246 $res = $this->db->exec_SELECTquery(
'*',
'sys_log',
'type=255 AND action=3 AND error<>0 AND tstamp>' . (
int)$theTimeBack,
'',
'tstamp');
2247 if ($this->db->sql_num_rows($res) > $max) {
2249 $subject =
'TYPO3 Login Failure Warning (at ' .
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'sitename'] .
')';
2250 $email_body =
'There have been some attempts (' . $this->db->sql_num_rows($res) .
') to login at the TYPO3
2253 This is a dump of the failures:
2256 while ($testRows = $this->db->sql_fetch_assoc($res)) {
2257 $theData = unserialize($testRows[
'log_data']);
2258 $email_body .= date(
2259 $GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'ddmmyy'] .
' ' .
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'hhmm'],
2261 ) .
': ' . @sprintf($testRows[
'details'], (
string)$theData[0], (
string)$theData[1], (
string)$theData[2]);
2264 $from = \TYPO3\CMS\Core\Utility\MailUtility::getSystemFrom();
2267 $mail->setTo($email)->setFrom($from)->setSubject($subject)->setBody($email_body);
2270 $this->
writelog(255, 4, 0, 3,
'Failure warning (%s failures within %s seconds) sent by email to %s', array($this->db->sql_num_rows($res), $secondsBack, $email));
2271 $this->db->sql_free_result($res);
2284 $configuredCookieName = trim(
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'cookieName']);
2285 if (empty($configuredCookieName)) {
2286 $configuredCookieName =
'be_typo_user';
2288 return $configuredCookieName;
2301 if (
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'enabledBeUserIPLock']) {
2303 if (trim($IPList)) {
2324 if (empty($this->user[
'uid'])) {
2325 if ($proceedIfNoUserIsLoggedIn ===
false) {
2327 \TYPO3\CMS\Core\Utility\HttpUtility::redirect(
$url);
2339 $this->emailAtLogin();
2341 throw new \RuntimeException(
'Login Error: TYPO3 is in maintenance mode at the moment. Only administrators are allowed access.', 1294585860);
2344 throw new \RuntimeException(
'Login Error: IP locking prevented you from being authorized. Can\'t proceed, sorry.', 1294585861);
2359 if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI) {
2360 if (!$this->user[
'uid']) {
2361 if (substr(
$GLOBALS[
'MCONF'][
'name'], 0, 5) ==
'_CLI_') {
2362 $userName = strtolower(
$GLOBALS[
'MCONF'][
'name']);
2364 if ($this->user[
'uid']) {
2368 fwrite(STDERR,
'ERROR: CLI backend user "' . $userName .
'" was ADMIN which is not allowed!' . LF . LF);
2372 fwrite(STDERR,
'ERROR: No backend user named "' . $userName .
'" was found!' . LF . LF);
2376 fwrite(STDERR,
'ERROR: Module name, "' .
$GLOBALS[
'MCONF'][
'name'] .
'", was not prefixed with "_CLI_"' . LF . LF);
2380 fwrite(STDERR,
'ERROR: Another user was already loaded which is impossible in CLI mode!' . LF . LF);
2398 $temp_theSavedUC = unserialize($this->user[
'uc']);
2399 if (is_array($temp_theSavedUC)) {
2404 $originalUc = array();
2405 if (is_array($this->uc) && isset($this->uc[
'ucSetByInstallTool'])) {
2407 unset($originalUc[
'ucSetByInstallTool'], $this->uc);
2409 if (!is_array($this->uc)) {
2410 $this->uc = array_merge(
2412 (array)
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'defaultUC'],
2420 if ($this->userTSUpdated) {
2425 if (!isset($this->uc[
'lang'])) {
2426 $this->uc[
'lang'] = $this->user[
'lang'];
2430 if (!isset($this->uc[
'firstLoginTimeStamp'])) {
2431 $this->uc[
'firstLoginTimeStamp'] =
$GLOBALS[
'EXEC_TIME'];
2449 $this->uc = array_merge((array)$this->uc, (array)$this->
getTSConfigProp(
'setup.override'));
2460 $this->user[
'uc'] =
'';
2472 private function emailAtLogin()
2474 if ($this->loginSessionStarted) {
2476 $subject =
'At "' .
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'sitename'] .
'"' .
' from '
2480 'User "%s" logged in from %s (%s) at "%s" (%s)',
2481 $this->user[
'username'],
2484 $GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'sitename'],
2488 if (
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'warning_email_addr']) {
2491 if ((
int)
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'warning_mode'] & 1) {
2494 $prefix = $this->
isAdmin() ?
'[AdminLoginWarning]' :
'[LoginWarning]';
2496 if ($this->
isAdmin() && (
int)$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'warning_mode'] & 2) {
2499 $prefix =
'[AdminLoginWarning]';
2502 $from = \TYPO3\CMS\Core\Utility\MailUtility::getSystemFrom();
2505 $mail->setTo($GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'warning_email_addr'])->setFrom($from)->setSubject($prefix .
' ' . $subject)->setBody($msg);
2510 if ($this->uc[
'emailMeAtLogin'] && strstr($this->user[
'email'],
'@')) {
2511 $from = \TYPO3\CMS\Core\Utility\MailUtility::getSystemFrom();
2514 $mail->setTo($this->user[
'email'])->setFrom($from)->setSubject($subject)->setBody($msg);
2533 $isUserAllowedToLogin =
false;
2534 $adminOnlyMode = $GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'adminOnly'];
2536 if (!$adminOnlyMode || $this->
isAdmin()) {
2537 $isUserAllowedToLogin =
true;
2538 }
elseif ($adminOnlyMode == 2 && TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI) {
2539 $isUserAllowedToLogin =
true;
2540 }
elseif ($this->user[
'ses_backuserid']) {
2541 $backendUserId = (int)$this->user[
'ses_backuserid'];
2543 if ($this->db->exec_SELECTcountRows(
'uid',
'be_users', $whereAdmin) > 0) {
2544 $isUserAllowedToLogin =
true;
2547 return $isUserAllowedToLogin;
2555 if (isset($GLOBALS[
'BE_USER']) && $GLOBALS[
'BE_USER'] instanceof
BackendUserAuthentication && isset($GLOBALS[
'BE_USER']->user[
'uid'])) {
2556 \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get()->clean();