Skip to content

Commit

Permalink
Merging cpdb to ci branch
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_ci@10687 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed Aug 11, 2011
1 parent ace4e25 commit 50a6671
Show file tree
Hide file tree
Showing 222 changed files with 49,102 additions and 3,101 deletions.
2 changes: 1 addition & 1 deletion application/config/autoload.php
Expand Up @@ -64,7 +64,7 @@
| $autoload['helper'] = array('url', 'file');
*/

$autoload['helper'] = array('url','form','string','common','sanitize','admin/htmleditor');
$autoload['helper'] = array('url','form','string','common','sanitize','admin/htmleditor','html');


/*
Expand Down
2 changes: 1 addition & 1 deletion application/config/config.php
Expand Up @@ -127,7 +127,7 @@
| DO NOT CHANGE THIS UNLESS YOU FULLY UNDERSTAND THE REPERCUSSIONS!!
|
*/
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-|| @ ,';


/*
Expand Down
90 changes: 45 additions & 45 deletions application/config/database.php
@@ -1,46 +1,46 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| DATABASE CONNECTIVITY SETTINGS
| -------------------------------------------------------------------
| This file will contain the settings needed to access your database.
|
| For complete instructions please consult the 'Database Connection'
| page of the User Guide.
|
| -------------------------------------------------------------------
| EXPLANATION OF VARIABLES
| -------------------------------------------------------------------
|
| ['hostname'] The hostname of your database server.
| ['username'] The username used to connect to the database
| ['password'] The password used to connect to the database
| ['database'] The name of the database you want to connect to
| ['dbdriver'] The database type. ie: mysql. Currently supported:
mysql, mysqli, postgre, odbc, mssql, sqlite, oci8
| ['dbprefix'] You can add an optional prefix, which will be added
| to the table name when using the Active Record class
| ['pconnect'] TRUE/FALSE - Whether to use a persistent connection
| ['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
| ['cache_on'] TRUE/FALSE - Enables/disables query caching
| ['cachedir'] The path to the folder where cache files should be stored
| ['char_set'] The character set used in communicating with the database
| ['dbcollat'] The character collation used in communicating with the database
| ['swap_pre'] A default table prefix that should be swapped with the dbprefix
| ['autoinit'] Whether or not to automatically initialize the database.
| ['stricton'] TRUE/FALSE - forces 'Strict Mode' connections
| - good for ensuring strict SQL while developing
|
| The $active_group variable lets you choose which connection group to
| make active. By default there is only one group (the 'default' group).
|
| The $active_record variables lets you determine whether or not to load
| the active record class
*/
$active_group = 'default';
$active_record = TRUE;
| -------------------------------------------------------------------
| DATABASE CONNECTIVITY SETTINGS
| -------------------------------------------------------------------
| This file will contain the settings needed to access your database.
|
| For complete instructions please consult the 'Database Connection'
| page of the User Guide.
|
| -------------------------------------------------------------------
| EXPLANATION OF VARIABLES
| -------------------------------------------------------------------
|
| ['hostname'] The hostname of your database server.
| ['username'] The username used to connect to the database
| ['password'] The password used to connect to the database
| ['database'] The name of the database you want to connect to
| ['dbdriver'] The database type. ie: mysql. Currently supported:
mysql, mysqli, postgre, odbc, mssql, sqlite, oci8
| ['dbprefix'] You can add an optional prefix, which will be added
| to the table name when using the Active Record class
| ['pconnect'] TRUE/FALSE - Whether to use a persistent connection
| ['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
| ['cache_on'] TRUE/FALSE - Enables/disables query caching
| ['cachedir'] The path to the folder where cache files should be stored
| ['char_set'] The character set used in communicating with the database
| ['dbcollat'] The character collation used in communicating with the database
| ['swap_pre'] A default table prefix that should be swapped with the dbprefix
| ['autoinit'] Whether or not to automatically initialize the database.
| ['stricton'] TRUE/FALSE - forces 'Strict Mode' connections
| - good for ensuring strict SQL while developing
|
| The $active_group variable lets you choose which connection group to
| make active. By default there is only one group (the 'default' group).
|
| The $active_record variables lets you determine whether or not to load
| the active record class
*/

$active_group = 'default';
$active_record = TRUE;

$db['default']['hostname'] = '';
$db['default']['username'] = '';
$db['default']['password'] = '';
Expand All @@ -58,7 +58,7 @@
$db['default']['stricton'] = FALSE;
$db['default']['port'] = 'default';
$db['default']['databasetabletype'] = 'myISAM';
$config['dbdriver'] = $db['default']['dbdriver'];
$config['dbdriver'] = $db['default']['dbdriver'];

/* End of file database.php */
/* Location: ./application/config/database.php */
/* End of file database.php */
/* Location: ./application/config/database.php */
2 changes: 1 addition & 1 deletion application/config/lsconfig.php
Expand Up @@ -63,7 +63,7 @@
$config['printanswershonorsconditions'] = 1; // Set to 1 if you want the participant printanswers feature to show only the questions that were displayed survey branching-logic
$config['shownoanswer'] = 1; // Show 'no answer' for non mandatory questions ( 0 = no , 1 = yes , 2 = survey admin can choose )
$config['admintheme'] = 'default'; // This setting specifys the directory where the admin finds it theme/css style files, e.g. setting 'default' points to /admin/styles/default

$config['userideditable'] = 'N';
$config['defaulttemplate'] = 'default'; // This setting specifys the default theme used for the 'public list' of surveys

$config['allowedtemplateuploads'] = 'gif,ico,jpg,png'; // File types allowed to be uploaded in the templates section.
Expand Down
21 changes: 21 additions & 0 deletions application/controllers/admin/browse.php
Expand Up @@ -1109,4 +1109,25 @@ function action($surveyid = null, $subaction = null, $var1 = null, $var2 = null,
self::_getAdminFooter("http://docs.limesurvey.org", $this->limesurvey_lang->gT("LimeSurvey online manual"));

}

/**
* Browse Menu Bar
*/
function _browsemenubar($surveyid, $title='')
{
//BROWSE MENU BAR
$data['title'] = $title;
$data['thissurvey'] = getSurveyInfo($surveyid);
$data['imageurl'] = $this->config->item("imageurl");
$data['clang'] = $this->limesurvey_lang;
$data['surveyid'] = $surveyid;

$tmp_survlangs = GetAdditionalLanguagesFromSurveyID($surveyid);
$baselang = GetBaseLanguageFromSurveyID($surveyid);
$tmp_survlangs[] = $baselang;
rsort($tmp_survlangs);
$data['tmp_survlangs'] = $tmp_survlangs;

$this->load->view("admin/browse/browsemenubar_view", $data);
}
}
225 changes: 0 additions & 225 deletions application/controllers/admin/database.php
Expand Up @@ -28,232 +28,7 @@ function index($action=null)
}


if ($action == "updateansweroptions" && bHasSurveyPermission($surveyid, 'surveycontent','update'))
{
$this->load->helper('database');
$anslangs = GetAdditionalLanguagesFromSurveyID($surveyid);
$baselang = GetBaseLanguageFromSurveyID($surveyid);

$alllanguages = $anslangs;
array_unshift($alllanguages,$baselang);


$query = "select type from ".$this->db->dbprefix."questions where qid=$qid";
$res= db_execute_assoc($query);
$resrow = $res->row_array();
$questiontype = $resrow['type']; //$connect->GetOne($query); // Checked)
$qtypes=getqtypelist('','array');
$scalecount=$qtypes[$questiontype]['answerscales'];

$count=0;
$invalidCode = 0;
$duplicateCode = 0;

//require_once("../classes/inputfilter/class.inputfilter_clean.php");
//$myFilter = new InputFilter('','',1,1,1);
$_POST = $this->input->post();
//First delete all answers
$query = "delete from ".$this->db->dbprefix."answers where qid=".$qid;
$result = db_execute_assoc($query); // Checked

for ($scale_id=0;$scale_id<$scalecount;$scale_id++)
{
$maxcount=(int) $_POST['answercount_'.$scale_id];

for ($sortorderid=1;$sortorderid<$maxcount;$sortorderid++)
{
$oldcode=sanitize_paranoid_string($_POST['oldcode_'.$sortorderid.'_'.$scale_id]);
$code=sanitize_paranoid_string($_POST['code_'.$sortorderid.'_'.$scale_id]);
$assessmentvalue=(int) $_POST['assessment_'.$sortorderid.'_'.$scale_id];
foreach ($alllanguages as $language)
{
$answer=$_POST['answer_'.$language.'_'.$sortorderid.'_'.$scale_id];

/**if ($filterxsshtml)
{
//Sanitize input, strip XSS
$answer=$myFilter->process($answer);
}
else
{ */
$answer=html_entity_decode($answer, ENT_QUOTES, "UTF-8");
//}
// Fix bug with FCKEditor saving strange BR types
$answer=fix_FCKeditor_text($answer);

// Now we insert the answers
$query = "INSERT INTO ".$this->db->dbprefix."answers (code,answer,qid,sortorder,language,assessment_value, scale_id)
VALUES ('".$code."', '".
$answer."', ".
$qid.", ".
$sortorderid.", '".
$language."', ".
$assessmentvalue.",
$scale_id)";
if (!$result = db_execute_assoc($query)) // Checked
{
$databaseoutput .= "<script type=\"text/javascript\">\n<!--\n alert(\"".$clang->gT("Failed to update answers","js")." - ".$query." - ".$connect->ErrorMsg()."\")\n //-->\n</script>\n";
}
} // foreach ($alllanguages as $language)

if($code !== $oldcode) {
$query='UPDATE '.$this->db->dbprefix.'conditions SET value=\''.$code.' WHERE cqid='.$qid.' AND value=\''.$oldcode.'\'';
db_execute_assoc($query);
}

} // for ($sortorderid=0;$sortorderid<$maxcount;$sortorderid++)
} // for ($scale_id=0;

if ($invalidCode == 1) $databaseoutput .= "<script type=\"text/javascript\">\n<!--\n alert(\"".$clang->gT("Answers with a code of 0 (zero) or blank code are not allowed, and will not be saved","js")."\")\n //-->\n</script>\n";
if ($duplicateCode == 1) $databaseoutput .= "<script type=\"text/javascript\">\n<!--\n alert(\"".$clang->gT("Duplicate codes found, these entries won't be updated","js")."\")\n //-->\n</script>\n";

$sortorderid--;
$this->session->set_userdata('flashmessage', $clang->gT("Answer options were successfully saved."));

if ($databaseoutput != '')
{
echo $databaseoutput;
}
else
{
redirect(site_url('admin/question/answeroptions/'.$surveyid.'/'.$gid.'/'.$qid));
}

//$action='editansweroptions';

}


if ($action == "updatesubquestions" && bHasSurveyPermission($surveyid, 'surveycontent','update'))
{
$this->load->helper('database');
$anslangs = GetAdditionalLanguagesFromSurveyID($surveyid);
$baselang = GetBaseLanguageFromSurveyID($surveyid);
array_unshift($anslangs,$baselang);

$query = "select type from ".$this->db->dbprefix."questions where qid=$qid";
$res=db_execute_assoc($query);
$row = $res->row_array();
$questiontype = $row['type']; //$connect->GetOne($query); // Checked
$qtypes=getqtypelist('','array');
$scalecount=$qtypes[$questiontype]['subquestions'];
$_POST = $this->input->post();
$clang = $this->limesurvey_lang;
// First delete any deleted ids
$deletedqids=explode(' ', trim($_POST['deletedqids']));

foreach ($deletedqids as $deletedqid)
{
$deletedqid=(int)$deletedqid;
if ($deletedqid>0)
{ // don't remove undefined
$query = "DELETE FROM ".$this->db->dbprefix."questions WHERE qid='{$deletedqid}'"; // Checked
if (!$result = db_execute_assoc($query))
{
$databaseoutput .= "<script type=\"text/javascript\">\n<!--\n alert(\"".$clang->gT("Failed to delete answer","js")." - ".$query." \")\n //-->\n</script>\n";
}
}
}

//Determine ids by evaluating the hidden field
$rows=array();
$codes=array();
$oldcodes=array();
foreach ($_POST as $postkey=>$postvalue)
{
$postkey=explode('_',$postkey);
if ($postkey[0]=='answer')
{
$rows[$postkey[3]][$postkey[1]][$postkey[2]]=$postvalue;
}
if ($postkey[0]=='code')
{
$codes[$postkey[2]][]=$postvalue;
}
if ($postkey[0]=='oldcode')
{
$oldcodes[$postkey[2]][]=$postvalue;
}
}
$count=0;
$invalidCode = 0;
$duplicateCode = 0;
$dupanswers = array();
/*
for ($scale_id=0;$scale_id<$scalecount;$scale_id++)
{
// Find duplicate codes and add these to dupanswers array
$foundCat=array_count_values($codes);
foreach($foundCat as $key=>$value){
if($value>=2){
$dupanswers[]=$key;
}
}
}
*/
//require_once("../classes/inputfilter/class.inputfilter_clean.php");
//$myFilter = new InputFilter('','',1,1,1);


$insertqids=array();
for ($scale_id=0;$scale_id<$scalecount;$scale_id++)
{
foreach ($anslangs as $language)
{
$position=0;
foreach ($rows[$scale_id][$language] as $subquestionkey=>$subquestionvalue)
{
if (substr($subquestionkey,0,3)!='new')
{
$query='Update '.$this->db->dbprefix.'questions set question_order='.($position+1).', title=\''.$codes[$scale_id][$position].'\', question=\''.$subquestionvalue.'\', scale_id='.$scale_id.' where qid=\''.$subquestionkey.'\' AND language=\''.$language.'\'';
db_execute_assoc($query);

if($codes[$scale_id][$position] !== $oldcodes[$scale_id][$position]) {
$query='UPDATE '.$this->db->dbprefix.'conditions SET cfieldname="+'.$surveyid.'X'.$gid.'X'.$qid.$codes[$scale_id][$position].'" WHERE cqid='.$qid.' AND cfieldname="+'.$surveyid.'X'.$gid.'X'.$qid.$oldcodes[$scale_id][$position].'"';
db_execute_assoc($query);
$query='UPDATE '.$this->db->dbprefix.'conditions SET value="'.$codes[$scale_id][$position].'" WHERE cqid='.$qid.' AND cfieldname="'.$surveyid.'X'.$gid.'X'.$qid.'" AND value="'.$oldcodes[$scale_id][$position].'"';
db_execute_assoc($query);
}

}
else
{
if (!isset($insertqid[$position]))
{
$query='INSERT into '.$this->db->dbprefix.'questions (sid, gid, question_order, title, question, parent_qid, language, scale_id) values ('.$surveyid.','.$gid.','.($position+1).',\''.$codes[$scale_id][$position].'\',\''.$subquestionvalue.'\','.$qid.',\''.($language).'\','.$scale_id.')';
db_execute_assoc($query);
$insertqid[$position]=$this->db->insert_id(); //$connect->Insert_Id(db_table_name_nq('questions'),"qid");
}
else
{
db_switchIDInsert('questions',true);
$query='INSERT into '.$this->db->dbprefix.'questions (qid, sid, gid, question_order, title, question, parent_qid, language, scale_id) values ('.$insertqid[$position].','.$surveyid.','.$gid.','.($position+1).',\''.$codes[$scale_id][$position].'\',\''.$subquestionvalue.'\','.$qid.',\''.$language.'\','.$scale_id.')';
db_execute_assoc($query);
db_switchIDInsert('questions',true);
}
}
$position++;
}

}
}
//include("surveytable_functions.php");
//surveyFixColumns($surveyid);
$this->session->set_userdata('flashmessage', $clang->gT("Subquestions were successfully saved."));

//$action='editsubquestions';

if ($databaseoutput != '')
{
echo $databaseoutput;
}
else
{
redirect(site_url('admin/question/subquestions/'.$surveyid.'/'.$gid.'/'.$qid));
}
}

if ($action == "insertquestion" && bHasSurveyPermission($surveyid, 'surveycontent','create'))
{
$_POST = $this->input->post();
Expand Down

0 comments on commit 50a6671

Please sign in to comment.