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 Profiles (Moderator: Dave Greenberg) »
  • Restricting access to a profile
Pages: [1]

Author Topic: Restricting access to a profile  (Read 1120 times)

leupi

  • I post frequently
  • ***
  • Posts: 192
  • Karma: 2
Restricting access to a profile
December 03, 2012, 12:05:14 pm
My goal is to create an alumni group for our organization. I am using Drupal 6.26, CiviCRM 4.2.4, Webform 6.x-3.17, User Registration 6.x-1.x-dev, and Webform CiviCRM Integration 6.x-2.6.

I created the webform and that seems to work fine. Users can fill out the form and it creates a CiviCRM contact record for them and it also creates a Drupal account for them if they don't already have one.

I would now like to set this up so that only Alumni can look at the Alumni Directory. I created a profile, called Alumni Directory (with all of the fields that I want in the directory), and checked off 'Standalone Form or Directory' and 'Search Views'. This all works fine, when I point a browser at that URL I have a form that shows any field that I made searchable. I do a search and the results are as expected. My only issue is trying to make that form accessible only to those that are in the CiviCRM group 'Alumni'. I'm not seeing any way to do this. Can someone point me in the right direction?

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: Restricting access to a profile
December 03, 2012, 12:45:01 pm
hi leupi - i think my approach tends to be
- set Alumni to a specific role
- use Drupal Views to create a display that is access controlled to Alumni role
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

leupi

  • I post frequently
  • ***
  • Posts: 192
  • Karma: 2
Re: Restricting access to a profile
December 04, 2012, 09:49:02 am
That does sound like a good way of doing it. Of course, when I tried I got some issues.

I created a View of type 'CiviCRM Contacts'. When I try to add a field I get the following error:

Quote
user warning: Table '[SITE NAME].civicrm_contact' doesn't exist query: SELECT COUNT(*) FROM (SELECT civicrm_contact.first_name AS civicrm_contact_first_name, civicrm_contact.id AS id, civicrm_contact.last_name AS civicrm_contact_last_name FROM civicrm_contact civicrm_contact ) count_alias in C:\apache2\htdocs\drupal\sites\all\modules\views\plugins\views_plugin_pager.inc on line 141.

I looked at the information on this at http://drupal.org/node/1028988 and it looks like I needed to add the output of civicrm/admin/uf in my settings.php file, which I did. After doing this I'm still getting the aforementioned error. Should that be in settings.php or in civicrm.settings.php. I eventually placed it in both files and I'm still getting the error.

The code that I used was:
Code: [Select]
$databases['default']['default']['prefix']= array(
       
  'civicrm_acl'                              => '`civicrm`.',
  'civicrm_acl_cache'                        => '`civicrm`.',
  'civicrm_acl_contact_cache'                => '`civicrm`.',
  ...
);

Should 'default' and 'prefix' be modified? I just pulled it verbatim from the page.

I also saw the following in that page:
Quote
Are you sharing a database between CiviCRM and Drupal? If so then your prefix would be ''. If your CiviCRM DB is called 'civicrm' then the prefix is 'civicrm.'.
I am not sharing the Drupal database. Is there a place in civicrm.settings.php or in settings.php that this has to go?

leupi

  • I post frequently
  • ***
  • Posts: 192
  • Karma: 2
Re: Restricting access to a profile
December 17, 2012, 06:44:08 am
I'm still not able to get any further with this. I do think that using Drupal Views, as suggested is the way to go, but this database error is stopping me dead in my tracks. Any thoughts on what I might be doing wrong and what needs to be done to correct it? I feel that I'm 90% there and need to just get past this one thing and then home free.

Thanks!

leupi

  • I post frequently
  • ***
  • Posts: 192
  • Karma: 2
Re: Restricting access to a profile
December 17, 2012, 07:32:03 am
I tried something a bit different but that does not seem to be working either. I tried to limit access to this profile via ACLs; however, access is not limited, anyone can view the profile.

Here is what I did:
  • Created a profile called 'Alumni directory'
  • Created a contact group called 'Alumni. This group currently has no members
  • Created an ACL Role called Alumni member
  • Created an ACL called 'Access alumni directory. With Role = 'Alumni member', Operation = 'View', Type of data = 'A profile', Profile = 'Alumni directory'
  • Added a Role Assignment - ACL Role = "Alumni member', Assigned to = 'Alumni'
I can see how this would give anyone in the CiviCRM group 'Alumni' the ability to see the profile 'Alumni directory' but I'm not seeing any way of limiting the ability of anyone that is NOT is the group from seeing the profile. Whenever I go to http://SITE-NAME/civicrm/profile/profile?reset=1&gid=[PROFILE-ID] as any user, even anonymous, I can see the profile.

Am I not understanding how this works (I obviously feel that is indeed the case)?

leupi

  • I post frequently
  • ***
  • Posts: 192
  • Karma: 2
Re: Restricting access to a profile
December 17, 2012, 08:35:05 am
I just looked at my Drupal user permission and see this under CiviCRM:

profile create   
profile edit   
profile listings   
profile listings and forms
profile view

Can I assume that 'Profile View' permissions need to be taken away from 'anonymous' and 'authenticated' and then I must create an ACL for EVERY profile that I use for the site? If that is the case, what are the 'profile listings' and 'profile listings and forms' permissions doing that is different from 'profile view'?

Honestly, I would much rather be able to get the Drupal Views working with CiviCRM as that seems to be the most efficient way of doing this. Any thoughts on the database error?

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: Restricting access to a profile
December 17, 2012, 09:21:29 am

does this database and table exist?

 Table '[SITE NAME].civicrm_contact'

based on the error. I would go about debugging that and see why its giving that error? does the same user have permissions on both the databases etc

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

leupi

  • I post frequently
  • ***
  • Posts: 192
  • Karma: 2
Re: Restricting access to a profile
December 18, 2012, 10:34:26 am
drupal.civicrm_contact does not exist but civicrm.civicrm_contact does exist. So it's trying to find it in my Drupal database and not the CiviCRM database. I'm not sure how to modify the settings so it will look in the CiviCRM database for that table. I tried adding the output of civicrm/admin/setting/uf to settings.php and civicrm.settings.php but that didn't do the trick.

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: Restricting access to a profile
December 18, 2012, 10:49:44 am

u'll need to play around with drupal's settings.php and tweak it so views uses the civi db for all civi tables

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 Profiles (Moderator: Dave Greenberg) »
  • Restricting access to a profile

This forum was archived on 2017-11-26.