Exemplo n.º 1
0
 public static function includeModules($methods = array())
 {
     foreach ($methods as $val) {
         $ary = explode('::', $val);
         $module = $class = $ary[0];
         //$method = $ary[1];
         if (moduleloader::isInstalledModule($module)) {
             moduleloader::includeModule($module);
         }
     }
     return;
 }
 /**
  * Upgrade to a specific version of a module
  * @param float $specific, e.g. '5.06'
  * @return boolean $res
  */
 public function upgrade($specific = null)
 {
     // Only upgrade if module is installed
     if (!moduleloader::isInstalledModule($this->installInfo['NAME'])) {
         common::echoMessage("Notice: Can not upgrade. You will need to install module first");
         return;
     }
     // Get specific version
     if (!isset($specific)) {
         $specific = $this->installInfo['VERSION'];
     }
     // Get current module version from registry
     $row = $this->getModuleDbInfo();
     $current_version = $row['module_version'];
     // Same version. Return
     if ($current_version == $specific) {
         $this->confirm = "Module '" . $this->installInfo['NAME'] . "'. Version is '{$specific}'. No upgrade to perform";
         return true;
     }
     // Get a list of SQL updates to perform
     $updates = $this->getSqlFileListOrdered($this->installInfo['NAME'], 'up');
     // perform sql upgrade
     if (!empty($updates)) {
         foreach ($updates as $key => $val) {
             $possible_versions = '';
             $version = substr($val, 0, -4);
             if ($version == $specific) {
                 $version_exists = true;
             } else {
                 $possible_versions .= "{$version} ";
             }
         }
         if (!isset($version_exists)) {
             $this->error = 'Module SQL ' . $this->installInfo['NAME'] . " ";
             $this->error .= 'does not have such a version. Possible version are: ';
             $this->error .= $possible_versions;
         }
         // perform SQL updates found in .sql files
         foreach ($updates as $key => $val) {
             $version = substr($val, 0, -4);
             if ($current_version < $version) {
                 $this->executeSqlUpgrade($version);
             }
         }
     }
     // update registry
     $this->updateRegistry($specific, $row['id']);
     if ($specific > $current_version) {
         $this->confirm = "Module '" . $this->installInfo['NAME'] . "'. ";
         $this->confirm .= "Version '" . $specific . "' installed. ";
         $this->confirm .= "Upgraded from {$current_version}";
         return true;
     } else {
         $this->confirm = "Module '" . $this->installInfo['NAME'] . "'. Nothing to upgrade. Module version is still {$current_version}";
         return true;
     }
 }
Exemplo n.º 3
0
 /**
  * inits profile system. Include profile module
  */
 public static function initProfile()
 {
     if (!isset(self::$profile_object)) {
         $profile_system = conf::getMainIni('profile_module');
         if (!isset($profile_system) || !moduleloader::isInstalledModule($profile_system)) {
             self::$profile_object = new defaultProfile();
             return;
         } else {
             moduleloader::includeModule($profile_system);
             $class = "modules\\{$profile_system}\\module";
             self::$profile_object = new $class();
         }
     }
 }