hiding fields in a find form by permission

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

hiding fields in a find form by permission

Postby magazzu » Fri Mar 02, 2012 12:03 pm

Hello,

I set permissions on some fields, using functions like this in the php file in my table:

function price__permissions(&$record){
if ( isAdmin() ) return Dataface_PermissionsTool::ALL();
return Dataface_PermissionsTool::NO_ACCESS();
}


This works, but users who are not Admin still have in their search form the fields that are not permitted.

What can I do to obtain that these forbidden fields only appear in the Admin search form? ('find' action)?

Thanks

Antonio
magazzu
 
Posts: 11
Joined: Tue Jan 17, 2012 4:49 am

Re: hiding fields in a find form by permission

Postby shannah » Fri Mar 02, 2012 12:36 pm

What version of Xataface are you using?
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: hiding fields in a find form by permission

Postby magazzu » Fri Mar 02, 2012 2:49 pm

Actually, I'm using librarianDB, maybe I posted in the wrong place.


The version.txt file says: 0.3.2 2530
magazzu
 
Posts: 11
Joined: Tue Jan 17, 2012 4:49 am

Re: hiding fields in a find form by permission

Postby shannah » Fri Mar 02, 2012 2:58 pm

Inside the dataface directory of the application there should be another version.txt file. What does it say?
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: hiding fields in a find form by permission

Postby magazzu » Sat Mar 03, 2012 2:53 pm

it's 1.3rc4 2458
magazzu
 
Posts: 11
Joined: Tue Jan 17, 2012 4:49 am

Re: hiding fields in a find form by permission

Postby magazzu » Wed Mar 07, 2012 2:39 am

Hello,


The version is 1.3rc4 2458

Any hint?

Thanks
magazzu
 
Posts: 11
Joined: Tue Jan 17, 2012 4:49 am

Re: hiding fields in a find form by permission

Postby shannah » Wed Mar 07, 2012 10:24 am

I believe that if you update the dataface directory to the latest (1.3.2) it should fix this issue.
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: hiding fields in a find form by permission

Postby magazzu » Wed Mar 07, 2012 10:30 am

shannah wrote:I believe that if you update the dataface directory to the latest (1.3.2) it should fix this issue.


Thank you.

I am not sure I know how to do it. Where do I get the new directory? How can I make the update with no risk for my application?

These questions may appear silly, but I'm really new to this.
magazzu
 
Posts: 11
Joined: Tue Jan 17, 2012 4:49 am

Re: hiding fields in a find form by permission

Postby shannah » Wed Mar 07, 2012 10:41 am

rename the dataface directory to dataface-old
download xataface-1.3.2 and place it in the librariandb directory, but rename it "dataface", so that it is effectively replacing your old dataface directory.

That's it.
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: hiding fields in a find form by permission

Postby magazzu » Wed Mar 07, 2012 11:06 am

shannah wrote:rename the dataface directory to dataface-old
download xataface-1.3.2 and place it in the librariandb directory, but rename it "dataface", so that it is effectively replacing your old dataface directory.

That's it.


Thanks.

Successfully done. But my problem remains: The "find" action shows also the fields that I want to hide to common users. Sigh.

Is there another way to hide fields, leaving them visible to admin?
magazzu
 
Posts: 11
Joined: Tue Jan 17, 2012 4:49 am

Re: hiding fields in a find form by permission

Postby shannah » Wed Mar 07, 2012 11:22 am

In the init() method of the table delegate class, you could conditionally make them hidden.
e.g.
Code: Select all
function init(Dataface_Table $table){
    if ( !isAdmin() ){
        $myfield =& $table->getField('myfield');
        $myfield['visibility']['find'] = 'hidden';
    }

    // etc...
}


NOTE: isAdmin() doesn't exist. YOu need to create a function like that yourself.
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: hiding fields in a find form by permission

Postby magazzu » Wed Mar 07, 2012 12:34 pm

YES, this works!

Thank you very much.

Antonio
magazzu
 
Posts: 11
Joined: Tue Jan 17, 2012 4:49 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 15 guests

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