Source for file pnadminapi.php
Documentation is available at pnadminapi.php
* Zikula Application Framework
* @copyright (c) 2002, Zikula Development Team
* @link http://www.zikula.org
* @version $Id: pnadminapi.php 24342 2008-06-06 12:03:14Z markwest $
* @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
* @package Zikula_System_Modules
* create a admin category
* @param string $args['catname'] name of the category
* @param string $args['description'] description of the category
* @return mixed admin category ID on success, false on failure
if (!isset ($args['catname']) ||
!isset ($args['description'])) {
$item = array('catname' => $args['catname'], 'description' => $args['description']);
// Let other modules know an item has been created
pnModCallHooks('item', 'create', $item['cid'], array('module' => 'Admin'));
// Return the id of the newly created item to the calling process
* delete a admin category
* @param int $args['cid'] ID of the category
* @return bool true on success, false on failure
if (!isset ($args['cid']) || !is_numeric($args['cid'])) {
$item = pnModAPIFunc('Admin', 'admin', 'get', array('cid' => $args['cid']));
// Avoid deletion of the default category
$defaultcategory = pnModGetVar('Admin', 'defaultcategory');
if ($args['cid'] == $defaultcategory) {
// Avoid deletion of the start category
$startcategory = pnModGetVar('Admin', 'startcategory');
if ($args['cid'] == $startcategory) {
// move all modules from the category to be deleted into the
// default category. We can't do this via a simple DBUtil call
// because it's a non-object based mass update of the key field.
$column = $pntable['admin_module_column'];
$obj['cid'] = $defaultcategory;
// Now actually delete the category
// Let any hooks know that we have deleted an item.
pnModCallHooks('item', 'delete', $args['cid'], array('module' => 'Admin'));
// Let the calling process know that we have finished successfully
* update a admin category
* @param int $args['cid'] the ID of the category
* @param string $args['catname'] the new name of the category
* @param string $args['description'] the new description of the category
* @return bool true on success, false on failure
if (!isset ($args['cid']) ||
!isset ($args['catname']) ||
!isset ($args['description'])) {
$item = pnModAPIFunc('Admin', 'admin', 'get', array('cid' => $args['cid']));
// Security checks (both old item and updated item)
$item = array('cid' => $args['cid'], 'catname' => $args['catname'], 'description' => $args['description']);
pnModCallHooks('item', 'update', $args['cid'], array('module' => 'Admin'));
// Let the calling process know that we have finished successfully
* get all admin categories
* @param int $args['startnum'] starting record number
* @param int $args['numitems'] number of items to get
* @return mixed array of items, or false on failure
if (!isset ($args['startnum']) || !is_numeric($args['startnum'])) {
if (!isset ($args['numitems']) || !is_numeric($args['numitems'])) {
if (!isset ($args['startnum']) ||
!isset ($args['numitems'])) {
// get the necessary db information
$admincategorycolumn = &$pntable['admin_category_column'];
// get all categories the user has permission to see
$orderBy = "ORDER BY $admincategorycolumn[catname]";
$permFilter = array(array('realm' => 0,
'component_left' => 'Admin',
'instance_left' => 'catname',
'instance_right' => 'cid',
$result = DBUtil::selectObjectArray('admin_category', '', $orderBy, $args['startnum']- 1, $args['numitems'], '', $permFilter);
* get a specific category
* @param int $args['cid'] id of example item to get
* @return mixed item array, or false on failure
if (!isset ($args['cid'])) {
// retrieve the category object
* utility function to count the number of items held by this module
* @return int number of items held by this module
* add a module to a category
* @param string $args['module'] name of the module
* @param int $args['category'] number of the category
* @return mixed admin category ID on success, false on failure
if (!isset ($args['module']) ||
!isset ($args['category'])) {
// this function is called durung the init process so we have to check in _PNINSTALLVER
// is set as alternative to the correct permission check
$values['cid'] = $args['category'];
* Get the category a module belongs to
* @param int $args['mid'] id of the module
* @return mixed category id, or false on failure
// create a static result set to prevent multiple sql queries
static $catitems = array();
if (!isset ($args['mid'])) {
return LogUtil::registerError (_MODARGSERROR);
// check if we've already worked this query out
if (isset ($catitems[$args['mid']])) {
return $catitems[$args['mid']];
// retrieve the admin module object array
$catitems[$val] = $result[$val]['cid'];
// Return the category id
if (isset ($catitems[$args['mid']])) {
return $catitems[$args['mid']];
* Get the category a module belongs to
* @param int $args['mid'] id of the module
* @return mixed array of styles if successful, or false on failure
// check our input and get the module information
if (!isset ($args['modname']) ||
if (!isset ($args['exclude']) || !is_array($args['exclude'])) {
$args['exclude'] = array();
// create an empty result set
if (is_dir($dir = "modules/$osmoddir/pnstyle")) {
while (false !== ($file = readdir($handle))) {
} else if (is_dir($dir = "system/$osmoddir/pnstyle")) {
while (false !== ($file = readdir($handle))) {
* get available admin panel links
* @return array array of admin links
|