When using this new version of the module in combination with Masquerade, the webform is filled with the values of the user that originally logged in and not with the values of the user you are masquerading. The values of the wrong contact_id are selected (the right masqueraded user is logged in!). So when you masquerade someone you cannot add or change his civicrm contact values, because your own values are shown in the webform.

Comments

colemanw’s picture

Interesting. I've never used that module before, but I suspect this may be a core civicrm issue as well, since this module just grabs the cid from CiviCRM's session variable.
Have you experimented with core profiles and such to see if they are also misbehaving?

Quick fix: in the file webform_civicrm_utils.inc on line 1431, change this:

  if (!$id) {
    return empty($_SESSION['CiviCRM']['userID']) ? NULL : $_SESSION['CiviCRM']['userID'];
  }

to this:

  if (!$id) {
    global $user;
    $id = $user->uid;
  }

That should fix it for you (temporarily, but you don't want to have to hack this module every time you upgrade). Getting CID from the session instead of from the API gives a performance boost though, so it would be interesting to find out why this variable isn't getting updated by Civi core and what it would take to do so. Wanna ask about it in the forums or IRC and post back here?

BasH’s picture

Thanks a lot!! It saved me a lot of searching. I was trying to change something like this but in the wrong include file (-:. And this works perfectly.
I am still constantly changing and testing our site, but untill now this was our only problem while masquerading, so no problems with the core profile(s) yet (but I'll keep your warning in mind).

I don't know if this fix really affects the performance, but if this also can be or has to be changed somewhere else in the Civicrm code, maybe it is worth asking around in the forums (do you have a specific forum in mind?).

But on the other hand I thought this wasn't a problem in the previous version of Webform CiviCRM Integration, and checking the utils include file showed me that the global user was used there. So maybe this should be a permanent fix in this or a next version, because the value in the session might be used (I don't know..) for switching back to that user, and in that case it cannot be changed and used while masquerading!

By the way, I am glad I didn't have to revert to the previous version because you have to rearrange all the fields of all (civicrm) webforms when you upgrade to this new 2.2 version. That is worth mentioning (in for instance the install/upgrade notes) to users that still have to upgrade, I think!
For me this was a lot of work when I installed version 2.2., you have to check and change the position and length of every field again (!!), however, it is a real improvement especially because of being able to select and update the correct home/work phonenumber/emailaddress etc. of a contact. Thanks for your work!

colemanw’s picture

I have not committed the code in #1, so you will need to manually port it to 2.3 when upgrading.
Instead I filed an issue with the core team to see if we can address it there.
http://issues.civicrm.org/jira/browse/CRM-9255

colemanw’s picture

Version: 6.x-2.2 » 7.x-2.x-dev
Status: Active » Fixed

I am going ahead and committing this fix. The bug in Civi doesn't seem like it will be resolved anytime soon, so this makes sense for now.
Perhaps in the future there will be a standard way in Civi for getting the logged-in user's cid, and we can switch to that when it becomes available.

Status: Fixed » Closed (fixed)

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