Set widget:type based on ROLE

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

Set widget:type based on ROLE

Postby wisni1rr » Thu Apr 19, 2012 10:16 am

Is it possible to set a widget:type based on the role? For Example, The My Profile link will allow you to modify your profile. However I do not want my users to be able to modify their assigned ROLE. I would like the field to appear static for most or the ROLEs. My ADMIN and MANAGER ROLEs should be able to edit the ROLE field.

Thanks for taking the time to read my post!
wisni1rr
 
Posts: 107
Joined: Mon Feb 13, 2012 9:03 pm

Re: Set widget:type based on ROLE

Postby Jean » Fri Apr 27, 2012 2:59 am

Hello Steve,

I have too this kind of problem, how to access to parameters from the fields.ini and change them according to user id or role ?
Here for wisni1rr, it is about the widget type or for me the savepath for a file field.
Steve, how can we do ?

Thank you

Jean
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France

Re: Set widget:type based on ROLE

Postby shannah » Sat Apr 28, 2012 10:03 pm

This has to be done programatically. Use the init() method of the table delegate class to change the field configuration. This method is called only once per request when the table is initially loaded.

e.g.
Code: Select all
function init(Dataface_Table $table){
    if ( userIsRole1() ){
        $myfield =& $table->getField('myfield');
        $myfield['widget']['type'] = 'select';
    }
}



etc...

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Set widget:type based on ROLE

Postby wisni1rr » Tue May 01, 2012 9:42 am

I'm confused on this line:

Code: Select all
if ( userIsRole1() ){


In my case, the role I need to check is DATAINPUT. How would I use the call?
wisni1rr
 
Posts: 107
Joined: Mon Feb 13, 2012 9:03 pm

Re: Set widget:type based on ROLE

Postby Jean » Wed May 02, 2012 12:28 am

Hello,
Have a look on this topic http://xataface.com/forum/viewtopic.php?f=4&t=6734 to see hw to implement the authentication class in your table Delegate Class.
In fact it is a function you create in your table Delegate Class :

Code: Select all
function userIsRole1(){
     $user = $this->getUser();
$role=$user->val('role');
if ($role=='DATAINPUT'){
return TRUE;
}
}


Cheers
Jean
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 7 guests

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