Easiest Method to restrict IDs to current BE User ONLY
I have a module that will list property entries. I want to restrict it so that when a BE user logs in, they can only see the entries author'd by them and when they create new entries to be them as the author automatically.
I can add an author field (similar to News), but then where do I add the code, and HOW do I restrict the listing, as it's controlled in the DC_Table.php? I think I can do a eval=>(root => array(1,10,16)) override, right? Retrieving the permission IDs (in an onload_callback)
Then I just have to force the Author field to be the current user ID only (if not admin).
Re: Easiest Method to restrict IDs to current BE User ONLY
Hey thyon, I think this might be helpful (not sure if I got your point though, got some problems with it lately):
[code=php:2sqxpd4j]<span class="syntaxdefault">
</span><span class="syntaxkeyword">if*(!</span><span class="syntaxdefault">$this</span><span class="syntaxkeyword">-></span><span class="syntaxdefault">User</span><span class="syntaxkeyword">-></span><span class="syntaxdefault">isAdmin</span><span class="syntaxkeyword">)
{
****</span><span class="syntaxcomment">//*Show*to*user*only*his*records
****</span><span class="syntaxdefault">$GLOBALS</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'TL_DCA'</span><span class="syntaxkeyword">][</span><span class="syntaxstring">'tl_table'</span><span class="syntaxkeyword">][</span><span class="syntaxstring">'list'</span><span class="syntaxkeyword">][</span><span class="syntaxstring">'sorting'</span><span class="syntaxkeyword">][</span><span class="syntaxstring">'filter'</span><span class="syntaxkeyword">]*=*array
****(
********array(</span><span class="syntaxstring">'author_id=?'</span><span class="syntaxkeyword">,*</span><span class="syntaxdefault">$this</span><span class="syntaxkeyword">-></span><span class="syntaxdefault">User</span><span class="syntaxkeyword">-></span><span class="syntaxdefault">id</span><span class="syntaxkeyword">)
****);
}
*</span><span class="syntaxdefault"></span>[/code:2sqxpd4j]
Re: Easiest Method to restrict IDs to current BE User ONLY
Kewl. I forgot about the new filter. That is by far the coolest addition yet. Then I can just remove that DCA element for admins.