History record show NO Access

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

History record show NO Access

Postby muzafar » Mon Feb 13, 2012 11:28 pm

Greetings,

I enabled the history and I have records in history tables in database as well, but when I try to view history while clicking on (+) sign to expand the view, it shows "NO ACCESS" in front of the field column. i.e
Details Changes
Id: NO ACCESS
Agenda: NO ACCESS
Cycle: NO ACCESS
Meeting Start: NO ACCESS

why it doesn't show the records even if it's still in the history table?

kindly lead me.

Thanks,

regards,

Muzafar
muzafar
 
Posts: 44
Joined: Mon Nov 28, 2011 9:25 pm

Re: History record show NO Access

Postby shannah » Tue Feb 14, 2012 11:24 am

What permissions do you assign for the user on that table?
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: History record show NO Access

Postby muzafar » Tue Feb 14, 2012 11:15 pm

We have different roles for different users, but we are accessing it through the role Admin. as you can see in the below functions, for each user we have different roles and assigned different permissions, but for the role Admin we have assigned the ALL permission. As you explained in the documents of history logging, we did the same and enable history in conf file. History linked is enabled but when we click on to view the details it is showing No Access in front of each column, even No ACCESS in the changes tab as well.
please find the attached snapshot. I am logged in from my account, muzafar, which has the role of Admin.

function getPermissions(&$record)
{
$user = Dataface_AuthenticationTool::getInstance()->getLoggedInUser();
if ( !isset($user) )return Dataface_PermissionsTool::NO_ACCESS();
$role = $user->val('role');
switch ($role)
{
case 'Admin':
return Dataface_PermissionsTool::ALL();
case 'Regular':
case 'Cal':
$perms = Dataface_PermissionsTool::NO_ACCESS();
$perms['new'] = 1;
$perms['list'] = 1;
$perms['find'] = 1;
$perms['details'] = 1;
$perms['view'] = 1;
$perms['browse'] = 1;
$perms['link'] = 1;
$perms['edit'] = 1;
$perms['calendar'] = 1;
return $perms;
default:
return Dataface_PermissionsTool::NO_ACCESS();
}
}
Attachments
No_Access.jpg
Attached is the snapshot of No Access.
No_Access.jpg (67.64 KiB) Viewed 9543 times
muzafar
 
Posts: 44
Joined: Mon Nov 28, 2011 9:25 pm

Re: History record show NO Access

Postby ADobkin » Wed Feb 15, 2012 10:36 pm

I ran into a similar problem in one of my applications. I think part of the issue is that the built-in tables (i.e. those starting with dataface__ or ending with __history) are set as "_disallowed_tables" by default. In my case, I also have the default table role (when no other permissions are defined) set to NO ACCESS. Since the "__history" tables are not explicitly defined (i.e. no table delegate files), access to these fields is restricted, so I used the following workaround:

Code: Select all
function getPermissions(&$record) {
    // Skip no access restrictions for certain built-in tables
    $tableName = $record->_table->tablename;
    if (substr($tableName, 0, 10) == 'dataface__' or substr($tableName, -9, 9) == '__history') {
        // default permissions go here
    }
}
ADobkin
 
Posts: 195
Joined: Mon Oct 22, 2007 7:31 pm
Location: Atlanta, GA, USA

Re: History record show NO Access

Postby muzafar » Wed Feb 15, 2012 11:32 pm

thanks ADobkin I am playing with it now, and putting this block of code in my table delegate class, like this.

function getPermissions(&$record)
{
$user = Dataface_AuthenticationTool::getInstance()->getLoggedInUser();
if ( !isset($user) )return Dataface_PermissionsTool::NO_ACCESS();
$role = $user->val('role');

$tableName = $record->_table->tablename;
if (substr($tableName, 0, 10) == 'dataface__' || substr($tableName, -9, 9) == '__history') {
return Dataface_PermissionsTool::ALL();
}

switch ($role)
{
case 'Admin':
return Dataface_PermissionsTool::ALL();
case 'Regular':
case 'Cal':
$perms = Dataface_PermissionsTool::NO_ACCESS();
$perms['new'] = 1;
$perms['list'] = 1;
$perms['find'] = 1;
$perms['details'] = 1;
$perms['view'] = 1;
$perms['browse'] = 1;
$perms['link'] = 1;
$perms['edit'] = 1;
$perms['calendar'] = 1;
return $perms;
default:
return Dataface_PermissionsTool::NO_ACCESS();
}
}

I also put your block of code in case Admin: but it's not working. I have role of Admin. please lead me what I am doing wrong? I put this script but it's still show NO ACCESS. I put it in ApplicationDelegate.php as well, but not working at all.

your help on the above will be greatly appreciated.

Thanks
muzafar
 
Posts: 44
Joined: Mon Nov 28, 2011 9:25 pm

Re: History record show NO Access

Postby ADobkin » Wed Feb 15, 2012 11:50 pm

Sorry, I should have clarified - in my case, that block of code goes in the Application Delegate class so it catches all tables. Otherwise, you would have to explicitly create a separate table delegate class for each table's history table, e.g.:

table1
table1__history
table2
table2__history
...

Do you already have a getPermissions() function in your Application Delegate, or are they only defined in table delegates?

Alan
ADobkin
 
Posts: 195
Joined: Mon Oct 22, 2007 7:31 pm
Location: Atlanta, GA, USA

Re: History record show NO Access

Postby muzafar » Thu Feb 16, 2012 12:33 am

thanks AdoBkin

it's fine now. actually I had put getPermission function in ApplicationDelete class in which I had passed No Access. I modified the code and it's working fine now. One thing now is that there is no revert icon at the left of the history revision, why this icon is not showing here with me? as it is defined here,

http://xataface.com/documentation/how-to/history-howto
muzafar
 
Posts: 44
Joined: Mon Nov 28, 2011 9:25 pm

Re: History record show NO Access

Postby shannah » Thu Feb 16, 2012 10:43 am

Yes. This was happening because it was showing the values through a record of the xxx__history table which you wouldn't have defined permissions on.

I have fixed this in the 1.3.x and 1.5.x branches and the trunk.

Code: Select all
r3294 | shannah | 2012-02-16 09:36:52 -0800 (Thu, 16 Feb 2012) | 2 lines
Changed paths:
   M /dataface/core/trunk/Dataface/templates/Dataface_HistoryRecordDetails.html
   M /dataface/core/trunk/Dataface/templates/Dataface_RecordHistory.html
   M /dataface/core/trunk/actions/history.php
   M /dataface/core/trunk/actions/view_history_record_details.php

Fixed permissions on history so that if user has view permission for fields in the source table, then they'll be able to view the history of said field also.
http://xataface.com/forum/viewtopic.php?f=4&t=6583


I recommend you change your application delegate back to no access as this is safer. If you apply this fix, it will properly use the permissions of the base table instead of the history table so you should be able to see the fields.

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

Re: History record show NO Access

Postby ADobkin » Wed Feb 22, 2012 8:12 pm

Steve,

Thanks for making these changes! Unfortunately, after updating these files, when I revert my Application Delegate back to no access, I still get NO ACCESS in all of the history fields. Any suggestions for debugging this issue further? I've tried both 1.3.x and 1.5.x, but not the trunk yet.

Thanks,
Alan
ADobkin
 
Posts: 195
Joined: Mon Oct 22, 2007 7:31 pm
Location: Atlanta, GA, USA

Re: History record show NO Access

Postby shannah » Thu Feb 23, 2012 10:48 am

I can't reproduce this behaviour on the 1.3.x branch. Your table just needs to provide "history" permission and it should show up.

Example that is working for me on 1.3.x:

Application Delegate:
Code: Select all
<?php
class conf_ApplicationDelegate {
   function getPermissions($record){
      return Dataface_PermissionsTool::NO_ACCESS();
   }
}


People table delegate:
Code: Select all
<?php
class tables_people {
   function getPermissions($record){
      return array(
         'view'=>1,
         'list'=>1,
         'history'=>1,
         'edit'=>1
      );
   }
}


If you go to the history tab of a record in the people table it should show you all of the fields properly. Can you post a simple counterexample?

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

Re: History record show NO Access

Postby ADobkin » Thu Feb 23, 2012 10:01 pm

I'm a bit perplexed so far, but still trying to figure this one out. I replaced my Application Delegate and one of my table delegates to match yours as a test. I am logged in as an admin user, which normally has rights to everything in my application. The user can access the records in this table, but it still gets "NO ACCESS" for all of the history detail fields. If I exclude the __history tables from the no access rule in the Application Delegate, then it works fine.
ADobkin
 
Posts: 195
Joined: Mon Oct 22, 2007 7:31 pm
Location: Atlanta, GA, USA


Return to Xataface Users

Who is online

Users browsing this forum: Bing [Bot] and 2 guests

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