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) »
  • civicrm permission hook
Pages: [1]

Author Topic: civicrm permission hook  (Read 1205 times)

CiviDev

  • I’m new here
  • *
  • Posts: 16
  • Karma: 1
  • CiviCRM version: v3.2, v3.3, v3.4 and v4.0
  • CMS version: Drupal 6 and 7, Joomla 1.6
  • MySQL version: 5.1
  • PHP version: 5.3
civicrm permission hook
October 20, 2011, 01:03:17 am
Is there any civicrm hook similar with drupal's hook_perm? 

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: civicrm permission hook
October 20, 2011, 06:58:00 am
I do not know wat the drupal's hook_perm does but there are these permission related CiviCRM hooks: http://wiki.civicrm.org/confluence/display/CRMDOC40/CiviCRM+hook+specification#CiviCRMhookspecification-Permissionrelatedhooks
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: civicrm permission hook
October 20, 2011, 02:02:45 pm
Drupal's hook_perm is used to declare the existence of a permission; it has the affect of putting new options in Drupal's user-administration UIs. It's not responsible for using/enforcing the permissions.

If your goal is to write a custom Drupal module that adds new features which need new permissions, then it's easiest to use just Drupal's hook_perm in your own module. If you can't package as a Drupal module (e.g. because your customization needs to work on another CMS), then we'd need to add a new hook/API for this.

If your goal is to work on core code and you're trying trace how permissions are declared in CiviCRM, there are two places to look: 1) CRM/Core/Permissions.php includes some baseline permissions and 2) each CiviCRM component (CiviMail, CiviEvent, etc) defines permissions in its Info.php file (e.g. CRM/Mailing/Info.php, CRM/Event/Info.php).

CiviDev

  • I’m new here
  • *
  • Posts: 16
  • Karma: 1
  • CiviCRM version: v3.2, v3.3, v3.4 and v4.0
  • CMS version: Drupal 6 and 7, Joomla 1.6
  • MySQL version: 5.1
  • PHP version: 5.3
Re: civicrm permission hook
October 20, 2011, 06:30:58 pm
My goal is to declare new permission and use it for civicrm customization purpose.  Currently, i edited permission.php to do this.  I know this is not a good practice but i cant find a better way to do this.

I agree that permission related hooks are very useful but they're limited to particular types of data (grouping of contact, event, profile etc).
If we can add a new hook to declare permission, then it will be more flexible in many aspects to manage permission in the long run. 

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: civicrm permission hook
October 20, 2011, 07:18:18 pm
whats the specific reason you cannot use either:

drupals hook_perm

or joomla's mechanism to extend permissions?

I dont think civi should duplicate hooks that are already present in the CMS

As we figure out extensions and how much to wrap in them, this might come up, but for now, i'm not for adding a new permission hook

and yes, hacking Permission.php is even worse :)

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

CiviDev

  • I’m new here
  • *
  • Posts: 16
  • Karma: 1
  • CiviCRM version: v3.2, v3.3, v3.4 and v4.0
  • CMS version: Drupal 6 and 7, Joomla 1.6
  • MySQL version: 5.1
  • PHP version: 5.3
Re: civicrm permission hook
October 23, 2011, 06:14:23 pm
actually im working on civicrm report customization.  I need to set different access control of reports for 3 teams.  Since i cant find any ACL for reports yet but i can actually set a report permission while creating or updating the reports.  My solution for this is to declare a permission and grant specific permission for each team to access diff reports.  Thats the reason why im asking if there is a civicrm hook similar with drupal's hook_perm.

or is there any other solution to fix this issue?  would appreciate any help here.

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

This forum was archived on 2017-11-26.