hi all,
i just developed my custom 2 modules :

** the first is about laod data from db and put the "title" -it is a coulmn in table- in a combobox and on change the value of this combo box it open a new window that has the corresponding url -another coulmn in table-

**the second module is about to make 3 operations on this table like add ,edit and delete some records in the table

and i assume that when the loging was with admin , he can configure in the both modules, but if u r normal user ,so u can only deal with the first module.

what i think now is to combine the 2 modules in one and check the loging user if he was admin so he can see both modules ,on the other hand ,if he was a normal user so he can only deal with the first only.

NOTE--> i make 2 completly separated modules (i.e 2 .info and 2 .modules files)

any ideas to accomblish that .

thanks for advance

Comments

tashicoder’s picture

Both the modules have menu hook , i assume. All you need to do is create two permissions array then for the admin assign both the permission and for the authenticated user just assign just one appropriate permission.

For example:

* Implementation of hook_perm().
*/
function mymodule_perm() {
return array('admin one', 'admin two');
}
/**
* Implementation of hook_menu().
*/
function mymodule_menu() {
$items[‘admin’] = array(
'title' => ‘I am admin’,
'page callback' => ‘abc’,
'access arguments' => array('admin one', 'admin two'),
'type' => MENU_NORMAL_ITEM,
);
$items[‘auth’] = array(
'title' => ‘I am authenticate user’,
'page callback' => ‘xyz’,
'access arguments' => array('admin one'),
'type' => MENU_NORMAL_ITEM,
);
return $items;
}