diff --git a/common.php b/common.php index 4e439d96..44e3ba0f 100644 --- a/common.php +++ b/common.php @@ -27,7 +27,7 @@ session_start(); define('MYAAC', true); define('MYAAC_VERSION', '0.8.0-dev'); -define('DATABASE_VERSION', 21); +define('DATABASE_VERSION', 22); define('TABLE_PREFIX', 'myaac_'); define('START_TIME', microtime(true)); define('MYAAC_OS', (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? 'WINDOWS' : (strtoupper(PHP_OS) == 'DARWIN' ? 'MAC' : 'LINUX')); diff --git a/install/tools/7-finish.php b/install/tools/7-finish.php index a4145351..72623f3b 100644 --- a/install/tools/7-finish.php +++ b/install/tools/7-finish.php @@ -85,6 +85,9 @@ if(!databaseMigration20($content)) { '); } +// add z_polls tables +require_once(SYSTEM . 'migrations/22.php'); + $locale['step_finish_desc'] = str_replace('$ADMIN_PANEL$', generateLink(str_replace('tools/', '',ADMIN_URL), $locale['step_finish_admin_panel'], true), $locale['step_finish_desc']); $locale['step_finish_desc'] = str_replace('$HOMEPAGE$', generateLink(str_replace('tools/', '', BASE_URL), $locale['step_finish_homepage'], true), $locale['step_finish_desc']); $locale['step_finish_desc'] = str_replace('$LINK$', generateLink('http://my-aac.org', 'http://my-aac.org', true), $locale['step_finish_desc']); diff --git a/system/migrations/22.php b/system/migrations/22.php new file mode 100644 index 00000000..d09b6fce --- /dev/null +++ b/system/migrations/22.php @@ -0,0 +1,26 @@ +hasTable('z_polls')) + $db->query(' +CREATE TABLE `z_polls` ( + `id` int(11) NOT NULL auto_increment, + `question` varchar(255) NOT NULL, + `description` varchar(255) NOT NULL, + `end` int(11) NOT NULL DEFAULT 0, + `start` int(11) NOT NULL DEFAULT 0, + `answers` int(11) NOT NULL DEFAULT 0, + `votes_all` int(11) NOT NULL DEFAULT 0, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;'); + +if(!$db->hasTable('z_polls_answers')) +$db->query(' + CREATE TABLE `z_polls_answers` ( + `poll_id` int(11) NOT NULL, + `answer_id` int(11) NOT NULL, + `answer` varchar(255) NOT NULL, + `votes` int(11) NOT NULL DEFAULT 0 +) ENGINE=MyISAM DEFAULT CHARSET=latin1;'); + +if(!$db->hasColumn('accounts', 'vote')) + $db->query('ALTER TABLE `accounts` ADD `vote` INT( 11 ) NOT NULL ;'); \ No newline at end of file diff --git a/system/pages/polls.php b/system/pages/polls.php index 17e5b4d0..cf1843fe 100644 --- a/system/pages/polls.php +++ b/system/pages/polls.php @@ -13,31 +13,6 @@ $title = 'Polls'; /* Polls System By Averatec from pervera.pl & otland.net */ -if(!$db->hasTable('z_polls')) - $db->query(' -CREATE TABLE `z_polls` ( - `id` int(11) NOT NULL auto_increment, - `question` varchar(255) NOT NULL, - `description` varchar(255) NOT NULL, - `end` int(11) NOT NULL DEFAULT 0, - `start` int(11) NOT NULL DEFAULT 0, - `answers` int(11) NOT NULL DEFAULT 0, - `votes_all` int(11) NOT NULL DEFAULT 0, - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;'); - -if(!$db->hasTable('z_polls_answers')) -$db->query(' - CREATE TABLE `z_polls_answers` ( - `poll_id` int(11) NOT NULL, - `answer_id` int(11) NOT NULL, - `answer` varchar(255) NOT NULL, - `votes` int(11) NOT NULL DEFAULT 0 -) ENGINE=MyISAM DEFAULT CHARSET=latin1;'); - -if(!$db->hasColumn('accounts', 'vote')) - $db->query('ALTER TABLE `accounts` ADD `vote` INT( 11 ) NOT NULL ;'); - function getColorByPercent($percent) { if($percent < 15)