Skip to content

Commit

Permalink
Editing local settings now possible!
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_ci@10364 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
sachdeva-shubham committed Jun 28, 2011
1 parent 1ce437d commit 82a2af4
Show file tree
Hide file tree
Showing 6 changed files with 283 additions and 8 deletions.
86 changes: 86 additions & 0 deletions application/controllers/admin/database.php
Expand Up @@ -18,6 +18,8 @@ function index($action)
$postqid=returnglobal('qid');
$postqaid=returnglobal('qaid');
$databaseoutput = '';
$surveyid = $this->input->post("sid");

if ($action == "insertsurvey" && $this->session->userdata('USER_RIGHT_CREATE_SURVEY'))
{

Expand Down Expand Up @@ -226,6 +228,90 @@ function index($action)
// safe_die ("Initial survey table could not be created, please report this as a bug."."<br />".$creationResult);
//}
}
if ($databaseoutput != '')
{
echo $databaseoutput;
}
else
{
redirect(site_url('admin/survey/view/'.$surveyid));
}
}


if (($action == "updatesurveylocalesettings") && bHasSurveyPermission($surveyid,'surveylocale','update'))
{
$languagelist = GetAdditionalLanguagesFromSurveyID($surveyid);
$languagelist[]=GetBaseLanguageFromSurveyID($surveyid);
/**require_once("../classes/inputfilter/class.inputfilter_clean.php");
$myFilter = new InputFilter('','',1,1,1);
*/
foreach ($languagelist as $langname)
{
if ($langname)
{
$url = $this->input->post('url_'.$langname);
if ($url == 'http://') {$url="";}

// Clean XSS attacks
/**if ($filterxsshtml) //not required. As we are using input class, XSS filetring is done automatically!
{
$_POST['short_title_'.$langname]=$myFilter->process($_POST['short_title_'.$langname]);
$_POST['description_'.$langname]=$myFilter->process($_POST['description_'.$langname]);
$_POST['welcome_'.$langname]=$myFilter->process($_POST['welcome_'.$langname]);
$_POST['endtext_'.$langname]=$myFilter->process($_POST['endtext_'.$langname]);
$_POST['urldescrip_'.$langname]=$myFilter->process($_POST['urldescrip_'.$langname]);
$_POST['url_'.$langname]=$myFilter->process($_POST['url_'.$langname]);
}
else
{
$_POST['short_title_'.$langname] = html_entity_decode($_POST['short_title_'.$langname], ENT_QUOTES, "UTF-8");
$_POST['description_'.$langname] = html_entity_decode($_POST['description_'.$langname], ENT_QUOTES, "UTF-8");
$_POST['welcome_'.$langname] = html_entity_decode($_POST['welcome_'.$langname], ENT_QUOTES, "UTF-8");
$_POST['endtext_'.$langname] = html_entity_decode($_POST['endtext_'.$langname], ENT_QUOTES, "UTF-8");
$_POST['urldescrip_'.$langname] = html_entity_decode($_POST['urldescrip_'.$langname], ENT_QUOTES, "UTF-8");
$_POST['url_'.$langname] = html_entity_decode($_POST['url_'.$langname], ENT_QUOTES, "UTF-8");
} */

// Fix bug with FCKEditor saving strange BR types
$short_title = $this->input->post('short_title_'.$langname);
$description = $this->input->post('description_'.$langname);
$welcome = $this->input->post('welcome_'.$langname);
$endtext = $this->input->post('endtext_'.$langname);

$short_title=fix_FCKeditor_text($short_title);
$description=fix_FCKeditor_text($description);
$welcome=fix_FCKeditor_text($welcome);
$endtext=fix_FCKeditor_text($endtext);

$data = array(
'surveyls_title' => $short_title,
'surveyls_description' => $description,
'surveyls_welcometext' => $welcome,
'surveyls_endtext' => $endtext,
'surveyls_url' => $url,
'surveyls_urldescription' => $this->input->post('urldescrip_'.$langname),
'surveyls_dateformat' => $this->input->post('dateformat_'.$langname),
'surveyls_numberformat' => $this->input->post('numberformat_'.$langname)
);
//In 'surveyls_survey_id' => $surveyid, it was initially $postsid. returnglobal not working properly!
$condition = array('surveyls_survey_id' => $surveyid, 'surveyls_language' => $langname);
/**
$usquery = "UPDATE ".db_table_name('surveys_languagesettings')." \n"
. "SET surveyls_title='".db_quote($short_title)."', surveyls_description='".db_quote($description)."',\n"
. "surveyls_welcometext='".db_quote($welcome)."',\n"
. "surveyls_endtext='".db_quote($endtext)."',\n"
. "surveyls_url='".db_quote($url)."',\n"
. "surveyls_urldescription='".db_quote($_POST['urldescrip_'.$langname])."',\n"
. "surveyls_dateformat='".db_quote($_POST['dateformat_'.$langname])."',\n"
. "surveyls_numberformat='".db_quote($_POST['numberformat_'.$langname])."'\n"
. "WHERE surveyls_survey_id=".$postsid." and surveyls_language='".$langname."'"; */
$this->load->model('surveys_languagesettings_model');

$usresult = $this->surveys_languagesettings_model->update($data,$condition);// or safe_die("Error updating local settings"); // Checked
}
}
$this->session->set_userdata('flashmessage',$clang->gT("Survey text elements successfully saved."));
}

if ($databaseoutput != '')
Expand Down
136 changes: 135 additions & 1 deletion application/controllers/admin/survey.php
Expand Up @@ -38,6 +38,140 @@ function view($surveyid)
}
}

function editlocalsettings($surveyid)
{
$clang = $this->limesurvey_lang;

self::_js_admin_includes(base_url().'application/scripts/surveysettings.js');
self::_getAdminHeader();
self::_showadminmenu();

if(bHasSurveyPermission($surveyid,'surveylocale','read'))
{

$grplangs = GetAdditionalLanguagesFromSurveyID($surveyid);
$baselang = GetBaseLanguageFromSurveyID($surveyid);
array_unshift($grplangs,$baselang);

$editsurvey = PrepareEditorScript();


$editsurvey .="<div class='header ui-widget-header'>".$clang->gT("Edit survey text elements")."</div>\n";
$editsurvey .= "<form id='addnewsurvey' class='form30' name='addnewsurvey' action='".site_url("admin/database/index/updatesurveylocalesettings")."' method='post'>\n"
. '<div id="tabs">';
$i = 0;
foreach ($grplangs as $grouplang)
{
// this one is created to get the right default texts fo each language
$this->load->library('Limesurvey_lang',array($grouplang));
$this->load->helper('database');
$this->load->helper('surveytranslator');
$bplang = $this->limesurvey_lang;//new limesurvey_lang($grouplang);
$esquery = "SELECT * FROM ".$this->db->dbprefix."surveys_languagesettings WHERE surveyls_survey_id=$surveyid and surveyls_language='$grouplang'";
$esresult = db_execute_assoc($esquery); //Checked
$esrow = $esresult->row_array();

$tab_title[$i] = getLanguageNameFromCode($esrow['surveyls_language'],false);

if ($esrow['surveyls_language']==GetBaseLanguageFromSurveyID($surveyid))
$tab_title[$i] .= '('.$clang->gT("Base Language").')';

$esrow = array_map('htmlspecialchars', $esrow);
$data['clang'] = $clang;
$data['esrow'] = $esrow;
$data['surveyid'] = $surveyid;
$data['action'] = "editsurveylocalesettings";

$tab_content[$i] = $this->load->view('admin/Survey/editLocalSettings_view',$data,true);

/**
$tab_content[$i] = "<ul>\n"
. "<li><label for=''>".$clang->gT("Survey title").":</label>\n"
. "<input type='text' size='80' name='short_title_".$esrow['surveyls_language']."' value=\"{$esrow['surveyls_title']}\" /></li>\n"
. "<li><label for=''>".$clang->gT("Description:")."</label>\n"
. "<textarea cols='80' rows='15' name='description_".$esrow['surveyls_language']."'>{$esrow['surveyls_description']}</textarea>\n"
. getEditor("survey-desc","description_".$esrow['surveyls_language'], "[".$clang->gT("Description:", "js")."](".$esrow['surveyls_language'].")",$surveyid,'','',$action)
. "</li>\n"
. "<li><label for=''>".$clang->gT("Welcome message:")."</label>\n"
. "<textarea cols='80' rows='15' name='welcome_".$esrow['surveyls_language']."'>{$esrow['surveyls_welcometext']}</textarea>\n"
. getEditor("survey-welc","welcome_".$esrow['surveyls_language'], "[".$clang->gT("Welcome:", "js")."](".$esrow['surveyls_language'].")",$surveyid,'','',$action)
. "</li>\n"
. "<li><label for=''>".$clang->gT("End message:")."</label>\n"
. "<textarea cols='80' rows='15' name='endtext_".$esrow['surveyls_language']."'>{$esrow['surveyls_endtext']}</textarea>\n"
. getEditor("survey-endtext","endtext_".$esrow['surveyls_language'], "[".$clang->gT("End message:", "js")."](".$esrow['surveyls_language'].")",$surveyid,'','',$action)
. "</li>\n"
. "<li><label for=''>".$clang->gT("End URL:")."</label>\n"
. "<input type='text' size='80' name='url_".$esrow['surveyls_language']."' value=\"{$esrow['surveyls_url']}\" />\n"
. "</li>"
. "<li><label for=''>".$clang->gT("URL description:")."</label>\n"
. "<input type='text' size='80' name='urldescrip_".$esrow['surveyls_language']."' value=\"{$esrow['surveyls_urldescription']}\" />\n"
. "</li>"
. "<li><label for=''>".$clang->gT("Date format:")."</label>\n"
. "<select size='1' name='dateformat_".$esrow['surveyls_language']."'>\n";
foreach (getDateFormatData() as $index=>$dateformatdata)
{
$tab_content[$i].= "<option value='{$index}'";
if ($esrow['surveyls_dateformat']==$index) {
$tab_content[$i].=" selected='selected'";
}
$tab_content[$i].= ">".$dateformatdata['dateformat'].'</option>';
}
$tab_content[$i].= "</select></li>"
. "<li><label for=''>".$clang->gT("Decimal Point Format:")."</label>\n";
$tab_content[$i].="<select size='1' name='numberformat_".$esrow['surveyls_language']."'>\n";
foreach (getRadixPointData() as $index=>$radixptdata)
{
$tab_content[$i].= "<option value='{$index}'";
if ($esrow['surveyls_numberformat']==$index) {
$tab_content[$i].=" selected='selected'";
}
$tab_content[$i].= ">".$radixptdata['desc'].'</option>';
}
$tab_content[$i].= "</select></li></ul>"; */
$i++;
}

$editsurvey .= "<ul>";
foreach($tab_title as $i=>$eachtitle){
$editsurvey .= "<li style='clear:none'><a href='#edittxtele$i'>$eachtitle</a></li>";
}
$editsurvey .= "</ul>";
foreach ($tab_content as $i=>$eachcontent){
$editsurvey .= "<div id='edittxtele$i'>$eachcontent</div>";
}
$editsurvey .= "</div>";
if(bHasSurveyPermission($surveyid,'surveylocale','update'))
{
$editsurvey .= "<p><input type='submit' class='standardbtn' value='".$clang->gT("Save")."' />\n"
. "<input type='hidden' name='action' value='updatesurveylocalesettings' />\n"
. "<input type='hidden' name='sid' value=\"{$surveyid}\" />\n"
. "<input type='hidden' name='language' value=\"{$esrow['surveyls_language']}\" />\n"
. "</p>\n"
. "</form>\n";
}




$editsurvey .= self::_loadEndScripts();

//echo $editsurvey;
$finaldata['display'] = $editsurvey;
$this->load->view('survey_view',$finaldata);
//self::_getAdminFooter("http://docs.limesurvey.org", $this->limesurvey_lang->gT("LimeSurvey online manual"));

}
else
{
//include("access_denied.php");
$finaldata['display'] = access_denied("editsurvey",$surveyid);
$this->load->view('survey_view',$finaldata);

}
self::_getAdminFooter("http://docs.limesurvey.org", $this->limesurvey_lang->gT("LimeSurvey online manual"));

}

function copy()
{

Expand Down Expand Up @@ -78,7 +212,7 @@ function copy()
{
$exclude['conditions'] = true;
}
echo "hi";

//include("export_structure_xml.php");
$this->load->helper('admin/export_structure_xml');

Expand Down
15 changes: 11 additions & 4 deletions application/helpers/common_helper.php
Expand Up @@ -592,7 +592,9 @@ function gettemplatelist()
*/
function getQuestions($surveyid,$gid,$selectedqid)
{
global $clang,$CI;
//global $clang,$CI;
$CI =& get_instance();
$clang = $CI->limesurvey_lang;
$CI->load->config('lsconfig');
$s_lang = GetBaseLanguageFromSurveyID($surveyid);
$CI->load->model('questions');
Expand Down Expand Up @@ -1212,7 +1214,9 @@ function longest_string( $new_string , $longest_length )
*/
function getNotificationlist($notificationcode)
{
global $clang;
//global $clang;
$CI =& get_instance();
$clang = $CI->limesurvey_lang;
$ntypes = array(
"0"=>$clang->gT("No email notification"),
"1"=>$clang->gT("Basic email notification"),
Expand Down Expand Up @@ -3764,7 +3768,9 @@ function getQuestionAttributeValue($questionAttributeArray, $attributeName)
*/
function questionAttributes($returnByName=false)
{
global $clang,$CI;
//global $clang,$CI;
$CI =& get_instance();
$clang = $CI->limesurvey_lang;
//For each question attribute include a key:
// name - the display name
// types - a string with one character representing each question typy to which the attribute applies
Expand Down Expand Up @@ -7393,8 +7399,9 @@ function access_denied($action,$sid='')
}
elseif($action == "editsurvey")
{
$link = site_url("admin/survey/view/$sid");
$accesssummary .= "<p>".$clang->gT("You are not allowed to edit this survey!")."</p>";
$accesssummary .= "<a href='$scriptname?sid={$sid}'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
$accesssummary .= "<a href='$link'>".$clang->gT("Continue")."</a><br />&nbsp;\n";
}
elseif($action == "editgroup")
{
Expand Down
3 changes: 2 additions & 1 deletion application/helpers/surveytranslator_helper.php
Expand Up @@ -65,7 +65,8 @@ function getDateFormatData($format=0)

function getRadixPointData($format=-1)
{
global $clang;
$CI =& get_instance();
$clang = $CI->limesurvey_lang;
$aRadixFormats = array (
0=>array('seperator'=> '.', 'desc'=> $clang->gT('Dot (.)')),
1=>array('seperator'=> ',', 'desc'=> $clang->gT('Comma (,)'))
Expand Down
47 changes: 47 additions & 0 deletions application/views/admin/Survey/editLocalSettings_view.php
@@ -0,0 +1,47 @@
<ul>
<li><label for=''><?php echo $clang->gT("Survey title"); ?>:</label>
<input type='text' size='80' name='short_title_<?php echo $esrow['surveyls_language']; ?>' value="<?php echo $esrow['surveyls_title']; ?>" />
</li>
<li><label for=''><?php echo $clang->gT("Description:"); ?></label>
<textarea cols='80' rows='15' name='description_<?php echo $esrow['surveyls_language']; ?>'><?php echo $esrow['surveyls_description']; ?></textarea>
<?php echo getEditor("survey-desc","description_".$esrow['surveyls_language'], "[".$clang->gT("Description:", "js")."](".$esrow['surveyls_language'].")",$surveyid,'','',$action); ?>
</li>
<li><label for=''><?php echo $clang->gT("Welcome message:"); ?></label>
<textarea cols='80' rows='15' name='welcome_<?php echo $esrow['surveyls_language']; ?>'><?php echo $esrow['surveyls_welcometext']; ?></textarea>
<?php echo getEditor("survey-welc","welcome_".$esrow['surveyls_language'], "[".$clang->gT("Welcome:", "js")."](".$esrow['surveyls_language'].")",$surveyid,'','',$action); ?>
</li>
<li><label for=''><?php echo $clang->gT("End message:"); ?></label>
<textarea cols='80' rows='15' name='endtext_<?php echo $esrow['surveyls_language']; ?>'><?php echo $esrow['surveyls_endtext']; ?></textarea>
<?php echo getEditor("survey-endtext","endtext_".$esrow['surveyls_language'], "[".$clang->gT("End message:", "js")."](".$esrow['surveyls_language'].")",$surveyid,'','',$action); ?>
</li>
<li><label for=''><?php echo $clang->gT("End URL:"); ?></label>
<input type='text' size='80' name='url_<?php echo $esrow['surveyls_language']; ?>' value="<?php echo $esrow['surveyls_url']; ?>" />
</li>
<li><label for=''><?php echo $clang->gT("URL description:"); ?></label>
<input type='text' size='80' name='urldescrip_<?php echo $esrow['surveyls_language']; ?>' value="<?php echo $esrow['surveyls_urldescription']; ?>" />
</li>
<li><label for=''><?php echo $clang->gT("Date format:"); ?></label>
<select size='1' name='dateformat_<?php echo $esrow['surveyls_language']; ?>'>
<?php foreach (getDateFormatData() as $index=>$dateformatdata)
{ ?>
<option value='<?php echo $index; ?>'
<?php if ($esrow['surveyls_dateformat']==$index) { ?>
selected='selected'
<?php } ?>
><?php echo $dateformatdata['dateformat']; ?></option>
<?php } ?>
</select>
</li>
<li><label for=''><?php echo $clang->gT("Decimal Point Format:"); ?></label>
<select size='1' name='numberformat_<?php echo $esrow['surveyls_language']; ?>'>
<?php foreach (getRadixPointData() as $index=>$radixptdata)
{ ?>
<option value='<?php echo $index; ?>'
<?php if ($esrow['surveyls_numberformat']==$index) { ?>
selected='selected'
<?php } ?>
><?php echo $radixptdata['desc']; ?></option>
<?php } ?>
</select>
</li>
</ul>

0 comments on commit 82a2af4

Please sign in to comment.