Skip to content

Commit

Permalink
New feature: Global setting to restrict the languages being available…
Browse files Browse the repository at this point in the history
… in administration or frontend

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_ci@11166 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed Oct 14, 2011
1 parent bd3a363 commit 27b3df8
Show file tree
Hide file tree
Showing 15 changed files with 945 additions and 1,240 deletions.
8 changes: 8 additions & 0 deletions application/config/lsconfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,14 @@
// defines if the CKeditor toolbar should be opened by default
$config['ckeditexpandtoolbar'] = true;

/**
* This variable defines the languages available in LimeSurvey (front- and backend)
* and should contain a space-separated list of language codes. If empty then no restrictions
* are set and all languages are available
*
* @var string
*/
$config['restrictToLanguages'] = '';


// === Advanced Setup
Expand Down
7 changes: 0 additions & 7 deletions application/controllers/admin/authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,6 @@ function _showLoginForm($logoutsummary="")
$data['summary'] = $logoutsummary;
}

$lan=array();
$this->load->helper("surveytranslator");
foreach (getlanguagedata(true) as $langkey=>$languagekind)
{
array_push($lan,$langkey);
}

parent::_getAdminHeader();
$this->load->view('admin/authentication/login', $data);
parent::_getAdminFooter("http://docs.limesurvey.org", $this->limesurvey_lang->gT("LimeSurvey online manual"));
Expand Down
27 changes: 27 additions & 0 deletions application/controllers/admin/globalsettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ function _display()
{

$clang = $this->limesurvey_lang;
$this->load->helper('surveytranslator_helper');

self::_js_admin_includes(base_url()."scripts/jquery/jquery.selectboxes.min.js");
self::_js_admin_includes(base_url()."scripts/admin/globalsettings.js");

$data['title']="hi";
Expand All @@ -68,6 +70,17 @@ function _display()
$data['updatelastcheck'] = $this->config->item("updatelastcheck");
$data['updateavailable'] = $this->config->item("updateavailable");
$data['updateinfo'] = $this->config->item("updateinfo");
$data['allLanguages']=getLanguageData();
if (trim($this->config->item('restrictToLanguages'))=='')
{
$data['restrictToLanguages']=array_keys($data['allLanguages']);
$data['excludedLanguages']=array();
}
else
{
$data['restrictToLanguages']=explode(' ',trim($this->config->item('restrictToLanguages')));
$data['excludedLanguages']=array_diff(array_keys($data['allLanguages']),$data['restrictToLanguages']);
}

self::_getAdminHeader();
self::_showadminmenu();
Expand All @@ -79,6 +92,8 @@ function _display()
function _savesettings()
{
$clang = $this->limesurvey_lang;
$this->load->helper('surveytranslator_helper');

$action = $this->input->post("action");
if ($action == "globalsettingssave")
{
Expand All @@ -89,6 +104,17 @@ function _savesettings()
{
$maxemails=1;
}

$aRestrictToLanguages=explode(' ',sanitize_languagecodeS($this->input->post('restrictToLanguages')));
if (count(array_diff(array_keys(getLanguageData()),$aRestrictToLanguages))==0)
{
$aRestrictToLanguages='';
}else
{
$aRestrictToLanguages=implode(' ',$aRestrictToLanguages);
}

setGlobalSetting('restrictToLanguages',trim($aRestrictToLanguages));
setGlobalSetting('sitename',strip_tags($this->input->post('sitename')));
setGlobalSetting('updatecheckperiod',(int)($this->input->post('updatecheckperiod')));
setGlobalSetting('addTitleToLinks',sanitize_paranoid_string($this->input->post('addTitleToLinks')));
Expand Down Expand Up @@ -141,6 +167,7 @@ function _savesettings()

$this->session->set_userdata('flashmessage',$clang->gT("Global settings were saved."));
}
redirect(site_url('admin'));
}
}

Expand Down
123 changes: 1 addition & 122 deletions application/controllers/admin/labels.php
Original file line number Diff line number Diff line change
Expand Up @@ -388,106 +388,18 @@ function index($action,$lid=0)
$data['lid'] = $lid;


/**$labelsoutput.="<div class='header header_statistics'>\n"
."<input type='image' src='$imageurl/close.gif' align='right' "
."onclick=\"window.open('admin.php?action=labels&amp;lid=$lid', '_top')\" />\n"; */

if ($action == "newlabelset") {$langids=$this->session->userdata('adminlang'); $tabitem=$clang->gT("Create New Label Set");}
else { $tabitem=$clang->gT("Edit label set");}
$langidsarray=explode(" ",trim($langids)); //Make an array of it
//$labelsoutput.= "\n\t</div>\n";

if (isset($row['lid'])) { $panecookie=$row['lid'];} else {$panecookie='new';}

$data['langids'] = $langids;
$data['langidsarray'] = $langidsarray;
$data['panecookie'] = $panecookie;
$data['tabitem'] = $tabitem;
/**$tab_title[0] = $tabitem;
$tab_content[0] = "<form method='post' class='form30' id='labelsetform' action='admin.php' onsubmit=\"return isEmpty(document.getElementById('label_name'), '".$clang->gT("Error: You have to enter a name for this label set.","js")."')\">\n";
$tab_content[0].= "<ul'>\n"
."<li><label for='languageids'>".$clang->gT("Set name:")."</label>\n"
."\t<input type='hidden' name='languageids' id='languageids' value='$langids' />"
."\t<input type='text' id='label_name' name='label_name' maxlength='100' size='50' value='";
if (isset($lbname)) {$tab_content[0].= $lbname;}
$tab_content[0].= "' />\n"
."</li>\n"
// Additional languages listbox
. "\t<li><label>".$clang->gT("Languages:")."</label>\n"
. "<table><tr><td align='left'><select multiple='multiple' style='min-width:220px;' size='5' id='additional_languages' name='additional_languages'>";
foreach ($langidsarray as $langid)
{
$tab_content[0].= "\t<option id='".$langid."' value='".$langid."'";
$tab_content[0].= ">".getLanguageNameFromCode($langid,false)."</option>\n";
}
// Add/Remove Buttons
$tab_content[0].= "</select></td>"
. "<td align='left'><input type=\"button\" value=\"<< ".$clang->gT("Add")."\" onclick=\"DoAdd()\" id=\"AddBtn\" /><br /> <input type=\"button\" value=\"".$clang->gT("Remove")." >>\" onclick=\"DoRemove(1,'".$clang->gT("You cannot remove this item since you need at least one language in a labelset.", "js")."')\" id=\"RemoveBtn\" /></td>\n"
// Available languages listbox
. "<td align='left'><select size='5' style='min-width:220px;' id='available_languages' name='available_languages'>";
foreach (getLanguageData() as $langkey=>$langname)
{
if (in_array($langkey,$langidsarray)==false) // base languag must not be shown here
{
$tab_content[0].= "\t<option id='".$langkey."' value='".$langkey."'";
$tab_content[0].= ">".$langname['description']."</option>\n";
}
}

$tab_content[0].= "\t</select></td>"
." </tr></table></li></ul>\n"
."<p><input type='submit' value='";
if ($action == "newlabelset") {$tab_content[0].= $clang->gT("Save");}
else {$tab_content[0].= $clang->gT("Update");}
$tab_content[0].= "' />\n"
."<input type='hidden' name='action' value='";
if ($action == "newlabelset") {$tab_content[0].= "insertlabelset";}
else {$tab_content[0].= "updateset";}
$tab_content[0].= "' />\n";
if ($action == "editlabelset") {
$tab_content[0].= "<input type='hidden' name='lid' value='$lblid' />\n";
}
$tab_content[0].= "</form>\n";
if ($action == "newlabelset"){
$tab_title[1] = $clang->gT("Import label set(s)");
$tab_content[1] = "<form enctype='multipart/form-data' id='importlabels' name='importlabels' action='admin.php' method='post'>\n"
."<div class='header ui-widget-header'>\n"
.$clang->gT("Import label set(s)")."\n"
."</div><ul>\n"
."<li><label for='the_file'>"
.$clang->gT("Select label set file (*.lsl,*.csv):")."</label>\n"
."<input id='the_file' name='the_file' type='file' size='35' />"
."</li>\n"
."<li><label for='checkforduplicates'>"
.$clang->gT("Don't import if label set already exists:")."</label>\n"
."<input name='checkforduplicates' id='checkforduplicates' type='checkbox' checked='checked' />\n"
."</li>"
."<li><label for='translinksfields'>"
.$clang->gT("Convert resources links?")."</label>\n"
."<input name='translinksfields' id='translinksfields' type='checkbox' checked='checked' />\n"
."</li></ul>\n"
."<p><input type='submit' value='".$clang->gT("Import label set(s)")."' />\n"
."<input type='hidden' name='action' value='importlabels' />\n"
."</form></div>\n";
}
$labelsoutput .= "<div id='tabs'><ul>";
foreach($tab_title as $i=>$eachtitle){
$labelsoutput .= "<li><a href='#neweditlblset$i'>$eachtitle</a></li>";
}
$labelsoutput .= "</ul>";
foreach($tab_content as $i=>$eachcontent){
$labelsoutput .= "<div id='neweditlblset$i'>$eachcontent</div>";
}
$labelsoutput .= "</div>";
*/
$this->load->view('admin/labels/editlabel_view',$data);

}
Expand Down Expand Up @@ -522,7 +434,6 @@ function view($lid=false)
$this->load->model('labelsets_model');
$condn = array('lid' => $lid);

//$query = "SELECT * FROM ".db_table_name('labelsets')." WHERE lid=$lid";
$result = $this->labelsets_model->getAllRecords($condn); //($query);)

if ($lid && $result->num_rows()>0)
Expand All @@ -538,40 +449,8 @@ function view($lid=false)
$data['row'] = $result->row_array();
$this->load->view("admin/labels/labelbar_view",$data);
}
/**
foreach ($result->result_array() as $row)
{
$labelsoutput.= "<div class='menubar'>\n"
."<div class='menubar-title ui-widget-header'>\n"
."\t<strong>".$clang->gT("Label Set").":</strong> {$row['label_name']}\n"
."</div>\n"
."<div class='menubar-main'>\n"
."\t<div class='menubar-left'>\n"
."\t<img src='$imageurl/blank.gif' width='40' height='20' border='0' hspace='0' align='left' alt='' />\n"
."\t<img src='$imageurl/seperator.gif' border='0' hspace='0' align='left' alt='' />\n"
."\t<a href='admin.php?action=editlabelset&amp;lid=$lid' title=\"".$clang->gTview("Edit label set")."\" >" .
"<img name='EditLabelsetButton' src='$imageurl/edit.png' alt='".$clang->gT("Edit label set")."' align='left' /></a>"
."\t<a href='#' title='".$clang->gTview("Delete label set")."' onclick=\"if (confirm('".$clang->gT("Do you really want to delete this label set?","js")."')) {".get2post("admin.php?action=deletelabelset&amp;lid=$lid")."}\" >"
."<img src='$imageurl/delete.png' border='0' alt='".$clang->gT("Delete label set")."' align='left' /></a>\n"
."\t<img src='$imageurl/seperator.gif' border='0' hspace='0' align='left' alt='' />\n"
."\t<a href='admin.php?action=dumplabel&amp;lid=$lid' title=\"".$clang->gTview("Export this label set")."\" >" .
"<img src='$imageurl/dumplabel.png' alt='".$clang->gT("Export this label set")."' align='left' /></a>"
."\t</div>\n"
."\t<div class='menubar-right'>\n"
."\t<input type='image' src='$imageurl/close.gif' title='".$clang->gT("Close Window")."'"
."onclick=\"window.open('admin.php?action=labels', '_top')\" />\n"
."\t</div>\n"
."\t</div>\n"
."\t</div>\n";
$labelsoutput .= "<p style='margin:0;font-size:1px;line-height:1px;height:1px;'>&nbsp;</p>"; //CSS Firefox 2 transition fix
}
*/

//LABEL ANSWERS - SHOW THE MASK FOR EDITING THE LABELS

//$js_admin_includes[]='scripts/updateset.js';

//$qulabelset = "SELECT * FROM ".db_table_name('labelsets')." WHERE lid=$lid";
$rslabelset = $this->labelsets_model->getAllRecords($condn); //db_execute_assoc($qulabelset) or safe_die($connect->ErrorMsg());
$rwlabelset=$rslabelset->row_array();
$lslanguages=explode(" ", trim($rwlabelset['languages']));
Expand Down
Loading

0 comments on commit 27b3df8

Please sign in to comment.