checkboxes in related lists

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

checkboxes in related lists

Postby ianmac » Sat Dec 12, 2009 5:41 am

Firstly, thanks for the excellent framework.

I've got rid of the select checkboxes from the main list tab. However disable_select_rows doesn't prevent them from appearing in a related list. Is there any way of doing this (and generally making the related list appearance consistent with the normal result list)?

I'm using 1.1.5r2 (because of php version used by host)
ianmac
 
Posts: 4
Joined: Sat Dec 12, 2009 5:33 am

Postby shannah » Sat Dec 12, 2009 9:24 am

The checkboxes will appear as long as there are selected actions to perform. It is looking for any actions of category "related_list_actions" and if it finds any, it will add checkboxes and the corresponding buttons below the list.

You can disable the related_list_actions in 3 ways:

1. Override each action of this category individually and change its category, or alter it's permission or condition so as to not appear in the cases that you are interested in.

2. Check the permission on the actions in this category, and set your permissions so as not to permit these actions.

You can see which actions are in this category by just looking at the xataface permissions.ini file.
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby ianmac » Sat Dec 12, 2009 9:42 am

Thanks for your prompt reply. I have been cutting out actions (in actions.ini), but will look at cutting out permissions per your suggestion. Thanks.
ianmac
 
Posts: 4
Joined: Sat Dec 12, 2009 5:33 am

Postby ianmac » Mon Dec 14, 2009 4:45 am

I'm trying to make a completely stripped-down, read-only app.

Before I created this topic I did the following in actions.ini:
- cleared all 'invalid' actions by deleting everything after the header, like:
;; Create a new record
[new]
<deleted>

which I understand to mean that the New action no longer ever has any permission to happen.

- So, all remaining 'valid' actions were in one of the following categories:
table_tabs, find_actions, record_tabs, ajax_actions
(+ login_actions, personal_tools, management_actions, event_actions, which I don't think are relevant here)

- and the only permissions used by the 'valid' actions are:
view, list, find, calendar, ajax_load, find_list, ajax_form
(+ install, manage_*, xml_view, which I don't think are relevant here)
Plus the [Ajax_form] action had the ajax_form permission, and the [Edit_event_details] had the edit permission.

- The only related_* action that has anything at all in it is:
[related_records_list]
mode = browse
template = Dataface_Related_Records_List.html
label = "{$query['-relationship']}"
permission = view
related=1

After your reply, I looked at permissions.ini, but I can't see any need to do anything there after the above, but I went back to actions.ini and changed the [Ajax_form] action permission to view and [Edit_event_details] permission to view. That had no effect.

I can see that unlike ResultList.php, RelatedList.php does not check disable_select_rows, and I may be wrong, but it looks to me like RelatedList.php assumes that edit, etc is allowed if the relationship is many-to-many.

Any idea where am I going wrong?

edit: I have actions:addexisting = 0 and actions:addnew = 0 in both relationships.ini files.
ianmac
 
Posts: 4
Joined: Sat Dec 12, 2009 5:33 am

Postby shannah » Mon Dec 14, 2009 10:24 am

If you're trying to make a "read only" application, then you should be looking at permissions exclusively. Simply disabling the action is neither sufficient nor necessary.

If I were you, I'd put everything back to default, then set your permissions in your application delegate class as follows:

Code: Select all
class conf_ApplicationDelegate {
    function getPermissions(&$record){
        return Dataface_PermissionsTool::READ_ONLY();
}


Or if read only is still too permissive for you , you can create a custom role in your permissions.ini file with even less permissions than the READ ONLY role.

e.g. a role that only allows view, list, and link (this is pretty minimal), you would do:

Code: Select all
[my_role]
    view=1
    list=1
    link=1


Then your getPermissions method would change to:

Code: Select all
function getPermissions(&$record){
    return Dataface_PermissionsTool::getRolePermissions('my_role');
}


or you could use the getRoles() method instead of getPermissions() to accomplish the same thing:

Code: Select all
function getRoles(&$record){
    return 'my_role';
}
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby ianmac » Tue Dec 15, 2009 4:27 am

Thanks. That's a much cleaner way of achieving read-only behaviour. I returned my actions.ini and permissions.ini to default, then I created a role in permissions.ini:
[my_role]
view = 1
list = 1
find = 1
view related records = 1

I added the getPermissions method as suggested above into ApplicationDelegate.php in folder conf of my application.

My conf.ini was as before.

And that all works pretty much as before, including that the record selector checkboxes still appear in the related list!

Unlike ResultList.php, RelatedList.php does not make their appearance conditional.

To achieve that I used the checks from ResultList.php and modified RelatedList.php at about line 343:
Code: Select all
         if ( count($records) > 0 ){
         
            $canSelect = false;
            if ( !@$app->prefs['disable_select_rows'] ){
               $canSelect = Dataface_PermissionsTool::checkPermission('select_rows',
                     Dataface_PermissionsTool::getPermissions( $this->_table ));
            }
            echo '
               <table>
               <thead>
               <tr>'; //<th><input></th>
               //';
               if ( $canSelect){
                  echo '<th><input></th>';
               }


and at about line 469:
Code: Select all

echo "<tr>";
               if ( $canSelect ) {
                  echo '
                  <td>
                     <input>
                  ';
                  
                  echo '
                  </td>';
               }


Sorry, I can't get the code to appear correctly here, but you get the idea.

That all seems to work, but it does mean I've modified the base code, which I don't like. Is there another way of doing the above?
ianmac
 
Posts: 4
Joined: Sat Dec 12, 2009 5:33 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 14 guests

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