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) »
  • Allowing user to edit Summary record
Pages: [1]

Author Topic: Allowing user to edit Summary record  (Read 1336 times)

dschafer

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 3
    • Backoffice Thinking
  • CiviCRM version: 3.2.3 - 4.4.4
  • CMS version: Drupal 6.x, 7.x, Wordpress
  • MySQL version: 5.1.x - 5.5.x
  • PHP version: 5.2.x - 5.4.x
Allowing user to edit Summary record
April 28, 2010, 02:01:11 pm
Because we use several custom data group with mutliple records we need to give individual user access to their account record.

Basically everything works pretty well except the user cannot edit the data on the summary tab. Clicking on the edit button results in "acccess denied".

The user has the following permissions in drupal.
Access CiviCRM
access Contact Dashboard
access all custom data
profile listings and forms

I've tried creating an ACL to give them access to the same group that they belong to but that hasn't work.

What am I missing? I didn't see any relevant reference in the forum or the wiki.

Thanks,
    Dave

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: Allowing user to edit Summary record
April 28, 2010, 05:08:53 pm

what edit screen r u referring to?

is it edit contact?

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

dschafer

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 3
    • Backoffice Thinking
  • CiviCRM version: 3.2.3 - 4.4.4
  • CMS version: Drupal 6.x, 7.x, Wordpress
  • MySQL version: 5.1.x - 5.5.x
  • PHP version: 5.2.x - 5.4.x
Re: Allowing user to edit Summary record
April 28, 2010, 07:25:46 pm
Hi,
It the page accessed via the "edit" button on the contact summary tab.
/civicrm/contact/view?reset=1&cid=14209

the url of the edit page is
/civicrm/contact/add?reset=1&action=update&cid=14209

If we enable the "edit all contacts" permission it will work - but that is too much access. We only want the user to edit their own record.

Thanks

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: Allowing user to edit Summary record
April 28, 2010, 09:58:50 pm

hey dschafer:

can u try applying this patch:

Code: [Select]
svn diff CRM/Contact/Form/Contact.php
Index: CRM/Contact/Form/Contact.php
===================================================================
--- CRM/Contact/Form/Contact.php        (revision 27173)
+++ CRM/Contact/Form/Contact.php        (working copy)
@@ -178,7 +178,9 @@
                 
                 // check for permissions
                 require_once 'CRM/Contact/BAO/Contact/Permission.php';
-                if ( ! CRM_Contact_BAO_Contact_Permission::allow( $this->_contactId, CRM_Core_Permission::EDIT ) ) {
+                $session =& CRM_Core_Session::singleton( );
+                if ( $session->get( 'userID' ) != $this->_contactId ||
+                     ! CRM_Contact_BAO_Contact_Permission::allow( $this->_contactId, CRM_Core_Permission::EDIT ) ) {
                     CRM_Core_Error::statusBounce( ts('You do not have the necessary permission to edit this contact.') );
                 }

and see if it works

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

dschafer

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 3
    • Backoffice Thinking
  • CiviCRM version: 3.2.3 - 4.4.4
  • CMS version: Drupal 6.x, 7.x, Wordpress
  • MySQL version: 5.1.x - 5.5.x
  • PHP version: 5.2.x - 5.4.x
Re: Allowing user to edit Summary record
April 30, 2010, 08:07:08 am
Hi lobo,
Well the patch looked like it would do exactly what I thought was needed.
However it does not correct the problem.

The issues appears to be outside contact.php.

The message we get is
"Access denied
You are not authorized to access this page."

This is not there error that would be emitted by contact.php
"You do not have the necessary permission to edit this contact."

It appears that this messages originates in
drupal/includes/common.inc
function drupal_access_denied()

-- Dave

dschafer

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 3
    • Backoffice Thinking
  • CiviCRM version: 3.2.3 - 4.4.4
  • CMS version: Drupal 6.x, 7.x, Wordpress
  • MySQL version: 5.1.x - 5.5.x
  • PHP version: 5.2.x - 5.4.x
Re: Allowing user to edit Summary record
April 30, 2010, 09:03:53 am
Did some additional digging.

Some background.
drupal_access_denied() appears to be encapsulated in utils/system/durpal/drupal.php  permissionedDenied()

It looks like in invoke.php there is some type of check to see it the user has access to the particular menu associated with the page.

If the user does not have access the permissionDenied() function is invoked.

Does this imply that the user needs access to the Contact menu as well?

I checked and the user can see the contacts menu.  The code in invoke.php is
v3.0.3  line 128
            // check that we are permissioned to access this page
            if ( ! CRM_Core_Permission::checkMenuItem( $item ) ) {
                CRM_Utils_System::permissionDenied( );
                return;
            }

Did some additional digging.

There appears to be a dependent relationship between the menu permissions and the level of access.

It appears that CRM_Core_Permission::checkMenuItem( $item ) is checking whether the user has the permission to access the menu option associated with the page.

Here is the $item object that is interrogated to determine the permissions. It seems it is being treated the same as "New Contact"
Code: [Select]
Array
(
    [id] => 93
    [domain_id] => 1
    [path] => civicrm/contact/add
    [title] => New Contact
    [access_callback] => Array
        (
            [0] => CRM_Core_Permission
            [1] => checkMenu
        )

    [access_arguments] => Array
        (
            [0] => Array
                (
                    [0] => access CiviCRM
                    [1] => add contacts
                )

            [1] => and
        )

    [page_callback] => CRM_Contact_Form_Contact
    [page_arguments] => addSequence=1
    [breadcrumb] => Array
        (
            [0] => Array
                (
                    [title] => CiviCRM
                    [url] => /civicrm?reset=1
                )

        )

    [is_ssl] => 0
    [weight] => 1
    [type] => 1
    [page_type] => 0
)
The way we have things setup only certain roles have the "edit all contacts" permission. Users that do not have this do not even see the Contacts menu, the idea is to lock them into their own record.  Our individual user has only "Access CiviCRM" so I believe that access is denied because they do not also have "add contacts"

It would be ok to enable the "edit all contacts" permission for these uses if we could suppress access to the Contacts menu.

Although as I read it, in order to access the contacts page for add/edit page you must have permission to the menu item associated with the page.

Hope this is helpful.

-- Dave
« Last Edit: April 30, 2010, 01:42:24 pm by dschafer »

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: Allowing user to edit Summary record
May 01, 2010, 06:56:27 am

1. can u also give the person "add contacts" permission (i think we fixed this in 3.1)

2. if the above does not fix, please jump on the IRC channel (on monday, not around this weekend). might be easier to sort it out real time

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

dschafer

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 3
    • Backoffice Thinking
  • CiviCRM version: 3.2.3 - 4.4.4
  • CMS version: Drupal 6.x, 7.x, Wordpress
  • MySQL version: 5.1.x - 5.5.x
  • PHP version: 5.2.x - 5.4.x
Resolved: Allowing user to edit Summary record
May 12, 2010, 09:15:37 am
Hi,
Just following up.
Adding 'add contact' permssion resovled the issue for the contacts accessing their own record.

We added a form hook to essential only allow access to their own contact record and any contact records that were permissioned via relationship.

Thanks for your help.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Allowing user to edit Summary record

This forum was archived on 2017-11-26.