我正在使用 drupal 7 和 entity_registration 模块(registration-7.x-1.0-alpha5)进行事件注册。
此处仅针对特定角色显示注册链接,即,如果为经过身份验证的用户设置了权限,则注册链接将显示给经过身份验证的用户。
如果我们尝试手动访问例如 node/9/register 的页面,它会显示访问被拒绝。
现在,我使用 LoginToboggan 将拒绝访问页面重定向到用户登录页面。但是,当我手动创建一个名为 Register 且具有路径 node/9/register 的菜单项时,菜单项本身并没有显示。
我想要一种方法来告诉用户登录注册或类似的东西..
我希望你明白我的意思。
这是模块文件代码..我认为格式有问题所以我只粘贴了 hook_menu 和 hook_permission 函数..请访问查看完整代码的链接 www.karyashala.in/code.html
/**
* Implements hook_menu().
*/
function registration_menu() {
$items['registration/%registration'] = array(
'title callback' => 'registration_page_title',
'title arguments' => array(1),
'page callback' => 'registration_view',
'page arguments' => array(1),
'access callback' => 'entity_access',
'access arguments' => array('view', 'registration', 1),
);
$items['registration/%registration/view'] = array(
'title' => 'View',
'page callback' => 'registration_view',
'page arguments' => array(1),
'access callback' => 'entity_access',
'access arguments' => array('view', 'registration', 1),
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['registration/%registration/edit'] = array(
'title' => 'Edit',
'page callback' => 'drupal_get_form',
'page arguments' => array('registration_form', 1),
'access callback' => 'entity_access',
'access arguments' => array('update', 'registration', 1),
'weight' => 10,
'type' => MENU_LOCAL_TASK,
);
$items['registration/%registration/delete'] = array(
'title' => 'Delete',
'page callback' => 'drupal_get_form',
'page arguments' => array('registration_delete_confirm', 1),
'access callback' => 'entity_access',
'access arguments' => array('delete', 'registration', 1),
'type' => MENU_CALLBACK,
);
// entity local tasks
foreach (registration_get_registration_instances() as $instance) {
$type = $instance['entity_type'];
if (!in_array($type, array('registration', 'registration_type'))) {
$items[$type . '/%entity_object/register'] = array(
'load arguments' => array($type),
'title' => 'Register',
'page callback' => 'registration_register_page',
'page arguments' => array(0, 1),
'access callback' => 'registration_register_page_access',
'access arguments' => array(0, 1),
'type' => MENU_LOCAL_TASK,
);
$items[$type . '/%entity_object/registrations'] = array(
'load arguments' => array($type),
'title' => 'Manage Registrations',
'page callback' => 'registration_registrations_page',
'page arguments' => array(0, 1),
'access callback' =>
'registration_administer_registrations_access',
'access arguments' => array(0, 1),
'type' => MENU_LOCAL_TASK,
);
$items[$type . '/%entity_object/registrations/list'] = array(
'load arguments' => array($type),
'title' => 'Registrations',
'page callback' => 'registration_registrations_page',
'page arguments' => array(0, 1),
'access callback' => 'registration_administer_registrations_access',
'access arguments' => array(0, 1),
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items[$type . '/%entity_object/registrations/settings'] = array(
'load arguments' => array($type),
'title' => 'Settings',
'page callback' => 'drupal_get_form',
'page arguments' => array('registration_registrations_settings_form', 0,
1),
'access callback' => 'registration_administer_registrations_access',
'access arguments' => array(0, 1),
'weight' => 9,
'type' => MENU_LOCAL_TASK,
);
$items[$type . '/%entity_object/registrations/broadcast'] = array(
'load arguments' => array($type),
'title' => 'Email Registrants',
'page callback' => 'drupal_get_form',
'page arguments' => array('registration_registrations_broadcast_form', 0,
1),
'access callback' => 'registration_administer_registrations_access',
'access arguments' => array(0, 1),
'weight' => 10,
'type' => MENU_LOCAL_TASK,
);
}
}
if (module_exists('devel')) {
$items['registration/%registration/devel'] = array(
'title' => 'Devel',
'page callback' => 'devel_load_object',
'page arguments' => array('node', 1),
'access arguments' => array('access devel information'),
'type' => MENU_LOCAL_TASK,
'file path' => drupal_get_path('module', 'devel'),
'file' => 'devel.pages.inc',
'weight' => 100,
);
$items['registration/%registration/devel/load'] = array(
'title' => 'Load',
'type' => MENU_DEFAULT_LOCAL_TASK,
);
}
return $items;
}
/**
* Implements hook_permission().
*/
function registration_permission() {
$permissions = array(
'administer registration types' => array(
'title' => t('Administer registration types'),
'description' => t('Manage registration types, fields, and display
settings.'),
'restrict access' => TRUE,
),
'administer registration' => array(
'title' => t('Administer registration'),
'description' => t('View, edit, delete, and manage all registrations,
regardless of type.'),
'restrict access' => TRUE,
),
);
foreach(registration_get_types() as $type_info) {
$permissions += registration_permission_list($type_info);
}
return $permissions;
}