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 »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • "delete contact" option appears on "more" drop-down list despite permissions
Pages: [1]

Author Topic: "delete contact" option appears on "more" drop-down list despite permissions  (Read 1291 times)

ctarascio

  • I post frequently
  • ***
  • Posts: 334
  • Karma: 30
    • American Friends Service Committee
  • CiviCRM version: 4.1.3
  • CMS version: Drupal 6.26
  • MySQL version: 5.5.20
  • PHP version: 5.3.13
"delete contact" option appears on "more" drop-down list despite permissions
May 19, 2011, 10:29:43 am
Hi,
I posted this as an issue when we were testing 3.4.alpha and 3.4.beta but at that time, I wasn't sure if it was related to our multi-site installation or to a core issue, but now I am experiencing the same issue in a 3.4.1 non-multi-site installation of civi.

Permissions for the role "staff" are as follows: access civicrm, access contacts, add contacts, profile listings, access content and change user name.

I log in as a user with the "staff" role. Do a search for all contacts. Select a contact. I am able to select "delete contact" from the "More" menu that appears to the right of the selected contact. I am then able to delete the selected contact, usually without error, but the contact continues to appear on the screen even though the message indicates that the contact was deleted. Sometimes though, when I click on delete contact I receive the message "sorry, a non-recoverable error has occurred".

Further... if I log out and then log back in as an administrator with full permissions, the record that was deleted by "staff" does not appear when I do a search/find contacts but it does appear when I do an advanced search/search in "trash".

I can't test this on the demo because i can't get to the Drupal permissions.

Any help would be much appreciated.

Thanks,
Cynthia


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: "delete contact" option appears on "more" drop-down list despite permissions
May 19, 2011, 01:14:21 pm

Seems like a bug. Would be great if you can get an AFSC developer to investigate and submit a patch to fix this

thanx

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

davej

  • Ask me questions
  • ****
  • Posts: 404
  • Karma: 21
Re: "delete contact" option appears on "more" drop-down list despite permissions
July 14, 2011, 09:11:54 am
Hi,

I've had a bit of a look through the relevant code. In our case I found that "edit all contacts" permission was allowing users to delete contacts.

Cynthia, you didn't mention "edit all contacts" permission but you mentioned "access contacts", which isn't a permission that I can see. Can you confirm the exact Civi permissions that your staff role has? Do you have any ACLs defined for the relevant users?

Here's the code path that seems to be responsible:

CRM_Contact_Selector::getRows:
line 567:
Code: [Select]
        $links =& self::links( $this->_context, $this->_contextMenu, $this->_key );
then line 723:
Code: [Select]
                // FIXME: guard with permission check
                } else {
                    $row['action']   = CRM_Core_Action::formLink( $links, $mapMask, array( 'id' => $result->contact_id ) );
                }
...where $this->_contextMenu was passed as a parameter to CRM_Contact_Selector::_construct, which was called in CRM_Contact_Form_Search::postProcess, passing contextMenu originally set in preProcess from CRM_Contact_BAO_Contact::contextMenu().

CRM_Contact_BAO_Contact::contextMenu() checks for 'access deleted contacts' and 'delete contacts' - but it then does this:
line 2543:
Code: [Select]
                 // if still user does not have required permissions, check acl.
                 if ( !$hasAllPermissions ) {
                     if ( in_array( $values['ref'], $aclPermissionedTasks ) &&
                          $corePermission == CRM_Core_Permission::EDIT ) {
                         $hasAllPermissions = true;
                     } else...
                 }
where $values['ref'] is 'delete-contact', which is in $aclPermissionedTasks.
So it checks $corePermission,
which comes from CRM_Core_Permission::getPermission(),
which calls CRM_Core_Permission_Drupal::getPermission(),
which checks self::$_editPermission,
which is set to true in self::group() if the user has 'edit all contacts' permission (or, IIUC, if they have ACL edit rights for any group).

So CRM_Core_Permission_Drupal::getPermission() returns CRM_Core_Permission::EDIT.

So CRM_Contact_BAO_Contact::contextMenu() sets $hasAllPermissions = true and so includes the Delete Contact link.

I'm not sure what's the best way to sort this out. I wonder if there's an underlying issue that needs thinking about: the way there's a grand CRM_Core_Permission::EDIT, conferred by 'edit all contacts', which bypasses more fine-grained permission checking. Is this a hangover from days when the permissioning was simpler, and does it need re-thinking? It would be helpful if one of the core team could offer their thoughts.

Short of such a re-think, it seems to me the place to fix it is in CRM_Contact_BAO_Contact::contextMenu(). Could someone who understands these things explain the intention behind the above code snippet from that function, where it looks at $aclPermissionedTasks? It seems to be saying if the task is one that can be ACL'd, then allow access if the user has CRM_Core_Permission::EDIT.

Ah, just had a look at why the Delete Contact form doesn't refuse the deletion and found this in CRM_Contact_Form_Task_Delete, line 94:
Code: [Select]
            if ( !CRM_Contact_BAO_Contact_Permission::allow( $cid, CRM_Core_Permission::EDIT ) ) {
                CRM_Core_Error::fatal( ts( 'You do not have permission to delete this contact. Note: you can delete contacts if you can edit them.' ) );
            }

Is that the currently intended behaviour or an oversight from before delete permission was introduced?

Dave J

ctarascio

  • I post frequently
  • ***
  • Posts: 334
  • Karma: 30
    • American Friends Service Committee
  • CiviCRM version: 4.1.3
  • CMS version: Drupal 6.26
  • MySQL version: 5.5.20
  • PHP version: 5.3.13
Re: "delete contact" option appears on "more" drop-down list despite permissions
July 14, 2011, 09:42:35 am
hi dave,
many thanks for looking into this :)

we have the following permissions assigned to the staff role:
access CiviCRM
access CiviMail subscribe/unsubscribe pages
access Contact Dashboard
access all custom data
add contacts
edit all contacts
edit groups
profile listings
profile listings and forms
profile view
access content
change own username

the "access contacts" in my initial post was a mistake. sorry for confusing you.

we do not have any acl's whatsoever defined.

it doesn't seem logical to me that the edit all contacts permission should allow deletes.

if you need any more information or if i can be of any help in any way, please let me know.

thanks again dave,
cynthia

davej

  • Ask me questions
  • ****
  • Posts: 404
  • Karma: 21
Re: "delete contact" option appears on "more" drop-down list despite permissions
August 02, 2011, 06:33:55 am
Hi,

I've created issue http://issues.civicrm.org/jira/browse/CRM-8602 . Any thoughts from the core team about the above musings on how to fix?

Regards,

Dave J

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: "delete contact" option appears on "more" drop-down list despite permissions
August 02, 2011, 07:42:23 am

yes most / all of the permissioning code was done before the "delete permission" was added. so basically edit permission meant that the user could do everything

i'm not sure about "delete", but i think u can only "delete" if you have edit permissions and the delete permission.

For now, do u want to look at contextMenu and make a short term fix to it? at some point, we will need to refactor and clean the permissioning system

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

davej

  • Ask me questions
  • ****
  • Posts: 404
  • Karma: 21
Re: "delete contact" option appears on "more" drop-down list despite permissions
August 02, 2011, 10:14:58 am
Hi Lobo,

Quote from: Donald Lobo on August 02, 2011, 07:42:23 am
yes most / all of the permissioning code was done before the "delete permission" was added. so basically edit permission meant that the user could do everything

That's useful to know.

Quote from: Donald Lobo on August 02, 2011, 07:42:23 am
i'm not sure about "delete", but i think u can only "delete" if you have edit permissions and the delete permission.

In my testing, 'access CiviCRM', 'add contacts', 'edit all contacts' and 'view all contacts' are sufficient to allow you to delete contacts - see description in CRM-8602.

Quote from: Donald Lobo on August 02, 2011, 07:42:23 am
For now, do u want to look at contextMenu and make a short term fix to it? at some point, we will need to refactor and clean the permissioning system

I'll try to find time - we're short-staffed this week and then I'm off-grid for ten days!

Thanks,

Dave J

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: "delete contact" option appears on "more" drop-down list despite permissions
August 03, 2011, 03:37:42 am
This issue was fix in this issue: http://issues.civicrm.org/jira/browse/CRM-8491 and the fix will be part of 3.4.5 / 4.0.5 release.

You can get the patch from https://fisheye2.atlassian.com/changelog/CiviCRM?cs=35441

Kurund
Found this reply helpful? Support CiviCRM

ctarascio

  • I post frequently
  • ***
  • Posts: 334
  • Karma: 30
    • American Friends Service Committee
  • CiviCRM version: 4.1.3
  • CMS version: Drupal 6.26
  • MySQL version: 5.5.20
  • PHP version: 5.3.13
Re: "delete contact" option appears on "more" drop-down list despite permissions
August 03, 2011, 05:43:45 am
lobo, dave and kurund,
thank you very much for helping to get this fixed. it is much appreciated.

cynthia

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • "delete contact" option appears on "more" drop-down list despite permissions

This forum was archived on 2017-11-26.