Main Page | Directories | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages | Examples

t3lib_userAuthGroup Class Reference

Inherits t3lib_userAuth.

Inherited by t3lib_beUserAuth.

List of all members.

Public Member Functions

 isAdmin ()
 Returns true if user is admin Basically this function evaluates if the ->user[admin] field has bit 0 set.
 isMemberOfGroup ($groupId)
 Returns true if the current user is a member of group $groupId $groupId must be set.
 doesUserHaveAccess ($row, $perms)
 Checks if the permissions is granted based on a page-record ($row) and $perms (binary and'ed).
 isInWebMount ($id, $readPerms='', $exitOnError=0)
 Checks if the page id, $id, is found within the webmounts set up for the user.
 modAccess ($conf, $exitOnError)
 Checks access to a backend module with the $MCONF passed as first argument.
 getPagePermsClause ($perms)
 Returns a WHERE-clause for the pages-table where user permissions according to input argument, $perms, is validated.
 calcPerms ($row)
 Returns a combined binary representation of the current users permissions for the page-record, $row.
 isRTE ()
 Returns true if the RTE (Rich Text Editor) can be enabled for the user Strictly this is not permissions being checked but rather a series of settings like a loaded extension, browser/client type and a configuration option in ->uc[edit_RTE] The reasons for a FALSE return can be found in $this->RTE_errors.
 check ($type, $value)
 Returns true if the $value is found in the list in a $this->groupData[] index pointed to by $type (array key).
 checkAuthMode ($table, $field, $value, $authMode)
 Checking the authMode of a select field with authMode set.
 checkLanguageAccess ($langValue)
 Checking if a language value (-1, 0 and >0 for sys_language records) is allowed to be edited by the user.
 recordEditAccessInternals ($table, $idOrRow)
 Checking if a user has editing access to a record from a $TCA table.
 isPSet ($lCP, $table, $type='')
 Will check a type of permission against the compiled permission integer, $lCP, and in relation to table, $table.
 mayMakeShortcut ()
 Returns true if the BE_USER is allowed to *create* shortcuts in the backend modules.
 getTSConfig ($objectString, $config='')
 Returns the value/properties of a TS-object as given by $objectString, eg.
 getTSConfigVal ($objectString)
 Returns the "value" of the $objectString from the BE_USERS "User TSconfig" array.
 getTSConfigProp ($objectString)
 Returns the "properties" of the $objectString from the BE_USERS "User TSconfig" array.
 inList ($in_list, $item)
 Returns true if $item is in $in_list.
 returnWebmounts ()
 Returns an array with the webmounts.
 returnFilemounts ()
 Returns an array with the filemounts for the user.
 fetchGroupData ()
 Initializes a lot of stuff like the access-lists, database-mountpoints and filemountpoints This method is called by ->backendCheckLogin() (from extending class t3lib_beuserauth) if the backend user login has verified OK.
 fetchGroups ($grList, $idList='')
 Fetches the group records, subgroups and fills internal arrays.
 setCachedList ($cList)
 Updates the field be_users.usergroup_cached_list if the groupList of the user has changed/is different from the current list.
 addFileMount ($title, $altTitle, $path, $webspace, $type)
 Adds a filemount to the users array of filemounts, $this->groupData['filemounts'][hash_key] = Array ('name'=>$name, 'path'=>$path, 'type'=>$type); Is a part of the authentication proces of the user.
 addTScomment ($str)
 Creates a TypoScript comment with the string text inside.

Public Attributes

 $usergroup_column = 'usergroup'
 $usergroup_table = 'be_groups'
 $groupData
 $userGroups = Array()
 $userGroupsUID = Array()
 $groupList = ''
 $dataLists
 $includeHierarchy = array()
 $includeGroupArray = array()
 $OS = ''
 $TSdataArray = array()
 $userTS_text = ''
 $userTS = array()
 $userTSUpdated = 0
 $userTS_dontGetCached = 0
 $RTE_errors = array()
 $errorMsg = ''


Member Function Documentation

t3lib_userAuthGroup::addFileMount title,
altTitle,
path,
webspace,
type
 

Adds a filemount to the users array of filemounts, $this->groupData['filemounts'][hash_key] = Array ('name'=>$name, 'path'=>$path, 'type'=>$type); Is a part of the authentication proces of the user.

A final requirement for a path being mounted is that a) it MUST return true on is_dir(), b) must contain either PATH_site+'fileadminDir' OR 'lockRootPath' - if lockRootPath is set - as first part of string! Paths in the mounted information will always be absolute and have a trailing slash.

Parameters:
string $title will be the (root)name of the filemount in the folder tree
string $altTitle will be the (root)name of the filemount IF $title is not true (blank or zero)
string $path is the path which should be mounted. Will accept backslash in paths on windows servers (will substituted with forward slash). The path should be 1) relative to TYPO3_CONF_VARS[BE][fileadminDir] if $webspace is set, otherwise absolute.
boolean If $webspace is set, the $path is relative to 'fileadminDir' in TYPO3_CONF_VARS, otherwise $path is absolute. 'fileadminDir' must be set to allow mounting of relative paths.
string Type of filemount; Can be blank (regular) or "user" / "group" (for user and group filemounts presumably). Probably sets the icon first and foremost.
Returns:
boolean Returns "1" if the requested filemount was mounted, otherwise no return value. private

Definition at line 902 of file class.t3lib_userauthgroup.php.

References PATH_site.

00902                                                                      {
00903          // Return false if fileadminDir is not set and we try to mount a relative path
00904       if ($webspace && !$GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir']) return false;
00905 
00906          // Trimming and pre-processing
00907       $path=trim($path);
00908       if ($this->OS=='WIN')   {     // with WINDOWS convert backslash to slash!!
00909          $path=str_replace('\\','/',$path);
00910       }
00911          // If the path is true and validates as a valid path string:
00912       if ($path && t3lib_div::validPathStr($path)) {
00913             // these lines remove all slashes and dots before and after the path
00914          $path=ereg_replace('^[\/\. ]*','',$path);
00915          $path=trim(ereg_replace('[\/\. ]*$','',$path));
00916 
00917 
00918          if ($path)  {  // there must be some chars in the path
00919             $fdir=PATH_site.$GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'];   // fileadmin dir, absolute
00920             if ($webspace) {
00921                $path=$fdir.$path;   // PATH_site + fileadmin dir is prepended
00922             } else {
00923                if ($this->OS!='WIN')   {     // with WINDOWS no prepending!!
00924                   $path='/'.$path;  // root-level is the start...
00925                }
00926             }
00927             $path.='/';
00928 
00929                // We now have a path with slash after and slash before (if unix)
00930             if (@is_dir($path) &&
00931                (($GLOBALS['TYPO3_CONF_VARS']['BE']['lockRootPath'] && t3lib_div::isFirstPartOfStr($path,$GLOBALS['TYPO3_CONF_VARS']['BE']['lockRootPath'])) || t3lib_div::isFirstPartOfStr($path,$fdir)))   {
00932                      // Alternative title?
00933                   $name = $title ? $title : $altTitle;
00934                      // Adds the filemount. The same filemount with same name, type and path cannot be set up twice because of the hash string used as key.
00935                   $this->groupData['filemounts'][md5($name.'|'.$path.'|'.$type)] = Array('name'=>$name, 'path'=>$path, 'type'=>$type);
00936                      // Return true - went well, success!
00937                   return 1;
00938             }
00939          }
00940       }
00941    }

t3lib_userAuthGroup::addTScomment str  ) 
 

Creates a TypoScript comment with the string text inside.

Parameters:
string The text to wrap in comment prefixes and delimiters.
Returns:
string TypoScript comment with the string text inside.

Definition at line 949 of file class.t3lib_userauthgroup.php.

References $out.

t3lib_userAuthGroup::calcPerms row  ) 
 

Returns a combined binary representation of the current users permissions for the page-record, $row.

The perms for user, group and everybody is OR'ed together (provided that the page-owner is the user and for the groups that the user is a member of the group If the user is admin, 31 is returned (full permissions for all five flags)

Parameters:
array Input page row with all perms_* fields available.
Returns:
integer Bitwise representation of the users permissions in relation to input page row, $row

Definition at line 316 of file class.t3lib_userauthgroup.php.

References $out.

Referenced by doesUserHaveAccess().

00316                               {
00317       if ($this->isAdmin()) {return 31;}     // Return 31 for admin users.
00318 
00319       $out=0;
00320       if (isset($row['perms_userid']) && isset($row['perms_user']) && isset($row['perms_groupid']) && isset($row['perms_group']) && isset($row['perms_everybody']) && isset($this->groupList))  {
00321          if ($this->user['uid']==$row['perms_userid'])   {
00322             $out|=$row['perms_user'];
00323          }
00324          if ($this->isMemberOfGroup($row['perms_groupid'])) {
00325             $out|=$row['perms_group'];
00326          }
00327          $out|=$row['perms_everybody'];
00328       }
00329       return $out;
00330    }

t3lib_userAuthGroup::check type,
value
 

Returns true if the $value is found in the list in a $this->groupData[] index pointed to by $type (array key).

Can thus be users to check for modules, exclude-fields, select/modify permissions for tables etc. If user is admin true is also returned Please see the document Inside TYPO3 for examples.

Parameters:
string The type value; "webmounts", "filemounts", "pagetypes_select", "tables_select", "tables_modify", "non_exclude_fields", "modules"
string String to search for in the groupData-list
Returns:
boolean True if permission is granted (that is, the value was found in the groupData list - or the BE_USER is "admin")

Definition at line 373 of file class.t3lib_userauthgroup.php.

Referenced by modAccess().

00373                                  {
00374       if (isset($this->groupData[$type])) {
00375          if ($this->isAdmin() || $this->inList($this->groupData[$type],$value)) {
00376             return 1;
00377          }
00378       }
00379    }

t3lib_userAuthGroup::checkAuthMode table,
field,
value,
authMode
 

Checking the authMode of a select field with authMode set.

Parameters:
string Table name
string Field name (must be configured in TCA and of type "select" with authMode set!)
string Value to evaluation (single value, must not contain any of the chars ":,|")
string Auth mode keyword (explicitAllow, explicitDeny, individual)
Returns:
boolean True or false whether access is granted or not.

Definition at line 390 of file class.t3lib_userauthgroup.php.

References $out, $TCA, and table().

00390                                                             {
00391       global $TCA;
00392 
00393          // Admin users can do anything:
00394       if ($this->isAdmin())   return TRUE;
00395 
00396          // Allow all blank values:
00397       if (!strcmp($value,'')) return TRUE;
00398 
00399          // Certain characters are not allowed in the value
00400       if (ereg('[:|,]',$value))  {
00401          return FALSE;
00402       }
00403 
00404          // Initialize:
00405       $testValue = $table.':'.$field.':'.$value;
00406       $out = TRUE;
00407 
00408          // Checking value:
00409       switch((string)$authMode)  {
00410          case 'explicitAllow':
00411             if (!$this->inList($this->groupData['explicit_allowdeny'],$testValue.':ALLOW'))  {
00412                $out = FALSE;
00413             }
00414          break;
00415          case 'explicitDeny':
00416             if ($this->inList($this->groupData['explicit_allowdeny'],$testValue.':DENY')) {
00417                $out = FALSE;
00418             }
00419          break;
00420          case 'individual':
00421             t3lib_div::loadTCA($table);
00422             if (is_array($TCA[$table]) && is_array($TCA[$table]['columns'][$field]))   {
00423                $items = $TCA[$table]['columns'][$field]['config']['items'];
00424                if (is_array($items))   {
00425                   foreach($items as $iCfg)   {
00426                      if (!strcmp($iCfg[1],$value) && $iCfg[4]) {
00427                         switch((string)$iCfg[4])   {
00428                            case 'EXPL_ALLOW':
00429                               if (!$this->inList($this->groupData['explicit_allowdeny'],$testValue.':ALLOW'))  {
00430                                  $out = FALSE;
00431                               }
00432                            break;
00433                            case 'EXPL_DENY':
00434                               if ($this->inList($this->groupData['explicit_allowdeny'],$testValue.':DENY')) {
00435                                  $out = FALSE;
00436                               }
00437                            break;
00438                         }
00439                         break;
00440                      }
00441                   }
00442                }
00443             }
00444          break;
00445       }
00446 
00447       return $out;
00448    }

t3lib_userAuthGroup::checkLanguageAccess langValue  ) 
 

Checking if a language value (-1, 0 and >0 for sys_language records) is allowed to be edited by the user.

Parameters:
integer Language value to evaluate
Returns:
boolean Returns true if the language value is allowed, otherwise false.

Definition at line 456 of file class.t3lib_userauthgroup.php.

00456                                              {
00457       if (strcmp($this->groupData['allowed_languages'],'')) {  // The users language list must be non-blank - otherwise all languages are allowed.
00458          $langValue = intval($langValue);
00459          if ($langValue != -1 && !$this->check('allowed_languages',$langValue))  {  // Language must either be explicitly allowed OR the lang Value be "-1" (all languages)
00460             return FALSE;
00461          }
00462       }
00463       return TRUE;
00464    }

t3lib_userAuthGroup::doesUserHaveAccess row,
perms
 

Checks if the permissions is granted based on a page-record ($row) and $perms (binary and'ed).

Bits for permissions, see $perms variable:

1 - Show: See/Copy page and the pagecontent. 16- Edit pagecontent: Change/Add/Delete/Move pagecontent. 2- Edit page: Change/Move the page, eg. change title, startdate, hidden. 4- Delete page: Delete the page and pagecontent. 8- New pages: Create new pages under the page.

Parameters:
array $row is the pagerow for which the permissions is checked
integer $perms is the binary representation of the permission we are going to check. Every bit in this number represents a permission that must be set. See function explanation.
Returns:
boolean True or False upon evaluation

Definition at line 210 of file class.t3lib_userauthgroup.php.

References calcPerms().

00210                                              {
00211       $userPerms = $this->calcPerms($row);
00212       return ($userPerms & $perms)==$perms;
00213    }

t3lib_userAuthGroup::fetchGroupData  ) 
 

Initializes a lot of stuff like the access-lists, database-mountpoints and filemountpoints This method is called by ->backendCheckLogin() (from extending class t3lib_beuserauth) if the backend user login has verified OK.

Returns:
void private
See also:
t3lib_TSparser

Definition at line 687 of file class.t3lib_userauthgroup.php.

References checkIncludeLines_array(), t3lib_BEfunc::getHash(), t3lib_extMgm::isLoaded(), PATH_site, and t3lib_BEfunc::storeHash().

Referenced by t3lib_beUserAuth::backendCheckLogin().

00687                               {
00688       if ($this->user['uid']) {
00689 
00690             // Get lists for the be_user record and set them as default/primary values.
00691          $this->dataLists['modList'] = $this->user['userMods'];               // Enabled Backend Modules
00692          $this->dataLists['allowed_languages'] = $this->user['allowed_languages'];              // Add Allowed Languages
00693          $this->dataLists['webmount_list'] = $this->user['db_mountpoints'];      // Database mountpoints
00694          $this->dataLists['filemount_list'] = $this->user['file_mountpoints'];   // File mountpoints
00695 
00696             // Setting default User TSconfig:
00697          $this->TSdataArray[]=$this->addTScomment('From $GLOBALS["TYPO3_CONF_VARS"]["BE"]["defaultUserTSconfig"]:').
00698                            $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultUserTSconfig'];
00699 
00700             // Default TSconfig for admin-users
00701          if ($this->isAdmin())   {
00702             $this->TSdataArray[]=$this->addTScomment('"admin" user presets:').'
00703                admPanel.enable.all = 1
00704                options.shortcutFrame = 1
00705             ';
00706             if (t3lib_extMgm::isLoaded('tt_news')) {
00707                $this->TSdataArray[]='
00708                   // Setting defaults for tt_news author / email...
00709                   TCAdefaults.tt_news.author = '.$this->user['realName'].'
00710                   TCAdefaults.tt_news.author_email = '.$this->user['email'].'
00711                ';
00712             }
00713             if (t3lib_extMgm::isLoaded('sys_note'))   {
00714                $this->TSdataArray[]='
00715                   // Setting defaults for sys_note author / email...
00716                   TCAdefaults.sys_note.author = '.$this->user['realName'].'
00717                   TCAdefaults.sys_note.email = '.$this->user['email'].'
00718                ';
00719             }
00720          }
00721 
00722             // FILE MOUNTS:
00723             // Admin users has the base fileadmin dir mounted
00724          if ($this->isAdmin() && $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir']) {
00725             $this->addFileMount($GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'], '', PATH_site.$GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'], 0, '');
00726          }
00727 
00728             // If userHomePath is set, we attempt to mount it
00729          if ($GLOBALS['TYPO3_CONF_VARS']['BE']['userHomePath'])   {
00730                // First try and mount with [uid]_[username]
00731             $didMount=$this->addFileMount($this->user['username'], '',$GLOBALS['TYPO3_CONF_VARS']['BE']['userHomePath'].$this->user['uid'].'_'.$this->user['username'].$GLOBALS['TYPO3_CONF_VARS']['BE']['userUploadDir'], 0, 'user');
00732             if (!$didMount)   {
00733                   // If that failed, try and mount with only [uid]
00734                $this->addFileMount($this->user['username'], '', $GLOBALS['TYPO3_CONF_VARS']['BE']['userHomePath'].$this->user['uid'].$GLOBALS['TYPO3_CONF_VARS']['BE']['userUploadDir'], 0, 'user');
00735             }
00736          }
00737 
00738             // BE_GROUPS:
00739             // Get the groups...
00740 #        $grList = t3lib_BEfunc::getSQLselectableList($this->user[$this->usergroup_column],$this->usergroup_table,$this->usergroup_table);
00741          $grList = $GLOBALS['TYPO3_DB']->cleanIntList($this->user[$this->usergroup_column]); // 240203: Since the group-field never contains any references to groups with a prepended table name we think it's safe to just intExplode and re-implode - which should be much faster than the other function call.
00742          if ($grList)   {
00743                // Fetch groups will add a lot of information to the internal arrays: modules, accesslists, TSconfig etc. Refer to fetchGroups() function.
00744             $this->fetchGroups($grList);
00745          }
00746 
00747             // Add the TSconfig for this specific user:
00748          $this->TSdataArray[] = $this->addTScomment('USER TSconfig field').$this->user['TSconfig'];
00749             // Check include lines.
00750          $this->TSdataArray = t3lib_TSparser::checkIncludeLines_array($this->TSdataArray);
00751 
00752             // Parsing the user TSconfig (or getting from cache)
00753          $this->userTS_text = implode(chr(10).'[GLOBAL]'.chr(10),$this->TSdataArray);  // Imploding with "[global]" will make sure that non-ended confinements with braces are ignored.
00754          $hash = md5('userTS:'.$this->userTS_text);
00755          $cachedContent = t3lib_BEfunc::getHash($hash,0);
00756          if (isset($cachedContent) && !$this->userTS_dontGetCached)  {
00757             $this->userTS = unserialize($cachedContent);
00758          } else {
00759             $parseObj = t3lib_div::makeInstance('t3lib_TSparser');
00760             $parseObj->parse($this->userTS_text);
00761             $this->userTS = $parseObj->setup;
00762             t3lib_BEfunc::storeHash($hash,serialize($this->userTS),'BE_USER_TSconfig');
00763                // Update UC:
00764             $this->userTSUpdated=1;
00765          }
00766 
00767             // Processing webmounts
00768          if ($this->isAdmin() && !$this->getTSConfigVal('options.dontMountAdminMounts'))  {  // Admin's always have the root mounted
00769             $this->dataLists['webmount_list']='0,'.$this->dataLists['webmount_list'];
00770          }
00771 
00772             // Processing filemounts
00773          $this->dataLists['filemount_list'] = t3lib_div::uniqueList($this->dataLists['filemount_list']);
00774          if ($this->dataLists['filemount_list'])   {
00775             $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_filemounts', 'NOT deleted AND NOT hidden AND pid=0 AND uid IN ('.$this->dataLists['filemount_list'].')');
00776             while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))  {
00777                $this->addFileMount($row['title'], $row['path'], $row['path'], $row['base']?1:0, '');
00778             }
00779          }
00780 
00781             // The lists are cleaned for duplicates
00782          $this->groupData['webmounts'] = t3lib_div::uniqueList($this->dataLists['webmount_list']);
00783          $this->groupData['pagetypes_select'] = t3lib_div::uniqueList($this->dataLists['pagetypes_select']);
00784          $this->groupData['tables_select'] = t3lib_div::uniqueList($this->dataLists['tables_modify'].','.$this->dataLists['tables_select']);
00785          $this->groupData['tables_modify'] = t3lib_div::uniqueList($this->dataLists['tables_modify']);
00786          $this->groupData['non_exclude_fields'] = t3lib_div::uniqueList($this->dataLists['non_exclude_fields']);
00787          $this->groupData['explicit_allowdeny'] = t3lib_div::uniqueList($this->dataLists['explicit_allowdeny']);
00788          $this->groupData['allowed_languages'] = t3lib_div::uniqueList($this->dataLists['allowed_languages']);
00789          $this->groupData['custom_options'] = t3lib_div::uniqueList($this->dataLists['custom_options']);
00790          $this->groupData['modules'] = t3lib_div::uniqueList($this->dataLists['modList']);
00791 
00792             // populating the $this->userGroupsUID -array with the groups in the order in which they were LAST included.!!
00793          $this->userGroupsUID = array_reverse(array_unique(array_reverse($this->includeGroupArray)));
00794 
00795             // Finally this is the list of group_uid's in the order they are parsed (including subgroups!) and without duplicates (duplicates are presented with their last entrance in the list, which thus reflects the order of the TypoScript in TSconfig)
00796          $this->groupList = implode(',',$this->userGroupsUID);
00797          $this->setCachedList($this->groupList);
00798       }
00799    }

t3lib_userAuthGroup::fetchGroups grList,
idList = ''
 

Fetches the group records, subgroups and fills internal arrays.

Function is called recursively to fetch subgroups

Parameters:
string Commalist of be_groups uid numbers
string List of already processed be_groups-uids so the function will not fall into a eternal recursion.
Returns:
void private

Definition at line 810 of file class.t3lib_userauthgroup.php.

00810                                              {
00811 
00812          // Fetching records of the groups in $grList (which are not blocked by lockedToDomain either):
00813       $lockToDomain_SQL = ' AND (lockToDomain="" OR lockToDomain="'.t3lib_div::getIndpEnv('HTTP_HOST').'")';
00814       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $this->usergroup_table, 'NOT deleted AND NOT hidden AND pid=0 AND uid IN ('.$grList.')'.$lockToDomain_SQL);
00815 
00816          // The userGroups array is filled
00817       while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))  {
00818          $this->userGroups[$row['uid']] = $row;
00819       }
00820 
00821          // Traversing records in the correct order
00822       $include_staticArr = t3lib_div::intExplode(',',$grList);
00823       reset($include_staticArr);
00824       while(list(,$uid)=each($include_staticArr))  {  // traversing list
00825 
00826             // Get row:
00827          $row=$this->userGroups[$uid];
00828          if (is_array($row) && !t3lib_div::inList($idList,$uid))  {  // Must be an array and $uid should not be in the idList, because then it is somewhere previously in the grouplist
00829 
00830                // Include sub groups
00831             if (trim($row['subgroup']))   {
00832                $theList = implode(',',t3lib_div::intExplode(',',$row['subgroup'])); // Make integer list
00833                $this->fetchGroups($theList, $idList.','.$uid);    // Call recursively, pass along list of already processed groups so they are not recursed again.
00834             }
00835                // Add the group uid, current list, TSconfig to the internal arrays.
00836             $this->includeGroupArray[]=$uid;
00837             $this->includeHierarchy[]=$idList;
00838             $this->TSdataArray[] = $this->addTScomment('Group "'.$row['title'].'" ['.$row['uid'].'] TSconfig field:').$row['TSconfig'];
00839 
00840                // Mount group database-mounts
00841             if (($this->user['options']&1) == 1)   {  $this->dataLists['webmount_list'].= ','.$row['db_mountpoints'];   }
00842 
00843                // Mount group file-mounts
00844             if (($this->user['options']&2) == 2)   {  $this->dataLists['filemount_list'].= ','.$row['file_mountpoints'];   }
00845 
00846                // Mount group home-dirs
00847             if (($this->user['options']&2) == 2)   {
00848                   // If groupHomePath is set, we attempt to mount it
00849                if ($GLOBALS['TYPO3_CONF_VARS']['BE']['groupHomePath'])  {
00850                   $this->addFileMount($row['title'], '', $GLOBALS['TYPO3_CONF_VARS']['BE']['groupHomePath'].$row['uid'], 0, 'group');
00851                }
00852             }
00853 
00854                // The lists are made: groupMods, tables_select, tables_modify, pagetypes_select, non_exclude_fields, explicit_allowdeny, allowed_languages, custom_options
00855             if ($row['inc_access_lists']==1) {
00856                $this->dataLists['modList'].= ','.$row['groupMods'];
00857                $this->dataLists['tables_select'].= ','.$row['tables_select'];
00858                $this->dataLists['tables_modify'].= ','.$row['tables_modify'];
00859                $this->dataLists['pagetypes_select'].= ','.$row['pagetypes_select'];
00860                $this->dataLists['non_exclude_fields'].= ','.$row['non_exclude_fields'];
00861                $this->dataLists['explicit_allowdeny'].= ','.$row['explicit_allowdeny'];
00862                $this->dataLists['allowed_languages'].= ','.$row['allowed_languages'];
00863                $this->dataLists['custom_options'].= ','.$row['custom_options'];
00864             }
00865                // If this function is processing the users OWN group-list (not subgroups) AND if the ->firstMainGroup is not set, then the ->firstMainGroup will be set.
00866             if (!strcmp($idList,'') && !$this->firstMainGroup) {
00867                $this->firstMainGroup=$uid;
00868             }
00869          }
00870       }
00871 
00872    }

t3lib_userAuthGroup::getPagePermsClause perms  ) 
 

Returns a WHERE-clause for the pages-table where user permissions according to input argument, $perms, is validated.

$perms is the 'mask' used to select. Fx. if $perms is 1 then you'll get all pages that a user can actually see! 2^0 = show (1) 2^1 = edit (2) 2^2 = delete (4) 2^3 = new (8) If the user is 'admin' " 1=1" is returned (no effect) If the user is not set at all (->user is not an array), then " 1=0" is returned (will cause no selection results at all) The 95% use of this function is "->getPagePermsClause(1)" which will return WHERE clauses for *selecting* pages in backend listings - in other words will this check read permissions.

Parameters:
integer Permission mask to use, see function description
Returns:
string Part of where clause. Prefix " AND " to this.

Definition at line 290 of file class.t3lib_userauthgroup.php.

References isAdmin().

Referenced by isInWebMount().

00290                                        {
00291       if (is_array($this->user)) {
00292          if ($this->isAdmin())   {
00293             return ' 1=1';
00294          }
00295 
00296          $perms = intval($perms);   // Make sure it's integer.
00297          $str= ' ('.
00298             '(pages.perms_everybody & '.$perms.' = '.$perms.')'.  // Everybody
00299             'OR(pages.perms_userid = '.$this->user['uid'].' AND pages.perms_user & '.$perms.' = '.$perms.')';  // User
00300          if ($this->groupList){$str.='OR(pages.perms_groupid in ('.$this->groupList.') AND pages.perms_group & '.$perms.' = '.$perms.')';}   // Group (if any is set)
00301          $str.=')';
00302          return $str;
00303       } else {
00304          return ' 1=0';
00305       }
00306    }

t3lib_userAuthGroup::getTSConfig objectString,
config = ''
 

Returns the value/properties of a TS-object as given by $objectString, eg.

'options.dontMountAdminMounts' Nice (general!) function for returning a part of a TypoScript array!

Parameters:
string Pointer to an "object" in the TypoScript array, fx. 'options.dontMountAdminMounts'
array Optional TSconfig array: If array, then this is used and not $this->userTS. If not array, $this->userTS is used.
Returns:
array An array with two keys, "value" and "properties" where "value" is a string with the value of the objectsting and "properties" is an array with the properties of the objectstring. array An array with the TypoScript where the $objectString is located. If this argument is not an array, then internal ->userTS (User TSconfig for the current BE_USER) will be used instead.

Definition at line 586 of file class.t3lib_userauthgroup.php.

References $key.

00586                                                    {
00587       if (!is_array($config)) {
00588          $config=$this->userTS;  // Getting Root-ts if not sent
00589       }
00590       $TSConf=array();
00591       $parts = explode('.',$objectString,2);
00592       $key = $parts[0];
00593       if (trim($key))   {
00594          if (count($parts)>1 && trim($parts[1]))   {
00595             // Go on, get the next level
00596             if (is_array($config[$key.'.'])) $TSConf = $this->getTSConfig($parts[1],$config[$key.'.']);
00597          } else {
00598             $TSConf['value']=$config[$key];
00599             $TSConf['properties']=$config[$key.'.'];
00600          }
00601       }
00602       return $TSConf;
00603    }

t3lib_userAuthGroup::getTSConfigProp objectString  ) 
 

Returns the "properties" of the $objectString from the BE_USERS "User TSconfig" array.

Parameters:
string Object string, eg. "somestring.someproperty.somesubproperty"
Returns:
array The properties for that object string (object path) - if any
See also:
getTSConfig()

Definition at line 624 of file class.t3lib_userauthgroup.php.

00624                                              {
00625       $TSConf = $this->getTSConfig($objectString);
00626       return $TSConf['properties'];
00627    }

t3lib_userAuthGroup::getTSConfigVal objectString  ) 
 

Returns the "value" of the $objectString from the BE_USERS "User TSconfig" array.

Parameters:
string Object string, eg. "somestring.someproperty.somesubproperty"
Returns:
string The value for that object string (object path)
See also:
getTSConfig()

Definition at line 612 of file class.t3lib_userauthgroup.php.

Referenced by t3lib_beUserAuth::checkLockToIP().

00612                                           {
00613       $TSConf = $this->getTSConfig($objectString);
00614       return $TSConf['value'];
00615    }

t3lib_userAuthGroup::inList in_list,
item
 

Returns true if $item is in $in_list.

Parameters:
string Comma list with items, no spaces between items!
string The string to find in the list of items
Returns:
string Boolean

Definition at line 636 of file class.t3lib_userauthgroup.php.

Referenced by isMemberOfGroup().

00636                                     {
00637       return strstr(','.$in_list.',', ','.$item.',');
00638    }

t3lib_userAuthGroup::isAdmin  ) 
 

Returns true if user is admin Basically this function evaluates if the ->user[admin] field has bit 0 set.

If so, user is admin.

Returns:
boolean

Definition at line 176 of file class.t3lib_userauthgroup.php.

Referenced by t3lib_beUserAuth::backendCheckLogin(), t3lib_beUserAuth::checkCLIuser(), t3lib_beUserAuth::emailAtLogin(), getPagePermsClause(), isInWebMount(), and modAccess().

00176                         {
00177       return (($this->user['admin']&1) ==1);
00178    }

t3lib_userAuthGroup::isInWebMount id,
readPerms = '',
exitOnError = 0
 

Checks if the page id, $id, is found within the webmounts set up for the user.

This should ALWAYS be checked for any page id a user works with, whether it's about reading, writing or whatever. The point is that this will add the security that a user can NEVER touch parts outside his mounted pages in the page tree. This is otherwise possible if the raw page permissions allows for it. So this security check just makes it easier to make safe user configurations. If the user is admin OR if this feature is disabled (fx. by setting TYPO3_CONF_VARS['BE']['lockBeUserToDBmounts']=0) then it returns "1" right away Otherwise the function will return the uid of the webmount which was first found in the rootline of the input page $id

Parameters:
integer Page ID to check
string Content of "->getPagePermsClause(1)" (read-permissions). If not set, they will be internally calculated (but if you have the correct value right away you can save that database lookup!)
boolean If set, then the function will exit with an error message.
Returns:
integer The page UID of a page in the rootline that matched a mount point

Definition at line 227 of file class.t3lib_userauthgroup.php.

References t3lib_BEfunc::BEgetRootLine(), getPagePermsClause(), isAdmin(), returnWebmounts(), and typo3PrintError().

00227                                                             {
00228       if (!$GLOBALS['TYPO3_CONF_VARS']['BE']['lockBeUserToDBmounts'] || $this->isAdmin()) return 1;
00229       $id = intval($id);
00230       if (!$readPerms)  $readPerms = $this->getPagePermsClause(1);
00231       if ($id>0)  {
00232          $wM = $this->returnWebmounts();
00233          $rL = t3lib_BEfunc::BEgetRootLine($id,' AND '.$readPerms);
00234 
00235          foreach($rL as $v)   {
00236             if ($v['uid'] && in_array($v['uid'],$wM)) {
00237                return $v['uid'];
00238             }
00239          }
00240       }
00241       if ($exitOnError) {
00242          t3lib_BEfunc::typo3PrintError ('Access Error','This page is not within your DB-mounts',0);
00243          exit;
00244       }
00245    }

t3lib_userAuthGroup::isMemberOfGroup groupId  ) 
 

Returns true if the current user is a member of group $groupId $groupId must be set.

$this->groupList must contain groups Will return true also if the user is a member of a group through subgroups.

Parameters:
integer Group ID to look for in $this->groupList
Returns:
boolean

Definition at line 188 of file class.t3lib_userauthgroup.php.

References inList().

00188                                        {
00189       $groupId = intval($groupId);
00190       if ($this->groupList && $groupId)   {
00191          return $this->inList($this->groupList, $groupId);
00192       }
00193    }

t3lib_userAuthGroup::isPSet lCP,
table,
type = ''
 

Will check a type of permission against the compiled permission integer, $lCP, and in relation to table, $table.

Parameters:
integer $lCP could typically be the "compiled permissions" integer returned by ->calcPerms
string $table is the tablename to check: If "pages" table then edit,new,delete and editcontent permissions can be checked. Other tables will be checked for "editcontent" only (and $type will be ignored)
string For $table='pages' this can be 'edit' (2), 'new' (8 or 16), 'delete' (4), 'editcontent' (16). For all other tables this is ignored. (16 is used)
Returns:
boolean private

Definition at line 541 of file class.t3lib_userauthgroup.php.

00541                                           {
00542       if ($this->isAdmin())   return true;
00543       if ($table=='pages') {
00544          if ($type=='edit')   return $lCP & 2;
00545          if ($type=='new') return ($lCP & 8) || ($lCP & 16);   // Create new page OR pagecontent
00546          if ($type=='delete') return $lCP & 4;
00547          if ($type=='editcontent')  return $lCP & 16;
00548       } else {
00549          return $lCP & 16;
00550       }
00551    }

t3lib_userAuthGroup::isRTE  ) 
 

Returns true if the RTE (Rich Text Editor) can be enabled for the user Strictly this is not permissions being checked but rather a series of settings like a loaded extension, browser/client type and a configuration option in ->uc[edit_RTE] The reasons for a FALSE return can be found in $this->RTE_errors.

Returns:
boolean

Definition at line 339 of file class.t3lib_userauthgroup.php.

References $TYPO3_CONF_VARS, and RTEgetObj().

00339                      {
00340       global $CLIENT;
00341 
00342          // Start:
00343       $this->RTE_errors = array();
00344       if (!$this->uc['edit_RTE'])
00345          $this->RTE_errors[] = 'RTE is not enabled for user!';
00346       if (!$GLOBALS['TYPO3_CONF_VARS']['BE']['RTEenabled'])
00347          $this->RTE_errors[] = 'RTE is not enabled in $TYPO3_CONF_VARS["BE"]["RTEenabled"]';
00348 
00349 
00350          // Acquire RTE object:
00351       $RTE = &t3lib_BEfunc::RTEgetObj();
00352       if (!is_object($RTE))   {
00353          $this->RTE_errors = array_merge($this->RTE_errors, $RTE);
00354       }
00355 
00356       if (!count($this->RTE_errors))   {
00357          return TRUE;
00358       } else {
00359          return FALSE;
00360       }
00361    }

t3lib_userAuthGroup::mayMakeShortcut  ) 
 

Returns true if the BE_USER is allowed to *create* shortcuts in the backend modules.

Returns:
boolean

Definition at line 558 of file class.t3lib_userauthgroup.php.

00558                               {
00559       return $this->getTSConfigVal('options.shortcutFrame') && !$this->getTSConfigVal('options.mayNotCreateEditShortcuts');
00560    }

t3lib_userAuthGroup::modAccess conf,
exitOnError
 

Checks access to a backend module with the $MCONF passed as first argument.

Parameters:
array $MCONF array of a backend module!
boolean If set, an array will issue an error message and exit.
Returns:
boolean Will return true if $MCONF['access'] is not set at all, if the BE_USER is admin or if the module is enabled in the be_users/be_groups records of the user (specifically enabled). Will return false if the module name is not even found in $TBE_MODULES

Definition at line 254 of file class.t3lib_userauthgroup.php.

References check(), isAdmin(), isModuleSetInTBE_MODULES(), and typo3PrintError().

00254                                           {
00255       if (!t3lib_BEfunc::isModuleSetInTBE_MODULES($conf['name'])) {
00256          if ($exitOnError) {
00257             t3lib_BEfunc::typo3PrintError ('Fatal Error','This module "'.$conf['name'].'" is not enabled in TBE_MODULES',0);
00258             exit;
00259          }
00260          return false;
00261       }
00262 
00263          // Returns true if conf[access] is not set at all or if the user is admin
00264       if (!$conf['access']  ||  $this->isAdmin()) return true;
00265 
00266          // If $conf['access'] is set but not with 'admin' then we return true, if the module is found in the modList
00267       if (!strstr($conf['access'],'admin') && $conf['name'])   {
00268          $acs = $this->check('modules',$conf['name']);
00269       }
00270       if (!$acs && $exitOnError) {
00271          t3lib_BEfunc::typo3PrintError ('Access Error','You don\'t have access to this module.',0);
00272          exit;
00273       } else return $acs;
00274    }

t3lib_userAuthGroup::recordEditAccessInternals table,
idOrRow
 

Checking if a user has editing access to a record from a $TCA table.

The checks does not take page permissions and other "environmental" things into account. It only deal with record internals; If any values in the record fields disallows it. For instance languages settings, authMode selector boxes are evaluated (and maybe more in the future). The function takes an ID (integer) or row (array) as second argument.

Parameters:
string Table name
mixed If integer, then this is the ID of the record. If Array this just represents fields in the record.
Returns:
boolean True if OK, otherwise false

Definition at line 476 of file class.t3lib_userauthgroup.php.

References $TCA, t3lib_BEfunc::getRecord(), and table().

00476                                                          {
00477       global $TCA;
00478 
00479       if (isset($TCA[$table]))   {
00480          t3lib_div::loadTCA($table);
00481 
00482             // Always return true for Admin users.
00483          if ($this->isAdmin())   return TRUE;
00484 
00485             // Fetching the record if the $idOrRow variable was not an array on input:
00486          if (!is_array($idOrRow))   {
00487             $idOrRow = t3lib_BEfunc::getRecord($table, $idOrRow);
00488             if (!is_array($idOrRow))   {
00489                $this->errorMsg = 'ERROR: Record could not be fetched.';
00490                return FALSE;
00491             }
00492          }
00493 
00494             // Checking languages:
00495          if ($TCA[$table]['ctrl']['languageField'])   {
00496             if (isset($idOrRow[$TCA[$table]['ctrl']['languageField']])) {  // Language field must be found in input row - otherwise it does not make sense.
00497                if (!$this->checkLanguageAccess($idOrRow[$TCA[$table]['ctrl']['languageField']]))   {
00498                   $this->errorMsg = 'ERROR: Language was not allowed.';
00499                   return FALSE;
00500                }
00501             }
00502          }
00503 
00504             // Checking authMode fields:
00505          if (is_array($TCA[$table]['columns'])) {
00506             foreach($TCA[$table]['columns'] as $fN => $fV)  {
00507                if (isset($idOrRow[$fN]))  {  //
00508                   if ($fV['config']['type']=='select' && $fV['config']['authMode'] && !strcmp($fV['config']['authMode_enforce'],'strict')) {
00509                      if (!$this->checkAuthMode($table,$fN,$idOrRow[$fN],$fV['config']['authMode']))   {
00510                         $this->errorMsg = 'ERROR: authMode "'.$fV['config']['authMode'].'" failed for field "'.$fN.'" with value "'.$idOrRow[$fN].'" evaluated';
00511                         return FALSE;
00512                      }
00513                   }
00514                }
00515             }
00516          }
00517 
00518             // Checking "editlock" feature
00519          if ($TCA[$table]['ctrl']['editlock'] && $idOrRow[$TCA[$table]['ctrl']['editlock']]) {
00520             $this->errorMsg = 'ERROR: Record was locked for editing. Only admin users can change this state.';
00521             return FALSE;
00522          }
00523 
00524             // Checking record permissions
00525          // THIS is where we can include a check for "perms_" fields for other records than pages...
00526 
00527             // Finally, return true if all is well.
00528          return TRUE;
00529       }
00530    }

t3lib_userAuthGroup::returnFilemounts  ) 
 

Returns an array with the filemounts for the user.

Each filemount is represented with an array of a "name", "path" and "type". If no filemounts an empty array is returned.

Returns:
array

Definition at line 657 of file class.t3lib_userauthgroup.php.

00657                                  {
00658       return $this->groupData['filemounts'];
00659    }

t3lib_userAuthGroup::returnWebmounts  ) 
 

Returns an array with the webmounts.

If no webmounts, and empty array is returned. NOTICE: Deleted pages WILL NOT be filtered out! So if a mounted page has been deleted it is STILL coming out as a webmount. This is not checked due to performance.

Returns:
array

Definition at line 647 of file class.t3lib_userauthgroup.php.

Referenced by isInWebMount().

00647                               {
00648       return (string)($this->groupData['webmounts'])!='' ? explode(',',$this->groupData['webmounts']) : Array();
00649    }

t3lib_userAuthGroup::setCachedList cList  ) 
 

Updates the field be_users.usergroup_cached_list if the groupList of the user has changed/is different from the current list.

The field "usergroup_cached_list" contains the list of groups which the user is a member of. After authentication (where these functions are called...) one can depend on this list being a representation of the exact groups/subgroups which the BE_USER has membership with.

Parameters:
string The newly compiled group-list which must be compared with the current list in the user record and possibly stored if a difference is detected.
Returns:
void private

Definition at line 882 of file class.t3lib_userauthgroup.php.

00882                                     {
00883       if ((string)$cList != (string)$this->user['usergroup_cached_list'])  {
00884          $GLOBALS['TYPO3_DB']->exec_UPDATEquery('be_users', 'uid='.intval($this->user['uid']), array('usergroup_cached_list' => $cList));
00885       }
00886    }


Member Data Documentation

t3lib_userAuthGroup::$dataLists
 

Initial value:

array(            // Used internally to accumulate data for the user-group. DONT USE THIS EXTERNALLY! Use $this->groupData instead
      'webmount_list'=>'',
      'filemount_list'=>'',
      'modList'=>'',
      'tables_select'=>'',
      'tables_modify'=>'',
      'pagetypes_select'=>'',
      'non_exclude_fields'=>'',
      'explicit_allowdeny'=>'',
      'allowed_languages' => '',
      'custom_options' => '',
   )

Definition at line 127 of file class.t3lib_userauthgroup.php.

t3lib_userAuthGroup::$errorMsg = ''
 

Definition at line 150 of file class.t3lib_userauthgroup.php.

t3lib_userAuthGroup::$groupData
 

Initial value:

 Array(           // This array holds lists of eg. tables, fields and other values related to the permission-system. See fetchGroupData
      'filemounts' => Array()       // Filemounts are loaded here
   )

Definition at line 120 of file class.t3lib_userauthgroup.php.

t3lib_userAuthGroup::$groupList = ''
 

Definition at line 126 of file class.t3lib_userauthgroup.php.

t3lib_userAuthGroup::$includeGroupArray = array()
 

Definition at line 140 of file class.t3lib_userauthgroup.php.

t3lib_userAuthGroup::$includeHierarchy = array()
 

Definition at line 139 of file class.t3lib_userauthgroup.php.

t3lib_userAuthGroup::$OS = ''
 

Definition at line 142 of file class.t3lib_userauthgroup.php.

t3lib_userAuthGroup::$RTE_errors = array()
 

Definition at line 149 of file class.t3lib_userauthgroup.php.

t3lib_userAuthGroup::$TSdataArray = array()
 

Definition at line 143 of file class.t3lib_userauthgroup.php.

t3lib_userAuthGroup::$usergroup_column = 'usergroup'
 

Definition at line 116 of file class.t3lib_userauthgroup.php.

t3lib_userAuthGroup::$usergroup_table = 'be_groups'
 

Definition at line 117 of file class.t3lib_userauthgroup.php.

t3lib_userAuthGroup::$userGroups = Array()
 

Definition at line 124 of file class.t3lib_userauthgroup.php.

t3lib_userAuthGroup::$userGroupsUID = Array()
 

Definition at line 125 of file class.t3lib_userauthgroup.php.

t3lib_userAuthGroup::$userTS = array()
 

Definition at line 145 of file class.t3lib_userauthgroup.php.

t3lib_userAuthGroup::$userTS_dontGetCached = 0
 

Definition at line 147 of file class.t3lib_userauthgroup.php.

t3lib_userAuthGroup::$userTS_text = ''
 

Definition at line 144 of file class.t3lib_userauthgroup.php.

t3lib_userAuthGroup::$userTSUpdated = 0
 

Definition at line 146 of file class.t3lib_userauthgroup.php.


The documentation for this class was generated from the following file:
Generated on Sun Oct 3 01:07:32 2004 for TYPO3core 3.7.0 dev by  doxygen 1.3.8-20040913