Пример #1
0
 /**
 *
 */
 function parse () {
     $query = "SELECT config FROM extern_config WHERE config_id = ?";
     $parameters = array($this->id);
     $statement = DBManager::get()->prepare($query);
     $statement->execute($parameters);
     $row = $statement->fetchColumn();
     if ($row) {
         $this->config = unserialize(stripslashes($row));
     } else {
         ExternModule::printError();
     }
 }
Пример #2
0
    function setDefaultConfiguration ($config) {
        foreach ($config as $element_name => $element) {
            if (is_array($element)) foreach ($element as $attribute => $value) {
                if ((string)$value{0} == '|') {
                    $new_config[$element_name][$attribute] = explode('|', substr($value, 1));
                } else {
                    $new_config[$element_name][$attribute] = $value;
                }
            }
        }

        $this->id = $this->makeId();
        $this->config_name = $this->createConfigName($this->range_id);
        
        // take the new configuration, write the name in the configuration
        // insert it into the database and store it (method of storaging deepends on
        // object type)
        $this->config = $new_config;
        $this->setValue('Main', 'name', $this->config_name);
        if ($this->insertConfiguration()) {
            $this->store();
        } else {
            echo MessageBox::error(_("Sie haben die maximale Anzahl an Konfigurationen für dieses Modul erreicht! Kopieren fehlgeschlagen!"));
            ExternModule::printError();
        }
    }
Пример #3
0
    /**
    *
    */
    function store () {
        parent::store();
        if (!$this->file_name) {
            if ($this->id) {
                $this->file_name = $this->id . '.cfg';
            } else {
                return FALSE;
            }
        }
        $file_content = "; Configuration file for the extern module"
                . " $this->module_name in Stud.IP\n"
                . "; (range_id: $this->range_id)\n"
                . "; DO NOT EDIT !!!\n";
        
        foreach ($this->config as $element => $attributes) {
            $file_content .= "\n[" . $element . "]\n";
            foreach ($attributes as $attribute => $value) {
                if (is_array($value)) {
                    $value = '|' . implode('|', $value);
                }
                $file_content .= $attribute . " = \"" . $value . "\"\n";
            }
        }

        if ($file = @fopen($GLOBALS['EXTERN_CONFIG_FILE_PATH'] . $this->file_name, 'w')) {
            fputs($file, $file_content);
            fclose($file);
            return ($this->updateConfiguration());
        } else {
            ExternModule::printError();
            return FALSE;
        }
        
    }