Change or remove the delete action

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

Change or remove the delete action

Postby clawes » Tue May 15, 2012 11:43 am

I have developed a contact management application with a mysql backend. The records in this database are later used to create contact accounts in our Windows Active Directory domain. I have a Windows Powershell script that queries the database periodically for all records that are flagged (create_this=1) for processing then create the AD contact accounts accordingly.

At the moment, deleting a contact record in the database has no impact on the related account in AD. What I would like is for all Xataface delete actions to simply "flag" the record for deletion instead of removing it entirely. Is there a way to customize the delete action so that the affected records are flagged, i.e. set the delete_this field to 1 then hidden the record from the list view? The Powershell script will be updated to find these records then remove the corresponding AD accounts.

:?:
clawes
 
Posts: 22
Joined: Mon May 07, 2012 12:02 pm

Re: Change or remove the delete action

Postby shannah » Tue May 15, 2012 12:00 pm

I think the easiest thing to do would be to:

1. Disallow the delete permission on the table (so users cannot delete records)
2. Create your own "delete" action that is essentially a special update.

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

Re: Change or remove the delete action

Postby clawes » Tue May 15, 2012 2:31 pm

Thanks for the responding.


1. Pardon my ignorance, but how do you set the "disable delete" at the table level?
2. I would like to keep the Delete (with selected) option on the list view so that one can easily select multiple records for deletion "flagging" instead of creating a delete action checkbox at the form level.

Any pointers?
clawes
 
Posts: 22
Joined: Mon May 07, 2012 12:02 pm

Re: Change or remove the delete action

Postby shannah » Tue May 15, 2012 2:48 pm

If you disallow the delete permission it will prevent users from deleting records from any access point. It is possible that the delete selected action will need to be disabled separately.... though if you use delete selected on a record that doesn't grant the "delete" permission, the operation will fail.

You can set permissions on a table by table basis by defining the getPermissions() method in the appropriate table's delegate class.

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

Re: Change or remove the delete action

Postby clawes » Tue May 15, 2012 3:13 pm

Upon further pondering, I decide to approach this another way:

I will allow deletion as normal. I will create a beforeDelete trigger that will copy the deleted records to another table called delete_these, for example.
My backend Powershell script will query the delete_these table and process any record it finds there.

In this approach, I don't have to make any changes to the form or fiddle with permissions. My contacts table stays current with only active contacts.

I would appreciate if you could provide a simple code snippet (or direction to one) that demonstrates how to copy a dataface record array to another table.

TIA.
clawes
 
Posts: 22
Joined: Mon May 07, 2012 12:02 pm

Re: Change or remove the delete action

Postby shannah » Tue May 15, 2012 4:06 pm

Just use SQL queries.
Code: Select all
$res = mysql_query("insert into copy_of_table select * from original_table where id='".addslashes($record->val('id'))."'", df_db());
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Change or remove the delete action

Postby clawes » Wed May 16, 2012 6:45 am

That worked. Thanks again! :D
clawes
 
Posts: 22
Joined: Mon May 07, 2012 12:02 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 14 guests

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