Adding an action basically consists of doing 3 things :
- Adding the action's key (any kind of alphanumeric string, like action_a) to the info file of the module. (info.php)
- Adding a case-switch block to the actions() method of the module.
- Assigning group permissions, (allow/disallow) for that action to the permission table, through the permissions manager in admin.
- Dropping in a template for that action, in templates folder (whichever you are using) of the module.
So, first, decide on a key for your action. Like, action_a. This will be the key you will send to the module to request that action.
Then, edit info.php in the module folder, and add the action key to the actions array, so system will know. Like:
$gb->modules['user']['actions'] = array(
'action_a', <- added here
After that, add your new action into the module (in this case, user module as the example), in its class.php file, by adding a case-switch block, as you see below :
.......... (various code present in this existing action) ......
.......... (various other switch blocks (actions) like the above present in between) ......
.......... (your code for your action here !!!) ......
.......... (add the below commands in order to process and build the output your action will do - mostly the below will be same for any action ) ......
// Build the module template up till this stage
// Build language of module
// Append it to page output.
} // Switch-case for actions end.
Replace the string 'user' with the key of the module you are adding an action to, above. Like, if you are adding it to groups, put in 'groups' string instead of 'user'.
Now, at this stage, go to the templatees/ folder for the module, and drop a plain, empty text file with the name of your action -> in this case, action_a.tpl. You dont need to add anything to this template file. The output of the action, will be appended to the page output with the
Last, just go to the GiriGiri admin, and permissions module. Choose the module (in this case, user), and then choose your action, action_a from radio select boxes. Then, choose a group from the above group selector box, and then either choose Allow or Disallow, from the final select box. When you save this form, that group will be granted the permission you have given for that action. By default, if there are no permissions for allowing for any action, the system assumes no permission.