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) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • is access civicrm permission necessary for hook_civicrm_contactListQuery()?
Pages: [1]

Author Topic: is access civicrm permission necessary for hook_civicrm_contactListQuery()?  (Read 1028 times)

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
is access civicrm permission necessary for hook_civicrm_contactListQuery()?
May 24, 2012, 03:42:45 am
Hey there,

We are looking at using hook_civicrm_contactListQuery() to populate an autocomplete which should be available to anonymous users.  However, it looks like you need access civicrm permissions to use this hook, which means that it wouldn't work for this use case unless we give anonymous users access to civicrm, which doesn't seem like a sensible thing to do.

If I'm correct that you do need the access civicrm permission for hook_civicrm_contactListQuery() to work, what do you think the solution is? Remove this requirement? Or not use the CiviCRM autocomplete hook.  Happy to dig in to the code and have a look but if someone has the bigger picture here, that would be useful.

Perhaps the most sensible solution is to just implement a seperate ajax call that doesn't use the hook.  Not sure at this point how much extra coding that would involve.

Thanks,
Michael
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: is access civicrm permission necessary for hook_civicrm_contactListQuery()?
May 25, 2012, 03:58:21 am
Hi, don't know about the contactListQuery path, but what can be done the api way

1) give anonymous the access ajax api permission (but none of the entity/action will work, just the right to access it and get an is_error)
2) create a new Contact/special.php that implements the civicrm_api ('Contact", "special")
3) create an hook to open this entity+action to anonymous
http://wiki.civicrm.org/confluence/display/CRMDOC40/CiviCRM+hook+specification#CiviCRMhookspecification-hookcivicrmalterAPIPermissions


on the client side, I have published examples on how to use the ajax api for an autocomplete (or check the js/rest.js)

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

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: is access civicrm permission necessary for hook_civicrm_contactListQuery()?
May 28, 2012, 08:42:57 am
Hey Xavier,

Awesome answer - thanks a lot :)
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: is access civicrm permission necessary for hook_civicrm_contactListQuery()?
May 28, 2012, 09:06:40 am
OK, so then I was wondering how the access ajax api permission interacts with other permissions?

I found the answer here: http://wiki.civicrm.org/confluence/display/CRMDOC41/API+Security
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • is access civicrm permission necessary for hook_civicrm_contactListQuery()?

This forum was archived on 2017-11-26.