コード例 #1
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;
        }
        
    }
コード例 #2
0
ファイル: ExternConfigDb.class.php プロジェクト: ratbird/hope
    /**
    *
    */
    function store () {
        parent::store();
        $serialized_config = serialize($this->config);

        if (strlen($serialized_config)) {
            $stmt = DBManager::get()->prepare("UPDATE extern_config 
                SET config = ?, chdate = UNIX_TIMESTAMP()
                WHERE config_id = ? AND range_id = ?");
            $stmt->execute($data = array($serialized_config, $this->id, $this->range_id));

            return($this->updateConfiguration());
        } else {
            ExternModule::printError();
            return FALSE;
        }
        
    }