Mercurial > hg > fapweb
changeset 515:2fc7bd9e209f
Add comments.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 08 Dec 2013 16:29:53 +0200 |
parents | 8693052c66a9 |
children | 664915ff8520 |
files | createdb.php |
diffstat | 1 files changed, 21 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/createdb.php Sun Dec 08 14:34:27 2013 +0200 +++ b/createdb.php Sun Dec 08 16:29:53 2013 +0200 @@ -13,7 +13,7 @@ // -// The defaults we put in +// Site settings and defaults we put in // $siteDefaults = array( "maxAttendeesHard" => array(VT_INT, 60, "Maximum attendees (HARD limit, <= 0 means no limit)"), @@ -159,10 +159,12 @@ "siteExtraHTML" => array(VT_TEXT, "<div id=\"sponsors\">Gentle Eye</div>", "Extra global HTML code (f.e. sponsors box)"), ); + +// +// +// $sqlTables = array( - // // Database metadata - // "dbmeta" => array( array("key" , "VARCHAR(32)", "PRIMARY KEY"), array("vtype" , "INT"), @@ -172,9 +174,7 @@ array("desc" , "VARCHAR(128)"), ), - // // Site settings - // "settings" => array( array("key" , "VARCHAR(32)", "PRIMARY KEY"), array("vtype" , "INT"), @@ -237,9 +237,8 @@ array("value" , "INT", "DEFAULT 0"), ), - // - // Information system tables - // + + // Party information system tables "displayVars" => array( array("key" , "VARCHAR(32)", "PRIMARY KEY"), array("vtype" , "INT"), @@ -268,6 +267,10 @@ ), ); + +// +// Party information system settings / data +// $siteDisplayVars = array( "showMode" => array(VT_INT, 0, "Currently active display mode"), "rotateDuration" => array(VT_INT, 15, "Slide rotation time per slide (seconds)"), @@ -292,6 +295,10 @@ "lastUpdate" => array(VT_INT, 0, "Timestamp of last slide update"), ); + +// +// Some premade test data +// $siteTestData = array( "news" => array( "utime,title,text,author", @@ -407,6 +414,7 @@ { if (isset($upgradeMappings[$name][$type])) { + // XXX TODO .. } else die("Upgrade failed due to missing or invalid upgrade definition: ".$type." ".$name." from version X to Y.\n"); @@ -426,6 +434,7 @@ foreach ($settings as $key => $data) { + // Get setting type switch ($data[0]) { case VT_TEXT: $type = "%s"; $var = "vtext"; break; @@ -435,10 +444,13 @@ default: die("Invalid type in default settings '".$key."', type=".$data[0]."\n"); } + // Map the key, in case the name has changed $inKey = stUpgradeMap("key", $key); + // Check if we are upgrading if ($upgrade && ($res = stDBFetchSQL($inDB, stDBPrepareSQL($inDB, "SELECT * FROM ".$table." WHERE key=%s", $inKey))) !== FALSE) { + // Yup, upgrade the data, if we can echo "."; if ($res["vtype"] != $data[0]) @@ -450,6 +462,7 @@ } else { + // Normal insertion of default data echo "+"; $sql = stDBPrepareSQL($outDB, "INSERT INTO ".$table." (key,vtype,".$var.",desc) VALUES (%s,%d,".$type.",%s)",