Skip to content

Commit

Permalink
Dev Removed obsolete fields from users table
Browse files Browse the repository at this point in the history
Dev Added created/modified fields to users table
  • Loading branch information
c-schmitz committed Mar 26, 2013
1 parent d0edf1f commit fb8fb01
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 71 deletions.
87 changes: 43 additions & 44 deletions application/controllers/InstallerController.php
Expand Up @@ -144,14 +144,14 @@ private function stepWelcome()

if (isset(Yii::app()->session['installerLang']))
{
$currentLanguage=Yii::app()->session['installerLang'];
$sCurrentLanguage=Yii::app()->session['installerLang'];
}
else
$currentLanguage='en';
$sCurrentLanguage='en';

foreach(getLanguageData(true, $currentLanguage) as $langkey => $languagekind)
foreach(getLanguageData(true, $sCurrentLanguage) as $sKey => $aLanguageInfo)
{
$languages[htmlspecialchars($langkey)] = sprintf('%s - %s', $languagekind['nativedescription'], $languagekind['description']);
$languages[htmlspecialchars($sKey)] = sprintf('%s - %s', $aLanguageInfo['nativedescription'], $aLanguageInfo['description']);
}
$aData['languages']=$languages;
$this->render('/installer/welcome_view',$aData);
Expand Down Expand Up @@ -184,9 +184,8 @@ private function stepLicense()
*/
public function stepViewLicense()
{
$filename = dirname(BASEPATH) . '/docs/license.txt';
header('Content-Type: text/plain; charset=UTF-8');
readfile($filename);
readfile(dirname(BASEPATH) . '/docs/license.txt');
exit;
}

Expand Down Expand Up @@ -344,27 +343,27 @@ private function stepDatabaseConfiguration()
}

//$aData array won't work here. changing the name
$values['title'] = $clang->gT('Database settings');
$values['descp'] = $clang->gT('Database settings');
$values['classesForStep'] = array('off','off','off','off','on','off');
$values['progressValue'] = 60;
$aValues['title'] = $clang->gT('Database settings');
$aValues['descp'] = $clang->gT('Database settings');
$aValues['classesForStep'] = array('off','off','off','off','on','off');
$aValues['progressValue'] = 60;

//it store text content
$values['adminoutputText'] = '';
$aValues['adminoutputText'] = '';
//it store the form code to be displayed
$values['adminoutputForm'] = '';
$aValues['adminoutputForm'] = '';

//if DB exist, check if its empty or up to date. if not, tell user LS can create it.
if (!$bDBExists)
{
Yii::app()->session['databaseDontExist'] = true;

$values['adminoutputText'].= "\t<tr bgcolor='#efefef'><td align='center'>\n"
$aValues['adminoutputText'].= "\t<tr bgcolor='#efefef'><td align='center'>\n"
."<strong>".$clang->gT("Database doesn't exist!")."</strong><br /><br />\n"
.$clang->gT("The database you specified does not exist:")."<br /><br />\n<strong>".$model->dbname."</strong><br /><br />\n"
.$clang->gT("LimeSurvey can attempt to create this database for you.")."<br /><br />\n";

$values['adminoutputForm'] = CHtml::form(array('installer/createdb'), 'post').
$aValues['adminoutputForm'] = CHtml::form(array('installer/createdb'), 'post').
"<input type='submit' value='"
.$clang->gT("Create database")."' class='ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only' /></form>";
}
Expand All @@ -373,11 +372,11 @@ private function stepDatabaseConfiguration()
Yii::app()->session['populatedatabase'] = true;

//$this->connection->database = $model->dbname;
// //$this->connection->createCommand("USE DATABASE `".$model->dbname."`")->execute();
$values['adminoutputText'].= sprintf($clang->gT('A database named "%s" already exists.'),$model->dbname)."<br /><br />\n"
// //$this->connection->createCommand("USE DATABASE `".$model->dbname."`")->execute();
$aValues['adminoutputText'].= sprintf($clang->gT('A database named "%s" already exists.'),$model->dbname)."<br /><br />\n"
.$clang->gT("Do you want to populate that database now by creating the necessary tables?")."<br /><br />";

$values['adminoutputForm'] = CHtml::form(array('installer/populatedb'), 'post')
$aValues['adminoutputForm'] = CHtml::form(array('installer/populatedb'), 'post')
."<input class='ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only' type='submit' name='createdbstep2' value='".$clang->gT("Populate database")."' />"
."</form>";
}
Expand All @@ -388,12 +387,12 @@ private function stepDatabaseConfiguration()
//$this->connection->createCommand("USE DATABASE `$databasename`")->execute();
/* @todo Implement Upgrade */
//$output=CheckForDBUpgrades();
if ($output== '') {$values['adminoutput'].='<br />'.$clang->gT('LimeSurvey database is up to date. No action needed');}
else {$values['adminoutput'].=$output;}
$values['adminoutput'].= "<br />" . sprintf($clang->gT('Please <a href="%s">log in</a>.', 'unescaped'), $this->createUrl("/admin"));
if ($output== '') {$aValues['adminoutput'].='<br />'.$clang->gT('LimeSurvey database is up to date. No action needed');}
else {$aValues['adminoutput'].=$output;}
$aValues['adminoutput'].= "<br />" . sprintf($clang->gT('Please <a href="%s">log in</a>.', 'unescaped'), $this->createUrl("/admin"));
}
$values['clang'] = $clang;
$this->render('/installer/dbsettings_view', $values);
$aValues['clang'] = $clang;
$this->render('/installer/dbsettings_view', $aValues);
} else {
$this->render('/installer/dbconfig_view', $aData);
}
Expand Down Expand Up @@ -432,7 +431,7 @@ function stepCreateDb()

$aData['adminoutputForm'] = '';
// Yii doesn't have a method to create a database
$createDb = true; // We are thinking positive
$bCreateDB = true; // We are thinking positive
switch ($sDatabaseType)
{
case 'mysqli':
Expand All @@ -443,7 +442,7 @@ function stepCreateDb()
}
catch(Exception $e)
{
$createDb=false;
$bCreateDB=false;
}
break;
case 'mssql':
Expand All @@ -454,7 +453,7 @@ function stepCreateDb()
}
catch(Exception $e)
{
$createDb=false;
$bCreateDB=false;
}
break;
case 'postgres':
Expand All @@ -474,13 +473,13 @@ function stepCreateDb()
}
catch(Exception $e)
{
$createDb=false;
$bCreateDB=false;
}
break;
}

//$this->load->dbforge();
if ($createDb) //Database has been successfully created
if ($bCreateDB) //Database has been successfully created
{
$sDsn = self::_getDsn($sDatabaseType, $sDatabaseLocation, $sDatabasePort, $sDatabaseName, $sDatabaseUser, $sDatabasePwd);
$this->connection = new CDbConnection($sDsn, $sDatabaseUser, $sDatabasePwd);
Expand Down Expand Up @@ -717,23 +716,23 @@ private function _check_requirements(&$data)
*/
function check_HTML_image($result)
{
$label = array('wrong', 'right');
return sprintf('<img src="%s/installer/images/tick-%s.png" alt="Found" />', Yii::app()->baseUrl, $label[$result]);
$aLabelYesNo = array('wrong', 'right');
return sprintf('<img src="%s/installer/images/tick-%s.png" alt="Found" />', Yii::app()->baseUrl, $aLabelYesNo[$result]);
}


function is_writable_recursive($dir)
function is_writable_recursive($sDirectory)
{
$folder = opendir($dir);
while($file = readdir( $folder ))
if($file != '.' && $file != '..' &&
( !is_writable( $dir."/".$file ) ||
( is_dir( $dir."/".$file ) && !is_writable_recursive( $dir."/".$file ) ) ))
$sFolder = opendir($sDirectory);
while($sFile = readdir( $sFolder ))
if($sFile != '.' && $sFile != '..' &&
( !is_writable( $sDirectory."/".$sFile ) ||
( is_dir( $sDirectory."/".$sFile ) && !is_writable_recursive( $sDirectory."/".$sFile ) ) ))
{
closedir($folder);
closedir($sFolder);
return false;
}
closedir($folder);
closedir($sFolder);
return true;
}

Expand Down Expand Up @@ -995,13 +994,13 @@ function _writeConfigFile()
."| EXPLANATION OF VARIABLES"."\n"
."| -------------------------------------------------------------------"."\n"
."|" ."\n"
."| 'connectionString' Hostname, database, port and database type for " ."\n"
."| the connection. Driver example: mysql. Currently supported:" ."\n"
."| mysql, pgsql, mssql, sqlite, oci" ."\n"
."| 'username' The username used to connect to the database" ."\n"
."| 'password' The password used to connect to the database" ."\n"
."| 'tablePrefix' You can add an optional prefix, which will be added" ."\n"
."| to the table name when using the Active Record class" ."\n"
."| 'connectionString' Hostname, database, port and database type for " ."\n"
."| the connection. Driver example: mysql. Currently supported:" ."\n"
."| mysql, pgsql, mssql, sqlite, oci" ."\n"
."| 'username' The username used to connect to the database" ."\n"
."| 'password' The password used to connect to the database" ."\n"
."| 'tablePrefix' You can add an optional prefix, which will be added" ."\n"
."| to the table name when using the Active Record class" ."\n"
."|" ."\n"
."*/" ."\n"
. "return array(" . "\n"
Expand Down
2 changes: 2 additions & 0 deletions application/helpers/update/updatedb_helper.php
Expand Up @@ -1088,6 +1088,8 @@ function db_upgrade_all($oldversion) {
if ($oldversion < 167)
{
addColumn('{{surveys_languagesettings}}', 'attachments', 'text');
addColumn('{{users}}', 'created', 'datetime');
addColumn('{{users}}', 'modified', 'datetime');
Yii::app()->db->createCommand()->update('{{settings_global}}',array('stg_value'=>167),"stg_name='DBVersion'");
}

Expand Down
12 changes: 3 additions & 9 deletions installer/sql/create-mssql.sql
Expand Up @@ -492,19 +492,13 @@ CREATE TABLE [prefix_users] (
[parent_id] int NOT NULL,
[lang] varchar(20),
[email] varchar(320),
[create_survey] int NOT NULL default '0',
[create_user] int NOT NULL default '0',
[participant_panel] int NOT NULL default '0',
[delete_user] int NOT NULL default '0',
[superadmin] int NOT NULL default '0',
[configurator] int NOT NULL default '0',
[manage_template] int NOT NULL default '0',
[manage_label] int NOT NULL default '0',
[htmleditormode] varchar(7) default 'default',
[templateeditormode] varchar(7) NOT NULL default 'default',
[questionselectormode] varchar(7) NOT NULL default 'default',
[one_time_pw] text,
[dateformat] int NOT NULL DEFAULT 1
[dateformat] int NOT NULL DEFAULT 1,
[created] datetime,
[modified] datetime
);


Expand Down
12 changes: 3 additions & 9 deletions installer/sql/create-mysql.sql
Expand Up @@ -497,19 +497,13 @@ CREATE TABLE `prefix_users` (
`parent_id` int(11) NOT NULL,
`lang` varchar(20),
`email` varchar(320),
`create_survey` int(11) NOT NULL default '0',
`create_user` int(11) NOT NULL default '0',
`participant_panel` int(11) NOT NULL default '0',
`delete_user` int(11) NOT NULL default '0',
`superadmin` int(11) NOT NULL default '0',
`configurator` int(11) NOT NULL default '0',
`manage_template` int(11) NOT NULL default '0',
`manage_label` int(11) NOT NULL default '0',
`htmleditormode` varchar(7) default 'default',
`templateeditormode` varchar(7) NOT NULL default 'default',
`questionselectormode` varchar(7) NOT NULL default 'default',
`one_time_pw` BLOB,
`dateformat` INT NOT NULL DEFAULT 1
`dateformat` INT NOT NULL DEFAULT 1,
`created` datetime,
`modified` datetime
) ENGINE=MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;


Expand Down
12 changes: 3 additions & 9 deletions installer/sql/create-pgsql.sql
Expand Up @@ -502,19 +502,13 @@ CREATE TABLE prefix_users (
parent_id integer NOT NULL,
lang character varying(20),
email character varying(320),
create_survey integer DEFAULT 0 NOT NULL,
create_user integer DEFAULT 0 NOT NULL,
participant_panel 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 varying(7) DEFAULT 'default',
templateeditormode character varying(7) DEFAULT 'default' NOT NULL,
questionselectormode character varying(7) DEFAULT 'default' NOT NULL,
one_time_pw bytea,
"dateformat" integer DEFAULT 1 NOT NULL
"dateformat" integer DEFAULT 1 NOT NULL,
"created" timestamp,
"modified" timestamp
);


Expand Down

0 comments on commit fb8fb01

Please sign in to comment.