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) »
  • Using tab hook to customize based on user.
Pages: [1]

Author Topic: Using tab hook to customize based on user.  (Read 2049 times)

dschafer

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 3
    • Backoffice Thinking
  • CiviCRM version: 3.2.3 - 4.4.4
  • CMS version: Drupal 6.x, 7.x, Wordpress
  • MySQL version: 5.1.x - 5.5.x
  • PHP version: 5.2.x - 5.4.x
Using tab hook to customize based on user.
February 03, 2010, 06:41:06 am
I haven't been able to find an example of this appoarch.
We want to control the set of tabs based on the acl role of the current user. The hook parameter $contactID is the contact that is being viewed.

How to I access the information about the current user?

Thanks

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 tab hook to customize based on user.
February 03, 2010, 07:29:59 am

what information do u want to access? you can use the civicrm api / bao functions to get civicrm info. u can use drupal function to access drupal info

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

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Using tab hook to customize based on user.
February 03, 2010, 07:55:08 am
Example of tab hook can be found here: http://svn.civicrm.org/civicrm/branches/v3.1/drupal/civitest.module.sample

Kurund
Found this reply helpful? Support CiviCRM

dschafer

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 3
    • Backoffice Thinking
  • CiviCRM version: 3.2.3 - 4.4.4
  • CMS version: Drupal 6.x, 7.x, Wordpress
  • MySQL version: 5.1.x - 5.5.x
  • PHP version: 5.2.x - 5.4.x
Re: Using tab hook to customize based on user.
February 03, 2010, 08:00:15 am
For the current user, I need to know their Civi acl group.

So I expect I need to find the contactID for the current user and then get their groups (using the civi api).

I didn't see anything in the Civi developer or api documentation (http://wiki.civicrm.org/confluence/display/CRMDOC/Develop) that described how to access the current user.

Is there other documentation I should reference?

I have the tab hook setup, its accessing the user info while in the hook that is not clear.

Thanks

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 tab hook to customize based on user.
February 03, 2010, 08:28:33 am

our developer documentation with regard to the internals is pretty limited / non-existent. a few answers to get you going:

1.to access current user, use:

Code: [Select]
$session =& CRM_Core_Session::singleton( );
$userID = $session->get( 'userID' );

2. to get various ACL related info, check the classes in: CRM/ACL/*. specifically: CRM/ACL/API.php and CRM/ACL/BAO/ACL.php should give most of what u need

3. Note that implementing ACL checks in the tabs hook does not really prevent a knowledgeble user from going to the relevant portions of the contact record directly

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

dschafer

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 3
    • Backoffice Thinking
  • CiviCRM version: 3.2.3 - 4.4.4
  • CMS version: Drupal 6.x, 7.x, Wordpress
  • MySQL version: 5.1.x - 5.5.x
  • PHP version: 5.2.x - 5.4.x
Re: Using tab hook to customize based on user.
February 03, 2010, 09:41:41 am
Thanks!

This looks like it will give me what I need.

This solution is specifically designed to keep a group of users who only have access to view contact data from viewing information that is not relevant to their role.

I believe once we suppress the tabs there is essentially no way for them to know it exists.  They won't have any access to the system until this control is in place.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Using tab hook to customize based on user.

This forum was archived on 2017-11-26.