private function _refreshtemplates() { $template_a = getTemplateList(); foreach ($template_a as $tp => $fullpath) { // check for each folder if there is already an entry in the database // if not create it with current user as creator (user with rights "create user" can assign template rights) $result = Template::model()->findByPk($tp); if (count($result) == 0) { $post = new Template(); $post->folder = $tp; $post->creator = Yii::app()->session['loginID']; $post->save(); } } return true; }
><?php eT("Group by Group"); ?> </option> <option value='A' <?php if ($esrow['format'] == "A") { ?> selected='selected' <?php } ?> ><?php eT("All in one"); ?> </option> </select> </li> <li> <label for='template'><?php eT("Template:"); ?></label> <select id='template' name='template'> <?php foreach (array_keys(getTemplateList()) as $tname) { if (Permission::model()->hasGlobalPermission('superadmin','read') || Permission::model()->hasGlobalPermission('templates','read') || hasTemplateManageRights(Yii::app()->session["loginID"], $tname) == 1 || $esrow['template']==htmlspecialchars($tname) ) { ?> <option value='<?php echo $tname; ?>' <?php if ($esrow['template'] && htmlspecialchars($tname) == $esrow['template']) { ?> selected='selected' <?php } elseif (!$esrow['template'] && $tname == Yii::app()->getConfig('defaulttemplate')) { ?> selected='selected' <?php } ?> ><?php echo $tname; ?></option> <?php } } ?> </select> </li> <li><label for='preview'><?php eT("Template Preview:"); ?></label>
/** * Function that initialises all data and call other functions to load default view. * * @access protected * @param string $templatename * @param string $screenname * @param string $editfile * @param bool $showsummary * @return */ protected function _initialise($templatename, $screenname, $editfile, $showsummary = true) { App()->getClientScript()->reset(); $clang = $this->getController()->lang; Yii::app()->loadHelper('surveytranslator'); Yii::app()->loadHelper('admin/template'); $files = $this->_initfiles($templatename); $cssfiles = $this->_initcssfiles(); // Standard Support Files // These files may be edited or saved $supportfiles[] = array('name' => 'print_img_radio.png'); $supportfiles[] = array('name' => 'print_img_checkbox.png'); // Standard screens // Only these may be viewed $screens[] = array('name' => $clang->gT('Survey List Page'), 'id' => 'surveylist'); $screens[] = array('name' => $clang->gT('Welcome Page'), 'id' => 'welcome'); $screens[] = array('name' => $clang->gT('Question Page'), 'id' => 'question'); $screens[] = array('name' => $clang->gT('Completed Page'), 'id' => 'completed'); $screens[] = array('name' => $clang->gT('Clear All Page'), 'id' => 'clearall'); $screens[] = array('name' => $clang->gT('Register Page'), 'id' => 'register'); $screens[] = array('name' => $clang->gT('Load Page'), 'id' => 'load'); $screens[] = array('name' => $clang->gT('Save Page'), 'id' => 'save'); $screens[] = array('name' => $clang->gT('Print answers page'), 'id' => 'printanswers'); $screens[] = array('name' => $clang->gT('Printable survey page'), 'id' => 'printablesurvey'); // Page display blocks $SurveyList = array('startpage.pstpl', 'surveylist.pstpl', 'endpage.pstpl'); $Welcome = array('startpage.pstpl', 'welcome.pstpl', 'privacy.pstpl', 'navigator.pstpl', 'endpage.pstpl'); $Question = array('startpage.pstpl', 'survey.pstpl', 'startgroup.pstpl', 'groupdescription.pstpl', 'question.pstpl', 'endgroup.pstpl', 'navigator.pstpl', 'endpage.pstpl'); $CompletedTemplate = array('startpage.pstpl', 'assessment.pstpl', 'completed.pstpl', 'endpage.pstpl'); $Clearall = array('startpage.pstpl', 'clearall.pstpl', 'endpage.pstpl'); $Register = array('startpage.pstpl', 'survey.pstpl', 'register.pstpl', 'endpage.pstpl'); $Save = array('startpage.pstpl', 'save.pstpl', 'endpage.pstpl'); $Load = array('startpage.pstpl', 'load.pstpl', 'endpage.pstpl'); $printtemplate = array('startpage.pstpl', 'printanswers.pstpl', 'endpage.pstpl'); $printablesurveytemplate = array('print_survey.pstpl', 'print_group.pstpl', 'print_question.pstpl'); $file_version = "LimeSurvey template editor " . Yii::app()->getConfig('versionnumber'); Yii::app()->session['s_lang'] = Yii::app()->session['adminlang']; $templatename = sanitize_dirname($templatename); $screenname = autoUnescape($screenname); // Checks if screen name is in the list of allowed screen names if (multiarray_search($screens, 'id', $screenname) === false) { $this->getController()->error('Invalid screen name'); } if (!isset($action)) { $action = sanitize_paranoid_string(returnGlobal('action')); } if (!isset($subaction)) { $subaction = sanitize_paranoid_string(returnGlobal('subaction')); } if (!isset($newname)) { $newname = sanitize_dirname(returnGlobal('newname')); } if (!isset($copydir)) { $copydir = sanitize_dirname(returnGlobal('copydir')); } if (is_file(Yii::app()->getConfig('usertemplaterootdir') . '/' . $templatename . '/question_start.pstpl')) { $files[] = array('name' => 'question_start.pstpl'); $Question[] = 'question_start.pstpl'; } $availableeditorlanguages = array('bg', 'cs', 'de', 'dk', 'en', 'eo', 'es', 'fi', 'fr', 'hr', 'it', 'ja', 'mk', 'nl', 'pl', 'pt', 'ru', 'sk', 'zh'); $extension = substr(strrchr($editfile, "."), 1); if ($extension == 'css' || $extension == 'js') { $highlighter = $extension; } else { $highlighter = 'html'; } if (in_array(Yii::app()->session['adminlang'], $availableeditorlanguages)) { $codelanguage = Yii::app()->session['adminlang']; } else { $codelanguage = 'en'; } $templates = getTemplateList(); if (!isset($templates[$templatename])) { $templatename = Yii::app()->getConfig('defaulttemplate'); } $normalfiles = array("DUMMYENTRY", ".", "..", "preview.png"); foreach ($files as $fl) { $normalfiles[] = $fl["name"]; } foreach ($cssfiles as $fl) { $normalfiles[] = $fl["name"]; } // Some global data $aData['sitename'] = Yii::app()->getConfig('sitename'); $siteadminname = Yii::app()->getConfig('siteadminname'); $siteadminemail = Yii::app()->getConfig('siteadminemail'); // Set this so common.php doesn't throw notices about undefined variables $thissurvey['active'] = 'N'; // FAKE DATA FOR TEMPLATES $thissurvey['name'] = $clang->gT("Template Sample"); $thissurvey['description'] = "<p>" . $clang->gT('This is a sample survey description. It could be quite long.') . "</p>" . "<p>" . $clang->gT("But this one isn't.") . "<p>"; $thissurvey['welcome'] = "<p>" . $clang->gT('Welcome to this sample survey') . "<p>" . "<p>" . $clang->gT('You should have a great time doing this') . "<p>"; $thissurvey['allowsave'] = "Y"; $thissurvey['active'] = "Y"; $thissurvey['tokenanswerspersistence'] = "Y"; $thissurvey['templatedir'] = $templatename; $thissurvey['format'] = "G"; $thissurvey['surveyls_url'] = "http://www.limesurvey.org/"; $thissurvey['surveyls_urldescription'] = $clang->gT("Some URL description"); $thissurvey['usecaptcha'] = "A"; $percentcomplete = makegraph(6, 10); $groupname = $clang->gT("Group 1: The first lot of questions"); $groupdescription = $clang->gT("This group description is fairly vacuous, but quite important."); $navigator = $this->getController()->render('/admin/templates/templateeditor_navigator_view', array('screenname' => $screenname, 'clang' => $clang), true); $completed = $this->getController()->render('/admin/templates/templateeditor_completed_view', array('clang' => $clang), true); $assessments = $this->getController()->render('/admin/templates/templateeditor_assessments_view', array('clang' => $clang), true); $printoutput = $this->getController()->render('/admin/templates/templateeditor_printoutput_view', array('clang' => $clang), true); $totalquestions = '10'; $surveyformat = 'Format'; $notanswered = '5'; $privacy = ''; $surveyid = '1295'; $token = 1234567; $templatedir = getTemplatePath($templatename); $templateurl = getTemplateURL($templatename); // Save these variables in an array $aData['thissurvey'] = $thissurvey; $aData['percentcomplete'] = $percentcomplete; $aData['groupname'] = $groupname; $aData['groupdescription'] = $groupdescription; $aData['navigator'] = $navigator; $aData['help'] = $clang->gT("This is some help text."); $aData['surveyformat'] = $surveyformat; $aData['totalquestions'] = $totalquestions; $aData['completed'] = $completed; $aData['notanswered'] = $notanswered; $aData['privacy'] = $privacy; $aData['surveyid'] = $surveyid; $aData['sid'] = $surveyid; $aData['token'] = $token; $aData['assessments'] = $assessments; $aData['printoutput'] = $printoutput; $aData['templatedir'] = $templatedir; $aData['templateurl'] = $templateurl; $aData['templatename'] = $templatename; $aData['screenname'] = $screenname; $aData['editfile'] = $editfile; $myoutput[] = ""; switch ($screenname) { case 'surveylist': unset($files); $surveylist = array("nosid" => $clang->gT("You have not provided a survey identification number"), "contact" => sprintf($clang->gT("Please contact %s ( %s ) for further assistance."), Yii::app()->getConfig("siteadminname"), Yii::app()->getConfig("siteadminemail")), "listheading" => $clang->gT("The following surveys are available:"), "list" => $this->getController()->render('/admin/templates/templateeditor_surveylist_view', array(), true)); $aData['surveylist'] = $surveylist; $myoutput[] = ""; foreach ($SurveyList as $qs) { $files[] = array("name" => $qs); $myoutput = array_merge($myoutput, doreplacement(getTemplatePath($templatename) . "/{$qs}", $aData)); } break; case 'question': unset($files); foreach ($Question as $qs) { $files[] = array("name" => $qs); } $myoutput[] = $this->getController()->render('/admin/templates/templateeditor_question_meta_view', array('clang' => $clang), true); $myoutput = array_merge($myoutput, doreplacement(getTemplatePath($templatename) . "/startpage.pstpl", $aData)); $myoutput = array_merge($myoutput, doreplacement(getTemplatePath($templatename) . "/survey.pstpl", $aData)); $myoutput = array_merge($myoutput, doreplacement(getTemplatePath($templatename) . "/startgroup.pstpl", $aData)); $myoutput = array_merge($myoutput, doreplacement(getTemplatePath($templatename) . "/groupdescription.pstpl", $aData)); $question = array('all' => $clang->gT("How many roads must a man walk down?"), 'text' => $clang->gT("How many roads must a man walk down?"), 'code' => '1a', 'help' => 'helpful text', 'mandatory' => $clang->gT("*"), 'man_class' => ' mandatory', 'man_message' => '', 'valid_message' => '', 'file_valid_message' => '', 'essentials' => 'id="question1"', 'class' => 'list-radio', 'input_error_class' => '', 'number' => '1', 'type' => 'L'); $aData['question'] = $question; $answer = $this->getController()->render('/admin/templates/templateeditor_question_answer_view', array('clang' => $clang), true); $aData['answer'] = $answer; $myoutput = array_merge($myoutput, doreplacement(getTemplatePath($templatename) . "/question.pstpl", $aData)); $answer = $this->getController()->render('/admin/templates/templateeditor_question_answer_view', array('alt' => true, 'clang' => $clang), true); $aData['answer'] = $answer; $question = array('all' => $clang->gT("Please explain something in detail:"), 'text' => $clang->gT('Please explain something in detail:'), 'code' => '2a', 'help' => '', 'mandatory' => '', 'man_message' => '', 'valid_message' => '', 'file_valid_message' => '', 'essentials' => 'id="question2"', 'class' => 'text-long', 'man_class' => 'mandatory', 'input_error_class' => '', 'number' => '2', 'type' => 'T'); $aData['question'] = $question; $myoutput = array_merge($myoutput, doreplacement(getTemplatePath($templatename) . "/question.pstpl", $aData)); $myoutput = array_merge($myoutput, doreplacement(getTemplatePath($templatename) . "/endgroup.pstpl", $aData)); $myoutput = array_merge($myoutput, doreplacement(getTemplatePath($templatename) . "/navigator.pstpl", $aData)); $myoutput = array_merge($myoutput, doreplacement(getTemplatePath($templatename) . "/endpage.pstpl", $aData)); break; case 'welcome': unset($files); $myoutput[] = ""; foreach ($Welcome as $qs) { $files[] = array("name" => $qs); $myoutput = array_merge($myoutput, doreplacement(getTemplatePath($templatename) . "/{$qs}", $aData)); } break; case 'register': unset($files); foreach ($Register as $qs) { $files[] = array("name" => $qs); } $myoutput[] = templatereplace(file_get_contents("{$templatedir}/startpage.pstpl"), array(), $aData); $myoutput[] = templatereplace(file_get_contents("{$templatedir}/survey.pstpl"), array(), $aData); $myoutput[] = templatereplace(file_get_contents("{$templatedir}/register.pstpl"), array(), $aData); $myoutput[] = templatereplace(file_get_contents("{$templatedir}/endpage.pstpl"), array(), $aData); $myoutput[] = "\n"; break; case 'save': unset($files); foreach ($Save as $qs) { $files[] = array("name" => $qs); } $myoutput[] = templatereplace(file_get_contents("{$templatedir}/startpage.pstpl"), array(), $aData); $myoutput[] = templatereplace(file_get_contents("{$templatedir}/save.pstpl"), array(), $aData); $myoutput[] = templatereplace(file_get_contents("{$templatedir}/endpage.pstpl"), array(), $aData); $myoutput[] = "\n"; break; case 'load': unset($files); foreach ($Load as $qs) { $files[] = array("name" => $qs); } $myoutput[] = templatereplace(file_get_contents("{$templatedir}/startpage.pstpl"), array(), $aData); $myoutput[] = templatereplace(file_get_contents("{$templatedir}/load.pstpl"), array(), $aData); $myoutput[] = templatereplace(file_get_contents("{$templatedir}/endpage.pstpl"), array(), $aData); $myoutput[] = "\n"; break; case 'clearall': unset($files); foreach ($Clearall as $qs) { $files[] = array("name" => $qs); } $myoutput[] = templatereplace(file_get_contents("{$templatedir}/startpage.pstpl"), array(), $aData); $myoutput[] = templatereplace(file_get_contents("{$templatedir}/clearall.pstpl"), array(), $aData); $myoutput[] = templatereplace(file_get_contents("{$templatedir}/endpage.pstpl"), array(), $aData); $myoutput[] = "\n"; break; case 'completed': unset($files); $myoutput[] = ""; foreach ($CompletedTemplate as $qs) { $files[] = array("name" => $qs); $myoutput = array_merge($myoutput, doreplacement(getTemplatePath($templatename) . "/{$qs}", $aData)); } break; case 'printablesurvey': unset($files); foreach ($printablesurveytemplate as $qs) { $files[] = array("name" => $qs); } $questionoutput = array(); foreach (file("{$templatedir}/print_question.pstpl") as $op) { $questionoutput[] = templatereplace($op, array('QUESTION_NUMBER' => '1', 'QUESTION_CODE' => 'Q1', 'QUESTION_MANDATORY' => $clang->gT('*'), 'QUESTION_SCENARIO' => 'Only answer this if certain conditions are met.', 'QUESTION_CLASS' => ' mandatory list-radio', 'QUESTION_TYPE_HELP' => $clang->gT('Please choose *only one* of the following:'), 'QUESTION_MAN_MESSAGE' => '', 'QUESTION_VALID_MESSAGE' => '', 'QUESTION_FILE_VALID_MESSAGE' => '', 'QUESTION_TEXT' => $clang->gT('This is a sample question text. The user was asked to pick an entry.'), 'QUESTIONHELP' => $clang->gT('This is some help text for this question.'), 'ANSWER' => $this->getController()->render('/admin/templates/templateeditor_printablesurvey_quesanswer_view', array('templateurl' => $templateurl, 'clang' => $clang), true)), $aData); } $groupoutput = array(); $groupoutput[] = templatereplace(file_get_contents("{$templatedir}/print_group.pstpl"), array('QUESTIONS' => implode(' ', $questionoutput)), $aData); $myoutput[] = templatereplace(file_get_contents("{$templatedir}/print_survey.pstpl"), array('GROUPS' => implode(' ', $groupoutput), 'FAX_TO' => $clang->gT("Please fax your completed survey to:") . " 000-000-000", 'SUBMIT_TEXT' => $clang->gT("Submit your survey."), 'HEADELEMENTS' => getPrintableHeader(), 'SUBMIT_BY' => sprintf($clang->gT("Please submit by %s"), date('d.m.y')), 'THANKS' => $clang->gT('Thank you for completing this survey.'), 'END' => $clang->gT('This is the survey end message.')), $aData); break; case 'printanswers': unset($files); foreach ($printtemplate as $qs) { $files[] = array("name" => $qs); } $myoutput[] = templatereplace(file_get_contents("{$templatedir}/startpage.pstpl"), array(), $aData); $myoutput[] = templatereplace(file_get_contents("{$templatedir}/printanswers.pstpl"), array('ANSWERTABLE' => $printoutput), $aData); $myoutput[] = templatereplace(file_get_contents("{$templatedir}/endpage.pstpl"), array(), $aData); $myoutput[] = "\n"; break; } $myoutput[] = "</html>"; if (is_array($files)) { $match = 0; foreach ($files as $f) { if ($editfile == $f["name"]) { $match = 1; } } foreach ($cssfiles as $f) { if ($editfile == $f["name"]) { $match = 1; } } if ($match == 0) { if (count($files) > 0) { $editfile = $files[0]["name"]; } else { $editfile = ""; } } } // Get list of 'otherfiles' $otherfiles = array(); if ($handle = opendir($templatedir)) { while (false !== ($file = readdir($handle))) { if (!array_search($file, $normalfiles)) { if (!is_dir($templatedir . DIRECTORY_SEPARATOR . $file)) { $otherfiles[] = array("name" => $file); } } } closedir($handle); } $aData['clang'] = $this->getController()->lang; $aData['codelanguage'] = $codelanguage; $aData['highlighter'] = $highlighter; $aData['screens'] = $screens; $aData['templatename'] = $templatename; $aData['templates'] = $templates; $aData['editfile'] = $editfile; $aData['screenname'] = $screenname; $aData['tempdir'] = Yii::app()->getConfig('tempdir'); $aData['usertemplaterootdir'] = Yii::app()->getConfig('usertemplaterootdir'); $aViewUrls['templateeditorbar_view'][] = $aData; if ($showsummary) { $aViewUrls = array_merge($aViewUrls, $this->_templatesummary($templatename, $screenname, $editfile, $templates, $files, $cssfiles, $otherfiles, $myoutput)); } App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('adminscripts') . 'admin_core.js'); return $aViewUrls; }
?> </p></div> <div id='general'> <ul> <li><label for='sitename'><?php $clang->eT("Site name:") . (Yii::app()->getConfig("demoMode") == true ? '*' : ''); ?> </label> <input type='text' size='50' id='sitename' name='sitename' value="<?php echo htmlspecialchars(getGlobalSetting('sitename')); ?> " /></li> <?php $thisdefaulttemplate = getGlobalSetting('defaulttemplate'); $templatenames = array_keys(getTemplateList()); ?> <li><label for="defaulttemplate"><?php $clang->eT("Default template:"); ?> </label> <select name="defaulttemplate" id="defaulttemplate"> <?php foreach ($templatenames as $templatename) { echo "<option value='{$templatename}'"; if ($thisdefaulttemplate == $templatename) { echo " selected='selected' "; } echo ">{$templatename}</option>"; }
<?php /* Preparing some array /* Template list : find User template, allways add existing template */ $aTemplateOptions=array(); foreach (array_keys(getTemplateList()) as $sTemplateName) { if(Permission::model()->hasTemplatePermission($sTemplateName) || htmlspecialchars($sTemplateName) == $esrow['template']) $aTemplateOptions[$sTemplateName]=$sTemplateName; } /* showxquestion */ $sValShowxquestions=$esrow['showxquestions']; switch (Yii::app()->getConfig('showxquestions')) { case 'show': $aShowxquestionsOptions=array("Y"=>gT('Yes (Forced by the system administrator)','unescaped')); $bDisableShowxquestions=true; $sValShowxquestions="Y"; break; case 'hide': $aShowxquestionsOptions=array("N"=>gT('No (Forced by the system administrator)','unescaped')); $bDisableShowxquestions=true; $sValShowxquestions="N"; break; case 'choose': default: $aShowxquestionsOptions=array("Y"=>gT("Yes",'unescaped'),"N"=>gT("No",'unescaped')); $bDisableShowxquestions=false; break; } /* showgroupinfo */ $sValShowgroupinfo=$esrow['showgroupinfo'];
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); } }
/** * Defines the customs validation rule tmplfilter * * @param mixed $attribute * @param mixed $params */ public function tmplfilter($attribute, $params) { if (!array_key_exists($this->{$attribute}, getTemplateList())) { $this->{$attribute} = 'default'; } }
/** * @return bool true if the operation was successfull false otherwise * * @access public */ function saveElement($regroup) { if ($regroup == 'templ_man') { return $this->_saveTemplateManager(); } if ($regroup == 'suiteman') { return $this->_saveSuiteManager(); } $reSetting = sql_query("\r\n\t\tSELECT param_name, value_type, extra_info\r\n\t\tFROM " . $this->table . "\r\n\t\tWHERE regroup = '" . $regroup . "' AND hide_in_modify = '0'"); $re = true; while (list($var_name, $value_type, $extra_info) = sql_fetch_row($reSetting)) { switch ($value_type) { case "menuvoice": require_once $GLOBALS['where_framework'] . '/lib/lib.menu.php'; $menu_man = new MenuManager(); if (isset($_POST['option'][$var_name]) && $_POST['option'][$var_name] == 1) { $menu_man->addPerm(ADMIN_GROUP_GODADMIN, '/lms/admin' . $extra_info); $new_value = 1; } else { $menu_man->removePerm(ADMIN_GROUP_GODADMIN, '/lms/admin' . $extra_info); $new_value = 0; } break; case "menuvoice_course_public": $after_reload_perm = true; require_once $GLOBALS['where_framework'] . '/lib/lib.menu.php'; $menu_man = new MenuManager(); if (isset($_POST['option'][$var_name]) && $_POST['option'][$var_name] == 1) { $perm = explode(';', $extra_info); foreach ($perm as $k => $perm_suffix) { $menu_man->addPerm('/oc_0', '/lms/course' . trim($perm_suffix)); } $new_value = 1; } else { $perm = explode(';', $extra_info); foreach ($perm as $k => $perm_suffix) { $menu_man->removePerm('/oc_0', '/lms/course' . trim($perm_suffix)); } $new_value = 0; } break; case "tablist_coursecatalogue": $tab_selected = array(); foreach ($_POST['tablist'] as $tab_code => $v) { $tab_selected[$tab_code] = 1; } $new_value = urlencode(serialize($tab_selected)); break; case "tablist_mycourses": $temp_arr = array(); for ($i = 0; $i < 3; $i++) { $temp_var = $_POST['mycourses'][$i]; if ($temp_var != '' && !in_array($temp_var, $temp_arr)) { //avoid repeated params $temp_arr[] = $temp_var; } } $new_value = implode(',', $temp_arr); break; //if is int cast it //if is int cast it case "language": $lang = Docebo::langManager()->getAllLangCode(); $new_value = $lang[$_POST['option'][$var_name]]; break; case "template": $templ = getTemplateList(); $new_value = $templ[$_POST['option'][$var_name]]; break; case "int": $new_value = (int) $_POST['option'][$var_name]; break; //if is enum switch value to on or off //if is enum switch value to on or off case "enum": if (isset($_POST['option'][$var_name])) { $new_value = 'on'; } else { $new_value = 'off'; } break; case "check": if (isset($_POST['option'][$var_name]) && $_POST['option'][$var_name] == 1) { $new_value = 1; } else { $new_value = 0; } break; case "menuvoice": require_once $GLOBALS['where_framework'] . '/lib/lib.menu.php'; $menu_man = new MenuManager(); if (isset($_POST['option'][$var_name]) && $_POST['option'][$var_name] == 1) { $menu_man->addPerm(ADMIN_GROUP_GODADMIN, '/framework/admin' . $extra_info); $new_value = 1; } else { $menu_man->removePerm(ADMIN_GROUP_GODADMIN, '/framework/admin' . $extra_info); $new_value = 0; } break; //else simple assignament //else simple assignament default: $new_value = $_POST['option'][$var_name]; } if (!sql_query("UPDATE " . $this->table . "\r\n\t\t\tSET param_value = '{$new_value}'\r\n\t\t\tWHERE param_name = '{$var_name}' AND regroup = '" . $regroup . "'")) { $re = false; } } return $re; }
/** * @return bool true if the operation was successfull false otherwise * * @access public */ function saveElement($regroup) { if ($regroup == 'root') { return $this->_setRoot(); } $reSetting = sql_query("\r\n\t\tSELECT param_name, value_type, extra_info \r\n\t\tFROM " . $this->table . " \r\n\t\tWHERE regroup = '" . $regroup . "' AND \r\n\t\t\thide_in_modify = '0'"); $re = true; while (list($var_name, $value_type, $extra_info) = sql_fetch_row($reSetting)) { switch ($value_type) { //if is int cast it case "template": $templ = getTemplateList(); $new_value = $templ[$_POST['option'][$var_name]]; break; case "int": $new_value = (int) $_POST['option'][$var_name]; break; //if is enum switch value to on or off //if is enum switch value to on or off case "enum": if (isset($_POST['option'][$var_name])) { $new_value = 'on'; } else { $new_value = 'off'; } break; case "check": if (isset($_POST['option'][$var_name]) && $_POST['option'][$var_name] == 1) { $new_value = 1; } else { $new_value = 0; } break; //else simple assignament //else simple assignament default: $new_value = $_POST['option'][$var_name]; } if (!sql_query("\r\n\t\t\tUPDATE " . $this->table . " \r\n\t\t\tSET param_value = '{$new_value}' \r\n\t\t\tWHERE param_name = '{$var_name}' AND regroup = '" . $regroup . "'")) { $re = false; } } return $re; }
/** * @param array $array_source save the preferences of a user * @param string $base_path if specified load only preference form this base_path * * @return nothing */ function savePreferences($array_source, $base_path = false) { $info_pref = $this->_up_db->getFullPreferences($this->id_user, true, false, $base_path); if (!isset($array_source[$this->base_name])) { return true; } if (!is_array($array_source[$this->base_name])) { return true; } $re = true; while (list(, $pref) = each($info_pref)) { if (isset($array_source[$this->base_name][$pref['path_name']])) { $new_value = $array_source[$this->base_name][$pref['path_name']]; } else { $new_value = NULL; } switch ($pref['type']) { case "language": $langs = Docebo::langManager()->getAllLangCode(); $re &= $this->setLanguage($langs[$new_value]); break; case "template": $templ = getTemplateList(); $re &= $this->setTemplate($templ[$new_value]); break; case "enum": if ($new_value == NULL) { $re &= $this->setPreference($pref['path_name'], 'off'); } else { $re &= $this->setPreference($pref['path_name'], 'on'); } break; default: $re &= $this->setPreference($pref['path_name'], $new_value); } } return $re; }
/** * Function that initialises all data and call other functions to load default view. * * @access protected * @param string $templatename * @param string $screenname * @param string $editfile * @param bool $showsummary * @return */ protected function _initialise($templatename, $screenname, $editfile, $showsummary = true, $useindex = false) { // LimeSurvey style global $oEditedTemplate; $oEditedTemplate = Template::model()->getTemplateConfiguration($templatename); // In survey mode, bootstrap is loaded via the app init. // From template editor, we just add the bootstrap files to the js/css to load for template_helper::templatereplace() if ($oEditedTemplate->cssFramework == 'bootstrap') { // Core templates (are published only if exists) $oEditedTemplate->config->files->css->filename[] = "../../styles-public/bootstrap-for-template-editor.css"; $oEditedTemplate->config->files->js->filename[] = "../../scripts/bootstrap-for-template-editor.js"; // User templates (are published only if exists) $oEditedTemplate->config->files->css->filename[] = "../../../styles-public/bootstrap-for-template-editor.css"; $oEditedTemplate->config->files->js->filename[] = "../../../scripts/bootstrap-for-template-editor.js"; } //App()->getClientScript()->reset(); Yii::app()->loadHelper('surveytranslator'); Yii::app()->loadHelper('admin/template'); $files = $this->_initfiles($templatename); $cssfiles = $this->_initcssfiles($oEditedTemplate); // Standard Support Files // These files may be edited or saved $supportfiles[] = array('name' => 'print_img_radio.png'); $supportfiles[] = array('name' => 'print_img_checkbox.png'); // Standard screens // Only these may be viewed $screens[] = array('name' => gT('Survey List Page'), 'id' => 'surveylist'); $screens[] = array('name' => gT('Welcome Page'), 'id' => 'welcome'); $screens[] = array('name' => gT('Question Page'), 'id' => 'question'); $screens[] = array('name' => gT('Completed Page'), 'id' => 'completed'); $screens[] = array('name' => gT('Clear All Page'), 'id' => 'clearall'); $screens[] = array('name' => gT('Register Page'), 'id' => 'register'); $screens[] = array('name' => gT('Load Page'), 'id' => 'load'); $screens[] = array('name' => gT('Save Page'), 'id' => 'save'); $screens[] = array('name' => gT('Print answers page'), 'id' => 'printanswers'); $screens[] = array('name' => gT('Printable survey page'), 'id' => 'printablesurvey'); // Page display blocks $SurveyList = array('startpage.pstpl', 'surveylist.pstpl', 'endpage.pstpl'); $Welcome = array('startpage.pstpl', 'welcome.pstpl', 'privacy.pstpl', 'navigator.pstpl', 'endpage.pstpl'); $Question = array('startpage.pstpl', 'survey.pstpl', 'startgroup.pstpl', 'groupdescription.pstpl', 'question.pstpl', 'endgroup.pstpl', 'navigator.pstpl', 'endpage.pstpl'); $CompletedTemplate = array('startpage.pstpl', 'assessment.pstpl', 'completed.pstpl', 'endpage.pstpl'); $Clearall = array('startpage.pstpl', 'clearall.pstpl', 'endpage.pstpl'); $Register = array('startpage.pstpl', 'survey.pstpl', 'register.pstpl', 'endpage.pstpl'); $Save = array('startpage.pstpl', 'save.pstpl', 'endpage.pstpl'); $Load = array('startpage.pstpl', 'load.pstpl', 'endpage.pstpl'); $printtemplate = array('startpage.pstpl', 'printanswers.pstpl', 'endpage.pstpl'); $printablesurveytemplate = array('print_survey.pstpl', 'print_group.pstpl', 'print_question.pstpl'); $file_version = "LimeSurvey template editor " . Yii::app()->getConfig('versionnumber'); Yii::app()->session['s_lang'] = Yii::app()->session['adminlang']; $templatename = sanitize_dirname($templatename); $screenname = autoUnescape($screenname); // Checks if screen name is in the list of allowed screen names if (multiarray_search($screens, 'id', $screenname) === false) { Yii::app()->user->setFlash('error', gT('Invalid screen name')); $this->getController()->redirect(array("admin/templates/sa/upload")); } if (!isset($action)) { $action = sanitize_paranoid_string(returnGlobal('action')); } if (!isset($subaction)) { $subaction = sanitize_paranoid_string(returnGlobal('subaction')); } if (!isset($newname)) { $newname = sanitize_dirname(returnGlobal('newname')); } if (!isset($copydir)) { $copydir = sanitize_dirname(returnGlobal('copydir')); } if (is_file(Yii::app()->getConfig('usertemplaterootdir') . '/' . $templatename . '/question_start.pstpl')) { $files[] = array('name' => 'question_start.pstpl'); $Question[] = 'question_start.pstpl'; } $editfile = sanitize_filename($editfile); // Fixed with editable file after, but put in aData before fix $availableeditorlanguages = array('bg', 'cs', 'de', 'dk', 'en', 'eo', 'es', 'fi', 'fr', 'hr', 'it', 'ja', 'mk', 'nl', 'pl', 'pt', 'ru', 'sk', 'zh'); // 2.06 way of doing. if (!$useindex) { $extension = substr(strrchr($editfile, "."), 1); } else { // The extension is now set as a prefix separated by a _ $file_datas = explode("_", $editfile); $extension = $file_datas[0]; // The file name is now based on the index of the oTemplate files $file_index = $file_datas[1]; switch ($extension) { case 'css': $aTemplateFiles = (array) $oEditedTemplate->config->files_editable->css->filename; break; case 'js': $aTemplateFiles = (array) $oEditedTemplate->config->files_editable->js->filename; break; default: $aTemplateFiles = (array) $oEditedTemplate->config->files_editable->css->filename; break; } $editfile = $aTemplateFiles[$file_index]; } if ($extension == 'css' || $extension == 'js') { $highlighter = $extension; } else { $highlighter = 'html'; } if (in_array(Yii::app()->session['adminlang'], $availableeditorlanguages)) { $codelanguage = Yii::app()->session['adminlang']; } else { $codelanguage = 'en'; } $templates = getTemplateList(); if (!isset($templates[$templatename])) { $templatename = Yii::app()->getConfig('defaulttemplate'); } $normalfiles = array("DUMMYENTRY", ".", "..", "preview.png"); foreach ($files as $fl) { $normalfiles[] = $fl["name"]; } foreach ($cssfiles as $fl) { $normalfiles[] = $fl["name"]; } // Some global data $aData['sitename'] = Yii::app()->getConfig('sitename'); $siteadminname = Yii::app()->getConfig('siteadminname'); $siteadminemail = Yii::app()->getConfig('siteadminemail'); // Set this so common.php doesn't throw notices about undefined variables $thissurvey['active'] = 'N'; // FAKE DATA FOR TEMPLATES $thissurvey['name'] = gT("Template Sample"); $thissurvey['description'] = "<p>" . gT('This is a sample survey description. It could be quite long.') . "</p>" . "<p>" . gT("But this one isn't.") . "<p>"; $thissurvey['welcome'] = "<p>" . gT('Welcome to this sample survey') . "<p>" . "<p>" . gT('You should have a great time doing this') . "<p>"; $thissurvey['allowsave'] = "Y"; $thissurvey['active'] = "Y"; $thissurvey['tokenanswerspersistence'] = "Y"; $thissurvey['templatedir'] = $templatename; $thissurvey['format'] = "G"; $thissurvey['surveyls_url'] = "http://www.limesurvey.org/"; $thissurvey['surveyls_urldescription'] = gT("Some URL description"); $thissurvey['usecaptcha'] = "A"; $percentcomplete = makegraph(6, 10); $groupname = gT("Group 1: The first lot of questions"); $groupdescription = gT("This group description is fairly vacuous, but quite important."); $navigator = $this->getController()->render('/admin/templates/templateeditor_navigator_view', array('screenname' => $screenname), true); $completed = $this->getController()->render('/admin/templates/templateeditor_completed_view', array(), true); $assessments = $this->getController()->render('/admin/templates/templateeditor_assessments_view', array(), true); $printoutput = $this->getController()->render('/admin/templates/templateeditor_printoutput_view', array(), true); $totalquestions = '10'; $surveyformat = 'Format'; $notanswered = '5'; $privacy = ''; $surveyid = '1295'; $token = 1234567; $templatedir = $oEditedTemplate->viewPath; $templateurl = getTemplateURL($templatename); // Save these variables in an array $aData['thissurvey'] = $thissurvey; $aData['percentcomplete'] = $percentcomplete; $aData['groupname'] = $groupname; $aData['groupdescription'] = $groupdescription; $aData['navigator'] = $navigator; $aData['help'] = gT("This is some help text."); $aData['surveyformat'] = $surveyformat; $aData['totalquestions'] = $totalquestions; $aData['completed'] = $completed; $aData['notanswered'] = $notanswered; $aData['privacy'] = $privacy; $aData['surveyid'] = $surveyid; $aData['sid'] = $surveyid; $aData['token'] = $token; $aData['assessments'] = $assessments; $aData['printoutput'] = $printoutput; $aData['templatedir'] = $templatedir; $aData['templateurl'] = $templateurl; $aData['templatename'] = $templatename; $aData['screenname'] = $screenname; $aData['editfile'] = $editfile; $myoutput[] = ""; switch ($screenname) { case 'surveylist': unset($files); $surveylist = array("nosid" => gT("You have not provided a survey identification number"), "contact" => sprintf(gT("Please contact %s ( %s ) for further assistance."), Yii::app()->getConfig("siteadminname"), Yii::app()->getConfig("siteadminemail")), "listheading" => gT("The following surveys are available:"), "list" => $this->getController()->render('/admin/templates/templateeditor_surveylist_view', array(), true)); $aData['surveylist'] = $surveylist; $myoutput[] = ""; //$myoutput[] = templatereplace(file_get_contents("$templatedir/startpage.pstpl"), array(), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate); foreach ($SurveyList as $qs) { $files[] = array("name" => $qs); $myoutput = array_merge($myoutput, doreplacement($oEditedTemplate->viewPath . "/{$qs}", $aData, $oEditedTemplate)); } break; case 'question': unset($files); foreach ($Question as $qs) { $files[] = array("name" => $qs); } $myoutput[] = $this->getController()->render('/admin/templates/templateeditor_question_meta_view', array(), true); $aData['aReplacements'] = array('SAVE_LINKS' => '<li><a href="#" id="saveallbtnlink">Resume later</a></li>', 'CLEARALL_LINKS' => '<li><a href="#" id="clearallbtnlink">' . gT("Exit and clear survey") . '</a></li>'); $myoutput = array_merge($myoutput, doreplacement($oEditedTemplate->viewPath . "/startpage.pstpl", $aData, $oEditedTemplate)); $myoutput = array_merge($myoutput, doreplacement($oEditedTemplate->viewPath . "/survey.pstpl", $aData, $oEditedTemplate)); $myoutput = array_merge($myoutput, doreplacement($oEditedTemplate->viewPath . "/startgroup.pstpl", $aData, $oEditedTemplate)); $myoutput = array_merge($myoutput, doreplacement($oEditedTemplate->viewPath . "/groupdescription.pstpl", $aData, $oEditedTemplate)); $aReplacements = array('QUESTION_TEXT' => gT("How many roads must a man walk down?"), 'QUESTION_CODE' => '1a', 'QUESTIONHELP' => 'helpful text', 'QUESTION_MANDATORY' => gT("*"), 'QUESTION_MAN_CLASS' => ' mandatory', 'QUESTION_ESSENTIALS' => 'id="question1"', 'QUESTION_CLASS' => 'list-radio', 'QUESTION_NUMBER' => '1'); $aReplacements['ANSWER'] = $this->getController()->render('/admin/templates/templateeditor_question_answer_view', array(), true); $aData['aReplacements'] = $aReplacements; $myoutput = array_merge($myoutput, doreplacement($oEditedTemplate->viewPath . "/question.pstpl", $aData, $oEditedTemplate)); $aReplacements = array('QUESTION_TEXT' => gT('Please explain something in detail:'), 'QUESTION_CODE' => '2a', 'QUESTION_ESSENTIALS' => 'id="question2"', 'QUESTION_CLASS' => 'text-long', 'QUESTION_NUMBER' => '2'); $aReplacements['ANSWER'] = $this->getController()->render('/admin/templates/templateeditor_question_answer_view', array('alt' => true), true); $aData['aReplacements'] = $aReplacements; $myoutput = array_merge($myoutput, doreplacement($oEditedTemplate->viewPath . "/question.pstpl", $aData, $oEditedTemplate)); $myoutput = array_merge($myoutput, doreplacement($oEditedTemplate->viewPath . "/endgroup.pstpl", $aData, $oEditedTemplate)); $aData['aReplacements'] = array('MOVEPREVBUTTON' => '<button type="submit" id="moveprevbtn" value="moveprev" name="moveprev" accesskey="p" class="submit button btn btn-default btn-lg ">Previous</button>', 'MOVENEXTBUTTON' => '<button type="submit" id="movenextbtn" value="movenext" name="movenext" accesskey="n" class="submit button btn btn-default btn-lg ">Next</button>'); $myoutput = array_merge($myoutput, doreplacement($oEditedTemplate->viewPath . "/navigator.pstpl", $aData, $oEditedTemplate)); $myoutput = array_merge($myoutput, doreplacement($oEditedTemplate->viewPath . "/endpage.pstpl", $aData, $oEditedTemplate)); break; case 'welcome': unset($files); foreach ($Welcome as $qs) { $files[] = array("name" => $qs); $myoutput = array_merge($myoutput, doreplacement($oEditedTemplate->viewPath . "/{$qs}", $aData, $oEditedTemplate)); } /* $myoutput = array_merge($myoutput, doreplacement($oEditedTemplate->viewPath . "/startpage.pstpl", $aData, $oEditedTemplate)); $myoutput = array_merge($myoutput, doreplacement($oEditedTemplate->viewPath . "/welcome.pstpl", $aData, $oEditedTemplate)); $myoutput = array_merge($myoutput, doreplacement($oEditedTemplate->viewPath . "/privacy.pstpl", $aData, $oEditedTemplate)); */ $aData['aReplacements'] = array('MOVENEXTBUTTON' => '<button type="submit" id="movenextbtn" value="movenext" name="movenext" accesskey="n" class="submit button btn btn-default btn-lg">Next</button>'); $myoutput = array_merge($myoutput, doreplacement($oEditedTemplate->viewPath . "/navigator.pstpl", $aData, $oEditedTemplate)); $myoutput = array_merge($myoutput, doreplacement($oEditedTemplate->viewPath . "/endpage.pstpl", $aData, $oEditedTemplate)); break; case 'register': unset($files); foreach ($Register as $qs) { $files[] = array("name" => $qs); } $myoutput[] = templatereplace(file_get_contents("{$templatedir}/startpage.pstpl"), array(), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate); $aData = array('aReplacements' => array('SURVEYNAME' => 'Survey name')); $myoutput = array_merge($myoutput, doreplacement($oEditedTemplate->viewPath . "/survey.pstpl", $aData, $oEditedTemplate)); $aData['aReplacements'] = array('REGISTERERROR' => 'Example error message', 'REGISTERMESSAGE1' => 'Register message 1', 'REGISTERMESSAGE2' => 'Register message 2', 'REGISTERFORM' => $this->getController()->render('/admin/templates/templateeditor_register_view', array('alt' => true), true)); $myoutput = array_merge($myoutput, doreplacement($oEditedTemplate->viewPath . "/register.pstpl", $aData, $oEditedTemplate)); $myoutput[] = templatereplace(file_get_contents("{$templatedir}/endpage.pstpl"), array(), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate); $myoutput[] = "\n"; break; case 'save': unset($files); foreach ($Save as $qs) { $files[] = array("name" => $qs); } $myoutput[] = templatereplace(file_get_contents("{$templatedir}/startpage.pstpl"), array(), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate); $myoutput[] = templatereplace(file_get_contents("{$templatedir}/save.pstpl"), array(), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate); $myoutput[] = templatereplace(file_get_contents("{$templatedir}/endpage.pstpl"), array(), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate); $myoutput[] = "\n"; break; case 'load': unset($files); foreach ($Load as $qs) { $files[] = array("name" => $qs); } $myoutput[] = templatereplace(file_get_contents("{$templatedir}/startpage.pstpl"), array(), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate); $myoutput[] = templatereplace(file_get_contents("{$templatedir}/load.pstpl"), array(), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate); $myoutput[] = templatereplace(file_get_contents("{$templatedir}/endpage.pstpl"), array(), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate); $myoutput[] = "\n"; break; case 'clearall': unset($files); foreach ($Clearall as $qs) { $files[] = array("name" => $qs); } $myoutput[] = templatereplace(file_get_contents("{$templatedir}/startpage.pstpl"), array(), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate); $myoutput[] = templatereplace(file_get_contents("{$templatedir}/clearall.pstpl"), array(), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate); $myoutput[] = templatereplace(file_get_contents("{$templatedir}/endpage.pstpl"), array(), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate); $myoutput[] = "\n"; break; case 'completed': unset($files); $myoutput[] = ""; foreach ($CompletedTemplate as $qs) { $files[] = array("name" => $qs); $myoutput = array_merge($myoutput, doreplacement($oEditedTemplate->viewPath . "/{$qs}", $aData, $oEditedTemplate)); } break; case 'printablesurvey': unset($files); foreach ($printablesurveytemplate as $qs) { $files[] = array("name" => $qs); } $questionoutput = array(); foreach (file("{$templatedir}/print_question.pstpl") as $op) { $questionoutput[] = templatereplace($op, array('QUESTION_NUMBER' => '1', 'QUESTION_CODE' => 'Q1', 'QUESTION_MANDATORY' => gT('*'), 'QUESTION_SCENARIO' => 'Only answer this if certain conditions are met.', 'QUESTION_CLASS' => ' mandatory list-radio', 'QUESTION_TYPE_HELP' => gT('Please choose *only one* of the following:'), 'QUESTION_MAN_MESSAGE' => '', 'QUESTION_VALID_MESSAGE' => '', 'QUESTION_FILE_VALID_MESSAGE' => '', 'QUESTION_TEXT' => gT('This is a sample question text. The user was asked to pick an entry.'), 'QUESTIONHELP' => gT('This is some help text for this question.'), 'ANSWER' => $this->getController()->render('/admin/templates/templateeditor_printablesurvey_quesanswer_view', array('templateurl' => $templateurl), true)), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate); } $groupoutput = array(); $groupoutput[] = templatereplace(file_get_contents("{$templatedir}/print_group.pstpl"), array('QUESTIONS' => implode(' ', $questionoutput)), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate); $myoutput[] = templatereplace(file_get_contents("{$templatedir}/print_survey.pstpl"), array('GROUPS' => implode(' ', $groupoutput), 'FAX_TO' => gT("Please fax your completed survey to:") . " 000-000-000", 'SUBMIT_TEXT' => gT("Submit your survey."), 'HEADELEMENTS' => getPrintableHeader(), 'SUBMIT_BY' => sprintf(gT("Please submit by %s"), date('d.m.y')), 'THANKS' => gT('Thank you for completing this survey.'), 'END' => gT('This is the survey end message.')), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate); break; case 'printanswers': unset($files); foreach ($printtemplate as $qs) { $files[] = array("name" => $qs); } $myoutput[] = templatereplace(file_get_contents("{$templatedir}/startpage.pstpl"), array(), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate); $myoutput[] = templatereplace(file_get_contents("{$templatedir}/printanswers.pstpl"), array('ANSWERTABLE' => $printoutput), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate); $myoutput[] = templatereplace(file_get_contents("{$templatedir}/endpage.pstpl"), array(), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate); $myoutput[] = "\n"; break; } $myoutput[] = "</html>"; $jsfiles = $this->_getEditableJsFiles($oEditedTemplate); if (is_array($files)) { $match = 0; foreach ($files as $f) { if ($editfile == $f["name"]) { $match = 1; } } $aCssAndJsfiles = array_merge($cssfiles, $jsfiles); foreach ($aCssAndJsfiles as $f) { if ($editfile == $f["name"]) { $match = 1; } } if ($match == 0) { if (count($files) > 0) { $editfile = $files[0]["name"]; } else { $editfile = ""; } } } // Get list of 'otherfiles' // We can't use $oTemplate->otherFiles, because of retrocompatibility with 2.06 template and the big mess of it mixing files $filesdir = $oEditedTemplate->filesPath != '' ? $oEditedTemplate->filesPath : $templatedir . '../files'; $otherfiles = array(); if (file_exists($filesdir) && ($handle = opendir($filesdir))) { while (false !== ($file = readdir($handle))) { if (!array_search($file, $normalfiles)) { if (!is_dir($templatedir . DIRECTORY_SEPARATOR . $file)) { $otherfiles[] = array("name" => $file); } } } closedir($handle); } $aData['codelanguage'] = $codelanguage; $aData['highlighter'] = $highlighter; $aData['screens'] = $screens; $aData['templatename'] = $templatename; $aData['templates'] = $templates; $aData['editfile'] = $editfile; $aData['screenname'] = $screenname; $aData['tempdir'] = Yii::app()->getConfig('tempdir'); $aData['usertemplaterootdir'] = Yii::app()->getConfig('usertemplaterootdir'); $aViewUrls['templateeditorbar_view'][] = $aData; if ($showsummary) { //$aCssfileseditable = (array) $oEditedTemplate->config->files_editable->css->filename; $aViewUrls = array_merge($aViewUrls, $this->_templatesummary($templatename, $screenname, $editfile, $templates, $files, $cssfiles, $jsfiles, $otherfiles, $myoutput)); } App()->getClientScript()->registerScriptFile(App()->getAssetManager()->publish(ADMIN_SCRIPT_PATH . 'admin_core.js')); return $aViewUrls; }
<?php $body = ""; $languages = Docebo::langManager()->getAllLanguages(true); //getAllLangCode(); $std_lang = getLanguage(); $body .= Form::openForm('addfolder_form', "ajax.adm_server.php?r=" . $this->link . "/createfolder"); $body .= Form::getHidden('addfolder_id_parent', 'id_parent', $id_parent); $body .= Form::getTextfield(Lang::t('_CODE', 'organization_chart'), 'org_code', 'org_code', 50); $body .= Form::getDropdown(Lang::t('_DEFAULTTEMPLATE', 'configuration'), 'associated_template', 'associated_template', getTemplateList(), $default_template); $body .= Form::getBreakRow(); foreach ($languages as $language) { $lang_code = $language['code']; $lang_name = $language['description']; $body .= Form::getTextfield($lang_code, 'newfolder_' . $lang_code, 'langs[' . $lang_code . ']', 255); } $body .= Form::closeForm(); if (isset($json)) { $output['header'] = $title; $output['body'] = $body; echo $json->encode($output); } else { echo '<h2>' . $title . '</h2>'; echo $body; }
$aSettingsUpdate[$sName] = array('type' => 'link', 'label' => $sLabel, 'text' => gt("Use ComfortUpdate"), 'link' => $this->createUrl("admin/update", array('sa' => 'index', 'build' => $aUpdateVersion['build'])), 'htmlOptions' => array('class' => 'button', 'target' => '_top'), 'help' => sprintf(gT('You can %s and % manually or use the %s'), CHtml::link(gT("download"), $sDownloadLink, array('target' => '_blank')), CHtml::link(gT("update"), "http://manual.limesurvey.org/Upgrading_from_a_previous_version", array('target' => '_blank')), CHtml::link(gT("3-Click ComfortUpdate"), "http://manual.limesurvey.org/ComfortUpdate", array('target' => '_blank')))); } } elseif (isset($updateinfo['errorcode'])) { $aSettingsUpdate['updateavailable'] = array('type' => 'info', 'label' => sprintf(gT('There was an error on update check (%s)'), $updateinfo['errorcode']), 'content' => CHtml::tag('pre', array(), strip_tags($updateinfo['errorhtml']))); } elseif ($updatable) { $aSettingsUpdate['updateavailable'] = array('type' => 'info', 'content' => gT('There is currently no newer LimeSurvey version available.')); } else { $aSettingsUpdate['updateavailable'] = array('type' => 'info', 'content' => sprintf(gT('This is an unstable version and cannot be updated using ComfortUpdate. Please check %s regularly for a newer version.'), CHtml::link(gT("our website"), "http://www.limesurvey.org"))); } $this->widget('ext.SettingsWidget.SettingsWidget', array('title' => gt("Updates"), 'form' => false, 'formHtmlOptions' => array('class' => 'form-core'), 'inlist' => true, 'settings' => $aSettingsUpdate)); ?> </div> <?php // General seetings in one part // Preparing array $aTemplateNames = array_keys(getTemplateList()); $aAdminThemes = array_keys(getAdminThemeList()); $dateformatdata = getDateFormatData(Yii::app()->session['dateformat']); $aGeneralSettings = array('info_general' => array(), 'sitename' => array('type' => 'string', 'label' => gT("Site name") . $sStringDemoMode, 'labelOptions' => array('class' => $sClassDemoMode), 'current' => getGlobalSetting('sitename'), 'htmlOptions' => array('readonly' => $bDemoMode)), 'defaulttemplate' => array('type' => 'select', 'label' => gT('Default template') . $sStringDemoMode, 'labelOptions' => array('class' => $sClassDemoMode), 'htmlOptions' => array('readonly' => $bDemoMode), 'options' => array_combine($aTemplateNames, $aTemplateNames), 'current' => Template::templateNameFilter(getGlobalSetting('defaulttemplate'))), 'admintheme' => array('type' => 'select', 'label' => gT('Administration template') . $sStringDemoMode, 'labelOptions' => array('class' => $sClassDemoMode), 'htmlOptions' => array('readonly' => $bDemoMode), 'options' => array_combine($aAdminThemes, $aAdminThemes), 'current' => getGlobalSetting('admintheme')), 'defaulthtmleditormode' => array('type' => 'select', 'label' => gT('Default HTML editor mode') . $sStringDemoMode, 'labelOptions' => array('class' => $sClassDemoMode), 'htmlOptions' => array('readonly' => $bDemoMode), 'options' => array('none' => gT("No HTML editor", 'unescaped'), 'inline' => gT("Inline HTML editor (default)", 'unescaped'), 'popup' => gT("Popup HTML editor", 'unescaped')), 'current' => getGlobalSetting('defaulthtmleditormode')), 'defaultquestionselectormode' => array('type' => 'select', 'label' => gT('Question type selector') . $sStringDemoMode, 'labelOptions' => array('class' => $sClassDemoMode), 'htmlOptions' => array('readonly' => $bDemoMode), 'options' => array('default' => gT("Full selector (default)", 'unescaped'), 'none' => gT("Simple selector", 'unescaped')), 'current' => getGlobalSetting('defaultquestionselectormode')), 'defaulttemplateeditormode' => array('type' => 'select', 'label' => gT('Template editor') . $sStringDemoMode, 'labelOptions' => array('class' => $sClassDemoMode), 'htmlOptions' => array('readonly' => $bDemoMode), 'options' => array('default' => gT("Full template editor (default)", 'unescaped'), 'none' => gT("Simple template editor", 'unescaped')), 'current' => getGlobalSetting('defaulttemplateeditormode')), 'timeadjust' => array('type' => 'float', 'label' => gt("Time difference (in hours)"), 'current' => str_replace(array('+', ' hours', ' minutes'), array('', '', ''), getGlobalSetting('timeadjust')) / 60, 'help' => sprintf(gT("Server time: %s - Corrected time: %s"), convertDateTimeFormat(date('Y-m-d H:i:s'), 'Y-m-d H:i:s', $dateformatdata['phpdate'] . ' H:i'), convertDateTimeFormat(dateShift(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'))), 'iSessionExpirationTime' => array(), 'GeoNamesUsername' => array('type' => 'string', 'label' => 'GeoNames username for API', 'current' => getGlobalSetting('GeoNamesUsername'), 'htmlOptions' => array('size' => '35')), 'googleMapsAPIKey' => array('type' => 'string', 'label' => 'Google Maps API key', 'current' => getGlobalSetting('googleMapsAPIKey'), 'htmlOptions' => array('size' => '35')), 'ipInfoDbAPIKey' => array('type' => 'string', 'label' => 'IP Info DB API Key', 'current' => getGlobalSetting('ipInfoDbAPIKey'), 'htmlOptions' => array('size' => '35')), 'googleanalyticsapikey' => array('type' => 'string', 'label' => 'Google Analytics API key', 'current' => getGlobalSetting('googleanalyticsapikey'), 'htmlOptions' => array('size' => '35')), 'googletranslateapikey' => array('type' => 'string', 'label' => 'Google Translate API key', 'current' => getGlobalSetting('googletranslateapikey'), 'htmlOptions' => array('size' => '35'))); if (isset(Yii::app()->session->connectionID)) { $aGeneralSettings["iSessionExpirationTime"] = array('type' => 'int', 'label' => 'Session lifetime for surveys (seconds)', 'current' => getGlobalSetting('iSessionExpirationTime'), 'htmlOptions' => array('style' => 'width:10em', 'min' => 1)); } if ($bDemoMode) { $aGeneralSettings['info_general'] = array('type' => 'info', 'class' => 'alert', 'label' => gt("Note"), 'content' => gt("Demo mode is activated. Some settings can't be changed.")); } $this->widget('ext.SettingsWidget.SettingsWidget', array('id' => 'general', 'form' => false, 'formHtmlOptions' => array('class' => 'form-core'), 'inlist' => true, 'settings' => $aGeneralSettings)); ?> <div id='email'> <?php // Email in 2 part : User and SMTP
/** * Search for the default template * @return string the default template saved in database */ function getDefaultTemplate($platform = false) { $plat_templ = Get::sett('defaultTemplate'); if (is_dir(_base_ . '/templates/' . $plat_templ)) { return $plat_templ; } else { return array_pop(getTemplateList()); } }
$region = CAT_Helper_Validate::get('_REQUEST', 'template'); $tpl = 'backend_settings_index_' . $region . '.tpl'; $data = getSettingsTable(); $tpl_data = array('values' => $data); $tpl_data['DISPLAY_ADVANCED'] = $users->checkPermission('Settings', 'settings_advanced'); switch ($region) { case 'frontend': $tpl_data['templates'] = getTemplateList('frontend'); $tpl_data['variants'] = array(); $info = CAT_Helper_Addons::checkInfo(CAT_PATH . '/templates/' . CAT_Registry::get('DEFAULT_TEMPLATE')); if (isset($info['module_variants']) && is_array($info['module_variants']) && count($info['module_variants'])) { $tpl_data['variants'] = $info['module_variants']; } break; case 'backend': $tpl_data['backends'] = getTemplateList('backend'); $tpl_data['wysiwyg'] = CAT_Helper_Addons::get_addons(CAT_Registry::get('WYSIWYG_EDITOR'), 'module', 'wysiwyg'); $tpl_data['variants'] = array(); $info = CAT_Helper_Addons::checkInfo(CAT_PATH . '/templates/' . CAT_Registry::get('DEFAULT_THEME')); if (isset($info['module_variants']) && is_array($info['module_variants']) && count($info['module_variants'])) { $tpl_data['variants'] = $info['module_variants']; } break; case 'system': $tpl_data['er_levels'] = getErrorLevels(); $tpl_data['PAGES_LIST'] = getPagesList('maintenance_page', CAT_Registry::get('MAINTENANCE_PAGE')); $tpl_data['ERR_PAGES_LIST'] = getPagesList('err_page_404', CAT_Registry::get('ERR_PAGE_404')); break; case 'users': $tpl_data['groups'] = $users->get_groups(CAT_Registry::get('FRONTEND_SIGNUP'), '', false); break;
public function modfolder() { //check permissions if (!$this->permissions['mod_org']) { $output = array('success' => false, 'message' => $this->_getErrorMessage('no permission')); echo $this->json->encode($output); return; } $output = array(); $id = Get::req('node_id', DOTY_INT, -1); $code = Get::req('org_code', DOTY_STRING, ''); $template_id = Get::req('associated_template', DOTY_INT, ''); $template_arr = getTemplateList(); $langs = Get::req('modfolder', DOTY_MIXED, false); $res = $this->model->modFolderCodeAndTemplate($id, $code, $template_arr[$template_id]); $res = $this->model->renameFolder($id, $langs); if ($res) { $output['success'] = true; //$output['new_name'] = ($code != "" ? '['.$code.'] ' : '').$langs[getLanguage()]; $output['new_name'] = $this->_formatFolderCode($id, $code) . $langs[getLanguage()]; } else { $output['success'] = false; $output['message'] = Lang::t('_CONNECTION_ERROR'); } echo $this->json->encode($output); }