diff --git a/application/commands/DemomodeCommand.php b/application/commands/DemomodeCommand.php new file mode 100644 index 00000000000..393168df601 --- /dev/null +++ b/application/commands/DemomodeCommand.php @@ -0,0 +1,139 @@ +_resetDatabase(); + echo "|| Resetting Files\n"; + $this->_resetFiles(); + echo "|| Installing demo surveys\n"; + $this->_createDemo(); + echo "##### Done recreating demo state #####\n"; + } else { + // TODO: a valid error process + echo 'This CLI command wipes a LimeSurvey installation clean (including all user except for the user ID 1 and user-uploaded content). For security reasons this command can only started if you add the parameter \'yes\' to the command line.'; + } + + } + + private function _resetDatabase(){ + Yii::import('application.helpers.common_helper', true); + Yii::import('application.helpers.database_helper', true); + + //Truncate most of the tables + $truncatableTables = ['{{assessments}}','{{answers}}','{{conditions}}','{{defaultvalues}}','{{labels}}','{{labelsets}}','{{groups}}','{{questions}}','{{surveys}}','{{surveys_languagesettings}}','{{quota}}','{{quota_members}}','{{quota_languagesettings}}','{{question_attributes}}','{{quota}}','{{quota_members}}','{{quota_languagesettings}}','{{question_attributes}}','{{user_groups}}','{{user_in_groups}}','{{templates}}','{{template_configuration}}','{{participants}}','{{participant_attribute_names}}','{{participant_attribute_names_lang}}','{{participant_attribute_values}}','{{participant_shares}}','{{settings_user}}','{{failed_login_attempts}}','{{saved_control}}','{{survey_links}}']; + foreach($truncatableTables as $table){ + $actquery = "truncate table ".$table; + Yii::app()->db->createCommand($actquery)->execute(); + } + //Now delete the basics in all other tables + $actquery = "delete from {{permissions}} where uid<>1"; + Yii::app()->db->createCommand($actquery)->execute(); + $actquery = "delete from {{users}} where uid<>1"; + Yii::app()->db->createCommand($actquery)->execute(); + $actquery = "update {{users}} set lang='en'"; + Yii::app()->db->createCommand($actquery)->execute(); + $actquery = "update {{users}} set lang='auto'"; + Yii::app()->db->createCommand($actquery)->execute(); + $actquery = "delete from {{settings_global}} where stg_name LIKE 'last_question%'"; + Yii::app()->db->createCommand($actquery)->execute(); + $actquery = "delete from {{settings_global}} where stg_name LIKE 'last_survey%'"; + Yii::app()->db->createCommand($actquery)->execute(); + $actquery = "update {{users}} set email = 'test@domain.test', full_name='Administrator'"; + Yii::app()->db->createCommand($actquery)->execute(); + $actquery = "update {{settings_global}} set stg_value='' where stg_name='googleanalyticsapikey' or stg_name='googleMapsAPIKey' or stg_name='googletranslateapikey' or stg_name='ipInfoDbAPIKey' or stg_name='pdfheadertitle' or stg_name='pdfheaderstring'"; + Yii::app()->db->createCommand($actquery)->execute(); + $actquery = "update {{settings_global}} set stg_value='test@domain.test' where stg_name='siteadminbounce' or stg_name='siteadminemail'"; + Yii::app()->db->createCommand($actquery)->execute(); + $actquery = "update {{settings_global}} set stg_value='Administrator' where stg_name='siteadminname'"; + Yii::app()->db->createCommand($actquery)->execute(); + $actquery = "update {{settings_global}} set stg_value='Sea_Green' where stg_name='admintheme'"; + Yii::app()->db->createCommand($actquery)->execute(); + + $surveyidresult = dbGetTablesLike("tokens%"); + foreach ($surveyidresult as $sv) { + Yii::app()->db->createCommand("drop table ".$sv)->execute(); + } + + $surveyidresult = dbGetTablesLike("old\_%"); + foreach ($surveyidresult as $sv) { + Yii::app()->db->createCommand("drop table ".$sv)->execute(); + } + + $surveyidresult = dbGetTablesLike("survey\_%"); + foreach ($surveyidresult as $sv) { + if (strpos($sv, 'survey_links') === false && strpos($sv, 'survey_url_parameters') === false) { + Yii::app()->db->createCommand("drop table ".$sv)->execute(); + } + } + + // At last reset the basic themes + foreach($templateData=LsDefaultDataSets::getTemplatesData() as $template){ + Yii::app()->db->createCommand()->insert("{{templates}}", $template ); + } + foreach($templateConfigurationData=LsDefaultDataSets::getTemplateConfigurationData() as $templateConfiguration){ + Yii::app()->db->createCommand()->insert("{{template_configuration}}", $templateConfiguration ); + } + } + + private function _resetFiles(){ + + $sBaseUploadDir = dirname(dirname(dirname(__FILE__))).DIRECTORY_SEPARATOR.'upload'; + + SureRemoveDir($sBaseUploadDir.DIRECTORY_SEPARATOR.'surveys', false); + SureRemoveDir($sBaseUploadDir.DIRECTORY_SEPARATOR.'templates', false); + SureRemoveDir($sBaseUploadDir.DIRECTORY_SEPARATOR.'themes'.DIRECTORY_SEPARATOR.'survey', false); + SureRemoveDir($sBaseUploadDir.DIRECTORY_SEPARATOR.'themes'.DIRECTORY_SEPARATOR.'question', false); + } + + private function _createDemo(){ + Yii::app()->loadHelper('admin/import'); + require_once(dirname(dirname(dirname(__FILE__))).'/application/helpers/expressions/em_manager_helper.php'); + + Yii::app()->session->add( 'loginID', 1 ); + $documentationSurveyPath = dirname(dirname(dirname(__FILE__))).DIRECTORY_SEPARATOR.'docs'.DIRECTORY_SEPARATOR.'demosurveys'.DIRECTORY_SEPARATOR; + $aSamplesurveys = scandir($documentationSurveyPath); + foreach($aSamplesurveys as $sSamplesurvey) { + @XMLImportSurvey($documentationSurveyPath.$sSamplesurvey); + } + } + +} + + +function SureRemoveDir($dir, $DeleteMe) +{ + if (!$dh = @opendir($dir)) { + return; + } + while (false !== ($obj = readdir($dh))) { + if ($obj == '.' || $obj == '..') { + continue; + } + if (!@unlink($dir.'/'.$obj)) { + SureRemoveDir($dir.'/'.$obj, true); + } + } + closedir($dh); + if ($DeleteMe) { + if (!@rmdir($dir)) { + echo "Error: could not delete ".$dir; + } + + } +} diff --git a/application/commands/WipeCommand.php b/application/commands/WipeCommand.php index 003b3fce5fb..561aa001664 100644 --- a/application/commands/WipeCommand.php +++ b/application/commands/WipeCommand.php @@ -56,6 +56,8 @@ public function run($sArgument) Yii::app()->db->createCommand($actquery)->execute(); $actquery = "truncate table {{templates}}"; Yii::app()->db->createCommand($actquery)->execute(); + $actquery = "truncate table {{template_configuration}}"; + Yii::app()->db->createCommand($actquery)->execute(); $actquery = "truncate table {{participants}}"; Yii::app()->db->createCommand($actquery)->execute(); $actquery = "truncate table {{participant_attribute_names}}"; @@ -93,6 +95,13 @@ public function run($sArgument) $actquery = "update {{settings_global}} set stg_value='Sea_Green' where stg_name='admintheme'"; Yii::app()->db->createCommand($actquery)->execute(); + foreach($templateData=LsDefaultDataSets::getTemplatesData() as $template){ + Yii::app()->db->createCommand()->insert("{{templates}}", $template ); + } + foreach($templateConfigurationData=LsDefaultDataSets::getTemplateConfigurationData() as $templateConfiguration){ + Yii::app()->db->createCommand()->insert("{{template_configuration}}", $templateConfiguration ); + } + $surveyidresult = dbGetTablesLike("tokens%"); foreach ($surveyidresult as $sv) { Yii::app()->db->createCommand("drop table ".$sv)->execute(); @@ -113,6 +122,8 @@ public function run($sArgument) SureRemoveDir($sBaseUploadDir.DIRECTORY_SEPARATOR.'surveys', false); SureRemoveDir($sBaseUploadDir.DIRECTORY_SEPARATOR.'templates', false); + SureRemoveDir($sBaseUploadDir.DIRECTORY_SEPARATOR.'themes'.DIRECTORY_SEPARATOR.'survey', false); + SureRemoveDir($sBaseUploadDir.DIRECTORY_SEPARATOR.'themes'.DIRECTORY_SEPARATOR.'question', false); } else { // TODO: a valid error process echo 'This CLI command wipes a LimeSurvey installation clean (including all user except for the user ID 1 and user-uploaded content). For security reasons this command can only started if you add the parameter \'yes\' to the command line.'; diff --git a/application/commands/console.php b/application/commands/console.php index 52b618d3c27..e58458cc3fc 100644 --- a/application/commands/console.php +++ b/application/commands/console.php @@ -25,6 +25,10 @@ $sCurrentDir = dirname(__FILE__); $settings = require (dirname($sCurrentDir).DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config-defaults.php'); $config = require (dirname($sCurrentDir).DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'internal.php'); + $config['components']['session']['class'] = 'ConsoleHttpSession'; + $config['components']['session']['cookieMode'] = 'none'; + $config['components']['session']['cookieParams'] = []; + $core = dirname($sCurrentDir).DIRECTORY_SEPARATOR.'core'.DIRECTORY_SEPARATOR; if (isset($config['config'])) { $settings = array_merge($settings, $config['config']); diff --git a/application/config/fonts.php b/application/config/fonts.php new file mode 100644 index 00000000000..329208ddf0d --- /dev/null +++ b/application/config/fonts.php @@ -0,0 +1,88 @@ + 2 , seems really an core dev issue to fix bootstrap.js ;) */ +$minVersion = ($debug > 0) ? "" : ".min"; +/* needed ? @see third_party.php */ +if (isset($_GET['isAjax'])) { + return array(); +} +return array( + + 'fontawesome' => array( + //'basePath' => 'third_party.bootstrap', // Need fix third_party alias + 'devBaseUrl' => 'assets/fonts/font-src/fontawesome/', + 'basePath' => 'fonts.font-src.fontawesome', + 'css'=> array( + 'css/font-awesome'.$minVersion.'.css', + ), + ), + + 'font-roboto' => array( + 'devBaseUrl' => 'assets/fonts/', + 'basePath' => 'fonts', + 'css' => array( + 'roboto.css', + ), + ), + + 'font-icomoon' => array( + 'devBaseUrl' => 'assets/fonts/', + 'basePath' => 'fonts', + 'css' => array( + 'icomoon.css', + ), + ), + + 'font-noto' => array( + 'devBaseUrl' => 'assets/fonts/', + 'basePath' => 'fonts', + 'css' => array( + 'noto.css', + ), + ), + + 'font-news_cycle' => array( + 'devBaseUrl' => 'assets/fonts/', + 'basePath' => 'fonts', + 'css' => array( + 'news_cycle.css', + ), + ), + + 'font-ubuntu' => array( + 'devBaseUrl' => 'assets/fonts/', + 'basePath' => 'fonts', + 'css' => array( + 'ubuntu.css', + ), + ), + + 'font-lato' => array( + 'devBaseUrl' => 'assets/fonts/', + 'basePath' => 'fonts', + 'css' => array( + 'lato.css', + ), + ), + + // see: https://www.w3schools.com/cssref/css_websafe_fonts.asp + 'font-websafe' => array( + 'devBaseUrl' => 'assets/fonts/', + 'basePath' => 'fonts', + 'css' => array( + 'websafe.css', + ), + ), + +); diff --git a/application/config/internal.php b/application/config/internal.php index 6b87dd8084d..2a9bb74a1ce 100644 --- a/application/config/internal.php +++ b/application/config/internal.php @@ -108,7 +108,9 @@ 'clientScript'=>array( 'packages' => array_merge( require('third_party.php'), - require('packages.php') + require('packages.php'), + require('questiontypes.php'), + require('fonts.php') ), 'class' => 'application.core.LSYii_ClientScript' ), @@ -241,12 +243,13 @@ 'imageSrc' => 'LS_Twig_Extension::imageSrc', 'sprintf' => 'sprintf', 'gT' => 'gT', + 'ngT' => 'ngT', 'createUrl' => 'LS_Twig_Extension::createUrl', 'json_decode' => 'LS_Twig_Extension::json_decode', ), 'filters' => array( 'jencode' => 'CJSON::encode', - 't' => 'eT', + 't' => 'gT', 'gT' => 'gT', ), @@ -257,6 +260,7 @@ 'ETwigViewRendererStaticClassProxy' => array("encode", "textfield", "form", "link", "emailField", "beginForm", "endForm", "dropDownList", "htmlButton", "passwordfield"), 'Survey' => array("getAllLanguages", "localizedtitle"), 'LSHttpRequest' => array("getParam"), + 'LSCaptcha' => array("renderOut") ), 'properties' => array( 'ETwigViewRendererYiiCoreStaticClassesProxy' => array("Html"), @@ -266,7 +270,7 @@ 'Question' => array('qid', 'parent_qid', 'sid', 'gid', 'type', 'title', 'question', 'help', 'other', 'mandatory', 'language', 'scale_qid'), 'QuestionGroups' => array('gid', 'sid', 'group_name', 'group_order', 'description', 'language', 'randomization_group', 'grelevance') ), - 'functions' => array('include', 'dump', 'flatEllipsizeText', 'getLanguageData', 'array_flip', 'array_intersect_key', 'registerPublicCssFile', 'registerTemplateCssFile', 'registerGeneralScript', 'registerTemplateScript', 'registerScript', 'registerPackage', 'unregisterPackage', 'registerCssFile', 'registerScriptFile', 'unregisterScriptFile', 'unregisterScriptForAjax', 'listCoreScripts', 'listScriptFiles', 'getAllQuestionClasses', 'intval', 'count', 'empty', 'reset', 'renderCaptcha', 'getPost', 'getParam', 'getQuery', 'isset', 'str_replace', 'assetPublish', 'image', 'imageSrc', 'sprintf', 'gT', 'createUrl', 'json_decode'), + 'functions' => array('include', 'dump', 'flatEllipsizeText', 'getLanguageData', 'array_flip', 'array_intersect_key', 'registerPublicCssFile', 'registerTemplateCssFile', 'registerGeneralScript', 'registerTemplateScript', 'registerScript', 'registerPackage', 'unregisterPackage', 'registerCssFile', 'registerScriptFile', 'unregisterScriptFile', 'unregisterScriptForAjax', 'listCoreScripts', 'listScriptFiles', 'getAllQuestionClasses', 'intval', 'count', 'empty', 'reset', 'renderCaptcha', 'getPost', 'getParam', 'getQuery', 'isset', 'str_replace', 'assetPublish', 'image', 'imageSrc', 'sprintf', 'gT', 'ngT', 'createUrl', 'json_decode'), ), ), diff --git a/application/config/packages.php b/application/config/packages.php index 18e5781b197..29ee0d13f10 100644 --- a/application/config/packages.php +++ b/application/config/packages.php @@ -79,37 +79,6 @@ 'bootstrap', ) ), - /* Ranking question type */ - 'question-ranking'=>array( - 'devBaseUrl' => 'assets/packages/questions/ranking/', - 'basePath' => 'core.questions.ranking', - 'position' => CClientScript::POS_BEGIN, - 'css'=> array( - 'css/ranking.css', - ), - 'js'=>array( - 'scripts/sortable.min.js', - 'scripts/ranking.js', - ), - 'depends' => array( - 'jquery', - ) - ), - /* numeric slider question : numerci question type with slider */ - 'question-numeric-slider'=>array( - 'devBaseUrl' => 'assets/packages/questions/numeric-slider/', - 'basePath' => 'core.questions.numeric-slider', - 'position' => CClientScript::POS_BEGIN, - 'css'=> array( - 'css/numeric-slider.css', - ), - 'js'=>array( - 'scripts/numeric-slider.js', - ), - 'depends' => array( - 'bootstrap-slider', - ) - ), 'ckeditor' => array( 'devBaseUrl' => 'assets/packages/ckeditor', 'basePath' => 'core.ckeditor', @@ -266,70 +235,6 @@ ) ), - 'font-roboto' => array( - 'devBaseUrl' => 'assets/fonts/', - 'basePath' => 'fonts', - 'position' =>CClientScript::POS_BEGIN, - 'css' => array( - 'roboto.css', - ), - ), - - 'font-icomoon' => array( - 'devBaseUrl' => 'assets/fonts/', - 'basePath' => 'fonts', - 'position' =>CClientScript::POS_BEGIN, - 'css' => array( - 'icomoon.css', - ), - ), - - 'font-noto' => array( - 'devBaseUrl' => 'assets/fonts/', - 'basePath' => 'fonts', - 'position' =>CClientScript::POS_BEGIN, - 'css' => array( - 'noto.css', - ), - ), - - 'font-news_cycle' => array( - 'devBaseUrl' => 'assets/fonts/', - 'basePath' => 'fonts', - 'position' =>CClientScript::POS_BEGIN, - 'css' => array( - 'news_cycle.css', - ), - ), - - 'font-ubuntu' => array( - 'devBaseUrl' => 'assets/fonts/', - 'basePath' => 'fonts', - 'position' =>CClientScript::POS_BEGIN, - 'css' => array( - 'ubuntu.css', - ), - ), - - 'font-lato' => array( - 'devBaseUrl' => 'assets/fonts/', - 'basePath' => 'fonts', - 'position' =>CClientScript::POS_BEGIN, - 'css' => array( - 'lato.css', - ), - ), - - // see: https://www.w3schools.com/cssref/css_websafe_fonts.asp - 'font-websafe' => array( - 'devBaseUrl' => 'assets/fonts/', - 'basePath' => 'fonts', - 'position' =>CClientScript::POS_BEGIN, - 'css' => array( - 'websafe.css', - ), - ), - 'surveymenufunctions' => array( 'devBaseUrl' => 'assets/packages/surveymenufunctions/', 'basePath' => 'core.surveymenufunctions', diff --git a/application/config/questiontypes.php b/application/config/questiontypes.php new file mode 100644 index 00000000000..2d6779ec533 --- /dev/null +++ b/application/config/questiontypes.php @@ -0,0 +1,97 @@ + 2 , seems really an core dev issue to fix bootstrap.js ;) */ +$minVersion = ($debug > 0) ? "" : ".min"; +/* needed ? @see third_party.php */ +if (isset($_GET['isAjax'])) { + return array(); +} +return array( + /* Ranking question type */ + 'question-ranking'=>array( + 'devBaseUrl' => 'assets/packages/questions/ranking/', + 'basePath' => 'core.questions.ranking', + 'position' => CClientScript::POS_BEGIN, + 'css'=> array( + 'css/ranking.css', + ), + 'js'=>array( + 'scripts/sortable.min.js', + 'scripts/ranking.js', + ), + 'depends' => array( + 'jquery', + ) + ), + /* numeric slider question : numerci question type with slider */ + 'question-numeric-slider'=>array( + 'devBaseUrl' => 'assets/packages/questions/numeric-slider/', + 'basePath' => 'core.questions.numeric-slider', + 'position' => CClientScript::POS_BEGIN, + 'css'=> array( + 'css/numeric-slider.css', + ), + 'js'=>array( + 'scripts/numeric-slider.js', + ), + 'depends' => array( + 'bootstrap-slider', + ) + ), + /* five point singlechoice slider rating question */ + 'question-5pointchoice-slider'=>array( + 'devBaseUrl' => 'assets/packages/questions/5pointchoice/', + 'basePath' => 'core.questions.5pointchoice', + 'position' => CClientScript::POS_BEGIN, + 'css'=> array( + 'css/slider-rating.css', + 'css/emoji.css', + 'css/ss-emoji.css' + ), + 'js'=>array( + 'scripts/slider-rating.js', + ) + ), + /* five point singlechoice star rating question */ + 'question-5pointchoice-star'=>array( + 'devBaseUrl' => 'assets/packages/questions/5pointchoice/', + 'basePath' => 'core.questions.5pointchoice', + 'position' => CClientScript::POS_BEGIN, + 'css'=> array( + 'css/star-rating.css', + ), + 'js'=>array( + 'scripts/star-rating.js', + ) + ), + /* file upload question */ + 'question-file-upload'=>array( + 'devBaseUrl' => 'assets/packages/questions/upload/', + 'basePath' => 'core.questions.upload', + 'position' => CClientScript::POS_BEGIN, + 'css'=> array( + 'css/uploader-file.css', + 'css/uploader.css', + ), + 'js'=>array( + 'scripts/uploadquestion'.$minVersion.'.js', + ), + 'depends' => [ + 'emoji' + ] + ), +); diff --git a/application/config/third_party.php b/application/config/third_party.php index 16c5d421689..52d08f06329 100755 --- a/application/config/third_party.php +++ b/application/config/third_party.php @@ -153,15 +153,6 @@ ) ), - 'fontawesome' => array( - //'basePath' => 'third_party.bootstrap', // Need fix third_party alias - 'devBaseUrl' => 'assets/fonts/font-src/fontawesome/', - 'basePath' => 'fonts.font-src.fontawesome', - 'css'=> array( - 'css/font-awesome'.$minVersion.'.css', - ), - ), - // jQuery UI 'jqueryui' => array( 'devBaseUrl' => 'third_party/jquery-ui', @@ -351,13 +342,6 @@ ), ), - 'emoji' => array( - 'basePath' => 'third_party.emojifont', - 'css' => array( - 'css/emoji.css', - 'css/ss-emoji.css' - ), - ), 'jquery-datatable' => array( 'basePath' => 'third_party.jquery-datatable', 'position' => CClientScript::POS_BEGIN, diff --git a/application/config/updater_version.php b/application/config/updater_version.php index 8e85f377f7c..8bfe90c4d82 100644 --- a/application/config/updater_version.php +++ b/application/config/updater_version.php @@ -15,7 +15,7 @@ // THIS FILE SHOULD NOT BE CHANGED MANUALLY ! -$config['updaterversion'] = 6; +$config['updaterversion'] = 8; $config['comfort_update_server_url'] = 'comfortupdate.limesurvey.org/'; //$config['comfort_update_server_url'] = 'web.comfortupdate.org/'; $config['comfort_update_server_ssl'] = 0; diff --git a/application/config/version.php b/application/config/version.php index f27813e87f1..55d8f683ec7 100644 --- a/application/config/version.php +++ b/application/config/version.php @@ -12,9 +12,9 @@ */ -$config['versionnumber'] = '3.0.3'; //The current version of this branch, LS3 -$config['dbversionnumber'] = 344; +$config['versionnumber'] = '3.0.5'; //The current version of this branch, LS3 +$config['dbversionnumber'] = 345; $config['buildnumber'] = ''; $config['updatable'] = true; -$config['assetsversionnumber'] = '30004'; +$config['assetsversionnumber'] = '30008'; return $config; diff --git a/application/controllers/AdminController.php b/application/controllers/AdminController.php index 7ecc0693798..72448b7f88c 100644 --- a/application/controllers/AdminController.php +++ b/application/controllers/AdminController.php @@ -105,10 +105,6 @@ protected function _sessioncontrol() Yii::app()->session["adminlang"] = Yii::app()->getConfig("defaultlang"); } Yii::app()->setLanguage(Yii::app()->session["adminlang"]); - - if (!empty($this->user_id)) { - $this->_GetSessionUserRights($this->user_id); - } } /** @@ -229,32 +225,6 @@ public function getActionClasses() ); } - /** - * Set Session User Rights - * - * @access public - * @return void - */ - public function _GetSessionUserRights($loginID) - { - $oUser = User::model()->findByPk($loginID); - - // SuperAdmins - // * original superadmin with uid=1 unless manually changed and defined - // in config-defaults.php - // * or any user having USER_RIGHT_SUPERADMIN right - - // Let's check if I am the Initial SuperAdmin - - $oUser = User::model()->findByAttributes(array('parent_id' => 0)); - - if (!is_null($oUser) && $oUser->uid == $loginID) { - Yii::app()->session['USER_RIGHT_INITIALSUPERADMIN'] = 1; - } else { - Yii::app()->session['USER_RIGHT_INITIALSUPERADMIN'] = 0; - } - } - /** * Prints Admin Header * @@ -273,7 +243,6 @@ public function _getAdminHeader($meta = false, $return = false) $aData['adminlang'] = Yii::app()->language; $aData['languageRTL'] = ""; $aData['styleRTL'] = ""; - Yii::app()->loadHelper("surveytranslator"); if (getLanguageRTL(Yii::app()->language)) { diff --git a/application/controllers/SurveyController.php b/application/controllers/SurveyController.php index 0b79b46d9f9..9cec3f6bffd 100644 --- a/application/controllers/SurveyController.php +++ b/application/controllers/SurveyController.php @@ -1,4 +1,5 @@ -findByPk($surveyid); + $aData['title_bar']['title'] = ""; + $aData['surveybar']['buttons']['view'] = false; + $aData['activated'] = null; + if($surveyid) { + $surveyid = sanitize_int($surveyid); + $oSurvey = Survey::model()->findByPk($surveyid); + if($oSurvey) { + $aData['surveybar']['buttons']['view'] = true; + $aData['title_bar']['title'] = viewHelper::flatEllipsizeText($oSurvey->defaultlanguage->surveyls_title)." (".gT("ID").":".$surveyid.")"; + $aData['activated'] = $oSurvey->active; + } + // Plugin must test to send 404 if needed, maybe want to “create” a new survey, who know … + } $aData['surveyid'] = $surveyid; - - $aData['surveybar']['buttons']['view'] = true; - $aData['title_bar']['title'] = viewHelper::flatEllipsizeText($oSurvey->defaultlanguage->surveyls_title)." (".gT("ID").":".$surveyid.")"; - $content = $this->getContent($surveyid, $plugin, $method); $aData['sidemenu'] = array(); $aData['sidemenu']['state'] = false; $aData['sideMenuBehaviour'] = getGlobalSetting('sideMenuBehaviour'); $aData['content'] = $content; - $aData['activated'] = $oSurvey->active; + $aData['sideMenuOpen'] = false; // TODO: Assume this for all plugins? $this->_renderWrappedTemplate(null, array('super/sidebody'), $aData); - } /** diff --git a/application/controllers/admin/authentication.php b/application/controllers/admin/authentication.php index 97d1b082162..b56ba7e34b9 100644 --- a/application/controllers/admin/authentication.php +++ b/application/controllers/admin/authentication.php @@ -169,11 +169,6 @@ public static function prepareLogin() FailedLoginAttempt::model()->deleteAttempts(); App()->user->setState('plugin', $authMethod); - // This call to AdminController::_GetSessionUserRights() ; - // NB 1:calling another controller method from a controller method is a bad pratice - // NB 2: this function only check if logged in user is super admin to set in session USER_RIGHT_INITIALSUPERADMIN - // TODO: move this function to the user object - Yii::app()->getController()->_GetSessionUserRights(Yii::app()->session['loginID']); Yii::app()->session['just_logged_in'] = true; Yii::app()->session['loginsummary'] = self::getSummary(); @@ -183,6 +178,7 @@ public static function prepareLogin() return array('success'); } else { // Failed + tracevar("authenticate failed"); $event = new PluginEvent('afterFailedLoginAttempt'); $event->set('identity', $identity); App()->getPluginManager()->dispatchEvent($event); diff --git a/application/controllers/admin/index.php b/application/controllers/admin/index.php index 8adc7da9559..a521e7304da 100644 --- a/application/controllers/admin/index.php +++ b/application/controllers/admin/index.php @@ -71,8 +71,8 @@ public function run() $aData['showLastQuestion'] = false; } - $aData['countSurveyList'] = count((array) getSurveyList(true)); - + $aData['countSurveyList'] = Survey::model()->count(); + // We get the home page display setting $aData['bShowSurveyList'] = (getGlobalSetting('show_survey_list') == "show"); $aData['bShowSurveyListSearch'] = (getGlobalSetting('show_survey_list_search') == "show"); diff --git a/application/controllers/admin/questions.php b/application/controllers/admin/questions.php index 396236eef4e..cae9d1d3313 100644 --- a/application/controllers/admin/questions.php +++ b/application/controllers/admin/questions.php @@ -1035,7 +1035,6 @@ public function newquestion($surveyid) $eqrow['title'] = ''; $eqrow['question'] = ''; $eqrow['help'] = ''; - $eqrow['type'] = 'T'; $eqrow['lid'] = 0; $eqrow['lid1'] = 0; $eqrow['gid'] = null; @@ -1046,6 +1045,8 @@ public function newquestion($surveyid) $eqrow['group_name'] = ''; $eqrow['modulename'] = ''; $eqrow['conditions_number'] = false; + $eqrow['type'] = 'T'; + if (isset($_GET['gid'])) { $eqrow['gid'] = $_GET['gid']; } @@ -1070,6 +1071,7 @@ public function newquestion($surveyid) $aData['accordionDatas']['selectormodeclass'] = $selectormodeclass; $aData['selectormodeclass'] = $selectormodeclass; + $aData['ajaxDatas']['selectormodeclass'] = $selectormodeclass; $aData['accordionDatas']['eqrow'] = $eqrow; @@ -1305,6 +1307,7 @@ public function index($sa, $surveyid, $gid, $qid = null) } $aData['selectormodeclass'] = $selectormodeclass; + $aData['ajaxDatas']['selectormodeclass'] = $selectormodeclass; } /** @@ -1324,7 +1327,9 @@ public function index($sa, $surveyid, $gid, $qid = null) App()->getClientScript()->registerScriptFile(App()->getConfig('adminscripts').'questions.js', LSYii_ClientScript::POS_BEGIN); $aData['sValidateUrl'] = ($adding || $copying) ? $this->getController()->createUrl('admin/questions', array('sa' => 'ajaxValidate', 'surveyid'=>$surveyid)) : $this->getController()->createUrl('admin/questions', array('sa' => 'ajaxValidate', 'surveyid'=>$surveyid, 'qid'=>$qid)); - + $aData['ajaxDatas']['sValidateUrl'] = $aData['sValidateUrl']; + $aData['ajaxDatas']['qTypeOutput'] = $aData['qTypeOutput']; + $aData['addlanguages'] = Survey::model()->findByPk($surveyid)->additionalLanguages; $aViewUrls['editQuestion_view'][] = $aData; @@ -1333,7 +1338,7 @@ public function index($sa, $surveyid, $gid, $qid = null) include('accessDenied.php'); } - $aData['ajaxDatas']['sValidateUrl'] = (isset($aData['sValidateUrl'])) ? $aData['sValidateUrl'] : $this->getController()->createUrl('admin/questions', array('sa' => 'ajaxValidate', 'surveyid'=>$surveyid)); + $aData['ajaxDatas']['qTypeOutput'] = $aData['qTypeOutput']; /////////// diff --git a/application/controllers/admin/tokens.php b/application/controllers/admin/tokens.php index 3b031ceba8d..ad00e508a4c 100644 --- a/application/controllers/admin/tokens.php +++ b/application/controllers/admin/tokens.php @@ -359,8 +359,8 @@ public function browse($iSurveyId, $limit = 50, $start = 0) $aData['model'] = $model; // Set number of page - if (isset($_POST['pageSize'])) { - Yii::app()->user->setState('pageSize', (int) $_POST['pageSize']); + if (isset($_POST['pageSizeTokenView'])) { + Yii::app()->user->setState('pageSizeTokenView', (int) $_POST['pageSizeTokenView']); } $aData['massiveAction'] = App()->getController()->renderPartial('/admin/token/massive_actions/_selector', array(), true, false); @@ -1488,7 +1488,7 @@ public function email($iSurveyId, $tokenids = null) unset($fieldsarray); } - $aViewUrls = array('emailpost'); + $aViewUrls = array(); $aData['tokenoutput'] = $tokenoutput; if ($ctcount > $emcount) { @@ -1502,7 +1502,9 @@ public function email($iSurveyId, $tokenids = null) } $aData['lefttosend'] = $ctcount - $iMaxEmails; + $aData['nosidebodyblock'] = true; $aViewUrls[] = 'emailwarning'; + } else { if (!$bInvalidDate && !$bSendError) { $aData['tokenoutput'] .= "".gT("All emails were sent.").""; @@ -1518,7 +1520,7 @@ public function email($iSurveyId, $tokenids = null) $aData['tokenoutput'] .= '

'.gT("Ok").'

'; } } - + $aViewUrls[] = 'emailpost'; $this->_renderWrappedTemplate('token', $aViewUrls, $aData); } else { $aData['sidemenu']['state'] = false; diff --git a/application/controllers/admin/usergroups.php b/application/controllers/admin/usergroups.php index a30c1cc050f..cf97b5f38e8 100644 --- a/application/controllers/admin/usergroups.php +++ b/application/controllers/admin/usergroups.php @@ -125,7 +125,7 @@ public function delete() if ($result->count() > 0) { $delquery_result = UserGroup::model()->deleteGroup($ugid, Yii::app()->session["loginID"]); if ($delquery_result) { - Yii::app()->user->setFlash("success", gT("Successfully deleted usergroup.")); + Yii::app()->user->setFlash("success", gT("Successfully deleted user group.")); } else { Yii::app()->user->setFlash("notice", gT("Could not delete user group.")); } diff --git a/application/core/ConsoleHttpSession.php b/application/core/ConsoleHttpSession.php new file mode 100644 index 00000000000..edde40a9dd2 --- /dev/null +++ b/application/core/ConsoleHttpSession.php @@ -0,0 +1,12 @@ + + * @link http://www.limesurvey.org/ + * @copyright 2008-2018 LimeSurvey GmbH + * @license GPLv3 + */ + +class LSCaptcha extends CCaptcha +{ + + public function renderOut(){ + $html = $this->renderImage(); + return $html; + } + + /** + * Renders the CAPTCHA image. + */ + protected function renderImage() + { + if(!isset($this->imageOptions['id'])) + $this->imageOptions['id']=$this->getId(); + + $url=$this->getController()->createUrl($this->captchaAction,array('v'=>uniqid())); + $alt=isset($this->imageOptions['alt'])?$this->imageOptions['alt']:''; + return CHtml::image($url,$alt,$this->imageOptions); + } +} diff --git a/application/core/LS_Twig_Extension.php b/application/core/LS_Twig_Extension.php index bd3acd5d3fe..aabd57662d4 100644 --- a/application/core/LS_Twig_Extension.php +++ b/application/core/LS_Twig_Extension.php @@ -215,7 +215,8 @@ public static function getAllQuestionClasses($iQid) public static function renderCaptcha() { - App()->getController()->widget('CCaptcha', array( + return App()->getController()->createWidget('LSCaptcha', array( + 'captchaAction'=>'captcha', 'buttonOptions'=>array('class'=> 'btn btn-xs btn-info'), 'buttonType' => 'button', 'buttonLabel' => gt('Reload image', 'unescaped') diff --git a/application/core/LsDefaultDataSets.php b/application/core/LsDefaultDataSets.php index 2af2fd2314d..0d94eabd6bc 100644 --- a/application/core/LsDefaultDataSets.php +++ b/application/core/LsDefaultDataSets.php @@ -7,48 +7,103 @@ class LsDefaultDataSets { public static function getSurveyMenuEntryData(){ $headerArray = ['menu_id','user_id','ordering','name','title','menu_title','menu_description','menu_icon','menu_icon_type','menu_class','menu_link','action','template','partial','classes','permission','permission_grade','data','getdatamethod','language','active','changed_at','changed_by','created_at','created_by']; $basicMenues = [ - [1,NULL,1,'overview','Survey overview','Overview','Open general survey overview and quick action','list','fontawesome','','admin/survey/sa/view','','','','','','','{"render": { "link": {"data": {"surveyid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [1,NULL,2,'generalsettings','General survey settings','General settings','Open general survey settings','gears','fontawesome','','','updatesurveylocalesettings_generalsettings','editLocalSettings_main_view','/admin/survey/subview/accordion/_generaloptions_panel','','surveysettings','read',NULL,'_generalTabEditSurvey','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [1,NULL,3,'surveytexts','Survey text elements','Text elements','Survey text elements','file-text-o','fontawesome','','','updatesurveylocalesettings','editLocalSettings_main_view','/admin/survey/subview/tab_edit_view','','surveylocale','read',NULL,'_getTextEditData','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [1,NULL,4,'theme_options','Theme options','Theme options','Edit theme options for this survey','paint-brush','fontawesome','','admin/themeoptions/sa/updatesurvey','','','','','themes','read','{"render": {"link": { "pjaxed": true, "data": {"surveyid": ["survey","sid"], "gsid":["survey","gsid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [1,NULL,5,'participants','Survey participants','Survey participants','Go to survey participant and token settings','user','fontawesome','','admin/tokens/sa/index/','','','','','surveysettings','update','{"render": { "link": {"data": {"surveyid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [1,NULL,6,'presentation','Presentation & navigation settings','Presentation','Edit presentation and navigation settings','eye-slash','fontawesome','','','updatesurveylocalesettings','editLocalSettings_main_view','/admin/survey/subview/accordion/_presentation_panel','','surveylocale','read',NULL,'_tabPresentationNavigation','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [1,NULL,7,'publication','Publication and access control settings','Publication & access','Edit settings for publicationa and access control','key','fontawesome','','','updatesurveylocalesettings','editLocalSettings_main_view','/admin/survey/subview/accordion/_publication_panel','','surveylocale','read',NULL,'_tabPublicationAccess','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [1,NULL,8,'surveypermissions','Edit surveypermissions','Survey permissions','Edit permissions for this survey','lock','fontawesome','','admin/surveypermission/sa/view/','','','','','surveysecurity','read','{"render": { "link": {"data": {"surveyid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [1,NULL,9,'tokens','Survey participant settings','Participant settings','Set additional options for survey participants','users','fontawesome','','','updatesurveylocalesettings','editLocalSettings_main_view','/admin/survey/subview/accordion/_tokens_panel','','surveylocale','read',NULL,'_tabTokens','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [1,NULL,10,'quotas','Edit quotas','Quotas','Edit quotas for this survey.','tasks','fontawesome','','admin/quotas/sa/index/','','','','','quotas','read','{"render": { "link": {"data": {"surveyid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [1,NULL,11,'assessments','Edit assessments','Assessments','Edit and look at the assessements for this survey.','comment-o','fontawesome','','admin/assessments/sa/index/','','','','','assessments','read','{"render": { "link": {"data": {"surveyid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [1,NULL,12,'notification','Notification and data management settings','Data management','Edit settings for notification and data management','feed','fontawesome','','','updatesurveylocalesettings','editLocalSettings_main_view','/admin/survey/subview/accordion/_notification_panel','','surveylocale','read',NULL,'_tabNotificationDataManagement','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [1,NULL,13,'emailtemplates','Email templates','Email templates','Edit the templates for invitation, reminder and registration emails','envelope-square','fontawesome','','admin/emailtemplates/sa/index/','','','','','assessments','read','{"render": { "link": {"data": {"surveyid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [1,NULL,14,'panelintegration','Edit survey panel integration','Panel integration','Define panel integrations for your survey','link','fontawesome','','','updatesurveylocalesettings','editLocalSettings_main_view','/admin/survey/subview/accordion/_integration_panel','','surveylocale','read','{"render": {"link": { "pjaxed": false}}}','_tabPanelIntegration','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [1,NULL,15,'resources','Add/Edit resources to the survey','Resources','Add/Edit resources to the survey','file','fontawesome','','','updatesurveylocalesettings','editLocalSettings_main_view','/admin/survey/subview/accordion/_resources_panel','','surveylocale','read',NULL,'_tabResourceManagement','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [2,NULL,1,'activateSurvey','Activate survey','Activate survey','Activate survey','play','fontawesome','','admin/survey/sa/activate','','','','','surveyactivation','update','{"render": {"isActive": false, "link": {"data": {"surveyid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [2,NULL,2,'deactivateSurvey','Stop this survey','Stop this survey','Stop this survey','stop','fontawesome','','admin/survey/sa/deactivate','','','','','surveyactivation','update','{"render": {"isActive": true, "link": {"data": {"surveyid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [2,NULL,3,'testSurvey','Go to survey','Go to survey','Go to survey','cog','fontawesome','','survey/index/','','','','','','','{"render": {"link": {"external": true, "data": {"sid": ["survey","sid"], "newtest": "Y", "lang": ["survey","language"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [2,NULL,4,'listQuestions','List questions','List questions','List questions','list','fontawesome','','admin/survey/sa/listquestions','','','','','surveycontent','read','{"render": { "link": {"data": {"surveyid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [2,NULL,5,'listQuestionGroups','List question groups','List question groups','List question groups','th-list','fontawesome','','admin/survey/sa/listquestiongroups','','','','','surveycontent','read','{"render": { "link": {"data": {"surveyid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [2,NULL,6,'generalsettings_collapsed','General survey settings','General settings','Open general survey settings','gears','fontawesome','','','updatesurveylocalesettings_generalsettings','editLocalSettings_main_view','/admin/survey/subview/accordion/_generaloptions_panel','','surveysettings','read',NULL,'_generalTabEditSurvey','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [2,NULL,7,'surveypermissions_collapsed','Edit surveypermissions','Survey permissions','Edit permissions for this survey','lock','fontawesome','','admin/surveypermission/sa/view/','','','','','surveysecurity','read','{"render": { "link": {"data": {"surveyid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [2,NULL,8,'quotas_collapsed','Edit quotas','Survey quotas','Edit quotas for this survey.','tasks','fontawesome','','admin/quotas/sa/index/','','','','','quotas','read','{"render": { "link": {"data": {"surveyid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [2,NULL,9,'assessments_collapsed','Edit assessments','Assessments','Edit and look at the assessements for this survey.','comment-o','fontawesome','','admin/assessments/sa/index/','','','','','assessments','read','{"render": { "link": {"data": {"surveyid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [2,NULL,10,'emailtemplates_collapsed','Email templates','Email templates','Edit the templates for invitation, reminder and registration emails','envelope-square','fontawesome','','admin/emailtemplates/sa/index/','','','','','surveylocale','read','{"render": { "link": {"data": {"surveyid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [2,NULL,11,'surveyLogicFile','Survey logic file','Survey logic file','Survey logic file','sitemap','fontawesome','','admin/expressions/sa/survey_logic_file/','','','','','surveycontent','read','{"render": { "link": {"data": {"sid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [2,NULL,12,'tokens_collapsed','Survey participant settings','Participant settings','Set additional options for survey participants','user','fontawesome','','','updatesurveylocalesettings','editLocalSettings_main_view','/admin/survey/subview/accordion/_tokens_panel','','surveylocale','read','{"render": { "link": {"data": {"surveyid": ["survey","sid"]}}}}','_tabTokens','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [2,NULL,13,'cpdb','Central participant database','Central participant database','Central participant database','users','fontawesome','','admin/participants/sa/displayParticipants','','','','','tokens','read','{"render": {"link": {}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [2,NULL,14,'responses','Responses','Responses','Responses','icon-browse','iconclass','','admin/responses/sa/browse/','','','','','responses','read','{"render": {"isActive": true, "link": {"data": {"surveyid": ["survey", "sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [2,NULL,15,'statistics','Statistics','Statistics','Statistics','bar-chart','fontawesome','','admin/statistics/sa/index/','','','','','statistics','read','{"render": {"isActive": true, "link": {"data": {"surveyid": ["survey", "sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [2,NULL,16,'reorder','Reorder questions/question groups','Reorder questions/question groups','Reorder questions/question groups','icon-organize','iconclass','','admin/survey/sa/organize/','','','','','surveycontent','update','{"render": {"isActive": false, "link": {"data": {"surveyid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], - [3,NULL,16,'plugins','Simple plugin settings', 'Simple plugins', 'Edit simple plugin settings','plug','fontawesome','','','updatesurveylocalesettings','editLocalSettings_main_view','/admin/survey/subview/accordion/_plugins_panel','','surveysettings','read','{"render": {"link": {"data": {"surveyid": ["survey","sid"]}}}}','_pluginTabSurvey','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [1,NULL,1,'overview', gT('Survey overview'),gT('Overview'),gT('Open general survey overview and quick action'),'list','fontawesome','','admin/survey/sa/view','','','','','','','{"render": { "link": {"data": {"surveyid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [1,NULL,2,'generalsettings', gT('General survey settings'),gT('General settings'),gT('Open general survey settings'),'gears','fontawesome','','','updatesurveylocalesettings_generalsettings','editLocalSettings_main_view','/admin/survey/subview/accordion/_generaloptions_panel','','surveysettings','read',NULL,'_generalTabEditSurvey','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [1,NULL,3,'surveytexts', gT('Survey text elements'),gT('Text elements'),gT('Survey text elements'),'file-text-o','fontawesome','','','updatesurveylocalesettings','editLocalSettings_main_view','/admin/survey/subview/tab_edit_view','','surveylocale','read',NULL,'_getTextEditData','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [1,NULL,4,'theme_options', gT('Theme options'),gT('Theme options'),gT('Edit theme options for this survey'),'paint-brush','fontawesome','','admin/themeoptions/sa/updatesurvey','','','','','themes','read','{"render": {"link": { "pjaxed": true, "data": {"surveyid": ["survey","sid"], "gsid":["survey","gsid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [1,NULL,5,'participants', gT('Survey participants'),gT('Survey participants'),gT('Go to survey participant and token settings'),'user','fontawesome','','admin/tokens/sa/index/','','','','','surveysettings','update','{"render": { "link": {"data": {"surveyid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [1,NULL,6,'presentation', gT('Presentation and navigation settings'),gT('Presentation'),gT('Edit presentation and navigation settings'),'eye-slash','fontawesome','','','updatesurveylocalesettings','editLocalSettings_main_view','/admin/survey/subview/accordion/_presentation_panel','','surveylocale','read',NULL,'_tabPresentationNavigation','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [1,NULL,7,'publication', gT('Publication and access control settings'),gT('Publication and access'),gT('Edit settings for publication and access control'),'key','fontawesome','','','updatesurveylocalesettings','editLocalSettings_main_view','/admin/survey/subview/accordion/_publication_panel','','surveylocale','read',NULL,'_tabPublicationAccess','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [1,NULL,8,'surveypermissions',gT('Edit surveypermissions'),gT('Survey permissions'),gT('Edit permissions for this survey'),'lock','fontawesome','','admin/surveypermission/sa/view/','','','','','surveysecurity','read','{"render": { "link": {"data": {"surveyid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [1,NULL,9,'tokens', gT('Survey participant settings'),gT('Participant settings'),gT('Set additional options for survey participants'),'users','fontawesome','','','updatesurveylocalesettings','editLocalSettings_main_view','/admin/survey/subview/accordion/_tokens_panel','','surveylocale','read',NULL,'_tabTokens','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [1,NULL,10,'quotas', gT('Edit quotas'),gT('Quotas'),gT('Edit quotas for this survey.'),'tasks','fontawesome','','admin/quotas/sa/index/','','','','','quotas','read','{"render": { "link": {"data": {"surveyid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [1,NULL,11,'assessments', gT('Edit assessments'),gT('Assessments'),gT('Edit and look at the assessements for this survey.'),'comment-o','fontawesome','','admin/assessments/sa/index/','','','','','assessments','read','{"render": { "link": {"data": {"surveyid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [1,NULL,12,'notification', gT('Notification and data management settings'),gT('Data management'),gT('Edit settings for notification and data management'),'feed','fontawesome','','','updatesurveylocalesettings','editLocalSettings_main_view','/admin/survey/subview/accordion/_notification_panel','','surveylocale','read',NULL,'_tabNotificationDataManagement','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [1,NULL,13,'emailtemplates', gT('Email templates'),gT('Email templates'),gT('Edit the templates for invitation, reminder and registration emails'),'envelope-square','fontawesome','','admin/emailtemplates/sa/index/','','','','','assessments','read','{"render": { "link": {"data": {"surveyid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [1,NULL,14,'panelintegration', gT('Edit survey panel integration'),gT('Panel integration'),gT('Define panel integrations for your survey'),'link','fontawesome','','','updatesurveylocalesettings','editLocalSettings_main_view','/admin/survey/subview/accordion/_integration_panel','','surveylocale','read','{"render": {"link": { "pjaxed": false}}}','_tabPanelIntegration','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [1,NULL,15,'resources', gT('Add/Edit resources to the survey'),gT('Resources'),gT('Add/Edit resources to the survey'),'file','fontawesome','','','updatesurveylocalesettings','editLocalSettings_main_view','/admin/survey/subview/accordion/_resources_panel','','surveylocale','read',NULL,'_tabResourceManagement','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [2,NULL,1,'activateSurvey',gT('Activate survey'),gT('Activate survey'),gT('Activate survey'),'play','fontawesome','','admin/survey/sa/activate','','','','','surveyactivation','update','{"render": {"isActive": false, "link": {"data": {"surveyid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [2,NULL,2,'deactivateSurvey', gT('Stop this survey'),gT('Stop this survey'),gT('Stop this survey'),'stop','fontawesome','','admin/survey/sa/deactivate','','','','','surveyactivation','update','{"render": {"isActive": true, "link": {"data": {"surveyid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [2,NULL,3,'testSurvey', gT('Go to survey'),gT('Go to survey'),gT('Go to survey'),'cog','fontawesome','','survey/index/','','','','','','','{"render": {"link": {"external": true, "data": {"sid": ["survey","sid"], "newtest": "Y", "lang": ["survey","language"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [2,NULL,4,'listQuestions',gT('List questions'),gT('List questions'),gT('List questions'),'list','fontawesome','','admin/survey/sa/listquestions','','','','','surveycontent','read','{"render": { "link": {"data": {"surveyid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [2,NULL,5,'listQuestionGroups',gT('List question groups'),gT('List question groups'),gT('List question groups'),'th-list','fontawesome','','admin/survey/sa/listquestiongroups','','','','','surveycontent','read','{"render": { "link": {"data": {"surveyid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [2,NULL,6,'generalsettings_collapsed',gT('General survey settings'),gT('General settings'),gT('Open general survey settings'),'gears','fontawesome','','','updatesurveylocalesettings_generalsettings','editLocalSettings_main_view','/admin/survey/subview/accordion/_generaloptions_panel','','surveysettings','read',NULL,'_generalTabEditSurvey','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [2,NULL,7,'surveypermissions_collapsed',gT('Edit surveypermissions'),gT('Survey permissions'),gT('Edit permissions for this survey'),'lock','fontawesome','','admin/surveypermission/sa/view/','','','','','surveysecurity','read','{"render": { "link": {"data": {"surveyid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [2,NULL,8,'quotas_collapsed',gT('Edit quotas'),gT('Survey quotas'),gT('Edit quotas for this survey.'),'tasks','fontawesome','','admin/quotas/sa/index/','','','','','quotas','read','{"render": { "link": {"data": {"surveyid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [2,NULL,9,'assessments_collapsed',gT('Edit assessments'),gT('Assessments'),gT('Edit and look at the assessements for this survey.'),'comment-o','fontawesome','','admin/assessments/sa/index/','','','','','assessments','read','{"render": { "link": {"data": {"surveyid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [2,NULL,10,'emailtemplates_collapsed',gT('Email templates'),gT('Email templates'),gT('Edit the templates for invitation, reminder and registration emails'),'envelope-square','fontawesome','','admin/emailtemplates/sa/index/','','','','','surveylocale','read','{"render": { "link": {"data": {"surveyid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [2,NULL,11,'surveyLogicFile',gT('Survey logic file'),gT('Survey logic file'),gT('Survey logic file'),'sitemap','fontawesome','','admin/expressions/sa/survey_logic_file/','','','','','surveycontent','read','{"render": { "link": {"data": {"sid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [2,NULL,12,'tokens_collapsed',gT('Survey participant settings'),gT('Participant settings'),gT('Set additional options for survey participants'),'user','fontawesome','','','updatesurveylocalesettings','editLocalSettings_main_view','/admin/survey/subview/accordion/_tokens_panel','','surveylocale','read','{"render": { "link": {"data": {"surveyid": ["survey","sid"]}}}}','_tabTokens','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [2,NULL,13,'cpdb',gT('Central participant database'),gT('Central participant database'),gT('Central participant database'),'users','fontawesome','','admin/participants/sa/displayParticipants','','','','','tokens','read','{"render": {"link": {}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [2,NULL,14,'responses',gT('Responses'),gT('Responses'),gT('Responses'),'icon-browse','iconclass','','admin/responses/sa/browse/','','','','','responses','read','{"render": {"isActive": true, "link": {"data": {"surveyid": ["survey", "sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [2,NULL,15,'statistics',gT('Statistics'),gT('Statistics'),gT('Statistics'),'bar-chart','fontawesome','','admin/statistics/sa/index/','','','','','statistics','read','{"render": {"isActive": true, "link": {"data": {"surveyid": ["survey", "sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [2,NULL,16,'reorder',gT('Reorder questions/question groups'),gT('Reorder questions/question groups'),gT('Reorder questions/question groups'),'icon-organize','iconclass','','admin/survey/sa/organize/','','','','','surveycontent','update','{"render": {"isActive": false, "link": {"data": {"surveyid": ["survey","sid"]}}}}','','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], + [3,NULL,16,'plugins',gT('Simple plugin settings'), gT('Simple plugins'), gT('Edit simple plugin settings'),'plug','fontawesome','','','updatesurveylocalesettings','editLocalSettings_main_view','/admin/survey/subview/accordion/_plugins_panel','','surveysettings','read','{"render": {"link": {"data": {"surveyid": ["survey","sid"]}}}}','_pluginTabSurvey','en-GB',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0], ]; $returnArray = []; foreach($basicMenues as $basicMenu){ $returnArray[] = array_combine($headerArray, $basicMenu); } - return $returnArray; } + + public static function getTemplateDefaultTexts($mode){ + $returnArray = array( + 'admin_detailed_notification_subject'=>gT("Response submission for survey {SURVEYNAME} with results", $mode), + 'admin_detailed_notification'=>gT("Hello,\n\nA new response was submitted for your survey '{SURVEYNAME}'.\n\nClick the following link to see the individual response:\n{VIEWRESPONSEURL}\n\nClick the following link to edit the individual response:\n{EDITRESPONSEURL}\n\nView statistics by clicking here:\n{STATISTICSURL}\n\n\nThe following answers were given by the participant:\n{ANSWERTABLE}", $mode), + 'admin_detailed_notification_css'=>'', + 'admin_notification_subject'=>gT("Response submission for survey {SURVEYNAME}", $mode), + 'admin_notification'=>gT("Hello,\n\nA new response was submitted for your survey '{SURVEYNAME}'.\n\nClick the following link to see the individual response:\n{VIEWRESPONSEURL}\n\nClick the following link to edit the individual response:\n{EDITRESPONSEURL}\n\nView statistics by clicking here:\n{STATISTICSURL}", $mode), + 'confirmation_subject'=>gT("Confirmation of your participation in our survey"), + 'confirmation'=>gT("Dear {FIRSTNAME},\n\nthis email is to confirm that you have completed the survey titled {SURVEYNAME} and your response has been saved. Thank you for participating.\n\nIf you have any further questions about this email, please contact {ADMINNAME} on {ADMINEMAIL}.\n\nSincerely,\n\n{ADMINNAME}", $mode), + 'invitation_subject'=>gT("Invitation to participate in a survey", $mode), + 'invitation'=>gT("Dear {FIRSTNAME},\n\nyou have been invited to participate in a survey.\n\nThe survey is titled:\n\"{SURVEYNAME}\"\n\n\"{SURVEYDESCRIPTION}\"\n\nTo participate, please click on the link below.\n\nSincerely,\n\n{ADMINNAME} ({ADMINEMAIL})\n\n----------------------------------------------\nClick here to do the survey:\n{SURVEYURL}", $mode)."\n\n".gT("If you do not want to participate in this survey and don't want to receive any more invitations please click the following link:\n{OPTOUTURL}", $mode)."\n\n".gT("If you are blacklisted but want to participate in this survey and want to receive invitations please click the following link:\n{OPTINURL}", $mode), + 'reminder_subject'=>gT("Reminder to participate in a survey", $mode), + 'reminder'=>gT("Dear {FIRSTNAME},\n\nRecently we invited you to participate in a survey.\n\nWe note that you have not yet completed the survey, and wish to remind you that the survey is still available should you wish to take part.\n\nThe survey is titled:\n\"{SURVEYNAME}\"\n\n\"{SURVEYDESCRIPTION}\"\n\nTo participate, please click on the link below.\n\nSincerely,\n\n{ADMINNAME} ({ADMINEMAIL})\n\n----------------------------------------------\nClick here to do the survey:\n{SURVEYURL}", $mode)."\n\n".gT("If you do not want to participate in this survey and don't want to receive any more invitations please click the following link:\n{OPTOUTURL}", $mode), + 'registration_subject'=>gT("Survey registration confirmation", $mode), + 'registration'=>gT("Dear {FIRSTNAME},\n\nYou, or someone using your email address, have registered to participate in an online survey titled {SURVEYNAME}.\n\nTo complete this survey, click on the following URL:\n\n{SURVEYURL}\n\nIf you have any questions about this survey, or if you did not register to participate and believe this email is in error, please contact {ADMINNAME} at {ADMINEMAIL}.", $mode) + ); + + return $returnArray; + } + public static function getSurveyMenuData(){ $headerArray = [ 'parent_id', @@ -67,9 +122,9 @@ public static function getSurveyMenuData(){ 'created_by' ]; $returnArray = []; - $returnArray[] = array_combine($headerArray, [NULL,NULL,NULL,0,0,'mainmenu','Survey menu','side','Main survey menu',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0]); - $returnArray[] = array_combine($headerArray, [NULL,NULL,NULL,0,0,'quickmenu','Quick menu','collapsed','Quick menu',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0]); - $returnArray[] = array_combine($headerArray, [1,NULL,NULL,0,1,'pluginmenu','Plugin menu','side','Plugin menu',1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0]); + $returnArray[] = array_combine($headerArray, [NULL,NULL,NULL,0,0,'mainmenu',gT('Survey menu'),'side',gT('Main survey menu'),1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0]); + $returnArray[] = array_combine($headerArray, [NULL,NULL,NULL,0,0,'quickmenu',gT('Quick menu'),'collapsed',gT('Quick menu'),1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0]); + $returnArray[] = array_combine($headerArray, [1,NULL,NULL,0,1,'pluginmenu',gT('Plugin menu'),'side',gT('Plugin menu'),1, date('Y-m-d H:i:s'),0,date('Y-m-d H:i:s'),0]); return $returnArray; } @@ -77,12 +132,12 @@ public static function getSurveyMenuData(){ public static function getBoxesData(){ $returnArray = []; - $returnArray[] = ['position' => 1, 'url' => 'admin/survey/sa/newsurvey', 'title' => 'Create survey', 'ico' => 'add', 'desc' => 'Create a new survey', 'page' => 'welcome', 'usergroup' => '-2']; - $returnArray[] = ['position' => 2, 'url' => 'admin/survey/sa/listsurveys', 'title' => 'List surveys', 'ico' => 'list', 'desc' => 'List available surveys', 'page' => 'welcome', 'usergroup' => '-1']; - $returnArray[] = ['position' => 3, 'url' => 'admin/globalsettings', 'title' => 'Global settings', 'ico' => 'settings', 'desc' => 'Edit global settings', 'page' => 'welcome', 'usergroup' => '-2']; - $returnArray[] = ['position' => 4, 'url' => 'admin/update', 'title' => 'ComfortUpdate', 'ico' => 'shield', 'desc' => 'Stay safe and up to date', 'page' => 'welcome', 'usergroup' => '-2']; - $returnArray[] = ['position' => 5, 'url' => 'admin/labels/sa/view', 'title' => 'Label sets', 'ico' => 'label', 'desc' => 'Edit label sets', 'page' => 'welcome', 'usergroup' => '-2']; - $returnArray[] = ['position' => 6, 'url' => 'admin/themeoptions', 'title' => 'Themes', 'ico' => 'templates', 'desc' => 'Themes', 'page' => 'welcome', 'usergroup' => '-2']; + $returnArray[] = ['position' => 1, 'url' => 'admin/survey/sa/newsurvey', 'title' => gT('Create survey'), 'ico' => 'add', 'desc' => gT('Create a new survey'), 'page' => 'welcome', 'usergroup' => '-2']; + $returnArray[] = ['position' => 2, 'url' => 'admin/survey/sa/listsurveys', 'title' => gT('List surveys'), 'ico' => 'list', 'desc' => gT('List available surveys'), 'page' => 'welcome', 'usergroup' => '-1']; + $returnArray[] = ['position' => 3, 'url' => 'admin/globalsettings', 'title' => gT('Global settings'), 'ico' => 'settings', 'desc' => gT('Edit global settings'), 'page' => 'welcome', 'usergroup' => '-2']; + $returnArray[] = ['position' => 4, 'url' => 'admin/update', 'title' => gT('ComfortUpdate'), 'ico' => 'shield', 'desc' => gT('Stay safe and up to date'), 'page' => 'welcome', 'usergroup' => '-2']; + $returnArray[] = ['position' => 5, 'url' => 'admin/labels/sa/view', 'title' => gT('Label sets'), 'ico' => 'label', 'desc' => gT('Edit label sets'), 'page' => 'welcome', 'usergroup' => '-2']; + $returnArray[] = ['position' => 6, 'url' => 'admin/themeoptions', 'title' => gT('Themes'), 'ico' => 'templates', 'desc' => gT('Themes'), 'page' => 'welcome', 'usergroup' => '-2']; return $returnArray; @@ -234,7 +289,7 @@ public static function getTutorialData() { $returnArray[] = [ 'name' => 'firstStartTour', - 'title' => 'Beginner tour', + 'title' => gT('Beginner tour'), 'icon' => 'fa-rocket', 'description' => 'The first start tour to get your first feeling into LimeSurvey', 'active' => 1, @@ -256,7 +311,7 @@ public static function getTutorialData() { ."" ."" ."", - 'onShown' => "(function(tour){ console.ls.log($('#notif-container').children()); $('#notif-container').children().remove(); })", + 'onShown' => "(function(tour){ console.ls.logT($('#notif-container').children()); $('#notif-container').children().remove(); })", 'onEnd' => "(function(tour){window.location.reload();})", 'endOnOrphan' => true, )), diff --git a/application/core/plugins/AuthLDAP/AuthLDAP.php b/application/core/plugins/AuthLDAP/AuthLDAP.php index 535948ef4d5..05d85ff952f 100644 --- a/application/core/plugins/AuthLDAP/AuthLDAP.php +++ b/application/core/plugins/AuthLDAP/AuthLDAP.php @@ -297,7 +297,6 @@ private function _createNewUser($new_user) $oEvent->set('errorMessageBody', gT("Failed to add user")); return null; } - Permission::model()->setGlobalPermission($iNewUID, 'auth_ldap'); $oEvent->set('newUserID', $iNewUID); @@ -424,7 +423,8 @@ public function newUserSession() if ($identity->plugin != 'AuthLDAP') { return; } - + /* unsubscribe from beforeHasPermission, else updating event */ + $this->unsubscribe('beforeHasPermission'); // Here we do the actual authentication $username = $this->getUsername(); $password = $this->getPassword(); @@ -445,9 +445,8 @@ public function newUserSession() } if ($user !== null) { //If user cannot login via LDAP: setAuthFailure - if (($user->uid == 1 && !$this->get('allowInitialUser')) - || - !Permission::model()->find('permission = :permission AND uid=:uid AND read_p =1', array(":permission" => 'auth_ldap',":uid"=>$user->uid)) // Don't use Permission::model()->hasGlobalPermission , else plugin event updated + if ( ($user->uid == 1 && !$this->get('allowInitialUser')) + || !Permission::model()->hasGlobalPermission('auth_ldap','read',$user->uid) ) { $this->setAuthFailure(self::ERROR_AUTH_METHOD_INVALID, gT('LDAP authentication method is not allowed for this user')); return; diff --git a/application/extensions/admin/grid/MassiveActionsWidget/assets/listActions.js b/application/extensions/admin/grid/MassiveActionsWidget/assets/listActions.js index 439231890b8..fec019e5c8b 100644 --- a/application/extensions/admin/grid/MassiveActionsWidget/assets/listActions.js +++ b/application/extensions/admin/grid/MassiveActionsWidget/assets/listActions.js @@ -19,8 +19,8 @@ var onClickListAction = function () { var $that = $(this); // The clicked link var $actionUrl = $that.data('url'); // The url of the Survey Controller action to call var onSuccess = $that.data('on-success'); - var $gridid = $(this).closest('div.listActions').data('grid-id'); - var $oCheckedItems = $.fn.yiiGridView.getChecked($gridid, $(this).closest('div.listActions').data('pk')); // List of the clicked checkbox + var $gridid = $('#'+$(this).closest('div.listActions').data('grid-id')); + var $oCheckedItems = $gridid.yiiGridView('getChecked', $(this).closest('div.listActions').data('pk')); // List of the clicked checkbox var $oCheckedItems = JSON.stringify($oCheckedItems); var actionType = $that.data('actionType'); @@ -39,7 +39,7 @@ var onClickListAction = function () { // TODO : Switch case "redirection (with 2 type; post or fill session)" if(actionType == "redirect") { - $oCheckedItems = $.fn.yiiGridView.getChecked($gridid, $('.listActions').data('pk')); // So we can join + $oCheckedItems = $gridid.yiiGridView('getChecked', $('.listActions').data('pk')); // So we can join var newForm = jQuery('
', { 'action': $actionUrl, 'target': '_blank', @@ -71,7 +71,7 @@ var onClickListAction = function () { // Set window location href. Used by download files in responses list view. if (actionType == 'window-location-href') { - var $oCheckedItems = $.fn.yiiGridView.getChecked($gridid, $('.listActions').data('pk')); // So we can join + var $oCheckedItems = $gridid.yiiGridView('getChecked', $('.listActions').data('pk')); // So we can join window.location.href = $actionUrl + $oCheckedItems.join(','); return; } @@ -83,7 +83,7 @@ var onClickListAction = function () { if (actionType == 'custom') { var js = $that.data('custom-js'); var func = eval(js); - var itemIds = $.fn.yiiGridView.getChecked($gridid, $('.listActions').data('pk')); + var itemIds = $gridid.yiiGridView('getChecked', $('.listActions').data('pk')); func(itemIds); return; } @@ -113,7 +113,7 @@ var onClickListAction = function () { if ($that.data('grid-reload') == "yes") { - $.fn.yiiGridView.update($gridid); // Update the surveys list + $gridid.yiiGridView('update'); // Update the surveys list setTimeout(function(){ $(document).trigger("actions-updated");}, 500); // Raise an event if some widgets inside the modals need some refresh (eg: position widget in question list) } diff --git a/application/extensions/admin/survey/ListSurveysWidget/assets/reload.js b/application/extensions/admin/survey/ListSurveysWidget/assets/reload.js index 96d5e1abdcb..f86c49e4e2e 100644 --- a/application/extensions/admin/survey/ListSurveysWidget/assets/reload.js +++ b/application/extensions/admin/survey/ListSurveysWidget/assets/reload.js @@ -9,7 +9,7 @@ $(document).on('ready pjax:scriptcomplete', function() { { jQuery(document).on("change", '#pageSize', function() { - $.fn.yiiGridView.update('survey-grid',{ data:{ pageSize: $(this).val() }}); + $('#survey-grid').yiiGridView('update',{ data:{ pageSize: $(this).val() }}); }); }); }); diff --git a/application/extensions/captchaExtended/CaptchaExtendedAction.php b/application/extensions/captchaExtended/CaptchaExtendedAction.php index bd2b011787f..b9b6752b93b 100644 --- a/application/extensions/captchaExtended/CaptchaExtendedAction.php +++ b/application/extensions/captchaExtended/CaptchaExtendedAction.php @@ -98,7 +98,6 @@ class CaptchaExtendedAction extends CCaptchaAction{ * Run action */ public function run(){ - if(!extension_loaded('mbstring')){ throw new CHttpException(500, Yii::t('main','Missing extension "{ext}"', array('{ext}' => 'mbstring'))); } @@ -451,9 +450,7 @@ public function getVerifyResult($regenerate=false){ * @return string image content */ protected function renderImage($code){ - $image = imagecreatetruecolor($this->width,$this->height); - $backColor = imagecolorallocate($image, (int)($this->backColor % 0x1000000 / 0x10000), (int)($this->backColor % 0x10000 / 0x100), @@ -466,7 +463,8 @@ protected function renderImage($code){ } if($this->fontFile === null){ - $this->fontFile = dirname(__FILE__) . '/Duality.ttf'; + $this->fontFile = realname(Yii::app()->basePath."/../assets/fonts/font-src/lato-v11-latin-700.ttf"); + } $length = strlen($code); @@ -538,15 +536,15 @@ protected function renderImage($code){ } } - imagecolordeallocate($image,$foreColor); + imagecolordeallocate($image,$foreColor); - header('Pragma: public'); - header('Expires: 0'); - header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); - header('Content-Transfer-Encoding: binary'); - header("Content-type: image/png"); - imagepng($image); + header('Pragma:public'); + header('Expires:0'); + header('Cache-Control:must-revalidate,post-check=0,pre-check=0'); + header('Content-Transfer-Encoding:binary'); + header("Content-type:image/png"); + imagepng($image); //This will normally output the image, but because of ob_start(), it won't. imagedestroy($image); } -} \ No newline at end of file +} diff --git a/application/helpers/SurveyRuntimeHelper.php b/application/helpers/SurveyRuntimeHelper.php index 5359c93a610..91bb94ad9be 100644 --- a/application/helpers/SurveyRuntimeHelper.php +++ b/application/helpers/SurveyRuntimeHelper.php @@ -148,76 +148,78 @@ public function run($surveyid, $args) } $upload_file = false; - foreach ($_SESSION[$this->LEMsessid]['fieldarray'] as $key => $ia) { - ++$qnumber; - $ia[9] = $qnumber; // incremental question count; + if(isset($_SESSION[$this->LEMsessid]['fieldarray'])) { + foreach ($_SESSION[$this->LEMsessid]['fieldarray'] as $key => $ia) { + ++$qnumber; + $ia[9] = $qnumber; // incremental question count; - // Make $qanda only for needed question $ia[10] is the randomGroup and $ia[5] the real group - if ((isset($ia[10]) && $ia[10] == $gid) || (!isset($ia[10]) && $ia[5] == $gid)) { + // Make $qanda only for needed question $ia[10] is the randomGroup and $ia[5] the real group + if ((isset($ia[10]) && $ia[10] == $gid) || (!isset($ia[10]) && $ia[5] == $gid)) { - // In question by question mode, we only procceed current question - if ($this->sSurveyMode == 'question' && $ia[0] != $this->aStepInfo['qid']) { - continue; - } - - // In group by group mode, we only procceed current group - if ($this->sSurveyMode == 'group' && $ia[5] != $this->aStepInfo['gid']) { - if (isset($_SESSION[$this->LEMsessid]['fieldmap-'.$this->iSurveyid.'-randMaster'])) { - // This is a randomized survey, don't continue. - } else { + // In question by question mode, we only procceed current question + if ($this->sSurveyMode == 'question' && $ia[0] != $this->aStepInfo['qid']) { continue; } - } - $qidattributes = QuestionAttribute::model()->getQuestionAttributes($ia[0]); + // In group by group mode, we only procceed current group + if ($this->sSurveyMode == 'group' && $ia[5] != $this->aStepInfo['gid']) { + if (isset($_SESSION[$this->LEMsessid]['fieldmap-'.$this->iSurveyid.'-randMaster'])) { + // This is a randomized survey, don't continue. + } else { + continue; + } + } - if ($ia[4] != '*' && ($qidattributes === false || !isset($qidattributes['hidden']) || $qidattributes['hidden'] == 1)) { - continue; - } + $qidattributes = QuestionAttribute::model()->getQuestionAttributes($ia[0]); + + if ($ia[4] != '*' && ($qidattributes === false || !isset($qidattributes['hidden']) || $qidattributes['hidden'] == 1)) { + continue; + } + + //Get the answers/inputnames + // TMSW - can content of retrieveAnswers() be provided by LEM? Review scope of what it provides. + // TODO - retrieveAnswers is slow - queries database separately for each question. May be fixed in _CI or _YII ports, so ignore for now + list($plus_qanda, $plus_inputnames) = retrieveAnswers($ia); - //Get the answers/inputnames - // TMSW - can content of retrieveAnswers() be provided by LEM? Review scope of what it provides. - // TODO - retrieveAnswers is slow - queries database separately for each question. May be fixed in _CI or _YII ports, so ignore for now - list($plus_qanda, $plus_inputnames) = retrieveAnswers($ia); + if ($plus_qanda) { + $plus_qanda[] = $ia[4]; + $plus_qanda[] = $ia[6]; // adds madatory identifyer for adding mandatory class to question wrapping div - if ($plus_qanda) { - $plus_qanda[] = $ia[4]; - $plus_qanda[] = $ia[6]; // adds madatory identifyer for adding mandatory class to question wrapping div + // Add a finalgroup in qa array , needed for random attribute : TODO: find a way to have it in new quanda_helper in 2.1 + if (isset($ia[10])) { + $plus_qanda['finalgroup'] = $ia[10]; + } else { + $plus_qanda['finalgroup'] = $ia[5]; + } - // Add a finalgroup in qa array , needed for random attribute : TODO: find a way to have it in new quanda_helper in 2.1 - if (isset($ia[10])) { - $plus_qanda['finalgroup'] = $ia[10]; - } else { - $plus_qanda['finalgroup'] = $ia[5]; + $qanda[] = $plus_qanda; + } + if ($plus_inputnames) { + $inputnames = addtoarray_single($inputnames, $plus_inputnames); } - $qanda[] = $plus_qanda; - } - if ($plus_inputnames) { - $inputnames = addtoarray_single($inputnames, $plus_inputnames); - } + //Display the "mandatory" popup if necessary + // TMSW - get question-level error messages - don't call **_popup() directly + if ($okToShowErrors && $this->aStepInfo['mandViolation']) { + list($mandatorypopup, $this->popup) = mandatory_popup($ia, $this->notanswered); + } - //Display the "mandatory" popup if necessary - // TMSW - get question-level error messages - don't call **_popup() directly - if ($okToShowErrors && $this->aStepInfo['mandViolation']) { - list($mandatorypopup, $this->popup) = mandatory_popup($ia, $this->notanswered); - } + //Display the "validation" popup if necessary + if ($okToShowErrors && !$this->aStepInfo['valid']) { + list($validationpopup, $vpopup) = validation_popup($ia, $this->notvalidated); + } - //Display the "validation" popup if necessary - if ($okToShowErrors && !$this->aStepInfo['valid']) { - list($validationpopup, $vpopup) = validation_popup($ia, $this->notvalidated); + // Display the "file validation" popup if necessary + if ($okToShowErrors && ($this->filenotvalidated !== false)) { + list($filevalidationpopup, $fpopup) = file_validation_popup($ia, $this->filenotvalidated); + } } - // Display the "file validation" popup if necessary - if ($okToShowErrors && ($this->filenotvalidated !== false)) { - list($filevalidationpopup, $fpopup) = file_validation_popup($ia, $this->filenotvalidated); + if ($ia[4] == "|") { + $upload_file = true; } - } - - if ($ia[4] == "|") { - $upload_file = true; - } - } //end iteration + } //end iteration + } } if ($this->sSurveyMode != 'survey' && isset($this->aSurveyInfo['showprogress']) && $this->aSurveyInfo['showprogress'] == 'Y') { @@ -227,7 +229,7 @@ public function run($surveyid, $args) $this->aSurveyInfo['progress']['total'] = $_SESSION[$this->LEMsessid]['totalsteps']; } else { $this->aSurveyInfo['progress']['currentstep'] = $_SESSION[$this->LEMsessid]['step']; - $this->aSurveyInfo['progress']['total'] = $_SESSION[$this->LEMsessid]['totalsteps']; + $this->aSurveyInfo['progress']['total'] = isset($_SESSION[$this->LEMsessid]['totalsteps']) ? $_SESSION[$this->LEMsessid]['totalsteps'] : 1; } } @@ -338,6 +340,7 @@ public function run($surveyid, $args) $showgroupdesc_ = $showgroupinfo_ == 'B' /* both */ || $showgroupinfo_ == 'D'; /* (group-) description */ + $aGroup['showgroupinfo'] = $showgroupinfo_; $aGroup['showdescription'] = (!$this->previewquestion && trim($redata['groupdescription']) != "" && $showgroupdesc_); $aGroup['description'] = $redata['groupdescription']; @@ -465,7 +468,6 @@ public function run($surveyid, $args) Yii::app()->twigRenderer->renderTemplateFromFile("layout_global.twig", array('oSurvey'=> Survey::model()->findByPk($this->iSurveyid), 'aSurveyInfo'=>$this->aSurveyInfo), false); } - public function getShowNumAndCode() { @@ -935,11 +937,12 @@ private function displayFirstPageIfNeeded() if ($this->sSurveyMode != 'survey' && $_SESSION[$this->LEMsessid]['step'] == 0) { $_SESSION[$this->LEMsessid]['test'] = time(); - // TODO: Find out why language is not fetched correctly the first time. - $this->aSurveyInfo = getSurveyInfo( + // TODO: Find out why language is not fetched correctly the first time. Where is s_lang set? + $tmpSurveyInfo = getSurveyInfo( $this->thissurvey['sid'], $_SESSION['survey_'.$this->thissurvey['sid']]['s_lang'] ); + $this->aSurveyInfo = array_merge($this->aSurveyInfo, $tmpSurveyInfo); display_first_page($this->thissurvey, $this->aSurveyInfo); Yii::app()->end(); // So we can still see debug messages @@ -1650,6 +1653,11 @@ private function initTemplate() //$oTemplate->registerAssets(); } + /** + * Set alanguageChanger.show to true if we need to show + * the language changer. + * @return void + */ private function makeLanguageChanger() { $this->aSurveyInfo['alanguageChanger']['show'] = false; diff --git a/application/helpers/common_helper.php b/application/helpers/common_helper.php index 584bff95d4b..47050e0190e 100644 --- a/application/helpers/common_helper.php +++ b/application/helpers/common_helper.php @@ -178,17 +178,10 @@ function getSurveyList($bReturnArray = false) if (is_null($cached)) { $surveyidresult = Survey::model() ->permission(Yii::app()->user->getId()) + ->with('languagesettings') ->findAll(); foreach ($surveyidresult as $result) { - if (!empty($result->defaultlanguage)) { - $surveynames[] = array_merge($result->attributes, $result->defaultlanguage->attributes); - } elseif (!($bCheckIntegrity)) { - $bCheckIntegrity = true; - Yii::app()->setFlashMessage( - CHtml::link(gT("One or more surveys seem to be broken - please use the data integrity check tool to fix this."), array("admin/checkintegrity")) - , - 'error'); - } + $surveynames[] = array_merge($result->attributes,$result->languagesettings[$result->language]->attributes); } usort($surveynames, function($a, $b) @@ -918,59 +911,13 @@ function templateDefaultTexts($sLanguage, $mode = 'html', $sNewlines = 'text') { $sOldLanguage = App()->language; App()->setLanguage($sLanguage); - $aDefaultTexts = array( - 'admin_detailed_notification_subject'=>gT("Response submission for survey {SURVEYNAME} with results", $mode), - 'admin_detailed_notification'=>gT("Hello,\n\nA new response was submitted for your survey '{SURVEYNAME}'.\n\nClick the following link to see the individual response:\n{VIEWRESPONSEURL}\n\nClick the following link to edit the individual response:\n{EDITRESPONSEURL}\n\nView statistics by clicking here:\n{STATISTICSURL}\n\n\nThe following answers were given by the participant:\n{ANSWERTABLE}", $mode), - 'admin_detailed_notification_css'=>'', - 'admin_notification_subject'=>gT("Response submission for survey {SURVEYNAME}", $mode), - 'admin_notification'=>gT("Hello,\n\nA new response was submitted for your survey '{SURVEYNAME}'.\n\nClick the following link to see the individual response:\n{VIEWRESPONSEURL}\n\nClick the following link to edit the individual response:\n{EDITRESPONSEURL}\n\nView statistics by clicking here:\n{STATISTICSURL}", $mode), - 'confirmation_subject'=>gT("Confirmation of your participation in our survey"), - 'confirmation'=>gT("Dear {FIRSTNAME},\n\nthis email is to confirm that you have completed the survey titled {SURVEYNAME} and your response has been saved. Thank you for participating.\n\nIf you have any further questions about this email, please contact {ADMINNAME} on {ADMINEMAIL}.\n\nSincerely,\n\n{ADMINNAME}", $mode), - 'invitation_subject'=>gT("Invitation to participate in a survey", $mode), - 'invitation'=>gT("Dear {FIRSTNAME},\n\nyou have been invited to participate in a survey.\n\nThe survey is titled:\n\"{SURVEYNAME}\"\n\n\"{SURVEYDESCRIPTION}\"\n\nTo participate, please click on the link below.\n\nSincerely,\n\n{ADMINNAME} ({ADMINEMAIL})\n\n----------------------------------------------\nClick here to do the survey:\n{SURVEYURL}", $mode)."\n\n".gT("If you do not want to participate in this survey and don't want to receive any more invitations please click the following link:\n{OPTOUTURL}", $mode)."\n\n".gT("If you are blacklisted but want to participate in this survey and want to receive invitations please click the following link:\n{OPTINURL}", $mode), - 'reminder_subject'=>gT("Reminder to participate in a survey", $mode), - 'reminder'=>gT("Dear {FIRSTNAME},\n\nRecently we invited you to participate in a survey.\n\nWe note that you have not yet completed the survey, and wish to remind you that the survey is still available should you wish to take part.\n\nThe survey is titled:\n\"{SURVEYNAME}\"\n\n\"{SURVEYDESCRIPTION}\"\n\nTo participate, please click on the link below.\n\nSincerely,\n\n{ADMINNAME} ({ADMINEMAIL})\n\n----------------------------------------------\nClick here to do the survey:\n{SURVEYURL}", $mode)."\n\n".gT("If you do not want to participate in this survey and don't want to receive any more invitations please click the following link:\n{OPTOUTURL}", $mode), - 'registration_subject'=>gT("Survey registration confirmation", $mode), - 'registration'=>gT("Dear {FIRSTNAME},\n\nYou, or someone using your email address, have registered to participate in an online survey titled {SURVEYNAME}.\n\nTo complete this survey, click on the following URL:\n\n{SURVEYURL}\n\nIf you have any questions about this survey, or if you did not register to participate and believe this email is in error, please contact {ADMINNAME} at {ADMINEMAIL}.", $mode) - ); + + $aDefaultTexts = LsDefaultDataSets::getTemplateDefaultTexts($mode); + if ($sNewlines == 'html') { $aDefaultTexts = array_map('nl2br', $aDefaultTexts); } + App()->setLanguage($sOldLanguage); return $aDefaultTexts; } diff --git a/application/helpers/expressions/em_manager_helper.php b/application/helpers/expressions/em_manager_helper.php index 8b5dd2fb647..d5a46eb4609 100644 --- a/application/helpers/expressions/em_manager_helper.php +++ b/application/helpers/expressions/em_manager_helper.php @@ -2974,23 +2974,22 @@ public function _CreateSubQLevelRelevanceAndValidationEqns($onlyThisQseq=NULL) $em_validation_q_tip = ''; } - // em_validation_q - an EM validation equation that must be satisfied for the whole question. Uses 'this' in the equation if (isset($qattr['em_validation_q']) && !is_null($qattr['em_validation_q']) && trim($qattr['em_validation_q']) != '') { $em_validation_q = $qattr['em_validation_q']; + $sq_names = array(); if ($hasSubqs) { $subqs = $qinfo['subqs']; - $sq_names = array(); foreach ($subqs as $sq) { $sq_name = NULL; - switch ($type) - { + switch ($type) { case 'A': //ARRAY (5 POINT CHOICE) radio-buttons case 'B': //ARRAY (10 POINT CHOICE) radio-buttons case 'C': //ARRAY (YES/UNCERTAIN/NO) radio-buttons case 'E': //ARRAY (Increase/Same/Decrease) radio-buttons case 'F': //ARRAY (Flexible) - Row Format + case 'H': //ARRAY (Flexible) - Col Format case 'K': //MULTIPLE NUMERICAL QUESTION case 'Q': //MULTIPLE SHORT TEXT case ';': //ARRAY (Multi Flexi) Text @@ -3004,16 +3003,16 @@ public function _CreateSubQLevelRelevanceAndValidationEqns($onlyThisQseq=NULL) case 'T': //LONG FREE TEXT case 'U': //HUGE FREE TEXT case 'D': //DATE - if ($this->sgqaNaming) - { + if ($this->sgqaNaming) { $sq_name = '!(' . preg_replace('/\bthis\b/',(string)substr($sq['jsVarName'],4), $em_validation_q) . ')'; - } - else - { + } else { $sq_name = '!(' . preg_replace('/\bthis\b/',$sq['varName'], $em_validation_q) . ')'; } break; + case 'L': + case '!': default: + // Nothing to do : no realsubq, set it after break; } if (!is_null($sq_name)) { @@ -3034,6 +3033,21 @@ public function _CreateSubQLevelRelevanceAndValidationEqns($onlyThisQseq=NULL) ); } } + // No subqs or false subqs (L and !) + if (empty($sq_names)) { + if ($this->sgqaNaming) { + $eqn = '(' . preg_replace('/\bthis\b/',$qinfo['sgqa'], $em_validation_q) . ')'; + } else { + $eqn = '(' . preg_replace('/\bthis\b/',$qinfo['varName'], $em_validation_q) . ')'; + } + $validationEqn[$questionNum][] = array( + 'qtype' => $type, + 'type' => 'em_validation_q', + 'class' => 'q_fn_validation', + 'eqn' => $eqn, + 'qid' => $questionNum, + ); + } } else { @@ -3880,7 +3894,6 @@ public function setVariableAndTokenMappingsForExpressionManager($surveyid,$force case 'C': //ARRAY (YES/UNCERTAIN/NO) radio-buttons case 'E': //ARRAY (Increase/Same/Decrease) radio-buttons case 'F': //ARRAY (Flexible) - Row Format - case 'H': //ARRAY (Flexible) - Column Format // note does not have javatbd equivalent - so array filters don't work on it case 'K': //MULTIPLE NUMERICAL QUESTION // note does not have javatbd equivalent - so array filters don't work on it, but need rowdivid to process validations case 'M': //Multiple choice checkbox case 'P': //Multiple choice with comments checkbox + text @@ -3890,16 +3903,21 @@ public function setVariableAndTokenMappingsForExpressionManager($surveyid,$force $varName = $fielddata['title'] . '_' . $fielddata['aid']; $question = $fielddata['subquestion']; // $question = $fielddata['question'] . ': ' . $fielddata['subquestion']; - if ($type != 'H') { - if ($type == 'P' && preg_match("/comment$/", $sgqa)) { - // $rowdivid = substr($sgqa,0,-7); - } - else { - $sqsuffix = '_' . $fielddata['aid']; - $rowdivid = $sgqa; - } + if ($type == 'P' && preg_match("/comment$/", $sgqa)) { + // $rowdivid = substr($sgqa,0,-7); + } + else { + $sqsuffix = '_' . $fielddata['aid']; + $rowdivid = $sgqa; } break; + case 'H': //ARRAY (Flexible) - Column Format + $csuffix = $fielddata['aid']; + $varName = $fielddata['title'] . '_' . $fielddata['aid']; + $question = $fielddata['subquestion']; + $sqsuffix = '_' . $fielddata['aid']; + $rowdivid = $sgqa; // Really bad name here … because row are subquestion not row … + break; case ':': //ARRAY (Multi Flexi) 1 to 10 case ';': //ARRAY (Multi Flexi) Text $csuffix = $fielddata['aid']; @@ -4043,7 +4061,6 @@ public function setVariableAndTokenMappingsForExpressionManager($surveyid,$force if($hidden && $type!="*"){ $jsVarName_on = ''; } - if (!is_null($rowdivid) || $type == 'L' || $type == 'N' || $type == '!' || $type == 'O' || !is_null($preg) || $type == 'S' || $type == 'D' || $type == 'T' || $type == 'U' || $type == '|') { if (!isset($q2subqInfo[$questionNum])) { @@ -4137,7 +4154,6 @@ public function setVariableAndTokenMappingsForExpressionManager($surveyid,$force } $ansList = ",'answers':{ " . implode(",",$answers) . "}"; } - // Set mappings of variable names to needed attributes $varInfo_Code = array( 'jsName_on'=>$jsVarName_on, @@ -4164,7 +4180,6 @@ public function setVariableAndTokenMappingsForExpressionManager($surveyid,$force 'rowdivid'=>(is_null($rowdivid) ? '' : $rowdivid), 'onlynum'=>$onlynum, ); - $this->questionSeq2relevance[$questionSeq] = array( 'relevance'=>$relevance, 'grelevance'=>$grelevance, @@ -8526,7 +8541,7 @@ private function getQuestionAttributesForEM($surveyid=0,$qid=0, $lang='') $aQuestionAttributesForEM=array(); foreach($oQids as $oQid) { - $aAttributesValues=QuestionAttribute::model()->getQuestionAttributes($oQid->qid); + $aAttributesValues=QuestionAttribute::model()->getQuestionAttributes($oQid->qid, $lang); // Change array lang to value foreach($aAttributesValues as &$aAttributeValue) { diff --git a/application/helpers/frontend_helper.php b/application/helpers/frontend_helper.php index 9dd247b2cc6..ca7e551494a 100644 --- a/application/helpers/frontend_helper.php +++ b/application/helpers/frontend_helper.php @@ -1255,12 +1255,15 @@ function renderRenderWayForm($renderWay, array $scenarios, $sTemplateViewPath, $ $aForm['token'] = array_key_exists('token', $aEnterTokenData) ? $aEnterTokenData['token'] : null; $aForm['aEnterErrors'] = $aEnterTokenData['aEnterErrors']; $aForm['bCaptchaEnabled'] = (isset($aEnterTokenData['bCaptchaEnabled'])) ? $aEnterTokenData['bCaptchaEnabled'] : ''; - + if($aForm['bCaptchaEnabled']) { + Yii::app()->getController()->createAction('captcha'); + } // Rendering layout_user_forms.twig $thissurvey["aForm"] = $aForm; $thissurvey['surveyUrl'] = App()->createUrl("/survey/index", array("sid"=>$surveyid)); - - Yii::app()->twigRenderer->renderTemplateFromFile("layout_user_forms.twig", array('oSurvey'=>Survey::model()->findByPk($surveyid), 'aSurveyInfo'=>$thissurvey), false); + $thissurvey['include_content'] = 'userforms.twig'; + + Yii::app()->twigRenderer->renderTemplateFromFile("layout_global.twig", array('oSurvey'=>Survey::model()->findByPk($surveyid), 'aSurveyInfo'=>$thissurvey), false); break; case "register": //Register new user diff --git a/application/helpers/qanda_helper.php b/application/helpers/qanda_helper.php index 2cf60192039..7501cabd82e 100644 --- a/application/helpers/qanda_helper.php +++ b/application/helpers/qanda_helper.php @@ -778,7 +778,7 @@ function do_5pointchoice($ia) $aQuestionAttributes = QuestionAttribute::model()->getQuestionAttributes($ia[0]); $inputnames = array(); - $sRows = ""; + $aRows = array();; for ($fp = 1; $fp <= 5; $fp++) { $checkedState = ''; if ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] == $fp) { @@ -786,7 +786,7 @@ function do_5pointchoice($ia) $checkedState = ' CHECKED '; } - $sRows .= doRender('/survey/questions/answer/5pointchoice/rows/item_row', array( + $aRows[] = array( 'name' => $ia[1], 'value' => $fp, 'id' => $ia[1].$fp, @@ -794,7 +794,7 @@ function do_5pointchoice($ia) 'itemExtraClass' => '', 'checkedState' => $checkedState, 'checkconditionFunction' => $checkconditionFunction, - ), true); + ); } if ($ia[6] != "Y" && SHOW_NO_ANSWER == 1) { @@ -803,7 +803,7 @@ function do_5pointchoice($ia) if (!$_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]]) { $checkedState = ' CHECKED '; } - $aData = array( + $aRows[] = array( 'name' => $ia[1], 'value' => "", 'id' => $ia[1], @@ -812,7 +812,6 @@ function do_5pointchoice($ia) 'checkedState' => $checkedState, 'checkconditionFunction' => $checkconditionFunction, ); - $sRows .= doRender('/survey/questions/answer/5pointchoice/rows/item_row', $aData, true); } $sessionValue = $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]]; @@ -823,15 +822,17 @@ function do_5pointchoice($ia) if ($aQuestionAttributes['slider_rating'] == 1) { $slider_rating = 1; - Yii::app()->getClientScript()->registerCssFile(Yii::app()->getConfig('publicstyleurl').'star-rating.css'); - Yii::app()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts')."star-rating.js", LSYii_ClientScript::POS_BEGIN); + Yii::app()->getClientScript()->registerPackage('question-5pointchoice-star'); + Yii::app()->getClientScript()->registerScript('doRatingSlider_'.$ia[0], " + var doRatingSlider_".$ia[1]."= new getRatingSlider('".$ia[0]."'); + doRatingSlider_".$ia[1]."(); + ", LSYii_ClientScript::POS_POSTSCRIPT); } if ($aQuestionAttributes['slider_rating'] == 2) { $slider_rating = 2; - Yii::app()->getClientScript()->registerPackage('emoji'); - Yii::app()->getClientScript()->registerCssFile(Yii::app()->getConfig('publicstyleurl').'slider-rating.css'); - Yii::app()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts')."slider-rating.js", LSYii_ClientScript::POS_BEGIN); + Yii::app()->getClientScript()->registerPackage('question-5pointchoice-slider'); + Yii::app()->getClientScript()->registerScript('doRatingStar_'.$ia[0], "doRatingStar('".$ia[0]."'); ", LSYii_ClientScript::POS_POSTSCRIPT); } @@ -841,7 +842,7 @@ function do_5pointchoice($ia) 'name' => $ia[1], 'basename' => $ia[1], 'sessionValue' => $sessionValue, - 'sRows' => $sRows, + 'aRows' => $aRows, 'slider_rating' => $slider_rating, ), true); @@ -2350,28 +2351,13 @@ function do_file_upload($ia) $_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['preview'] = 0; $questgrppreview = 0; } + + $uploadurl = $scriptloc."?sid=".Yii::app()->getConfig('surveyID')."&fieldname=".$ia[1]."&qid=".$ia[0]; + $uploadurl .= "&preview=".$questgrppreview."&show_title=".$aQuestionAttributes['show_title']; + $uploadurl .= "&show_comment=".$aQuestionAttributes['show_comment']; + $uploadurl .= "&minfiles=".$aQuestionAttributes['min_num_of_files']; // TODO: Regression here? Should use LEMval(minfiles) like above + $uploadurl .= "&maxfiles=".$aQuestionAttributes['max_num_of_files']; // Same here. - $answer = "\n"; Yii::app()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts')."modaldialog.js", LSYii_ClientScript::POS_BEGIN); Yii::app()->getClientScript()->registerCssFile(Yii::app()->getConfig('publicstyleurl')."uploader-files.css"); // Modal dialog @@ -2384,95 +2370,29 @@ function upload_$ia[1]() { $filecountvalue = $tempval; } } + $surveyId = Yii::app()->getConfig('surveyID'); $fileuploadData = array( + 'surveyId' => $surveyId, + 'qid' => $ia[0], 'fileid' => $ia[1], 'value' => $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]], 'filecountvalue'=>$filecountvalue, 'coreClass'=>$coreClass, 'basename' => $ia[1], + 'maxFiles' => $aQuestionAttributes['max_num_of_files'], + 'minFiles' => $aQuestionAttributes['min_num_of_files'], + 'uploadurl' => $uploadurl, + 'showTitle' => $aQuestionAttributes["show_title"], + 'showComment' => $aQuestionAttributes["show_comment"], ); - $answer .= doRender('/survey/questions/answer/file_upload/answer', $fileuploadData, true); - - $answer .= ''; - - $answer .= ''; - - $uploadurl = $scriptloc."?sid=".Yii::app()->getConfig('surveyID')."&fieldname=".$ia[1]."&qid=".$ia[0]; - $uploadurl .= "&preview=".$questgrppreview."&show_title=".$aQuestionAttributes['show_title']; - $uploadurl .= "&show_comment=".$aQuestionAttributes['show_comment']; - $uploadurl .= "&minfiles=".$aQuestionAttributes['min_num_of_files']; // TODO: Regression here? Should use LEMval(minfiles) like above - $uploadurl .= "&maxfiles=".$aQuestionAttributes['max_num_of_files']; // Same here. - - $answer .= ' - - - - - '; + App()->getClientScript()->registerCssFile(Yii::app()->getConfig("publicstyleurl")."uploader.css"); + App()->getClientScript()->registerCssFile(Yii::app()->getConfig('publicstyleurl')."uploader-files.css"); + // App()->getClientScript()->registerScript('sNeededScriptVar', $sNeededScriptVar, LSYii_ClientScript::POS_BEGIN); + // App()->getClientScript()->registerScript('sLangScriptVar', $sLangScriptVar, LSYii_ClientScript::POS_BEGIN); + App()->getClientScript()->registerScriptFile(Yii::app()->getConfig("generalscripts").'ajaxupload.js', LSYii_ClientScript::POS_END); + App()->getClientScript()->registerScriptFile(Yii::app()->getConfig("generalscripts").'uploader.js', LSYii_ClientScript::POS_END); + + $answer = doRender('/survey/questions/answer/file_upload/answer', $fileuploadData, true); $inputnames = array(); $inputnames[] = $ia[1]; diff --git a/application/helpers/questionHelper.php b/application/helpers/questionHelper.php index f349cfc3043..334d8fe53ec 100644 --- a/application/helpers/questionHelper.php +++ b/application/helpers/questionHelper.php @@ -291,7 +291,7 @@ public static function getAttributesDefinitions() ); self::$attributes["em_validation_q"] = array( - "types"=>":;ABCDEFKMNOPQRSTU", + "types"=>":;ABCDEFHKMNOPQRSTU"."L!", // separate question with REAL subqs (in EM) and with FALSE subsq (where subqs are answer …) 'category'=>gT('Logic'), 'sortorder'=>200, 'inputtype'=>'textarea', @@ -301,7 +301,7 @@ public static function getAttributesDefinitions() ); self::$attributes["em_validation_q_tip"] = array( - "types"=>":;ABCDEFKMNOPQRSTU", + "types"=>":;ABCDEFHKMNOPQRSTU"."L!", // separate question with subqs (in EM) and without 'category'=>gT('Logic'), 'sortorder'=>210, 'inputtype'=>'textarea', diff --git a/application/helpers/remotecontrol/remotecontrol_handle.php b/application/helpers/remotecontrol/remotecontrol_handle.php index 39f3fc2db64..e36534bd211 100644 --- a/application/helpers/remotecontrol/remotecontrol_handle.php +++ b/application/helpers/remotecontrol/remotecontrol_handle.php @@ -55,12 +55,12 @@ public function get_session_key($username, $password, $plugin = 'Authdb') $session->data = $username; $session->save(); return $sSessionKey; - } else { - if (is_string($loginResult)) { - return array('status' => $loginResult); - } - return array('status' => 'Invalid user name or password'); + + } + if (is_string($loginResult)) { + return array('status' => $loginResult); } + return array('status' => 'Invalid user name or password'); } /** @@ -3027,7 +3027,6 @@ protected function _jumpStartSession($username) } Yii::app()->user->setId($aUserData['uid']); - $this->controller->_GetSessionUserRights($aUserData['uid']); return true; } diff --git a/application/helpers/surveytranslator_helper.php b/application/helpers/surveytranslator_helper.php index d0d575387b3..26d37d3ee73 100644 --- a/application/helpers/surveytranslator_helper.php +++ b/application/helpers/surveytranslator_helper.php @@ -508,21 +508,13 @@ function getLanguageData($bOrderByNative = false, $sLanguageCode = 'en') $supportedLanguages['fa']['dateformat'] = 6; $supportedLanguages['fa']['radixpoint'] = 0; - // Papiamento (Aruba) - $supportedLanguages['pap-AW']['description'] = gT('Papiamento (Aruba)'); - $supportedLanguages['pap-AW']['nativedescription'] = 'Papiamento'; - $supportedLanguages['pap-AW']['rtl'] = false; - $supportedLanguages['pap-AW']['dateformat'] = 2; - $supportedLanguages['pap-AW']['radixpoint'] = 1; - $supportedLanguages['pap-AW']['cldr'] = 'en'; // Fix me - Yii does not provice Papiamento support, yet - // Papiamento (Curacao and Bonaire) - $supportedLanguages['pap-CW']['description'] = gT('Papiamento (Curaçao and Bonaire)'); + $supportedLanguages['pap-CW']['description'] = gT('Papiamento (Curaçao & Bonaire)'); $supportedLanguages['pap-CW']['nativedescription'] = 'Papiamentu'; $supportedLanguages['pap-CW']['rtl'] = false; $supportedLanguages['pap-CW']['dateformat'] = 2; $supportedLanguages['pap-CW']['radixpoint'] = 1; - $supportedLanguages['pap-CW']['cldr'] = 'en'; // Fix me - Yii does not provice Papiamento support, yet + $supportedLanguages['pap-CW']['cldr'] = 'en'; // Fix me - Yii does not provide Papiamento support, yet // Polish $supportedLanguages['pl']['description'] = gT('Polish'); diff --git a/application/helpers/update/updatedb_helper.php b/application/helpers/update/updatedb_helper.php index fb010a3d117..98c929036f6 100644 --- a/application/helpers/update/updatedb_helper.php +++ b/application/helpers/update/updatedb_helper.php @@ -959,7 +959,7 @@ function db_upgrade_all($iOldDBVersion, $bSilent = false) [ 'extends' => 'vanilla', ], - "extends=''" + "extends = '' AND name != 'vanilla'" ); // If vanilla template is missing, install it. @@ -1021,6 +1021,98 @@ function db_upgrade_all($iOldDBVersion, $bSilent = false) $oTransaction->commit(); } + /** + * Fruit template configuration might be faulty when updating + * from 2.7x, as well as bootswatch. + */ + if ($iOldDBVersion < 345) { + $oTransaction = $oDB->beginTransaction(); + $fruityConf = $oDB + ->createCommand() + ->select('*') + ->from('{{template_configuration}}') + ->where('template_name=:template_name', ['template_name'=>'fruity']) + ->queryRow(); + if ($fruityConf) { + // Brute force way. Just have to hope noone changed the default + // config yet. + $oDB->createCommand()->update( + '{{template_configuration}}', + [ + 'files_css' => '{"add":["css/ajaxify.css","css/animate.css","css/variations/sea_green.css","css/theme.css","css/custom.css"]}', + 'files_js' => '{"add":["scripts/theme.js","scripts/ajaxify.js","scripts/custom.js"]}', + 'files_print_css' => '{"add":["css/print_theme.css"]}', + 'options' => '{"ajaxmode":"off","brandlogo":"on","brandlogofile":"./files/logo.png","container":"on","backgroundimage":"off","backgroundimagefile":"./files/pattern.png","animatebody":"off","bodyanimation":"fadeInRight","bodyanimationduration":"1.0","animatequestion":"off","questionanimation":"flipInX","questionanimationduration":"1.0","animatealert":"off","alertanimation":"shake","alertanimationduration":"1.0","font":"noto","bodybackgroundcolor":"#ffffff","fontcolor":"#444444","questionbackgroundcolor":"#ffffff","questionborder":"on","questioncontainershadow":"on","checkicon":"f00c","animatecheckbox":"on","checkboxanimation":"rubberBand","checkboxanimationduration":"0.5","animateradio":"on","radioanimation":"zoomIn","radioanimationduration":"0.3"}', + 'cssframework_name' => 'bootstrap', + 'cssframework_css' => '{}', + 'cssframework_js' => '', + 'packages_to_load' => '{"add":["pjax","font-noto","moment"]}', + ], + "template_name = 'fruity'" + ); + } else { + $fruityConfData = [ + 'template_name' => 'fruity', + 'sid' => NULL, + 'gsid' => NULL, + 'uid' => NULL, + 'files_css' => '{"add":["css/ajaxify.css","css/animate.css","css/variations/sea_green.css","css/theme.css","css/custom.css"]}', + 'files_js' => '{"add":["scripts/theme.js","scripts/ajaxify.js","scripts/custom.js"]}', + 'files_print_css' => '{"add":["css/print_theme.css"]}', + 'options' => '{"ajaxmode":"off","brandlogo":"on","brandlogofile":"./files/logo.png","container":"on","backgroundimage":"off","backgroundimagefile":"./files/pattern.png","animatebody":"off","bodyanimation":"fadeInRight","bodyanimationduration":"1.0","animatequestion":"off","questionanimation":"flipInX","questionanimationduration":"1.0","animatealert":"off","alertanimation":"shake","alertanimationduration":"1.0","font":"noto","bodybackgroundcolor":"#ffffff","fontcolor":"#444444","questionbackgroundcolor":"#ffffff","questionborder":"on","questioncontainershadow":"on","checkicon":"f00c","animatecheckbox":"on","checkboxanimation":"rubberBand","checkboxanimationduration":"0.5","animateradio":"on","radioanimation":"zoomIn","radioanimationduration":"0.3"}', + 'cssframework_name' => 'bootstrap', + 'cssframework_css' => '{}', + 'cssframework_js' => '', + 'packages_to_load' => '{"add":["pjax","font-noto","moment"]}', + 'packages_ltr' => NULL, + 'packages_rtl' => NULL + ]; + $oDB->createCommand()->insert('{{template_configuration}}', $fruityConfData); + } + $bootswatchConf = $oDB + ->createCommand() + ->select('*') + ->from('{{template_configuration}}') + ->where('template_name=:template_name', ['template_name'=>'bootswatch']) + ->queryRow(); + if ($bootswatchConf) { + $oDB->createCommand()->update( + '{{template_configuration}}', + [ + 'files_css' => '{"add":["css/ajaxify.css","css/theme.css","css/custom.css"]}', + 'files_js' => '{"add":["scripts/theme.js","scripts/ajaxify.js","scripts/custom.js"]}', + 'files_print_css' => '{"add":["css/print_theme.css"]}', + 'options' => '{"ajaxmode":"on","brandlogo":"on","container":"on","brandlogofile":"./files/logo.png"}', + 'cssframework_name' => 'bootstrap', + 'cssframework_css' => '{"replace":[["css/bootstrap.css","css/variations/flatly.min.css"]]}', + 'cssframework_js' => '', + 'packages_to_load' => '{"add":["pjax","font-noto"]}', + ], + "template_name = 'bootswatch'" + ); + } else { + $bootswatchConfData = [ + 'template_name' => 'bootswatch', + 'sid' => NULL, + 'gsid' => NULL, + 'uid' => NULL, + 'files_css' => '{"add":["css/ajaxify.css","css/theme.css","css/custom.css"]}', + 'files_js' => '{"add":["scripts/theme.js","scripts/ajaxify.js","scripts/custom.js"]}', + 'files_print_css' => '{"add":["css/print_theme.css"]}', + 'options' => '{"ajaxmode":"on","brandlogo":"on","container":"on","brandlogofile":"./files/logo.png"}', + 'cssframework_name' => 'bootstrap', + 'cssframework_css' => '{"replace":[["css/bootstrap.css","css/variations/flatly.min.css"]]}', + 'cssframework_js' => '', + 'packages_to_load' => '{"add":["pjax","font-noto"]}', + 'packages_ltr' => NULL, + 'packages_rtl' => NULL + ]; + $oDB->createCommand()->insert('{{template_configuration}}', $bootswatchConfData); + } + $oDB->createCommand()->update('{{settings_global}}', ['stg_value'=>345], "stg_name='DBVersion'"); + $oTransaction->commit(); + } + } catch (Exception $e) { Yii::app()->setConfig('Updating', false); @@ -1040,7 +1132,7 @@ function db_upgrade_all($iOldDBVersion, $bSilent = false) .'

' .htmlspecialchars($e->getMessage()) .'


' - . gT('File') . ' ' . $file .', ' . gT('line') . ' ' . $trace[1]['line'] . '.' + . sprintf(gT('File %s, line %s.'),$file,$trace[1]['line']) ); return false; } diff --git a/application/models/QuestionAttribute.php b/application/models/QuestionAttribute.php index ed46b7e328b..71cccf9f3c1 100644 --- a/application/models/QuestionAttribute.php +++ b/application/models/QuestionAttribute.php @@ -159,6 +159,7 @@ public function setMultiple($iSid, $aQidsAndLang, $aAttributesToUpdate, $aValidQ * @param string $sLanguage restrict to this language (@todo : add it in qanda) * @return array|boolean * @throws CException + * @todo This function needs to be incorporated in the model because it creates a big number of additional queries. For exmaple the default value merging could be done in AfterFind. */ public function getQuestionAttributes($iQuestionID, $sLanguage = null) { @@ -172,6 +173,7 @@ public function getQuestionAttributes($iQuestionID, $sLanguage = null) } $aQuestionAttributes = array(); $oQuestion = Question::model()->find("qid=:qid", array('qid'=>$iQuestionID)); // Maybe take parent_qid attribute before this qid attribute + if ($oQuestion) { if ($sLanguage) { $aLanguages = array($sLanguage); diff --git a/application/models/Survey.php b/application/models/Survey.php index b743b256f50..1218a125126 100755 --- a/application/models/Survey.php +++ b/application/models/Survey.php @@ -186,7 +186,7 @@ public function init() $this->template = Template::templateNameFilter(getGlobalSetting('defaulttheme')); $validator = new LSYii_Validators; $this->language = $validator->languageFilter(Yii::app()->getConfig('defaultlang')); - $this->attachEventHandler("onAfterFind", array($this, 'fixSurveyAttribute')); + $this->attachEventHandler("onAfterFind", array($this, 'afterFindSurvey')); } /** @inheritdoc */ @@ -289,19 +289,25 @@ public static function model($class = __CLASS__) public function relations() { return array( - 'permissions' => array(self::HAS_MANY, 'Permission', array('entity_id'=> 'sid'), 'together' => true), // - 'languagesettings' => array(self::HAS_MANY, 'SurveyLanguageSetting', 'surveyls_survey_id', 'index' => 'surveyls_language', 'together' => true), - 'defaultlanguage' => array(self::BELONGS_TO, 'SurveyLanguageSetting', array('language' => 'surveyls_language', 'sid' => 'surveyls_survey_id'), 'together' => true), - 'correct_relation_defaultlanguage' => array(self::HAS_ONE, 'SurveyLanguageSetting', array('surveyls_language' => 'language', 'surveyls_survey_id' => 'sid'), 'together' => true), - 'owner' => array(self::BELONGS_TO, 'User', 'owner_id', 'together' => true), - 'groups' => array(self::HAS_MANY, 'QuestionGroup', 'sid', 'together' => true, 'order'=>'group_order ASC'), + 'permissions' => array(self::HAS_MANY, 'Permission', array('entity_id'=> 'sid')), // + 'languagesettings' => array(self::HAS_MANY, 'SurveyLanguageSetting', 'surveyls_survey_id', 'index' => 'surveyls_language'), + 'defaultlanguage' => array(self::BELONGS_TO, 'SurveyLanguageSetting', array('language' => 'surveyls_language', 'sid' => 'surveyls_survey_id')), + 'correct_relation_defaultlanguage' => array(self::HAS_ONE, 'SurveyLanguageSetting', array('surveyls_language' => 'language', 'surveyls_survey_id' => 'sid')), + 'owner' => array(self::BELONGS_TO, 'User', 'owner_id',), + 'groups' => array(self::HAS_MANY, 'QuestionGroup', 'sid', 'order'=>'group_order ASC'), 'quotas' => array(self::HAS_MANY, 'Quota', 'sid', 'order'=>'name ASC'), 'surveymenus' => array(self::HAS_MANY, 'Surveymenu', array('survey_id' => 'sid')), - 'surveygroup' => array(self::BELONGS_TO, 'SurveysGroups', array('gsid' => 'gsid'), 'together' => true), + 'surveygroup' => array(self::BELONGS_TO, 'SurveysGroups', array('gsid' => 'gsid')), 'templateModel' => array(self::HAS_ONE, 'Template', array('name' => 'template')) ); } + + /* public function defaultScope() + { + return array('order'=> $this->getTableAlias().'.sid'); + } */ + /** @inheritdoc */ public function scopes() { @@ -386,16 +392,16 @@ public function rules() /** - * fixSurveyAttribute to fix and/or add some survey attribute + * afterFindSurvey to fix and/or add some survey attribute * - Fix template name to be sure template exist */ - public function fixSurveyAttribute() + public function afterFindSurvey() { - $event = new PluginEvent('afterFindSurvey'); + $event = new PluginEvent('afterFindSurvey'); $event->set('surveyid', $this->sid); App()->getPluginManager()->dispatchEvent($event); // set the attributes we allow to be fixed - $allowedAttributes = array('template', 'usecookie', 'allowprev', + $allowedAttributes = array( 'template', 'usecookie', 'allowprev', 'showxquestions', 'shownoanswer', 'showprogress', 'questionindex', 'usecaptcha', 'showgroupinfo', 'showqnumcode', 'navigationdelay'); foreach ($allowedAttributes as $attribute) { @@ -403,7 +409,6 @@ public function fixSurveyAttribute() $this->{$attribute} = $event->get($attribute); } } - $this->template = Template::templateNameFilter($this->template); } @@ -656,6 +661,12 @@ public function getSurveyTemplateConfiguration() return TemplateConfiguration::getInstance(null, null, $this->sid); } + private function __useTranslationForSurveymenu(&$entryData){ + $entryData['title'] = gT($entryData['title']); + $entryData['menu_title'] = gT($entryData['menu_title']); + $entryData['menu_description'] = gT($entryData['menu_description']); + } + private function _createSurveymenuArray($oSurveyMenuObjects) { //Posibility to add more languages to the database is given, so it is possible to add a call by language @@ -686,6 +697,7 @@ private function _createSurveymenuArray($oSurveyMenuObjects) $aEntry['link_external'] = $oDataAttribute->linkExternal; $aEntry['debugData'] = $oDataAttribute->attributes; $aEntry['pjax'] = $oDataAttribute->pjaxed; + $this->__useTranslationForSurveymenu($aEntry); $entries[$aEntry['id']] = $aEntry; } $aResultCollected[$oSurveyMenuObject->id] = [ @@ -1468,10 +1480,6 @@ public function search() $criteria->compare('correct_relation_defaultlanguage.surveyls_title', $this->searched_value, true, 'OR'); $criteria->compare('surveygroup.title', $this->searched_value, true, 'OR'); - - $criteria->compare('t.gsid', [$this->gsid], false, 'AND'); - - // Active filter if (isset($this->active)) { if ($this->active == 'N' || $this->active == "Y") { diff --git a/application/models/SurveyLanguageSetting.php b/application/models/SurveyLanguageSetting.php index befbba4a1ae..4008ab52eac 100644 --- a/application/models/SurveyLanguageSetting.php +++ b/application/models/SurveyLanguageSetting.php @@ -123,6 +123,11 @@ public function rules() array('surveyls_numberformat', 'numerical', 'integerOnly'=>true, 'min'=>'0', 'max'=>'1', 'allowEmpty'=>true), ); } + + public function defaultScope() + { + return array('index'=>'surveyls_language'); + } /** * Defines the customs validation rule lsdefault diff --git a/application/models/Surveymenu.php b/application/models/Surveymenu.php index 693b584ceb9..42b115fe46d 100644 --- a/application/models/Surveymenu.php +++ b/application/models/Surveymenu.php @@ -333,21 +333,25 @@ public function onAfterSave($event) */ public function restoreDefaults() { + $sOldLanguage = App()->language; + App()->setLanguage('en'); + $oDB = Yii::app()->db; $oTransaction = $oDB->beginTransaction(); try { $oDB->createCommand()->truncateTable('{{surveymenu}}'); - $headerArray = ['parent_id', 'survey_id', 'user_id', 'ordering', 'level', 'name', 'title', 'position', 'description', 'active', 'changed_at', 'changed_by', 'created_at', 'created_by']; - $oDB->createCommand()->insert("{{surveymenu}}", array_combine($headerArray, [null, null, null, 0, 0, 'mainmenu', 'Survey menu', 'side', 'Main survey menu', 1, date('Y-m-d H:i:s'), 0, date('Y-m-d H:i:s'), 0])); - $oDB->createCommand()->insert("{{surveymenu}}", array_combine($headerArray, [null, null, null, 0, 0, 'quickmenu', 'Quick menu', 'collapsed', 'Quick menu', 1, date('Y-m-d H:i:s'), 0, date('Y-m-d H:i:s'), 0])); - $oDB->createCommand()->insert("{{surveymenu}}", array_combine($headerArray, [1, null, null, 0, 1, 'pluginmenu', 'Plugin menu', 'side', 'Plugin menu', 1, date('Y-m-d H:i:s'), 0, date('Y-m-d H:i:s'), 0])); - + $basicMenues = LsDefaultDataSets::getSurveyMenuData(); + foreach ($basicMenues as $basicMenu) { + $oDB->createCommand()->insert("{{surveymenu}}", $basicMenu); + } $oTransaction->commit(); } catch (Exception $e) { + App()->setLanguage($sOldLanguage); return false; } + App()->setLanguage($sOldLanguage); return true; } diff --git a/application/models/SurveymenuEntries.php b/application/models/SurveymenuEntries.php index 9640a6b8614..9b5f86acdcd 100644 --- a/application/models/SurveymenuEntries.php +++ b/application/models/SurveymenuEntries.php @@ -508,13 +508,15 @@ public function search() */ public function restoreDefaults() { + $sOldLanguage = App()->language; + App()->setLanguage('en'); $oDB = Yii::app()->db; $oTransaction = $oDB->beginTransaction(); try { $oDB->createCommand()->truncateTable('{{surveymenu_entries}}'); - $basicMenues = LsDefaultDataSet::getSurveyMenuEntryData(); + $basicMenues = LsDefaultDataSets::getSurveyMenuEntryData(); foreach ($basicMenues as $basicMenu) { $oDB->createCommand()->insert("{{surveymenu_entries}}", $basicMenu); } @@ -522,10 +524,12 @@ public function restoreDefaults() $oTransaction->commit(); } catch (Exception $e) { + App()->setLanguage($sOldLanguage); throw $e; return false; } + App()->setLanguage($sOldLanguage); return true; } diff --git a/application/models/Template.php b/application/models/Template.php index 3a4bda3f382..8497d15c0df 100755 --- a/application/models/Template.php +++ b/application/models/Template.php @@ -198,11 +198,15 @@ public function checkTemplate() // Check that extended template is installed. $this->checkTemplateExtends(); + // A template should not extend it self. + $this->checkExtendsItSelf(); + return true; } /** - * Returns false if any of the extended templates are not installed; otherwise true. + * Throws exception if any of the extended templates are not installed; otherwise + * returns true. * @return boolean * @throws Exception if extended template is not installed. */ @@ -222,6 +226,23 @@ public function checkTemplateExtends() return true; } + /** + * @return boolean + * @throws Exception if name equals extends. + */ + public function checkExtendsItSelf() + { + if ($this->name == $this->extends) { + throw new Exception( + sprintf( + 'Error: The template %s extends it self', + $this->name + ) + ); + } + return true; + } + /** * Check if a given Template has a valid XML File * @TODO: check api version diff --git a/application/models/TemplateConfiguration.php b/application/models/TemplateConfiguration.php index 4d8aea3074e..23b0864d07d 100755 --- a/application/models/TemplateConfiguration.php +++ b/application/models/TemplateConfiguration.php @@ -751,7 +751,9 @@ protected function setMotherTemplates() { if (!empty($this->template->extends)) { $sMotherTemplateName = $this->template->extends; - $this->oMotherTemplate = TemplateConfiguration::getInstanceFromTemplateName($sMotherTemplateName)->prepareTemplateRendering($sMotherTemplateName, null); + $instance = TemplateConfiguration::getInstanceFromTemplateName($sMotherTemplateName); + $instance->template->checkTemplate(); + $this->oMotherTemplate = $instance->prepareTemplateRendering($sMotherTemplateName, null); } } diff --git a/application/models/TokenDynamic.php b/application/models/TokenDynamic.php index f97f5e54ae4..4d910868cf3 100644 --- a/application/models/TokenDynamic.php +++ b/application/models/TokenDynamic.php @@ -877,7 +877,7 @@ public function getbuttons() */ public function search() { - $pageSize = Yii::app()->user->getState('pageSize', Yii::app()->params['defaultPageSize']); + $pageSizeTokenView = Yii::app()->user->getState('pageSizeTokenView', Yii::app()->params['defaultPageSize']); $sort = new CSort(); $sort->defaultOrder = 'tid ASC'; @@ -1006,7 +1006,7 @@ public function search() 'sort'=>$sort, 'criteria'=>$criteria, 'pagination'=>array( - 'pageSize'=>$pageSize, + 'pageSize'=>$pageSizeTokenView, ), )); diff --git a/application/views/admin/emailtemplates/email_language_template_tab.php b/application/views/admin/emailtemplates/email_language_template_tab.php index e1585053354..7c9bc97e81e 100644 --- a/application/views/admin/emailtemplates/email_language_template_tab.php +++ b/application/views/admin/emailtemplates/email_language_template_tab.php @@ -35,7 +35,7 @@ 'fillin btn btn-default','data-target'=>"email_{$tab}_{$grouplang}",'data-value'=>$details['default']['body'])); + echo CHtml::button(gT("Reset this template"),array( 'id'=>'reset_template_'.$grouplang.'_'.$tab, 'class'=>'fillin btn btn-default selector__reset_template','data-target'=>"email_{$tab}_{$grouplang}",'data-value'=>$details['default']['body'])); ?> @@ -115,6 +115,9 @@ App()->getClientScript()->registerScript("ScriptEmailTemplateLanguageTemplate__", " $('#validate_expression_".$grouplang."_".$tab."').remoteModal();\n\n + $('#reset_template_".$grouplang."_".$tab."').on('click', function(){ + $('#'+$(this).data('target')).val($(this).data('value')); + });\n\n var prepEmailTemplates = PrepEmailTemplates();\n prepEmailTemplates.init();\n ".implode("\n", $script), LSYii_ClientScript::POS_POSTSCRIPT); diff --git a/application/views/admin/global_settings/_email.php b/application/views/admin/global_settings/_email.php index 8370d3ed098..09ee406d509 100644 --- a/application/views/admin/global_settings/_email.php +++ b/application/views/admin/global_settings/_email.php @@ -39,7 +39,7 @@
-

+

diff --git a/application/views/admin/super/layout_insurvey.php b/application/views/admin/super/layout_insurvey.php index f1262be5255..1d32773a8e4 100644 --- a/application/views/admin/super/layout_insurvey.php +++ b/application/views/admin/super/layout_insurvey.php @@ -32,7 +32,7 @@ echo '
'; diff --git a/application/views/admin/survey/Question/editQuestion_view.php b/application/views/admin/survey/Question/editQuestion_view.php index 82948df48ee..73659fe757d 100644 --- a/application/views/admin/survey/Question/editQuestion_view.php +++ b/application/views/admin/survey/Question/editQuestion_view.php @@ -29,9 +29,6 @@
'form30 ','id'=>'frmeditquestion','name'=>'frmeditquestion')); ?> - - -