function fasttoggle_menu in Fasttoggle 5
Same name and namespace in other branches
- 6 fasttoggle.module \fasttoggle_menu()
- 7 fasttoggle.module \fasttoggle_menu()
Implementation of hook_menu().
File
- ./
fasttoggle.module, line 26 - Enables fast toggling of binary or not so binary settings
Code
function fasttoggle_menu($may_cache) {
$items = array();
if (!$may_cache) {
// The callback for toggling node settings
if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == 'toggle' && arg(3) != '') {
$node = node_load(arg(1));
if ($node->nid && count(fasttoggle_get_options('node', $node))) {
$items[] = array(
'path' => 'node/' . arg(1) . '/toggle',
'title' => t('toggle'),
'callback' => 'fasttoggle_node_option',
'callback arguments' => array(
$node,
),
'access' => true,
'type' => MENU_CALLBACK,
);
}
}
elseif (arg(0) == 'admin' && arg(1) == 'user' && is_numeric(arg(2)) && arg(3) == 'toggle' && arg(4) != '') {
$user = user_load(array(
'uid' => arg(2),
));
if ($user->uid && count(fasttoggle_get_options('user', $user))) {
$items[] = array(
'path' => 'admin/user/' . arg(2) . '/toggle',
'title' => t('status'),
'callback' => 'fasttoggle_user_option',
'callback arguments' => array(
$user,
),
'access' => true,
'type' => MENU_CALLBACK,
);
}
}
elseif (arg(0) == 'comment' && arg(1) == 'toggle' && is_numeric(arg(2)) && arg(3) != '') {
$comment = _comment_load(arg(2));
if ($comment->cid && count(fasttoggle_get_options('comment', $comment))) {
$items[] = array(
'path' => 'comment/toggle/' . arg(2),
'title' => t('status'),
'callback' => 'fasttoggle_comment_option',
'callback arguments' => array(
$comment,
),
'access' => true,
'type' => MENU_CALLBACK,
);
}
}
}
else {
$items[] = array(
'path' => 'admin/settings/fasttoggle',
'title' => t('Fasttoggle'),
'description' => t('Configure what fast toggling options are available.'),
'callback' => 'drupal_get_form',
'callback arguments' => array(
'fasttoggle_settings_form',
),
);
}
return $items;
}