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 »
  • 5.0 Saloon »
  • Smarter smart groups
Pages: [1]

Author Topic: Smarter smart groups  (Read 1050 times)

capo

  • I post occasionally
  • **
  • Posts: 108
  • Karma: 5
Smarter smart groups
May 10, 2014, 12:36:38 pm
Last Wednesday we had a session of the CiviCRM Madrid work group about ACL's and, in general, permissions. There was a few of different organizations and we all realized that we use to have the same needs, talking about permissions. Users from a state/province must access contacts from it's own state/province, and so on.

During the session, we arrived to this conclusions that are probably shared with a lot of other organizations:
  • CiviCRM is out-of-the-box able to handle almost all the permission environments we may need
  • The configuration can be hard to maintain, specially when working with organizations that have a lot of (normally regional) groups

My question is, may Doctrine Query Language be used to facilitate the creation of "smarter smart groups"? I mean, if the logic of querying is finally moved to the doctrine layer, it won't be hard to make available for the queries parameters about the user logged in (or the corresponding API user running a command).

If we had this information available, we may be able to create smart groups such as: "Contacts from the state/province of the logged user" (I'm using state/province just as an example). This group would show contacts from a different state/province depending on the user logged in. If we could create this kind of smart groups, ACL configurations would be much simpler, I guess.

Would it be possible to access information about the logged user from the doctrine layer? Or am I just maybe wrong?

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Smarter smart groups
May 18, 2014, 03:18:29 am
WHen you have complex access rights like that (staff from region X can see the constituents from that region only) where you have quite a lot of regions, it's probably easier to write an extension handling custom ACL.

Not sure it can be made generic, but might be worthwhile sharing as a starting point. I seem to remember the green AU have something like that. Pete or Eileen, is this something you have to share?
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

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: Smarter smart groups
May 18, 2014, 01:48:36 pm
we have used a number of approaches - eg ACLs running off custom fields, or running off Relationships - and of course the multisite approach. But i don't think either of the first two are very generic and hence are not packaged up and able to be passed around.
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

capo

  • I post occasionally
  • **
  • Posts: 108
  • Karma: 5
Re: Smarter smart groups
May 21, 2014, 02:21:09 am
I wrote my question into the 5.0 Saloon because I wasn't looking for a solution with current development possibilities. What I meant is that, if a link to the logged user is available at the Docrine layer, we'd have a new world of possibilities.

I'll try to explain it a bit better.

Now, you can easily create a smart group that dinamically shows contacts from, lets say, Madrid. In that case, the where_clause at civicrm_saved_search would be something like:

Code: [Select]
( civicrm_address.state_province_id IN (2452) )

But, imagine that:
  • The current where_clause at the civicrm_group and civicrm_saved_search tables was replaced by a where_dql_clause.
  • The ID of the logged user was available from the Doctrine layer.

Then, we would be able to write DQL conditions like:

Code: [Select]
(
    civicrm_address.state_province_id IN (
        SELECT
            logged_user_address.state_province_id
        FROM civicrm_address AS logged_user_address
        WHERE
            logged_user_address.contact_id = :logged_user_id
    )
)

The powerful thing about it, is that this group, would show different sets of contacts depending on the user who's querying it.

It means that, by changing the search user interface, adding the posibility of using tokens related to the information of the logged user, CiviCRM administrators would be able to do a lot of things that now only developers can do.

Note:
The big deal about this proposal would be to identify the groups that are using information about the logged user in their where_dql_clauses, so we could generate a per user group contact cache.

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: Smarter smart groups
May 21, 2014, 01:38:10 pm
got you - well not the detail - but yes the idea that this is a deeper concept that how we tackle it currently - will mossie on out of the saloon  8)
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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • 5.0 Saloon »
  • Smarter smart groups

This forum was archived on 2017-11-26.