function newsletter_template_access in Newsletter 7.2
Determines whether the given user has access to a newsletter template.
Parameters
$op: The operation being performed. One of 'view', 'update', 'create', 'delete' or just 'edit' (being the same as 'create' or 'update').
$template: Optionally a template or a template type to check access for. If nothing is given, access for all templates is determined.
$account: The user to check for. Leave it to NULL to check for the global user.
Return value
boolean Whether access is allowed or not.
1 string reference to 'newsletter_template_access'
- newsletter_template_entity_info in modules/
template/ newsletter_template.module - Implements hook_entity_info().
File
- modules/
template/ newsletter_template.module, line 191 - Module for the Newsletter Template Entity
Code
function newsletter_template_access($op, $template = NULL, $account = NULL) {
if (user_access('administer newsletter templates', $account)) {
return TRUE;
}
if (isset($template) && ($type_name = $template->type)) {
$op = $op == 'view' ? 'view' : 'edit';
if (user_access("{$op} any {$type_name} newsletter template", $account)) {
return TRUE;
}
elseif ($template->uid == $GLOBALS['user']->uid && user_access('subscribe newsletters')) {
return TRUE;
}
}
return FALSE;
}