[TYPO3-english] Page access

Xavier Perseguers typo3 at perseguers.ch
Sat Apr 3 09:47:46 CEST 2010


Hi André,

> This is a question of page access: Every newly created page on second level
> may not get "New pages" permission while on first level it must. I don't
> understand how you solve this using a DB mount.

I would use hook processDatamap_afterDatabaseOperations to update ACL.

Here is an example. Add this to your localconf.php:

$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = 'fileadmin/class.user_acl.php:user_acl';

Create file fileadmin/class.user_acl.php:

<?php

class user_acl {

	protected $maxLevels = 2;
	
	/**
	 * Ensure only two levels of pages may be created.
	 *
	 * @param	string		$status: Status of the current operation, 'new' or 'update
	 * @param	string		$table: The table currently processing data for
	 * @param	string		$id: The record uid currently processing data for, [integer] or [string] (like 'NEW...')
	 * @param	array		$fieldArray: The field array of a record
	 * @param	t3lib_tcemain	$pObj: The parent object
	 */
	public function processDatamap_afterDatabaseOperations($status, $table, $id, array $fieldArray, t3lib_tcemain $pObj) {
		if (!($table === 'pages' && $status === 'new')) {
			return;
		}
		$pageUid = $pObj->substNEWwithIDs[$id];
		$rootline = t3lib_BEfunc::BEgetRootLine($pageUid);

		if (count($rootline) > ($this->maxLevels + 1)) {
				// Do not allow further "inside" new pages to be created
			$GLOBALS['TYPO3_DB']->exec_UPDATEquery(
				'pages',
				'uid=' . $pageUid,
				array(
					'perms_user'      => $fieldArray['perms_user'] & ~$pObj->pMap['new'],
					'perms_group'     => $fieldArray['perms_group'] & ~$pObj->pMap['new'],
					'perms_everybody' => $fieldArray['perms_everybody'] & ~$pObj->pMap['new'],
				)
			);
		}
	}

}

?>

Have fun!

-- 
Xavier Perseguers
http://xavier.perseguers.ch/en


More information about the TYPO3-english mailing list