Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By wpanssi on
I'm trying to learn Drupal 6 access control with these instructions: http://drupal.org/node/109157
I'm trying to figure out the function of 'access arguments' inside the menu_hook.
For example, here is a clip of webform module's menu hook:
$items['node/%webform_menu/submission/%webform_menu_submission/edit'] = array(
'title' => 'Edit',
'load arguments' => array(1),
'page callback' => 'webform_client_form_load',
'page arguments' => array(1, 3, TRUE, FALSE),
'access callback' => 'webform_submission_access',
'access arguments' => array(1, 3, 'edit'),
'weight' => 1,
'type' => MENU_LOCAL_TASK,
);
It's unclear to me what these numbers mean in 'access arguments'? Could someone explain me a bit of 'access arguments'? What do the numbers 1 and 3 mean??
Comments
Where in the webform module
Where in the webform module do you see that snippet? I can't seem to find it. I'm fairly new to module development but I've only ever used something like:
where those access permissions are actually defined in the module's implementation of hook_perm like:
looking in webform.module, here's the implementation of hook_perm()
you can also check api.drupal.org for more info: http://api.drupal.org/api/function/hook_perm/6
hope that helps!
The php I gave can be found
The php I gave can be found in the webform_menu function. There are quite a lot of items. I just presented one of them.
I'm trying to implement 'access own webform results' and that's why I'm asking. I already created this new permission by modifying webform_perm(). But I need to find out what those numbers 1 and 3 mean in the 'access arguments'. I have not found any examples where 'access arguments' contains plain numbers, so If someone could help me out here I would be grateful..
--
http://www.sitemedia.fi
http://webgallup.com
Integer values in access arguements
Looking at hook_menu in the API (http://api.drupal.org/api/function/hook_menu) it describes access arguments as follows:
So in your example the url node/%webform_menu/submission/%webform_menu_submission/edit breaks down as:
0 =>node
1 => %webform_menu
2 => submission
3 => %webform_menu_submission
4 => edit
This means the access arguments will be:
The '%' in the URL of your example are parameters, probably used to insert the name of a webform, e.g.
Hope this helps.