Add report links to user profile

Add report links to user profile, visible only on profile
of community managers and ambassadors.

Change-Id: I7e8e5946e6a4097f18829f0179c73bd2315c3d1b
This commit is contained in:
Marton Kiss 2015-02-23 10:46:07 +01:00
parent e8ac3ba589
commit 81bbee5437
2 changed files with 11 additions and 2 deletions

View File

@ -234,6 +234,7 @@ function openstack_bootstrap_preprocess_views_view(&$variables) {
* Implements template_preprocess_user_profile()
*/
function openstack_bootstrap_preprocess_user_profile(&$variables) {
global $user;
$account = $variables['elements']['#account'];
if (in_array('ambassador', $account->roles)) {
$variables['user_profile']['role_ambassador'] = array(
@ -249,8 +250,9 @@ function openstack_bootstrap_preprocess_user_profile(&$variables) {
'#suffix' => '</span>',
);
}
if ((in_array('community_manager', $account->roles)) ||
(in_array('ambassador', $account->roles))) {
if (((in_array('community_manager', $user->roles)) ||
(in_array('ambassador', $user->roles)) ||
(in_array('administrator', $user->roles))) && ($user->uid == $account->uid)) {
$pending_groups = db_select('node', 'n')
->fields('n')
->condition('n.status', 0, '=')
@ -267,6 +269,12 @@ function openstack_bootstrap_preprocess_user_profile(&$variables) {
'#prefix' => '<h3>'.t('Groups waiting for approval').'</h3>',
'#markup' => $content,
);
$variables['user_profile']['reports'] = array(
'#prefix' => '<h3>'.t('Reports').'</h3>',
'#markup' =>
'<div>'.l('User group membership report', 'reports/groups-membership-report').'</div>'.
'<div>'.l('Membership history report', 'reports/groups-membership-history-report').'</div>',
);
}
if (user_is_logged_in()) {
$variables['user_profile']['register_new_group'] = array(

View File

@ -46,6 +46,7 @@
</div>
<?php print render($user_profile['og_user_node']); ?>
<?php print render($user_profile['summary']); ?>
<?php print render($user_profile['reports']); ?>
<?php print render($user_profile['pending_groups']); ?>
<?php print render($user_profile['register_new_group']); ?>
</div>