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) »
  • Restrict Access to Certain Activities
Pages: [1]

Author Topic: Restrict Access to Certain Activities  (Read 1199 times)

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Restrict Access to Certain Activities
March 11, 2009, 06:47:55 am
I am working on an upgrading a customized CiviCRM 2.0.4 (Drupal) to 2.2. One customization made was to restrict view/edit access to certain Activity types to users lacking a certain Drupal permission.

Am I correct that there is no way to do this in CiviCRM, aside from editing the core code?

Thanks.
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

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: Restrict Access to Certain Activities
March 11, 2009, 08:32:08 am

yes, you are correct :)

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

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Restrict Access to Certain Activities
March 11, 2009, 08:36:36 am
Thanks.
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Restrict Access to Certain Activities
February 07, 2012, 10:31:08 am
Hershel - is this still the approach you are / would be using? Is there enough code involved to ask if you could share some, realising we would need to make it specific to our use case.
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Restrict Access to Certain Activities
February 07, 2012, 10:38:26 am
I will admit that I don't even recall what site that was for, back in 2009. But as luck would have it, I did the same for a D7 site this year. :)

I put

Code: [Select]
/// customized by Hershel Robinson
// Hide certain activities for all except admins and staff
  global $user;
  if (!in_array('staff',$user->roles) && !in_array('administrator',$user->roles)) {
    unset($otherTypes[35]);
    unset($otherTypes[36]);
    unset($otherTypes[37]);
    unset($otherTypes[38]);
    unset($otherTypes[39]);
    unset($otherTypes[40]);
    unset($otherTypes[41]);
  }
/// END customized by Hershel Robinson

in line 72 of CRM/Activity/Form/ActivityLinks.php

and

Code: [Select]
/// customized by Hershel Robinson
// Hide certain activities for all except admins and staff
  global $user;
  $skip = 0;
  if (!in_array('staff',$user->roles) && !in_array('administrator',$user->roles)) {
    if (in_array($dao->activity_type_id,array(35,36,37,38,39,40,41))) {
      $skip = 1;
    }
  }
  if (!$skip) {
/// END customized by Hershel Robinson

in line 799 and then

Code: [Select]
/// customized by Hershel Robinson
  }
/// END customized by Hershel Robinson

in line 845 of CRM/Activity/BAO/Activity.php

Your line numbers may differ by a few, but that's the basic idea. Not the prettiest solution, but since this list only does need to appear in these two places, I was satisfied to do it this way.

Would be better to store the array in a function or a variable of course.
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Restrict Access to Certain Activities
February 07, 2012, 10:51:55 am
Awesome response - thx. If we cook up anything different we will post back.
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

TwoMice

  • I post frequently
  • ***
  • Posts: 214
  • Karma: 16
    • Emphanos
  • CiviCRM version: Always current stable version
  • CMS version: Drupal 7
Re: Restrict Access to Certain Activities
February 07, 2012, 11:22:01 am
We're right now discussing solutions for a client who wants something similar, and I'm wondering if there may be some friendly overlap.

This client wants permissioning per Activity, rather than per Activity Type.  We're thinking of ways we could limit access to specific activities based on Group membership, and will probably post those here soon for feedback.

I'm leaning toward extending ACLs to Activities.  As Lobo points out (here: http://forum.civicrm.org/index.php?topic=10347.0), there are some significant challenges when it comes to implementing ACLs for specific Activities.  But I think it would be easier to implement them for Activity Types.  That doesn't solve our client's problem entirely, but there may be some helpful overlap.

- Allen
Please consider contributing to help improve CiviCRM with the Make it Happen! initiative.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Restrict Access to Certain Activities

This forum was archived on 2017-11-26.