Source for file pnadminapi.php
Documentation is available at pnadminapi.php
* Zikula Application Framework
* @copyright (c) 2001, 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
* update attributes of a block
* @param int $args ['bid'] the ID of the block to update
* @param string $args ['title'] the new title of the block
* @param string $args ['positions'] the new positions of the block
* @param string $args ['url'] the new URL of the block
* @param string $args ['language'] the new language of the block
* @param string $args ['content'] the new content of the block
* @return bool true on success, false on failure
if (!isset ($args['url'])) {
if (!isset ($args['content'])) {
if (!isset ($args['bid']) ||
!isset ($args['content']) ||
!isset ($args['title']) ||
!isset ($args['language']) ||
!isset ($args['collapsable']) ||
!isset ($args['defaultstate'])) {
// this function is called durung the init process so we have to check in _PNINSTALLVER
// is set as alternative to the correct permission check
$item = array('bid' => isset ($args['bid']) ? $args['bid'] : $block['bid'],
'content' => isset ($args['content']) ? $args['content'] : $block['content'],
'title' => isset ($args['title']) ? $args['title'] : $block['title'],
'filter' => isset ($args['filter']) ? serialize($args['filter']) : $block['filter'],
'url' => isset ($args['url']) ? $args['url'] : $block['url'],
'refresh' => isset ($args['refresh']) ? $args['refresh'] : $block['refresh'],
'language' => isset ($args['language']) ? $args['language'] : $block['language'],
'collapsable' => isset ($args['collapsable']) ? $args['collapsable'] : $block['collapsable'],
'defaultstate' => isset ($args['defaultstate']) ? $args['defaultstate'] : $block['defaultstate']);
// leave unchanged positions as is, delete removed positions from placements table
// and add placement for new positions
if (isset ($args['positions'])) {
// Get all existing block positions. We do not use the userapi function here because we need
// an associative array for the next steps: key = pid (position id)
foreach ($allblockspositions as $positionid => $blockposition) {
if(in_array($positionid, $args['positions'])) {
// position name is present in the array submitted from the user
// block is already in this position, placement did not change, this means we do nothing
// add the block to the given position as last entry (max(pn_order) +1
$newplacement = array('pid' => $blockposition['pid'],
'order' => count($blocksinpositions));
// position name is NOT present in the array submitted from the user
// delete the block id from the placements table for this position
pnModCallHooks('item', 'update', $args['bid'], array('module' => 'Blocks'));
* @param string $block ['title'] the title of the block
* @param int $block ['mid'] the module ID of the block
* @param string $block ['language'] the language of the block
* @param int $block ['bkey'] the key of the block
* @return mixed block Id on success, false on failure
if ((!isset ($args['title'])) ||
(!isset ($args['mid'])) ||
(!isset ($args['language'])) ||
(!isset ($args['collapsable'])) ||
(!isset ($args['defaultstate'])) ||
(!isset ($args['bkey']))) {
if (!isset ($args['content']) || !is_string($args['content'])) {
$block = array('title' => $args['title'], 'language' => $args['language'], 'collapsable' => $args['collapsable'],
'mid' => $args['mid'], 'defaultstate' => $args['defaultstate'], 'bkey' => $args['bkey'],
'content' => $args['content']);
$block['refresh'] = 3600;
$block['last_update'] = date('Y-m-d H:i:s');
// empty block positions for this block
if (isset ($args['positions'])) {
// add new block positions
$blockplacments = array();
foreach ($args['positions'] as $position) {
$blockplacments[] = array('bid' => $block['bid'], 'pid' => $position);
// Let other modules know we have created an item
pnModCallHooks('item', 'create', $block['bid'], array('module' => 'Blocks'));
* Set a block's active state
* @param int $args ['bid'] the ID of the block to deactivate
* @return bool true on success, false on failure
if (!isset ($block['bid']) || !is_numeric($block['bid'])) {
if (!isset ($block['active']) || !is_numeric($block['active'])) {
// create a new object to ensure that we only update the 'active' field
$obj['bid'] = $block['bid'];
$obj['active'] = $block['active'];
* @param int $args ['bid'] the ID of the block to deactivate
* @return bool true on success, false on failure
* @param int $args ['bid'] the ID of the block to activate
* @return bool true on success, false on failure
* @param int $args ['bid'] the ID of the block to delete
* @return bool true on success, false on failure
if (!isset ($args['bid']) || !is_numeric($args['bid'])) {
// delete block placements for this block
// delete the block itself
// Let other modules know we have deleted an item
pnModCallHooks('item', 'delete', $args['bid'], array('module' => 'Blocks'));
* create a block position
* @param string $args['name'] name of the position
* @param string $args['description'] description of the position
* @return mixed position ID on success, false on failure
if (!isset ($args['name']) ||
!isset ($args['description'])) {
$positions = pnModAPIFunc('Blocks', 'user', 'getallpositions');
if (isset ($positions) && is_array($positions)) {
foreach ($positions as $position) {
if ($position['name'] == $args['name']) {
$item = array('name' => $args['name'], 'description' => $args['description']);
// Return the id of the newly created item to the calling process
* update a block position item
* @param int $args['pid'] the ID of the item
* @param sting $args['name'] name of the block position
* @param string $args['description'] description of the block position
* @return bool true if successful, false otherwise
if (!isset ($args['pid']) ||
!isset ($args['description'])) {
// Get the existing admin message
$item = pnModAPIFunc('Blocks', 'user', 'getposition', array('pid' => $args['pid']));
$item = array('pid' => $args['pid'], 'name' => $args['name'], 'description' => $args['description']);
// Let the calling process know that we have finished successfully
* delete a block position
* @param int $args['pid'] ID of the position
* @return bool true on success, false on failure
if (!isset ($args['pid']) || !is_numeric($args['pid'])) {
$item = pnModAPIFunc('Blocks', 'user', 'getposition', array('pid' => $args['pid']));
// Now actually delete the category
// Let the calling process know that we have finished successfully
* get available admin panel links
* @return array array of admin links
|