profile2_og_access.module
1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/**
* @file
* Profile2 og access integration module.
*/
/**
* Implements hook_og_permission().
*/
function profile2_og_access_og_permission() {
$permissions = array();
// Generate per profile type permissions.
foreach (profile2_get_types() as $type) {
$type_name = check_plain($type->type);
$permissions += array(
"edit any $type_name profile" => array(
'title' => t('%type_name: Edit any profile', array('%type_name' => $type->label)),
),
"view any $type_name profile" => array(
'title' => t('%type_name: View any profile', array('%type_name' => $type->label)),
),
);
}
return $permissions;
}
/**
* Implements hook_profile2_access().
*
* @see profile2_profile2_access()
*/
function profile2_og_access_profile2_access($op, $profile = NULL, $account = NULL) {
if (isset($profile) && ($type_name = $profile->type) && $profile->identifier() && $op != 'delete') {
// Only return TRUE if og grants access. So other modules may still grant
// access in case og does not.
if (og_user_access_entity("$op any $type_name profile", 'profile2', $profile, $account)) {
return TRUE;
}
}
}