Permissions, user related field: how to?

A place for users and developers of the Xataface to discuss and receive support.

Permissions, user related field: how to?

Postby brokenclock » Wed Oct 01, 2008 11:59 am

Hi,

I have 2 questions, but related, and pardon me if you think that all I need is in the documentation... I did not the solution by myself yet, and your help will be very appreciated.
First, I want to automatically give a value to an hidden field on the insertion form, and I want it to receive the UserId of the current user (I want Carrie to be able to add a record in the table "Posts", and to fill the field "AuthorId" with Carrie's Id automatically).
Second, I want to manage permissions on some records with the UserId, and another foreign key (I want Alan to be able to edit all records of the tables "Posts" where the CityId is "NewYork" for exemple).

Can you please help me with that?

Best regards,

BrokenClock
brokenclock
 
Posts: 12
Joined: Tue Sep 30, 2008 7:16 am

Postby shannah » Wed Oct 01, 2008 4:54 pm

Use the beforeInsert() trigger in the delegate class. e.g.
[/code]
function beforeInsert(&$record){
$auth =& Dataface_AuthenticationTool::getInstance();
$user =& $auth->getLoggedInUser();
if ( $user ) $record->setValue('authorid', $user->val('userid'));
}
[/code]
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Great, but...

Postby brokenclock » Thu Oct 02, 2008 12:48 am

That's great to solve the problem of the authorId - it can be automatically be associated with a record. First question is solved. Many thanks, sincerely.
But the second remains, so let me be clearer: how could I do if I want to allow Alan to see and edit the posts for the New-york and San Francisco but not for LA?
I mean, how can I manage rights on records, not tables, before the form, the page or the view, whatever, is displayed?
brokenclock
 
Posts: 12
Joined: Tue Sep 30, 2008 7:16 am

Sorry

Postby brokenclock » Thu Oct 02, 2008 1:43 am

brokenclock
 
Posts: 12
Joined: Tue Sep 30, 2008 7:16 am

You need to apply security filters

Postby njw » Thu Oct 02, 2008 4:19 am

Have a look here http://framework.weblite.ca/documentati ... ty_filters

Then you just have to work out how you can identify programmatically which records are allocated to Alan and which are not. For example, you may need a field on the Cities table that you can use to assign a person to; then when a blog is created, a piece of code in Before_Update that allocates that code to the blog record.
njw
 
Posts: 280
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 29 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved