Skip to content

Commit

Permalink
Fixed issue #4939: Group ordering problem: group_order not correctly …
Browse files Browse the repository at this point in the history
…initialized when adding groups and using mssql_n driver

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_dev@9763 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed Feb 10, 2011
1 parent c5193e3 commit b60906c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 17 deletions.
5 changes: 2 additions & 3 deletions admin/install/create-mssql.sql
Expand Up @@ -420,11 +420,10 @@ CREATE TABLE [prefix_templates] (
--

CREATE TABLE [prefix_failed_login_attempts] (
[id] int(11) NOT NULL AUTO_INCREMENT,
[id] INT NOT NULL IDENTITY (1,1) PRIMARY KEY,
[ip] varchar(37) NOT NULL,
[last_attempt] varchar(20) NOT NULL,
[number_attempts] int(11) NOT NULL,
PRIMARY KEY ([id])
[number_attempts] int NOT NULL
);

--
Expand Down
5 changes: 2 additions & 3 deletions admin/install/create-mssqlnative.sql
Expand Up @@ -431,11 +431,10 @@ CREATE TABLE [prefix_templates] (
--

CREATE TABLE [prefix_failed_login_attempts] (
[id] int(11) NOT NULL AUTO_INCREMENT,
[id] INT NOT NULL IDENTITY (1,1) PRIMARY KEY,
[ip] varchar(37) NOT NULL,
[last_attempt] varchar(20) NOT NULL,
[number_attempts] int(11) NOT NULL,
PRIMARY KEY ([id])
[number_attempts] int NOT NULL
);


Expand Down
4 changes: 2 additions & 2 deletions admin/update/upgrade-mssql.php
Expand Up @@ -570,11 +570,11 @@ function upgrade_token_tables134()
// Add the usesleft field to all existing token tables
function upgrade_token_tables145()
{
global $modifyoutput,$dbprefix;
global $modifyoutput, $dbprefix, $connect;
$surveyidquery = db_select_tables_like($dbprefix."tokens%");
$surveyidresult = db_execute_num($surveyidquery);
$tokentables=$connect->MetaTables('TABLES',false,$dbprefix."tokens%");
foreach ($tokentables as $sv)
foreach ($tokentables as $sv) {
modify_database("","ALTER TABLE ".$sv[0]." ADD [usesleft] int NOT NULL DEFAULT '1'"); echo $modifyoutput; flush();ob_flush();
modify_database("","UPDATE ".$sv[0]." SET usesleft=0 WHERE completed<>'N'"); echo $modifyoutput; flush();ob_flush();
}
Expand Down
4 changes: 2 additions & 2 deletions admin/update/upgrade-mssqlnative.php
Expand Up @@ -567,11 +567,11 @@ function upgrade_token_tables134()
// Add the usesleft field to all existing token tables
function upgrade_token_tables145()
{
global $modifyoutput,$dbprefix;
global $modifyoutput, $dbprefix, $connect;
$surveyidquery = db_select_tables_like($dbprefix."tokens%");
$surveyidresult = db_execute_num($surveyidquery);
$tokentables=$connect->MetaTables('TABLES',false,$dbprefix."tokens%");
foreach ($tokentables as $sv)
foreach ($tokentables as $sv) {
modify_database("","ALTER TABLE ".$sv[0]." ADD [usesleft] int NOT NULL DEFAULT '1'"); echo $modifyoutput; flush();ob_flush();
modify_database("","UPDATE ".$sv[0]." SET usesleft=0 WHERE completed<>'N'"); echo $modifyoutput; flush();ob_flush();
}
Expand Down
12 changes: 5 additions & 7 deletions common_functions.php
Expand Up @@ -849,20 +849,18 @@ function getQuestionSum($surveyid, $groupid)


/**
* getMaxgrouporder($surveyid) queries the database for the maximum sortorder of a group.
* getMaxgrouporder($surveyid) queries the database for the maximum sortorder of a group and returns the next higher one.
*
* @param mixed $surveyid
* @global string $surveyid
*/
function getMaxgrouporder($surveyid)
{
global $surveyid ;
global $surveyid, $connect ;
$s_lang = GetBaseLanguageFromSurveyID($surveyid);
$max_sql = "SELECT max( group_order ) AS max FROM ".db_table_name('groups')." WHERE sid =$surveyid AND language='{$s_lang}'" ;
$max_result =db_execute_assoc($max_sql) ; //Checked
$maxrow = $max_result->FetchRow() ;
$current_max = $maxrow['max'];
if($current_max=="")
$current_max = $connect->GetOne($max_sql) ;
if(is_null($current_max))
{
return "0" ;
}
Expand Down Expand Up @@ -8204,7 +8202,7 @@ function bCheckQuestionForAnswer($q, $aFieldnamesInfoInv)
{
if(isset($_SESSION[$sField]) && trim($_SESSION[$sField])!='')
{
$bAnsw = false;
$bAnsw = true;
break;
}
}
Expand Down

0 comments on commit b60906c

Please sign in to comment.