actions_permissions.module in Views Bulk Operations (VBO) 6.3
File
actions_permissions.module
View source
<?php
function actions_permissions_perm() {
$perms = array();
$actions = actions_list() + _actions_permissions_get_custom_actions();
foreach ($actions as $callback => $action) {
$perms[] = actions_permissions_get_perm($action['description'], $callback);
}
module_load_include('inc', 'node', 'node.admin');
foreach (array(
'node',
'user',
) as $type) {
foreach (module_invoke_all($type . '_operations') as $operation) {
if (is_array($operation['label']) || empty($operation['callback'])) {
continue;
}
$perms[] = actions_permissions_get_perm($operation['label'], $operation['callback']);
}
}
return $perms;
}
function _actions_permissions_get_custom_actions() {
$actions = array();
$static_actions = actions_list();
$result = db_query("SELECT * FROM {actions} WHERE parameters > ''");
while ($action = db_fetch_object($result)) {
$actions[$action->aid] = array(
'description' => $action->description,
'type' => $action->type,
'configurable' => FALSE,
'parameters' => unserialize($action->parameters),
);
$actions[$action->aid]['behavior'] = isset($static_actions[$action->callback]['behavior']) ? $static_actions[$action->callback]['behavior'] : null;
}
return $actions;
}
function actions_permissions_get_perm($label, $callback) {
return 'execute ' . rt($label) . ' (' . $callback . ')';
}
function rt($string) {
global $language;
$langcode = $language->language;
static $custom_strings;
if (!isset($custom_strings[$langcode])) {
$custom_strings[$langcode] = variable_get('locale_custom_strings_' . $langcode, array());
}
if ($source = array_search($string, $custom_strings[$langcode])) {
return $source;
}
if (!function_exists('locale') || $langcode == 'en') {
return $string;
}
if (variable_get('locale_cache_strings', 1) == 1) {
$locale_t = locale();
if (isset($locale_t[$langcode]) && ($source = array_search($string, $locale_t[$langcode], TRUE))) {
return $source;
}
else {
return $string;
}
}
else {
$source = db_result(db_query("SELECT s.source FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = '%s' WHERE t.translation = '%s' AND s.textgroup = 'default'", $langcode, $string));
return $source ? $source : $string;
}
}