Wiki : ModuleAdminLinks
Documentation Home :: Categories :: Index :: Recent Changes :: Comments :: Search :: Help :: Login/Registergetlinks admin API
This standard module API is used by PostNuke to display links to any admin functions a module may possess. In the example module these would be the view, new and modifyconfig functions. This API, in conjunction with the moduleadminlinks plugin, replaces the plugin provide by each module for admin navigation. This solution provides the advantage that other modules and/or blocks can call this function to implement custom navigation. For example the adminnav block calls this API for each module to provide a block based administration system.
The following example is the getlinks API from the Example module.
/**
* Get available admin panel links
*
* @return array array of admin links
*/
function Example_adminapi_getlinks()
{
// Define an empty array to hold the list of admin links
$links = array();
// Load the admin language file
// This allows this API to be called outside of the module
pnModLangLoad('Example', 'admin');
// Check the users permissions to each avaiable action within the admin panel
// and populate the links array if the user has permission
if (pnSecAuthAction(0, 'Example::', '::', ACCESS_READ)) {
$links[] = array('url' => pnModURL('Example', 'admin', 'view'), 'text' => _VIEW);
}
if (pnSecAuthAction(0, 'Example::', '::', ACCESS_ADD)) {
$links[] = array('url' => pnModURL('Example', 'admin', 'new'), 'text' => _NEW);
}
if (pnSecAuthAction(0, 'Example::', '::', ACCESS_ADMIN)) {
$links[] = array('url' => pnModURL('Example', 'admin', 'modifyconfig'), 'text' => _MODIFYCONFIG);
}
// Return the links array back to the calling function
return $links;
}
* Get available admin panel links
*
* @return array array of admin links
*/
function Example_adminapi_getlinks()
{
// Define an empty array to hold the list of admin links
$links = array();
// Load the admin language file
// This allows this API to be called outside of the module
pnModLangLoad('Example', 'admin');
// Check the users permissions to each avaiable action within the admin panel
// and populate the links array if the user has permission
if (pnSecAuthAction(0, 'Example::', '::', ACCESS_READ)) {
$links[] = array('url' => pnModURL('Example', 'admin', 'view'), 'text' => _VIEW);
}
if (pnSecAuthAction(0, 'Example::', '::', ACCESS_ADD)) {
$links[] = array('url' => pnModURL('Example', 'admin', 'new'), 'text' => _NEW);
}
if (pnSecAuthAction(0, 'Example::', '::', ACCESS_ADMIN)) {
$links[] = array('url' => pnModURL('Example', 'admin', 'modifyconfig'), 'text' => _MODIFYCONFIG);
}
// Return the links array back to the calling function
return $links;
}
The API returns an array of links. Each link is an array consisting of a number of predefined elements. These are
- url - the target URL
- id - the ID attribute of the anchor tag
- text - the link text
- title - the title attribute of the anchor tag
- disabled - make the link unclickable.This is useful to show that while a certain feature is available it isn't available in the current situation (possibly configuration)
- linebreak - insert a linebreak after this link. This is used by the modulelinks links plugin in it's formatting
CategoryDeveloperDocs
