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 »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • temporary workaround for self-service organization updates
Pages: [1]

Author Topic: temporary workaround for self-service organization updates  (Read 1040 times)

thebenedict

  • Guest
temporary workaround for self-service organization updates
June 26, 2008, 07:06:27 am
After two months away I finally have time to work on this again :)

It's great to see that the employee-of relationship can be used to update organization info in 2.1 (http://civicrm.org/node/352), but the release and my ability to upgrade to Drupal 6 are at least a few months off. I have an idea for a temporary solution that will prevent having to use the organization-as-user hack and make it easier to eventually upgrade. The disadvantage is that all registered users need to be given permission to update all contacts. For most sites I realize this is a problem, but for our small, low traffic site it is not.

Once the permission is set, the edit url .../index.php?q=civicrm/profile/edit&reset=1&id=###&gid=n

allows the kind of editing I'm looking for, so the idea is to make a dropdown menu where the label is organization name and the value is contact id. (similar to http://forum.civicrm.org/index.php/topic,2951.0.htm). Then use the selected contact id to create an edit url for that organization, and send the user there when they press submit on a page. This bit I don't know how to do. Could someone suggest a reference? I'm looking for the code to use and where to put it.

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: temporary workaround for self-service organization updates
June 26, 2008, 11:02:58 am
You should be able to do the "redirect on select+button click" with a fairly simple Javascript function added to that page.

You can use the <button /> element rather than <input type="submit" .../> - and add an onclick attribute to your button which calls your  jscript function. The function retrieves the currently selected option value (i.e. the selected contact ID) and constructs the URL, then uses window.location to redirect to that URL.

There's a lot of good javascript example sites on the web which should provide you with examples of the pieces of the above.
Protect your investment in CiviCRM by  becoming a Member!

thebenedict

  • Guest
Re: temporary workaround for self-service organization updates
June 26, 2008, 03:13:24 pm
Yes, thanks, that's just what I had in mind. I see now that it's really a javascript question. Anyway, this seems to work:

Code: [Select]
<SCRIPT type="text/javascript">
function editProfile(id) {
  for (var i = 0; i < id.options.length; i++) {
      if (id.options[i].selected) {
        var url = ".../?q=civicrm/profile/edit&reset=1&id="+id.options[i].value+"&gid=n";
        window.location=url;
    }
  }
}
</SCRIPT>

<FORM>
<INPUT TYPE="button" VALUE="Edit" onClick="editProfile(orgId)">
</FORM>

Where orgId is the name of the select box. Thanks again!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • temporary workaround for self-service organization updates

This forum was archived on 2017-11-26.