__filters__ manual page

A place to discuss development of the Xataface core.

__filters__ manual page

Postby Jean » Wed Jun 18, 2008 2:20 am

Hi Steve,
Could you give me the URL of the __filters__ manual page ?
Thank you
Jean
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France

Postby shannah » Wed Jun 18, 2008 7:34 pm

hmmm.. I can't seem to find it right now.

Practically speaking the __filters__ section is not all that useful because you can't include very much environment information into the filters.

Using the setSecurityFilter() method is usually more effective.

Here is a quick example:

In the fields.ini file for say the users table:
Code: Select all
[__filters__]
    group_id=10


This would effectively filter the users table to only show users with group_id=10.

You can see how this isn't all that helpful.

A more flexible solution involving the setSecurityFilter() method:

In the delegate class for the users table:
Code: Select all
<?php
class tables_users {
    function init(&$table){
        $table->setSecurityFilter(array('group_id'=>10));
    }
}


The above would be the equivalent to the __filters__ example.

More useful if we apply different filters for different users:
e.g.
Code: Select all
<?php
class tables_users {
    function init(&$table){
        if ( !isAdmin() ){
            $table->setSecurityFilter(array('group_id'=>10));
        }
    }
}


This will only set the filter on non-admin users (assuming that you have defined a function isAdmin() to tell you if the current user is an admin user.

Hope this helps.

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

Postby shannah » Wed Jun 18, 2008 7:36 pm

Another thing used in my example that I realize may not have been well documented is the init() method. If you define a method in your delegate class as follows:
Code: Select all
function init(&$table){

   ....
}



This method will be call once just after the table is loaded for the first time. It allows you to do initialization stuff (like security filters) that you only want to happen once.

Note that it takes a single parameter: a Dataface_Table object of the table that is being initialized.

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


Return to Xataface Developers

Who is online

Users browsing this forum: No registered users and 8 guests

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