function flag_flag::access_multiple in Flag 7.2
Same name and namespace in other branches
- 6.2 flag.inc \flag_flag::access_multiple()
- 7.3 includes/flag/flag_flag.inc \flag_flag::access_multiple()
Determine access to multiple objects.
Similar to user_access() but works on multiple IDs at once. Called in the pre_render() stage of the 'Flag links' field within Views to find out where that link applies. The reason we do a separate DB query, and not lump this test in the Views query, is to make 'many to one' tests possible without interfering with the rows, and also to reduce the complexity of the code.
This method typically should not be overridden by child classes. Instead they should implement type_access_multiple(), which is called by this method.
Parameters
$content_ids: The array of content IDs to check. The keys are the content IDs, the values are the actions to test: either 'flag' or 'unflag'.
$account: Optional. The account for which the actions will be compared against. If left empty, the current user will be used.
Return value
An array whose keys are the object IDs and values are booleans indicating access.
See also
File
- ./
flag.inc, line 550 - Implements various flags. Uses object oriented style inspired by that of Views 2.
Class
- flag_flag
- This abstract class represents a flag, or, in Views 2 terminology, "a handler".
Code
function access_multiple($content_ids, $account = NULL) {
$account = isset($account) ? $account : $GLOBALS['user'];
$access = array();
// First check basic user access for this action.
foreach ($content_ids as $content_id => $action) {
$access[$content_id] = $this
->user_access($content_ids[$content_id], $account);
}
// Check for additional access rules provided by sub-classes.
$child_access = $this
->type_access_multiple($content_ids, $account);
if (isset($child_access)) {
foreach ($child_access as $content_id => $content_access) {
if (isset($content_access)) {
$access[$content_id] = $content_access;
}
}
}
// Merge in module-defined access.
foreach (module_implements('flag_access_multiple') as $module) {
$module_access = module_invoke($module, 'flag_access_multiple', $this, $content_ids, $account);
foreach ($module_access as $content_id => $content_access) {
if (isset($content_access)) {
$access[$content_id] = $content_access;
}
}
}
return $access;
}