Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
og
Commits
9d625a92
Commit
9d625a92
authored
Sep 08, 2016
by
joelpittet
Committed by
amitaibu
Sep 08, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2250177
by joelpittet, Devin Carlson, ezra-g: Improve performance of og_is_group()
parent
c2147b5b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
4 deletions
+10
-4
og.module
og.module
+10
-4
No files found.
og.module
View file @
9d625a92
...
...
@@ -1810,15 +1810,21 @@ function og_membership_access($op, $entity, $account = NULL, $entity_type = 'og_
* The entity type.
* @param $entity
* The entity object, or the entity ID.
*
* @return
* TRUE or FALSE if the entity is a group.
*/
function
og_is_group
(
$entity_type
,
$entity
)
{
$wrapper
=
entity_metadata_wrapper
(
$entity_type
,
$entity
);
$bundle
=
$wrapper
->
getBundle
();
if
(
is_numeric
(
$entity
))
{
$entity
=
entity_load_single
(
$entity_type
,
$entity
);
}
list
(,,
$bundle
)
=
entity_extract_ids
(
$entity_type
,
$entity
);
if
(
!
field_info_instance
(
$entity_type
,
OG_GROUP_FIELD
,
$bundle
))
{
return
variable_get
(
"og_is_group__
{
$entity_type
}
__
{
$bundle
}
"
,
FALSE
);
}
return
!
empty
(
$wrapper
->
{
OG_GROUP_FIELD
})
&&
$wrapper
->
{
OG_GROUP_FIELD
}
->
value
();
$items
=
field_get_items
(
$entity_type
,
$entity
,
OG_GROUP_FIELD
);
return
!
empty
(
$items
[
0
][
'value'
]);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment