2
0
mirror of https://github.com/ACSPRI/queXS synced 2024-04-02 12:12:16 +00:00

Removed limesurvey install directory

This commit is contained in:
azammitdcarf
2011-02-21 00:40:15 +00:00
parent 5b13440762
commit 9c7296d1f7
11 changed files with 0 additions and 2892 deletions

View File

@@ -1,185 +0,0 @@
<?php
/*
* LimeSurvey
* Copyright (C) 2007 The LimeSurvey Project Team / Nicolas Barcet
* All rights reserved.
* License: http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id: index.php 4729 2008-05-31 21:32:02Z nijaba $
*/
$cmd_install=true;
if (isset($argv[1]) && ($argv[1]=='install'|| $argv[1]=='upgrade') && isset($argv[2]) && isset($argv[3]))
{
require_once($argv[2]);
require_once($argv[3]);
}
else
{
require_once(dirname(__FILE__).'/../../config-defaults.php');
require_once(dirname(__FILE__).'/../../common.php');
}
// SET THE LANGUAGE???? -> DEFAULT SET TO EN FOR NOW
require_once($rootdir.'/classes/core/language.php');
$clang = new limesurvey_lang("en");
ob_implicit_flush(true);
if (isset($argv[1]) && $argv[1]=='install')
{
print("trying to create and populate $databasename on $databaselocation:$databaseport ($databasetype) \n");
if (!$database_exists) //Database named in config.php does not exist
{
if($connect->Execute("CREATE DATABASE $databasename;"))
{
print("\nDatabase $databasename on $databasetype CREATED \n");
}
else
{
print("\nDatabase $databasename on $databasetype COULD NOT BE CREATED \n");
print("\n".$connect->ErrorMsg());
return 1;
}
}
else
{
if ($databasetype=='mysql' || $databasetype=='mysqli') {$connect->Execute("ALTER DATABASE `$databasename` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;");} //Set the collation also for manually created DBs
print("\nDatabase $databasename on $databasetype EXISTS, not created \n");
}
// Connect to the database we created a sec ago or to the existing db.
if(!$connect->Connect($databaselocation,$databaseuser,$databasepass,$databasename))
{
print("\n".$connect->ErrorMsg());
return 1;
}
require_once($homedir."/classes/core/sha256.php");
$success = 0; // Let's be optimistic
$createdbtype=$databasetype;
if ($createdbtype=='mssql_n' || $createdbtype=='odbc_mssql' || $createdbtype=='odbtp') $createdbtype='mssql';
$sqlfile = dirname(__FILE__).'/create-'.$createdbtype.'.sql' ;
if (!empty($sqlfile)) {
if (!is_readable($sqlfile)) {
$success = false;
print "\nTried to populate database, but '". $sqlfile ."' doesn't exist!\n";
return $success;
} else {
$lines = file($sqlfile);
}
} else {
$sqlstring = trim($sqlstring);
if ($sqlstring{strlen($sqlstring)-1} != ";") {
$sqlstring .= ";"; // add it in if it's not there.
}
$lines[] = $sqlstring;
}
$command = '';
$connect->SetFetchMode(ADODB_FETCH_NUM);
foreach ($lines as $line) {
$line = rtrim($line);
$length = strlen($line);
if ($length and $line[0] <> '#' and substr($line,0,2) <> '--') {
if (substr($line, $length-1, 1) == ';') {
$line = substr($line, 0, $length-1); // strip ;
$command .= $line;
$command = str_replace('prefix_', $dbprefix, $command); // Table prefixes
$command = str_replace('$defaultuser', $defaultuser, $command); // variables By Moses
$command = str_replace('$defaultpass', SHA256::hashing($defaultpass), $command); // variables By Moses
$command = str_replace('$siteadminname', $siteadminname, $command);
$command = str_replace('$siteadminemail', $siteadminemail, $command); // variables By Moses
$command = str_replace('$defaultlang', $defaultlang, $command); // variables By Moses
$command = str_replace('$sessionname', 'ls'.getRandomID().getRandomID().getRandomID().getRandomID(), $command); // variables By Moses
$command = str_replace('$databasetabletype', $databasetabletype, $command);
if(!$connect->Execute($command,false))
{
print ("\n".$clang->gT("Executing").".....".$command."...".$clang->gT('Failed! Reason:')."\n".$connect->ErrorMsg()."\n\n");
$success=1;
}
$command = '';
} else {
$command .= $line;
}
}
}
$connect->SetFetchMode(ADODB_FETCH_ASSOC);
if($success == 0)
{
print("Database $databasename on $databasetype POPULATED");
print("\n\neverything went fine");
return $success;
}
else
{
print("\n\nSomething is strange");
print("\nplease check you Database and Settings");
return $success;
}
// if (modify_database(dirname(__FILE__).'\create-'.$databasetype.'.sql'))
// {
// print("\nDatabase $databasename on $databasetype POPULATED \n");
// return 0;
// } else {
// print("Could not populate $databasename on $databasetype\n");
// return 1;
// }
}
elseif (isset($argv[1]) && $argv[1]=='upgrade')
{
$upgradedbtype=$databasetype;
if ($upgradedbtype=='mssql_n' || $upgradedbtype=='odbc_mssql' || $upgradedbtype=='odbtp') $upgradedbtype='mssql';
include ('upgrade-'.$upgradedbtype.'.php');
$tables = $connect->MetaTables();
$usquery = "SELECT stg_value FROM ".db_table_name("settings_global")." where stg_name='DBVersion'";
$usresult = db_execute_assoc($usquery);
$usrow = $usresult->FetchRow();
if (intval($usrow['stg_value'])<$dbversionnumber)
{
print("Upgrading db to $dbversionnumber\n");
db_upgrade(intval($usrow['stg_value']));
} else {
print("Already at db version $dbversionnumber\n");
}
return 0;
}
else
{
print("LimeSurvey Commandline Install\n");
print("Usage: cmd_install <option> < <<path1>> <<path2>> >\n");
print("<option> - 'install' or 'upgrade' \n");
print("<<path1>> - Full path including filename to a custom config-defaults.php\n");
print("<<path2>> - Full path including filename to a custom common.php\n");
print("Paths are optional. If used both paths must be set.\n");
return 2;
}
?>

View File

@@ -1,402 +0,0 @@
-- LimeSurvey MS SQL Server 2000 database schema
-- --------------------------------------------------------
CREATE TABLE [prefix_quota] (
[id] int NOT NULL IDENTITY (1,1),
[sid] int ,
[name] varchar(255),
[qlimit] int ,
[action] int ,
[active] int NOT NULL default '1',
[autoload_url] int NOT NULL default '0',
PRIMARY KEY ([id])
);
CREATE TABLE [prefix_quota_languagesettings] (
[quotals_id] int NOT NULL IDENTITY (1,1),
[quotals_quota_id] int,
[quotals_language] varchar(45) NOT NULL default 'en',
[quotals_name] varchar(255),
[quotals_message] text,
[quotals_url] varchar(255),
[quotals_urldescrip] varchar(255),
PRIMARY KEY ([quotals_id])
);
CREATE TABLE [prefix_quota_members] (
[id] int NOT NULL IDENTITY (1,1),
[sid] int ,
[qid] int ,
[quota_id] int ,
[code] varchar(11) ,
PRIMARY KEY ([id])
);
--
-- Table structure for table [answers]
--
CREATE TABLE [prefix_answers] (
[qid] INT NOT NULL default '0',
[code] VARCHAR(5) NOT NULL default '',
[answer] varchar(8000) NOT NULL,
[default_value] char(1) NOT NULL default 'N',
[sortorder] INT NOT NULL,
[assessment_value] INT NOT NULL default '0',
[language] VARCHAR(20) default 'en',
PRIMARY KEY ([qid],[code],[language])
)
;
-- --------------------------------------------------------
--
-- Table structure for table [assessments]
--
CREATE TABLE [prefix_assessments] (
[id] INT NOT NULL IDENTITY (1,1),
[sid] INT NOT NULL default '0',
[scope] VARCHAR(5) NOT NULL default '',
[gid] INT NOT NULL default '0',
[name] text NOT NULL,
[minimum] VARCHAR(50) NOT NULL default '',
[maximum] VARCHAR(50) NOT NULL default '',
[message] text NOT NULL,
[language] VARCHAR(20) NOT NULL default 'en',
PRIMARY KEY ([id],[language])
)
;
-- --------------------------------------------------------
--
-- Table structure for table [conditions]
--
CREATE TABLE [prefix_conditions] (
[cid] INT NOT NULL IDENTITY (1,1),
[qid] INT NOT NULL default '0',
[scenario] INT NOT NULL default '1',
[cqid] INT NOT NULL default '0',
[cfieldname] VARCHAR(50) NOT NULL default '',
[method] char(2) NOT NULL default '',
[value] VARCHAR(255) NOT NULL default '',
PRIMARY KEY ([cid])
)
;
--
-- Table structure for table [groups]
--
CREATE TABLE [prefix_groups] (
[gid] INT NOT NULL IDENTITY (1,1),
[sid] INT NOT NULL default '0',
[group_name] VARCHAR(100) NOT NULL default '',
[group_order] INT NOT NULL default '0',
[description] text,
[language] VARCHAR(20) default 'en',
PRIMARY KEY ([gid],[language])
)
;
-- --------------------------------------------------------
--
-- Table structure for table [labels]
--
CREATE TABLE [prefix_labels] (
[lid] INT NOT NULL default '0',
[code] VARCHAR(5) NOT NULL default '',
[title] VARCHAR(4000),
[sortorder] INT NOT NULL,
[language] VARCHAR(20) default 'en',
[assessment_value] INT NOT NULL default '0',
PRIMARY KEY ([lid],[sortorder],[language]),
)
;
CREATE INDEX labels_code_idx
ON [prefix_labels] ([code])
;
-- --------------------------------------------------------
--
-- Table structure for table [labelsets]
--
CREATE TABLE [prefix_labelsets] (
[lid] INT NOT NULL IDENTITY (1,1),
[label_name] VARCHAR(100) NOT NULL default '',
[languages] VARCHAR(200) default 'en',
PRIMARY KEY ([lid])
)
;
-- --------------------------------------------------------
--
-- Table structure for table [question_attributes]
--
CREATE TABLE [prefix_question_attributes] (
[qaid] INT NOT NULL IDENTITY (1,1),
[qid] INT NOT NULL default '0',
[attribute] VARCHAR(50) default NULL,
[value] TEXT default NULL,
PRIMARY KEY ([qaid])
)
;
-- --------------------------------------------------------
--
-- Table structure for table [questions]
--
CREATE TABLE [prefix_questions] (
[qid] INT NOT NULL IDENTITY (1,1),
[sid] INT NOT NULL default '0',
[gid] INT NOT NULL default '0',
[type] char(1) NOT NULL default 'T',
[title] VARCHAR(20) NOT NULL default '',
[question] text NOT NULL,
[preg] text,
[help] text,
[other] char(1) NOT NULL default 'N',
[mandatory] char(1) default NULL,
[lid] INT NOT NULL default '0',
[lid1] INT NOT NULL default '0',
[question_order] INT NOT NULL,
[language] VARCHAR(20) default 'en',
PRIMARY KEY ([qid],[language])
)
;
-- --------------------------------------------------------
--
-- Table structure for table [saved_control]
--
CREATE TABLE [prefix_saved_control] (
[scid] INT NOT NULL IDENTITY (1,1),
[sid] INT NOT NULL default '0',
[srid] INT NOT NULL default '0',
[identifier] varchar(255) NOT NULL,
[access_code] text NOT NULL,
[email] VARCHAR(320) default NULL,
[ip] text NOT NULL,
[saved_thisstep] text NOT NULL,
[status] char(1) NOT NULL default '',
[saved_date] datetime,
[refurl] text,
PRIMARY KEY ([scid])
)
;
-- --------------------------------------------------------
--
-- Table structure for table [surveys]
--
CREATE TABLE [prefix_surveys] (
[sid] INT NOT NULL,
[owner_id] INT NOT NULL,
[admin] VARCHAR(50) default NULL,
[active] char(1) NOT NULL default 'N',
[startdate] DATETIME default NULL,
[expires] DATETIME default NULL,
[adminemail] VARCHAR(320) default NULL,
[private] char(1) default NULL,
[faxto] VARCHAR(20) default NULL,
[format] char(1) default NULL,
[template] VARCHAR(100) default 'default',
[language] VARCHAR(50) default NULL,
[additional_languages] VARCHAR(255) default NULL,
[datestamp] char(1) default 'N',
[usecookie] char(1) default 'N',
[notification] char(1) default '0',
[allowregister] char(1) default 'N',
[allowsave] char(1) default 'Y',
[autonumber_start] bigINT default '0',
[autoredirect] char(1) default 'N',
[allowprev] char(1) default 'Y',
[printanswers] char(1) default 'N',
[ipaddr] char(1) default 'N',
[refurl] char(1) default 'N',
[datecreated] DATETIME default NULL,
[listpublic] char(1) default 'N',
[publicstatistics] char(1) default 'N',
[publicgraphs] char(1) default 'N',
[htmlemail] char(1) default 'N',
[tokenanswerspersistence] char(1) default 'N',
[assessments] char(1) default 'N',
[usecaptcha] char(1) default 'N',
[usetokens] char(1) default 'N',
[bounce_email] VARCHAR(320) default NULL,
[attributedescriptions] text,
PRIMARY KEY ([sid])
)
;
--
-- Table structure for table [surveys_languagesettings]
--
if EXISTS (select * from dbo.sysobjects where id = object_id(N'[dbo].[prefix_surveys_languagesettings]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].[prefix_surveys_languagesettings]
;
CREATE TABLE [prefix_surveys_languagesettings] (
[surveyls_survey_id] INT NOT NULL DEFAULT 0,
[surveyls_language] VARCHAR(45) NOT NULL DEFAULT 'en',
[surveyls_title] VARCHAR(200) NOT NULL,
[surveyls_description] TEXT NULL,
[surveyls_welcometext] TEXT NULL,
[surveyls_endtext] TEXT NULL,
[surveyls_url] VARCHAR(255) NULL,
[surveyls_urldescription] VARCHAR(255) NULL,
[surveyls_email_invite_subj] VARCHAR(255) NULL,
[surveyls_email_invite] TEXT NULL,
[surveyls_email_remind_subj] VARCHAR(255) NULL,
[surveyls_email_remind] TEXT NULL,
[surveyls_email_register_subj] VARCHAR(255) NULL,
[surveyls_email_register] TEXT NULL,
[surveyls_email_confirm_subj] VARCHAR(255) NULL,
[surveyls_email_confirm] TEXT NULL,
[surveyls_dateformat] INT NOT NULL DEFAULT 1,
PRIMARY KEY ([surveyls_survey_id],[surveyls_language])
)
;
--
-- Table structure for table [users]
--
CREATE TABLE [prefix_users] (
[uid] INT NOT NULL IDENTITY (1,1) PRIMARY KEY,
[users_name] VARCHAR(64) NOT NULL UNIQUE default '',
[password] varchar(8000) NOT NULL default '',
[full_name] VARCHAR(50) NOT NULL,
[parent_id] INT NOT NULL,
[lang] VARCHAR(20),
[email] VARCHAR(320) NOT NULL UNIQUE,
[create_survey] TINYINT NOT NULL default '0',
[create_user] TINYINT NOT NULL default '0',
[delete_user] TINYINT NOT NULL default '0',
[superadmin] TINYINT NOT NULL default '0',
[configurator] TINYINT NOT NULL default '0',
[manage_template] TINYINT NOT NULL default '0',
[manage_label] TINYINT NOT NULL default '0',
[htmleditormode] char(7) default 'default',
[one_time_pw] TEXT,
[dateformat] INT NOT NULL DEFAULT 1
);
--
-- Table structure for table [surveys_rights]
--
CREATE TABLE [prefix_surveys_rights] (
[sid] INT NOT NULL default '0',
[uid] INT NOT NULL default '0',
[edit_survey_property] TINYINT NOT NULL default '0',
[define_questions] TINYINT NOT NULL default '0',
[browse_response] TINYINT NOT NULL default '0',
[export] TINYINT NOT NULL default '0',
[delete_survey] TINYINT NOT NULL default '0',
[activate_survey] TINYINT NOT NULL default '0',
PRIMARY KEY ([sid], [uid])
)
;
--
-- Table structure for table [user_groups]
--
CREATE TABLE [prefix_user_groups] (
[ugid] INT NOT NULL IDENTITY (1,1) PRIMARY KEY,
[name] VARCHAR(20) NOT NULL UNIQUE,
[description] TEXT NOT NULL default '',
[owner_id] INT NOT NULL
)
;
--
-- Table structure for table [user_in_groups]
--
CREATE TABLE [prefix_user_in_groups] (
[ugid] INT NOT NULL,
[uid] INT NOT NULL
)
;
--
-- Table structure for table [settings_global]
--
CREATE TABLE [prefix_settings_global] (
[stg_name] VARCHAR(50) NOT NULL default '',
[stg_value] VARCHAR(255) NOT NULL default '',
PRIMARY KEY ([stg_name])
);
CREATE TABLE [prefix_templates_rights] (
[uid] int NOT NULL,
[folder] varchar(255) NOT NULL,
[use] int NOT NULL,
PRIMARY KEY ([uid],[folder])
);
CREATE TABLE [prefix_templates] (
[folder] varchar(255) NOT NULL,
[creator] int NOT NULL,
PRIMARY KEY ([folder])
);
--
-- Table [settings_global]
--
INSERT INTO [prefix_settings_global] VALUES ('DBVersion', '138');
INSERT INTO [prefix_settings_global] VALUES ('SessionName', '$sessionname');
--
-- indexes
--
create index [answers_idx2] on [prefix_answers] ([sortorder]);
create index [assessments_idx2] on [prefix_assessments] ([sid]);
create index [assessments_idx3] on [prefix_assessments] ([gid]);
create index [conditions_idx2] on [prefix_conditions] ([qid]);
create index [conditions_idx3] on [prefix_conditions] ([cqid]);
create index [groups_idx2] on [prefix_groups] ([sid]);
create index [questions_idx2] on [prefix_questions] ([sid]);
create index [questions_idx3] on [prefix_questions] ([gid]);
create index [questions_idx4] on [prefix_questions] ([type]);
create index [question_attributes_idx2] on [prefix_question_attributes] ([qid]);
create index [quota_idx2] on [prefix_quota] ([sid]);
create index [saved_control_idx2] on [prefix_saved_control] ([sid]);
create index [user_in_groups_idx1] on [prefix_user_in_groups] ([ugid], [uid]);
--
-- Create the admin user
--
INSERT INTO [prefix_users] ([users_name], [password], [full_name], [parent_id], [lang] ,[email], [create_survey], [create_user] ,[delete_user] ,[superadmin] ,[configurator] ,[manage_template] , [manage_label]) VALUES ('$defaultuser', '$defaultpass', '$siteadminname', 0, '$defaultlang', '$siteadminemail', 1,1,1,1,1,1,1);

View File

@@ -1,390 +0,0 @@
--
-- Table structure for table `answers`
--
CREATE TABLE `prefix_answers` (
`qid` int(11) NOT NULL default '0',
`code` varchar(5) NOT NULL default '',
`answer` text NOT NULL,
`default_value` char(1) NOT NULL default 'N',
`assessment_value` int(11) NOT NULL default '0',
`sortorder` int(11) NOT NULL,
`language` varchar(20) default 'en',
PRIMARY KEY (`qid`,`code`,`language`)
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `assessments`
--
CREATE TABLE `prefix_assessments` (
`id` int(11) NOT NULL auto_increment,
`sid` int(11) NOT NULL default '0',
`scope` varchar(5) NOT NULL default '',
`gid` int(11) NOT NULL default '0',
`name` text NOT NULL,
`minimum` varchar(50) NOT NULL default '',
`maximum` varchar(50) NOT NULL default '',
`message` text NOT NULL,
`language` varchar(20) NOT NULL default 'en',
PRIMARY KEY (`id`,`language`)
) ENGINE=$databasetabletype AUTO_INCREMENT=1 CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `conditions`
--
CREATE TABLE `prefix_conditions` (
`cid` int(11) NOT NULL auto_increment,
`qid` int(11) NOT NULL default '0',
`scenario` int(11) NOT NULL default '1',
`cqid` int(11) NOT NULL default '0',
`cfieldname` varchar(50) NOT NULL default '',
`method` char(2) NOT NULL default '',
`value` varchar(255) NOT NULL default '',
PRIMARY KEY (`cid`)
) ENGINE=$databasetabletype AUTO_INCREMENT=1 CHARACTER SET utf8 COLLATE utf8_unicode_ci;
--
-- Table structure for table `groups`
--
CREATE TABLE `prefix_groups` (
`gid` int(11) NOT NULL auto_increment,
`sid` int(11) NOT NULL default '0',
`group_name` varchar(100) NOT NULL default '',
`group_order` int(11) NOT NULL default '0',
`description` text,
`language` varchar(20) default 'en',
PRIMARY KEY (`gid`,`language`)
) ENGINE=$databasetabletype AUTO_INCREMENT=1 CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `labels`
--
CREATE TABLE `prefix_labels` (
`lid` int(11) NOT NULL default '0',
`code` varchar(5) NOT NULL default '',
`title` text,
`sortorder` int(11) NOT NULL,
`assessment_value` int(11) NOT NULL default '0',
`language` varchar(20) default 'en',
PRIMARY KEY (`lid`,`sortorder`,`language`),
KEY `ixcode` (`code`)
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `labelsets`
--
CREATE TABLE `prefix_labelsets` (
`lid` int(11) NOT NULL auto_increment,
`label_name` varchar(100) NOT NULL default '',
`languages` varchar(200) default 'en',
PRIMARY KEY (`lid`)
) ENGINE=$databasetabletype AUTO_INCREMENT=1 CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `question_attributes`
--
CREATE TABLE `prefix_question_attributes` (
`qaid` int(11) NOT NULL auto_increment,
`qid` int(11) NOT NULL default '0',
`attribute` varchar(50) default NULL,
`value` text default NULL,
PRIMARY KEY (`qaid`)
) ENGINE=$databasetabletype AUTO_INCREMENT=1 CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-- --------------------------------------------------------
CREATE TABLE `prefix_quota` (
`id` int(11) NOT NULL auto_increment,
`sid` int(11) default NULL,
`name` varchar(255) collate utf8_unicode_ci default NULL,
`qlimit` int(8) default NULL,
`action` int(2) default NULL,
`active` int(1) NOT NULL default '1',
`autoload_url` int(1) NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
--
-- Table Structure for table quota_languagesettings
--
CREATE TABLE `prefix_quota_languagesettings` (
`quotals_id` int(11) NOT NULL auto_increment,
`quotals_quota_id` int(11) NOT NULL default '0',
`quotals_language` varchar(45) NOT NULL default 'en',
`quotals_name` varchar(255) collate utf8_unicode_ci default NULL,
`quotals_message` text NOT NULL,
`quotals_url` varchar(255),
`quotals_urldescrip` varchar(255),
PRIMARY KEY (`quotals_id`)
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE TABLE `prefix_quota_members` (
`id` int(11) NOT NULL auto_increment,
`sid` int(11) default NULL,
`qid` int(11) default NULL,
`quota_id` int(11) default NULL,
`code` varchar(11) collate utf8_unicode_ci default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `sid` (`sid`,`qid`,`quota_id`,`code`)
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
--
-- Table structure for table `questions`
--
CREATE TABLE `prefix_questions` (
`qid` int(11) NOT NULL auto_increment,
`sid` int(11) NOT NULL default '0',
`gid` int(11) NOT NULL default '0',
`type` char(1) NOT NULL default 'T',
`title` varchar(20) NOT NULL default '',
`question` text NOT NULL,
`preg` text,
`help` text,
`other` char(1) NOT NULL default 'N',
`mandatory` char(1) default NULL,
`lid` int(11) NOT NULL default '0',
`lid1` int(11) NOT NULL default '0',
`question_order` int(11) NOT NULL,
`language` varchar(20) default 'en',
PRIMARY KEY (`qid`,`language`)
) ENGINE=$databasetabletype AUTO_INCREMENT=1 CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `saved_control`
--
CREATE TABLE `prefix_saved_control` (
`scid` int(11) NOT NULL auto_increment,
`sid` int(11) NOT NULL default '0',
`srid` int(11) NOT NULL default '0',
`identifier` text NOT NULL,
`access_code` text NOT NULL,
`email` varchar(320) default NULL,
`ip` text NOT NULL,
`saved_thisstep` text NOT NULL,
`status` char(1) NOT NULL default '',
`saved_date` datetime NOT NULL,
`refurl` text,
PRIMARY KEY (`scid`)
) ENGINE=$databasetabletype AUTO_INCREMENT=1 CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `settings_global`
--
CREATE TABLE `prefix_settings_global` (
`stg_name` varchar(50) NOT NULL default '',
`stg_value` varchar(255) NOT NULL default '',
PRIMARY KEY (`stg_name`)
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
--
-- Table structure for table `surveys`
--
CREATE TABLE `prefix_surveys` (
`sid` int(11) NOT NULL,
`owner_id` int(11) NOT NULL,
`admin` varchar(50) default NULL,
`active` char(1) NOT NULL default 'N',
`expires` date default NULL,
`startdate` date default NULL,
`adminemail` varchar(320) default NULL,
`private` char(1) default NULL,
`faxto` varchar(20) default NULL,
`format` char(1) default NULL,
`template` varchar(100) default 'default',
`language` varchar(50) default NULL,
`additional_languages` varchar(255) default NULL,
`datestamp` char(1) default 'N',
`usecookie` char(1) default 'N',
`notification` char(1) default '0',
`allowregister` char(1) default 'N',
`allowsave` char(1) default 'Y',
`autonumber_start` bigint(11) default '0',
`autoredirect` char(1) default 'N',
`allowprev` char(1) default 'Y',
`printanswers` char(1) default 'N',
`ipaddr` char(1) default 'N',
`refurl` char(1) default 'N',
`datecreated` date default NULL,
`publicstatistics` char(1) default 'N',
`publicgraphs` char(1) default 'N',
`listpublic` char(1) default 'N',
`htmlemail` char(1) default 'N',
`tokenanswerspersistence` char(1) default 'N',
`assessments` char(1) default 'N',
`usecaptcha` char(1) default 'N',
`usetokens` char(1) default 'N',
`bounce_email` varchar(320) default NULL,
`attributedescriptions` text,
PRIMARY KEY (`sid`)
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
--
-- Table structure for table `surveys_languagesettings`
--
DROP TABLE IF EXISTS `prefix_surveys_languagesettings`;
CREATE TABLE `prefix_surveys_languagesettings` (
`surveyls_survey_id` INT UNSIGNED NOT NULL DEFAULT 0,
`surveyls_language` VARCHAR(45) NULL DEFAULT 'en',
`surveyls_title` VARCHAR(200) NOT NULL,
`surveyls_description` TEXT NULL,
`surveyls_welcometext` TEXT NULL,
`surveyls_endtext` TEXT NULL,
`surveyls_url` VARCHAR(255) NULL,
`surveyls_urldescription` VARCHAR(255) NULL,
`surveyls_email_invite_subj` VARCHAR(255) NULL,
`surveyls_email_invite` TEXT NULL,
`surveyls_email_remind_subj` VARCHAR(255) NULL,
`surveyls_email_remind` TEXT NULL,
`surveyls_email_register_subj` VARCHAR(255) NULL,
`surveyls_email_register` TEXT NULL,
`surveyls_email_confirm_subj` VARCHAR(255) NULL,
`surveyls_email_confirm` TEXT NULL,
`surveyls_dateformat` INT UNSIGNED NOT NULL DEFAULT 1,
PRIMARY KEY (`surveyls_survey_id`, `surveyls_language`)
)
TYPE = $databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
--
-- Table structure for table `surveys_rights`
--
CREATE TABLE `prefix_surveys_rights` (
`sid` int(10) unsigned NOT NULL default '0',
`uid` int(10) unsigned NOT NULL default '0',
`edit_survey_property` tinyint(1) NOT NULL default '0',
`define_questions` tinyint(1) NOT NULL default '0',
`browse_response` tinyint(1) NOT NULL default '0',
`export` tinyint(1) NOT NULL default '0',
`delete_survey` tinyint(1) NOT NULL default '0',
`activate_survey` tinyint(1) NOT NULL default '0',
PRIMARY KEY (sid, uid)
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE TABLE `prefix_user_groups` (
`ugid` int(10) unsigned NOT NULL auto_increment PRIMARY KEY,
`name` varchar(20) NOT NULL UNIQUE,
`description` TEXT NOT NULL,
`owner_id` int(10) unsigned NOT NULL
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE TABLE `prefix_user_in_groups` (
`ugid` int(10) unsigned NOT NULL,
`uid` int(10) unsigned NOT NULL
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
--
-- Table structure for table `users`
--
CREATE TABLE `prefix_users` (
`uid` int(11) NOT NULL auto_increment PRIMARY KEY,
`users_name` varchar(64) NOT NULL UNIQUE default '',
`password` BLOB NOT NULL,
`full_name` varchar(50) NOT NULL,
`parent_id` int(10) unsigned NOT NULL,
`lang` varchar(20),
`email` varchar(320),
`create_survey` tinyint(1) NOT NULL default '0',
`create_user` tinyint(1) NOT NULL default '0',
`delete_user` tinyint(1) NOT NULL default '0',
`superadmin` tinyint(1) NOT NULL default '0',
`configurator` tinyint(1) NOT NULL default '0',
`manage_template` tinyint(1) NOT NULL default '0',
`manage_label` tinyint(1) NOT NULL default '0',
`htmleditormode` varchar(7) default 'default',
`one_time_pw` BLOB,
`dateformat` INT UNSIGNED NOT NULL DEFAULT 1
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE TABLE `prefix_templates_rights` (
`uid` int(11) NOT NULL,
`folder` varchar(255) NOT NULL,
`use` int(1) NOT NULL,
PRIMARY KEY (`uid`,`folder`)
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE TABLE `prefix_templates` (
`folder` varchar(255) NOT NULL,
`creator` int(11) NOT NULL,
PRIMARY KEY (`folder`)
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;
--
-- Table `settings_global`
--
INSERT INTO `prefix_settings_global` VALUES ('DBVersion', '138');
INSERT INTO `prefix_settings_global` VALUES ('SessionName', '$sessionname');
--
-- Table `users`
--
INSERT INTO `prefix_users` (`users_name`, `password`, `full_name`, `parent_id`, `lang` ,`email`, `create_survey`,`create_user` ,`delete_user` ,`superadmin` ,`configurator` ,`manage_template` , `manage_label`) VALUES ('$defaultuser', '$defaultpass', '$siteadminname', 0, '$defaultlang', '$siteadminemail', 1,1,1,1,1,1,1);
--
-- indexes
--
create index `answers_idx2` on `prefix_answers` (`sortorder`);
create index `assessments_idx2` on `prefix_assessments` (`sid`);
create index `assessments_idx3` on `prefix_assessments` (`gid`);
create index `conditions_idx2` on `prefix_conditions` (`qid`);
create index `conditions_idx3` on `prefix_conditions` (`cqid`);
create index `groups_idx2` on `prefix_groups` (`sid`);
create index `question_attributes_idx2` on `prefix_question_attributes` (`qid`);
create index `questions_idx2` on `prefix_questions` (`sid`);
create index `questions_idx3` on `prefix_questions` (`gid`);
create index `questions_idx4` on `prefix_questions` (`type`);
create index `quota_idx2` on `prefix_quota` (`sid`);
create index `saved_control_idx2` on `prefix_saved_control` (`sid`);
create index `user_in_groups_idx1` on `prefix_user_in_groups` (`ugid`, `uid`);

View File

@@ -1,547 +0,0 @@
--
-- PostgreSQL database dump
--
-- Started on 2007-11-18 18:48:15
SET client_encoding = 'UTF8';
SET check_function_bodies = false;
SET client_min_messages = warning;
SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- TOC entry 1300 (class 1259 OID 16405)
-- Dependencies: 1655 1656 1657 1658 4
-- Name: prefix_answers; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE prefix_answers (
qid integer DEFAULT 0 NOT NULL,
code character varying(5) DEFAULT ''::character varying NOT NULL,
answer text NOT NULL,
default_value character(1) DEFAULT 'N'::bpchar NOT NULL,
sortorder integer NOT NULL,
assessment_value integer DEFAULT 0 NOT NULL,
"language" character varying(20) DEFAULT 'en'::character varying NOT NULL
);
--
-- TOC entry 1302 (class 1259 OID 16418)
-- Dependencies: 1660 1661 1662 1663 1664 4
-- Name: prefix_assessments; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE prefix_assessments (
id serial,
sid integer DEFAULT 0 NOT NULL,
scope character varying(5) DEFAULT ''::character varying NOT NULL,
gid integer DEFAULT 0 NOT NULL,
name text NOT NULL,
minimum character varying(50) DEFAULT ''::character varying NOT NULL,
maximum character varying(50) DEFAULT ''::character varying NOT NULL,
message text NOT NULL,
language character(20) DEFAULT 'en'::bpchar NOT NULL
);
--
-- TOC entry 1304 (class 1259 OID 16433)
-- Dependencies: 1666 1667 1668 1669 1670 4
-- Name: prefix_conditions; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE prefix_conditions (
cid serial,
qid integer DEFAULT 0 NOT NULL,
scenario integer DEFAULT 1 NOT NULL,
cqid integer DEFAULT 0 NOT NULL,
cfieldname character varying(50) DEFAULT ''::character varying NOT NULL,
method character(2) DEFAULT ''::bpchar NOT NULL,
value character varying(255) DEFAULT ''::character varying NOT NULL
);
--
-- TOC entry 1306 (class 1259 OID 16445)
-- Dependencies: 1672 1673 1674 1675 4
-- Name: prefix_groups; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE prefix_groups (
gid serial ,
sid integer DEFAULT 0 NOT NULL,
group_name character varying(100) DEFAULT ''::character varying NOT NULL,
group_order integer DEFAULT 0 NOT NULL,
description text,
"language" character varying(20) DEFAULT 'en'::character varying NOT NULL
);
--
-- TOC entry 1307 (class 1259 OID 16457)
-- Dependencies: 1676 1677 1678 1679 4
-- Name: prefix_labels; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE prefix_labels (
lid integer DEFAULT 0 NOT NULL,
code character varying(5) DEFAULT ''::character varying NOT NULL,
title text,
sortorder integer NOT NULL,
assessment_value integer DEFAULT 0 NOT NULL,
"language" character varying(20) DEFAULT 'en'::character varying NOT NULL
);
--
-- TOC entry 1309 (class 1259 OID 16468)
-- Dependencies: 1681 1682 4
-- Name: prefix_labelsets; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE prefix_labelsets (
lid serial NOT NULL,
label_name character varying(100) DEFAULT ''::character varying NOT NULL,
languages character varying(200) DEFAULT 'en'::character varying
);
--
-- TOC entry 1313 (class 1259 OID 16494)
-- Dependencies: 1692 4
-- Name: prefix_question_attributes; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE prefix_question_attributes (
qaid serial NOT NULL,
qid integer DEFAULT 0 NOT NULL,
attribute character varying(50),
value text NULL
);
--
-- Table structure for table `quota`
--
CREATE TABLE prefix_quota (
id serial NOT NULL,
sid integer,
name character varying(255),
qlimit integer,
"action" integer,
"active" integer NOT NULL default '1',
autoload_url integer NOT NULL DEFAULT 0
);
ALTER TABLE ONLY prefix_quota
ADD CONSTRAINT prefix_quota_pkey PRIMARY KEY (id);
CREATE TABLE prefix_quota_languagesettings
(
quotals_id serial NOT NULL,
quotals_quota_id integer NOT NULL DEFAULT 0,
quotals_language character varying(45) NOT NULL DEFAULT 'en'::character varying,
quotals_name character varying(200),
quotals_message text NOT NULL,
quotals_url character varying(255),
quotals_urldescrip character varying(255)
);
ALTER TABLE ONLY prefix_quota_languagesettings
ADD CONSTRAINT prefix_quota_languagesettings_pkey PRIMARY KEY (quotals_id);
CREATE TABLE prefix_quota_members (
id serial,
sid integer,
qid integer,
quota_id integer,
code character varying(11)
);
ALTER TABLE ONLY prefix_quota_members
ADD CONSTRAINT prefix_quota_members_pkey PRIMARY KEY (id);
CREATE INDEX prefix_quota_members_ixcode_idx ON prefix_quota_members USING btree (sid,qid,quota_id,code);
--
-- Name: prefix_questions; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE prefix_questions (
qid serial NOT NULL,
sid integer DEFAULT 0 NOT NULL,
gid integer DEFAULT 0 NOT NULL,
"type" character(1) DEFAULT 'T'::bpchar NOT NULL,
title character varying(20) DEFAULT ''::character varying NOT NULL,
question text NOT NULL,
preg text,
help text,
other character(1) DEFAULT 'N'::bpchar NOT NULL,
mandatory character(1),
lid integer DEFAULT 0 NOT NULL,
lid1 integer DEFAULT 0 NOT NULL,
question_order integer NOT NULL,
"language" character varying(20) DEFAULT 'en'::character varying NOT NULL
);
--
-- TOC entry 1315 (class 1259 OID 16502)
-- Dependencies: 1694 1695 1696 4
-- Name: prefix_saved_control; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE prefix_saved_control (
scid serial NOT NULL,
sid integer DEFAULT 0 NOT NULL,
srid integer DEFAULT 0 NOT NULL,
identifier text,
access_code text NOT NULL,
email character varying(320) NOT NULL,
ip text NOT NULL,
saved_thisstep text NOT NULL,
status character(1) DEFAULT ''::bpchar NOT NULL,
saved_date timestamp without time zone NOT NULL,
refurl text
);
--
-- Dependencies: 1697 1698 4
-- Name: prefix_settings_global; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE prefix_settings_global (
stg_name character varying(50) DEFAULT ''::character varying NOT NULL,
stg_value character varying(255) DEFAULT ''::character varying NOT NULL
);
--
-- Name: prefix_surveys; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE prefix_surveys (
sid integer NOT NULL,
owner_id integer NOT NULL,
"admin" character varying(50),
active character(1) DEFAULT 'N'::bpchar NOT NULL,
startdate date,
expires date,
adminemail character varying(320) NOT NULL,
private character(1),
faxto character varying(20),
format character(1),
"template" character varying(100) DEFAULT 'default'::character varying,
"language" character varying(50),
additional_languages character varying(255),
datestamp character(1) DEFAULT 'N'::bpchar,
usecookie character(1) DEFAULT 'N'::bpchar,
notification character(1) DEFAULT '0'::bpchar,
allowregister character(1) DEFAULT 'N'::bpchar,
allowsave character(1) DEFAULT 'Y'::bpchar,
printanswers character(1) DEFAULT 'N'::bpchar,
autonumber_start integer DEFAULT 0,
autoredirect character(1) DEFAULT 'N'::bpchar,
allowprev character(1) DEFAULT 'Y'::bpchar,
ipaddr character(1) DEFAULT 'N'::bpchar,
refurl character(1) DEFAULT 'N'::bpchar,
datecreated date,
listpublic character(1) DEFAULT 'N'::bpchar,
publicstatistics character(1) DEFAULT 'N'::bpchar,
publicgraphs character(1) DEFAULT 'N'::bpchar,
htmlemail character(1) DEFAULT 'N'::bpchar,
tokenanswerspersistence character(1) DEFAULT 'N'::bpchar,
assessments character(1) DEFAULT 'N'::bpchar,
usecaptcha character(1) DEFAULT 'N'::bpchar,
usetokens character(1) DEFAULT 'N'::bpchar,
"bounce_email" character varying(320) NOT NULL,
attributedescriptions text
);
-- Dependencies: 1713 1714 4
-- Name: prefix_surveys_languagesettings; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE prefix_surveys_languagesettings (
surveyls_survey_id integer DEFAULT 0 NOT NULL,
surveyls_language character varying(45) DEFAULT 'en'::character varying NOT NULL,
surveyls_title character varying(200) NOT NULL,
surveyls_description text,
surveyls_welcometext text,
surveyls_url character varying(255),
surveyls_urldescription character varying(255),
surveyls_endtext text,
surveyls_email_invite_subj character varying(255),
surveyls_email_invite text,
surveyls_email_remind_subj character varying(255),
surveyls_email_remind text,
surveyls_email_register_subj character varying(255),
surveyls_email_register text,
surveyls_email_confirm_subj character varying(255),
surveyls_email_confirm text,
surveyls_dateformat integer DEFAULT 1 NOT NULL
);
--
-- TOC entry 1319 (class 1259 OID 16549)
-- Dependencies: 1715 1716 1717 1718 1719 1720 1721 1722 4
-- Name: prefix_surveys_rights; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE prefix_surveys_rights (
sid integer DEFAULT 0 NOT NULL,
uid integer DEFAULT 0 NOT NULL,
edit_survey_property integer DEFAULT 0 NOT NULL,
define_questions integer DEFAULT 0 NOT NULL,
browse_response integer DEFAULT 0 NOT NULL,
export integer DEFAULT 0 NOT NULL,
delete_survey integer DEFAULT 0 NOT NULL,
activate_survey integer DEFAULT 0 NOT NULL
);
-- Name: prefix_user_groups; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
CREATE TABLE prefix_user_groups (
ugid serial NOT NULL,
name character varying(20) NOT NULL,
description text NOT NULL,
owner_id integer NOT NULL
);
CREATE TABLE prefix_user_in_groups (
ugid integer NOT NULL,
uid integer NOT NULL
);
--
-- Name: prefix_users; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE prefix_users (
uid serial PRIMARY KEY NOT NULL,
users_name character varying(64) DEFAULT ''::character varying UNIQUE NOT NULL,
"password" bytea NOT NULL,
full_name character varying(50) NOT NULL,
parent_id integer NOT NULL,
lang character varying(20),
email character varying(320) NOT NULL,
create_survey integer DEFAULT 0 NOT NULL,
create_user integer DEFAULT 0 NOT NULL,
delete_user integer DEFAULT 0 NOT NULL,
superadmin integer DEFAULT 0 NOT NULL,
configurator integer DEFAULT 0 NOT NULL,
manage_template integer DEFAULT 0 NOT NULL,
manage_label integer DEFAULT 0 NOT NULL,
htmleditormode character(7) DEFAULT 'default'::bpchar,
one_time_pw bytea,
"dateformat" integer DEFAULT 1 NOT NULL
);
CREATE TABLE prefix_templates_rights (
"uid" integer NOT NULL,
"folder" character varying(255) NOT NULL,
"use" integer NOT NULL
);
ALTER TABLE ONLY prefix_templates_rights
ADD CONSTRAINT prefix_templates_rights_pkey PRIMARY KEY ("uid","folder");
CREATE TABLE prefix_templates (
"folder" character varying(255) NOT NULL,
"creator" integer NOT NULL
);
ALTER TABLE ONLY prefix_templates
ADD CONSTRAINT prefix_templates_pkey PRIMARY KEY ("folder");
--
-- TOC entry 1734 (class 2606 OID 16415)
-- Dependencies: 1300 1300 1300 1300
-- Name: prefix_answers_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY prefix_answers
ADD CONSTRAINT prefix_answers_pkey PRIMARY KEY (qid, code, "language");
--
-- TOC entry 1736 (class 2606 OID 16430)
-- Dependencies: 1302 1302
-- Name: prefix_assessments_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY prefix_assessments
ADD CONSTRAINT prefix_assessments_pkey PRIMARY KEY (id,language);
--
-- TOC entry 1738 (class 2606 OID 16442)
-- Dependencies: 1304 1304
-- Name: prefix_conditions_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY prefix_conditions
ADD CONSTRAINT prefix_conditions_pkey PRIMARY KEY (cid);
--
-- TOC entry 1740 (class 2606 OID 16456)
-- Dependencies: 1306 1306 1306
-- Name: prefix_groups_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY prefix_groups
ADD CONSTRAINT prefix_groups_pkey PRIMARY KEY (gid, "language");
--
-- TOC entry 1743 (class 2606 OID 16464)
-- Dependencies: 1307 1307 1307 1307
-- Name: prefix_labels_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY prefix_labels
ADD CONSTRAINT prefix_labels_pkey PRIMARY KEY (lid, sortorder, "language");
--
-- TOC entry 1745 (class 2606 OID 16474)
-- Dependencies: 1309 1309
-- Name: prefix_labelsets_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY prefix_labelsets
ADD CONSTRAINT prefix_labelsets_pkey PRIMARY KEY (lid);
--
-- TOC entry 1749 (class 2606 OID 16499)
-- Dependencies: 1313 1313
-- Name: prefix_question_attributes_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY prefix_question_attributes
ADD CONSTRAINT prefix_question_attributes_pkey PRIMARY KEY (qaid);
--
-- TOC entry 1747 (class 2606 OID 16491)
-- Dependencies: 1311 1311 1311
-- Name: prefix_questions_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY prefix_questions
ADD CONSTRAINT prefix_questions_pkey PRIMARY KEY (qid, "language");
--
-- TOC entry 1751 (class 2606 OID 16512)
-- Dependencies: 1315 1315
-- Name: prefix_saved_control_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY prefix_saved_control
ADD CONSTRAINT prefix_saved_control_pkey PRIMARY KEY (scid);
--
-- TOC entry 1753 (class 2606 OID 16518)
-- Dependencies: 1316 1316
-- Name: prefix_settings_global_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY prefix_settings_global
ADD CONSTRAINT prefix_settings_global_pkey PRIMARY KEY (stg_name);
--
-- TOC entry 1757 (class 2606 OID 16548)
-- Dependencies: 1318 1318 1318
-- Name: prefix_surveys_languagesettings_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY prefix_surveys_languagesettings
ADD CONSTRAINT prefix_surveys_languagesettings_pkey PRIMARY KEY (surveyls_survey_id, surveyls_language);
--
-- TOC entry 1755 (class 2606 OID 16539)
-- Dependencies: 1317 1317
-- Name: prefix_surveys_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY prefix_surveys
ADD CONSTRAINT prefix_surveys_pkey PRIMARY KEY (sid);
--
-- TOC entry 1759 (class 2606 OID 16560)
-- Dependencies: 1319 1319 1319
-- Name: prefix_surveys_rights_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY prefix_surveys_rights
ADD CONSTRAINT prefix_surveys_rights_pkey PRIMARY KEY (sid, uid);
--
-- TOC entry 1741 (class 1259 OID 16465)
-- Dependencies: 1307
-- Name: prefix_labels_ixcode_idx; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
--
CREATE INDEX prefix_labels_ixcode_idx ON prefix_labels USING btree (code);
--
-- Table `settings_global`
--
INSERT INTO prefix_settings_global VALUES ('DBVersion', '138');
INSERT INTO prefix_settings_global VALUES ('SessionName', '$sessionname');
--
-- indexes
--
create index assessments_idx2 on prefix_assessments (sid);
create index assessments_idx3 on prefix_assessments (gid);
create index conditions_idx2 on prefix_conditions (qid);
create index groups_idx2 on prefix_groups (sid);
create index question_attributes_idx2 on prefix_question_attributes (qid);
create index questions_idx2 on prefix_questions (sid);
create index questions_idx3 on prefix_questions (gid);
create index quota_idx2 on prefix_quota (sid);
create index saved_control_idx2 on prefix_saved_control (sid);
create index user_in_groups_idx1 on prefix_user_in_groups (ugid, uid);
--
-- Create admin user
--
INSERT INTO prefix_users(
users_name, "password", full_name, parent_id, lang, email,
create_survey, create_user, delete_user, superadmin, configurator,
manage_template, manage_label,htmleditormode)
VALUES ('$defaultuser', '$defaultpass', '$siteadminname', 0, '$defaultlang', '$siteadminemail',1,1,1,1,1,1,1,'default');

View File

@@ -1,100 +0,0 @@
<?php
/*
* LimeSurvey
* Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id: createdb.php 7053 2009-06-10 10:43:43Z c_schmitz $
*/
//Ensure script is not run directly, avoid path disclosure
if (isset($_REQUEST['rootdir'])) {die('You cannot start this script directly');}
require_once(dirname(__FILE__).'/../../config-defaults.php');
require_once(dirname(__FILE__).'/../../common.php');
require_once($rootdir.'/classes/core/language.php');
$clang = new limesurvey_lang("en");
$dbname = $databasename;
sendcacheheaders();
echo "<br />\n";
echo "<table width='350' align='center' style='border: 1px solid #555555' cellpadding='1' cellspacing='0'>\n";
echo "\t<tr bgcolor='#555555'><td colspan='2' height='4'><font size='1' face='verdana' color='white'><strong>".$clang->gT("Create Database")."</strong></td></tr>\n";
echo "\t<tr bgcolor='#CCCCCC'><td align='center'>$setfont\n";
// In Step2 fill the database with data
if (returnglobal('createdbstep2')==$clang->gT("Populate Database"))
{
$createdbtype=$databasetype;
if ($databasetype=='mysql' || $databasetype=='mysqli') {
@$connect->Execute("ALTER DATABASE `$dbname` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;");
$createdbtype='mysql';
}
if ($createdbtype=='mssql_n' || $createdbtype=='odbc_mssql' || $createdbtype=='odbtp') $createdbtype='mssql';
if (modify_database(dirname(__FILE__).'/create-'.$createdbtype.'.sql'))
{
echo sprintf($clang->gT("Database `%s` has been successfully populated."),$dbname)."</font></strong></font><br /><br />\n";
echo "<input type='submit' value='".$clang->gT("Main Admin Screen")."' onclick='location.href=\"../$scriptname\"'>";
exit;
}
else
{
echo $modifyoutput;
echo"Error";
}
}
if (!$dbname)
{
echo "<br /><strong>$setfont<font color='red'>".$clang->gT("Error")."</font></strong><br />\n";
echo $clang->gT("Database Information not provided. This script must be run from admin.php only.");
echo "<br /><br />\n";
echo "<input type='submit' value='".$clang->gT("Main Admin Screen")."' onclick='location.href=\"../$scriptname\"'>";
exit;
}
if (!$database_exists) //Database named in config-defaults.php does not exist
{
// TODO SQL: Portable to other databases??
switch ($databasetype)
{
case 'mysqli':
case 'mysql': $createDb=$connect->Execute("CREATE DATABASE `$dbname` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci");
break;
case 'mssql_n':
case 'odbc_mssql':
case 'odbtp': $createDb=$connect->Execute("CREATE DATABASE [$dbname];");
break;
default: $createDb=$connect->Execute("CREATE DATABASE $dbname");
}
if ($createDb) //Database has been successfully created
{
$connect->database = $dbname;
$connect->Execute("USE DATABASE `$dbname`");
echo "<br />$setfont<strong><font class='successtitle'>\n";
echo $clang->gT("Database has been created.")."</font></strong></font><br /><br />\n";
echo $clang->gT("Please click below to populate the database")."<br /><br />\n";
echo "<form method='post'>";
echo "<input type='submit' name='createdbstep2' value='".$clang->gT("Populate Database")."' onclick='location.href=\"createdb.php\"'></form>";
}
else
{
echo "<strong>$setfont<font color='red'>".$clang->gT("Error")."</font></strong></font><br />\n";
echo $clang->gT("Could not create database")." ($dbname)<br /><font size='1'>\n";
echo $connect->ErrorMsg();
echo "</font><br /><br />\n";
echo "<input type='submit' value='".$clang->gT("Main Admin Screen")."' onclick='location.href=\"../$scriptname\"'>";
}
}
echo "</td></tr></table>\n";
?>

View File

@@ -1,95 +0,0 @@
<?php
/*
* LimeSurvey
* Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id: index.php 6952 2009-05-27 09:40:07Z c_schmitz $
*/
if (isset($_REQUEST['rootdir'])) {die('You cannot start this script directly');}
require_once(dirname(__FILE__).'/../../config-defaults.php');
require_once(dirname(__FILE__).'/../../common.php');
$adminoutput=''; // Alle future output is written into this and then outputted at the end of file
// SET THE LANGUAGE???? -> DEFAULT SET TO EN FOR NOW
require_once($rootdir.'/classes/core/language.php');
$clang = new limesurvey_lang("en");
ob_implicit_flush(true);
sendcacheheaders();
if (!$database_exists)
{
$adminoutput.= "<br />\n"
."<table width='350' align='center' style='border: 1px solid #555555' cellpadding='1' cellspacing='0'>\n"
."\t<tr bgcolor='#555555'><td colspan='2' height='4'><font size='1' face='verdana' color='white'><strong>"
.$clang->gT("LimeSurvey Setup")."</strong></td></tr>\n"
."\t<tr bgcolor='#CCCCCC'><td align='center'>\n"
."<strong>".$clang->gT("Welcome to LimeSurvey Setup!")."</strong><br /><br />\n"
.$clang->gT("The database defined in config.php does not exist.")."<br />\n"
.$clang->gT("LimeSurvey can attempt to create this database for you.")."<br /><br />\n"
.$clang->gT("Your selected database name is:")."<strong> $databasename</strong><br />\n"
."<br /><input type='submit' value='"
.$clang->gT("Create Database")."' onclick='location.href=\"createdb.php\"' /></center>\n"
."</td></tr></table>\n"
."</body>\n</html>\n";
}
elseif ($dbexistsbutempty && !(returnglobal('createdbstep2')==$clang->gT("Populate Database")))
{
$connect->database = $databasename;
$connect->Execute("USE DATABASE `$databasename`");
$adminoutput.= "<table width='350' align='center' style='border: 1px solid #555555' cellpadding='1' cellspacing='0'>\n"
."\t<tr bgcolor='#555555'><td colspan='2' height='4'><font size='1' face='verdana' color='white'><strong>"
.$clang->gT("LimeSurvey Setup")."</strong></td></tr>\n"
."\t<tr bgcolor='#CCCCCC'><td align='center'>\n";
$adminoutput.= "<br /><strong><font class='successtitle'>\n";
$adminoutput.= sprintf($clang->gT('A database named "%s" already exists.'),$databasename)."</font></strong></font><br /><br />\n";
$adminoutput.= $clang->gT("Do you want to populate that database now by creating the necessary tables?")."<br /><br />\n";
$adminoutput.= "<form method='post' action='createdb.php'>";
$adminoutput.= "<input type='submit' name='createdbstep2' value='".$clang->gT("Populate Database")."'></form>";
}
else
{
//DB EXISTS, CHECK FOR APPROPRIATE UPGRADES
$connect->database = $databasename;
$connect->Execute("USE DATABASE `$databasename`");
$output=checkforupgrades();
if ($output== '') {$adminoutput.='<br />LimeSurvey Database is up to date. No action needed';}
else {$adminoutput.=$output;}
$adminoutput.="<br />Please <a href='$homeurl/$scriptname'>log in.</a>";
}
echo $adminoutput;
// This functions checks if the databaseversion in the settings table is the same one as required
function checkforupgrades()
{
global $connect, $databasetype, $dbprefix, $dbversionnumber, $clang;
$adminoutput='';
$upgradedbtype=$databasetype;
if ($upgradedbtype=='mssql_n' || $upgradedbtype=='odbc_mssql' || $upgradedbtype=='odbtp') $upgradedbtype='mssql';
if ($upgradedbtype=='mysqli') $upgradedbtype='mysql';
include ('upgrade-'.$upgradedbtype.'.php');
$tables = $connect->MetaTables();
$usquery = "SELECT stg_value FROM ".db_table_name("settings_global")." where stg_name='DBVersion'";
$usresult = db_execute_assoc($usquery);
$usrow = $usresult->FetchRow();
if (intval($usrow['stg_value'])<$dbversionnumber)
{
db_upgrade(intval($usrow['stg_value']));
$adminoutput="<br />".$clang->gT("Database has been successfully upgraded to version ".$dbversionnumber);
}
return $adminoutput;
}
?>

View File

@@ -1,17 +0,0 @@
<?php
/*
* LimeSurvey
* Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id: phpinfo.php 3579 2007-11-06 00:08:12Z leochaton $
*/
phpinfo();
?>

View File

@@ -1,38 +0,0 @@
<?php
/*
* LimeSurvey
* Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id: index.php 4037 2008-01-20 15:23:53Z c_schmitz $
*/
require_once(dirname(__FILE__).'/../../config-defaults.php');
require_once(dirname(__FILE__).'/../../common.php');
require_once($rootdir.'/classes/core/language.php');
$clang = new limesurvey_lang("en");
ob_implicit_flush(true);
sendcacheheaders();
switch ($databasetype)
{
case 'mysqli':
case 'mysql' : modify_database("",'UPDATE `prefix_users` set password=\'$defaultpass\' where uid=1;');
echo $modifyoutput; flush();
break;
case 'odbtp':
case 'mssql_n':
case 'odbc_mssql':modify_database("",'UPDATE [prefix_users] set password=\'$defaultpass\' where uid=1;');
echo $modifyoutput; flush();
break;
case 'postgres':modify_database("",'UPDATE prefix_users set \"password\"=\'$defaultpass\' where uid=1;');
echo $modifyoutput; flush();
break;
}
?>

View File

@@ -1,445 +0,0 @@
<?PHP
/*
* LimeSurvey
* Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id: upgrade-mssql.php 7122 2009-06-16 13:42:29Z c_schmitz $
*/
// There will be a file for each database (accordingly named to the dbADO scheme)
// where based on the current database version the database is upgraded
// For this there will be a settings table which holds the last time the database was upgraded
function db_upgrade($oldversion) {
/// This function does anything necessary to upgrade
/// older versions to match current functionality
global $modifyoutput, $dbprefix;
echo str_pad('Loading... ',4096)."<br />\n";
if ($oldversion < 111) {
// Language upgrades from version 110 to 111 since the language names did change
$oldnewlanguages=array('german_informal'=>'german-informal',
'cns'=>'cn-Hans',
'cnt'=>'cn-Hant',
'pt_br'=>'pt-BR',
'gr'=>'el',
'jp'=>'ja',
'si'=>'sl',
'se'=>'sv',
'vn'=>'vi');
foreach ($oldnewlanguages as $oldlang=>$newlang)
{
modify_database("","update [prefix_answers] set [language`='$newlang' where language='$oldlang'"); echo $modifyoutput; flush();
modify_database("","update [prefix_questions] set [language`='$newlang' where language='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_groups] set [language`='$newlang' where language='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_labels] set [language`='$newlang' where language='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_surveys] set [language`='$newlang' where language='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_surveys_languagesettings] set [surveyls_language`='$newlang' where surveyls_language='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_users] set [lang`='$newlang' where lang='$oldlang'");echo $modifyoutput;flush();
}
$resultdata=db_execute_assoc("select * from ".db_table_name("labelsets"));
while ($datarow = $resultdata->FetchRow()){
$toreplace=$datarow['languages'];
$toreplace=str_replace('german_informal','german-informal',$toreplace);
$toreplace=str_replace('cns','cn-Hans',$toreplace);
$toreplace=str_replace('cnt','cn-Hant',$toreplace);
$toreplace=str_replace('pt_br','pt-BR',$toreplace);
$toreplace=str_replace('gr','el',$toreplace);
$toreplace=str_replace('jp','ja',$toreplace);
$toreplace=str_replace('si','sl',$toreplace);
$toreplace=str_replace('se','sv',$toreplace);
$toreplace=str_replace('vn','vi',$toreplace);
modify_database("","update [prefix_labelsets] set [languages`='$toreplace' where lid=".$datarow['lid']);echo $modifyoutput;flush();
}
$resultdata=db_execute_assoc("select * from ".db_table_name("surveys"));
while ($datarow = $resultdata->FetchRow()){
$toreplace=$datarow['additional_languages'];
$toreplace=str_replace('german_informal','german-informal',$toreplace);
$toreplace=str_replace('cns','cn-Hans',$toreplace);
$toreplace=str_replace('cnt','cn-Hant',$toreplace);
$toreplace=str_replace('pt_br','pt-BR',$toreplace);
$toreplace=str_replace('gr','el',$toreplace);
$toreplace=str_replace('jp','ja',$toreplace);
$toreplace=str_replace('si','sl',$toreplace);
$toreplace=str_replace('se','sv',$toreplace);
$toreplace=str_replace('vn','vi',$toreplace);
modify_database("","update [prefix_surveys] set [additional_languages`='$toreplace' where sid=".$datarow['sid']);echo $modifyoutput;flush();
}
modify_database("","update [prefix_settings_global] set [stg_value]='111' where stg_name='DBVersion'"); echo $modifyoutput;
}
if ($oldversion < 112) {
//The size of the users_name field is now 64 char (20 char before version 112)
modify_database("","ALTER TABLE [prefix_users] ALTER COLUMN [users_name] VARCHAR( 64 ) NOT NULL"); echo $modifyoutput; flush();
modify_database("","update [prefix_settings_global] set [stg_value]='112' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 113) {
//No action needed
modify_database("","update [prefix_settings_global] set [stg_value]='113' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 114) {
modify_database("","ALTER TABLE [prefix_saved_control] ALTER COLUMN [email] VARCHAR(320) NOT NULL"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_surveys] ALTER COLUMN [adminemail] VARCHAR(320) NOT NULL"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_users] ALTER COLUMN [email] VARCHAR(320) NOT NULL"); echo $modifyoutput; flush();
modify_database("",'INSERT INTO [prefix_settings_global] VALUES (\'SessionName\', \'$sessionname\');');echo $modifyoutput; flush();
modify_database("","update [prefix_settings_global] set [stg_value]='114' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 126) {
modify_database("","ALTER TABLE [prefix_surveys] ADD [printanswers] CHAR(1) DEFAULT 'N'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_surveys] ADD [listpublic] CHAR(1) DEFAULT 'N'"); echo $modifyoutput; flush();
upgrade_survey_tables117();
upgrade_survey_tables118();
//119
modify_database("","CREATE TABLE [prefix_quota] (
[id] int NOT NULL IDENTITY (1,1),
[sid] int,
[name] varchar(255) ,
[qlimit] int ,
[action] int ,
[active] int NOT NULL default '1',
PRIMARY KEY ([id])
);");echo $modifyoutput; flush();
modify_database("","CREATE TABLE [prefix_quota_members] (
[id] int NOT NULL IDENTITY (1,1),
[sid] int ,
[qid] int ,
[quota_id] int ,
[code] varchar(5) ,
PRIMARY KEY ([id])
);");echo $modifyoutput; flush();
// Rename Norwegian language code from NO to NB
$oldnewlanguages=array('no'=>'nb');
foreach ($oldnewlanguages as $oldlang=>$newlang)
{
modify_database("","update [prefix_answers] set [language]='$newlang' where [language]='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_questions] set [language]='$newlang' where [language]='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_groups] set [language]='$newlang' where [language]='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_labels] set [language]='$newlang' where [language]='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_surveys] set [language]='$newlang' where [language]='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_surveys_languagesettings] set [surveyls_language]='$newlang' where surveyls_language='$oldlang'");echo $modifyoutput;flush();
modify_database("","update [prefix_users] set [lang]='$newlang' where lang='$oldlang'");echo $modifyoutput;flush();
}
$resultdata=db_execute_assoc("select * from ".db_table_name("labelsets"));
while ($datarow = $resultdata->FetchRow()){
$toreplace=$datarow['languages'];
$toreplace2=str_replace('no','nb',$toreplace);
if ($toreplace2!=$toreplace) {modify_database("","update [prefix_labelsets] set [languages]='$toreplace' where lid=".$datarow['lid']);echo $modifyoutput;flush();}
}
$resultdata=db_execute_assoc("select * from ".db_table_name("surveys"));
while ($datarow = $resultdata->FetchRow()){
$toreplace=$datarow['additional_languages'];
$toreplace2=str_replace('no','nb',$toreplace);
if ($toreplace2!=$toreplace) {modify_database("","update [prefix_surveys] set [additional_languages]='$toreplace' where sid=".$datarow['sid']);echo $modifyoutput;flush();}
}
modify_database("","ALTER TABLE [prefix_surveys] ADD [htmlemail] CHAR(1) DEFAULT 'N'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_surveys] ADD [usecaptcha] CHAR(1) DEFAULT 'N'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_surveys] ADD [tokenanswerspersistence] CHAR(1) DEFAULT 'N'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_users] ADD [htmleditormode] CHAR(7) DEFAULT 'default'"); echo $modifyoutput; flush();
modify_database("","CREATE TABLE [prefix_templates_rights] (
[uid] int NOT NULL,
[folder] varchar(255) NOT NULL,
[use] int NOT NULL,
PRIMARY KEY ([uid],[folder])
);");echo $modifyoutput; flush();
modify_database("","CREATE TABLE [prefix_templates] (
[folder] varchar(255) NOT NULL,
[creator] int NOT NULL,
PRIMARY KEY ([folder])
);");echo $modifyoutput; flush();
//123
modify_database("","ALTER TABLE [prefix_conditions] ALTER COLUMN [value] VARCHAR(255)"); echo $modifyoutput; flush();
// There is no other way to remove the previous default value
/*modify_database("","DECLARE @STR VARCHAR(100)
SET @STR = (
SELECT NAME
FROM SYSOBJECTS SO
JOIN SYSCONSTRAINTS SC ON SO.ID = SC.CONSTID
WHERE OBJECT_NAME(SO.PARENT_OBJ) = 'lime_labels'
AND SO.XTYPE = 'D' AND SC.COLID =
(SELECT COLID FROM SYSCOLUMNS WHERE ID = OBJECT_ID('lime_labels') AND NAME = 'title'))
SET @STR = 'ALTER TABLE lime_labels DROP CONSTRAINT ' + @STR
exec (@STR);"); echo $modifyoutput; flush(); */
modify_database("","ALTER TABLE [prefix_labels] ALTER COLUMN [title] varchar(4000)"); echo $modifyoutput; flush();
//124
modify_database("","ALTER TABLE [prefix_surveys] ADD [bounce_email] text"); echo $modifyoutput; flush();
//125
upgrade_token_tables125();
modify_database("","EXEC sp_rename 'prefix_users.move_user','superadmin'"); echo $modifyoutput; flush();
modify_database("","UPDATE [prefix_users] SET [superadmin]=1 where ([create_survey]=1 AND [create_user]=1 AND [delete_user]=1 AND [configurator]=1)"); echo $modifyoutput; flush();
//126
modify_database("","ALTER TABLE [prefix_questions] ADD [lid1] int NOT NULL DEFAULT '0'"); echo $modifyoutput; flush();
modify_database("","UPDATE [prefix_conditions] SET [method]='==' where ( [method] is null) or [method]='' or [method]='0'"); echo $modifyoutput; flush();
modify_database("","update [prefix_settings_global] set [stg_value]='126' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 127) {
modify_database("","create index [answers_idx2] on [prefix_answers] ([sortorder])"); echo $modifyoutput;
modify_database("","create index [assessments_idx2] on [prefix_assessments] ([sid])"); echo $modifyoutput;
modify_database("","create index [assessments_idx3] on [prefix_assessments] ([gid])"); echo $modifyoutput;
modify_database("","create index [conditions_idx2] on [prefix_conditions] ([qid])"); echo $modifyoutput;
modify_database("","create index [conditions_idx3] on [prefix_conditions] ([cqid])"); echo $modifyoutput;
modify_database("","create index [groups_idx2] on [prefix_groups] ([sid])"); echo $modifyoutput;
modify_database("","create index [question_attributes_idx2] on [prefix_question_attributes] ([qid])"); echo $modifyoutput;
modify_database("","create index [questions_idx2] on [prefix_questions] ([sid])"); echo $modifyoutput;
modify_database("","create index [questions_idx3] on [prefix_questions] ([gid])"); echo $modifyoutput;
modify_database("","create index [questions_idx4] on [prefix_questions] ([type])"); echo $modifyoutput;
modify_database("","create index [quota_idx2] on [prefix_quota] ([sid])"); echo $modifyoutput;
modify_database("","create index [saved_control_idx2] on [prefix_saved_control] ([sid])"); echo $modifyoutput;
modify_database("","create index [user_in_groups_idx1] on [prefix_user_in_groups] ([ugid], [uid])"); echo $modifyoutput;
modify_database("","update [prefix_settings_global] set [stg_value]='127' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 128) {
upgrade_token_tables128();
modify_database("","update [prefix_settings_global] set [stg_value]='128' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 129) {
//128
modify_database("","ALTER TABLE [prefix_surveys] ADD [startdate] DATETIME"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_surveys] ADD [usestartdate] char(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
modify_database("","update [prefix_settings_global] set [stg_value]='129' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 130)
{
modify_database("","ALTER TABLE [prefix_conditions] ADD [scenario] int NOT NULL DEFAULT '1'"); echo $modifyoutput; flush();
modify_database("","UPDATE [prefix_conditions] SET [scenario]=1 where ( [scenario] is null) or [scenario]='' or [scenario]=0"); echo $modifyoutput; flush();
modify_database("","update [prefix_settings_global] set [stg_value]='130' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 131)
{
modify_database("","ALTER TABLE [prefix_surveys] ADD [publicstatistics] char(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
modify_database("","update [prefix_settings_global] set [stg_value]='131' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 132)
{
modify_database("","ALTER TABLE [prefix_surveys] ADD [publicgraphs] char(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
modify_database("","update [prefix_settings_global] set [stg_value]='132' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 133)
{
modify_database("","ALTER TABLE [prefix_users] ADD [one_time_pw] text"); echo $modifyoutput; flush();
// Add new assessment setting
modify_database("","ALTER TABLE [prefix_surveys] ADD [assessments] char(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
// add new assessment value fields to answers & labels
modify_database("","ALTER TABLE [prefix_answers] ADD [assessment_value] int NOT NULL default '0'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_labels] ADD [assessment_value] int NOT NULL default '0'"); echo $modifyoutput; flush();
// copy any valid codes from code field to assessment field
modify_database("","update [prefix_answers] set [assessment_value]=CAST([code] as int)");// no output here is intended
modify_database("","update [prefix_labels] set [assessment_value]=CAST([code] as int)");// no output here is intended
// activate assessment where assesment rules exist
modify_database("","update [prefix_surveys] set [assessments]='Y' where [sid] in (SELECT [sid] FROM [prefix_assessments] group by [sid])"); echo $modifyoutput; flush();
// add language field to assessment table
modify_database("","ALTER TABLE [prefix_assessments] ADD [language] varchar(20) NOT NULL default 'en'"); echo $modifyoutput; flush();
// update language field with default language of that particular survey
modify_database("","update [prefix_assessments] set [language]=(select [language] from [prefix_surveys] where [sid]=[prefix_assessments].[sid])"); echo $modifyoutput; flush();
// copy assessment link to message since from now on we will have HTML assignment messages
modify_database("","update [prefix_assessments] set [message]=cast([message] as varchar) +'<br /><a href=\"'+[link]+'\">'+[link]+'</a>'"); echo $modifyoutput; flush();
// drop the old link field
modify_database("","ALTER TABLE [prefix_assessments] DROP COLUMN [link]"); echo $modifyoutput; flush();
// change the primary index to include language
// and fix missing translations for assessments
upgrade_survey_tables133a();
// Add new fields to survey language settings
modify_database("","ALTER TABLE [prefix_surveys_languagesettings] ADD [surveyls_url] varchar(255)"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_surveys_languagesettings] ADD [surveyls_endtext] text"); echo $modifyoutput; flush();
// copy old URL fields ot language specific entries
modify_database("","update [prefix_surveys_languagesettings] set [surveyls_url]=(select [url] from [prefix_surveys] where [sid]=[prefix_surveys_languagesettings].[surveyls_survey_id])"); echo $modifyoutput; flush();
// drop old URL field
mssql_drop_constraint('url','surveys');
modify_database("","ALTER TABLE [prefix_surveys] DROP COLUMN [url]"); echo $modifyoutput; flush();
modify_database("","update [prefix_settings_global] set [stg_value]='133' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 134)
{
// Add new assessment setting
modify_database("","ALTER TABLE [prefix_surveys] ADD [usetokens] char(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
mssql_drop_constraint('attribute1','surveys');
mssql_drop_constraint('attribute2','surveys');
modify_database("", "ALTER TABLE [prefix_surveys] ADD [attributedescriptions] TEXT;"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_surveys] DROP COLUMN [attribute1]"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_surveys] DROP COLUMN [attribute2]"); echo $modifyoutput; flush();
upgrade_token_tables134();
modify_database("","update [prefix_settings_global] set [stg_value]='134' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 135)
{
mssql_drop_constraint('value','question_attributes');
modify_database("","ALTER TABLE [prefix_question_attributes] ALTER COLUMN [value] text"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE [prefix_answers] ALTER COLUMN [answer] varchar(8000)"); echo $modifyoutput; flush();
modify_database("","update [prefix_settings_global] set [stg_value]='135' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 136) //New quota functions
{
modify_database("", "ALTER TABLE[prefix_quota] ADD [autoload_url] int NOT NULL default '0'"); echo $modifyoutput; flush();
modify_database("","CREATE TABLE [prefix_quota_languagesettings] (
[quotals_id] int NOT NULL IDENTITY (1,1),
[quotals_quota_id] int,
[quotals_language] varchar(45) NOT NULL default 'en',
[quotals_name] varchar(255),
[quotals_message] text,
[quotals_url] varchar(255),
[quotals_urldescrip] varchar(255),
PRIMARY KEY ([quotals_id])
);");echo $modifyoutput; flush();
modify_database("","update [prefix_settings_global] set [stg_value]='136' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 137) //New date format specs
{
modify_database("", "ALTER TABLE [prefix_surveys_languagesettings] ADD [surveyls_dateformat] int NOT NULL default '1'"); echo $modifyoutput; flush();
modify_database("", "ALTER TABLE [prefix_users] ADD [dateformat] int NOT NULL default '1'"); echo $modifyoutput; flush();
modify_database("", "update [prefix_surveys] set startdate=null where usestartdate='N'"); echo $modifyoutput; flush();
modify_database("", "update [prefix_surveys] set expires=null where useexpiry='N'"); echo $modifyoutput; flush();
mssql_drop_constraint('usestartdate','surveys');
mssql_drop_constraint('useexpiry','surveys');
modify_database("", "ALTER TABLE [prefix_surveys] DROP COLUMN usestartdate"); echo $modifyoutput; flush();
modify_database("", "ALTER TABLE [prefix_surveys] DROP COLUMN useexpiry"); echo $modifyoutput; flush();
modify_database("","update [prefix_settings_global] set [stg_value]='137' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 138) //Modify quota field
{
modify_database("", "ALTER TABLE [prefix_quota_members] ALTER COLUMN [code] VARCHAR(11) NULL"); echo $modifyoutput; flush();
modify_database("", "UPDATE [prefix_settings_global] SET [stg_value]='138' WHERE stg_name='DBVersion'"); echo $modifyoutput; flush();
}
return true;
}
function upgrade_survey_tables117()
{
global $modifyoutput;
$surveyidquery = "SELECT sid FROM ".db_table_name('surveys')." WHERE active='Y' and datestamp='Y'";
$surveyidresult = db_execute_num($surveyidquery);
if (!$surveyidresult) {return "Database Error";}
else
{
while ( $sv = $surveyidresult->FetchRow() )
{
modify_database("","ALTER TABLE ".db_table_name('survey_'.$sv[0])." ADD [startdate] datetime"); echo $modifyoutput; flush();
}
}
}
function upgrade_survey_tables118()
{
global $connect,$modifyoutput,$dbprefix;
$tokentables=$connect->MetaTables('TABLES',false,$dbprefix."tokens%");
foreach ($tokentables as $sv)
{
modify_database("","ALTER TABLE ".$sv." ALTER COLUMN [token] VARCHAR(36)"); echo $modifyoutput; flush();
}
}
function upgrade_token_tables125()
{
global $connect,$modifyoutput,$dbprefix;
$tokentables=$connect->MetaTables('TABLES',false,$dbprefix."tokens%");
foreach ($tokentables as $sv)
{
modify_database("","ALTER TABLE ".$sv." ADD [emailstatus] VARCHAR(300) DEFAULT 'OK'"); echo $modifyoutput; flush();
}
}
function upgrade_token_tables128()
{
global $connect,$modifyoutput,$dbprefix;
$tokentables=$connect->MetaTables('TABLES',false,$dbprefix."tokens%");
foreach ($tokentables as $sv)
{
modify_database("","ALTER TABLE ".$sv." ADD [remindersent] VARCHAR(17) DEFAULT 'OK'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE ".$sv." ADD [remindercount] int DEFAULT '0'"); echo $modifyoutput; flush();
}
}
function upgrade_survey_tables133a()
{
global $dbprefix, $connect, $modifyoutput;
// find out the constraint name of the old primary key
$pkquery = " SELECT CONSTRAINT_NAME "
."FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS "
."WHERE (TABLE_NAME = '{$dbprefix}assessments') AND (CONSTRAINT_TYPE = 'PRIMARY KEY')";
$primarykey=$connect->GetRow($pkquery);
if ($primarykey!=false)
{
modify_database("","ALTER TABLE [prefix_assessments] DROP CONSTRAINT {$primarykey[0]}"); echo $modifyoutput; flush();
}
// add the new primary key
modify_database("","ALTER TABLE [prefix_assessments] ADD CONSTRAINT pk_assessments_id_lang PRIMARY KEY ([id],[language])"); echo $modifyoutput; flush();
$surveyidquery = "SELECT sid,additional_languages FROM ".db_table_name('surveys');
$surveyidresult = db_execute_num($surveyidquery);
while ( $sv = $surveyidresult->FetchRow() )
{
FixLanguageConsistency($sv[0],$sv[1]);
}
}
function upgrade_token_tables134()
{
global $connect,$modifyoutput,$dbprefix;
$tokentables=$connect->MetaTables('TABLES',false,$dbprefix."tokens%");
foreach ($tokentables as $sv)
{
modify_database("","ALTER TABLE ".$sv." ADD [validfrom] DATETIME"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE ".$sv." ADD [validuntil] DATETIME"); echo $modifyoutput; flush();
}
}
function mssql_drop_constraint($fieldname, $tablename)
{
global $dbprefix, $connect, $modifyoutput;
// find out the name of the default constraint
// Did I already mention that this is the most suckiest thing I have ever seen in MSSQL database?
// It proves how badly designer some Microsoft software is!
$dfquery ="SELECT c_obj.name AS constraint_name
FROM sys.sysobjects AS c_obj INNER JOIN
sys.sysobjects AS t_obj ON c_obj.parent_obj = t_obj.id INNER JOIN
sys.sysconstraints AS con ON c_obj.id = con.constid INNER JOIN
sys.syscolumns AS col ON t_obj.id = col.id AND con.colid = col.colid
WHERE (c_obj.xtype = 'D') AND (col.name = '$fieldname') AND (t_obj.name='$dbprefix$tablename')";
$defaultname=$connect->GetRow($dfquery);
if ($defaultname!=false)
{
modify_database("","ALTER TABLE [prefix_$tablename] DROP CONSTRAINT {$defaultname[0]}"); echo $modifyoutput; flush();
}
}
?>

View File

@@ -1,466 +0,0 @@
<?PHP
/*
* LimeSurvey
* Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id: upgrade-mysql.php 7108 2009-06-15 05:43:21Z jcleeland $
*/
// There will be a file for each database (accordingly named to the dbADO scheme)
// where based on the current database version the database is upgraded
// For this there will be a settings table which holds the last time the database was upgraded
function db_upgrade($oldversion) {
/// This function does anything necessary to upgrade
/// older versions to match current functionality
global $modifyoutput, $databasename, $databasetabletype;
echo str_pad('Loading... ',4096)."<br />\n";
if ($oldversion < 111) {
// Language upgrades from version 110 to 111 since the language names did change
$oldnewlanguages=array('german_informal'=>'german-informal',
'cns'=>'cn-Hans',
'cnt'=>'cn-Hant',
'pt_br'=>'pt-BR',
'gr'=>'el',
'jp'=>'ja',
'si'=>'sl',
'se'=>'sv',
'vn'=>'vi');
foreach ($oldnewlanguages as $oldlang=>$newlang)
{
modify_database("","update `prefix_answers` set `language`='$newlang' where language='$oldlang'"); echo $modifyoutput; flush();
modify_database("","update `prefix_questions` set `language`='$newlang' where language='$oldlang'");echo $modifyoutput;flush();
modify_database("","update `prefix_groups` set `language`='$newlang' where language='$oldlang'");echo $modifyoutput;flush();
modify_database("","update `prefix_labels` set `language`='$newlang' where language='$oldlang'");echo $modifyoutput;flush();
modify_database("","update `prefix_surveys` set `language`='$newlang' where language='$oldlang'");echo $modifyoutput;flush();
modify_database("","update `prefix_surveys_languagesettings` set `surveyls_language`='$newlang' where surveyls_language='$oldlang'");echo $modifyoutput;flush();
modify_database("","update `prefix_users` set `lang`='$newlang' where lang='$oldlang'");echo $modifyoutput;flush();
}
$resultdata=db_execute_assoc("select * from ".db_table_name("labelsets"));
while ($datarow = $resultdata->FetchRow()){
$toreplace=$datarow['languages'];
$toreplace=str_replace('german_informal','german-informal',$toreplace);
$toreplace=str_replace('cns','cn-Hans',$toreplace);
$toreplace=str_replace('cnt','cn-Hant',$toreplace);
$toreplace=str_replace('pt_br','pt-BR',$toreplace);
$toreplace=str_replace('gr','el',$toreplace);
$toreplace=str_replace('jp','ja',$toreplace);
$toreplace=str_replace('si','sl',$toreplace);
$toreplace=str_replace('se','sv',$toreplace);
$toreplace=str_replace('vn','vi',$toreplace);
modify_database("","update `prefix_labelsets` set `languages`='$toreplace' where lid=".$datarow['lid']);echo $modifyoutput;flush();
}
$resultdata=db_execute_assoc("select * from ".db_table_name("surveys"));
while ($datarow = $resultdata->FetchRow()){
$toreplace=$datarow['additional_languages'];
$toreplace=str_replace('german_informal','german-informal',$toreplace);
$toreplace=str_replace('cns','cn-Hans',$toreplace);
$toreplace=str_replace('cnt','cn-Hant',$toreplace);
$toreplace=str_replace('pt_br','pt-BR',$toreplace);
$toreplace=str_replace('gr','el',$toreplace);
$toreplace=str_replace('jp','ja',$toreplace);
$toreplace=str_replace('si','sl',$toreplace);
$toreplace=str_replace('se','sv',$toreplace);
$toreplace=str_replace('vn','vi',$toreplace);
modify_database("","update `prefix_surveys` set `additional_languages`='$toreplace' where sid=".$datarow['sid']);echo $modifyoutput;flush();
}
modify_database("","update `prefix_settings_global` set `stg_value`='111' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 112) {
//The size of the users_name field is now 64 char (20 char before version 112)
modify_database("","ALTER TABLE `prefix_users` CHANGE `users_name` `users_name` VARCHAR( 64 ) NOT NULL"); echo $modifyoutput; flush();
modify_database("","update `prefix_settings_global` set `stg_value`='112' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 113) {
//Fixes the collation for the complete DB, tables and columns
echo "<strong>Attention:</strong>The following upgrades will update your MySQL Database collations. This may take some time.<br />If for any reason you should get a timeout just re-run the upgrade procedure. The updating will continue where it left off.<br /><br />"; flush();
fix_mysql_collation();
modify_database("","ALTER DATABASE `$databasename` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;");echo $modifyoutput; flush();
modify_database("","update `prefix_settings_global` set `stg_value`='113' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 114) {
modify_database("","ALTER TABLE `prefix_saved_control` CHANGE `email` `email` VARCHAR(320) NOT NULL"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE `prefix_surveys` CHANGE `adminemail` `adminemail` VARCHAR(320) NOT NULL"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE `prefix_users` CHANGE `email` `email` VARCHAR(320) NOT NULL"); echo $modifyoutput; flush();
modify_database("",'INSERT INTO `prefix_settings_global` VALUES (\'SessionName\', \'$sessionname\');');echo $modifyoutput; flush();
modify_database("","update `prefix_settings_global` set `stg_value`='114' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 126) {
//Adds new "public" field
modify_database("","ALTER TABLE `prefix_surveys` ADD `printanswers` CHAR(1) default 'N' AFTER allowsave"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE `prefix_surveys` ADD `listpublic` CHAR(1) default 'N' AFTER `datecreated`"); echo $modifyoutput; flush();
upgrade_survey_tables117();
upgrade_survey_tables118();
// 119
modify_database("","CREATE TABLE `prefix_quota` (
`id` int(11) NOT NULL auto_increment,
`sid` int(11) default NULL,
`qlimit` int(8) default NULL,
`name` varchar(255) collate utf8_unicode_ci default NULL,
`action` int(2) default NULL,
`active` int(1) NOT NULL default '1',
PRIMARY KEY (`id`)
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;"); echo $modifyoutput; flush();
modify_database("","CREATE TABLE `prefix_quota_members` (
`id` int(11) NOT NULL auto_increment,
`sid` int(11) default NULL,
`qid` int(11) default NULL,
`quota_id` int(11) default NULL,
`code` varchar(5) collate utf8_unicode_ci default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `sid` (`sid`,`qid`,`quota_id`,`code`)
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;"); echo $modifyoutput; flush();
// Rename Norwegian language code from NO to NB
$oldnewlanguages=array('no'=>'nb');
foreach ($oldnewlanguages as $oldlang=>$newlang)
{
modify_database("","update `prefix_answers` set `language`='$newlang' where language='$oldlang'");echo $modifyoutput;flush();
modify_database("","update `prefix_questions` set `language`='$newlang' where language='$oldlang'");echo $modifyoutput;flush();
modify_database("","update `prefix_groups` set `language`='$newlang' where language='$oldlang'");echo $modifyoutput;flush();
modify_database("","update `prefix_labels` set `language`='$newlang' where language='$oldlang'");echo $modifyoutput;flush();
modify_database("","update `prefix_surveys` set `language`='$newlang' where language='$oldlang'");echo $modifyoutput;flush();
modify_database("","update `prefix_surveys_languagesettings` set `surveyls_language`='$newlang' where surveyls_language='$oldlang'");echo $modifyoutput;flush();
modify_database("","update `prefix_users` set `lang`='$newlang' where lang='$oldlang'");echo $modifyoutput;flush();
}
$resultdata=db_execute_assoc("select * from ".db_table_name("labelsets"));
while ($datarow = $resultdata->FetchRow()){
$toreplace=$datarow['languages'];
$toreplace2=str_replace('no','nb',$toreplace);
if ($toreplace2!=$toreplace) {modify_database("","update `prefix_labelsets` set `languages`='$toreplace' where lid=".$datarow['lid']);echo $modifyoutput;flush();}
}
$resultdata=db_execute_assoc("select * from ".db_table_name("surveys"));
while ($datarow = $resultdata->FetchRow()){
$toreplace=$datarow['additional_languages'];
$toreplace2=str_replace('no','nb',$toreplace);
if ($toreplace2!=$toreplace) {modify_database("","update `prefix_surveys` set `additional_languages`='$toreplace' where sid=".$datarow['sid']);echo $modifyoutput;flush();}
}
modify_database("","ALTER TABLE `prefix_surveys` ADD `htmlemail` CHAR(1) default 'N'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE `prefix_surveys` ADD `tokenanswerspersistence` CHAR(1) default 'N'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE `prefix_surveys` ADD `usecaptcha` CHAR(1) default 'N'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE `prefix_users` ADD `htmleditormode` CHAR(7) default 'default'"); echo $modifyoutput; flush();
//122
modify_database("","CREATE TABLE `prefix_templates_rights` (
`uid` int(11) NOT NULL,
`folder` varchar(255) NOT NULL,
`use` int(1) NOT NULL,
PRIMARY KEY (`uid`,`folder`)
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;"); echo $modifyoutput; flush();
modify_database("","CREATE TABLE `prefix_templates` (
`folder` varchar(255) NOT NULL,
`creator` int(11) NOT NULL,
PRIMARY KEY (`folder`)
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;"); echo $modifyoutput; flush();
//123
modify_database("","ALTER TABLE `prefix_conditions` CHANGE `value` `value` VARCHAR(255) NOT NULL default ''"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE `prefix_labels` CHANGE `title` `title` text"); echo $modifyoutput; flush();
//124
modify_database("","ALTER TABLE `prefix_surveys` ADD `bounce_email` text"); echo $modifyoutput; flush();
//125
upgrade_token_tables125();
modify_database("","ALTER TABLE `prefix_users` ADD `superadmin` tinyint(1) NOT NULL default '0'"); echo $modifyoutput; flush();
modify_database("","UPDATE `prefix_users` SET `superadmin`=1 where (create_survey=1 AND create_user=1 AND move_user=1 AND delete_user=1 AND configurator=1)"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE `prefix_users` DROP COLUMN `move_user`"); echo $modifyoutput; flush();
//126
modify_database("","ALTER TABLE `prefix_questions` ADD `lid1` integer NOT NULL default '0'"); echo $modifyoutput; flush();
modify_database("","UPDATE `prefix_conditions` SET `method`='==' where (`method` is null) or `method`='' or `method`='0'"); echo $modifyoutput; flush();
modify_database("","update `prefix_settings_global` set `stg_value`='126' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 127) {
modify_database("","create index `assessments_idx2` on `prefix_assessments` (`sid`)"); echo $modifyoutput; flush();
modify_database("","create index `assessments_idx3` on `prefix_assessments` (`gid`)"); echo $modifyoutput; flush();
modify_database("","create index `conditions_idx2` on `prefix_conditions` (`qid`)"); echo $modifyoutput; flush();
modify_database("","create index `groups_idx2` on `prefix_groups` (`sid`)"); echo $modifyoutput; flush();
modify_database("","create index `questions_idx2` on `prefix_questions` (`sid`)"); echo $modifyoutput; flush();
modify_database("","create index `questions_idx3` on `prefix_questions` (`gid`)"); echo $modifyoutput; flush();
modify_database("","create index `question_attributes_idx2` on `prefix_question_attributes` (`qid`)"); echo $modifyoutput; flush();
modify_database("","create index `quota_idx2` on `prefix_quota` (`sid`)"); echo $modifyoutput; flush();
modify_database("","create index `saved_control_idx2` on `prefix_saved_control` (`sid`)"); echo $modifyoutput; flush();
modify_database("","create index `user_in_groups_idx1` on `prefix_user_in_groups` (`ugid`, `uid`)"); echo $modifyoutput; flush();
modify_database("","create index `answers_idx2` on `prefix_answers` (`sortorder`)"); echo $modifyoutput; flush();
modify_database("","create index `conditions_idx3` on `prefix_conditions` (`cqid`)"); echo $modifyoutput; flush();
modify_database("","create index `questions_idx4` on `prefix_questions` (`type`)"); echo $modifyoutput; flush();
modify_database("","update `prefix_settings_global` set `stg_value`='127' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 128) {
//128
upgrade_token_tables128();
modify_database("","update `prefix_settings_global` set `stg_value`='128' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 129) {
//129
modify_database("","ALTER TABLE `prefix_surveys` ADD `startdate` DATETIME"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE `prefix_surveys` ADD `usestartdate` varchar(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
modify_database("","update `prefix_settings_global` set `stg_value`='129' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 130)
{
modify_database("","ALTER TABLE `prefix_conditions` ADD `scenario` integer NOT NULL default '1' AFTER `qid`"); echo $modifyoutput; flush();
modify_database("","UPDATE `prefix_conditions` SET `scenario`=1 where (`scenario` is null) or `scenario`='' or `scenario`=0"); echo $modifyoutput; flush();
modify_database("","update `prefix_settings_global` set `stg_value`='130' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 131)
{
modify_database("","ALTER TABLE `prefix_surveys` ADD `publicstatistics` varchar(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
modify_database("","update `prefix_settings_global` set `stg_value`='131' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 132)
{
modify_database("","ALTER TABLE `prefix_surveys` ADD `publicgraphs` varchar(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
modify_database("","update `prefix_settings_global` set `stg_value`='132' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 133)
{
modify_database("","ALTER TABLE `prefix_users` ADD `one_time_pw` blob"); echo $modifyoutput; flush();
// Add new assessment setting
modify_database("","ALTER TABLE `prefix_surveys` ADD `assessments` varchar(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
// add new assessment value fields to answers & labels
modify_database("","ALTER TABLE `prefix_answers` ADD `assessment_value` int(11) NOT NULL default '0'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE `prefix_labels` ADD `assessment_value` int(11) NOT NULL default '0'"); echo $modifyoutput; flush();
// copy any valid codes from code field to assessment field
modify_database("","update `prefix_answers` set `assessment_value`=CAST(`code` as SIGNED) where `code` REGEXP '^-?[0-9]+$'");echo $modifyoutput; flush();
modify_database("","update `prefix_labels` set `assessment_value`=CAST(`code` as SIGNED) where `code` REGEXP '^-?[0-9]+$'");echo $modifyoutput; flush();
// activate assessment where assesment rules exist
modify_database("","update `prefix_surveys` set `assessments`='Y' where `sid` in (SELECT `sid` FROM `prefix_assessments` group by `sid`)"); echo $modifyoutput; flush();
// add language field to assessment table
modify_database("","ALTER TABLE `prefix_assessments` ADD `language` varchar(20) NOT NULL default 'en'"); echo $modifyoutput; flush();
// update language field with default language of that particular survey
modify_database("","update `prefix_assessments` set `language`=(select `language` from `prefix_surveys` where `sid`=`prefix_assessments`.`sid`)"); echo $modifyoutput; flush();
// copy assessment link to message since from now on we will have HTML assignment messages
modify_database("","update `prefix_assessments` set `message`=concat(replace(`message`,'/''',''''),'<br /><a href=\"',`link`,'\">',`link`,'</a>')"); echo $modifyoutput; flush();
// drop the old link field
modify_database("","ALTER TABLE `prefix_assessments` DROP COLUMN `link`"); echo $modifyoutput; flush();
// change the primary index to include language
modify_database("","ALTER TABLE `prefix_assessments` DROP PRIMARY KEY, ADD PRIMARY KEY USING BTREE(`id`, `language`)"); echo $modifyoutput; flush();
//finally fix missing translations for assessments
upgrade_survey_tables133();
// Add new fields to survey language settings
modify_database("","ALTER TABLE `prefix_surveys_languagesettings` ADD `surveyls_url` varchar(255)"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE `prefix_surveys_languagesettings` ADD `surveyls_endtext` text"); echo $modifyoutput; flush();
// copy old URL fields ot language specific entries
modify_database("","update `prefix_surveys_languagesettings` set `surveyls_url`=(select `url` from `prefix_surveys` where `sid`=`prefix_surveys_languagesettings`.`surveyls_survey_id`)"); echo $modifyoutput; flush();
// drop old URL field
modify_database("","ALTER TABLE `prefix_surveys` DROP COLUMN `url`"); echo $modifyoutput; flush();
modify_database("","update `prefix_settings_global` set `stg_value`='133' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 134)
{
// Add new tokens setting
modify_database("","ALTER TABLE `prefix_surveys` ADD `usetokens` varchar(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE `prefix_surveys` ADD `attributedescriptions` TEXT;"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE `prefix_surveys` DROP COLUMN `attribute1`"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE `prefix_surveys` DROP COLUMN `attribute2`"); echo $modifyoutput; flush();
upgrade_token_tables134();
modify_database("","update `prefix_settings_global` set `stg_value`='134' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 135)
{
modify_database("","ALTER TABLE `prefix_question_attributes` MODIFY `value` text"); echo $modifyoutput; flush();
modify_database("","UPDATE `prefix_settings_global` SET `stg_value`='135' WHERE stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 136) //New Quota Functions
{
modify_database("","ALTER TABLE `prefix_quota` ADD `autoload_url` int(1) NOT NULL default '0'"); echo $modifyoutput; flush();
modify_database("","CREATE TABLE `prefix_quota_languagesettings` (
`quotals_id` int(11) NOT NULL auto_increment,
`quotals_quota_id` int(11) NOT NULL default '0',
`quotals_language` varchar(45) NOT NULL default 'en',
`quotals_name` varchar(255) collate utf8_unicode_ci default NULL,
`quotals_message` text NOT NULL,
`quotals_url` varchar(255),
`quotals_urldescrip` varchar(255),
PRIMARY KEY (`quotals_id`)
) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci;"); echo $modifyoutput; flush();
modify_database("","UPDATE `prefix_settings_global` SET `stg_value`='136' WHERE stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 137) //New Quota Functions
{
modify_database("", "ALTER TABLE `prefix_surveys_languagesettings` ADD `surveyls_dateformat` int(1) NOT NULL default '1'"); echo $modifyoutput; flush();
modify_database("", "ALTER TABLE `prefix_users` ADD `dateformat` int(1) NOT NULL default '1'"); echo $modifyoutput; flush();
modify_database("", "UPDATE `prefix_surveys` set `startdate`=null where `usestartdate`='N'"); echo $modifyoutput; flush();
modify_database("", "UPDATE `prefix_surveys` set `expires`=null where `useexpiry`='N'"); echo $modifyoutput; flush();
modify_database("", "ALTER TABLE `prefix_surveys` DROP COLUMN `useexpiry`"); echo $modifyoutput; flush();
modify_database("", "ALTER TABLE `prefix_surveys` DROP COLUMN `usestartdate`"); echo $modifyoutput; flush();
modify_database("", "UPDATE `prefix_settings_global` SET `stg_value`='137' WHERE stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 138) //Modify quota field
{
modify_database("", "ALTER TABLE `prefix_quota_members` CHANGE `code` `code` VARCHAR(11) collate utf8_unicode_ci default NULL"); echo $modifyoutput; flush();
modify_database("", "UPDATE `prefix_settings_global` SET `stg_value`='138' WHERE stg_name='DBVersion'"); echo $modifyoutput; flush();
}
return true;
}
function upgrade_survey_tables117()
{
global $modifyoutput;
$surveyidquery = "SELECT sid FROM ".db_table_name('surveys')." WHERE active='Y' and datestamp='Y'";
$surveyidresult = db_execute_num($surveyidquery);
if (!$surveyidresult) {return "Database Error";}
else
{
while ( $sv = $surveyidresult->FetchRow() )
{
modify_database("","ALTER TABLE ".db_table_name('survey_'.$sv[0])." ADD `startdate` datetime AFTER `datestamp`"); echo $modifyoutput; flush();
}
}
}
function upgrade_survey_tables118()
{
global $modifyoutput,$dbprefix;
$surveyidquery = "SHOW TABLES LIKE '".$dbprefix."tokens%'";
$surveyidresult = db_execute_num($surveyidquery);
if (!$surveyidresult) {return "Database Error";}
else
{
while ( $sv = $surveyidresult->FetchRow() )
{
modify_database("","ALTER TABLE ".$sv[0]." CHANGE `token` `token` VARCHAR(15)"); echo $modifyoutput; flush();
}
}
}
function upgrade_token_tables125()
{
global $modifyoutput,$dbprefix;
$surveyidquery = "SHOW TABLES LIKE '".$dbprefix."tokens%'";
$surveyidresult = db_execute_num($surveyidquery);
if (!$surveyidresult) {return "Database Error";}
else
{
while ( $sv = $surveyidresult->FetchRow() )
{
modify_database("","ALTER TABLE ".$sv[0]." ADD `emailstatus` varchar(300) NOT NULL DEFAULT 'OK'"); echo $modifyoutput; flush();
}
}
}
// Add the reminders tracking fields
function upgrade_token_tables128()
{
global $modifyoutput,$dbprefix;
$surveyidquery = "SHOW TABLES LIKE '".$dbprefix."tokens%'";
$surveyidresult = db_execute_num($surveyidquery);
if (!$surveyidresult) {return "Database Error";}
else
{
while ( $sv = $surveyidresult->FetchRow() )
{
modify_database("","ALTER TABLE ".$sv[0]." ADD `remindersent` VARCHAR(17) DEFAULT 'N'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE ".$sv[0]." ADD `remindercount` INT(11) DEFAULT 0"); echo $modifyoutput; flush();
}
}
}
function upgrade_survey_tables133()
{
$surveyidquery = "SELECT sid,additional_languages FROM ".db_table_name('surveys');
$surveyidresult = db_execute_num($surveyidquery);
while ( $sv = $surveyidresult->FetchRow() )
{
FixLanguageConsistency($sv[0],$sv[1]);
}
}
// Add the reminders tracking fields
function upgrade_token_tables134()
{
global $modifyoutput,$dbprefix;
$surveyidquery = "SHOW TABLES LIKE '".$dbprefix."tokens%'";
$surveyidresult = db_execute_num($surveyidquery);
if (!$surveyidresult) {return "Database Error";}
else
{
while ( $sv = $surveyidresult->FetchRow() )
{
modify_database("","ALTER TABLE ".$sv[0]." ADD `validfrom` Datetime"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE ".$sv[0]." ADD `validuntil` Datetime"); echo $modifyoutput; flush();
}
}
}
function fix_mysql_collation()
{
global $connect, $modifyoutput, $dbprefix;
$sql = 'SHOW TABLE STATUS';
$result = db_execute_assoc($sql);
if (!$result) {
$modifyoutput .= 'SHOW TABLE - SQL Error';
}
while ( $tables = $result->FetchRow() ) {
// Loop through all tables in this database
$table = $tables['Name'];
$tablecollation=$tables['Collation'];
if (strpos($table,'old_')===false && ($dbprefix=='' || ($dbprefix!='' && strpos($table,$dbprefix)!==false)))
{
if ($tablecollation!='utf8_unicode_ci')
{
modify_database("","ALTER TABLE $table COLLATE utf8_unicode_ci");
echo $modifyoutput; flush();
}
# Now loop through all the fields within this table
$result2 = db_execute_assoc("SHOW FULL COLUMNS FROM ".$table);
while ( $column = $result2->FetchRow())
{
if ($column['Collation']!= 'utf8_unicode_ci' )
{
$field_name = $column['Field'];
$field_type = $column['Type'];
$field_default = $column['Default'];
if ($field_default!='NULL') {$field_default="'".$field_default."'";}
# Change text based fields
$skipped_field_types = array('char', 'text', 'enum', 'set');
foreach ( $skipped_field_types as $type )
{
if ( strpos($field_type, $type) !== false )
{
$modstatement="ALTER TABLE $table CHANGE `$field_name` `$field_name` $field_type CHARACTER SET utf8 COLLATE utf8_unicode_ci";
if ($type!='text') {$modstatement.=" DEFAULT $field_default";}
modify_database("",$modstatement);
echo $modifyoutput; flush();
}
}
}
}
}
}
}

View File

@@ -1,207 +0,0 @@
<?PHP
/*
* LimeSurvey
* Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id: upgrade-odbc_mssql.php 3631 2007-11-12 18:13:06Z c_schmitz $
*/
// There will be a file for each database (accordingly named to the dbADO scheme)
// where based on the current database version the database is upgraded
// For this there will be a settings table which holds the last time the database was upgraded
function db_upgrade($oldversion) {
global $modifyoutput;
if ($oldversion < 127) {
modify_database("","create index answers_idx2 on prefix_answers (sortorder)"); echo $modifyoutput; flush();
modify_database("","create index assessments_idx2 on prefix_assessments (sid)"); echo $modifyoutput; flush();
modify_database("","create index assessments_idx on prefix_assessments (gid)"); echo $modifyoutput; flush();
modify_database("","create index conditions_idx2 on prefix_conditions (qid)"); echo $modifyoutput; flush();
modify_database("","create index conditions_idx3 on prefix_conditions (cqid)"); echo $modifyoutput; flush();
modify_database("","create index groups_idx2 on prefix_groups (sid)"); echo $modifyoutput; flush();
modify_database("","create index question_attributes_idx2 on prefix_question_attributes (qid)"); echo $modifyoutput; flush();
modify_database("","create index questions_idx2 on prefix_questions (sid)"); echo $modifyoutput; flush();
modify_database("","create index questions_idx3 on prefix_questions (gid)"); echo $modifyoutput; flush();
modify_database("","create index questions_idx4 on prefix_questions (type)"); echo $modifyoutput; flush();
modify_database("","create index quota_idx2 on prefix_quota (sid)"); echo $modifyoutput; flush();
modify_database("","create index saved_control_idx2 on prefix_saved_control (sid)"); echo $modifyoutput; flush();
modify_database("","create index user_in_groups_idx1 on prefix_user_in_groups (ugid, uid)"); echo $modifyoutput; flush();
modify_database("","update prefix_settings_global set stg_value='127' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 128) {
//128
upgrade_token_tables128();
modify_database("","update prefix_settings_global set stg_value='128' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 129) {
//129
modify_database("","ALTER TABLE prefix_surveys ADD startdate date"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE prefix_surveys ADD usestartdate char(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
modify_database("","update prefix_settings_global set stg_value='129' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 130)
{
modify_database("","ALTER TABLE prefix_conditions ADD scenario integer NOT NULL default '1'"); echo $modifyoutput; flush();
modify_database("","UPDATE prefix_conditions SET scenario=1 where (scenario is null) or scenario=0"); echo $modifyoutput; flush();
modify_database("","update prefix_settings_global set stg_value='130' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 131)
{
modify_database("","ALTER TABLE prefix_surveys ADD publicstatistics char(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
modify_database("","update prefix_settings_global set stg_value='131' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 132)
{
modify_database("","ALTER TABLE prefix_surveys ADD publicgraphs char(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
modify_database("","update prefix_settings_global set stg_value='132' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 133)
{
modify_database("","ALTER TABLE prefix_users ADD one_time_pw bytea"); echo $modifyoutput; flush();
// Add new assessment setting
modify_database("","ALTER TABLE prefix_surveys ADD assessments char(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
// add new assessment value fields to answers & labels
modify_database("","ALTER TABLE prefix_answers ADD assessment_value integer NOT NULL default '0'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE prefix_labels ADD assessment_value integer NOT NULL default '0'"); echo $modifyoutput; flush();
// copy any valid codes from code field to assessment field
modify_database("","update [prefix_answers set assessment_value=CAST(code as integer)");// no output here is intended
modify_database("","update prefix_labels set assessment_value=CAST(code as integer)");// no output here is intended
// activate assessment where assesment rules exist
modify_database("","update prefix_surveys set assessments='Y' where sid in (SELECT sid FROM prefix_assessments group by sid)"); echo $modifyoutput; flush();
// add language field to assessment table
modify_database("","ALTER TABLE prefix_assessments ADD language character varying(20) NOT NULL default 'en'"); echo $modifyoutput; flush();
// update language field with default language of that particular survey
modify_database("","update prefix_assessments set language=(select language from prefix_surveys where sid=prefix_assessments.sid)"); echo $modifyoutput; flush();
// copy assessment link to message since from now on we will have HTML assignment messages
modify_database("","update prefix_assessments set message=cast(message as character) ||'<br /><a href=\"'||link||'\">'||link||'</a>'"); echo $modifyoutput; flush();
// drop the old link field
modify_database("","ALTER TABLE prefix_assessments DROP COLUMN link"); echo $modifyoutput; flush();
// change the primary index to include language
modify_database("","ALTER TABLE prefix_assessments DROP CONSTRAINT prefix_assessments_pkey"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE prefix_assessments ADD CONSTRAINT prefix_assessments_pkey PRIMARY KEY (id,language)"); echo $modifyoutput; flush();
// and fix missing translations for assessments
upgrade_survey_tables133();
// Add new fields to survey language settings
modify_database("","ALTER TABLE prefix_surveys_languagesettings ADD surveyls_url character varying(255)"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE prefix_surveys_languagesettings ADD surveyls_endtext text"); echo $modifyoutput; flush();
// copy old URL fields ot language specific entries
modify_database("","update prefix_surveys_languagesettings set surveyls_url=(select url from prefix_surveys where sid=prefix_surveys_languagesettings.surveyls_survey_id)"); echo $modifyoutput; flush();
// drop old URL field
modify_database("","ALTER TABLE prefix_surveys DROP COLUMN url"); echo $modifyoutput; flush();
modify_database("","update prefix_settings_global set stg_value='133' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 134)
{
modify_database("","ALTER TABLE prefix_surveys ADD usetokens char(1) NOT NULL default 'N'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE prefix_surveys ADD attributedescriptions TEXT;"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE prefix_surveys DROP COLUMN attribute1"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE prefix_surveys DROP COLUMN attribute2"); echo $modifyoutput; flush();
upgrade_token_tables134();
modify_database("","update prefix_settings_global set stg_value='134' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 135)
{
modify_database("","ALTER TABLE prefix_question_attributes ALTER COLUMN value TYPE text"); echo $modifyoutput; flush();
modify_database("","update prefix_settings_global set stg_value='135' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 136)
{
modify_database("", "ALTER TABLE prefix_quota ADD autoload_url integer NOT NULL DEFAULT 0"); echo $modifyoutput; flush();
modify_database("", "CREATE TABLE prefix_quota_languagesettings (
quotals_id serial NOT NULL,
quotals_quota_id integer NOT NULL DEFAULT 0,
quotals_language character varying(45) NOT NULL DEFAULT 'en'::character varying,
quotals_name character varying(200),
quotals_message text NOT NULL,
quotals_url character varying(255),
quotals_urldescrip character varying(255));"); echo $modifyoutput; flush();
modify_database("", "ALTER TABLE ONLY prefix_quota_languagesettings
ADD CONSTRAINT prefix_quota_languagesettings_pkey PRIMARY KEY (quotals_id);"); echo $modifyoutput; flush();
modify_database("", "ALTER TABLE ONLY prefix_users ADD CONSTRAINT prefix_users_pkey PRIMARY KEY (uid)"); echo $modifyoutput; flush();
modify_database("", "ALTER TABLE ONLY prefix_users ADD CONSTRAINT prefix_user_name_key UNIQUE (users_name)"); echo $modifyoutput; flush();
modify_database("", "update prefix_settings_global set stg_value='136' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 137) //New date format specs
{
modify_database("", "ALTER TABLE prefix_surveys_languagesettings ADD surveyls_dateformat integer NOT NULL default 1"); echo $modifyoutput; flush();
modify_database("", "ALTER TABLE prefix_users ADD \"dateformat\" integer NOT NULL default 1"); echo $modifyoutput; flush();
modify_database("", "update prefix_surveys set startdate=null where usestartdate='N'"); echo $modifyoutput; flush();
modify_database("", "update prefix_surveys set expires=null where useexpiry='N'"); echo $modifyoutput; flush();
modify_database("", "ALTER TABLE prefix_surveys DROP COLUMN usestartdate"); echo $modifyoutput; flush();
modify_database("", "ALTER TABLE prefix_surveys DROP COLUMN useexpiry"); echo $modifyoutput; flush();
modify_database("", "update prefix_settings_global set stg_value='137' where stg_name='DBVersion'"); echo $modifyoutput; flush();
}
if ($oldversion < 138) //Modify quota field
{
modify_database("", "ALTER TABLE prefix_quota_members ALTER COLUMN code TYPE character varying(11)"); echo $modifyoutput; flush();
modify_database("", "UPDATE prefix_settings_global SET stg_value='138' WHERE stg_name='DBVersion'"); echo $modifyoutput; flush();
}
return true;
}
function upgrade_token_tables128()
{
global $modifyoutput,$dbprefix;
$surveyidquery = db_select_tables_like($dbprefix."tokens%");
$surveyidresult = db_execute_num($surveyidquery);
if (!$surveyidresult) {return "Database Error";}
else
{
while ( $sv = $surveyidresult->FetchRow() )
{
modify_database("","ALTER TABLE ".$sv0." ADD remindersent character varying(17) DEFAULT 'N'"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE ".$sv0." ADD remindercount INTEGER DEFAULT 0"); echo $modifyoutput; flush();
}
}
}
function upgrade_survey_tables133()
{
global $modifyoutput;
$surveyidquery = "SELECT sid, additional_languages FROM ".db_table_name('surveys');
$surveyidresult = db_execute_num($surveyidquery);
while ( $sv = $surveyidresult->FetchRow() )
{
FixLanguageConsistency($sv['0'],$sv['1']);
}
}
function upgrade_token_tables134()
{
global $modifyoutput,$dbprefix;
$surveyidquery = db_select_tables_like($dbprefix."tokens%");
$surveyidresult = db_execute_num($surveyidquery);
if (!$surveyidresult) {return "Database Error";}
else
{
while ( $sv = $surveyidresult->FetchRow() )
{
modify_database("","ALTER TABLE ".$sv[0]." ADD validfrom timestamp"); echo $modifyoutput; flush();
modify_database("","ALTER TABLE ".$sv[0]." ADD validuntil timestamp"); echo $modifyoutput; flush();
}
}
}
?>