This repository has been archived on 2025-02-01. You can view files and clone it, but cannot push or open issues or pull requests.
accm-website/pages/InstallPage.inc.php
2010-08-14 22:32:09 +02:00

257 lines
No EOL
8 KiB
PHP

<?php
include_once './pages/PageInterface.inc.php';
include_once './includes/utils/InputSanitizer.inc.php';
include_once './includes/database/MySQLDatabase.inc.php';
/**
* This class represent the installation page of the site.
*
* @author Thomas Schwery <thomas.schwery@epfl.ch>
*/
class InstallPage implements PageInterface {
private $title;
private $content;
public function __construct() {
if (key_exists("step", $_GET)) {
$step = $_GET["step"];
if ($step == 2) $this->secondStep();
} else {
$this->firstStep();
}
}
public function getTitle() {
return Localization::adminInstall . $this->title;
}
public function getContent() {
return $this->content;
}
public static function getStaticTitle() {
return Localization::adminInstall;
}
private function firstStep() {
$this->content = "Debut de l'installation ...";
$this->content.= "<a href='?page=Install&step=2'>Suite</a>";
}
private function secondStep() {
$retVal = MySQLDatabase::getInstance()->runOperations(InstallPage::mySQLDataUser());
$this->content = "Insertion des utilisateurs par défaut: " . implode(",",$retVal) . "\n<br>";
$retVal = MySQLDatabase::getInstance()->runOperations(InstallPage::mySQLDataTournament());
$this->content .= "Insertion des concours par défaut: " . implode(",",$retVal) . "\n<br>";
$retVal = MySQLDatabase::getInstance()->runOperations(InstallPage::mySQLDataNews());
$this->content .= "Insertion des nouvelles par défaut: " . implode(",",$retVal) . "\n<br>";
$retVal = MySQLDatabase::getInstance()->runOperations(InstallPage::mySQLDataMenu());
$this->content .= "Insertion des entrées menu par défaut: " . implode(",",$retVal) . "\n<br>";
$retVal = MySQLDatabase::getInstance()->runOperations(InstallPage::mySQLDataCategories());
$this->content .= "Insertion des catégories par défaut: " . implode(",",$retVal) . "\n<br>";
}
private static function mySQLDataUser() {
return <<<SQL
--
-- Table structure for table `users`
--
DROP TABLE IF EXISTS `users`;
SET character_set_client = utf8;
CREATE TABLE `users` (
`identifier` int(11) NOT NULL auto_increment,
`username` text NOT NULL,
`fullName` text NOT NULL,
`password` text NOT NULL,
`birthday` date NOT NULL,
`mail` text NOT NULL,
PRIMARY KEY (`identifier`)
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `users`
--
LOCK TABLES `users` WRITE;
INSERT INTO `users` VALUES
(1,'tschwery','Thomas Schwery','a76b52e030ceff991cffdc13b756703260b15b2e2dcd2780b41775daab41c61d109c90aaabd154856924224075f6f7623dfffd51968cd810d62a9071e02d0df7','1987-09-23','username@somewhere.com'),
(2,'toto','Beta Tester','10e06b990d44de0091a2113fd95c92fc905166af147aa7632639c41aa7f26b1620c47443813c605b924c05591c161ecc35944fc69c4433a49d10fc6b04a33611','1965-02-10','username@somewhere.com');
UNLOCK TABLES;
--
-- Table structure for table `userRight`
--
DROP TABLE IF EXISTS `userRight`;
SET character_set_client = utf8;
CREATE TABLE `userRight` (
`rightId` int(11) NOT NULL auto_increment,
`name` text NOT NULL,
PRIMARY KEY (`rightId`)
) ENGINE=MyISAM AUTO_INCREMENT=10 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `userRight`
--
LOCK TABLES `userRight` WRITE;
INSERT INTO `userRight` VALUES (1,'Membre'),(6,'NewsAdministration'),(3,'UserAdministration'),(4,'MemberRightAdministration'),(5,'CentralAdministration'),(7,'MenuAdministration'),(8,'TournamentAdministration'),(9,'CategoryAdministration');
UNLOCK TABLES;
--
-- Table structure for table `userRightEntries`
--
DROP TABLE IF EXISTS `userRightEntries`;
SET character_set_client = utf8;
CREATE TABLE `userRightEntries` (
`rightId` int(11) NOT NULL,
`userId` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `userRightEntries`
--
LOCK TABLES `userRightEntries` WRITE;
INSERT INTO `userRightEntries` VALUES (1,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(2,11);
UNLOCK TABLES;
SQL;
}
private static function mySQLDataCategories() {
return <<<SQL
--
-- Table structure for table `categories`
--
DROP TABLE IF EXISTS `categories`;
SET character_set_client = utf8;
CREATE TABLE `categories` (
`identifier` int(11) NOT NULL auto_increment,
`name` text NOT NULL,
UNIQUE KEY `identifier` (`identifier`)
) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `categories`
--
LOCK TABLES `categories` WRITE;
INSERT INTO `categories` VALUES (6,'Catégorie 2'),(5,'Catégorie 1');
UNLOCK TABLES;
SQL;
}
private static function mySQLDataMenu() {
return <<<SQL
--
-- Table structure for table `menuEntries`
--
DROP TABLE IF EXISTS `menuEntries`;
SET character_set_client = utf8;
CREATE TABLE `menuEntries` (
`identifier` int(11) NOT NULL auto_increment,
`name` text NOT NULL,
`hint` text NOT NULL,
`url` text NOT NULL,
`menuId` int(11) NOT NULL,
`weight` int(11) NOT NULL,
PRIMARY KEY (`identifier`)
) ENGINE=MyISAM AUTO_INCREMENT=12 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `menuEntries`
--
LOCK TABLES `menuEntries` WRITE;
INSERT INTO `menuEntries` VALUES (1,'Nouvelles','Lien vers les nouvelles du club','News',0,0),(2,'Index','Something','Index',0,0),(7,'Membres','Liens vers une page des membres du club','Users',0,0),(11,'Concours','Liens vers une page listant tous les concours','Tournaments',0,0);
UNLOCK TABLES;
SQL;
}
private static function mySQLDataNews() {
return <<<SQL
--
-- Table structure for table `news`
--
DROP TABLE IF EXISTS `news`;
SET character_set_client = utf8;
CREATE TABLE `news` (
`identifier` int(11) NOT NULL auto_increment,
`writingDate` datetime NOT NULL,
`publicationDate` datetime NOT NULL,
`authorId` int(11) NOT NULL,
`abstract` text NOT NULL,
`text` text NOT NULL,
PRIMARY KEY (`identifier`)
) ENGINE=MyISAM AUTO_INCREMENT=12 DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;
--
-- Dumping data for table `news`
--
LOCK TABLES `news` WRITE;
INSERT INTO `news` VALUES (10,'2010-02-10 00:00:00','2010-03-07 00:00:00',15,'Article de Test','Ceci est un article testant la reconnaissance de dates ...'),(9,'2010-02-10 00:00:00','2010-01-01 00:00:00',15,'Nouvel Article','Ceci est un test ...'),(11,'2010-02-10 00:00:00','2010-02-08 00:00:00',15,'Encore un article','Youhouhou !');
UNLOCK TABLES;
SQL;
}
private static function mySQLDataTournament() {
return <<<SQL
--
-- Table structure for table `tournaments`
--
DROP TABLE IF EXISTS `tournaments`;
SET character_set_client = utf8;
CREATE TABLE `tournaments` (
`identifier` int(11) NOT NULL auto_increment,
`name` text NOT NULL,
`location` text NOT NULL,
`date` date NOT NULL,
`type` text NOT NULL,
`comments` text NOT NULL,
UNIQUE KEY `identifier` (`identifier`)
) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `tournaments`
--
LOCK TABLES `tournaments` WRITE;
INSERT INTO `tournaments` VALUES (2,'Concours test','Plan les ouates',2010-02-10,'Field','Commentaire test assez long pour éventuellement embêter ...'),(3,'Un autre concours pour un long nom','New location',2010-02-10,'New type','New comment');
UNLOCK TABLES;
--
-- Table structure for table `tournamentsEntries`
--
DROP TABLE IF EXISTS `tournamentsEntries`;
SET character_set_client = utf8;
CREATE TABLE `tournamentsEntries` (
`entryId` int(11) NOT NULL auto_increment,
`tournamentId` int(11) NOT NULL,
`userId` int(11) NOT NULL,
`categoryId` int(11) NOT NULL,
`points` int(11) NOT NULL,
`rank` int(11) NOT NULL,
`participants` int(11) NOT NULL,
PRIMARY KEY (`entryId`)
) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `tournamentsEntries`
--
LOCK TABLES `tournamentsEntries` WRITE;
INSERT INTO `tournamentsEntries` VALUES (1,2,15,5,230,1,2),(2,2,15,5,123,1,3),(4,2,15,6,300,3,12),(5,3,15,5,100,1,10),(6,2,17,5,300,2,32),(7,2,17,6,200,4,31),(8,2,17,6,400,1,21);
UNLOCK TABLES;
SQL;
}
}
?>