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

colemanw’s picture

I 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?

Co-operatives UK’s picture

If 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?

Co-operatives UK’s picture

OK. 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.

Co-operatives UK’s picture

What 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.

colemanw’s picture

By 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.

Co-operatives UK’s picture

Afraid 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.

colemanw’s picture

So do you have the "enforce permissions" box checked? What happens if you uncheck it?

Co-operatives UK’s picture

Have 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.

colemanw’s picture

Does this affect user 1 as well as normal users?

Co-operatives UK’s picture

Sorry - editted to give fuller answer: user 1 can access fine with 7.26 but not through 3.1.

colemanw’s picture

I'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.

Co-operatives UK’s picture

Thanks 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?

Co-operatives UK’s picture

And 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!

Co-operatives UK’s picture

Think 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!

colemanw’s picture

Title: Users cannot use webforms » Error with renamed contact types
Status: Active » Fixed

Thanks 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

Co-operatives UK’s picture

Not 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.

colemanw’s picture

I 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.

Co-operatives UK’s picture

Grand - thanks for fixing.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.