Zikula_Value_Addons
[ class tree: Zikula_Value_Addons ] [ index: Zikula_Value_Addons ] [ 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_Value_Addons
  10.  * @subpackage Banners
  11.  */
  12.  
  13. /**
  14.  * initialise the Banners module
  15.  * This function is only ever called once during the lifetime of a particular
  16.  * module instance
  17.  *
  18.  * @todo identify suitable indexes
  19.  * @author Devin Hayes
  20.  * @return bool true if successful, false otherwise
  21.  */
  22. function Banners_init()
  23. {
  24.     // create the three tables
  25.     $tables array('banners''bannersclient''bannersfinish');
  26.     foreach ($tables as $table{
  27.         if (!DBUtil::createTable($table)) {
  28.             return false;
  29.         }
  30.     }
  31.  
  32.     // migrate the old config vars into module vars
  33.     if (pnConfigGetVar('banners'!= ''){
  34.         $myIP pnConfigGetVar('myIP');
  35.         $banners pnConfigGetVar('banners');
  36.         pnModSetVar('Banners''myIP'$myIP);
  37.         pnModSetVar('Banners''banners'$banners);
  38.         pnConfigDelVar('myIP');
  39.         pnConfigDelVar('banners');
  40.     else {
  41.         pnModSetVar('Banners''myIP''127.0.0.1');
  42.         pnModSetVar('Banners''banners'false);
  43.     }
  44.     pnModSetVar('Banners''openinnewwindow'false);
  45.  
  46.     // Initialisation successful
  47.     return true;
  48. }
  49.  
  50. /**
  51.  * upgrade the Banners module from an old version
  52.  * This function can be called multiple times
  53.  * @author Devin Hayes
  54.  * @return bool true if successful, false otherwise
  55.  */
  56. function Banners_upgrade($oldversion)
  57. {
  58.     // create the three tables
  59.     $tables array('banners''bannersclient''bannersfinish');
  60.     foreach ($tables as $table{
  61.         if (!DBUtil::changeTable($table)) {
  62.             return false;
  63.         }
  64.     }
  65.  
  66.     // Upgrade dependent on old version number
  67.     switch($oldversion{
  68.         // version 1.0 was shipped with PN .7x
  69.         case 1.0:
  70.             // migrate the old config vars into module vars
  71.             if (pnConfigGetVar('banners'!= ''){
  72.                 $myIP pnConfigGetVar('myIP');
  73.                 $banners pnConfigGetVar('banners');
  74.                 pnModSetVar('Banners''myIP'$myIP);
  75.                 pnModSetVar('Banners''banners'$banners);
  76.                 pnModSetVar('Banners''openinnewwinow'false);
  77.                 pnConfigDelVar('myIP');
  78.                 pnConfigDelVar('banners');
  79.             }
  80.             break;
  81.     }
  82.  
  83.     // Update successful
  84.     return true;
  85. }
  86.  
  87. /**
  88.  * delete the Banners module
  89.  * This function is only ever called once during the lifetime of a particular
  90.  * module instance
  91.  * @author Devin Hayes
  92.  * @return bool true if successful, false otherwise
  93.  */
  94. function Banners_delete()
  95. {
  96.     // drop the three tables for the module
  97.     $tables array('banners''bannersclient''bannersfinish');
  98.     foreach ($tables as $table{
  99.         if (!DBUtil::dropTable($table)) {
  100.             return false;
  101.         }
  102.     }
  103.  
  104.     // delete all module vars
  105.     pnModDelVar('Banners');
  106.  
  107.     // Delete successful
  108.     return true;
  109. }

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