public function run() { /* * Instead of manually rendering scripts after this function returns we * use the callback. This ensures that scripts are always rendered, even * if we call exit at some point in the code. (Which we shouldn't, but * it happens.) */ // Ensure to set some var, but script are replaced in SurveyRuntimeHelper $aLSJavascriptVar = array(); $aLSJavascriptVar['bFixNumAuto'] = (int) (bool) Yii::app()->getConfig('bFixNumAuto', 1); $aLSJavascriptVar['bNumRealValue'] = (int) (bool) Yii::app()->getConfig('bNumRealValue', 0); $aLangData = getLanguageData(); $aRadix = getRadixPointData($aLangData[Yii::app()->getConfig('defaultlang')]['radixpoint']); $aLSJavascriptVar['sLEMradix'] = $aRadix['separator']; $sLSJavascriptVar = "LSvar=" . json_encode($aLSJavascriptVar) . ';'; App()->clientScript->registerScript('sLSJavascriptVar', $sLSJavascriptVar, CClientScript::POS_HEAD); App()->clientScript->registerScript('setJsVar', "setJsVar();", CClientScript::POS_BEGIN); // Ensure all js var is set before rendering the page (User can click before $.ready) App()->getClientScript()->registerPackage('jqueryui'); App()->getClientScript()->registerPackage('jquery-touch-punch'); App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts') . "survey_runtime.js"); useFirebug(); ob_start(function ($buffer, $phase) { App()->getClientScript()->render($buffer); App()->getClientScript()->reset(); return $buffer; }); ob_implicit_flush(false); $this->action(); ob_flush(); }
/** * Returns the locale settings for a certain language code * * @param string $codetosearch * @return array Array with locale details * */ function getLanguageDetails($codetosearch) { $detaillanguages = getLanguageData(); if (isset($detaillanguages[$codetosearch])) { return $detaillanguages[$codetosearch]; } else { return $detaillanguages['en']; } }
/** * Converts a locale ID to its canonical form. * In canonical form, a locale ID consists of only underscores and lower-case letters. * @param string $id the locale ID to be converted * @return string the locale ID in canonical form */ public static function getInstance($id) { // Fix up the LimeSurvey language code for Yii $aLanguageData = getLanguageData(); if (isset($aLanguageData[$id]['cldr'])) { $id = $aLanguageData[$id]['cldr']; } static $locales = array(); if (isset($locales[$id])) { return $locales[$id]; } else { return $locales[$id] = new CLocale($id); } }
public function run() { /* * Instead of manually rendering scripts after this function returns we * use the callback. This ensures that scripts are always rendered, even * if we call exit at some point in the code. (Which we shouldn't, but * it happens.) */ // Ensure to set some var, but script are replaced in SurveyRuntimeHelper $aLSJavascriptVar = array(); $aLSJavascriptVar['bFixNumAuto'] = (int) (bool) Yii::app()->getConfig('bFixNumAuto', 1); $aLSJavascriptVar['bNumRealValue'] = (int) (bool) Yii::app()->getConfig('bNumRealValue', 0); $aLangData = getLanguageData(); $aRadix = getRadixPointData($aLangData[Yii::app()->getConfig('defaultlang')]['radixpoint']); $aLSJavascriptVar['sLEMradix'] = $aRadix['separator']; $sLSJavascriptVar = "LSvar=" . json_encode($aLSJavascriptVar) . ';'; // Template configuration $param = $this->_getParameters(func_get_args(), $_POST); $surveyid = $param['sid']; // Font awesome if (!YII_DEBUG) { App()->getClientScript()->registerCssFile(App()->getAssetManager()->publish(dirname(Yii::app()->request->scriptFile) . '/styles-public/font-awesome-43.min.css')); } else { App()->getClientScript()->registerCssFile(Yii::app()->getBaseUrl(true) . '/styles-public/font-awesome-43-debugmode.min.css'); } global $oTemplate; $oTemplate = Template::model()->getTemplateConfiguration('', $surveyid); $this->oTemplate = $oTemplate; App()->clientScript->registerScript('sLSJavascriptVar', $sLSJavascriptVar, CClientScript::POS_HEAD); App()->clientScript->registerScript('setJsVar', "setJsVar();", CClientScript::POS_BEGIN); // Ensure all js var is set before rendering the page (User can click before $.ready) foreach ($oTemplate->packages as $package) { App()->getClientScript()->registerPackage($package); } App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts') . "survey_runtime.js"); if ($oTemplate->cssFramework == 'bootstrap') { App()->bootstrap->register(); } useFirebug(); ob_start(function ($buffer, $phase) { App()->getClientScript()->render($buffer); App()->getClientScript()->reset(); return $buffer; }); ob_implicit_flush(false); $this->action(); ob_flush(); }
public function run() { /* * Instead of manually rendering scripts after this function returns we * use the callback. This ensures that scripts are always rendered, even * if we call exit at some point in the code. (Which we shouldn't, but * it happens.) */ // Ensure to set some var, but script are replaced in SurveyRuntimeHelper $aLSJavascriptVar = array(); $aLSJavascriptVar['bFixNumAuto'] = (int) (bool) Yii::app()->getConfig('bFixNumAuto', 1); $aLSJavascriptVar['bNumRealValue'] = (int) (bool) Yii::app()->getConfig('bNumRealValue', 0); $aLangData = getLanguageData(); $aRadix = getRadixPointData($aLangData[Yii::app()->getConfig('defaultlang')]['radixpoint']); $aLSJavascriptVar['sLEMradix'] = $aRadix['separator']; $sLSJavascriptVar = "LSvar=" . json_encode($aLSJavascriptVar) . ';'; // Template configuration $param = $this->_getParameters(func_get_args(), $_POST); $surveyid = $param['sid']; $oTemplate = Template::model()->getInstance('', $surveyid); $this->oTemplate = $oTemplate; App()->clientScript->registerScript('sLSJavascriptVar', $sLSJavascriptVar, CClientScript::POS_HEAD); App()->clientScript->registerScript('setJsVar', "setJsVar();", CClientScript::POS_BEGIN); // Ensure all js var is set before rendering the page (User can click before $.ready) foreach ($oTemplate->packages as $package) { App()->getClientScript()->registerPackage((string) $package); } App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts') . "survey_runtime.js"); if ($oTemplate->cssFramework == 'bootstrap') { // We now use the bootstrap package isntead of the Yiistrap TbApi::register() method // Then instead of using the composer dependency system for templates // We can use the package dependency system Yii::app()->getClientScript()->registerMetaTag('width=device-width, initial-scale=1.0', 'viewport'); App()->bootstrap->registerAllScripts(); } useFirebug(); ob_start(function ($buffer, $phase) { App()->getClientScript()->render($buffer); App()->getClientScript()->reset(); return $buffer; }); ob_implicit_flush(false); $this->action(); ob_flush(); }
/** * This function creates the language selector for a particular survey * * @param mixed $sSelectedLanguage The language in which all information is shown */ function makeLanguageChangerSurvey($sSelectedLanguage) { $surveyid = Yii::app()->getConfig('surveyID'); Yii::app()->loadHelper("surveytranslator"); $slangs = Survey::model()->findByPk($surveyid)->getAdditionalLanguages(); $slangs[] = GetBaseLanguageFromSurveyID($surveyid); $aAllLanguages = getLanguageData(); $slangs = array_keys(array_intersect_key($aAllLanguages, array_flip($slangs))); // Sort languages by their locale name if (count($slangs) > 1) { $route = "/survey/index/sid/{$surveyid}"; if (Yii::app()->request->getParam('action', 'none') == 'previewgroup' && intval(Yii::app()->request->getParam('gid', 0))) { $route .= "/action/previewgroup/gid/" . intval(Yii::app()->request->getParam('gid', 0)); } if (Yii::app()->request->getParam('token') != '') { $route .= "/token/" . Yii::app()->request->getParam('token'); } $sHTMLCode = "<select id='languagechanger' name='languagechanger' class='languagechanger' onchange='javascript:window.location=this.value'>\n"; foreach ($slangs as $sLanguage) { $sTargetURL = Yii::app()->getController()->createUrl($route . "/lang/{$sLanguage}"); $sHTMLCode .= "<option value=\"{$sTargetURL}\" "; if ($sLanguage == $sSelectedLanguage) { $sHTMLCode .= " selected='selected'"; } $sHTMLCode .= ">" . $aAllLanguages[$sLanguage]['nativedescription'] . "</option>\n"; } $sHTMLCode .= "</select>\n"; return $sHTMLCode; } else { return false; } }
/** * This function creates the language selector for a particular survey * * @param mixed $sSelectedLanguage The language in which all information is shown */ function makeLanguageChangerSurvey($sSelectedLanguage) { $surveyid = Yii::app()->getConfig('surveyID'); $clang = Yii::app()->lang; Yii::app()->loadHelper("surveytranslator"); $aSurveyLangs = Survey::model()->findByPk($surveyid)->getAllLanguages(); if (count($aSurveyLangs) > 1) { $aAllLanguages = getLanguageData(true); $aSurveyLangs = array_intersect_key($aAllLanguages, array_flip($aSurveyLangs)); // Sort languages by their locale name $sClass = "languagechanger"; $sHTMLCode = ""; $sAction = Yii::app()->request->getParam('action', ''); // Different behaviour if preview $sSelected = ""; if (substr($sAction, 0, 7) == 'preview') { $route = "/survey/index/sid/{$surveyid}"; if ($sAction == 'previewgroup' && intval(Yii::app()->request->getParam('gid', 0))) { $route .= "/action/previewgroup/gid/" . intval(Yii::app()->request->getParam('gid', 0)); } if ($sAction == 'previewquestion' && intval(Yii::app()->request->getParam('gid', 0)) && intval(Yii::app()->request->getParam('qid', 0))) { $route .= "/action/previewquestion/gid/" . intval(Yii::app()->request->getParam('gid', 0)) . "/qid/" . intval(Yii::app()->request->getParam('qid', 0)); } if (!is_null(Yii::app()->request->getParam('token'))) { $route .= "/token/" . Yii::app()->request->getParam('token'); } $sClass .= " previewmode"; // Maybe add other param (for prefilling by URL): then need a real createUrl with array # foreach ($aSurveyLangs as $sLangCode => $aSurveyLang) # { # $sTargetURL=Yii::app()->getController()->createUrl($route."/lang/$sLangCode"); # $aListLang[$sTargetURL]=html_entity_decode($aSurveyLang['nativedescription'], ENT_COMPAT,'UTF-8'); # if($clang->langcode==$sLangCode) # $sSelected=$sTargetURL; # } } else { $route = "/survey/index/sid/{$surveyid}"; } $sTargetURL = Yii::app()->getController()->createUrl($route); foreach ($aSurveyLangs as $sLangCode => $aSurveyLang) { $aListLang[$sLangCode] = html_entity_decode($aSurveyLang['nativedescription'], ENT_COMPAT, 'UTF-8'); } $sSelected = $clang->langcode; $sHTMLCode = CHtml::label($clang->gT("Choose another language"), 'lang', array('class' => 'hide label')); $sHTMLCode .= CHtml::dropDownList('lang', $sSelected, $aListLang, array('class' => $sClass, 'data-targeturl' => $sTargetURL)); // We don't have to add this button if in previewmode $sHTMLCode .= CHtml::htmlButton($clang->gT("Change the language"), array('type' => 'submit', 'id' => "changelangbtn", 'value' => 'changelang', 'name' => 'changelang', 'class' => 'changelang jshide')); return $sHTMLCode; } else { return false; } }
?> "; var attname = "<?php $clang->eT("Attribute name:"); ?> "; removeitem = new Array(); // Array to hold values that are to be removed from langauges option </script> <div class='header ui-widget-header'><strong><?php $clang->eT("Attribute settings"); ?> </strong></div><br/> <?php $options = array(); $options[''] = $clang->gT('Select...'); foreach (getLanguageData(false, Yii::app()->session['adminlang']) as $langkey2 => $langname) { $options[$langkey2] = $langname['description']; } echo CHtml::beginForm(Yii::app()->getController()->createUrl('admin/participants/sa/saveAttribute/aid/' . Yii::app()->request->getQuery('aid')) . '/', "post"); ?> <div class='commonsettings'> <br/> <table width='400px'> <tr> <th colspan='2'> <label for='atttype' id='atttype'> <?php $clang->eT('Attribute type:'); ?> </label> </th>
/** * This function creates the language selector for a particular survey * * @param mixed $sSelectedLanguage The language in which all information is shown */ function makeLanguageChangerSurvey($sSelectedLanguage) { $surveyid = Yii::app()->getConfig('surveyID'); Yii::app()->loadHelper("surveytranslator"); $aSurveyLangs = Survey::model()->findByPk($surveyid)->getAllLanguages(); if (count($aSurveyLangs) > 1) { $aAllLanguages = getLanguageData(true); $aSurveyLangs = array_intersect_key($aAllLanguages, array_flip($aSurveyLangs)); // Sort languages by their locale name $sClass = "languagechanger"; $sHTMLCode = ""; $sAction = Yii::app()->request->getParam('action', ''); // Different behaviour if preview $sSelected = ""; if (substr($sAction, 0, 7) == 'preview') { $route = "/survey/index/sid/{$surveyid}"; if ($sAction == 'previewgroup' && intval(Yii::app()->request->getParam('gid', 0))) { $route .= "/action/previewgroup/gid/" . intval(Yii::app()->request->getParam('gid', 0)); } if ($sAction == 'previewquestion' && intval(Yii::app()->request->getParam('gid', 0)) && intval(Yii::app()->request->getParam('qid', 0))) { $route .= "/action/previewquestion/gid/" . intval(Yii::app()->request->getParam('gid', 0)) . "/qid/" . intval(Yii::app()->request->getParam('qid', 0)); } if (!is_null(Yii::app()->request->getParam('token'))) { $route .= "/token/" . Yii::app()->request->getParam('token'); } $sClass .= " previewmode"; // Maybe add other param (for prefilling by URL): then need a real createUrl with array # foreach ($aSurveyLangs as $sLangCode => $aSurveyLang) # { # $sTargetURL=Yii::app()->getController()->createUrl($route."/lang/$sLangCode"); # $aListLang[$sTargetURL]=html_entity_decode($aSurveyLang['nativedescription'], ENT_COMPAT,'UTF-8'); # if(App()->language==$sLangCode) # $sSelected=$sTargetURL; # } } else { $route = "/survey/index/sid/{$surveyid}"; } $sTargetURL = Yii::app()->getController()->createUrl($route); foreach ($aSurveyLangs as $sLangCode => $aSurveyLang) { $aListLang[$sLangCode] = html_entity_decode($aSurveyLang['nativedescription'], ENT_COMPAT, 'UTF-8'); } $sSelected = App()->language; $sClass .= ' form-control '; $languageChangerDatas = array('sSelected' => $sSelected, 'aListLang' => $aListLang, 'sClass' => $sClass, 'sTargetURL' => $sTargetURL); $sHTMLCode = Yii::app()->getController()->renderPartial('/survey/system/LanguageChanger/LanguageChanger', $languageChangerDatas, true); return $sHTMLCode; } else { return false; } }
if (Yii::app()->getConfig("userideditable") == 'Y') { $uid = '{ "name":"owner_uid", "index":"owner_uid", "width":150, "sorttype":"int", "sortable": true, "align":"center", "editable":true, "edittype":"select", "editoptions":{ "value":"'; $i = 0; foreach ($names as $row) { $name[$i] = $row->uid . ":" . $row->full_name; $i++; } $unames = implode(";", $name) . '"}}'; $uidNames[] = $uid . $unames; } else { $uidNames[] = '{ "name":"owner_uid", "index":"owner_uid", "width":150, "sorttype":"int", "sortable": true, "align":"center", "editable":false}'; } /* Build the options for additional languages */ $j = 1; $lang = '{ "name":"language", "index":"language", "sorttype":"string", "sortable": true, "align":"center", "editable":true, "formatter":"select", "edittype":"select", "editoptions":{ "value":"'; $getlangvalues = getLanguageData(false, Yii::app()->session['adminlang']); if (Yii::app()->session['adminlang'] != 'auto') { $lname[0] = Yii::app()->session['adminlang'] . ":" . $getlangvalues[Yii::app()->session['adminlang']]['description']; } foreach ($getlangvalues as $keycode => $keydesc) { if (Yii::app()->session['adminlang'] != $keycode) { $cleanlangdesc = str_replace(";", " -", $keydesc['description']); $lname[$j] = $keycode . ":" . $cleanlangdesc; $j++; } } $langnames = implode(";", $lname) . '"}}'; $langNames[] = $lang . $langnames; /* Build the columnNames for the extra attributes */ /* and, build the columnModel */ $autowidth = 'true';
function writeSortedCsvFiles($directory, $csvData) { foreach ($csvData as $file => $data) { ksort($data); $csvData = array_combine(array_keys($data), array_values($data)); $fh = fopen($directory . '/' . $file, 'w'); if (!$fh) { printf("Can't open file '%s' for writing, aborting\n", $directory . '/' . $file); exit; } // Sadly, we can't use fputcsv because it doesn't always enclose rows foreach ($csvData as $string => $translation) { $csvString = '"' . str_replace('"', '""', $string) . '","' . str_replace('"', '""', $translation) . '"' . "\n"; fputs($fh, $csvString); } fclose($fh); } } if (!is_dir($_SERVER['argv'][1])) { printf("Source directory '%s' doesn't exist\n", $_SERVER['argv'][1]); exit; } if (!is_dir($_SERVER['argv'][2])) { printf("Target directory '%s' doesn't exist\n", $_SERVER['argv'][2]); exit; } $sourceLanguageData = getLanguageData($_SERVER['argv'][1]); $targetLanguageData = getLanguageData($_SERVER['argv'][2]); $mergedLanguageData = mergeLanguageData($sourceLanguageData, $targetLanguageData); writeSortedCsvFiles($_SERVER['argv'][2], $mergedLanguageData); echo "Done!\n";
// Fix bug with FCKEditor saving strange BR types $_POST['short_title_' . $langname] = fix_FCKeditor_text($_POST['short_title_' . $langname]); $_POST['description_' . $langname] = fix_FCKeditor_text($_POST['description_' . $langname]); $_POST['welcome_' . $langname] = fix_FCKeditor_text($_POST['welcome_' . $langname]); $_POST['endtext_' . $langname] = fix_FCKeditor_text($_POST['endtext_' . $langname]); $usquery = "UPDATE " . db_table_name('surveys_languagesettings') . " \n" . "SET surveyls_title='" . db_quote($_POST['short_title_' . $langname]) . "', surveyls_description='" . db_quote($_POST['description_' . $langname]) . "',\n" . "surveyls_welcometext='" . db_quote($_POST['welcome_' . $langname]) . "',\n" . "surveyls_endtext='" . db_quote($_POST['endtext_' . $langname]) . "',\n" . "surveyls_url='" . db_quote($_POST['url_' . $langname]) . "',\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 . "'"; $usresult = $connect->Execute($usquery) or safe_die("Error updating<br />" . $usquery . "<br /><br /><strong>" . $connect->ErrorMsg()); // Checked } } $_SESSION['flashmessage'] = $clang->gT("Survey text elements successfully saved."); } } elseif ($action == "insertsurvey" && $_SESSION['USER_RIGHT_CREATE_SURVEY']) { $dateformatdetails = getDateFormatData($_SESSION['dateformat']); // $_POST['language'] $supportedLanguages = getLanguageData(); $numberformatid = $supportedLanguages[$_POST['language']]['radixpoint']; if ($_POST['url'] == 'http://') { $_POST['url'] = ""; } if (!$_POST['surveyls_title']) { $databaseoutput .= "<script type=\"text/javascript\">\n<!--\n alert(\"" . $clang->gT("Survey could not be created because it did not have a title", "js") . "\")\n //-->\n</script>\n"; } else { // Get random ids until one is found that is not used do { $surveyid = sRandomChars(5, '123456789'); $isquery = "SELECT sid FROM " . db_table_name('surveys') . " WHERE sid={$surveyid}"; $isresult = db_execute_assoc($isquery); // Checked } while ($isresult->RecordCount() > 0); if (!isset($_POST['template'])) {
private function _getLanguageList($iSurveyID, $tolang) { $language_list = ""; $langs = Survey::model()->findByPk($iSurveyID)->additionalLanguages; $supportedLanguages = getLanguageData(FALSE, Yii::app()->session['adminlang']); $language_list .= CHtml::openTag('div', array('class' => 'menubar-right')); // Opens .menubar-right div $language_list .= CHtml::openTag('div', array('class' => 'row')); $language_list .= CHtml::openTag('div', array('class' => 'col-sm-12')); $language_list .= CHtml::tag('label', array('for' => 'translationlanguage', 'class' => 'col-sm-1 control-label'), gT("Translate to") . ":"); $language_list .= CHtml::openTag('div', array('class' => 'col-sm-2')); $language_list .= CHtml::openTag('select', array('id' => 'translationlanguage', 'name' => 'translationlanguage', 'class' => 'form-control', 'onchange' => "window.open(this.options[this.selectedIndex].value,'_top')")); $language_list .= CHtml::closeTag('div'); $language_list .= CHtml::closeTag('div'); $language_list .= CHtml::closeTag('div'); $language_list .= CHtml::closeTag('div'); $language_list .= ''; if (count(Survey::model()->findByPk($iSurveyID)->additionalLanguages) > 1) { $selected = !isset($tolang) ? "selected" : ""; $language_list .= CHtml::tag('option', array('selected' => $selected, 'value' => $this->getController()->createUrl("admin/translate/sa/index/surveyid/{$iSurveyID}/")), gT("Please choose...")); } foreach ($langs as $lang) { $selected = $tolang == $lang ? "selected" : ""; $tolangtext = $supportedLanguages[$lang]['description']; $language_list .= CHtml::tag('option', array('selected' => $selected, 'value' => $this->getController()->createUrl("admin/translate/sa/index/surveyid/{$iSurveyID}/lang/{$lang}")), $tolangtext); } $language_list .= CHtml::closeTag('select'); $language_list .= CHtml::closeTag('div'); // End of menubar-right return $language_list; }
$data['templatedir'] = getTemplatePath(Yii::app()->getConfig("defaulttemplate")); $data['templateurl'] = getTemplateURL(Yii::app()->getConfig("defaulttemplate")) . "/"; $data['templatename'] = Yii::app()->getConfig("defaulttemplate"); $data['sitename'] = Yii::app()->getConfig("sitename"); $data['languagechanger'] = makeLanguageChanger(App()->lang->langcode); //A nice exit sendCacheHeaders(); doHeader(); // Javascript Var $aLSJavascriptVar = array(); $aLSJavascriptVar['bFixNumAuto'] = (int) (bool) Yii::app()->getConfig('bFixNumAuto', 1); $aLSJavascriptVar['bNumRealValue'] = (int) (bool) Yii::app()->getConfig('bNumRealValue', 0); if (isset($thissurvey['surveyls_numberformat'])) { $radix = getRadixPointData($thissurvey['surveyls_numberformat']); } else { $aLangData = getLanguageData(); $radix = getRadixPointData($aLangData[Yii::app()->getConfig('defaultlang')]['radixpoint']); // or $clang->langcode . defaultlang ensure it's same for each language ? } $aLSJavascriptVar['sLEMradix'] = $radix['separator']; $sLSJavascriptVar = "LSvar=" . json_encode($aLSJavascriptVar); App()->clientScript->registerScript('sLSJavascriptVar', $sLSJavascriptVar, CClientScript::POS_HEAD); App()->clientScript->registerScript('setJsVar', "setJsVar();", CClientScript::POS_BEGIN); // Ensure all js var is set before rendering the page (User can click before $.ready) App()->getClientScript()->registerPackage('jqueryui'); App()->getClientScript()->registerPackage('jquery-touch-punch'); App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts') . "survey_runtime.js"); useFirebug(); echo templatereplace(file_get_contents(getTemplatePath(Yii::app()->getConfig("defaulttemplate")) . "/startpage.pstpl"), array(), $data, 'survey[' . __LINE__ . ']'); echo templatereplace(file_get_contents(getTemplatePath(Yii::app()->getConfig("defaulttemplate")) . "/surveylist.pstpl"), array(), $data, 'survey[' . __LINE__ . ']'); echo templatereplace(file_get_contents(getTemplatePath(Yii::app()->getConfig("defaulttemplate")) . "/endpage.pstpl"), array(), $data, 'survey[' . __LINE__ . ']');
private function _saveSettings() { if ($_POST['action'] !== "globalsettingssave") { return; } if (!Permission::model()->hasGlobalPermission('settings', 'update')) { $this->getController()->redirect(array('/admin')); } Yii::app()->loadHelper('surveytranslator'); $iPDFFontSize = sanitize_int($_POST['pdffontsize']); if ($iPDFFontSize < 1) { $iPDFFontSize = 9; } $iPDFLogoWidth = sanitize_int($_POST['pdflogowidth']); if ($iPDFLogoWidth < 1) { $iPDFLogoWidth = 50; } $maxemails = $_POST['maxemails']; if (sanitize_int($_POST['maxemails']) < 1) { $maxemails = 1; } $defaultlang = sanitize_languagecode($_POST['defaultlang']); $aRestrictToLanguages = explode(' ', sanitize_languagecodeS($_POST['restrictToLanguages'])); if (!in_array($defaultlang, $aRestrictToLanguages)) { // Force default language in restrictToLanguages $aRestrictToLanguages[] = $defaultlang; } if (count(array_diff(array_keys(getLanguageData(false, Yii::app()->session['adminlang'])), $aRestrictToLanguages)) == 0) { $aRestrictToLanguages = ''; } else { $aRestrictToLanguages = implode(' ', $aRestrictToLanguages); } setGlobalSetting('defaultlang', $defaultlang); setGlobalSetting('restrictToLanguages', trim($aRestrictToLanguages)); setGlobalSetting('sitename', strip_tags($_POST['sitename'])); setGlobalSetting('defaulthtmleditormode', sanitize_paranoid_string($_POST['defaulthtmleditormode'])); setGlobalSetting('defaultquestionselectormode', sanitize_paranoid_string($_POST['defaultquestionselectormode'])); setGlobalSetting('defaulttemplateeditormode', sanitize_paranoid_string($_POST['defaulttemplateeditormode'])); if (!Yii::app()->getConfig('demoMode')) { $sTemplate = Yii::app()->getRequest()->getPost("defaulttemplate"); if (array_key_exists($sTemplate, getTemplateList())) { setGlobalSetting('defaulttemplate', $sTemplate); } } setGlobalSetting('admintheme', sanitize_paranoid_string($_POST['admintheme'])); setGlobalSetting('adminthemeiconsize', trim(file_get_contents(Yii::app()->getConfig("styledir") . DIRECTORY_SEPARATOR . sanitize_paranoid_string($_POST['admintheme']) . DIRECTORY_SEPARATOR . 'iconsize'))); setGlobalSetting('emailmethod', strip_tags($_POST['emailmethod'])); setGlobalSetting('emailsmtphost', strip_tags(returnGlobal('emailsmtphost'))); if (returnGlobal('emailsmtppassword') != 'somepassword') { setGlobalSetting('emailsmtppassword', strip_tags(returnGlobal('emailsmtppassword'))); } setGlobalSetting('bounceaccounthost', strip_tags(returnGlobal('bounceaccounthost'))); setGlobalSetting('bounceaccounttype', strip_tags(returnGlobal('bounceaccounttype'))); setGlobalSetting('bounceencryption', strip_tags(returnGlobal('bounceencryption'))); setGlobalSetting('bounceaccountuser', strip_tags(returnGlobal('bounceaccountuser'))); if (returnGlobal('bounceaccountpass') != 'enteredpassword') { setGlobalSetting('bounceaccountpass', strip_tags(returnGlobal('bounceaccountpass'))); } setGlobalSetting('emailsmtpssl', sanitize_paranoid_string(Yii::app()->request->getPost('emailsmtpssl', ''))); setGlobalSetting('emailsmtpdebug', sanitize_int(Yii::app()->request->getPost('emailsmtpdebug', '0'))); setGlobalSetting('emailsmtpuser', strip_tags(returnGlobal('emailsmtpuser'))); setGlobalSetting('filterxsshtml', strip_tags($_POST['filterxsshtml'])); $warning = ''; // make sure emails are valid before saving them if (Yii::app()->request->getPost('siteadminbounce', '') == '' || validateEmailAddress(Yii::app()->request->getPost('siteadminbounce'))) { setGlobalSetting('siteadminbounce', strip_tags(Yii::app()->request->getPost('siteadminbounce'))); } else { $warning .= gT("Warning! Admin bounce email was not saved because it was not valid.") . '<br/>'; } if (Yii::app()->request->getPost('siteadminemail', '') == '' || validateEmailAddress(Yii::app()->request->getPost('siteadminemail'))) { setGlobalSetting('siteadminemail', strip_tags(Yii::app()->request->getPost('siteadminemail'))); } else { $warning .= gT("Warning! Admin email was not saved because it was not valid.") . '<br/>'; } setGlobalSetting('siteadminname', strip_tags($_POST['siteadminname'])); setGlobalSetting('shownoanswer', sanitize_int($_POST['shownoanswer'])); setGlobalSetting('showxquestions', $_POST['showxquestions']); setGlobalSetting('showgroupinfo', $_POST['showgroupinfo']); setGlobalSetting('showqnumcode', $_POST['showqnumcode']); $repeatheadingstemp = (int) $_POST['repeatheadings']; if ($repeatheadingstemp == 0) { $repeatheadingstemp = 25; } setGlobalSetting('repeatheadings', $repeatheadingstemp); setGlobalSetting('maxemails', sanitize_int($maxemails)); $iSessionExpirationTime = (int) $_POST['iSessionExpirationTime']; if ($iSessionExpirationTime == 0) { $iSessionExpirationTime = 7200; } setGlobalSetting('iSessionExpirationTime', $iSessionExpirationTime); setGlobalSetting('ipInfoDbAPIKey', $_POST['ipInfoDbAPIKey']); setGlobalSetting('pdffontsize', $iPDFFontSize); setGlobalSetting('pdfshowheader', $_POST['pdfshowheader']); setGlobalSetting('pdflogowidth', $iPDFLogoWidth); setGlobalSetting('pdfheadertitle', $_POST['pdfheadertitle']); setGlobalSetting('pdfheaderstring', $_POST['pdfheaderstring']); setGlobalSetting('googleMapsAPIKey', $_POST['googleMapsAPIKey']); setGlobalSetting('googleanalyticsapikey', $_POST['googleanalyticsapikey']); setGlobalSetting('googletranslateapikey', $_POST['googletranslateapikey']); setGlobalSetting('force_ssl', $_POST['force_ssl']); setGlobalSetting('surveyPreview_require_Auth', $_POST['surveyPreview_require_Auth']); setGlobalSetting('RPCInterface', $_POST['RPCInterface']); setGlobalSetting('rpc_publish_api', (bool) $_POST['rpc_publish_api']); $savetime = (double) $_POST['timeadjust'] * 60 . ' minutes'; //makes sure it is a number, at least 0 if (substr($savetime, 0, 1) != '-' && substr($savetime, 0, 1) != '+') { $savetime = '+' . $savetime; } setGlobalSetting('timeadjust', $savetime); setGlobalSetting('usercontrolSameGroupPolicy', strip_tags($_POST['usercontrolSameGroupPolicy'])); Yii::app()->session['flashmessage'] = $warning . gT("Global settings were saved."); $url = htmlspecialchars_decode(Yii::app()->session['refurl']); if ($url) { Yii::app()->getController()->redirect($url); } }
/** * showTranslateAdminmenu() creates the main menu options for the survey translation page * @param string $surveyid The survey ID * @param string $survey_title * @param string $tolang * @param string $activated * @param string $scriptname * @global string $imageurl, $clang, $publicurl * @return string */ function showTranslateAdminmenu($surveyid, $survey_title, $tolang, $scriptname) { global $imageurl, $clang, $publicurl; $baselang = GetBaseLanguageFromSurveyID($surveyid); $supportedLanguages = getLanguageData(false); $langs = GetAdditionalLanguagesFromSurveyID($surveyid); $adminmenu = "" . "<div class='menubar'>\n" . "<div class='menubar-title ui-widget-header'>\n" . "<strong>" . $clang->gT("Translate survey") . ": {$survey_title}</strong>\n" . "</div>\n" . "<div class='menubar-main'>\n"; $adminmenu .= "" . "<div class='menubar-left'>\n"; // Return to survey administration button $adminmenu .= menuItem($clang->gT("Return to survey administration"), $clang->gTview("Return to survey administration"), "Administration", "home.png", "{$scriptname}?sid={$surveyid}"); // Separator $adminmenu .= menuSeparator(); // Test / execute survey button if ($tolang != "") { $sumquery1 = "SELECT * FROM " . db_table_name('surveys') . " inner join " . db_table_name('surveys_languagesettings') . " on (surveyls_survey_id=sid and surveyls_language=language) WHERE sid={$surveyid}"; //Getting data for this survey $sumresult1 = db_select_limit_assoc($sumquery1, 1); //Checked $surveyinfo = $sumresult1->FetchRow(); $surveyinfo = array_map('FlattenText', $surveyinfo); $activated = $surveyinfo['active']; if ($activated == "N") { $menutext = $clang->gT("Test This Survey"); $menutext2 = $clang->gTview("Test This Survey"); } else { $menutext = $clang->gT("Execute This Survey"); $menutext2 = $clang->gTview("Execute This Survey"); } if (count(GetAdditionalLanguagesFromSurveyID($surveyid)) == 0) { $adminmenu .= menuItem($menutext, $menutext2, "do.png", "{$publicurl}/index.php?sid={$surveyid}&newtest=Y&lang={$baselang}"); } else { $icontext = $clang->gT($menutext); $icontext2 = $clang->gT($menutext); $adminmenu .= "<a href='#' id='dosurvey' class='dosurvey'" . "title=\"" . $icontext2 . "\" accesskey='d'>" . "<img src='{$imageurl}/do.png' alt='{$icontext}' />" . "</a>\n"; $tmp_survlangs = GetAdditionalLanguagesFromSurveyID($surveyid); $tmp_survlangs[] = $baselang; rsort($tmp_survlangs); // Test Survey Language Selection Popup $adminmenu .= "<div class=\"langpopup\" id=\"dosurveylangpopup\">" . $clang->gT("Please select a language:") . "<ul>"; foreach ($tmp_survlangs as $tmp_lang) { $adminmenu .= "<li><a accesskey='d' onclick=\"\$('.dosurvey').qtip('hide');" . "\" target='_blank' href='{$publicurl}/index.php?sid={$surveyid}&" . "newtest=Y&lang={$tmp_lang}'>" . getLanguageNameFromCode($tmp_lang, false) . "</a></li>"; } $adminmenu .= "</ul></div>"; } } // End of survey-bar-left $adminmenu .= "</div>"; // Survey language list $selected = ""; if (!isset($tolang)) { $selected = " selected='selected' "; } $adminmenu .= "" . "<div class='menubar-right'>\n" . "<span class=\"boxcaption\">" . $clang->gT("Translate to") . ":</span>" . "<select onchange=\"window.open(this.options[this.selectedIndex].value,'_top')\">\n"; if (count(GetAdditionalLanguagesFromSurveyID($surveyid)) > 1) { $adminmenu .= "<option {$selected} value='{$scriptname}?action=translate&sid={$surveyid}'>" . $clang->gT("Please choose...") . "</option>\n"; } foreach ($langs as $lang) { $selected = ""; if ($tolang == $lang) { $selected = " selected='selected' "; } $tolangtext = $supportedLanguages[$lang]['description']; $adminmenu .= "<option {$selected} value='{$scriptname}?action=translate&sid={$surveyid}&tolang={$lang}'> " . $tolangtext . " </option>\n"; } $adminmenu .= "" . "</select>\n" . "</div>\n"; // End of menubar-right $adminmenu .= "" . "</div>\n"; $adminmenu .= "" . "</div>\n"; return $adminmenu; }
/** * welcome and language selection install step */ private function stepWelcome() { if (!is_null(Yii::app()->request->getPost('installerLang'))) { Yii::app()->session['installerLang'] = Yii::app()->request->getPost('installerLang'); $this->redirect(array('installer/license')); } $this->loadHelper('surveytranslator'); Yii::app()->session->remove('configFileWritten'); $aData['title'] = gT('Welcome'); $aData['descp'] = gT('Welcome to the LimeSurvey installation wizard. This wizard will guide you through the installation, database setup and initial configuration of LimeSurvey.'); $aData['classesForStep'] = array('on', 'off', 'off', 'off', 'off', 'off'); $aData['progressValue'] = 10; if (isset(Yii::app()->session['installerLang'])) { $sCurrentLanguage = Yii::app()->session['installerLang']; } else { $sCurrentLanguage = 'en'; } foreach (getLanguageData(true, $sCurrentLanguage) as $sKey => $aLanguageInfo) { $aLanguages[htmlspecialchars($sKey)] = sprintf('%s - %s', $aLanguageInfo['nativedescription'], $aLanguageInfo['description']); } $aData['languages'] = $aLanguages; $this->render('/installer/welcome_view', $aData); }
<?php ?> <legend><?php eT("You can leave these settings blank and change them later"); ?> </legend> <?php $rows = array(); $rows[] = array('label' => CHtml::activeLabelEx($model, 'adminLoginName', array('class' => 'control-label', 'label' => gT("Admin login name"), 'autofocus' => 'autofocus')), 'description' => gT("This will be the userid by which admin of board will login."), 'control' => CHtml::activeTextField($model, 'adminLoginName')); $rows[] = array('label' => CHtml::activeLabelEx($model, 'adminLoginPwd', array('class' => 'control-label', 'label' => gT("Admin login password"))), 'description' => gT("This will be the password of admin user."), 'control' => CHtml::activePasswordField($model, 'adminLoginPwd')); $rows[] = array('label' => CHtml::activeLabelEx($model, 'confirmPwd', array('class' => 'control-label', 'label' => gT("Confirm your admin password"))), 'control' => CHtml::activePasswordField($model, 'confirmPwd')); $rows[] = array('label' => CHtml::activeLabelEx($model, 'adminName', array('class' => 'control-label', 'label' => gT("Administrator name"))), 'description' => gT("This is the default name of the site administrator and used for system messages and contact options."), 'control' => CHtml::activeTextField($model, 'adminName')); $rows[] = array('label' => CHtml::activeLabelEx($model, 'adminEmail', array('class' => 'control-label', 'label' => gT("Administrator email"))), 'description' => gT("This is the default email address of the site administrator and used for system messages, contact options and default bounce email."), 'control' => CHtml::activeTextField($model, 'adminEmail')); $rows[] = array('label' => CHtml::activeLabelEx($model, 'siteName', array('class' => 'control-label', 'label' => gT("Site name"))), 'description' => gT("This name will appear in the survey list overview and in the administration header."), 'control' => CHtml::activeTextField($model, 'siteName')); foreach (getLanguageData(true, Yii::app()->session['installerLang']) as $langkey => $languagekind) { $languages[$langkey] = sprintf('%s - %s', $languagekind['nativedescription'], $languagekind['description']); } $rows[] = array('label' => CHtml::activeLabelEx($model, 'surveylang', array('class' => 'control-label', 'label' => gT("Default language"))), 'description' => gT("This will be your default language."), 'control' => CHtml::activeDropDownList($model, 'surveylang', $languages, array('style' => 'width: 156px', 'class' => 'form-control', 'encode' => false, 'options' => array('en' => array('selected' => true))))); foreach ($rows as $row) { echo CHtml::openTag('div', array('class' => 'control-group')); echo $row['label']; echo CHtml::openTag('div', array('class' => 'controls')); echo $row['control']; if (isset($row['description'])) { echo CHtml::tag('div', array('class' => 'description-field'), $row['description']); } echo CHtml::closeTag('div'); echo CHtml::closeTag('div'); } ?>
</select></li><?php unset($set_qnc, $sel_qnc); ?> </ul> </div> <div id='language'> <ul> <li><label for='defaultlang'><?php $clang->eT("Default site language:") . (Yii::app()->getConfig("demoMode") == true ? '*' : ''); ?> </label> <select name='defaultlang' id='defaultlang'> <?php $actuallang = getGlobalSetting('defaultlang'); foreach (getLanguageData(true) as $langkey2 => $langname) { ?> <option value='<?php echo $langkey2; ?> ' <?php if ($actuallang == $langkey2) { ?> selected='selected' <?php } ?> ><?php echo $langname['nativedescription'] . " - " . $langname['description']; ?> </option>
/** * This function tries to find out a valid language code for the language of the browser used * If it cannot find it it will return the default language from global settings * */ function getBrowserLanguage() { $sLanguage = Yii::app()->getRequest()->getPreferredLanguage(); Yii::app()->loadHelper("surveytranslator"); $aLanguages = getLanguageData(); if (!isset($aLanguages[$sLanguage])) { $sLanguage = str_replace('_', '-', $sLanguage); if (!isset($aLanguages[$sLanguage])) { $sLanguage = substr($sLanguage, 0, strpos($sLanguage, '-')); if (!isset($aLanguages[$sLanguage])) { $sLanguage = Yii::app()->getConfig('defaultlang'); } } } return $sLanguage; }
/** * This function creates the language selector for a particular survey * * @param mixed $sSelectedLanguage The language in which all information is shown */ function makeLanguageChangerSurvey($sSelectedLanguage) { $surveyid = Yii::app()->getConfig('surveyID'); Yii::app()->loadHelper("surveytranslator"); $slangs = Survey::model()->findByPk($surveyid)->getAdditionalLanguages(); $slangs[] = GetBaseLanguageFromSurveyID($surveyid); $aAllLanguages = getLanguageData(); $slangs = array_keys(array_intersect_key($aAllLanguages, array_flip($slangs))); // Sort languages by their locale name if (count($slangs) > 1) { $previewgrp = false; if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'previewgroup') { $previewgrp = true; } $sHTMLCode = "<select id='languagechanger' name='languagechanger' class='languagechanger' onchange='javascript:window.location=this.value'>\n"; $sAddToURL = ""; $sTargetURL = Yii::app()->getController()->createUrl("/survey/index"); if ($previewgrp) { $sAddToURL = "&action=previewgroup&gid={$_REQUEST['gid']}"; } foreach ($slangs as $sLanguage) { $sHTMLCode .= "<option value=\"{$sTargetURL}?sid=" . $surveyid . "&lang=" . $sLanguage . "{$sAddToURL}\" "; if ($sLanguage == $sSelectedLanguage) { $sHTMLCode .= " selected='selected'"; } $sHTMLCode .= ">" . $aAllLanguages[$sLanguage]['nativedescription'] . "</option>\n"; } $sHTMLCode .= "</select>\n"; return $sHTMLCode; } else { return false; } }
/** * welcome and language selection install step */ private function stepWelcome() { if (!empty($_POST['installerLang'])) { Yii::app()->session['installerLang'] = $_POST['installerLang']; $this->redirect($this->createUrl('installer/license')); } $this->loadHelper('surveytranslator'); Yii::app()->session->remove('configFileWritten'); $aData['clang'] = $clang = $this->lang; $aData['title'] = $clang->gT('Welcome'); $aData['descp'] = $clang->gT('Welcome to the LimeSurvey installation wizard. This wizard will guide you through the installation, database setup and initial configuration of LimeSurvey.'); $aData['classesForStep'] = array('on', 'off', 'off', 'off', 'off', 'off'); $aData['progressValue'] = 0; if (isset(Yii::app()->session['installerLang'])) { $currentLanguage = Yii::app()->session['installerLang']; } else { $currentLanguage = 'en'; } foreach (getLanguageData(true, $currentLanguage) as $langkey => $languagekind) { $languages[htmlspecialchars($langkey)] = sprintf('%s - %s', $languagekind['nativedescription'], $languagekind['description']); } $aData['languages'] = $languages; $this->render('/installer/welcome_view', $aData); }
$tolang = $_GET['tolang']; } elseif (isset($_POST['tolang'])) { $tolang = $_POST['tolang']; } if ($tolang == "" && count(GetAdditionalLanguagesFromSurveyID($surveyid)) == 1) { $tmp_langs = GetAdditionalLanguagesFromSurveyID($surveyid); $tolang = $tmp_langs[0]; } $actionvalue = ""; if (isset($_POST['actionvalue'])) { $actionvalue = $_POST['actionvalue']; } // if(isset($_GET['actionvalue'])) {$actionvalue = $_GET['actionvalue'];} $survey_title = $surveyinfo['name']; $baselang = GetBaseLanguageFromSurveyID($surveyid); $supportedLanguages = getLanguageData(false); $baselangdesc = $supportedLanguages[$baselang]['description']; if ($tolang != "") { $tolangdesc = $supportedLanguages[$tolang]['description']; } $translateoutput = ""; $translateoutput .= "<form name='translatemenu' id='translatemenu' " . "action='{$scriptname}' method='get' >"; $translateoutput .= showTranslateAdminmenu($surveyid, $survey_title, $tolang, $scriptname); $translateoutput .= "</form>"; $translateoutput .= "<p style='margin:0;font-size:1px;line-height:1px;height:1px;'> </p>\n"; //CSS Firefox 2 transition fix $translateoutput .= "<div class='header ui-widget-header'>" . $clang->gT("Translate survey") . "</div>\n"; // $tab_names=array("title", "description", "welcome", "end", "group", "group_desc", "question", "question_help", "answer"); // $tab_names=array("title", "description", "invitation", "reminder"); $tab_names = array("title", "welcome", "group", "question", "subquestion", "answer", "emailinvite", "emailreminder", "emailconfirmation", "emailregistration"); if ($tolang != "" && $actionvalue == "translateSave") {
private function _saveSettings() { if ($_POST['action'] !== "globalsettingssave") { return; } if (!Permission::model()->hasGlobalPermission('settings', 'update')) { $this->getController()->redirect(array('/admin')); } $clang = $this->getController()->lang; Yii::app()->loadHelper('surveytranslator'); $maxemails = $_POST['maxemails']; if (sanitize_int($_POST['maxemails']) < 1) { $maxemails = 1; } $defaultlang = sanitize_languagecode($_POST['defaultlang']); $aRestrictToLanguages = explode(' ', sanitize_languagecodeS($_POST['restrictToLanguages'])); if (!in_array($defaultlang, $aRestrictToLanguages)) { // Force default language in restrictToLanguages $aRestrictToLanguages[] = $defaultlang; } if (count(array_diff(array_keys(getLanguageData(false, Yii::app()->session['adminlang'])), $aRestrictToLanguages)) == 0) { $aRestrictToLanguages = ''; } else { $aRestrictToLanguages = implode(' ', $aRestrictToLanguages); } setGlobalSetting('defaultlang', $defaultlang); setGlobalSetting('restrictToLanguages', trim($aRestrictToLanguages)); setGlobalSetting('sitename', strip_tags($_POST['sitename'])); setGlobalSetting('updatecheckperiod', (int) $_POST['updatecheckperiod']); setGlobalSetting('updatenotification', strip_tags($_POST['updatenotification'])); setGlobalSetting('defaulthtmleditormode', sanitize_paranoid_string($_POST['defaulthtmleditormode'])); setGlobalSetting('defaultquestionselectormode', sanitize_paranoid_string($_POST['defaultquestionselectormode'])); setGlobalSetting('defaulttemplateeditormode', sanitize_paranoid_string($_POST['defaulttemplateeditormode'])); setGlobalSetting('defaulttemplate', sanitize_paranoid_string($_POST['defaulttemplate'])); setGlobalSetting('admintheme', sanitize_paranoid_string($_POST['admintheme'])); setGlobalSetting('adminthemeiconsize', trim(file_get_contents(Yii::app()->getConfig("styledir") . DIRECTORY_SEPARATOR . sanitize_paranoid_string($_POST['admintheme']) . DIRECTORY_SEPARATOR . 'iconsize'))); setGlobalSetting('emailmethod', strip_tags($_POST['emailmethod'])); setGlobalSetting('emailsmtphost', strip_tags(returnGlobal('emailsmtphost'))); if (returnGlobal('emailsmtppassword') != 'somepassword') { setGlobalSetting('emailsmtppassword', strip_tags(returnGlobal('emailsmtppassword'))); } setGlobalSetting('bounceaccounthost', strip_tags(returnGlobal('bounceaccounthost'))); setGlobalSetting('bounceaccounttype', strip_tags(returnGlobal('bounceaccounttype'))); setGlobalSetting('bounceencryption', strip_tags(returnGlobal('bounceencryption'))); setGlobalSetting('bounceaccountuser', strip_tags(returnGlobal('bounceaccountuser'))); if (returnGlobal('bounceaccountpass') != 'enteredpassword') { setGlobalSetting('bounceaccountpass', strip_tags(returnGlobal('bounceaccountpass'))); } setGlobalSetting('emailsmtpssl', sanitize_paranoid_string(Yii::app()->request->getPost('emailsmtpssl', ''))); setGlobalSetting('emailsmtpdebug', sanitize_int(Yii::app()->request->getPost('emailsmtpdebug', '0'))); setGlobalSetting('emailsmtpuser', strip_tags(returnGlobal('emailsmtpuser'))); setGlobalSetting('filterxsshtml', strip_tags($_POST['filterxsshtml'])); $warning = ''; // make sure emails are valid before saving them if (Yii::app()->request->getPost('siteadminbounce', '') == '' || validateEmailAddress(Yii::app()->request->getPost('siteadminbounce'))) { setGlobalSetting('siteadminbounce', strip_tags(Yii::app()->request->getPost('siteadminbounce'))); } else { $warning .= $clang->gT("Warning! Admin bounce email was not saved because it was not valid.") . '<br/>'; } if (Yii::app()->request->getPost('siteadminemail', '') == '' || validateEmailAddress(Yii::app()->request->getPost('siteadminemail'))) { setGlobalSetting('siteadminemail', strip_tags(Yii::app()->request->getPost('siteadminemail'))); } else { $warning .= $clang->gT("Warning! Admin email was not saved because it was not valid.") . '<br/>'; } setGlobalSetting('siteadminname', strip_tags($_POST['siteadminname'])); setGlobalSetting('shownoanswer', sanitize_int($_POST['shownoanswer'])); setGlobalSetting('showxquestions', $_POST['showxquestions']); setGlobalSetting('showgroupinfo', $_POST['showgroupinfo']); setGlobalSetting('showqnumcode', $_POST['showqnumcode']); $repeatheadingstemp = (int) $_POST['repeatheadings']; if ($repeatheadingstemp == 0) { $repeatheadingstemp = 25; } setGlobalSetting('repeatheadings', $repeatheadingstemp); setGlobalSetting('maxemails', sanitize_int($maxemails)); $iSessionExpirationTime = (int) $_POST['iSessionExpirationTime']; if ($iSessionExpirationTime == 0) { $iSessionExpirationTime = 7200; } setGlobalSetting('iSessionExpirationTime', $iSessionExpirationTime); setGlobalSetting('ipInfoDbAPIKey', $_POST['ipInfoDbAPIKey']); setGlobalSetting('googleMapsAPIKey', $_POST['googleMapsAPIKey']); setGlobalSetting('googleanalyticsapikey', $_POST['googleanalyticsapikey']); setGlobalSetting('googletranslateapikey', $_POST['googletranslateapikey']); setGlobalSetting('force_ssl', $_POST['force_ssl']); setGlobalSetting('surveyPreview_require_Auth', $_POST['surveyPreview_require_Auth']); setGlobalSetting('RPCInterface', $_POST['RPCInterface']); setGlobalSetting('rpc_publish_api', (bool) $_POST['rpc_publish_api']); //added by Gaurang 2014-04-14 setGlobalSetting('Project_Manager', (int) $_POST['Project_Manager']); //setGlobalSetting('Sales_Person', (int) $_POST['Sales_Person']); setGlobalSetting('Own_Panel', (int) $_POST['Own_Panel']); // EOF Gaurang //added by Gaurang 2014-04-17 // set global status of project setGlobalSetting('project_status_run', (int) $_POST['project_status_run']); setGlobalSetting('project_status_test', (int) $_POST['project_status_test']); setGlobalSetting('project_status_hold', (int) $_POST['project_status_hold']); setGlobalSetting('project_status_completed', (int) $_POST['project_status_completed']); setGlobalSetting('project_status_closed', (int) $_POST['project_status_closed']); // set global status of redirection setGlobalSetting('redirect_status_completed', (int) $_POST['redirect_status_completed']); setGlobalSetting('redirect_status_disqual', (int) $_POST['redirect_status_disqual']); setGlobalSetting('redirect_status_qf', (int) $_POST['redirect_status_qf']); setGlobalSetting('redirect_status_redirected', (int) $_POST['redirect_status_redirected']); setGlobalSetting('redirect_status_rej_fail', (int) $_POST['redirect_status_rej_fail']); setGlobalSetting('redirect_status_rej_incosist', (int) $_POST['redirect_status_rej_incosist']); setGlobalSetting('redirect_status_rej_poor', (int) $_POST['redirect_status_rej_poor']); setGlobalSetting('redirect_status_rej_quality', (int) $_POST['redirect_status_rej_quality']); setGlobalSetting('redirect_status_rej_speed', (int) $_POST['redirect_status_rej_speed']); // EOF Gaurang $savetime = (double) $_POST['timeadjust'] * 60 . ' minutes'; //makes sure it is a number, at least 0 if (substr($savetime, 0, 1) != '-' && substr($savetime, 0, 1) != '+') { $savetime = '+' . $savetime; } setGlobalSetting('timeadjust', $savetime); setGlobalSetting('usercontrolSameGroupPolicy', strip_tags($_POST['usercontrolSameGroupPolicy'])); Yii::app()->session['flashmessage'] = $warning . $clang->gT("Global settings were saved."); $url = htmlspecialchars_decode(Yii::app()->session['refurl']); if ($url) { Yii::app()->getController()->redirect($url); } }
/** * RPC Routine to delete a survey language. * * @access public * @param string $sSessionKey Auth credentials * @param integer $iSurveyID ID of the survey where a token table will be created for * @param string $sLanguage A valid language shortcut to delete from the current survey. If the language does not exist in that survey no error will be given. * @return array Status=>OK when successfull, otherwise the error description */ public function delete_language($sSessionKey, $iSurveyID, $sLanguage) { if ($this->_checkSessionKey($sSessionKey)) { $oSurvey = Survey::model()->findByPk($iSurveyID); if (is_null($oSurvey)) { return array('status' => 'Error: Invalid survey ID'); } if (Permission::model()->hasSurveyPermission($iSurveyID, 'surveysettings', 'update')) { Yii::app()->loadHelper('surveytranslator'); $aLanguages = getLanguageData(); if (!isset($aLanguages[$sLanguage])) { return array('status' => 'Invalid language'); } $oSurvey = Survey::model()->findByPk($iSurveyID); if ($sLanguage == $oSurvey->language) { return array('status' => 'Cannot remove base language'); } $aLanguages = $oSurvey->getAdditionalLanguages(); unset($aLanguages[$sLanguage]); $oSurvey->additional_languages = implode(' ', $aLanguages); try { $oSurvey->save(); // save the change to database SurveyLanguageSetting::model()->deleteByPk(array('surveyls_survey_id' => $iSurveyID, 'surveyls_language' => $sLanguage)); cleanLanguagesFromSurvey($iSurveyID, $oSurvey->additional_languages); return array('status' => 'OK'); } catch (Exception $e) { return array('status' => 'Error'); } } else { return array('status' => 'No permission'); } } }
function getLanguageDataRestricted($bOrderByNative = false, $sLanguageCode = 'en') { $aLanguageData = getLanguageData($bOrderByNative, $sLanguageCode); if (trim(Yii::app()->getConfig('restrictToLanguages')) != '') { foreach (explode(' ', trim(Yii::app()->getConfig('restrictToLanguages'))) as $key) { $aArray[$key] = $aLanguageData[$key]; } } else { $aArray = $aLanguageData; } return $aArray; }
public function rules() { return array(array('dbtype, dblocation, dbname, dbuser', 'required', 'on' => 'database'), array('dbpwd, dbprefix', 'safe', 'on' => 'database'), array('dbtype', 'in', 'range' => array_keys($this->supported_db_types), 'on' => 'database'), array('adminLoginName, adminName, siteName, confirmPwd', 'safe', 'on' => 'optional'), array('adminEmail', 'email', 'on' => 'optional'), array('surveylang', 'in', 'range' => array_keys(getLanguageData(true, Yii::app()->session['installerLang'])), 'on' => 'optional'), array('adminLoginPwd', 'compare', 'compareAttribute' => 'confirmPwd', 'message' => Yii::app()->getController()->lang->gT('Passwords do not match!'), 'strict' => true, 'on' => 'optional')); }
// 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='";
private function _saveSettings() { if ($_POST['action'] !== "globalsettingssave") { return; } if (Yii::app()->session['USER_RIGHT_CONFIGURATOR'] != 1) { $this->getController()->redirect($this->getController()->createUrl('/admin')); } $clang = $this->getController()->lang; Yii::app()->loadHelper('surveytranslator'); $maxemails = $_POST['maxemails']; if (sanitize_int($_POST['maxemails']) < 1) { $maxemails = 1; } $defaultlang = sanitize_languagecode($_POST['defaultlang']); $aRestrictToLanguages = explode(' ', sanitize_languagecodeS($_POST['restrictToLanguages'])); if (!in_array($defaultlang, $aRestrictToLanguages)) { // Force default language in restrictToLanguages $aRestrictToLanguages[] = $defaultlang; } if (count(array_diff(array_keys(getLanguageData(false, Yii::app()->session['adminlang'])), $aRestrictToLanguages)) == 0) { $aRestrictToLanguages = ''; } else { $aRestrictToLanguages = implode(' ', $aRestrictToLanguages); } setGlobalSetting('defaultlang', $defaultlang); setGlobalSetting('restrictToLanguages', trim($aRestrictToLanguages)); setGlobalSetting('sitename', strip_tags($_POST['sitename'])); setGlobalSetting('updatecheckperiod', (int) $_POST['updatecheckperiod']); setGlobalSetting('defaulthtmleditormode', sanitize_paranoid_string($_POST['defaulthtmleditormode'])); setGlobalSetting('defaultquestionselectormode', sanitize_paranoid_string($_POST['defaultquestionselectormode'])); setGlobalSetting('defaulttemplateeditormode', sanitize_paranoid_string($_POST['defaulttemplateeditormode'])); setGlobalSetting('defaulttemplate', sanitize_paranoid_string($_POST['defaulttemplate'])); setGlobalSetting('admintheme', sanitize_paranoid_string($_POST['admintheme'])); setGlobalSetting('adminthemeiconsize', trim(file_get_contents(Yii::app()->getConfig("styledir") . DIRECTORY_SEPARATOR . sanitize_paranoid_string($_POST['admintheme']) . DIRECTORY_SEPARATOR . 'iconsize'))); setGlobalSetting('emailmethod', strip_tags($_POST['emailmethod'])); setGlobalSetting('emailsmtphost', strip_tags(returnGlobal('emailsmtphost'))); if (returnGlobal('emailsmtppassword') != 'somepassword') { setGlobalSetting('emailsmtppassword', strip_tags(returnGlobal('emailsmtppassword'))); } setGlobalSetting('bounceaccounthost', strip_tags(returnGlobal('bounceaccounthost'))); setGlobalSetting('bounceaccounttype', strip_tags(returnGlobal('bounceaccounttype'))); setGlobalSetting('bounceencryption', strip_tags(returnGlobal('bounceencryption'))); setGlobalSetting('bounceaccountuser', strip_tags(returnGlobal('bounceaccountuser'))); if (returnGlobal('bounceaccountpass') != 'enteredpassword') { setGlobalSetting('bounceaccountpass', strip_tags(returnGlobal('bounceaccountpass'))); } setGlobalSetting('emailsmtpssl', sanitize_paranoid_string(Yii::app()->request->getPost('emailsmtpssl', ''))); setGlobalSetting('emailsmtpdebug', sanitize_int(Yii::app()->request->getPost('emailsmtpdebug', '0'))); setGlobalSetting('emailsmtpuser', strip_tags(returnGlobal('emailsmtpuser'))); setGlobalSetting('filterxsshtml', strip_tags($_POST['filterxsshtml'])); setGlobalSetting('siteadminbounce', strip_tags($_POST['siteadminbounce'])); setGlobalSetting('siteadminemail', strip_tags($_POST['siteadminemail'])); setGlobalSetting('siteadminname', strip_tags($_POST['siteadminname'])); setGlobalSetting('shownoanswer', sanitize_int($_POST['shownoanswer'])); setGlobalSetting('showxquestions', $_POST['showxquestions']); setGlobalSetting('showgroupinfo', $_POST['showgroupinfo']); setGlobalSetting('showqnumcode', $_POST['showqnumcode']); $repeatheadingstemp = (int) $_POST['repeatheadings']; if ($repeatheadingstemp == 0) { $repeatheadingstemp = 25; } setGlobalSetting('repeatheadings', $repeatheadingstemp); setGlobalSetting('maxemails', sanitize_int($maxemails)); $iSessionExpirationTime = (int) $_POST['iSessionExpirationTime']; if ($iSessionExpirationTime == 0) { $iSessionExpirationTime = 7200; } setGlobalSetting('iSessionExpirationTime', $iSessionExpirationTime); setGlobalSetting('ipInfoDbAPIKey', $_POST['ipInfoDbAPIKey']); setGlobalSetting('googleMapsAPIKey', $_POST['googleMapsAPIKey']); setGlobalSetting('googleanalyticsapikey', $_POST['googleanalyticsapikey']); setGlobalSetting('googletranslateapikey', $_POST['googletranslateapikey']); setGlobalSetting('force_ssl', $_POST['force_ssl']); setGlobalSetting('surveyPreview_require_Auth', $_POST['surveyPreview_require_Auth']); setGlobalSetting('RPCInterface', $_POST['RPCInterface']); $savetime = (double) $_POST['timeadjust'] * 60 . ' minutes'; //makes sure it is a number, at least 0 if (substr($savetime, 0, 1) != '-' && substr($savetime, 0, 1) != '+') { $savetime = '+' . $savetime; } setGlobalSetting('timeadjust', $savetime); setGlobalSetting('usercontrolSameGroupPolicy', strip_tags($_POST['usercontrolSameGroupPolicy'])); Yii::app()->session['flashmessage'] = $clang->gT("Global settings were saved."); $url = htmlspecialchars_decode(Yii::app()->session['refurl']); if ($url) { Yii::app()->getController()->redirect($url); } }
function globalsettingsdisplay() { global $action, $connect, $js_admin_includes, $editsurvey, $subaction, $scriptname, $clang; global $updateversion, $updatebuild, $updateavailable, $updatelastcheck, $demoModeOnly; if (isset($subaction) && $subaction == "updatecheck") { $updateinfo=updatecheck(); } if (isset($action) && $action == "globalsettings") { if($_SESSION['USER_RIGHT_SUPERADMIN'] == 1) { $js_admin_includes[]='scripts/globalsettings.js'; // header $editsurvey = "<div class='header ui-widget-header'>".$clang->gT("Global settings")."</div>\n"; // beginning TABs section $editsurvey .= "\t<div id='tabs'> <ul> <li><a href='#overview'>".$clang->gT("Overview & update")."</a></li> <li><a href='#general'>".$clang->gT("General")."</a></li> <li><a href='#email'>".$clang->gT("Email settings")."</a></li> <li><a href='#bounce'>".$clang->gT("Bounce settings")."</a></li> <li><a href='#security'>".$clang->gT("Security")."</a></li> <li><a href='#presentation'>".$clang->gT("Presentation")."</a></li> </ul>\n"; $editsurvey .= "<form class='form30' id='frmglobalsettings' name='frmglobalsettings' action='$scriptname' method='post'>\n"; $editsurvey .= "<div id='overview'>\n"; $editsurvey .= checksettings(); $thisupdatecheckperiod=getGlobalSetting('updatecheckperiod'); $editsurvey .= "<br /></p><div class='header ui-widget-header'>".$clang->gT("Updates")."</div><ul>" . "\t<li><label for='updatecheckperiod'>".$clang->gT("Check for updates:")."</label>\n" . "\t\t\t<select name='updatecheckperiod' id='updatecheckperiod'>\n" . "\t\t\t\t<option value='0'"; if ($thisupdatecheckperiod==0) {$editsurvey .= " selected='selected'";} $editsurvey .=">".$clang->gT("Never")."</option>\n" . "\t\t\t\t<option value='1'"; if ($thisupdatecheckperiod==1) {$editsurvey .= " selected='selected'";} $editsurvey .=">".$clang->gT("Every day")."</option>\n" . "\t\t\t\t<option value='7'"; if ($thisupdatecheckperiod==7) {$editsurvey .= " selected='selected'";} $editsurvey .=">".$clang->gT("Every week")."</option>\n" . "<option value='14'"; if ($thisupdatecheckperiod==14) {$editsurvey .= " selected='selected'";} $editsurvey .=">".$clang->gT("Every 2 weeks")."</option>\n" . "<option value='30'"; if ($thisupdatecheckperiod==30) {$editsurvey .= " selected='selected'";} $editsurvey .=">".$clang->gT("Every month")."</option>\n" . "</select> <input type='button' onclick=\"window.open('$scriptname?action=globalsettings&subaction=updatecheck', '_top')\" value='".$clang->gT("Check now")."' /> <span id='lastupdatecheck'>".sprintf($clang->gT("Last check: %s"),$updatelastcheck)."</span></li></ul><p>\n"; if (isset($updateavailable) && $updateavailable==1) { $editsurvey .='<span style="font-weight: bold;">'.sprintf($clang->gT('There is a LimeSurvey update available: Version %s'),$updateversion."($updatebuild)").'</span><br />'; $editsurvey .=sprintf($clang->gT('You can update %smanually%s or use the %s'),"<a href='http://docs.limesurvey.org/tiki-index.php?page=Upgrading+from+a+previous+version'>","</a>","<a href='$scriptname?action=update'>".$clang->gT('3-Click ComfortUpdate').'</a>').'.<br />'; } elseif (isset($updateinfo['errorcode'])) { $editsurvey .=sprintf($clang->gT('There was an error on update check (%s)'),$updateinfo['errorcode']).'.<br />'; $editsurvey .="<textarea readonly='readonly' style='width:35%; height:60px; overflow: auto;'>".strip_tags($updateinfo['errorhtml']).'</textarea>'; } else { $editsurvey .=$clang->gT('There is currently no newer LimeSurvey version available.'); } $editsurvey .= "</p></div>"; // General TAB $editsurvey .= "\t<div id='general'>\n"; // Administrator... $editsurvey .= "<ul>" . "\t<li><label for='sitename'>".$clang->gT("Site name:").(($demoModeOnly==true)?'*':'')."</label>\n" . "\t\t<input type='text' size='50' id='sitename' name='sitename' value=\"".htmlspecialchars(getGlobalSetting('sitename'))."\" /></li>\n" . "\t<li><label for='defaultlang'>".$clang->gT("Default site language:").(($demoModeOnly==true)?'*':'')."</label>\n" . "\t\t<select name='defaultlang' id='defaultlang'>\n"; $actuallang=getGlobalSetting('defaultlang'); foreach (getLanguageData(true) as $langkey2=>$langname) { $editsurvey .= "\t\t\t<option value='".$langkey2."'"; if ($actuallang == $langkey2) {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$langname['nativedescription']." - ".$langname['description']."</option>\n"; } $editsurvey .= "\t\t</select></li>"; $thisdefaulttemplate=getGlobalSetting('defaulttemplate'); $templatenames=array_keys(gettemplatelist()); $editsurvey .= "" . "\t<li><label for='defaulttemplate'>".$clang->gT("Default template:")."</label>\n" . "\t\t\t<select name='defaulttemplate' id='defaulttemplate'>\n"; foreach ($templatenames as $templatename) { $editsurvey.= "\t\t\t\t<option value='$templatename'"; if ($thisdefaulttemplate==$templatename) {$editsurvey .= " selected='selected'";} $editsurvey .=">$templatename</option>\n"; } $editsurvey .="\t\t\t</select></li>\n"; $thisdefaulthtmleditormode=getGlobalSetting('defaulthtmleditormode'); $editsurvey .= "" . "\t<li><label for='defaulthtmleditormode'>".$clang->gT("Default HTML editor mode:").(($demoModeOnly==true)?'*':'')."</label>\n" . "\t\t\t<select name='defaulthtmleditormode' id='defaulthtmleditormode'>\n" . "\t\t\t\t<option value='default'"; if ($thisdefaulthtmleditormode=='default') {$editsurvey .= " selected='selected'";} $editsurvey .=">".$clang->gT("Default HTML editor mode")."</option>\n" . "\t\t\t\t<option value='none'"; if ($thisdefaulthtmleditormode=='none') {$editsurvey .= " selected='selected'";} $editsurvey .=">".$clang->gT("No HTML editor")."</option>\n" . "<option value='inline'"; if ($thisdefaulthtmleditormode=='inline') {$editsurvey .= " selected='selected'";} $editsurvey .=">".$clang->gT("Inline HTML editor")."</option>\n" . "<option value='popup'"; if ($thisdefaulthtmleditormode=='popup') {$editsurvey .= " selected='selected'";} $editsurvey .=">".$clang->gT("Popup HTML editor")."</option>\n" . "</select></li>\n"; $dateformatdata=getDateFormatData($_SESSION['dateformat']); $editsurvey.= "\t<li><label for='timeadjust'>".$clang->gT("Time difference (in hours):")."</label>\n" . "\t\t<span><input type='text' size='10' id='timeadjust' name='timeadjust' value=\"".htmlspecialchars(str_replace(array('+',' hours'),array('',''),getGlobalSetting('timeadjust')))."\" /> " . $clang->gT("Server time:").' '.convertDateTimeFormat(date('Y-m-d H:i:s'),'Y-m-d H:i:s',$dateformatdata['phpdate'].' H:i')." - ".$clang->gT("Corrected time :").' '.convertDateTimeFormat(date_shift(date("Y-m-d H:i:s"), 'Y-m-d H:i:s', getGlobalSetting('timeadjust')),'Y-m-d H:i:s',$dateformatdata['phpdate'].' H:i')." </span></li>\n"; $thisusepdfexport=getGlobalSetting('usepdfexport'); $editsurvey .= "\t<li><label for='usepdfexport'>".$clang->gT("PDF export available:")."</label>\n" . "<select name='usepdfexport' id='usepdfexport'>\n" . "<option value='1'"; if ( $thisusepdfexport == true) {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("On")."</option>\n" . "<option value='0'"; if ( $thisusepdfexport == false) {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("Off")."</option>\n" . "\t\t</select>\n\t</li>\n"; $thisaddTitleToLinks=getGlobalSetting('addTitleToLinks'); $editsurvey .= "\t<li><label for='addTitleToLinks'>".$clang->gT("Screen reader compatibility mode:")."</label>\n" . "<select name='addTitleToLinks' id='addTitleToLinks'>\n" . "<option value='1'"; if ( $thisaddTitleToLinks == true) {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("On")."</option>\n" . "<option value='0'"; if ( $thisaddTitleToLinks == false) {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("Off")."</option>\n" . "</select>\n</li>\n" . "<li><label for='sessionlifetime'>".$clang->gT("Session lifetime (seconds):")."</label>\n" . "<input type='text' size='10' id='sessionlifetime' name='sessionlifetime' value=\"".htmlspecialchars(getGlobalSetting('sessionlifetime'))."\" /></li>" . "<li><label for='ipInfoDbAPIKey'>".$clang->gT("IP Info DB API Key:")."</label>\n" . "<input type='text' size='35' id='ipInfoDbAPIKey' name='ipInfoDbAPIKey' value=\"".htmlspecialchars(getGlobalSetting('ipInfoDbAPIKey'))."\" /></li>" . "<li><label for='googleMapsAPIKey'>".$clang->gT("Google Maps API key:")."</label>\n" . "<input type='text' size='35' id='googleMapsAPIKey' name='googleMapsAPIKey' value=\"".htmlspecialchars(getGlobalSetting('googleMapsAPIKey'))."\" /></li>" ; // End General TAB $editsurvey .= "\t</ul></div>\n"; // Email TAB $editsurvey .= "\t<div id='email'><ul>\n"; //Format $editsurvey.= "\t<li><label for='siteadminemail'>".$clang->gT("Default site admin email:")."</label>\n" . "\t\t<input type='text' size='50' id='siteadminemail' name='siteadminemail' value=\"".htmlspecialchars(getGlobalSetting('siteadminemail'))."\" /></li>\n" . "\t<li><label for='siteadminname'>".$clang->gT("Administrator name:")."</label>\n" . "\t\t<input type='text' size='50' id='siteadminname' name='siteadminname' value=\"".htmlspecialchars(getGlobalSetting('siteadminname'))."\" /><br /><br /></li>\n" . "\t<li><label for='emailmethod'>".$clang->gT("Email method:")."</label>\n" . "\t\t<select id='emailmethod' name='emailmethod'>\n" . "\t\t\t<option value='mail'"; if (getGlobalSetting('emailmethod')=='mail') {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("PHP (default)")."</option>\n" . "\t\t\t<option value='smtp'"; if (getGlobalSetting('emailmethod')=='smtp') {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("SMTP")."</option>\n" . "\t\t\t<option value='sendmail'"; if (getGlobalSetting('emailmethod')=='sendmail') {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("Sendmail")."</option>\n" . "\t\t\t<option value='qmail'"; if (getGlobalSetting('emailmethod')=='qmail') {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("Qmail")."</option>\n" . "\t\t</select></li>\n" . "\t<li>\n\t\t<label for=\"emailsmtphost\">".$clang->gT("SMTP host:")."</label>\n" . "\t\t<input type='text' size='50' id='emailsmtphost' name='emailsmtphost' value=\"".htmlspecialchars(getGlobalSetting('emailsmtphost'))."\" /> <font size='1'>".$clang->gT("Enter your hostname and port, e.g.: my.smtp.com:25")."</font></li>\n" . "\t<li><label for='emailsmtpuser'>".$clang->gT("SMTP username:"******"</label>\n" . "\t\t<input type='text' size='50' id='emailsmtpuser' name='emailsmtpuser' value=\"".htmlspecialchars(getGlobalSetting('emailsmtpuser'))."\" /></li>\n" . "\t<li><label for='emailsmtppassword'>".$clang->gT("SMTP password:"******"</label>\n" . "\t\t<input type='password' size='50' id='emailsmtppassword' name='emailsmtppassword' value='somepassword' /></li>\n" . "\t<li><label for='emailsmtpssl'>".$clang->gT("SMTP SSL/TLS:")."</label>\n" . "\t\t<select id='emailsmtpssl' name='emailsmtpssl'>\n" . "\t\t\t<option value=''"; if (getGlobalSetting('emailsmtpssl')=='') {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("Off")."</option>\n" . "\t\t\t<option value='ssl'"; if (getGlobalSetting('emailsmtpssl')=='ssl' || getGlobalSetting('emailsmtpssl')==1) {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("SSL")."</option>\n" . "\t\t\t<option value='tls'"; if (getGlobalSetting('emailsmtpssl')=='tls') {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("TLS")."</option>\n" . "\t\t</select></li>\n" . "\t<li><label for='emailsmtpdebug'>".$clang->gT("SMTP debug mode:")."</label>\n" . "\t\t<select id='emailsmtpdebug' name='emailsmtpdebug'>\n" . "\t\t\t<option value=''"; if (getGlobalSetting('emailsmtpdebug')=='0') {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("Off")."</option>\n" . "\t\t\t<option value='1'"; if (getGlobalSetting('emailsmtpdebug')=='1' || getGlobalSetting('emailsmtpssl')==1) {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("On errors")."</option>\n" . "\t\t\t<option value='2'"; if (getGlobalSetting('emailsmtpdebug')=='2' || getGlobalSetting('emailsmtpssl')==1) {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("Always")."</option>\n" . "\t\t</select><br /> </li>\n" . "\t<li><label for='maxemails'>".$clang->gT("Email batch size:")."</label>\n" . "\t\t<input type='text' size='5' id='maxemails' name='maxemails' value=\"".htmlspecialchars(getGlobalSetting('maxemails'))."\" /></li>\n" . "\t</ul>\n"; // End Email TAB $editsurvey .= "\t</div>\n"; // Start bounce tab $editsurvey .= "\t<div id='bounce'><ul>\n" . "\t<li><label for='siteadminbounce'>".$clang->gT("Default site bounce email:")."</label>\n" . "\t\t<input type='text' size='50' id='siteadminbounce' name='siteadminbounce' value=\"".htmlspecialchars(getGlobalSetting('siteadminbounce'))."\" /></li>\n" . "\t<li><label for='bounceaccounttype'>".$clang->gT("Server type:")."</label>\n" . "\t\t<select id='bounceaccounttype' name='bounceaccounttype'>\n" . "\t\t\t<option value='off'"; if (getGlobalSetting('bounceaccounttype')=='off') {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("Off")."</option>\n" . "\t\t\t<option value='IMAP'"; if (getGlobalSetting('bounceaccounttype')=='IMAP') {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("IMAP")."</option>\n" . "\t\t\t<option value='POP'"; if (getGlobalSetting('bounceaccounttype')=='POP') {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("POP")."</option>\n" ."\t\t</select></li>\n" . "\t<li><label for='bounceaccounthost'>".$clang->gT("Server name & port:")."</label>\n" . "\t\t<input type='text' size='50' id='bounceaccounthost' name='bounceaccounthost' value=\"".htmlspecialchars(getGlobalSetting('bounceaccounthost'))."\" />\n"."<font size='1'>".$clang->gT("Enter your hostname and port, e.g.: imap.gmail.com:995")."</font>\n" . "\t<li><label for='bounceaccountuser'>".$clang->gT("User name:")."</label>\n" . "\t\t<input type='text' size='50' id='bounceaccountuser' name='bounceaccountuser' value=\"".htmlspecialchars(getGlobalSetting('bounceaccountuser'))."\" /></li>\n" . "\t<li><label for='bounceaccountpass'>".$clang->gT("Password:"******"</label>\n" . "\t\t<input type='password' size='50' id='bounceaccountpass' name='bounceaccountpass' value='enteredpassword' /></li>\n"; $editsurvey.= "\t<li><label for='bounceencryption'>".$clang->gT("Encryption type:")."</label>\n" . "\t\t<select id='bounceencryption' name='bounceencryption'>\n" . "\t\t\t<option value='off'"; if (getGlobalSetting('bounceencryption')=='off') {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("Off")."</option>\n" . "\t\t\t<option value='SSL'"; if (getGlobalSetting('bounceencryption')=='SSL') {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("SSL")."</option>\n" . "\t\t\t<option value='TLS'"; if (getGlobalSetting('bounceencryption')=='TLS') {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("TLS")."</option>\n" ."\t\t</select></li>\n</ul>"; $editsurvey .= "\t</div>\n"; // End of bounce tabs // Security Settings $editsurvey .= "\t<div id='security'><ul>\n"; // Expiration $thissurveyPreview_require_Auth=getGlobalSetting('surveyPreview_require_Auth'); $editsurvey .= "\t<li><label for='surveyPreview_require_Auth'>".$clang->gT("Survey preview only for administration users")."</label>\n" . "\t\t<select id='surveyPreview_require_Auth' name='surveyPreview_require_Auth'>\n" . "\t\t\t<option value='1'"; if ($thissurveyPreview_require_Auth == true) {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("Yes")."</option>\n" . "\t\t\t<option value='0'"; if ($thissurveyPreview_require_Auth == false) {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("No")."</option>\n" . "\t\t</select></li>\n"; // Auto registration $thisfilterxsshtml=getGlobalSetting('filterxsshtml'); $editsurvey .= "\t<li><label for='filterxsshtml'>".$clang->gT("Filter HTML for XSS:").(($demoModeOnly==true)?'*':'')."</label>\n" . "\t\t<select id='filterxsshtml' name='filterxsshtml'>\n" . "\t\t\t<option value='1'"; if ( $thisfilterxsshtml == true) {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("Yes")."</option>\n" . "\t\t\t<option value='0'"; if ( $thisfilterxsshtml == false) {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("No")."</option>\n" . "\t\t</select></li>\n"; $thisusercontrolSameGroupPolicy=getGlobalSetting('usercontrolSameGroupPolicy'); $editsurvey .= "\t<li><label for='usercontrolSameGroupPolicy'>".$clang->gT("Group member can only see own group:")."</label>\n" . "\t\t<select id='usercontrolSameGroupPolicy' name='usercontrolSameGroupPolicy'>\n" . "\t\t\t<option value='1'"; if ( $thisusercontrolSameGroupPolicy == true) {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("Yes")."</option>\n" . "\t\t\t<option value='0'"; if ( $thisusercontrolSameGroupPolicy == false) {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("No")."</option>\n" . "\t\t</select></li>\n"; $thisforce_ssl = getGlobalSetting('force_ssl'); $opt_force_ssl_on = $opt_force_ssl_off = $opt_force_ssl_neither = ''; $warning_force_ssl = $clang->gT('Warning: Before turning on HTTPS, ') . '<a href="https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'"title="' . $clang->gT('Test if your server has SSL enabled by clicking on this link.').'">' . $clang->gT('check if this link works.').'</a><br/> ' . $clang->gT("If the link does not work and you turn on HTTPS, LimeSurvey will break and you won't be able to access it."); // $warning_force_ssl = ' Do <strong>NOT</strong> force "On" if you\'re <strong>not completely certain</strong> your server has a SSL enabled. <br />' // . 'Before turning on HTTPS, <a href="https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'">See if this link works</a><br />' // . 'If not, <strong>LimeSurvey will break</strong> if SSL is forced on but your server does not have a valid secure certificate installed and enabled.<br />'; switch($thisforce_ssl) { case 'on': $warning_force_ssl = ' '; break; case 'off': case 'neither': break; default: $thisforce_ssl = 'neither'; }; $this_opt = 'opt_force_ssl_'.$thisforce_ssl; $$this_opt = ' selected="selected"'; $editsurvey .= '<li><label for="force_ssl">'.$clang->gT('Force HTTPS:')."</label>\n" . "<select name=\"force_ssl\" id=\"force_ssl\">\n\t" . '<option value="on" '.$opt_force_ssl_on.'>'.$clang->gT('On')."</option>\n\t" . '<option value="off" '.$opt_force_ssl_off.'>'.$clang->gT('Off')."</option>\n\t" . '<option value="neither" '.$opt_force_ssl_neither.'>'.$clang->gT('Don\'t force on or off')."</option>\n\t" . "</select></li>\n" . "<li><span style='font-size:0.7em;'>$warning_force_ssl\n</span></li>\n"; unset($thisforce_ssl,$opt_force_ssl_on,$opt_force_ssl_off,$opt_force_ssl_neither,$warning_force_ssl,$this_opt); $editsurvey .= "\t</ul></div>\n"; // presentation settings tab $editsurvey .= "\t<div id='presentation'><ul>\n"; // shownoanswer $shownoanswer=getGlobalSetting('shownoanswer'); $sel_na = array( 0 => '' , 1 => '' , 2 => ''); $sel_na[$shownoanswer] = ' selected="selected"'; $editsurvey .= "\t<li><label for='shownoanswer'>".$clang->gT("Show 'no answer' option for non-mandatory questions:")."</label>\n" . "\t\t<select id='shownoanswer' name='shownoanswer'>\n" . "\t\t\t<option value=\"1\"{$sel_na[1]}>".$clang->gT('Yes')."</option>\n" . "\t\t\t<option value=\"0\"{$sel_na[0]}>".$clang->gT('No')."</option>\n" . "\t\t\t<option value=\"2\"{$sel_na[2]}>".$clang->gT('Survey admin can choose')."</option>\n" . "\t\t</select></li>\n"; $thisrepeatheadings=getGlobalSetting('repeatheadings'); $editsurvey .= "\t<li><label for='repeatheadings'>".$clang->gT("Repeating headings in array questions every X subquestions:")."</label>\n" . "\t\t<input id='repeatheadings' name='repeatheadings' value='$thisrepeatheadings' size='4' maxlength='4' /></li>\n"; // showXquestions $set_xq=getGlobalSetting('showXquestions'); $sel_xq = array( 'hide' => '' , 'show' => '' , 'choose' => ''); $sel_xq[$set_xq] = ' selected="selected"'; if( empty($sel_xq['hide']) && empty($sel_xq['show']) && empty($sel_xq['choose'])) { $sel_xq['choose'] = ' selected="selected"'; }; $editsurvey .= "\t<li><label for=\"showXquestions\">".$clang->gT('Show "There are X questions in this survey"')."</label>\n" . "\t\t<select id=\"showXquestions\" name=\"showXquestions\">\n" . "\t\t\t<option value=\"show\"{$sel_xq['show']}>".$clang->gT('Yes')."</option>\n" . "\t\t\t<option value=\"hide\"{$sel_xq['hide']}>".$clang->gT('No')."</option>\n" . "\t\t\t<option value=\"choose\"{$sel_xq['choose']}>".$clang->gT('Survey admin can choose')."</option>\n" . "\t\t</select></li>\n"; unset($set_xq,$sel_xq); // showgroupinfo $set_gri=getGlobalSetting('showgroupinfo'); $sel_gri = array( 'both' => '' , 'choose' =>'' , 'description' => '' , 'name' => '' , 'none' => '' ); $sel_gri[$set_gri] = ' selected="selected"'; if( empty($sel_gri['both']) && empty($sel_gri['choose']) && empty($sel_gri['description']) && empty($sel_gri['name']) && empty($sel_gri['none'])) { $sel_gri['choose'] = ' selected="selected"'; }; $editsurvey .= "\t<li><label for=\"showgroupinfo\">".$clang->gT('Show question group name and/or description')."</label>\n" . "\t\t<select id=\"showgroupinfo\" name=\"showgroupinfo\">\n" . "\t\t\t<option value=\"both\"{$sel_gri['both']}>".$clang->gT('Show both')."</option>\n" . "\t\t\t<option value=\"name\"{$sel_gri['name']}>".$clang->gT('Show group name only')."</option>\n" . "\t\t\t<option value=\"description\"{$sel_gri['description']}>".$clang->gT('Show group description only')."</option>\n" . "\t\t\t<option value=\"none\"{$sel_gri['none']}>".$clang->gT('Hide both')."</option>\n" . "\t\t\t<option value=\"choose\"{$sel_gri['choose']}>".$clang->gT('Survey admin can choose')."</option>\n" . "\t\t</select></li>\n"; unset($set_gri,$sel_gri); // showqnumcode $set_qnc=getGlobalSetting('showqnumcode'); $sel_qnc = array( 'both' => '' , 'choose' =>'' , 'number' => '' , 'code' => '' , 'none' => '' ); $sel_qnc[$set_qnc] = ' selected="selected"'; if( empty($sel_qnc['both']) && empty($sel_qnc['choose']) && empty($sel_qnc['number']) && empty($sel_qnc['code']) && empty($sel_qnc['none'])) { $sel_qnc['choose'] = ' selected="selected"'; }; $editsurvey .= "\t<li><label for=\"showqnumcode\">".$clang->gT('Show question number and/or question code')."</label>\n" . "\t\t<select id=\"showqnumcode\" name=\"showqnumcode\">\n" . "\t\t\t<option value=\"both\"{$sel_qnc['both']}>".$clang->gT('Show both')."</option>\n" . "\t\t\t<option value=\"number\"{$sel_qnc['number']}>".$clang->gT('Show question number only')."</option>\n" . "\t\t\t<option value=\"code\"{$sel_qnc['code']}>".$clang->gT('Show question code only')."</option>\n" . "\t\t\t<option value=\"none\"{$sel_qnc['none']}>".$clang->gT('Hide both')."</option>\n" . "\t\t\t<option value=\"choose\"{$sel_qnc['choose']}>".$clang->gT('Survey admin can choose')."</option>\n" . "\t\t</select></li>\n"; unset($set_qnc,$sel_qnc); $editsurvey .= "\t</ul>\n"; // End TAB page & form $editsurvey .= "\t</div><input type='hidden' name='action' value='globalsettingssave'/></form>\n"; // End tabs $editsurvey .= "</div>\n"; // The external button to sumbit Survey edit changes $editsurvey .= "\t<p><input type='button' onclick='$(\"#frmglobalsettings\").submit();' class='standardbtn' value='".$clang->gT("Save settings")."' /><br /></p>\n"; if ($demoModeOnly==true) { $editsurvey .= '<p>'.$clang->gT("Note: Demo mode is activated. Marked (*) settings can't be changed.").'</p>\n'; } } else { include("access_denied.php"); } } }