CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Soft delete using ACL?
Pages: [1]

Author Topic: Soft delete using ACL?  (Read 1356 times)

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Soft delete using ACL?
December 10, 2008, 11:49:37 am
Hi there,

I'm thinking about how to implement soft delete functionality in CiviCRM and think ACL sounds like a sensible approach (creating a deleted contacts ACL group with restricted permissions).  I've posted about what I need here (http://forum.civicrm.org/index.php/topic,3696.0.html) - but basically it is the following:
* ability to roll back any deletions
* deleted contacts are hidden from normal users and during most common operations, but still available to some/all for reporting

Haven't done anything with ACL apart from try and get my head around it, and (as I'm sure you can remember from when you couldn't understand it) it's a bit of a tough one, so before I start, I was wondering if anyone has any thoughts on whether this is a sensible stop gap for between now and when soft deletion becomes more thoughtfully considered and integrated.

I imagine that if it works in principle, I might make some 'shortcut' delete buttons that would assign people to the group and make these additions available if they worked ok, but before I do that...

Cheers!

Michael
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Soft delete using ACL?
December 10, 2008, 06:41:40 pm

so we've implemented soft delete for the case management functionality using is_deleted boolean flag (for case and activities). So basically we suppress all cases / activities where is_deleted is 1. At some stage we will make this configurable

We should consider using this approach for contacts also. We probably need to add the is_deleted flag to the top level objects (or maybe just the contact record, and then left join with civicrm_contact). I think this is a better more scalable approach (the ACL idea is quite neat too, i'd probably use a custom field and the acl hook to make it super efficient). We are in code freeze for 2.2, but would be great for you to consider doing this approach for 2.3. Dont know how urgent your needs are and if it wait for another release :)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Soft delete using ACL?
December 11, 2008, 04:35:58 am
Big shout out to all the 2.2 code freezers!!

OK - will have a look into the ACL hook and cutom data method (might need a little bit of help on that) and let you know how I get on.



Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Soft delete using ACL?
December 15, 2008, 11:26:15 am
OK, this is where I am so far...

With a little bit of help from Chris Burgess's and Lobo's posts, I'm think I've done reasonably well to start...

Because ACL's don't allow DENY but do allow ALLOW, I decided to set an ACL to ALLOW viewing of all contacts which are present.

Code: [Select]
function civitest_civicrm_aclWhereClause( $type, &$tables, &$whereTables, &$contactID, &$where ) {

    $presentTable='civicrm_value_present_3';
   
    $tables[$presentTable] = $whereTables[$presentTable] =
        "LEFT JOIN {$presentTable} presentTable ON contact_a.id = presentTable.entity_id";
   
    $where.=' presentTable.present_4 ';
}

This gives all users permission to view present contacts.  I now need to limit this hook to apply only when $ContactID is a members of a particular group but can't work out how to test for ACL group membership.  Is that correct?  Any pointers?  Maybe I am missing something obvious.

Another thing I am wondering is if this will sit nicely with other ACL.  I have a feeling I'm missing something in my $where variable.

Also, my Dojo search box doesn't respect the ACL - is that expected?  It will probably slightly confuse users (and might be a serious problem in some sensitive installations where even knowing that someone is on the database is significant).
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Soft delete using ACL?

This forum was archived on 2017-11-26.