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 (Moderator: Donald Lobo) »
  • Integrating permission for custom module
Pages: [1]

Author Topic: Integrating permission for custom module  (Read 1073 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
Integrating permission for custom module
April 08, 2010, 01:41:15 pm
Hi,
We've created a custom module. The module integration appears to be fine. The module is recognized by Civi, the pages etc work.

We added specific permissions for access to the module and specific operations within the module. The permission choices appear correctly in drupal and can be set successfully.

However we do not see the permissions appearing in the ACL.

We are retrieving the ACL as follows:
$session =& CRM_Core_Session::singleton( );
$userID = $session->get( 'userID' );
   
require_once('sites/all/modules/civicrm/CRM/ACL/BAO/ACL.php') ;
$acl_list = CRM_ACL_BAO_ACL::getAllByContact($userID) ;

I would appreciate some direction to what we might have missed.

Thanks,
     Dave

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: Integrating permission for custom module
April 08, 2010, 09:14:37 pm

not sure i understand

civicrm acl's are not related to drupal permissions at all (they are at a very high level), so not sure what you are expecting and why

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: Integrating permission for custom module
April 09, 2010, 07:01:20 am
Hi Lobo,
Sorry its a little hard to explain.

Please take a look at the attachment where I've tried to explain. 
From looking at the data, there does appear to be a connection between the permissions page and the data returned by
CRM_ACL_BAO_ACL::getAllByContact(userID)

Thanks,
Dave

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: Integrating permission for custom module
April 09, 2010, 09:22:57 pm

acl's appear on only a limited set of objects (contacts) and not on all drupal permissions. The ACL code just manages contacts, events, custom groups, profiles (for now)

what exactly are you trying to do. might be able to solve it without ACLs

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: Integrating permission for custom module
April 13, 2010, 11:08:44 am
Hi lobo

Are custom module exposes permission in the same manner as standard modules.

in info.php we have the following:
    public function getPermissions()
    {
        return array( 'access ARModule',
                      'add payment',   
                      'view payment' );
    }

The permissions appear on the drupal permissions page as we expected.

However we do know how to retrieve what the settings are for the current user.
It appeared that this could be done through CRM_ACL_BAO_ACL::getAllByContact($userID).

This returns an arrary of permissions (many are beyond contacts and custom data)

For example CiviContribute contains the following
    public function getPermissions()
    {
        return array( 'access CiviContribute',
                      'edit contributions',
                      'make online contributions',
                      'delete in CiviContribute' );
    }
These are expose on the drupal permissions page and then appear in the output of CRM_ACL_BAO_ACL::getAllByContact($userID).
    [9] => Array
        (
            [id] => 9
            [name] => Core ACL
            [deny] => 0
            [entity_table] => civicrm_acl_role
            [entity_id] => 1
            [operation] => All
            [object_table] => access CiviContribute
            [object_id] =>
            [acl_table] =>
            [acl_id] =>
            [is_active] => 1
        )
    [20] => Array
        (
            [id] => 20
            [name] => Core ACL
            [deny] => 0
            [entity_table] => civicrm_acl_role
            [entity_id] => 1
            [operation] => All
            [object_table] => delete in CiviContribute
            [object_id] =>
            [acl_table] =>
            [acl_id] =>
            [is_active] => 1
        )

    [33] => Array
        (
            [id] => 33
            [name] => Core ACL
            [deny] => 0
            [entity_table] => civicrm_acl_role
            [entity_id] => 1
            [operation] => All
            [object_table] => edit contributions
            [object_id] =>
            [acl_table] =>
            [acl_id] =>
            [is_active] => 1
        )
    [42] => Array
        (
            [id] => 42
            [name] => Core ACL
            [deny] => 0
            [entity_table] => civicrm_acl_role
            [entity_id] => 1
            [operation] => All
            [object_table] => make online contributions
            [object_id] =>
            [acl_table] =>
            [acl_id] =>
            [is_active] => 1
        )

Also, the permissions appear in the when we go to the customize the Navigation menu page.

Our problem is determining the permission settings for our custom module so we can determine what operations are valid for the user.

Thanks
« Last Edit: April 13, 2010, 02:46:07 pm by dschafer »

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: Integrating permission for custom module
April 13, 2010, 10:16:24 pm

might be easier to have a conversation in IRC (http://webchat.freenode.net/?channels=#civicrm) A bit more real time and easier to make progress :)

any specific reason you cant use the drupal check permission function? (user_access). I'm not sure if you are writing a civicrm component or a drupal module?

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) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Integrating permission for custom module

This forum was archived on 2017-11-26.