Closed (fixed)
Project:
Webform CiviCRM Integration
Version:
7.x-3.1
Component:
CiviCRM Data Handling
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
23 Aug 2012 at 11:16 UTC
Updated:
18 Sep 2012 at 08:51 UTC
Got a webform set up to allow users to edit organisation contacts they have a permissioned relationship with. Using Civicrm 4.1.3 and 7x3.1, and when a user tries to access the webform they get redirected and told they don't have permission to edit the organisation details. Am I missing something obvious, or is this a bug?
Comments
Comment #1
colemanw commentedI really don't know - this is the first I've heard of such a problem.
In general, this module does not issue any redirects. Is it a civi error? Can you turn on debug mode in CiviCRM, submit the form again and paste the error msg here?
Comment #2
Co-operatives UK commentedIf a user doesn't have permission to edit a record, they get redirected to the front page and a message appears. That's not the issue - the problem is that users have a permission to edit a record, but cannot do so through the civicrm webform. It might not be a problem with this module, but I don't know: does webform civicrm require an additional edit permission above the one granted by a relationship to work?
Comment #3
Co-operatives UK commentedOK. So no error fires - it's a permissions question so not an error. But if as a user you visit your dashboard, edit the details, then go direct the the webform and try to access it, the permissions have persisted and you can edit the contact details. If you try to go direct to it, you don't have permission and you get bumped.
Comment #4
Co-operatives UK commentedWhat permission does the form check against? I've set up a new form using the "Existing contact field" but as admin 1 it cannot find any organisations that it says I have permission to edit. Seems a bit odd.
ETA - I can select a default contact on the admin page, but it doesn't then show when viewing the webform. I'm really lost on this one now.
Comment #5
colemanw commentedBy default it does not check any permissions. On the existing contact field you'd have to check the "enforce permissions" box, in which case it will simply pass that request on to the CiviCRM api ('check_permissions' => TRUE).
Is this a problem with accessing the webform node itself, or just the autocomplete?
I'm not sure what's going on, but it sounds like something a bit weird with how permissions are functioning on your site. You may wish to review your acls and check for any caching that may be interfering.
Comment #6
Co-operatives UK commentedAfraid you might say that.
Got two sites using two versions - a live and a dev version. Live uses 7.26 and gets the bounce message about not being able to edit a record the user should have permission to edit. Dev is trying 3.1 and should populate contact from ?cid2=[cid] but just shows contact create. Not using ACLS - just permissioned relationships - so contact A can edit record of contact B. Works in dashboard but not with module.
I'll try playing with module weights, but that's as far as my permissions debugging ability goes so will have to revert to using profiles and the dashboard. Such a shame - great and very useful module. Thanks for developing it and trying to help.
Comment #7
colemanw commentedSo do you have the "enforce permissions" box checked? What happens if you uncheck it?
Comment #8
Co-operatives UK commentedHave tried it both ways with same result - it's a permission thing somewhere on my sites, since 7.26 doesn't have the enforce permission box and still can't get permission unless the user has just visited the dashboard.
Comment #9
colemanw commentedDoes this affect user 1 as well as normal users?
Comment #10
Co-operatives UK commentedSorry - editted to give fuller answer: user 1 can access fine with 7.26 but not through 3.1.
Comment #11
colemanw commentedI'm having trouble picturing what's going on. Ping me on irc or by email if you want me to take a peek at your server.
Comment #12
Co-operatives UK commentedThanks for the offer - I'll give you a shout if I can't sort it: have turned on Devel and found that what I'm actually getting is an error not a permissions problem, at least for the User 1 issue:
"The CiviCRM "contact get" API function returned the error: "contact_type `Organization` is not valid." when called by line 592 of F:\Websites\[online]\Co-operatives UK [v001]\html_prototype_001\sites\all\modules\webform_civicrm\contact_component.inc with the following parameters: "Array ( [is_deleted] => 0 [contact_type] => Organization [check_permissions] => 1 [id] => 1860 [return.display_name] => 1 [version] => 3 ) "
Which obviously sounds a bit crazy, but is getting me a bit closer to finding out what's going on. I have some contact sub-types set up for Organizations - don't suppose that would cause any problems?
Comment #13
Co-operatives UK commentedAnd armed with just that bit of knowledge, I've fixed it: a colleague had helpfully changed the label for Organizations to the UK spelling, meaning that the API couldn't find it.
Now I just need to sort the original permission problem and I'll be sorted!
Comment #14
Co-operatives UK commentedThink it may all have been related to that and a weighting issue but need to do a bit of testing: what I have discovered is that you can't use the Masquerade module to check the access on my site!
Comment #15
colemanw commentedThanks for digging. This is definitely a bug in the CiviCRM api -- you should certainly be allowed to spell Organization the wrong way if you so desire!
Filing an issue and fixing for Civi 4.2.1
See http://issues.civicrm.org/jira/browse/CRM-10736
Comment #16
Co-operatives UK commentedNot sure if it's a civi issue or not - they made the change direct in the database, rather than usiong the replacement patterns within civi. I'll be having a word.
Comment #17
colemanw commentedI can confirm it was a civi issue. But have fixed it for 4.2.1 (see link above)
Changing the label of Organization to something else (while not touching the name) is allowed, but was triggering the api bug.
Comment #18
Co-operatives UK commentedGrand - thanks for fixing.