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 Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • How to control what shows in the search pull down menu.
Pages: [1]

Author Topic: How to control what shows in the search pull down menu.  (Read 714 times)

chaseweb

  • I post occasionally
  • **
  • Posts: 48
  • Karma: 0
  • CiviCRM version: 4.3.1
  • CMS version: Joomla 2.5.11
  • MySQL version: 5.1.65-cll
  • PHP version: 5.3.17
How to control what shows in the search pull down menu.
November 06, 2012, 09:36:48 am
Hi,

I am trying to setup an authorization rule that does the following:

A user that is Authenticated - when they view contact records after a basic search - when they select contact records - I only want them to be able to select email selected contacts, but they have options to add/remove to groups, record activity, etc.

So my question is there a way to remove/constrain what options show in the pulldown after a basic search using the ACL API.

thanks
Corey

sogen

  • I’m new here
  • *
  • Posts: 10
  • Karma: 0
  • CiviCRM version: latest
  • CMS version: Drupal 7.16
  • MySQL version: latest
  • PHP version: 5
Re: How to control what shows in the search pull down menu.
November 06, 2012, 09:42:01 am
Seconded!

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: How to control what shows in the search pull down menu.
November 06, 2012, 10:38:34 am
you can use the hook_civicrm_searchTasks

http://wiki.civicrm.org/confluence/display/CRMDOC42/Hook+Reference#HookReference-hook_civicrm_searchTasks

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

sogen

  • I’m new here
  • *
  • Posts: 10
  • Karma: 0
  • CiviCRM version: latest
  • CMS version: Drupal 7.16
  • MySQL version: latest
  • PHP version: 5
Re: How to control what shows in the search pull down menu.
November 06, 2012, 12:59:29 pm
will this modification get deleted when one updates their civiCRM installation?


UPDATE: Yes, the answer is yes, this needs to be in its own module.

thx sr. Wolf!
« Last Edit: November 06, 2012, 01:03:54 pm by sogen »

chaseweb

  • I post occasionally
  • **
  • Posts: 48
  • Karma: 0
  • CiviCRM version: 4.3.1
  • CMS version: Joomla 2.5.11
  • MySQL version: 5.1.65-cll
  • PHP version: 5.3.17
Re: How to control what shows in the search pull down menu.
November 06, 2012, 04:57:31 pm
Thanks alot Lobo, I will take a look..

chaseweb

  • I post occasionally
  • **
  • Posts: 48
  • Karma: 0
  • CiviCRM version: 4.3.1
  • CMS version: Joomla 2.5.11
  • MySQL version: 5.1.65-cll
  • PHP version: 5.3.17
Re: How to control what shows in the search pull down menu.
November 07, 2012, 05:52:22 pm
Ok I am a little confused

I am trying to check if the user has the Authenticated Role - I believe.  I assume that is someone logs into Joomla they will get the Authenticated CiviCRM role.
So in the civitest_perm() - How do I check if user has this role?  And will the user_access function still be used to check on that Role?

If I can get some info on this, I think I will be good to go.

Code: [Select]
function civitest_perm () {
return array(
'access add contacts to group search action'
);
}


function civitest_civicrm_searchTasks($objectType, &$tasks ) {
if ( $objectType == 'Contact' ) {
// remove the action from the contact search results if the user doesn't have the permission
if (! user_access( 'access add contacts to group search action' )) {
unset($tasks[1]);
unset($tasks[2]);
unset($tasks[3]);
unset($tasks[4]);
unset($tasks[7]);
unset($tasks[8]);
unset($tasks[11]);
unset($tasks[13]);
unset($tasks[14]);
unset($tasks[17]);
unset($tasks[19]);
unset($tasks[22]);
}
}
}

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: How to control what shows in the search pull down menu.
November 07, 2012, 08:16:11 pm

note that within Civi to a large extent we dont care what CMS role the user has. We just invoke CMS functions to check if this user has a specific permission. thus is joomla we use:

Code: [Select]
    if (defined('_JEXEC')) {
      $permissionStr = 'civicrm.' . CRM_Utils_String::munge(strtolower($str));
      $permission = JFactory::getUser()->authorise($permissionStr, 'com_civicrm');
      return $permission;
    }

u can potentially use something similar within your module or use:

CRM_Core_Permission::check($permissionString);

which does the right thing for all CMS..

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

chaseweb

  • I post occasionally
  • **
  • Posts: 48
  • Karma: 0
  • CiviCRM version: 4.3.1
  • CMS version: Joomla 2.5.11
  • MySQL version: 5.1.65-cll
  • PHP version: 5.3.17
Re: How to control what shows in the search pull down menu.
November 08, 2012, 04:36:30 am
Hi,

So one more gap I have - determining the permission string.  If you see attached (which is image of the 'Edit ACL' screen in Civi)

So is my permission string the Description (in this case - Member Access View Contacts)

If this is my permission string - then this should work right?

Code: [Select]
if (! CRM_Core_Permission::check( 'Member Access View Contacts' )) {
unset($tasks[1]);
unset($tasks[2]);
unset($tasks[3]);
unset($tasks[4]);
unset($tasks[7]);
unset($tasks[8]);
unset($tasks[11]);
unset($tasks[13]);
unset($tasks[14]);
unset($tasks[17]);
unset($tasks[19]);
unset($tasks[22]);
}

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: How to control what shows in the search pull down menu.
November 08, 2012, 08:56:23 am

seems like we are mixing up joomla permissions vs civicrm acl permissions.

civicrm acl permissions are on a specific set of objects (contacts, custom data, profiles, events). So u have permission to access an object or not

joomla permissions are more generic: you have a permission or not

might want to read up a bit from the civicrm book and the joomla manuals

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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • How to control what shows in the search pull down menu.

This forum was archived on 2017-11-26.