1   <?php
  2   /**
  3   * @version      $Id: prerequisites.php 11891 2009-07-01 08:08:17Z alex $
  4   * @package      In-Bulletin
  5   * @copyright    Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
  6   * @license      GNU/GPL
  7   * In-Portal is Open Source software.
  8   * This means that this software may have been modified pursuant
  9   * the GNU General Public License, and as distributed it includes
  10   * or is derivative of works licensed under the GNU General Public License
  11   * or other free or open source software licenses.
  12   * See http://www.in-portal.net/license/ for copyright notices and details.
  13   */
  14           $prerequisite_class = 'InBulletinPrerequisites';
  15  
  16           /**
  17            * Class, that holds all prerequisite scripts for "In-Bulletin" module
  18            *
  19            */
  20           class InBulletinPrerequisites extends kHelper {
  21  
  22                   /**
  23                    * Install toolkit instance
  24                    *
  25                    * @var kInstallToolkit
  26                    */
  27                   var $_toolkit = null;
  28  
  29                   /**
  30                    * Sets common instance of installator toolkit
  31                    *
  32                    * @param kInstallToolkit $instance
  33                    */
  34                   function setToolkit(&$instance)
  35                   {
  36                           $this->_toolkit =& $instance;
  37                   }
  38  
  39                   /**
  40                    * Checks minimal version, that could be upgradeable
  41                    *
  42                    * @param string $mode when called mode {install, standalone, upgrade)
  43                    */
  44                   function CheckPrerequisites($versions, $mode)
  45                   {
  46                           $errors = Array ();
  47  
  48                           if ($mode == 'standalone') {
  49                                   if (!$this->Application->isModuleEnabled('In-Portal')) {
  50                                           $errors[] = 'Please install or enable "In-Portal" module first';
  51                                   }
  52                           }
  53  
  54                           if ($mode == 'upgrade') {
  55                                   $sql = 'SELECT Version
  56                                                   FROM ' . TABLE_PREFIX . 'Modules
  57                                                   WHERE Name = "In-Portal"';
  58                                   $inportal_version = $this->Conn->GetOne($sql);
  59  
  60                                   if ($inportal_version === false) {
  61                                           // only, when In-Portal was installed
  62                                           return $errors;
  63                                   }
  64  
  65                                   $min_version = '4.3.1';
  66  
  67                                   $current_version = $this->_toolkit->ConvertModuleVersion($inportal_version);
  68                                   $needed_version = $this->_toolkit->ConvertModuleVersion($min_version);
  69                                   if ($current_version < $needed_version) {
  70                                           $errors[] = 'Please upgrade "In-Portal" to version ' . $min_version;
  71                                   }
  72                           }
  73  
  74                           return $errors;
  75                   }
  76           }
  77  
  78   ?>