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 Profiles (Moderator: Dave Greenberg) »
  • Using Autocomplete for Current Employer Upon Registration - Not Logged In
Pages: [1]

Author Topic: Using Autocomplete for Current Employer Upon Registration - Not Logged In  (Read 2317 times)

CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
Using Autocomplete for Current Employer Upon Registration - Not Logged In
July 29, 2010, 12:19:18 pm
I found some good instructions about putting the Current Employer field to autocomplete in a profile.  However it specifically warns against this unless the person is logged in with access to CiviCRM.

http://en.flossmanuals.net/CiviCRM/DevelopAPI
Code: [Select]
{if $session->get('userID') > 0}

<script type="text/javascript" src="{$config->resourceBase}js/rest.js"></script>{literal}
<script>
jQuery(document).ready(function($){
  $('#current_employer').crmAutocomplete({params:{contact_type:'Organization'}});
});
</script>
{/literal}

{/if}

The problem is, upon Drupal registration, we want to collect Current Employer information, because new users will, more than likely, belong to an organization that is currently already in our Database.  Without an autocomplete field for Current Employer, we run the frequent risk of creation of duplicate Organizational contacts, if someone spells the name of their company just slightly differently than the next person.

Any way to safely use Autocomplete for Current Employer on registration without exposing our entire database to the universe?  PS. We are ok with everyone having access to all our Organization names, as all Orgs are all public anyhow.

Try CiviTeacher: the online video tutorial CiviCRM learning library.

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Using Autocomplete for Current Employer Upon Registration - Not Logged In
July 29, 2010, 03:40:14 pm
Hey Stuart - I think the code snippet above will only expose contacts of type 'Organization' (I think that's what the contact_type param does). HOWEVER, what about the case where the organization is NOT already in the DB? Haven't played with crmAutocomplete - but I'd be surprised if you get the same behavior as we have in the back-office contact edit form - where a new organization is created if the typed in value doesn't match and existing organization name.
Protect your investment in CiviCRM by  becoming a Member!

CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
Re: Using Autocomplete for Current Employer Upon Registration - Not Logged In
July 29, 2010, 05:47:21 pm
Well I did a lot of testing with this.  Here's what I found out:

1. If someone is logged in, the autocomplete field works in two ways:
   a. search for matching contact
   b. if no matching contact, create new contact

2. If someone is NOT logged in, the code above doesn't work.
   a. it does convert the field to an autocomplete field
   b. the autocomplete field doesn't have any search capabilities

Any idea why 2.b. is true?  Is this some kind of security feature?  Am I missing something?

In my situation, although admittedly not ALL situations, all our organizations are public and we WANT people to find their information.  Individuals are another matter, of course, and should be private.  Since we are able to further filter the result sets for autocomplete fields to Organizations who belong in group X, then any risk of exposing Organization data publicly (for an administrator who knows what they are doing) approaches zero.

Autocomplete only works for logged in people? If so, why?  Is there a way to override this?   Seems to hinder the usefulness of this autocomplete feature.  Thanks........

« Last Edit: July 29, 2010, 05:51:40 pm by Stoob »
Try CiviTeacher: the online video tutorial CiviCRM learning library.

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: Using Autocomplete for Current Employer Upon Registration - Not Logged In
July 29, 2010, 06:57:58 pm

this is primarily due to security reasons and to avoid exposing data to anon users. IMO, we need to rethink and restructure permissioning for ajax calls in a significant manner (and make them a lot more fine grained). I dont think this is a short term project

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

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Using Autocomplete for Current Employer Upon Registration - Not Logged In
July 29, 2010, 08:04:51 pm
hi,

the autocomplete uses the rest interface, that isn't available to anon users.

you might want to write a custom module that only exposes the functions you want.

-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
Re: Using Autocomplete for Current Employer Upon Registration - Not Logged In
July 29, 2010, 09:28:01 pm
Thank you both for clarifying.

This makes sense, and I can see the logic behind locking down AJAX for anon users.  Unfortunately as Lobo suggests the current plan does lack granularity and flexibility.  In some circumstances AJAX could be very useful for anon users.

I will propose a custom module, as always though, it is up to the client to approve this within a strict budget.  :(
Try CiviTeacher: the online video tutorial CiviCRM learning library.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Using Autocomplete for Current Employer Upon Registration - Not Logged In
August 09, 2010, 07:20:41 am
Any progress on that ?

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Profiles (Moderator: Dave Greenberg) »
  • Using Autocomplete for Current Employer Upon Registration - Not Logged In

This forum was archived on 2017-11-26.