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) »
  • Testing the privilege/group of a user in the template
Pages: [1]

Author Topic: Testing the privilege/group of a user in the template  (Read 1126 times)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Testing the privilege/group of a user in the template
May 24, 2009, 11:10:35 pm
Hi,

I would like to add in a template a special link tool (to ease the merging), but I'd like to expose it only to the admin.

How can I test in the user belongs to the admin group ? (drupal) or if he has admin rights on civicrm ?

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

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: Testing the privilege/group of a user in the template
May 25, 2009, 07:49:30 am

you can call any php function within smarty, so this should work

{if user_access( 'administer CiviCRM' )}
add your code to expose the merge link here
{/if}

not sure if it also works for calls in classes, you can also try:

{if CRM_Core_Permission::check( 'administer CiviCRM' )}
{/if}

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

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Testing the privilege/group of a user in the template
May 26, 2009, 12:53:48 pm
Hi,

In fine, I wrote a custom module on drupal.

Got to show it to you, works nicely.

Anyway, I like that idea of calling php from within drupal. Would if be possible as well to fetch/list stuff ? Eg an include that list all the related contacts that you can include within a profile view ?

X+

-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

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: Testing the privilege/group of a user in the template
May 26, 2009, 02:24:37 pm

i think it is possible, since you can include php snippets. in general we try to avoid doing a lot in the tpl :) kinda defeats the view/code seperation if you do it a lot :)

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

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Testing the privilege/group of a user in the template
May 27, 2009, 02:44:17 pm
Hi,

I've been struggling with a lot of {if action eq 4} bla {else} snippet ... {elsif...} Couldn't agree more with you !

X+

P.S. This being said {civiinclude "civicrm/relatedcontacts" cid=$cid} isn't that hurting to see, is it ?
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Testing the privilege/group of a user in the template

This forum was archived on 2017-11-26.