[TYPO3-core] RFC: #2278 - Hook request for t3lib_TCEmain::checkModifyAccessList()

Ernesto Baschny [cron IT] ernst at cron-it.de
Tue Nov 7 13:55:03 CET 2006


Michael Stucki schrieb:

> You mean like this? See attachment.

>  	function checkModifyAccessList($table)	{
> +		global $TYPO3_CONF_VARS;
> +		$hookObjectsArr = array();
> +		if (is_array ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['checkModifyAccessList']))	{
> +			foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['checkModifyAccessList'] as $classRef)	{
> +				$hookObjectsArr[] = &t3lib_div::getUserObj($classRef);
> +			}
> +		}
> +
>  		$res = ($this->admin || (!$this->tableAdminOnly($table) && t3lib_div::inList($this->BE_USER->groupData['tables_modify'],$table)));
> +
> +		foreach ($hookObjectsArr as $hookObj)	{
> +			if (method_exists($hookObj, 'checkModifyAccessList_post'))	{
> +				$hookObj->checkModifyAccessList_post($table, $this->cmdmap, $this, &$res);
> +			}
> +		}
> +
>  		return $res;

The function returns "true if the user has general access to modify the
$table". What is unclear if several extensions hook to this method. In
the current suggestion, the "last hook" wins (be it true or false). I
would rather have it return in a determinate way, for example:

- if all hooks PLUS default handling returns "TRUE" => return TRUE
- else, return FALSE

This is also easier to document and don't cause unpredictable results.

As for the hook itself, I don't see why you are creating an array of
hook-objects and then later iterating through these. This can be done in
a single loop (after the $res call).

As for the hooks name, I don't like the "_post" in this particular case,
because we are not doing any "post" processing. If we agree to my idea
above of "if all hooks return true, then true, else false", I would
rename the function just to "checkModifyAccessList", as each single call
with do a independent check on its own.

Other than that, +1 from me.

Cheers,
Ernesto



More information about the TYPO3-team-core mailing list