function fasttoggle_fasttoggle_options in Fasttoggle 5
Same name and namespace in other branches
- 6 fasttoggle.module \fasttoggle_fasttoggle_options()
Implementation of hook_fasttoggle_options().
File
- ./
fasttoggle.module, line 288 - Enables fast toggling of binary or not so binary settings
Code
function fasttoggle_fasttoggle_options($type, $obj = NULL) {
$return = array();
switch ($type) {
case 'node':
// $obj = node
$admin = user_access('administer nodes');
// Get an array with all enabled fast toggle links
$settings = variable_get('fasttoggle_node_settings', array(
'status' => TRUE,
'sticky' => TRUE,
'promote' => TRUE,
'comment' => FALSE,
));
if ($settings['status'] && ($admin || user_access('moderate posts'))) {
$return['status'] = _fasttoggle_get_label('node_status');
}
if ($settings['sticky'] && ($admin || user_access('make posts sticky'))) {
$return['sticky'] = _fasttoggle_get_label('node_sticky');
}
if ($settings['promote'] && ($admin || user_access('promote posts'))) {
$return['promote'] = _fasttoggle_get_label('node_promote');
}
if (module_exists('comment') && $settings['comment'] && ($admin || user_access('administer comments'))) {
$return['comment'] = _fasttoggle_get_label('comment_admin');
}
break;
case 'user':
// $obj = user
// Get an array with all enabled fast toggle links
$settings = variable_get('fasttoggle_user_settings', array(
'status' => TRUE,
));
if ($settings['status'] && (user_access('administer users') || user_access('moderate users'))) {
$return['status'] = _fasttoggle_get_label('user_status');
}
break;
case 'comment':
// $obj = comment
// Get an array with all enabled fast toggle links
$settings = variable_get('fasttoggle_comment_settings', array(
'status' => TRUE,
));
if ($settings['status'] && (user_access('administer comments') || user_access('moderate comments'))) {
$return['status'] = _fasttoggle_get_label('comment_status');
}
break;
}
return $return;
}