Source for file pninit.php
Documentation is available at pninit.php
* Zikula Application Framework
* @copyright (c) 2001, Zikula Development Team
* @link http://www.zikula.org
* @version $Id: pninit.php 24342 2008-06-06 12:03:14Z markwest $
* @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
* @package Zikula_System_Modules
* initialise the blocks module
* This function is only ever called once during the lifetime of a particular
* This function MUST exist in the pninit file for a module
* @return bool true on success, false otherwise
// appropriate error message and return
// create userblocks table
// create block positions table
// create block placements table
// Set a default value for a module variable
// Initialisation successful
* upgrade the blocks module from an old version
* This function can be called multiple times
* This function MUST exist in the pninit file for a module
* @return bool true on success, false otherwise
// update userblocks table
// update block positions table
// update block placements table
// Upgrade dependent on old version number
// version 2.2 was supplied with all .76x versions of PN
case 2.2: // upgrade from 76x
// create the default block positions
// force load the API since it's not available until the module is activated
$fields = array($prefix. '_position',
* delete the blocks module
* This function is only ever called once during the lifetime of a particular
* This function MUST exist in the pninit file for a module
* Since the blocks module should never be deleted we'all always return false here
* Add default block data for new installs
* This is called after a complete pn installation since the blocks
* need to be populated with module id's which are only available
* once the install has been completed
// create the default block positions - left, right and center for the traditional 3 column layout
// sanity check - truncate existing tables to ensure a clean blocks setup
//pnModLoad('Blocks', 'admin', true);
// define an array of the default blocks
// build the menu content
$menucontent['displaymodules'] = '1';
$menucontent['stylesheet'] = 'extmenu.css';
$menucontent['template'] = 'blocks_block_extmenu.htm';
'url' => '{Admin:adminpanel:admin}',
'url' => '{Users:logout}',
$blocks[] = array('bkey' => 'extmenu', 'collapsable' => 1, 'defaultstate' => 1, 'language' => '',
$blocks[] = array('bkey' => 'thelang', 'collapsable' => 1, 'defaultstate' => 1, 'language' => '',
$blocks[] = array('bkey' => 'login', 'collapsable' => 1, 'defaultstate' => 1, 'language' => '',
$blocks[] = array('bkey' => 'online', 'collapsable' => 1, 'defaultstate' => 1, 'language' => '',
$blocks[] = array('bkey' => 'messages', 'collapsable' => 1, 'defaultstate' => 1, 'language' => '',
// create each block and then update the block
// the create creates the initiial block record, the update sets the block placments
foreach ($blocks as $position => $block) {
$block['bid'] = pnModAPIFunc('Blocks', 'admin', 'create', $block);
* Upgrade for blocks tables data from 0.76x to 0.8+
* This function is called prior to the system upgrade
// we need to get the blocks table prior to the update otherwise the position field get dropped
// and we lose the data needed to rewrite any block positions
// get site prefix - the old way....
// get the values from the blocks table
$sql = "SELECT pn_bid, pn_position, pn_weight FROM {$prefix}_blocks";
// format a result array in the correct format for the block placements table
for (; !$result->EOF; $result->MoveNext()) {
list ($bid, $position, $weight) = $result->fields;
// manually map the position id
case 'l': $pid = 1; break;
case 'r': $pid = 2; break;
case 'c': $pid = 3; break;
// only add blocks that are in one of the core positions
$_SESSION['_PNUpgrader']['blocks'][] = array('pid' => $pid,
'order' => (int) $weight);
* Upgrade for blocks tables data from 0.76x to 0.8+
* This function is called after the system upgrade is complete
// now insert the backed up block positions into the placements table
// get site prefix - the old way....
// fix some block module id's
$sqls[] = "UPDATE {$prefix}_blocks SET pn_mid = {$blocksmodid} WHERE pn_mid = 0 AND pn_bkey IN ('html','finclude','menu','text','thelang')";
$sqls[] = "UPDATE {$prefix}_blocks SET pn_mid = {$usersmodid} WHERE pn_mid = 0 AND pn_bkey IN ('login','online','user')";
$sqls[] = "UPDATE {$prefix}_blocks SET pn_mid = {$pollsmodid} WHERE pn_mid = 0 AND pn_bkey IN ('poll')";
$sqls[] = "UPDATE {$prefix}_blocks SET pn_mid = {$bannersmodid} WHERE pn_mid = 0 AND pn_bkey IN ('banners')";
$sqls[] = "UPDATE {$prefix}_blocks SET pn_mid = {$newsmodid} WHERE pn_mid = 0 AND pn_bkey IN ('big','past','stories')";
$sqls[] = "UPDATE {$prefix}_blocks SET pn_mid = {$searchmodid} WHERE pn_mid = 0 AND pn_bkey IN ('search')";
foreach ($sqls as $sql) {
|