Index: typo3/sysext/cms/ext_localconf.php =================================================================== --- typo3/sysext/cms/ext_localconf.php (revision 7072) +++ typo3/sysext/cms/ext_localconf.php (working copy) @@ -193,5 +193,7 @@ $TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass'][] = 'EXT:cms/tslib/hooks/class.tx_cms_treelistcacheupdate.php:&tx_cms_treelistCacheUpdate'; $TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['moveRecordClass'][] = 'EXT:cms/tslib/hooks/class.tx_cms_treelistcacheupdate.php:&tx_cms_treelistCacheUpdate'; + // registering hook to update usergroup list for be_users +$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = 'EXT:cms/tslib/hooks/class.tx_cms_updateusergroups.php:&tx_cms_updateUsergroups'; ?> Index: typo3/sysext/cms/tslib/hooks/class.tx_cms_updateusergroups.php =================================================================== --- typo3/sysext/cms/tslib/hooks/class.tx_cms_updateusergroups.php (revision 0) +++ typo3/sysext/cms/tslib/hooks/class.tx_cms_updateusergroups.php (revision 0) @@ -0,0 +1,104 @@ + + * @package TYPO3 + * @subpackage tslib + */ +class tx_cms_updateUsergroups { + + /** + * waits for TCEmain commands and looks for changed pages, if found further + * changes take place to determine whether the cache needs to be updated + * + * @param string TCEmain operation status, either 'new' or 'update' + * @param string the DB table the operation was carried out on + * @param mixed the record's uid for update records, a string to look the record's uid up after it has been created + * @param array array of changed fiels and their new values + * @param t3lib_TCEmain TCEmain parent object + */ + public function processDatamap_afterDatabaseOperations($status, $table, $recordId, array $updatedFields, t3lib_TCEmain $tceMain) { + if ($table == 'be_users') { + $this->processUpdateUsers($recordId); + } elseif ($table == 'be_groups') { + $this->processUpdateUsergroups(); + } + } + + /** + * waits for TCEmain commands and looks for deleted usergroups, if found + * the usergroup list is updated + * + * @param string the TCE command + * @param string the record's table + * @param integer the record's uid + * @param array the commands value, typically an array with more detailed command information + * @param t3lib_TCEmain the TCEmain parent object + */ + public function processCmdmap_postProcess($command, $table, $recordId, $commandValue, t3lib_TCEmain $tceMain) { + + if ($table == 'be_groups' && $command == 'delete') { + $this->processUpdateUsergroups(); + } + } + + /** + * Update the cached usergroup list of all users + * + * @return void + */ + protected function processUpdateUsergroups() { + $userAuthGroupObj = t3lib_div::makeInstance('t3lib_userAuthGroup'); + $userAuthGroupObj->user_table = 'be_users'; + + $users = t3lib_BEfunc::getUserNames(); + foreach($users as $user) { + $userAuthGroupObj->setBeUserByUid($user['uid']); + $userAuthGroupObj->fetchGroupData(); + } + } + + /** + * Update the cached usergroup list of a given user + * + * @param int Id of the user + * @return void + */ + protected function processUpdateUsers($userId) { + $userAuthGroupObj = t3lib_div::makeInstance('t3lib_userAuthGroup'); + $userAuthGroupObj->user_table = 'be_users'; + $userAuthGroupObj->setBeUserByUid(intval($userId)); + $userAuthGroupObj->fetchGroupData(); + } +} + +?> \ No newline at end of file