[TYPO3-core] RFC: Bug #3903, Edit content doesn't work with TV

Dmitry Dulepov [typo3] dmitry at typo3.org
Mon Sep 24 11:54:21 CEST 2007


Hi!

Bernhard Kraft wrote:
> Problem:
> When you have only set "Edit page content" as access-right for a page - 
> and you are trying to add/delete/move a content element from within the 
> templa-voila page-module it will not work.

True :( Many people fall into this :(

> Solution:
> Add a hook in t3lib_tcemain.php which allows an extension method to 
> perform the check if it is valid to modify a specific table.

This is a good idea. Some time ago I thought about different solution: hook into TCEforms somehow and tell user that he needs also to set page modification rights for user. But your solution is better.

> For this to work properly I had to additionaly pass the modified fields 
> to the checkRecordUpdateAccess(...) method. Additionally I have to pass
> the "hookObjectsArray" - as I do this by reference and set it "false" at 
> the same time this patch also has PHP>=5 as requirement.
> 
> I hope this is ok for you ...

Fine if it goes to 4.2 only.

There are some things in the patch that I would like to change or get comment from you first. Here is a piece of TCEmain:

---------------
	$res = 0;
 	if ($TCA[$table] && intval($id)>0)	{
+		if (is_array($hookObjectsArr))	{
+			foreach($hookObjectsArr as $hookObj)	{
+				if (method_exists($hookObj, 'checkRecordUpdateAccess')) {
+					$res = $hookObj->checkRecordUpdateAccess($table, $id, $data, $res, $this);
+				}
+			}
+		}
+		if ($res)	{
+			return $res;
+		}
 		if (isset($this->recUpdateAccessCache[$table][$id]))	{	// If information is cached, return it
---------------

1. Last line uses cache. Should hook be executed after the cache? Hooks may perform complex processing, there is no need for it to repeat. What do you think?
2. I think hook may return true/false/null. This is equivalent to PostFix'es OK/REJECT/DONTKNOW. So if hook returns null, we continue looping. If it returns false, we return false. If it returns true, we mark it and continue looping (because access is always restrictive: one forbids -> no access). I do not insist on this but it would be interesting to here responses about it.
3. Should hook be called as last resort, when all others said "no access"? This would minimize calculation time in hooks if user already has edit rights.

> Next to the patch for the core there is a patch for the t3lib_tcemain 
> hook of templa-voila. It adds the required method which performs the 
> check by having a look at the posted data and if only "eType=ce" 
> flexfields and no other fields get modified ... i know the code there 
> looks a litte bit strange but I couldn't find a better solution. 
> Pherhaps one of you has a better idea.

I will review this. In particular I want to find a better solution than many "$res=0;break;" in the code. Nothing bad with it technically, just makes function fat...

> Dmitry: It seems that the source-code files of TV have DOS-style 
> newlines currently (\r\n) ... probably this is what your editor creates 
> but usually we have just \n (unix) in T3 - I couldn't find a way quickly 
> to properly apply the created patch to your class-files except 
> converting them to unix-style first (using the tools "dos2unix" 
> "unix2dos" ...) - so if you get a hunk failed have a look at the newline 
> encoding first ...

That was a problem with phpEclipse but I stopped using it long time ago, so all new files should be ok. I will run dos2unix, thanks!

-- 
Dmitry Dulepov
TYPO3 freelancer / TYPO3 core team member
Web: http://typo3bloke.net/
Skype: callto:liels_bugs


More information about the TYPO3-team-core mailing list