Current Record: Using the table relationship permissions function #45

News

Current Record: Using the table relationship permissions function #45

News

Click to minimize this section Details

News id 45
Headline Using the table relationship permissions function
Content Inside of each delegate class, we can use the function rel_nameOfRelationship__permissions(&$record) to specify the permissions on that relationship. The reason this works is because when we click on a tab to go to the relationship we are still in the original table. <br /><br />For example, say we have a companies table that had a relationship to an offerings table. An offerings tab will be present. You can control the permissions on the tab (as in whether the user can add new offerings) by using that rel_nameOfRelationship__permissions(&$record) function. <br /><br />In the event, that you want to actually remove that tab from the view, then you need to do this in the relationships.ini file of that table folder. Like this:<br /><br />[offerings]<br />__sql__ = "SELECT * FROM offerings WHERE company_id ='$company_id'"<br />action:condition="isAdmin() or ($record->val('company_id') == getCompanyID()) or ( isBrokerDealer() and $record->val('company_id') == getDealerID())"<br />actions:addexisting=0<br />action:label="offerings"<br />section:sort="date_reported desc<br /><br /><ol><br /><li>The __sql__ is just the SQL statement to retrieve the records</li><br /><li>action:condition is the part that determines whether the tab should appear or not.</li><br /><li>actions:addexisting makes it so that the add existing option doesn't appear</li><br /></ol><br /><br /><blockquote>I found this strange bug (not sure if it is a bug). But if the try to enter action:condition = 0 just by itself it won't hide the tab. You have to enter action:condition = "false" in order for it to work...</blockquote>
Image (Empty)
Date posted Fri May 9 13:21:00 2008
Posted by noreply@blogger.com (Fong Chun Chan)
Status Approved
Categories Blog
Source id Fong's Blog
Source url http://fongxataface.blogspot.com/2008/05/using-table-relationship-permissions.html
Powered by Xataface
(c) 2005-2024 All rights reserved