[BUGFIX] Some methods in t3lib_TSparser should be static
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_userauthgroup.php
index b6c81ee..263c2f9 100644 (file)
  *
  * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  */
-/**
- * [CLASS/FUNCTION INDEX of SCRIPT]
- *
- *
- *
- *  135: class t3lib_userAuthGroup extends t3lib_userAuth
- *
- *                       SECTION: Permission checking functions:
- *  199:        function isAdmin()
- *  211:        function isMemberOfGroup($groupId)
- *  233:        function doesUserHaveAccess($row,$perms)
- *  250:        function isInWebMount($id,$readPerms='',$exitOnError=0)
- *  277:        function modAccess($conf,$exitOnError)
- *  328:        function getPagePermsClause($perms)
- *  367:        function calcPerms($row)
- *  405:        function isRTE()
- *  439:        function check($type,$value)
- *  456:        function checkAuthMode($table,$field,$value,$authMode)
- *  522:        function checkLanguageAccess($langValue)
- *  544:        function recordEditAccessInternals($table,$idOrRow,$newRecord=FALSE)
- *  619:        function isPSet($lCP,$table,$type='')
- *  636:        function mayMakeShortcut()
- *  650:        function workspaceCannotEditRecord($table,$recData)
- *  689:        function workspaceCannotEditOfflineVersion($table,$recData)
- *  712:        function workspaceAllowLiveRecordsInPID($pid, $table)
- *  733:        function workspaceCreateNewRecord($pid, $table)
- *  752:        function workspaceAllowAutoCreation($table,$id,$recpid)
- *  772:        function workspaceCheckStageForCurrent($stage)
- *  795:        function workspacePublishAccess($wsid)
- *  823:        function workspaceSwapAccess()
- *  835:        function workspaceVersioningTypeAccess($type)
- *  866:        function workspaceVersioningTypeGetClosest($type)
- *
- *                       SECTION: Miscellaneous functions
- *  909:        function getTSConfig($objectString,$config='')
- *  935:        function getTSConfigVal($objectString)
- *  947:        function getTSConfigProp($objectString)
- *  959:        function inList($in_list,$item)
- *  970:        function returnWebmounts()
- *  980:        function returnFilemounts()
- *  997:        function jsConfirmation($bitmask)
- *
- *                       SECTION: Authentication methods
- * 1035:        function fetchGroupData()
- * 1168:        function fetchGroups($grList,$idList='')
- * 1266:        function setCachedList($cList)
- * 1286:        function addFileMount($title, $altTitle, $path, $webspace, $type)
- * 1333:        function addTScomment($str)
- *
- *                       SECTION: Workspaces
- * 1369:        function workspaceInit()
- * 1412:        function checkWorkspace($wsRec,$fields='uid,title,adminusers,members,reviewers,publish_access,stagechg_notification')
- * 1487:        function checkWorkspaceCurrent()
- * 1500:        function setWorkspace($workspaceId)
- * 1528:        function setWorkspacePreview($previewState)
- * 1538:        function getDefaultWorkspace()
- *
- *                       SECTION: Logging
- * 1589:        function writelog($type,$action,$error,$details_nr,$details,$data,$tablename='',$recuid='',$recpid='',$event_pid=-1,$NEWid='',$userId=0)
- * 1621:        function simplelog($message, $extKey='', $error=0)
- * 1642:        function checkLogFailures($email, $secondsBack=3600, $max=3)
- *
- * TOTAL FUNCTIONS: 45
- * (This index is automatically created/updated by the extension "extdeveval")
- *
- */
 
 
 /**
  * @package TYPO3
  * @subpackage t3lib
  */
-class t3lib_userAuthGroup extends t3lib_userAuth {
+abstract class t3lib_userAuthGroup extends t3lib_userAuth {
        var $usergroup_column = 'usergroup'; // Should be set to the usergroup-column (id-list) in the user-record
        var $usergroup_table = 'be_groups'; // The name of the group-table
 
@@ -306,7 +240,6 @@ class t3lib_userAuthGroup extends t3lib_userAuth {
         * @return      string          Part of where clause. Prefix " AND " to this.
         */
        function getPagePermsClause($perms) {
-               global $TYPO3_CONF_VARS;
                if (is_array($this->user)) {
                        if ($this->isAdmin()) {
                                return ' 1=1';
@@ -324,9 +257,9 @@ class t3lib_userAuthGroup extends t3lib_userAuth {
                                // ****************
                                // getPagePermsClause-HOOK
                                // ****************
-                       if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_userauthgroup.php']['getPagePermsClause'])) {
+                       if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauthgroup.php']['getPagePermsClause'])) {
 
-                               foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_userauthgroup.php']['getPagePermsClause'] as $_funcRef) {
+                               foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauthgroup.php']['getPagePermsClause'] as $_funcRef) {
                                        $_params = array('currentClause' => $str, 'perms' => $perms);
                                        $str = t3lib_div::callUserFunction($_funcRef, $_params, $this);
                                }
@@ -347,7 +280,6 @@ class t3lib_userAuthGroup extends t3lib_userAuth {
         * @return      integer         Bitwise representation of the users permissions in relation to input page row, $row
         */
        function calcPerms($row) {
-               global $TYPO3_CONF_VARS;
                if ($this->isAdmin()) {
                        return 31;
                } // Return 31 for admin users.
@@ -366,8 +298,8 @@ class t3lib_userAuthGroup extends t3lib_userAuth {
                        // ****************
                        // CALCPERMS hook
                        // ****************
-               if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_userauthgroup.php']['calcPerms'])) {
-                       foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_userauthgroup.php']['calcPerms'] as $_funcRef) {
+               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauthgroup.php']['calcPerms'])) {
+                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauthgroup.php']['calcPerms'] as $_funcRef) {
                                $_params = array(
                                        'row' => $row,
                                        'outputPermissions' => $out
@@ -387,8 +319,6 @@ class t3lib_userAuthGroup extends t3lib_userAuth {
         * @return      boolean
         */
        function isRTE() {
-               global $CLIENT;
-
                        // Start:
                $this->RTE_errors = array();
                if (!$this->uc['edit_RTE']) {
@@ -751,8 +681,9 @@ class t3lib_userAuthGroup extends t3lib_userAuth {
                                                return 'Versioning disabled for table';
                                        } elseif ((int) $recData['t3ver_wsid'] !== $this->workspace) { // So does workspace match?
                                                return 'Workspace ID of record didn\'t match current workspace';
-                                       } else { // So what about the stage of the version, does that allow editing for this user?
-                                               return $this->workspaceCheckStageForCurrent($recData['t3ver_stage']) ? FALSE : 'Record stage "' . $recData['t3ver_stage'] . '" and users access level did not allow for editing';
+                                       } else {
+                                                       // So is the user allowed to "use" the edit stage within the workspace?
+                                               return $this->workspaceCheckStageForCurrent(0) ? FALSE : 'User\'s access level did not allow for editing';
                                        }
                                } else { // We are testing a "live" record:
                                        if ($res = $this->workspaceAllowLiveRecordsInPID($recData['pid'], $table)) { // For "Live" records, check that PID for table allows editing
@@ -924,10 +855,9 @@ class t3lib_userAuthGroup extends t3lib_userAuth {
         * Returns TRUE if the user has access to publish content from the workspace ID given.
         * Admin-users are always granted access to do this
         * If the workspace ID is 0 (live) all users have access also
-        * If -1 (draft workspace) TRUE is returned if the user has access to the Live workspace
         * For custom workspaces it depends on whether the user is owner OR like with draft workspace if the user has access to Live workspace.
         *
-        * @param       integer         Workspace UID; -1,0,1+
+        * @param       integer         Workspace UID; 0,1+
         * @return      boolean         Returns TRUE if the user has access to publish content from the workspace ID given.
         */
        function workspacePublishAccess($wsid) {
@@ -944,9 +874,6 @@ class t3lib_userAuthGroup extends t3lib_userAuth {
                                case 0: // Live workspace
                                        $retVal = TRUE; // If access to Live workspace, no problem.
                                break;
-                               case -1: // Default draft workspace
-                                       $retVal = $this->checkWorkspace(0) ? TRUE : FALSE; // If access to Live workspace, no problem.
-                               break;
                                default: // Custom workspace
                                        $retVal = $wsAccess['_ACCESS'] === 'owner' || ($this->checkWorkspace(0) && !($wsAccess['publish_access'] & 2)); // Either be an adminuser OR have access to online workspace which is OK as well as long as publishing access is not limited by workspace option.
                                break;
@@ -982,7 +909,7 @@ class t3lib_userAuthGroup extends t3lib_userAuth {
        function workspaceVersioningTypeAccess($type) {
                $retVal = FALSE;
 
-               $type = t3lib_div::intInRange($type, -1);
+               $type = t3lib_utility_Math::forceIntegerInRange($type, -1);
 
                        // Check if only element versioning is allowed:
                if ($GLOBALS['TYPO3_CONF_VARS']['BE']['elementVersioningOnly'] && $type != -1) {
@@ -1022,7 +949,7 @@ class t3lib_userAuthGroup extends t3lib_userAuth {
         * @return      integer         Returning versioning type
         */
        function workspaceVersioningTypeGetClosest($type) {
-               $type = t3lib_div::intInRange($type, -1);
+               $type = t3lib_utility_Math::forceIntegerInRange($type, -1);
 
                if ($this->workspace > 0) {
                        switch ((int) $type) {
@@ -1346,8 +1273,6 @@ class t3lib_userAuthGroup extends t3lib_userAuth {
         * @access private
         */
        function fetchGroups($grList, $idList = '') {
-               global $TYPO3_CONF_VARS;
-
                        // Fetching records of the groups in $grList (which are not blocked by lockedToDomain either):
                $lockToDomain_SQL = ' AND (lockToDomain=\'\' OR lockToDomain IS NULL OR lockToDomain=\'' . t3lib_div::getIndpEnv('HTTP_HOST') . '\')';
                $whereSQL = 'deleted=0 AND hidden=0 AND pid=0 AND uid IN (' . $grList . ')' . $lockToDomain_SQL;
@@ -1434,8 +1359,8 @@ class t3lib_userAuthGroup extends t3lib_userAuth {
                        // ****************
                        // HOOK: fetchGroups_postProcessing
                        // ****************
-               if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_userauthgroup.php']['fetchGroups_postProcessing'])) {
-                       foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_userauthgroup.php']['fetchGroups_postProcessing'] as $_funcRef) {
+               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauthgroup.php']['fetchGroups_postProcessing'])) {
+                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauthgroup.php']['fetchGroups_postProcessing'] as $_funcRef) {
                                $_params = array();
                                t3lib_div::callUserFunction($_funcRef, $_params, $this);
                        }
@@ -1621,27 +1546,10 @@ class t3lib_userAuthGroup extends t3lib_userAuth {
        function checkWorkspace($wsRec, $fields = 'uid,title,adminusers,members,reviewers,publish_access,stagechg_notification') {
                $retVal = FALSE;
 
-                       // Show draft workspace only if it's enabled in version extension
-               if (t3lib_extMgm::isLoaded('version')) {
-                       $versionExtConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['version']);
-                       if (!$versionExtConf['showDraftWorkspace']) {
-                               if (!is_array($wsRec)) {
-                                       if ((string) $wsRec === '-1') {
-                                               return FALSE;
-                                       }
-                               } else {
-                                       if ((string) $wsRec['uid'] === '-1') {
-                                               return FALSE;
-                                       }
-                               }
-                       }
-               }
-
                        // If not array, look up workspace record:
                if (!is_array($wsRec)) {
                        switch ((string) $wsRec) {
                                case '0':
-                               case '-1':
                                        $wsRec = array('uid' => $wsRec);
                                break;
                                default:
@@ -1669,9 +1577,6 @@ class t3lib_userAuthGroup extends t3lib_userAuth {
                                        case '0':
                                                $retVal = ($this->groupData['workspace_perms'] & 1) ? array_merge($wsRec, array('_ACCESS' => 'online')) : FALSE;
                                        break;
-                                       case '-1':
-                                               $retVal = ($this->groupData['workspace_perms'] & 2) ? array_merge($wsRec, array('_ACCESS' => 'offline')) : FALSE;
-                                       break;
                                        default:
                                                        // Checking if the guy is admin:
                                                if (t3lib_div::inList($wsRec['adminusers'], 'be_users_' . $this->user['uid'])) {
@@ -1922,4 +1827,4 @@ if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLA
        include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_userauthgroup.php']);
 }
 
-?>
\ No newline at end of file
+?>