function trash_flag_og_permission in Trash Flag 7
Implements hook_og_permission().
File
- ./
trash_flag.module, line 247
Code
function trash_flag_og_permission() {
if ($flag = flag_get_flag('trash')) {
$trash_action = drupal_strtolower($flag->title);
$trashed = drupal_strtolower($flag->unflag_denied_text);
$untrash_action = drupal_strtolower($flag->unflag_short);
}
else {
$trash_action = 'trash';
$untrash_action = 'untrash';
$trashed = 'trashed';
}
$perms = array();
$t_args = array(
'@trash' => $trash_action,
'@untrash' => $untrash_action,
'@trashed' => $trashed,
);
$perms["trash any content"] = array(
'title' => t('@trash any content', $t_args),
'default role' => array(),
'restrict access' => TRUE,
);
$perms["untrash any content"] = array(
'title' => t('@untrash any content', $t_args),
'description' => t('Must be able to view @trashed content to @untrash.', $t_args),
'default role' => array(),
'restrict access' => TRUE,
);
$perms["view trash content"] = array(
'title' => t('View @trashed content', $t_args),
'description' => t('Users with this permission will be able to view @trashed content as normal, unless the @trashed content is specifically filtered out.', $t_args),
'default role' => array(),
'restrict access' => TRUE,
);
$perms["view trash bin"] = array(
'title' => t('View @trashed listing and content pages', $t_args),
'description' => t('Users with this permission will be able to view @trashed content in the @trashed listing and the content view pages.', $t_args),
'default role' => array(),
'restrict access' => TRUE,
);
// Generate standard node permissions for all applicable node types.
foreach (node_type_get_names() as $type => $name) {
if (og_is_group_content_type('node', $type)) {
$info = node_type_get_type($type);
// Build standard list of node permissions for this type.
$perms["trash any {$type} content"] = array(
'title' => t('%type_name: @trash any content', $t_args + array(
'%type_name' => $name,
)),
'default role' => array(
OG_AUTHENTICATED_ROLE,
),
'restrict access' => TRUE,
);
$perms["trash own {$type} content"] = array(
'title' => t('%type_name: @trash own content', $t_args + array(
'%type_name' => $name,
)),
'default role' => array(
OG_AUTHENTICATED_ROLE,
),
'restrict access' => TRUE,
);
$perms["untrash any {$type} content"] = array(
'title' => t('%type_name: @untrash any content', $t_args + array(
'%type_name' => $name,
)),
'description' => t('Must be able to view @trashed content to @untrash.', $t_args),
'default role' => array(),
'restrict access' => TRUE,
);
$perms["untrash own {$type} content"] = array(
'title' => t('%type_name: @untrash own content', $t_args + array(
'%type_name' => $name,
)),
'description' => t('Must be able to view @trashed content to @untrash.', $t_args),
'default role' => array(),
'restrict access' => TRUE,
);
}
}
return $perms;
}