Zikula_System_Modules
[ class tree: Zikula_System_Modules ] [ index: Zikula_System_Modules ] [ all elements ]

Source for file pninit.php

Documentation is available at pninit.php

  1. <?php
  2. /**
  3.  * Zikula Application Framework
  4.  *
  5.  * @copyright (c) 2002, Zikula Development Team
  6.  * @link http://www.zikula.org
  7.  * @version $Id: pninit.php 24342 2008-06-06 12:03:14Z markwest $
  8.  * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
  9.  * @package Zikula_System_Modules
  10.  * @subpackage Admin
  11.  */
  12.  
  13. /**
  14.  * initialise the Admin module
  15.  * This function is only ever called once during the lifetime of a particular
  16.  * module instance
  17.  * @author Mark West
  18.  * @return bool true if initialisation succcesful, false otherwise
  19.  */
  20. function Admin_init()
  21. {
  22.     if (!DBUtil::createTable('admin_category')) {
  23.         return false;
  24.     }
  25.  
  26.     if (!DBUtil::createTable('admin_module')) {
  27.         return false;
  28.     }
  29.  
  30.     pnModSetVar('Admin''modulesperrow'5);
  31.     pnModSetVar('Admin''itemsperpage'25);
  32.     pnModSetVar('Admin''defaultcategory'5);
  33.     pnModSetVar('Admin''modulestylesheet''navtabs.css');
  34.     pnModSetVar('Admin''admingraphic'1);
  35.     pnModSetVar('Admin''startcategory'1);
  36.     // change below to 0 before release - just makes it easier doing development meantime - drak
  37.     // we can now leave this at 0 since the code also checks the development flag (config.php) - markwest
  38.     pnModSetVar('Admin''ignoreinstallercheck'0);
  39.     pnModSetVar('Admin''admintheme''');
  40.  
  41.  
  42.     // Initialisation successful
  43.     return true;
  44. }
  45.  
  46. /**
  47.  * upgrade the Admin module from an old version
  48.  * This function can be called multiple times
  49.  * @author Mark West
  50.  * @param int $oldversion previous to upgrade from
  51.  * @return bool true if upgrade succcesful, false otherwise
  52.  */
  53. function Admin_upgrade($oldversion)
  54. {
  55.     // Upgrade dependent on old version number
  56.     switch($oldversion{
  57.         // version 0.1 was supplied with all .7x versions of PN
  58.         case 0.1:
  59.             Admin_init();
  60.             return Admin_upgrade(1.0);
  61.         case 1.0:
  62.             // move the admingraphic config var to a module var
  63.             pnModSetVar('Admin''admingraphic'pnConfigGetVar('admingraphic'));
  64.             pnConfigDelVar('admingraphic');
  65.             // set the remaining new vars
  66.             pnModSetVar('Admin''modulesperrow'5);
  67.             pnModSetVar('Admin''itemsperpage'25);
  68.             pnModSetVar('Admin''defaultcategory'5);
  69.             pnModSetVar('Admin''modulestylesheet''navtabs.css');
  70.             pnModSetVar('Admin''startcategory'1);
  71.             pnModSetVar('Admin''ignoreinstallercheck'0);
  72.             return Admin_upgrade(1.1);
  73.         case 1.1:
  74.             pnModSetVar('Admin''admintheme''');
  75.             return Admin_upgrade(1.2);
  76.         case 1.2:
  77.             //DBUtil::changeTable('admin_module'); // <<<< this doesnt work
  78.             // because adodb doesnt seem to generate valid SQL for a case where you dont already have an primary key already.  Need to drop and recreate instead.
  79.  
  80.             $pntable pnDBGetTables();
  81.             $result DBUtil::executeSQL("SELECT * FROM $pntable[admin_module]");
  82.             $objArray DBUtil::marshallObjects ($resultarray('mid''cid')true);
  83.             DBUtil::dropTable('admin_module');
  84.             DBUtil::createTable('admin_module');
  85.             DBUtil::insertObjectArray($objArray'admin_module''amid');
  86.             DBUtil::changeTable('admin_category');
  87.             break;
  88.     }
  89.     // Update successful
  90.     return true;
  91. }
  92.  
  93. /**
  94.  * delete the Admin module
  95.  * This function is only ever called once during the lifetime of a particular
  96.  * module instance
  97.  * @author Mark West
  98.  * @return bool true if deletetion succcesful, false otherwise
  99.  */
  100. function Admin_delete()
  101. {
  102.     if (!DBUtil::dropTable('admin_module')) {
  103.         return false;
  104.     }
  105.  
  106.     if (!DBUtil::dropTable('admin_category')) {
  107.         return false;
  108.     }
  109.  
  110.     pnModDelVar('Admin');
  111.  
  112.     // Deletion successful
  113.     return true;
  114. }
  115.  
  116. /**
  117.  * create the default data for the modules module
  118.  *
  119.  * This function is only ever called once during the lifetime of a particular
  120.  * module instance
  121.  *
  122.  * @author       Mark West
  123.  * @return       bool       false
  124.  */
  125. function Admin_defaultdata()
  126. {
  127.     $record array(array('catname'     => _ADMIN_CATEGORY_00_a,
  128.                           'description' => _ADMIN_CATEGORY_00_b),
  129.                     array('catname'     => _ADMIN_CATEGORY_01_a,
  130.                           'description' => _ADMIN_CATEGORY_01_b),
  131.                     array('catname'     => _ADMIN_CATEGORY_02_a,
  132.                           'description' => _ADMIN_CATEGORY_02_b),
  133.                     array('catname'     => _ADMIN_CATEGORY_03_a,
  134.                           'description' => _ADMIN_CATEGORY_03_b),
  135.                     array('catname'     => _ADMIN_CATEGORY_04_a,
  136.                           'description' => _ADMIN_CATEGORY_04_b),
  137.                     array('catname'     => _ADMIN_CATEGORY_05_a,
  138.                           'description' => _ADMIN_CATEGORY_05_b),
  139.                     array('catname'     => _ADMIN_CATEGORY_06_a,
  140.                           'description' => _ADMIN_CATEGORY_06_b));
  141.  
  142.     DBUtil::insertObjectArray($record'admin_category''cid');
  143. }

Documentation generated on Fri, 18 Jul 2008 21:53:18 +0200 by phpDocumentor 1.4.1