Page 1 of 1

How to hide "Also delete record(s) from database?" message?

PostPosted: Wed Oct 26, 2011 2:56 am
by FractalizeR
When I try to remove rows from relation, Xataface asks
"Also delete record(s) from database?"
- what does this question mean? As I can see, without checking it, record gets deleted well.
And how to hide it?

Re: How to hide "Also delete record(s) from database?" messa

PostPosted: Wed Oct 26, 2011 4:40 am
by ADobkin
By default, removing records from a relationship only makes it so the records are no longer related. The original records should still exist.

For example, with a cities table and countries table, I might accidentally create a relationship by adding London to France. To correct it, I would remove the relationship, but I would still want London to exist. However, if this were a city that needed to be deleted completely, then I would want to also select the option to delete the record from the database.

If you don't want this message to appear, one method I can think of would be to revoke the delete permission. I'm sure there are other ways to do it if that doesn't meet your needs.

Re: How to hide "Also delete record(s) from database?" messa

PostPosted: Wed Oct 26, 2011 5:58 am
by FractalizeR
ADobkin wrote:If you don't want this message to appear, one method I can think of would be to revoke the delete permission. I'm sure there are other ways to do it if that doesn't meet your needs.

How to do that? I've added the following to the table class, but this message still appears. I have user, country, and user_country tables in this relation.

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

Re: How to hide "Also delete record(s) from database?" messa

PostPosted: Wed Oct 26, 2011 6:21 am
by ADobkin
This wiki page explains it in detail:

http://xataface.com/wiki/Relationship_Permissions

Re: How to hide "Also delete record(s) from database?" messa

PostPosted: Wed Oct 26, 2011 6:45 am
by FractalizeR
Thanks, but this page contains permission fine-tuning only for relation itself.

It seems, that setting permission on the table, which is a relation participant, should really revoke delete permission from it, but somehow that message still appears for me despite providing tables_country::getPermissions() method.

Re: How to hide "Also delete record(s) from database?" messa

PostPosted: Wed Oct 26, 2011 7:01 am
by ADobkin
Perhaps the "delete related record" permission is granted somewhere in your application:

Permission to delete a related record. This allows both removing the related record from the relationship, and deleting the record from the database. This permission is not included in any default roles. A combination of permission for remove related record? in the source table and delete? in the target table, are equivalent to access to this permission. Use this permission only when you need to override the ability to delete records from the database based on membership in a relationship.


Since this permission is not normally included by default, maybe you have ALL() permissions defined somewhere.

Incidentally, I do not normally see this message in my applications when removing related records, and the original record is not deleted. So it sounds like you have customized something somewhere that is triggering it.

Re: How to hide "Also delete record(s) from database?" messa

PostPosted: Wed Oct 26, 2011 7:21 am
by FractalizeR
Can I show you my config by email? I don't see any permissions override since I don't use permission system at all.

I have only a call

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


But that's another table. And permission is READ_ONLY, not ALL.

Re: How to hide "Also delete record(s) from database?" messa

PostPosted: Wed Oct 26, 2011 7:49 am
by ADobkin
Sure, I can look at it for you. I will send you a PM with my contact info.

BTW, I need to correct my earlier statement. I do also see this message when logged in as an admin user. According to the code in RemoveRelatedRecordForm.php, it checks for two permissions:

// We are allowed to delete the records if for each record in the 
// set, we have either:
// 1. Delete permission on the domain record.
// 2. delete related record permission on the parent record


So, if you revoke delete permission on the parent record/table by setting READ ONLY (as it seems you have), that should suppress this option. I could do some testing in my application to verify this.

Re: How to hide "Also delete record(s) from database?" messa

PostPosted: Wed Oct 26, 2011 8:01 am
by FractalizeR
I've sent you my project. And yes, I login as admin user it seems because... I don't login at all ;) Xataface seem to set admin user priviledges by default, if application doesn't use permission system.

Thanks in advance.