Page 1 of 1

hiding fields in a find form by permission

PostPosted: Fri Mar 02, 2012 12:03 pm
by magazzu
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

Re: hiding fields in a find form by permission

PostPosted: Fri Mar 02, 2012 12:36 pm
by shannah
What version of Xataface are you using?

Re: hiding fields in a find form by permission

PostPosted: Fri Mar 02, 2012 2:49 pm
by magazzu
Actually, I'm using librarianDB, maybe I posted in the wrong place.


The version.txt file says: 0.3.2 2530

Re: hiding fields in a find form by permission

PostPosted: Fri Mar 02, 2012 2:58 pm
by shannah
Inside the dataface directory of the application there should be another version.txt file. What does it say?

Re: hiding fields in a find form by permission

PostPosted: Sat Mar 03, 2012 2:53 pm
by magazzu
it's 1.3rc4 2458

Re: hiding fields in a find form by permission

PostPosted: Wed Mar 07, 2012 2:39 am
by magazzu
Hello,


The version is 1.3rc4 2458

Any hint?

Thanks

Re: hiding fields in a find form by permission

PostPosted: Wed Mar 07, 2012 10:24 am
by shannah
I believe that if you update the dataface directory to the latest (1.3.2) it should fix this issue.

Re: hiding fields in a find form by permission

PostPosted: Wed Mar 07, 2012 10:30 am
by magazzu
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.

Re: hiding fields in a find form by permission

PostPosted: Wed Mar 07, 2012 10:41 am
by shannah
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.

Re: hiding fields in a find form by permission

PostPosted: Wed Mar 07, 2012 11:06 am
by magazzu
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?

Re: hiding fields in a find form by permission

PostPosted: Wed Mar 07, 2012 11:22 am
by shannah
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.

Re: hiding fields in a find form by permission

PostPosted: Wed Mar 07, 2012 12:34 pm
by magazzu
YES, this works!

Thank you very much.

Antonio