Page 1 of 1

DataGrid Tab doesn't appear [Solved]

PostPosted: Thu May 20, 2010 6:50 am
by ctrl
Hi,

first I have to congratulate you, xataface is a really great tool!

Currently I try to use the DataGrid module but the Tab doesn't appear and I don't know why.

This is what I have done so far:
1. Extract the DataGrid-zip in a xataface-modules folder.
Code: Select all
...
lib/xataface
lib/xataface_modules
...


2. Add the following line in my conf.ini file
Code: Select all
[_modules]
modules_DataGrid=../lib/xataface_modules/DataGrid/DataGrid.php

This works fine. If I change the path an error appears.

3. Add a permissions.ini file (I didn't use the permissions.ini file so far) with the following lines
Code: Select all
[ADMIN]
    DataGrid:view_grid=1
    DataGrid:update=1
   
[admin]
    DataGrid:view_grid=1
    DataGrid:update=1

'ADMIN' is a predefined role and 'admin' a role name in my user table

4. I enabled the xataface security/authentication mode and wrote a ApplicationDelegate class (as described in the docs) to implement a specific permission function. It allows to
disable access to specific tables for roles (works fine):
Code: Select all
function getPermissions(&$record)
    {
        $table = ($record->_tablename);
        $app =& Dataface_Application::getInstance();
        $config = $app->_conf;
        // $record is a Dataface_Record object
        $auth =& Dataface_AuthenticationTool::getInstance();
        $user =& $auth->getLoggedInUser();
        $permission;
        if ($user)
        {
            // perform logged in user
            $config = $app->conf();
            $role = $user->val('role_');
            $role_disallow_arr = $config['disallow_table'];
            //print_r($role_disallow_arr[$role]);
            if($role_disallow_arr[$role])
            {
                if(in_array($table, $role_disallow_arr[$role]))
                {
                    $permission = Dataface_PermissionsTool::getRolePermissions('NO ACCESS');
                    //echo "Not allowed";
                }
            }
           
            if($role == 'admin' OR $role == 'user')
            {
                $permission = Dataface_PermissionsTool::getRolePermissions('ADMIN');
                //echo "admin rights";
            }
            else if ($role == 'guest')
            {
                $permission = Dataface_PermissionsTool::getRolePermissions('READ ONLY');
            }
            else
            {
                //unkown role, search for match in predefined roles
                $permission = Dataface_PermissionsTool::getRolePermissions($role);
            }
        }
        else
        {
            // not logged in
            $permission = Dataface_PermissionsTool::getRolePermissions('NO ACCESS');
        }
        return $permission;
    }


In the conf.ini file I added the following lines:
Code: Select all
;Disallow table access for specific roles
;First set the role name with [] as suffix as key and the table name as value
[disallow_table]
user[]=event_type
user[]=period_type
user[]=user
guest[]=event_type
guest[]=period_type
guest[]=user


Any hints what I do wrong?

regards,
Armin

Re: DataGrid Tab doesn't appear

PostPosted: Thu May 20, 2010 7:57 am
by shannah
The xataface modules should be inside the xataface directory.
i.e. xataface/modules/DataGrid
not
xataface_modules/DataGrid

Re: DataGrid Tab doesn't appear

PostPosted: Thu May 20, 2010 8:17 am
by ctrl
wow, fast reply.
yeah! Now it works! Thanks!

Have to move the module into the xataface application directory.
Moving it to the xataface library the tab appears but it cause an error on click.
Code: Select all
app/manage/conf.ini
app/manage/index.php
...
app/manage/modules/DataGrid

app/lib/xataface


regards,
Armin