View source
<?php
function services_menu_permission() {
return array(
"services menu retrieve menu" => array(
'title' => t('Get menu'),
),
);
}
function services_menu_services_resources() {
return array(
'menu' => array(
'retrieve' => array(
'help' => 'Retrieves a menu',
'file' => array(
'type' => 'inc',
'module' => 'services_menu',
'name' => 'services_menu.resource',
),
'callback' => '_services_menu_retrieve',
'access callback' => '_services_menu_access',
'access arguments' => array(
'view',
),
'access arguments append' => TRUE,
'args' => array(
array(
'name' => 'menu_name',
'type' => 'string',
'description' => 'The name of the menu to get',
'source' => array(
'path' => '0',
),
'optional' => FALSE,
),
),
),
),
);
}
function _services_menu_access($op = 'view', $args = array()) {
global $user;
$access = FALSE;
switch ($op) {
case 'view':
$access = user_access("services menu retrieve menu");
if (!in_array($args[0], menu_get_names())) {
return services_error(t('Menu @menu_name could not be found', array(
'@menu_name' => $args[0],
)), 404);
}
break;
}
return $access;
}