[TYPO3-dev] Traversing related tables

Christian Lerrahn christian.lerrahn at cerebrum.com.au
Thu Mar 22 07:03:16 CET 2007


Hi,
I'm in the process of writing a rather generic extension that lets you
edit records in the FE as you would do in the BE. However, I want it to
be possible that FE users can only edit records that are already
related to their user record (or maybe a specific record from any
table). Now my problem is that if you're far down a chain of
relations I have to make sure that the logged in user is allowed to
edit this record. The only safe way for this is to traverse back all
the way to the user record. Here an example of what I mean.

User A --- relates to --> Table1, Record B --- relates to --> Table2,
Record C

Now if a form is posted that attempts to update Record C from Table2, I
have to check if the beginning of this chain of records is actually
really User A who is currently logged in. As I don't want to render all
this information in one form but use separate forms, I would have to
traverse back in the tree. However, if I don't require the relations to
be bidirectional I don't know from just a record from Table2 what the
parent table in my chain is. That means that I would have to make the
whole chain accessible through the form and pass on the whole chain of
table and field names. This is rather ugly because it is quite a large
amount of data and gives away too much information about my database
structure (from my POV). Does anybody have a better way of handling
this problem? Maybe even one that leaves me with less SQL queries?
Again, I don't want to require bi-directional relations and I don't
want to add any more fields or relations, either.

Cheers,
Christian




More information about the TYPO3-dev mailing list