diff --git a/CoreVersions/Baikal_0.1/Distrib.php b/CoreVersions/Baikal_0.1/Distrib.php
index 0d47c38..01cc894 100755
--- a/CoreVersions/Baikal_0.1/Distrib.php
+++ b/CoreVersions/Baikal_0.1/Distrib.php
@@ -24,5 +24,5 @@
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
-define("BAIKAL_VERSION", "0.2");
+define("BAIKAL_VERSION", "0.2.0");
define("BAIKAL_HOMEPAGE", "http://baikal.codr.fr");
\ No newline at end of file
diff --git a/CoreVersions/Baikal_0.1/Frameworks/Baikal/Core/Bootstrap.php b/CoreVersions/Baikal_0.1/Frameworks/Baikal/Core/Bootstrap.php
index cb16195..76408a9 100644
--- a/CoreVersions/Baikal_0.1/Frameworks/Baikal/Core/Bootstrap.php
+++ b/CoreVersions/Baikal_0.1/Frameworks/Baikal/Core/Bootstrap.php
@@ -24,6 +24,49 @@
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
+
+function rmBeginSlash($sString) {
+ if(substr($sString, 0, 1) === "/") {
+ $sString = substr($sString, 1);
+ }
+
+ return $sString;
+}
+
+function rmEndSlash($sString) {
+ if(substr($sString, -1) === "/") {
+ $sString = substr($sString, 0, -1);
+ }
+
+ return $sString;
+}
+
+function appendSlash($sString) {
+ if(substr($sString, -1) !== "/") {
+ $sString .= "/";
+ }
+
+ return $sString;
+}
+
+function prependSlash($sString) {
+ if(substr($sString, 0, 1) !== "/") {
+ $sString = "/" . $sString;
+ }
+
+ return $sString;
+}
+
+function installTool() {
+ if(defined("BAIKAL_CONTEXT_INSTALL") && BAIKAL_CONTEXT_INSTALL === TRUE) {
+ return;
+ } else {
+ $sInstallToolUrl = prependSlash($sBaseUrl . "admin/install/");
+ header("Location: " . $sInstallToolUrl);
+ exit(0);
+ }
+}
+
if(!defined("BAIKAL_CONTEXT") || BAIKAL_CONTEXT !== TRUE) {
die("Bootstrap.php may not be included outside the Baikal context");
}
@@ -55,41 +98,58 @@ define("BAIKAL_PATH_SPECIFIC", BAIKAL_PATH_ROOT . "Specific/");
define("BAIKAL_PATH_FRAMEWORKS", BAIKAL_PATH_CORE . "Frameworks/");
define("BAIKAL_PATH_WWWROOT", BAIKAL_PATH_CORE . "WWWRoot/");
-require_once(BAIKAL_PATH_SPECIFIC . "config.php");
-require_once(BAIKAL_PATH_SPECIFIC . "config.system.php");
+require_once(BAIKAL_PATH_CORE . "Distrib.php");
-date_default_timezone_set(BAIKAL_TIMEZONE);
+# Determine BAIKAL_URI
+#print_r($_SERVER);
+$sScript = substr($_SERVER["SCRIPT_FILENAME"], strlen($_SERVER["DOCUMENT_ROOT"]));
+$sDirName = appendSlash(dirname($sScript));
+$sBaseUrl = appendSlash(substr($sDirName, 0, -1 * strlen(BAIKAL_CONTEXT_BASEURI)));
+$aParts = explode("/", $_SERVER["SERVER_PROTOCOL"]);
+$sProtocol = strtolower(array_shift($aParts));
+define("BAIKAL_URI", $sProtocol . "://" . rmEndSlash($_SERVER["HTTP_HOST"]) . $sBaseUrl);
+unset($sScript); unset($sDirName); unset($sBaseUrl); unset($sProtocol); unset($aParts);
-# Check if DB exists
-if(!file_exists(BAIKAL_SQLITE_FILE)) {
- die("DB file does not exist.
To create it, please copy 'Core/Resources/baikal.empty.sqlite' to 'Specific/db/baikal.sqlite'.
Please note the change in the file name while doing so (from 'baikal.empty.sqlite' to 'baikal.sqlite').");
-}
-
-# Database
-$pdo = new PDO('sqlite:' . BAIKAL_SQLITE_FILE);
-$pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
-
-$bShouldCheckEnv = ((!defined("BAIKAL_CONTEXT_CLI") || BAIKAL_CONTEXT_CLI === FALSE) && (!defined("BAIKAL_CONTEXT_ADMIN") || BAIKAL_CONTEXT_ADMIN === FALSE));
-
-# Check if at least one user exists
-if($bShouldCheckEnv === TRUE) {
- if(($iNbUsers = intval($pdo->query('SELECT count(*) FROM users')->fetchColumn())) === 0) {
- die("No users are defined.
To create a user, you can use the helper Core/Scripts/adduser.php (requires command line access)");
- }
-}
-
-if($bShouldCheckEnv === TRUE) {
- # Mapping PHP errors to exceptions
- function exception_error_handler($errno, $errstr, $errfile, $errline) {
- throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
- }
-
- set_error_handler("exception_error_handler");
+# Check that a config file exists
+if(
+ !file_exists(BAIKAL_PATH_SPECIFIC . "config.php") ||
+ !file_exists(BAIKAL_PATH_SPECIFIC . "config.system.php")
+) {
+ installTool();
} else {
- error_reporting(E_ALL ^ E_NOTICE);
-}
+ require_once(BAIKAL_PATH_SPECIFIC . "config.php");
+ require_once(BAIKAL_PATH_SPECIFIC . "config.system.php");
+ date_default_timezone_set(BAIKAL_TIMEZONE);
-unset($bShouldCheckEnv);
-// Autoloader
-require_once(BAIKAL_PATH_SABREDAV . 'autoload.php');
+ if(version_compare(BAIKAL_VERSION, BAIKAL_CONFIGURED_VERSION) > 0) {
+ installTool();
+ } else {
+ # Check if DB exists
+ if(!file_exists(BAIKAL_SQLITE_FILE)) {
+ die("DB file does not exist.
To create it, please copy 'Core/Resources/baikal.empty.sqlite' to 'Specific/db/baikal.sqlite'.
Please note the change in the file name while doing so (from 'baikal.empty.sqlite' to 'baikal.sqlite').");
+ }
+
+ # Database
+ $pdo = new PDO('sqlite:' . BAIKAL_SQLITE_FILE);
+ $pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
+
+ $bShouldCheckEnv = ((!defined("BAIKAL_CONTEXT_CLI") || BAIKAL_CONTEXT_CLI === FALSE) && (!defined("BAIKAL_CONTEXT_ADMIN") || BAIKAL_CONTEXT_ADMIN === FALSE));
+
+ if($bShouldCheckEnv === TRUE) {
+ # Mapping PHP errors to exceptions
+ function exception_error_handler($errno, $errstr, $errfile, $errline) {
+ throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
+ }
+
+ set_error_handler("exception_error_handler");
+ } else {
+ error_reporting(E_ALL ^ E_NOTICE);
+ }
+
+ unset($bShouldCheckEnv);
+
+ // Autoloader
+ require_once(BAIKAL_PATH_SABREDAV . 'autoload.php');
+ }
+}
\ No newline at end of file
diff --git a/CoreVersions/Baikal_0.1/Frameworks/Baikal/Core/Tools.php b/CoreVersions/Baikal_0.1/Frameworks/Baikal/Core/Tools.php
index 14067c4..9fa1f56 100644
--- a/CoreVersions/Baikal_0.1/Frameworks/Baikal/Core/Tools.php
+++ b/CoreVersions/Baikal_0.1/Frameworks/Baikal/Core/Tools.php
@@ -46,7 +46,7 @@ class Tools {
return $aUsers;
}
- static function bashPrompt($prompt) {
+ public static function bashPrompt($prompt) {
print $prompt;
@flush();
@ob_flush();
@@ -54,7 +54,7 @@ class Tools {
return $confirmation;
}
- static function bashPromptSilent($prompt = "Enter Password:") {
+ public static function bashPromptSilent($prompt = "Enter Password:") {
$command = "/usr/bin/env bash -c 'echo OK'";
if(rtrim(shell_exec($command)) !== 'OK') {
@@ -70,4 +70,419 @@ class Tools {
echo "\n";
return $password;
}
+
+ public static function timezones() {
+ $aZones = array(
+ "Africa/Abidjan",
+ "Africa/Accra",
+ "Africa/Addis_Ababa",
+ "Africa/Algiers",
+ "Africa/Asmara",
+ "Africa/Bamako",
+ "Africa/Bangui",
+ "Africa/Banjul",
+ "Africa/Bissau",
+ "Africa/Blantyre",
+ "Africa/Brazzaville",
+ "Africa/Bujumbura",
+ "Africa/Cairo",
+ "Africa/Casablanca",
+ "Africa/Ceuta",
+ "Africa/Conakry",
+ "Africa/Dakar",
+ "Africa/Dar_es_Salaam",
+ "Africa/Djibouti",
+ "Africa/Douala",
+ "Africa/El_Aaiun",
+ "Africa/Freetown",
+ "Africa/Gaborone",
+ "Africa/Harare",
+ "Africa/Johannesburg",
+ "Africa/Juba",
+ "Africa/Kampala",
+ "Africa/Khartoum",
+ "Africa/Kigali",
+ "Africa/Kinshasa",
+ "Africa/Lagos",
+ "Africa/Libreville",
+ "Africa/Lome",
+ "Africa/Luanda",
+ "Africa/Lubumbashi",
+ "Africa/Lusaka",
+ "Africa/Malabo",
+ "Africa/Maputo",
+ "Africa/Maseru",
+ "Africa/Mbabane",
+ "Africa/Mogadishu",
+ "Africa/Monrovia",
+ "Africa/Nairobi",
+ "Africa/Ndjamena",
+ "Africa/Niamey",
+ "Africa/Nouakchott",
+ "Africa/Ouagadougou",
+ "Africa/Porto-Novo",
+ "Africa/Sao_Tome",
+ "Africa/Tripoli",
+ "Africa/Tunis",
+ "Africa/Windhoek",
+ "America/Adak",
+ "America/Anchorage",
+ "America/Anguilla",
+ "America/Antigua",
+ "America/Araguaina",
+ "America/Argentina/Buenos_Aires",
+ "America/Argentina/Catamarca",
+ "America/Argentina/Cordoba",
+ "America/Argentina/Jujuy",
+ "America/Argentina/La_Rioja",
+ "America/Argentina/Mendoza",
+ "America/Argentina/Rio_Gallegos",
+ "America/Argentina/Salta",
+ "America/Argentina/San_Juan",
+ "America/Argentina/San_Luis",
+ "America/Argentina/Tucuman",
+ "America/Argentina/Ushuaia",
+ "America/Aruba",
+ "America/Asuncion",
+ "America/Atikokan",
+ "America/Bahia",
+ "America/Barbados",
+ "America/Belem",
+ "America/Belize",
+ "America/Blanc-Sablon",
+ "America/Boa_Vista",
+ "America/Bogota",
+ "America/Boise",
+ "America/Cambridge_Bay",
+ "America/Campo_Grande",
+ "America/Cancun",
+ "America/Caracas",
+ "America/Cayenne",
+ "America/Cayman",
+ "America/Chicago",
+ "America/Chihuahua",
+ "America/Costa_Rica",
+ "America/Cuiaba",
+ "America/Curacao",
+ "America/Danmarkshavn",
+ "America/Dawson",
+ "America/Dawson_Creek",
+ "America/Denver",
+ "America/Detroit",
+ "America/Dominica",
+ "America/Edmonton",
+ "America/Eirunepe",
+ "America/El_Salvador",
+ "America/Felipe_Carrillo",
+ "America/Fortaleza",
+ "America/Glace_Bay",
+ "America/Godthab",
+ "America/Goose_Bay",
+ "America/Grand_Turk",
+ "America/Grenada",
+ "America/Guadeloupe",
+ "America/Guatemala",
+ "America/Guayaquil",
+ "America/Guyana",
+ "America/Halifax",
+ "America/Havana",
+ "America/Hermosillo",
+ "America/Indiana/Indianapolis",
+ "America/Indiana/Knox",
+ "America/Indiana/Marengo",
+ "America/Indiana/Petersburg",
+ "America/Indiana/Tell_City",
+ "America/Indiana/Vevay",
+ "America/Indiana/Vincennes",
+ "America/Indiana/Winamac",
+ "America/Inuvik",
+ "America/Iqaluit",
+ "America/Jamaica",
+ "America/Juneau",
+ "America/Kentucky/Louisville",
+ "America/Kentucky/Monticello",
+ "America/La_Paz",
+ "America/Lima",
+ "America/Los_Angeles",
+ "America/Maceio",
+ "America/Managua",
+ "America/Manaus",
+ "America/Marigot",
+ "America/Martinique",
+ "America/Matamoros",
+ "America/Mazatlan",
+ "America/Menominee",
+ "America/Merida",
+ "America/Mexico_City",
+ "America/Miquelon",
+ "America/Moncton",
+ "America/Monterrey",
+ "America/Montevideo",
+ "America/Montreal",
+ "America/Montserrat",
+ "America/Nassau",
+ "America/New_York",
+ "America/Nipigon",
+ "America/Nome",
+ "America/Noronha",
+ "America/North_Dakota/Center",
+ "America/North_Dakota/New_Salem",
+ "America/Ojinaga",
+ "America/Panama",
+ "America/Pangnirtung",
+ "America/Paramaribo",
+ "America/Phoenix",
+ "America/Port-au-Prince",
+ "America/Porto_Velho",
+ "America/Port_of_Spain",
+ "America/Puerto_Rico",
+ "America/Rainy_River",
+ "America/Rankin_Inlet",
+ "America/Recife",
+ "America/Regina",
+ "America/Resolute",
+ "America/Rio_Branco",
+ "America/Santarem",
+ "America/Santa_Isabel",
+ "America/Santiago",
+ "America/Santo_Domingo",
+ "America/Sao_Paulo",
+ "America/Scoresbysund",
+ "America/Shiprock",
+ "America/St_Barthelemy",
+ "America/St_Johns",
+ "America/St_Kitts",
+ "America/St_Lucia",
+ "America/St_Thomas",
+ "America/St_Vincent",
+ "America/Swift_Current",
+ "America/Tegucigalpa",
+ "America/Thule",
+ "America/Thunder_Bay",
+ "America/Tijuana",
+ "America/Toronto",
+ "America/Tortola",
+ "America/Vancouver",
+ "America/Whitehorse",
+ "America/Winnipeg",
+ "America/Yakutat",
+ "America/Yellowknife",
+ "Antarctica/Casey",
+ "Antarctica/Davis",
+ "Antarctica/DumontDUrville",
+ "Antarctica/Mawson",
+ "Antarctica/McMurdo",
+ "Antarctica/Palmer",
+ "Antarctica/Rothera",
+ "Antarctica/South_Pole",
+ "Antarctica/Syowa",
+ "Antarctica/Vostok",
+ "Arctic/Longyearbyen",
+ "Asia/Aden",
+ "Asia/Almaty",
+ "Asia/Amman",
+ "Asia/Anadyr",
+ "Asia/Aqtau",
+ "Asia/Aqtobe",
+ "Asia/Ashgabat",
+ "Asia/Baghdad",
+ "Asia/Bahrain",
+ "Asia/Baku",
+ "Asia/Bangkok",
+ "Asia/Beirut",
+ "Asia/Bishkek",
+ "Asia/Brunei",
+ "Asia/Choibalsan",
+ "Asia/Chongqing",
+ "Asia/Colombo",
+ "Asia/Damascus",
+ "Asia/Dhaka",
+ "Asia/Dili",
+ "Asia/Dubai",
+ "Asia/Dushanbe",
+ "Asia/Gaza",
+ "Asia/Harbin",
+ "Asia/Hong_Kong",
+ "Asia/Hovd",
+ "Asia/Ho_Chi_Minh",
+ "Asia/Irkutsk",
+ "Asia/Jakarta",
+ "Asia/Jayapura",
+ "Asia/Jerusalem",
+ "Asia/Kabul",
+ "Asia/Kamchatka",
+ "Asia/Karachi",
+ "Asia/Kashgar",
+ "Asia/Kathmandu",
+ "Asia/Kolkata",
+ "Asia/Krasnoyarsk",
+ "Asia/Kuala_Lumpur",
+ "Asia/Kuching",
+ "Asia/Kuwait",
+ "Asia/Macau",
+ "Asia/Magadan",
+ "Asia/Makassar",
+ "Asia/Manila",
+ "Asia/Muscat",
+ "Asia/Nicosia",
+ "Asia/Novokuznetsk",
+ "Asia/Novosibirsk",
+ "Asia/Omsk",
+ "Asia/Oral",
+ "Asia/Phnom_Penh",
+ "Asia/Pontianak",
+ "Asia/Pyongyang",
+ "Asia/Qatar",
+ "Asia/Qyzylorda",
+ "Asia/Rangoon",
+ "Asia/Riyadh",
+ "Asia/Sakhalin",
+ "Asia/Samarkand",
+ "Asia/Seoul",
+ "Asia/Shanghai",
+ "Asia/Singapore",
+ "Asia/Taipei",
+ "Asia/Tashkent",
+ "Asia/Tbilisi",
+ "Asia/Tehran",
+ "Asia/Thimphu",
+ "Asia/Tokyo",
+ "Asia/Ulaanbaatar",
+ "Asia/Urumqi",
+ "Asia/Vientiane",
+ "Asia/Vladivostok",
+ "Asia/Yakutsk",
+ "Asia/Yekaterinburg",
+ "Asia/Yerevan",
+ "Atlantic/Azores",
+ "Atlantic/Bermuda",
+ "Atlantic/Canary",
+ "Atlantic/Cape_Verde",
+ "Atlantic/Faroe",
+ "Atlantic/Madeira",
+ "Atlantic/Reykjavik",
+ "Atlantic/South_Georgia",
+ "Atlantic/Stanley",
+ "Atlantic/St_Helena",
+ "Australia/Adelaide",
+ "Australia/Brisbane",
+ "Australia/Broken_Hill",
+ "Australia/Currie",
+ "Australia/Darwin",
+ "Australia/Eucla",
+ "Australia/Hobart",
+ "Australia/Lindeman",
+ "Australia/Lord_Howe",
+ "Australia/Melbourne",
+ "Australia/Perth",
+ "Australia/Sydney",
+ "Europe/Amsterdam",
+ "Europe/Andorra",
+ "Europe/Athens",
+ "Europe/Belgrade",
+ "Europe/Berlin",
+ "Europe/Bratislava",
+ "Europe/Brussels",
+ "Europe/Bucharest",
+ "Europe/Budapest",
+ "Europe/Chisinau",
+ "Europe/Copenhagen",
+ "Europe/Dublin",
+ "Europe/Gibraltar",
+ "Europe/Guernsey",
+ "Europe/Helsinki",
+ "Europe/Isle_of_Man",
+ "Europe/Istanbul",
+ "Europe/Jersey",
+ "Europe/Kaliningrad",
+ "Europe/Kiev",
+ "Europe/Lisbon",
+ "Europe/Ljubljana",
+ "Europe/London",
+ "Europe/Luxembourg",
+ "Europe/Madrid",
+ "Europe/Malta",
+ "Europe/Mariehamn",
+ "Europe/Minsk",
+ "Europe/Monaco",
+ "Europe/Moscow",
+ "Europe/Oslo",
+ "Europe/Paris",
+ "Europe/Podgorica",
+ "Europe/Prague",
+ "Europe/Riga",
+ "Europe/Rome",
+ "Europe/Samara",
+ "Europe/San_Marino",
+ "Europe/Sarajevo",
+ "Europe/Simferopol",
+ "Europe/Skopje",
+ "Europe/Sofia",
+ "Europe/Stockholm",
+ "Europe/Tallinn",
+ "Europe/Tirane",
+ "Europe/Uzhgorod",
+ "Europe/Vaduz",
+ "Europe/Vatican",
+ "Europe/Vienna",
+ "Europe/Vilnius",
+ "Europe/Volgograd",
+ "Europe/Warsaw",
+ "Europe/Zagreb",
+ "Europe/Zaporozhye",
+ "Europe/Zurich",
+ "Indian/Antananarivo",
+ "Indian/Chagos",
+ "Indian/Christmas",
+ "Indian/Cocos",
+ "Indian/Comoro",
+ "Indian/Kerguelen",
+ "Indian/Mahe",
+ "Indian/Maldives",
+ "Indian/Mauritius",
+ "Indian/Mayotte",
+ "Indian/Reunion",
+ "Pacific/Apia",
+ "Pacific/Auckland",
+ "Pacific/Chatham",
+ "Pacific/Easter",
+ "Pacific/Efate",
+ "Pacific/Enderbury",
+ "Pacific/Fakaofo",
+ "Pacific/Fiji",
+ "Pacific/Funafuti",
+ "Pacific/Galapagos",
+ "Pacific/Gambier",
+ "Pacific/Guadalcanal",
+ "Pacific/Guam",
+ "Pacific/Honolulu",
+ "Pacific/Johnston",
+ "Pacific/Kiritimati",
+ "Pacific/Kosrae",
+ "Pacific/Kwajalein",
+ "Pacific/Majuro",
+ "Pacific/Marquesas",
+ "Pacific/Midway",
+ "Pacific/Nauru",
+ "Pacific/Niue",
+ "Pacific/Norfolk",
+ "Pacific/Noumea",
+ "Pacific/Pago_Pago",
+ "Pacific/Palau",
+ "Pacific/Pitcairn",
+ "Pacific/Ponape",
+ "Pacific/Port_Moresby",
+ "Pacific/Rarotonga",
+ "Pacific/Saipan",
+ "Pacific/Tahiti",
+ "Pacific/Tarawa",
+ "Pacific/Tongatapu",
+ "Pacific/Truk",
+ "Pacific/Wake",
+ "Pacific/Wallis",
+ );
+
+ reset($aZones);
+ return $aZones;
+ }
}
\ No newline at end of file
diff --git a/CoreVersions/Baikal_0.1/Frameworks/Baikal/Model/Config.php b/CoreVersions/Baikal_0.1/Frameworks/Baikal/Model/Config.php
index 362f8bc..3d6629c 100644
--- a/CoreVersions/Baikal_0.1/Frameworks/Baikal/Model/Config.php
+++ b/CoreVersions/Baikal_0.1/Frameworks/Baikal/Model/Config.php
@@ -26,49 +26,12 @@
namespace Baikal\Model;
-class Config extends \Flake\Core\Model\NoDb {
-
+abstract class Config extends \Flake\Core\Model\NoDb {
+
protected $sConfigFilePath = "";
- protected $aConstants = array(
- "BAIKAL_TIMEZONE" => array(
- "type" => "string",
- ),
-# "BAIKAL_URI" => array(
-# "type" => "string",
-# ),
- "BAIKAL_CARD_ENABLED" => array(
- "type" => "boolean",
- ),
- "BAIKAL_CAL_ENABLED" => array(
- "type" => "boolean",
- ),
- "BAIKAL_ADMIN_ENABLED" => array(
- "type" => "boolean",
- ),
- "BAIKAL_STANDALONE_ALLOWED" => array(
- "type" => "boolean",
- ),
- "BAIKAL_STANDALONE_PORT" => array(
- "type" => "integer",
- ),
- "BAIKAL_ADMIN_PASSWORDHASH" => array(
- "type" => "string",
- )
- );
-
- protected $aData = array(
- "BAIKAL_TIMEZONE" => "",
- "BAIKAL_CARD_ENABLED" => "",
- "BAIKAL_CAL_ENABLED" => "",
- "BAIKAL_TIMEZONE" => "",
- "BAIKAL_CARD_ENABLED" => "",
- "BAIKAL_CAL_ENABLED" => "",
- "BAIKAL_ADMIN_ENABLED" => "",
- "BAIKAL_STANDALONE_ALLOWED" => "",
- "BAIKAL_STANDALONE_PORT" => "",
- "BAIKAL_ADMIN_PASSWORDHASH" => ""
- );
-
+ protected $aConstants = array();
+ protected $aData = array();
+
public function __construct($sConfigFilePath) {
# Note: no call to parent::__construct() to avoid erasing $this->aData
$this->sConfigFilePath = $sConfigFilePath;
@@ -82,32 +45,32 @@ class Config extends \Flake\Core\Model\NoDb {
}
}
}
-
+
protected function getConfigAsString() {
$sContent = file_get_contents($this->sConfigFilePath);
return str_replace(LF . CR, LF, $sContent);
}
-
+
protected function parseConfig($sString) {
-
+
$aRes = array();
-
+
foreach(array_keys($this->aConstants) as $sConstant) {
$aConstant = $this->aConstants[$sConstant];
-
+
$aMatches = array();
$sPattern = '/\s*define\(\s*["|\']' . $sConstant . '["|\']\s*\,\s*(.*?)\s*\);\s*/ix';
-
+
$iNbRes = preg_match_all(
$sPattern,
$sString,
$aMatches
);
-
+
if($iNbRes === 1) {
# Exactly one match
# O would be not enough, and > 1, to much to handle properly
-
+
$sValue = $aMatches[1][0]; # first capture (.*?), first occurence (anyway, we asserted that there's only one)
switch($aConstant["type"]) {
case "string": {
@@ -126,22 +89,26 @@ class Config extends \Flake\Core\Model\NoDb {
}
break;
}
+ case "litteral": {
+ $sValue = trim($sValue);
+ break;
+ }
default: {
# nothing
break;
}
}
-
+
$aRes[$sConstant] = $sValue;
} elseif($iNbRes === 0) {
throw new \Exception("Baikal\Model\Config->parseConfig(): Unable to find constant '" . $prop . "' in config file");
}
}
-
+
reset($aRes);
return $aRes;
}
-
+
public function writable() {
return (
@file_exists($this->sConfigFilePath) &&
@@ -149,103 +116,37 @@ class Config extends \Flake\Core\Model\NoDb {
@is_writable($this->sConfigFilePath)
);
}
-
- public function formMorphologyForThisModelInstance() {
- $oMorpho = new \Formal\Form\Morphology();
-
- $oMorpho->add(new \Formal\Element\Listbox(array(
- "prop" => "BAIKAL_TIMEZONE",
- "label" => "Time zone",
- "validation" => "required",
- "options" => self::timezones(),
- "help" => "Time zone of the server",
- "popover" => array(
- "title" => "Time zone",
- "content" => "Time zone of the server",
- ),
- )));
-
- $oMorpho->add(new \Formal\Element\Checkbox(array(
- "prop" => "BAIKAL_CARD_ENABLED",
- "label" => "Enable CardDAV"
- )));
-
- $oMorpho->add(new \Formal\Element\Checkbox(array(
- "prop" => "BAIKAL_CAL_ENABLED",
- "label" => "Enable CalDAV"
- )));
-
- $oMorpho->add(new \Formal\Element\Checkbox(array(
- "prop" => "BAIKAL_ADMIN_ENABLED",
- "label" => "Enable Web Admin",
- "popover" => array(
- "title" => "Warning !",
- "content" => "If disabled, you'll lose access to this very admin interface !",
- ),
- )));
-
- $oMorpho->add(new \Formal\Element\Checkbox(array(
- "prop" => "BAIKAL_STANDALONE_ALLOWED",
- "label" => "Allow Standalone Baïkal execution"
- )));
-
- $oMorpho->add(new \Formal\Element\Text(array(
- "prop" => "BAIKAL_STANDALONE_PORT",
- "label" => "Standalone Baïkal port"
- )));
-
- $sNotice = "-- Leave empty to keep current password --";
- $oMorpho->add(new \Formal\Element\Password(array(
- "prop" => "BAIKAL_ADMIN_PASSWORDHASH",
- "label" => "Web admin password",
- "placeholder" => $sNotice,
- )));
-
- $oMorpho->add(new \Formal\Element\Password(array(
- "prop" => "BAIKAL_ADMIN_PASSWORDHASH_CONFIRM",
- "label" => "Web admin password confirmation",
- "placeholder" => $sNotice,
- "validation" => "sameas:BAIKAL_ADMIN_PASSWORDHASH",
- )));
-
-
- return $oMorpho;
- }
-
+
public static function icon() {
return "icon-cog";
}
-
+
public static function mediumicon() {
return "glyph-cogwheel";
}
-
+
public static function bigicon() {
return "glyph2x-cogwheel";
}
- public function label() {
- return "Baïkal Settings";
- }
-
public function floating() {
return FALSE;
}
-
+
public function persist() {
$aLines = explode(LF, $this->getConfigAsString());
-
+
foreach(array_keys($this->aData) as $prop) {
$iLines = count($aLines);
$sPattern = '/\s*define\(\s*["|\']' . $prop . '["|\']\s*\,\s*(.*?)\s*\);\s*/ix';
-
+
for($k = ($iLines - 1); $k >= 0; $k--) {
if(preg_match($sPattern, $aLines[$k])) {
# Found the last matching line
-
+
$sValue = $this->aData[$prop];
$bCalculated = (isset($this->aConstants[$prop]["type"]["calculated"]) && $this->aConstants[$prop]["type"]["calculated"] === TRUE);
-
+
switch($this->aConstants[$prop]["type"]) {
case "string": {
$sValue = '"' . addcslashes($sValue, "\"\\\0\n\r") . '"'; # Add quotes, and escape " and all string-termination chars
@@ -256,13 +157,17 @@ class Config extends \Flake\Core\Model\NoDb {
break;
}
case "boolean": {
-
+
if(intval($sValue) === 1) { # Note as a BOOLEAN PHP constant
$sValue = "TRUE";
} else {
$sValue = "FALSE";
}
-
+
+ break;
+ }
+ case "litteral": {
+ $sValue = trim($sValue);
break;
}
default: {
@@ -270,14 +175,14 @@ class Config extends \Flake\Core\Model\NoDb {
break;
}
}
-
+
$aLines[$k] = "define(\"" . $prop . "\", " . $sValue . ");";
}
}
}
-
+
$sLines = implode("\n", $aLines);
-
+
$sSandboxedCode = str_replace(array(""), "", $sLines);
$sRand = (string)rand();
$sCode = "if(0) {" . $sSandboxedCode . "}; echo '" . $sRand . "';";
@@ -285,7 +190,7 @@ class Config extends \Flake\Core\Model\NoDb {
eval($sCode);
$sRes = ob_get_contents();
ob_end_clean();
-
+
if($sRes !== $sRand) {
throw new \Exception("Parse error in new config file. Aborting, nothing has been changed.");
}
@@ -294,458 +199,18 @@ class Config extends \Flake\Core\Model\NoDb {
# We now check that all the constants are present, and with the right value
$aNewConfig = $this->parseConfig($sLines);
$aWrittenConfig = $this->aData;
-
+
asort($aNewConfig);
asort($aWrittenConfig);
-
+
if($aNewConfig != $aWrittenConfig) {
throw new \Exception("New config does not correspond to expected config. Aborting, nothing has been changed.");
}
-
+
file_put_contents($this->sConfigFilePath, $sLines);
}
- public function set($sProp, $sValue) {
- if($sProp === "BAIKAL_ADMIN_PASSWORDHASH" || $sProp === "BAIKAL_ADMIN_PASSWORDHASH_CONFIRM") {
- # Special handling for password and passwordconfirm
-
- if($sProp === "BAIKAL_ADMIN_PASSWORDHASH" && $sValue !== "") {
- parent::set(
- "BAIKAL_ADMIN_PASSWORDHASH",
- \BaikalAdmin\Core\Auth::hashAdminPassword($sValue)
- );
- }
-
- return $this;
- }
-
- parent::set($sProp, $sValue);
- }
-
- public function get($sProp) {
- if($sProp === "BAIKAL_ADMIN_PASSWORDHASH" || $sProp === "BAIKAL_ADMIN_PASSWORDHASH_CONFIRM") {
- return "";
- }
-
- return parent::get($sProp);
- }
-
public function destroy() {
-
- }
-
- protected static function timezones() {
- $aZones = array(
- "Africa/Abidjan",
- "Africa/Accra",
- "Africa/Addis_Ababa",
- "Africa/Algiers",
- "Africa/Asmara",
- "Africa/Bamako",
- "Africa/Bangui",
- "Africa/Banjul",
- "Africa/Bissau",
- "Africa/Blantyre",
- "Africa/Brazzaville",
- "Africa/Bujumbura",
- "Africa/Cairo",
- "Africa/Casablanca",
- "Africa/Ceuta",
- "Africa/Conakry",
- "Africa/Dakar",
- "Africa/Dar_es_Salaam",
- "Africa/Djibouti",
- "Africa/Douala",
- "Africa/El_Aaiun",
- "Africa/Freetown",
- "Africa/Gaborone",
- "Africa/Harare",
- "Africa/Johannesburg",
- "Africa/Juba",
- "Africa/Kampala",
- "Africa/Khartoum",
- "Africa/Kigali",
- "Africa/Kinshasa",
- "Africa/Lagos",
- "Africa/Libreville",
- "Africa/Lome",
- "Africa/Luanda",
- "Africa/Lubumbashi",
- "Africa/Lusaka",
- "Africa/Malabo",
- "Africa/Maputo",
- "Africa/Maseru",
- "Africa/Mbabane",
- "Africa/Mogadishu",
- "Africa/Monrovia",
- "Africa/Nairobi",
- "Africa/Ndjamena",
- "Africa/Niamey",
- "Africa/Nouakchott",
- "Africa/Ouagadougou",
- "Africa/Porto-Novo",
- "Africa/Sao_Tome",
- "Africa/Tripoli",
- "Africa/Tunis",
- "Africa/Windhoek",
- "America/Adak",
- "America/Anchorage",
- "America/Anguilla",
- "America/Antigua",
- "America/Araguaina",
- "America/Argentina/Buenos_Aires",
- "America/Argentina/Catamarca",
- "America/Argentina/Cordoba",
- "America/Argentina/Jujuy",
- "America/Argentina/La_Rioja",
- "America/Argentina/Mendoza",
- "America/Argentina/Rio_Gallegos",
- "America/Argentina/Salta",
- "America/Argentina/San_Juan",
- "America/Argentina/San_Luis",
- "America/Argentina/Tucuman",
- "America/Argentina/Ushuaia",
- "America/Aruba",
- "America/Asuncion",
- "America/Atikokan",
- "America/Bahia",
- "America/Barbados",
- "America/Belem",
- "America/Belize",
- "America/Blanc-Sablon",
- "America/Boa_Vista",
- "America/Bogota",
- "America/Boise",
- "America/Cambridge_Bay",
- "America/Campo_Grande",
- "America/Cancun",
- "America/Caracas",
- "America/Cayenne",
- "America/Cayman",
- "America/Chicago",
- "America/Chihuahua",
- "America/Costa_Rica",
- "America/Cuiaba",
- "America/Curacao",
- "America/Danmarkshavn",
- "America/Dawson",
- "America/Dawson_Creek",
- "America/Denver",
- "America/Detroit",
- "America/Dominica",
- "America/Edmonton",
- "America/Eirunepe",
- "America/El_Salvador",
- "America/Felipe_Carrillo",
- "America/Fortaleza",
- "America/Glace_Bay",
- "America/Godthab",
- "America/Goose_Bay",
- "America/Grand_Turk",
- "America/Grenada",
- "America/Guadeloupe",
- "America/Guatemala",
- "America/Guayaquil",
- "America/Guyana",
- "America/Halifax",
- "America/Havana",
- "America/Hermosillo",
- "America/Indiana/Indianapolis",
- "America/Indiana/Knox",
- "America/Indiana/Marengo",
- "America/Indiana/Petersburg",
- "America/Indiana/Tell_City",
- "America/Indiana/Vevay",
- "America/Indiana/Vincennes",
- "America/Indiana/Winamac",
- "America/Inuvik",
- "America/Iqaluit",
- "America/Jamaica",
- "America/Juneau",
- "America/Kentucky/Louisville",
- "America/Kentucky/Monticello",
- "America/La_Paz",
- "America/Lima",
- "America/Los_Angeles",
- "America/Maceio",
- "America/Managua",
- "America/Manaus",
- "America/Marigot",
- "America/Martinique",
- "America/Matamoros",
- "America/Mazatlan",
- "America/Menominee",
- "America/Merida",
- "America/Mexico_City",
- "America/Miquelon",
- "America/Moncton",
- "America/Monterrey",
- "America/Montevideo",
- "America/Montreal",
- "America/Montserrat",
- "America/Nassau",
- "America/New_York",
- "America/Nipigon",
- "America/Nome",
- "America/Noronha",
- "America/North_Dakota/Center",
- "America/North_Dakota/New_Salem",
- "America/Ojinaga",
- "America/Panama",
- "America/Pangnirtung",
- "America/Paramaribo",
- "America/Phoenix",
- "America/Port-au-Prince",
- "America/Porto_Velho",
- "America/Port_of_Spain",
- "America/Puerto_Rico",
- "America/Rainy_River",
- "America/Rankin_Inlet",
- "America/Recife",
- "America/Regina",
- "America/Resolute",
- "America/Rio_Branco",
- "America/Santarem",
- "America/Santa_Isabel",
- "America/Santiago",
- "America/Santo_Domingo",
- "America/Sao_Paulo",
- "America/Scoresbysund",
- "America/Shiprock",
- "America/St_Barthelemy",
- "America/St_Johns",
- "America/St_Kitts",
- "America/St_Lucia",
- "America/St_Thomas",
- "America/St_Vincent",
- "America/Swift_Current",
- "America/Tegucigalpa",
- "America/Thule",
- "America/Thunder_Bay",
- "America/Tijuana",
- "America/Toronto",
- "America/Tortola",
- "America/Vancouver",
- "America/Whitehorse",
- "America/Winnipeg",
- "America/Yakutat",
- "America/Yellowknife",
- "Antarctica/Casey",
- "Antarctica/Davis",
- "Antarctica/DumontDUrville",
- "Antarctica/Mawson",
- "Antarctica/McMurdo",
- "Antarctica/Palmer",
- "Antarctica/Rothera",
- "Antarctica/South_Pole",
- "Antarctica/Syowa",
- "Antarctica/Vostok",
- "Arctic/Longyearbyen",
- "Asia/Aden",
- "Asia/Almaty",
- "Asia/Amman",
- "Asia/Anadyr",
- "Asia/Aqtau",
- "Asia/Aqtobe",
- "Asia/Ashgabat",
- "Asia/Baghdad",
- "Asia/Bahrain",
- "Asia/Baku",
- "Asia/Bangkok",
- "Asia/Beirut",
- "Asia/Bishkek",
- "Asia/Brunei",
- "Asia/Choibalsan",
- "Asia/Chongqing",
- "Asia/Colombo",
- "Asia/Damascus",
- "Asia/Dhaka",
- "Asia/Dili",
- "Asia/Dubai",
- "Asia/Dushanbe",
- "Asia/Gaza",
- "Asia/Harbin",
- "Asia/Hong_Kong",
- "Asia/Hovd",
- "Asia/Ho_Chi_Minh",
- "Asia/Irkutsk",
- "Asia/Jakarta",
- "Asia/Jayapura",
- "Asia/Jerusalem",
- "Asia/Kabul",
- "Asia/Kamchatka",
- "Asia/Karachi",
- "Asia/Kashgar",
- "Asia/Kathmandu",
- "Asia/Kolkata",
- "Asia/Krasnoyarsk",
- "Asia/Kuala_Lumpur",
- "Asia/Kuching",
- "Asia/Kuwait",
- "Asia/Macau",
- "Asia/Magadan",
- "Asia/Makassar",
- "Asia/Manila",
- "Asia/Muscat",
- "Asia/Nicosia",
- "Asia/Novokuznetsk",
- "Asia/Novosibirsk",
- "Asia/Omsk",
- "Asia/Oral",
- "Asia/Phnom_Penh",
- "Asia/Pontianak",
- "Asia/Pyongyang",
- "Asia/Qatar",
- "Asia/Qyzylorda",
- "Asia/Rangoon",
- "Asia/Riyadh",
- "Asia/Sakhalin",
- "Asia/Samarkand",
- "Asia/Seoul",
- "Asia/Shanghai",
- "Asia/Singapore",
- "Asia/Taipei",
- "Asia/Tashkent",
- "Asia/Tbilisi",
- "Asia/Tehran",
- "Asia/Thimphu",
- "Asia/Tokyo",
- "Asia/Ulaanbaatar",
- "Asia/Urumqi",
- "Asia/Vientiane",
- "Asia/Vladivostok",
- "Asia/Yakutsk",
- "Asia/Yekaterinburg",
- "Asia/Yerevan",
- "Atlantic/Azores",
- "Atlantic/Bermuda",
- "Atlantic/Canary",
- "Atlantic/Cape_Verde",
- "Atlantic/Faroe",
- "Atlantic/Madeira",
- "Atlantic/Reykjavik",
- "Atlantic/South_Georgia",
- "Atlantic/Stanley",
- "Atlantic/St_Helena",
- "Australia/Adelaide",
- "Australia/Brisbane",
- "Australia/Broken_Hill",
- "Australia/Currie",
- "Australia/Darwin",
- "Australia/Eucla",
- "Australia/Hobart",
- "Australia/Lindeman",
- "Australia/Lord_Howe",
- "Australia/Melbourne",
- "Australia/Perth",
- "Australia/Sydney",
- "Europe/Amsterdam",
- "Europe/Andorra",
- "Europe/Athens",
- "Europe/Belgrade",
- "Europe/Berlin",
- "Europe/Bratislava",
- "Europe/Brussels",
- "Europe/Bucharest",
- "Europe/Budapest",
- "Europe/Chisinau",
- "Europe/Copenhagen",
- "Europe/Dublin",
- "Europe/Gibraltar",
- "Europe/Guernsey",
- "Europe/Helsinki",
- "Europe/Isle_of_Man",
- "Europe/Istanbul",
- "Europe/Jersey",
- "Europe/Kaliningrad",
- "Europe/Kiev",
- "Europe/Lisbon",
- "Europe/Ljubljana",
- "Europe/London",
- "Europe/Luxembourg",
- "Europe/Madrid",
- "Europe/Malta",
- "Europe/Mariehamn",
- "Europe/Minsk",
- "Europe/Monaco",
- "Europe/Moscow",
- "Europe/Oslo",
- "Europe/Paris",
- "Europe/Podgorica",
- "Europe/Prague",
- "Europe/Riga",
- "Europe/Rome",
- "Europe/Samara",
- "Europe/San_Marino",
- "Europe/Sarajevo",
- "Europe/Simferopol",
- "Europe/Skopje",
- "Europe/Sofia",
- "Europe/Stockholm",
- "Europe/Tallinn",
- "Europe/Tirane",
- "Europe/Uzhgorod",
- "Europe/Vaduz",
- "Europe/Vatican",
- "Europe/Vienna",
- "Europe/Vilnius",
- "Europe/Volgograd",
- "Europe/Warsaw",
- "Europe/Zagreb",
- "Europe/Zaporozhye",
- "Europe/Zurich",
- "Indian/Antananarivo",
- "Indian/Chagos",
- "Indian/Christmas",
- "Indian/Cocos",
- "Indian/Comoro",
- "Indian/Kerguelen",
- "Indian/Mahe",
- "Indian/Maldives",
- "Indian/Mauritius",
- "Indian/Mayotte",
- "Indian/Reunion",
- "Pacific/Apia",
- "Pacific/Auckland",
- "Pacific/Chatham",
- "Pacific/Easter",
- "Pacific/Efate",
- "Pacific/Enderbury",
- "Pacific/Fakaofo",
- "Pacific/Fiji",
- "Pacific/Funafuti",
- "Pacific/Galapagos",
- "Pacific/Gambier",
- "Pacific/Guadalcanal",
- "Pacific/Guam",
- "Pacific/Honolulu",
- "Pacific/Johnston",
- "Pacific/Kiritimati",
- "Pacific/Kosrae",
- "Pacific/Kwajalein",
- "Pacific/Majuro",
- "Pacific/Marquesas",
- "Pacific/Midway",
- "Pacific/Nauru",
- "Pacific/Niue",
- "Pacific/Norfolk",
- "Pacific/Noumea",
- "Pacific/Pago_Pago",
- "Pacific/Palau",
- "Pacific/Pitcairn",
- "Pacific/Ponape",
- "Pacific/Port_Moresby",
- "Pacific/Rarotonga",
- "Pacific/Saipan",
- "Pacific/Tahiti",
- "Pacific/Tarawa",
- "Pacific/Tongatapu",
- "Pacific/Truk",
- "Pacific/Wake",
- "Pacific/Wallis",
- );
-
- reset($aZones);
- return $aZones;
+
}
}
\ No newline at end of file
diff --git a/CoreVersions/Baikal_0.1/Frameworks/Baikal/Model/Config/Standard.php b/CoreVersions/Baikal_0.1/Frameworks/Baikal/Model/Config/Standard.php
new file mode 100644
index 0000000..0e6b405
--- /dev/null
+++ b/CoreVersions/Baikal_0.1/Frameworks/Baikal/Model/Config/Standard.php
@@ -0,0 +1,154 @@
+
+* All rights reserved
+*
+* http://baikal.codr.fr
+*
+* This script is part of the Baïkal Server project. The Baïkal
+* Server project is free software; you can redistribute it
+* and/or modify it under the terms of the GNU General Public
+* License as published by the Free Software Foundation; either
+* version 2 of the License, or (at your option) any later version.
+*
+* The GNU General Public License can be found at
+* http://www.gnu.org/copyleft/gpl.html.
+*
+* This script is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+
+namespace Baikal\Model\Config;
+
+class Standard extends \Baikal\Model\Config {
+
+ protected $aConstants = array(
+ "BAIKAL_TIMEZONE" => array(
+ "type" => "string",
+ ),
+ "BAIKAL_CARD_ENABLED" => array(
+ "type" => "boolean",
+ ),
+ "BAIKAL_CAL_ENABLED" => array(
+ "type" => "boolean",
+ ),
+ "BAIKAL_ADMIN_ENABLED" => array(
+ "type" => "boolean",
+ ),
+ "BAIKAL_STANDALONE_ALLOWED" => array(
+ "type" => "boolean",
+ ),
+ "BAIKAL_STANDALONE_PORT" => array(
+ "type" => "integer",
+ ),
+ "BAIKAL_ADMIN_PASSWORDHASH" => array(
+ "type" => "string",
+ )
+ );
+
+ protected $aData = array(
+ "BAIKAL_TIMEZONE" => "",
+ "BAIKAL_CARD_ENABLED" => "",
+ "BAIKAL_CAL_ENABLED" => "",
+ "BAIKAL_TIMEZONE" => "",
+ "BAIKAL_CARD_ENABLED" => "",
+ "BAIKAL_CAL_ENABLED" => "",
+ "BAIKAL_ADMIN_ENABLED" => "",
+ "BAIKAL_STANDALONE_ALLOWED" => "",
+ "BAIKAL_STANDALONE_PORT" => "",
+ "BAIKAL_ADMIN_PASSWORDHASH" => ""
+ );
+
+ public function formMorphologyForThisModelInstance() {
+ $oMorpho = new \Formal\Form\Morphology();
+
+ $oMorpho->add(new \Formal\Element\Listbox(array(
+ "prop" => "BAIKAL_TIMEZONE",
+ "label" => "Time zone",
+ "validation" => "required",
+ "options" => \Baikal\Core\Tools::timezones(),
+ "help" => "Time zone of the server"
+ )));
+
+ $oMorpho->add(new \Formal\Element\Checkbox(array(
+ "prop" => "BAIKAL_CARD_ENABLED",
+ "label" => "Enable CardDAV"
+ )));
+
+ $oMorpho->add(new \Formal\Element\Checkbox(array(
+ "prop" => "BAIKAL_CAL_ENABLED",
+ "label" => "Enable CalDAV"
+ )));
+
+ $oMorpho->add(new \Formal\Element\Checkbox(array(
+ "prop" => "BAIKAL_ADMIN_ENABLED",
+ "label" => "Enable Web Admin",
+ "popover" => array(
+ "title" => "Warning !",
+ "content" => "If disabled, you'll lose access to this very admin interface !",
+ ),
+ )));
+
+ $oMorpho->add(new \Formal\Element\Checkbox(array(
+ "prop" => "BAIKAL_STANDALONE_ALLOWED",
+ "label" => "Allow Standalone Baïkal execution"
+ )));
+
+ $oMorpho->add(new \Formal\Element\Text(array(
+ "prop" => "BAIKAL_STANDALONE_PORT",
+ "label" => "Standalone Baïkal port"
+ )));
+
+ $sNotice = "-- Leave empty to keep current password --";
+ $oMorpho->add(new \Formal\Element\Password(array(
+ "prop" => "BAIKAL_ADMIN_PASSWORDHASH",
+ "label" => "Web admin password",
+ "placeholder" => $sNotice,
+ )));
+
+ $oMorpho->add(new \Formal\Element\Password(array(
+ "prop" => "BAIKAL_ADMIN_PASSWORDHASH_CONFIRM",
+ "label" => "Web admin password confirmation",
+ "placeholder" => $sNotice,
+ "validation" => "sameas:BAIKAL_ADMIN_PASSWORDHASH",
+ )));
+
+
+ return $oMorpho;
+ }
+
+ public function label() {
+ return "Baïkal Settings";
+ }
+
+ public function set($sProp, $sValue) {
+ if($sProp === "BAIKAL_ADMIN_PASSWORDHASH" || $sProp === "BAIKAL_ADMIN_PASSWORDHASH_CONFIRM") {
+ # Special handling for password and passwordconfirm
+
+ if($sProp === "BAIKAL_ADMIN_PASSWORDHASH" && $sValue !== "") {
+ parent::set(
+ "BAIKAL_ADMIN_PASSWORDHASH",
+ \BaikalAdmin\Core\Auth::hashAdminPassword($sValue)
+ );
+ }
+
+ return $this;
+ }
+
+ parent::set($sProp, $sValue);
+ }
+
+ public function get($sProp) {
+ if($sProp === "BAIKAL_ADMIN_PASSWORDHASH" || $sProp === "BAIKAL_ADMIN_PASSWORDHASH_CONFIRM") {
+ return "";
+ }
+
+ return parent::get($sProp);
+ }
+}
\ No newline at end of file
diff --git a/CoreVersions/Baikal_0.1/Frameworks/Baikal/Model/Config/System.php b/CoreVersions/Baikal_0.1/Frameworks/Baikal/Model/Config/System.php
new file mode 100644
index 0000000..ce3a5b8
--- /dev/null
+++ b/CoreVersions/Baikal_0.1/Frameworks/Baikal/Model/Config/System.php
@@ -0,0 +1,120 @@
+
+* All rights reserved
+*
+* http://baikal.codr.fr
+*
+* This script is part of the Baïkal Server project. The Baïkal
+* Server project is free software; you can redistribute it
+* and/or modify it under the terms of the GNU General Public
+* License as published by the Free Software Foundation; either
+* version 2 of the License, or (at your option) any later version.
+*
+* The GNU General Public License can be found at
+* http://www.gnu.org/copyleft/gpl.html.
+*
+* This script is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+
+namespace Baikal\Model\Config;
+
+class System extends \Baikal\Model\Config {
+
+ protected $aConstants = array(
+ "BAIKAL_PATH_SABREDAV" => array(
+ "type" => "litteral",
+ ),
+ "BAIKAL_AUTH_REALM" => array(
+ "type" => "string",
+ ),
+ "BAIKAL_CARD_BASEURI" => array(
+ "type" => "string",
+ ),
+ "BAIKAL_CAL_BASEURI" => array(
+ "type" => "string",
+ ),
+ "BAIKAL_SQLITE_FILE" => array(
+ "type" => "litteral",
+ ),
+ );
+
+ protected $aData = array(
+ "BAIKAL_PATH_SABREDAV" => "",
+ "BAIKAL_AUTH_REALM" => "",
+ "BAIKAL_CARD_BASEURI" => "",
+ "BAIKAL_CAL_BASEURI" => "",
+ "BAIKAL_SQLITE_FILE" => "",
+ );
+
+ public function formMorphologyForThisModelInstance() {
+ $oMorpho = new \Formal\Form\Morphology();
+
+ $oMorpho->add(new \Formal\Element\Text(array(
+ "prop" => "BAIKAL_CAL_BASEURI",
+ "label" => "CalDAV base URI",
+ "validation" => "required",
+ "help" => "The absolute web path to cal.php",
+ "popover" => array(
+ "title" => "CalDAV base URI",
+ "content" => "If Baïkal is hosted in a subfolder, this path should reflect it.
Whatever happens, it should begin and end with a slash.",
+ )
+ )));
+
+ $oMorpho->add(new \Formal\Element\Text(array(
+ "prop" => "BAIKAL_CARD_BASEURI",
+ "label" => "CardDAV base URI",
+ "validation" => "required",
+ "help" => "The absolute web path to card.php",
+ "popover" => array(
+ "title" => "CardDAV base URI",
+ "content" => "If Baïkal is hosted in a subfolder, this path should reflect it.
Whatever happens, it should begin and end with a slash."
+ )
+ )));
+
+ $oMorpho->add(new \Formal\Element\Text(array(
+ "prop" => "BAIKAL_PATH_SABREDAV",
+ "label" => "Path to SabreDAV",
+ "validation" => "required",
+ "inputclass" => "input-xxlarge",
+ "help" => "The absolute server path to SabreDAV API",
+ "popover" => array(
+ "title" => "Path to SabreDAV",
+ "content" => "If Baïkal is hosted in a subfolder, this path should reflect it.
Whatever happens, it should begin and end with a slash.",
+ "position" => "top"
+ )
+ )));
+
+ $oMorpho->add(new \Formal\Element\Text(array(
+ "prop" => "BAIKAL_SQLITE_FILE",
+ "label" => "Path to SQLite DB",
+ "inputclass" => "input-xxlarge",
+ "validation" => "required",
+ "help" => "The absolute server path to SQLite database."
+ )));
+
+ $oMorpho->add(new \Formal\Element\Text(array(
+ "prop" => "BAIKAL_AUTH_REALM",
+ "label" => "Auth realm",
+ "validation" => "required",
+ "help" => "Token used in authentication process.
If you change this, you'll have to reset all your users passwords.
You'll also loose access to this admin interface.",
+ "popover" => array(
+ "title" => "Auth realm",
+ "content" => "If you change this, you'll loose your access to this interface.
In other words: you should not change this, unless YKWYD."
+ )
+ )));
+
+ return $oMorpho;
+ }
+
+ public function label() {
+ return "Baïkal Settings";
+ }
+}
\ No newline at end of file
diff --git a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Controller/Install.php b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Controller/Install.php
index 1ef7809..550a671 100644
--- a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Controller/Install.php
+++ b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Controller/Install.php
@@ -27,11 +27,82 @@
namespace BaikalAdmin\Controller;
class Install extends \Flake\Core\Controller {
-
+
+ protected $aMessages = array();
+ protected $oModel; # \BaikalAdmin\Model\Install
+ protected $oForm; # \Formal\Form
+
+ public function __construct() {
+ parent::__construct();
+
+ $this->oModel = new \BaikalAdmin\Model\Install();
+
+ $this->oForm = $this->oModel->formForThisModelInstance(array(
+ "close" => FALSE
+ ));
+ }
+
public function execute() {
+ if($this->oForm->submitted()) {
+ $this->oForm->execute();
+ }
}
public function render() {
- return "
Configure your new Baïkal installation.
+ +HTML; + + $sHtml .= $this->oForm->render(); + + return $sHtml; + } + + protected function render_upgradeInstall() { + $sBigIcon = \BaikalAdmin\Model\Install::bigicon(); + $sBaikalVersion = BAIKAL_VERSION; + $sBaikalConfiguredVersion = BAIKAL_CONFIGURED_VERSION; + + $sHtml = << +Upgrading Baïkal from version {$sBaikalConfiguredVersion} to version {$sBaikalVersion}.
+ +HTML; + +/* $sHtml .= <<What is this ? +
+ This is the Baïkal Install Tool.
+ It's displayed because you just installed or upgraded your Baïkal installation.
+ Baïkal requires some maintenance in order to ensure everything works as expected.
+
Manage Address Books for= $user->label() ?>.
@@ -16,7 +5,7 @@Display name | diff --git a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Resources/Templates/Calendars/Listing.html b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Resources/Templates/Calendars/Listing.html index 15617dc..a8603bb 100644 --- a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Resources/Templates/Calendars/Listing.html +++ b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Resources/Templates/Calendars/Listing.html @@ -1,14 +1,3 @@ - -
---|
Display name | diff --git a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Resources/Templates/Page/index.html b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Resources/Templates/Page/index.html index 76c90da..1b7d01b 100644 --- a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Resources/Templates/Page/index.html +++ b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Resources/Templates/Page/index.html @@ -8,9 +8,9 @@ - + @@ -25,20 +25,7 @@
---|