function flag_flag::validate_access in Flag 7.2
Same name and namespace in other branches
- 6.2 flag.inc \flag_flag::validate_access()
- 7.3 includes/flag/flag_flag.inc \flag_flag::validate_access()
Validates that the current flag's access settings are valid.
1 call to flag_flag::validate_access()
- flag_flag::validate in ./
flag.inc - Validates this flag's options.
File
- ./
flag.inc, line 346 - 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 validate_access() {
$errors = array();
// Require an unflag access denied message a role is not allowed to unflag.
if (empty($this->unflag_denied_text)) {
foreach ($this->roles['flag'] as $key => $rid) {
if ($rid && empty($this->roles['unflag'][$key])) {
$errors['unflag_denied_text'][] = array(
'error' => 'flag_denied_text_required',
'message' => t('The "Unflag not allowed text" is required if any user roles are not allowed to unflag.'),
);
break;
}
}
}
// Do not allow unflag access without flag access.
foreach ($this->roles['unflag'] as $key => $rid) {
if ($rid && empty($this->roles['flag'][$key])) {
$errors['roles'][] = array(
'error' => 'flag_roles_unflag',
'message' => t('Any user role that has the ability to unflag must also have the ability to flag.'),
);
break;
}
}
return $errors;
}