* auto add z_polls table on install

This commit is contained in:
slawkens1 2018-01-14 09:45:16 +01:00
parent 40981daf33
commit 4bfc804d85
4 changed files with 30 additions and 26 deletions

View File

@ -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'));

View File

@ -85,6 +85,9 @@ if(!databaseMigration20($content)) {
<textarea cols="70" rows="10">' . $content . '</textarea>');
}
// 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']);

26
system/migrations/22.php Normal file
View File

@ -0,0 +1,26 @@
<?php
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 ;');

View File

@ -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)