"Fossies" - the Fresh Open Source Software Archive

Member "4.6.1/db/migrations/03_step_87_extern_configurations.php" (8 Apr 2021, 2246 Bytes) of package /linux/www/studip-4.6.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 <?php
    2 require_once "lib/functions.php";
    3 require_once $GLOBALS["RELATIVE_PATH_EXTERN"]."/extern_config.inc.php";
    4 require_once $GLOBALS["RELATIVE_PATH_EXTERN"]."/lib/ExternConfig.class.php";
    5 require_once $GLOBALS["RELATIVE_PATH_EXTERN"]."/lib/ExternConfigIni.class.php";
    6 require_once $GLOBALS["RELATIVE_PATH_EXTERN"]."/lib/ExternConfigDb.class.php";
    7 
    8 
    9 class Step87ExternConfigurations extends Migration
   10 {
   11 
   12     public function description ()
   13     {
   14         return 'Extends table extern_config and converts configurations for the external pages from INI-style files to serialised arrays stored in the database.';
   15     }
   16 
   17     public function up ()
   18     {
   19         DBManager::get()->exec("ALTER TABLE `extern_config` ADD `config` MEDIUMTEXT NOT NULL AFTER `is_standard`");
   20 
   21         $configs = DBManager::get()->query("SELECT `range_id`, `config_id` FROM `extern_config`")->fetchAll(PDO::FETCH_ASSOC);
   22 
   23         $this->announce(" KONVERTIERUNG START ");
   24 
   25         $i = 0;
   26         foreach ($configs as $config) {
   27             $old_config = new ExternConfigIni($config['range_id'], '', $config['config_id']);
   28             $new_config = new ExternConfigDb($config['range_id'], '', $config['config_id']);
   29 
   30             $new_config->setConfiguration($old_config->getConfiguration());
   31 
   32             if ($new_config->store()) {
   33                 $this->write(sprintf("Konfiguration mit der id %s konvertiert!", $new_config->getId()));
   34                 $i++;
   35             } else {
   36                 $this->write(sprintf("FEHLER! Die Konfiguration mit der id %s konnte nicht konvertiert werden!", $config['config_id']));
   37             }
   38         }
   39 
   40         if (count($configs) == $i) {
   41             $this->write("Alle Konfigurationsdateien vermutlich fehlerfrei in die Datenbank uebertragen!");
   42             $this->write(sprintf("Es wurden %s Konfigurationsdateien uebertragen.", $i));
   43         } else {
   44             $this->write("Es wurden nicht alle Konfigurationsdateien uebertragen!");
   45             $this->write(sprintf("Es wurden %s Konfigurationsdateien von %s Konfigurationsdateien uebertragen!", $i, count($configs)));
   46             $this->write("Bitte die fehlerhaften Konfigurationen manuell ueberpruefen.");
   47         }
   48 
   49         $this->announce(" KONVERTIERUNG ENDE ");
   50 
   51     }
   52 }