/** * Save mail server configurations * * @param array $data */ public static function saveConfig($data) { $config = self::getConfig(); $protocol = $data['protocol']['protocol']; $config['protocol']['protocol'] = $protocol; switch ($protocol) { case 'mail': if (isset($config['smtp'])) { unset($config['smtp']); } break; case 'smtp': $host = $data['smtp']['host']; if ($host == null || $host == '') { unset($config['smtp']['host']); } else { $config['smtp']['host'] = $host; } $port = $data['smtp']['port']; if ($port == null || $port == '') { unset($config['smtp']['port']); } else { $config['smtp']['port'] = $port; } if ($data['authentication'] == 'true') { $config['smtp']['username'] = $data['smtp']['username']; $config['smtp']['password'] = $data['smtp']['password']; } else { unset($config['smtp']['username']); unset($config['smtp']['password']); } $security = $data['smtp']['security']; if ($security != 'none') { $config['smtp']['security'] = $security; } break; } $content = Gio_Core_Array::toIni($config, true); /** * Write file */ $fileName = MOD_DIR . DS . 'mail' . DS . 'configs' . DS . 'config.ini'; return Gio_Core_File::writeToFile($fileName, $content); }