diff --git a/.gitignore b/.gitignore index ada34299db8..6dd858a4ba3 100644 --- a/.gitignore +++ b/.gitignore @@ -54,5 +54,12 @@ Thumbs.db .buildpath *.un~ launch.json +# ignore plugins directory by default except LS plugin +# if you want to add a new distributed plugin : add the directory here +/plugins/* +!/plugins/index.html +!/plugins/Demo/ +!/plugins/AuditLog/ +enabletests diff --git a/application/config/internal.php b/application/config/internal.php index 927ddcf6a13..c9756a89fe8 100644 --- a/application/config/internal.php +++ b/application/config/internal.php @@ -43,6 +43,7 @@ // Third party path 'third_party' => realpath(__DIR__ . '/../../third_party'), 'core' => realpath(__DIR__ . '/../../assets/packages'), + 'fonts' => realpath(__DIR__ . '/../../fonts'), // yiistrap configuration 'bootstrap' => realpath(__DIR__ . '/../extensions/bootstrap'), @@ -58,6 +59,8 @@ // This line just point application.vendor.Twig to application/third_party/Twig // @see: ETwigViewRenderer::$twigPathAlias 'application.vendor.Twig'=>'application.third_party.Twig', + // 'CaptchaExtendedAction' => realpath(__DIR__ . '/../extensions/captchaExtended/CaptchaExtendedAction.php'), + // 'CaptchaExtendedValidator' => realpath(__DIR__ . '/../extensions/captchaExtended/CaptchaExtendedValidator.php') ), 'modules'=>array( @@ -84,12 +87,13 @@ 'application.models.*', 'application.controllers.*', 'application.modules.*', - 'bootstrap.helpers.*', 'bootstrap.widgets.*', 'bootstrap.behaviors.*', 'yiiwheels.widgets.select2.WhSelect2', - 'third_party.Twig.*' + 'third_party.Twig.*', + 'ext.captchaExtended.CaptchaExtendedAction', + 'ext.captchaExtended.CaptchaExtendedValidator' ), 'preload' => array ('log'), @@ -214,6 +218,8 @@ 'registerGeneralScript' => 'LS_Twig_Extension::registerGeneralScript', 'registerTemplateScript' => 'LS_Twig_Extension::registerTemplateScript', 'registerScript' => 'LS_Twig_Extension::registerScript', + 'unregisterPackage' => 'LS_Twig_Extension::unregisterPackage', + 'listCoreScripts' => 'LS_Twig_Extension::listCoreScripts', 'getAllQuestionClasses' => 'LS_Twig_Extension::getAllQuestionClasses', 'intval' => 'intval', 'empty' => 'empty', @@ -237,7 +243,7 @@ ), 'sandboxConfig' => array( - 'tags' => array('if', 'for', 'set', 'autoescape'), + 'tags' => array('if', 'for', 'set', 'autoescape', 'block'), 'filters' => array('escape', 'raw', 't', 'merge', 'length', 'gT', 'keys'), 'methods' => array( 'ETwigViewRendererStaticClassProxy' => array("encode", "textfield", "form", "link", "emailField", "beginForm", "endForm", "dropDownList", "htmlButton", "passwordfield" ), @@ -248,7 +254,7 @@ 'ETwigViewRendererYiiCoreStaticClassesProxy' => array("Html"), 'LSYii_Application' => array("request"), ), - 'functions' => array('include', 'dump', 'flatEllipsizeText', 'getLanguageData', 'array_flip', 'array_intersect_key', 'registerPublicCssFile', 'registerTemplateCssFile', 'registerGeneralScript', 'registerTemplateScript', 'registerScript', 'getAllQuestionClasses','intval', 'count', 'empty', 'reset', 'renderCaptcha', 'getPost','getParam', 'getQuery', 'isset', 'str_replace', 'assetPublish', 'image', 'sprintf', 'gT' ), + 'functions' => array('include', 'dump', 'flatEllipsizeText', 'getLanguageData', 'array_flip', 'array_intersect_key', 'registerPublicCssFile', 'registerTemplateCssFile', 'registerGeneralScript', 'registerTemplateScript', 'registerScript', 'unregisterPackage', 'listCoreScripts', 'getAllQuestionClasses','intval', 'count', 'empty', 'reset', 'renderCaptcha', 'getPost','getParam', 'getQuery', 'isset', 'str_replace', 'assetPublish', 'image', 'sprintf', 'gT' ), ), ), diff --git a/application/config/packages.php b/application/config/packages.php index 2a7f19a0ee9..c69ed44bc92 100644 --- a/application/config/packages.php +++ b/application/config/packages.php @@ -65,8 +65,8 @@ ), 'bootstrap-rtl'=>array( /* Adding boostrap rtl package */ - 'devBaseUrl' => 'assets/packages/bootstrap-rtl/', - 'basePath' => 'core.bootstrap-rtl', + 'devBaseUrl' => 'assets/packages/bootstrap/', + 'basePath' => 'core.bootstrap', 'css'=> array( 'bootstrap-rtl.css', ), diff --git a/application/config/third_party.php b/application/config/third_party.php index ab4f27bc678..ded633a106e 100755 --- a/application/config/third_party.php +++ b/application/config/third_party.php @@ -8,7 +8,7 @@ /* This allow us to use minified version according to debug */ $debug = isset($userConfig['config']['debug']) ? $userConfig['config']['debug'] : 0; /* To add more easily min version : config > 2 , seems really an core dev issue to fix bootstrap.js ;) */ -$minVersion = ($debug>2) ? "":".min"; +$minVersion = ($debug>0) ? "":".min"; /* Please : comment the reason, mantis bug link: ajax don't need any package if i don't make error */ /* Ajax must renderPartial (better : always return json) and never render and don't registerScript (IMHO) / Shnoulle on 2016-11-16 */ if(isset($_GET['isAjax'])){ @@ -19,6 +19,7 @@ // jQuery 'jquery' => array( + 'devBaseUrl' => 'third_party/jquery', 'basePath' => 'third_party.jquery', 'js' => array( 'jquery-3.1.1'.$minVersion.'.js', @@ -27,16 +28,17 @@ ), // Bootstrap // This package replace the Yiistrap register() function - // Then instead of using the composer dependency system for templates (will be used for LS3) + // Then instead of using the composer dependency system for templates // We can use the package dependency system (easier for now) 'bootstrap' => array( - 'basePath' => 'bootstrap', + 'devBaseUrl' => 'assets/packages/bootstrap/', + 'basePath' => 'core.bootstrap', 'css'=> array( - 'css/bootstrap.css',/* Admin need it, not public */ - 'css/yiistrap.css', + 'bootstrap'.$minVersion.'.css',/* Admin need it, not public */ + 'yiistrap'.$minVersion.'.css', ), 'js'=>array( - 'js/bootstrap'.$minVersion.'.js' + 'bootstrap'.$minVersion.'.js' ), 'depends' => array( 'jquery', @@ -59,14 +61,16 @@ 'fontawesome' => array( //'basePath' => 'third_party.bootstrap', // Need fix third_party alias - 'basePath' => 'third_party.fontawesome', + 'devBaseUrl' => 'fonts/fontawesome/', + 'basePath' => 'fonts.fontawesome', 'css'=> array( - 'css/font-awesome.min.css', + 'css/font-awesome'.$minVersion.'.css', ), ), // jQuery UI 'jqueryui' => array( + 'devBaseUrl' => 'third_party/jquery-ui', 'basePath' => 'third_party.jquery-ui', 'js' => array( 'jquery-ui'.$minVersion.'.js', @@ -188,6 +192,7 @@ // Ace 'ace' => array( + 'devBaseUrl' => 'third_party/ace', 'basePath' => 'third_party.ace', 'js' => array( 'ace.js' @@ -199,6 +204,7 @@ // jQuery Ace 'jquery-ace' => array( + 'devBaseUrl' => 'third_party/jquery-ace', 'basePath' => 'third_party.jquery-ace', 'js' => array( 'jquery.ace.js', @@ -232,6 +238,7 @@ // Decimal.js calculate in js 'decimal' => array( + 'devBaseUrl' => 'third_party/decimal', 'basePath' => 'third_party.decimal', 'js' => array( 'decimal.js' @@ -370,5 +377,14 @@ 'jquery.autocomplete'.$minVersion.'.js' ), ), - + 'jszip' => array( + 'basePath' => 'third_party.jszip', + 'js' => array( + 'jszip.js', + 'fileSaver.js', + ), + 'depends' => array( + 'jquery', + ) + ) ); diff --git a/application/config/version.php b/application/config/version.php index 8cd3decb376..378ba348441 100644 --- a/application/config/version.php +++ b/application/config/version.php @@ -13,8 +13,8 @@ $config['versionnumber'] = '3.0.0-alpha'; //The current version of this branch $config['masterversion'] = '2.62.2'; //The current masters version merged into this branch -$config['dbversionnumber'] = 263; +$config['dbversionnumber'] = 292; $config['buildnumber'] = ''; $config['updatable'] = true; -$config['assetsversionnumber'] = '2647'; +$config['assetsversionnumber'] = '2671'; return $config; diff --git a/application/controllers/InstallerController.php b/application/controllers/InstallerController.php index cc4951eb780..40e86a72dde 100644 --- a/application/controllers/InstallerController.php +++ b/application/controllers/InstallerController.php @@ -885,6 +885,11 @@ function check_DirectoryWriteable($directory, &$data, $base, $keyError, $bRecurs if (!check_PHPFunction('mb_convert_encoding', $aData['mbstringPresent'])) $bProceed = false; + // zlib library check + if (!check_PHPFunction('zlib_get_coding_type', $aData['zlibPresent'])) { + $bProceed = false; + } + // JSON library check if (!check_PHPFunction('json_encode', $aData['bJSONPresent'])) $bProceed = false; diff --git a/application/controllers/OptoutController.php b/application/controllers/OptoutController.php old mode 100644 new mode 100755 index 5248cabe6f0..9036d6090b8 --- a/application/controllers/OptoutController.php +++ b/application/controllers/OptoutController.php @@ -24,11 +24,55 @@ class OptoutController extends LSYii_Controller { public $layout = 'bare'; public $defaultAction = 'tokens'; + + function actiontokens() + { + + + $iSurveyID = Yii::app()->request->getQuery('surveyid'); + $sLanguageCode = Yii::app()->request->getQuery('langcode'); + $sToken = Token::sanitizeToken(Yii::app()->request->getQuery('token')); + + Yii::app()->loadHelper('database'); + Yii::app()->loadHelper('sanitize'); + + //IF there is no survey id, redirect back to the default public page + if (!$iSurveyID){ + $this->redirect(array('/')); + } + + $iSurveyID = (int)$iSurveyID; //Make sure it's an integer (protect from SQL injects) + //Check that there is a SID + // Get passed language from form, so that we dont lose this! + if (!isset($sLanguageCode) || $sLanguageCode == "" || !$sLanguageCode) + { + $sBaseLanguage = Survey::model()->findByPk($iSurveyID)->language; + } + else + { + $sBaseLanguage = sanitize_languagecode($sLanguageCode); + } + + Yii::app()->setLanguage($sBaseLanguage); + + $aSurveyInfo=getSurveyInfo($iSurveyID,$sBaseLanguage); + + if ($aSurveyInfo==false || !tableExists("{{tokens_{$iSurveyID}}}")){ + throw new CHttpException(404, "The survey in which you are trying to participate does not seem to exist. It may have been deleted or the link you were given is outdated or incorrect."); + }else{ + $sMessage = "
".gT('Please confirm that you want to opt out of this survey by clicking the button below.').'
'. gT("After confirmation you won't receive any invitations or reminders for this survey anymore.")."
'; + $this->_renderHtml($sMessage, $aSurveyInfo, $iSurveyID); + } + + + } + /** * This function is run when opting out of an individual token table. The other function /optout/participants * opts the user out of ALL survey invitations from the system */ - function actiontokens() + function actionremovetokens() { $iSurveyID=Yii::app()->request->getQuery('surveyid'); $sLanguageCode=Yii::app()->request->getQuery('langcode'); diff --git a/application/controllers/RegisterController.php b/application/controllers/RegisterController.php index 563ffe5f544..08e63d323d5 100644 --- a/application/controllers/RegisterController.php +++ b/application/controllers/RegisterController.php @@ -48,8 +48,8 @@ public function actions() { return array( 'captcha' => array( - 'class' => 'CCaptchaAction', - 'backColor'=>0xf6f6f6 + 'class' => 'CaptchaExtendedAction', + 'mode'=>CaptchaExtendedAction::MODE_MATH ) ); } @@ -471,7 +471,7 @@ private function display($iSurveyId) $oTemplate = Template::model()->getInstance('', $iSurveyId); Yii::app()->clientScript->registerPackage( 'survey-template' ); - $this->sTemplate=$oTemplate->name; + $this->sTemplate=$oTemplate->sTemplateName; if(!$this->sMessage){ $this->aGlobalData['languagechanger']=makeLanguageChangerSurvey($sLanguage); // Only show language changer shown the form is shown, not after submission $this->aReplacementData['content']=self::getRegisterForm($iSurveyId); diff --git a/application/controllers/SurveyController.php b/application/controllers/SurveyController.php index 628cecaa914..8e97a96f642 100644 --- a/application/controllers/SurveyController.php +++ b/application/controllers/SurveyController.php @@ -80,8 +80,9 @@ public function actions() 'uploader' => 'application.controllers.uploader', 'verification' => 'application.controllers.verification', 'captcha' => array( - 'class' => 'CCaptchaAction', - 'backColor'=>0xf6f6f6 + 'class'=>'CaptchaExtendedAction', + // if needed, modify settings + 'mode'=>CaptchaExtendedAction::MODE_MATH, ) ); } diff --git a/application/controllers/SurveysController.php b/application/controllers/SurveysController.php index 45bf9e47875..3ac104ad9db 100644 --- a/application/controllers/SurveysController.php +++ b/application/controllers/SurveysController.php @@ -31,7 +31,7 @@ public function actionPublicList($lang = null) //$oTemplate->registerAssets(); - $this->sTemplate = $oTemplate->name; + $this->sTemplate = $oTemplate->sTemplateName; //Yii::app()->clientScript->registerPackage( 'survey-template' ); //Yii::app()->clientScript->registerPackage( 'survey-template-'.$oTemplate->sTemplateName ); //var_dump('survey-template-'.$oTemplate->sTemplateName); @@ -70,7 +70,7 @@ public function actionError() { $oTemplate = Template::model()->getInstance(Yii::app()->getConfig("defaulttemplate")); - $this->sTemplate = $oTemplate->name; + $this->sTemplate = $oTemplate->sTemplateName; $error = Yii::app()->errorHandler->error; if ($error){ @@ -81,5 +81,4 @@ public function actionError() } } - } -?> + } \ No newline at end of file diff --git a/application/controllers/admin/NotificationController.php b/application/controllers/admin/NotificationController.php index f1346869611..0173dc035aa 100644 --- a/application/controllers/admin/NotificationController.php +++ b/application/controllers/admin/NotificationController.php @@ -28,17 +28,15 @@ public function index() public function getNotificationAsJSON($notId) { $this->checkPermission(); - - $not = Notification::model()->findByPk($notId); - - if ($not) - { - echo json_encode(array('result' => $not->getAttributes())); + if ((string) (int) $notId !== (string) $notId) { + } - else - { - echo json_encode(array('error' => 'Found no notification with id ' . $notId)); + $not = Notification::model()->findByPk($notId); + if(!$not) { + throw new CHttpException(404,sprintf(gT("Notification %s not found"),$notId)); } + header('Content-type: application/json'); + echo json_encode(array('result' => $not->getAttributes())); } /** @@ -51,17 +49,16 @@ public function notificationRead($notId) { $this->checkPermission(); - try - { - $not = Notification::model()->findByPk($notId); - $result = $not->markAsRead(); - echo json_encode(array('result' => $result)); + if ((string) (int) $notId !== (string) $notId) { + throw new CHttpException(403,gT("Invalid notification id")); } - catch (Exception $ex) - { - echo json_encode(array('error' => $ex->getMessage())); + $not = Notification::model()->findByPk($notId); + if(!$not) { + throw new CHttpException(404,sprintf(gT("Notification %s not found"),$notId)); } - + $result = $not->markAsRead(); + header('Content-type: application/json'); + echo json_encode(array('result' => $result)); } /** @@ -73,7 +70,6 @@ public function notificationRead($notId) public function actionGetMenuWidget($surveyId = null, $showLoader = false) { $this->checkPermission(); - echo self::getMenuWidget($surveyId, $showLoader); } @@ -85,14 +81,14 @@ public function actionGetMenuWidget($surveyId = null, $showLoader = false) public function clearAllNotifications($surveyId = null) { Notification::model()->deleteAll( - 'entity = \'user\' AND entity_id = ' . Yii::app()->user->id + 'entity = :entity AND entity_id = :entity_id', + array(":entity"=>'user',":entity_id"=>Yii::app()->user->id) ); - if (!is_null($surveyId)) - { - $surveyId = intval($surveyId); + if (is_int($surveyId)) { Notification::model()->deleteAll( - 'entity = \'survey\' AND entity_id = ' . $surveyId + 'entity = :entity AND entity_id = :entity_id', + array(":entity"=>'survey',":entity_id"=>$surveyId) ); } } @@ -104,9 +100,8 @@ public function clearAllNotifications($surveyId = null) protected function checkPermission() { // Abort if user is not logged in - if(Yii::app()->user->isGuest) - { - die('No permission'); + if (Yii::app()->user->isGuest) { + throw new CHttpException(401); } } @@ -129,10 +124,13 @@ public static function getMenuWidget($surveyId = null, $showLoader = false) $data = array(); $data['surveyId'] = $surveyId; $data['showLoader'] = $showLoader; - $data['clearAllNotificationsUrl'] = Yii::app()->createUrl('admin/notification', array( + $params=array( 'sa' => 'clearAllNotifications', - 'surveyId' => $surveyId - )); + ); + if ($surveyId) { + $params['surveyId'] = $surveyId; + } + $data['clearAllNotificationsUrl'] = Yii::app()->createUrl('admin/notification', $params); $data['updateUrl'] = Notification::getUpdateUrl($surveyId); $data['nrOfNewNotifications'] = Notification::countNewNotifications($surveyId); $data['nrOfNotifications'] = Notification::countNotifications($surveyId); diff --git a/application/controllers/admin/database.php b/application/controllers/admin/database.php index 03a72507f9e..899d6eee7d4 100644 --- a/application/controllers/admin/database.php +++ b/application/controllers/admin/database.php @@ -1317,6 +1317,30 @@ private function actionInsertCopyQuestion($iSurveyID) $validAttributes = Question::getQuestionTemplateAttributes($validAttributes, $aAttributeValues, $cqr ); $aLanguages=array_merge(array(Survey::model()->findByPk($iSurveyID)->language),Survey::model()->findByPk($iSurveyID)->additionalLanguages); + /* Start to fix some param before save (TODO : use models directly ?) */ + /* Date management */ + Yii::app()->loadHelper('surveytranslator'); + $formatdata=getDateFormatData(Yii::app()->session['dateformat']); + $startdate = App()->request->getPost('startdate'); + if (trim($startdate)=="") + { + $startdate=null; + } + else + { + $datetimeobj = DateTime::createFromFormat($formatdata['phpdate'].' H:i', $startdate ); + $startdate=$datetimeobj->format("Y-m-d H:i:s"); + } + $expires = App()->request->getPost('expires'); + if (trim($expires)=="") + { + $expires=null; + } + else + { + $datetimeobj = DateTime::createFromFormat($formatdata['phpdate'].' H:i', $expires); + $expires=$datetimeobj->format("Y-m-d H:i:s"); + } foreach ($validAttributes as $validAttribute) { diff --git a/application/controllers/admin/dataentry.php b/application/controllers/admin/dataentry.php index c6d5bc323ab..dea95551584 100644 --- a/application/controllers/admin/dataentry.php +++ b/application/controllers/admin/dataentry.php @@ -710,8 +710,8 @@ public function editdata($subaction, $id, $surveyid, $language='') ; if ($idrow[$fname['fieldname']]!='') { - $datetimeobj = new Date_Time_Converter($idrow[$fname['fieldname']], "Y-m-d H:i:s"); - $thisdate = $datetimeobj->convert($dateformatdetails['phpdate']); + $datetimeobj = DateTime::createFromFormat("!Y-m-d H:i:s", $idrow[$fname['fieldname']]); + $thisdate = $datetimeobj->format($dateformatdetails['phpdate']); } else { @@ -1503,12 +1503,10 @@ public function update() $qidattributes = getQuestionAttributeValues($irow['qid']); $dateformatdetails = getDateFormatDataForQID($qidattributes, $thissurvey); - $this->getController()->loadLibrary('Date_Time_Converter'); - $datetimeobj = new date_time_converter($thisvalue,$dateformatdetails['phpdate']) ; + $datetimeobj = DateTime::createFromFormat('!' . $dateformatdetails['phpdate'], $thisvalue); //need to check if library get initialized with new value of constructor or not. - //$datetimeobj = new Date_Time_Converter($thisvalue,$dateformatdetails['phpdate']); - $updateqr .= dbQuoteID($fieldname)." = '{$datetimeobj->convert("Y-m-d H:i:s")}', \n"; + $updateqr .= dbQuoteID($fieldname)." = '{$datetimeobj->format("Y-m-d H:i:s")}', \n"; } } elseif (($irow['type'] == 'N' || $irow['type'] == 'K') && $thisvalue == "") @@ -1766,11 +1764,10 @@ public function insert() } elseif ($irow['type'] == 'D') { - Yii::app()->loadLibrary('Date_Time_Converter'); $qidattributes = getQuestionAttributeValues($irow['qid']); $dateformatdetails = getDateFormatDataForQID($qidattributes, $thissurvey); - $datetimeobj = new Date_Time_Converter($_POST[$fieldname],$dateformatdetails['phpdate']); - $insert_data[$fieldname] = $datetimeobj->convert("Y-m-d H:i:s"); + $datetimeobj = DateTime::createFromFormat('!' . $dateformatdetails['phpdate'], $_POST[$fieldname]); + $insert_data[$fieldname] = $datetimeobj->format("Y-m-d H:i:s"); } else { @@ -2466,23 +2463,21 @@ private function _array_filter_help($qidattributes, $surveyprintlang, $surveyid) if(!empty($qidattributes['array_filter'])) { - $newquestiontext = Question::model()->findByAttributes(array('title' => $qidattributes['array_filter'], 'language' => $surveyprintlang, 'sid' => $surveyid)); - if(is_object($newquestiontext)) - { - $newquestiontext->getAttribute('question'); + /** @var Question $question */ + $question = Question::model()->findByAttributes(array('title' => $qidattributes['array_filte'], 'language' => $surveyprintlang, 'sid' => $surveyid)); + if($question) { $output .= "\n
- ".sprintf(gT("Only answer this question for the items you selected in question %s ('%s')"),$qidattributes['array_filter'], flattenText(breakToNewline($newquestiontext)))." + ".sprintf(gT("Only answer this question for the items you selected in question %s ('%s')"),$qidattributes['array_filter'], flattenText(breakToNewline($question->question)))."
\n"; } } if(!empty($qidattributes['array_filter_exclude'])) { - $newquestiontext = Question::model()->findByAttributes(array('title' => $qidattributes['array_filter_exclude'], 'language' => $surveyprintlang, 'sid' => $surveyid)); - if(is_object($newquestiontext)) - { - $newquestiontext->getAttribute('question'); + /** @var Question $question */ + $question = Question::model()->findByAttributes(array('title' => $qidattributes['array_filter_exclude'], 'language' => $surveyprintlang, 'sid' => $surveyid)); + if($question) { $output .= "\n- ".sprintf(gT("Only answer this question for the items you did not select in question %s ('%s')"),$qidattributes['array_filter_exclude'], breakToNewline($newquestiontext))." + ".sprintf(gT("Only answer this question for the items you did not select in question %s ('%s')"),$qidattributes['array_filter_exclude'], breakToNewline($question->question))."
\n"; } } diff --git a/application/controllers/admin/export.php b/application/controllers/admin/export.php index cdf8d73d5fd..45b96b88cd4 100644 --- a/application/controllers/admin/export.php +++ b/application/controllers/admin/export.php @@ -1370,7 +1370,7 @@ public function quexml($iSurveyID) */ private function _exportPrintableHtmls($iSurveyID,$readFile = true){ $oSurvey = Survey::model()->findByPk($iSurveyID); - $assetsDir = Template::getTemplateURL($oSurvey->template); + $assetsDir = substr(Template::getTemplateURL($oSurvey->template),1); $fullAssetsDir = Template::getTemplatePath($oSurvey->template); $aLanguages = $oSurvey->getAllLanguages(); diff --git a/application/controllers/admin/homepagesettings.php b/application/controllers/admin/homepagesettings.php index 442d86bc434..da2bd1494d1 100644 --- a/application/controllers/admin/homepagesettings.php +++ b/application/controllers/admin/homepagesettings.php @@ -56,6 +56,11 @@ public function create() $model=new Boxes; if(isset($_POST['Boxes'])) { + if (Yii::app()->getConfig('demoMode')) + { + Yii::app()->setFlashMessage(gT('This setting cannot be changed because demo mode is active.'),'error'); + $this->getController()->redirect(Yii::app()->getController()->createUrl("/admin/homepagesettings")); + } $model->attributes=$_POST['Boxes']; if($model->save()) { diff --git a/application/controllers/admin/htmleditor_pop.php b/application/controllers/admin/htmleditor_pop.php index 586f017c05f..b5627c82ab5 100644 --- a/application/controllers/admin/htmleditor_pop.php +++ b/application/controllers/admin/htmleditor_pop.php @@ -39,8 +39,7 @@ function index() $aData['sControlIdDis'] = $aData['sFieldName'] . '_popupctrldis'; $aData['toolbarname'] = 'popup'; $aData['htmlformatoption'] = ''; - - if (in_array($aData['sFieldType'], array('email-inv', 'email-reg', 'email-conf', 'email-rem'))) + if (in_array($aData['sFieldType'], array('email-invitation', 'email-registration', 'email-confirmation', 'email-reminder'))) { $aData['htmlformatoption'] = ',fullPage:true'; } diff --git a/application/controllers/admin/limereplacementfields.php b/application/controllers/admin/limereplacementfields.php index e604c65d78a..d9db2fde955 100644 --- a/application/controllers/admin/limereplacementfields.php +++ b/application/controllers/admin/limereplacementfields.php @@ -26,7 +26,6 @@ public function index() throw new CHttpException(401); } list($replacementFields, $isInsertAnswerEnabled) = $this->_getReplacementFields($fieldtype, $surveyid); - if ($isInsertAnswerEnabled === true) { //2: Get all other questions that occur before this question that are pre-determined answer types @@ -42,6 +41,7 @@ public function index() } $data['countfields'] = count($replacementFields); + asort($replacementFields); $data['replFields'] = $replacementFields; if (isset($childQuestions)) { $data['cquestions'] = $childQuestions; @@ -208,99 +208,103 @@ private function _getReplacementFields($fieldtype, $surveyid) case 'editdescription': // for translation case 'editwelcome': // for translation case 'editend': // for translation - $replFields[] = array('TOKEN:FIRSTNAME', gT("First name from token")); - $replFields[] = array('TOKEN:LASTNAME', gT("Last name from token")); - $replFields[] = array('TOKEN:EMAIL', gT("Email from the token")); + $replFields['TOKEN:FIRSTNAME']= gT("First name from token"); + $replFields['TOKEN:LASTNAME']= gT("Last name from token"); + $replFields['TOKEN:EMAIL']= gT("Email from the token"); $attributes = getTokenFieldsAndNames($surveyid, true); foreach ($attributes as $attributefield => $attributedescription) { - $replFields[] = array('TOKEN:' . strtoupper($attributefield), sprintf(gT("Token attribute: %s"), $attributedescription['description'])); + $replFields['TOKEN:' . strtoupper($attributefield)]= sprintf(gT("Token attribute: %s"), $attributedescription['description']); } - $replFields[] = array('EXPIRY', gT("Survey expiration date")); - $replFields[] = array('ADMINNAME', gT("Name of the survey administrator")); - $replFields[] = array('ADMINEMAIL', gT("Email address of the survey administrator")); + $replFields['EXPIRY']= gT("Survey expiration date"); + $replFields['ADMINNAME']= gT("Name of the survey administrator"); + $replFields['ADMINEMAIL']= gT("Email address of the survey administrator"); return array($replFields, false); case 'email-admin_notification': case 'email-admin_detailed_notification': - $replFields[] = array('RELOADURL', gT("Reload URL")); - $replFields[] = array('VIEWRESPONSEURL', gT("View response URL")); - $replFields[] = array('EDITRESPONSEURL', gT("Edit response URL")); - $replFields[] = array('STATISTICSURL', gT("Statistics URL")); - $replFields[] = array('TOKEN', gT("Token code for this participant")); - $replFields[] = array('TOKEN:FIRSTNAME', gT("First name from token")); - $replFields[] = array('TOKEN:LASTNAME', gT("Last name from token")); - $replFields[] = array('SURVEYNAME', gT("Name of the survey")); - $replFields[] = array('SURVEYDESCRIPTION', gT("Description of the survey")); + $replFields['RELOADURL']= gT("Reload URL"); + $replFields['VIEWRESPONSEURL']= gT("View response URL"); + $replFields['EDITRESPONSEURL']= gT("Edit response URL"); + $replFields['STATISTICSURL']= gT("Statistics URL"); + $replFields['TOKEN']= gT("Token code for this participant"); + $replFields['TOKEN:FIRSTNAME']= gT("First name from token"); + $replFields['TOKEN:LASTNAME']= gT("Last name from token"); + $replFields['SURVEYNAME']= gT("Survey title"); + $replFields['SID']= gT("Survey ID"); + $replFields['SURVEYDESCRIPTION']= gT("Survey description"); $attributes = getTokenFieldsAndNames($surveyid, true); - foreach ($attributes as $attributefield => $attributedescription) - { - $replFields[] = array(strtoupper($attributefield), sprintf(gT("Token attribute: %s"), $attributedescription['description'])); + foreach ($attributes as $attributefield => $attributedescription) { + $replFields[strtoupper($attributefield)] = sprintf(gT("Token attribute: %s"), $attributedescription['description']); } - $replFields[] = array('ADMINNAME', gT("Name of the survey administrator")); - $replFields[] = array('ADMINEMAIL', gT("Email address of the survey administrator")); + $replFields['ADMINNAME']= gT("Name of the survey administrator"); + $replFields['ADMINEMAIL']= gT("Email address of the survey administrator"); return array($replFields, false); case 'email-admin-resp': - $replFields[] = array('RELOADURL', gT("Reload URL")); - $replFields[] = array('VIEWRESPONSEURL', gT("View response URL")); - $replFields[] = array('EDITRESPONSEURL', gT("Edit response URL")); - $replFields[] = array('STATISTICSURL', gT("Statistics URL")); - $replFields[] = array('ANSWERTABLE', gT("Answers from this response")); - $replFields[] = array('TOKEN', gT("Token code for this participant")); - $replFields[] = array('TOKEN:FIRSTNAME', gT("First name from token")); - $replFields[] = array('TOKEN:LASTNAME', gT("Last name from token")); - $replFields[] = array('SURVEYNAME', gT("Name of the survey")); - $replFields[] = array('SURVEYDESCRIPTION', gT("Description of the survey")); + $replFields['RELOADURL']= gT("Reload URL"); + $replFields['VIEWRESPONSEURL']= gT("View response URL"); + $replFields['EDITRESPONSEURL']= gT("Edit response URL"); + $replFields['STATISTICSURL']= gT("Statistics URL"); + $replFields['ANSWERTABLE']= gT("Answers from this response"); + $replFields['TOKEN']= gT("Token code for this participant"); + $replFields['TOKEN:FIRSTNAME']= gT("First name from token"); + $replFields['TOKEN:LASTNAME']= gT("Last name from token"); + $replFields['SURVEYNAME']= gT("Survey title"); + $replFields['SID']= gT("Survey ID"); + $replFields['SURVEYDESCRIPTION']= gT("Survey description"); $attributes = getTokenFieldsAndNames($surveyid, true); foreach ($attributes as $attributefield => $attributedescription) { - $replFields[] = array(strtoupper($attributefield), sprintf(gT("Token attribute: %s"), $attributedescription['description'])); + $replFields[strtoupper($attributefield)] = sprintf(gT("Token attribute: %s"), $attributedescription['description']); } - $replFields[] = array('ADMINNAME', gT("Name of the survey administrator")); - $replFields[] = array('ADMINEMAIL', gT("Email address of the survey administrator")); + $replFields['ADMINNAME']= gT("Name of the survey administrator"); + $replFields['ADMINEMAIL']= gT("Email address of the survey administrator"); return array($replFields, false); case 'email-invitation': case 'email-reminder': // these 2 fields are supported by email-inv and email-rem // but not email-reg for the moment - $replFields[] = array('EMAIL', gT("Email from the token")); - $replFields[] = array('TOKEN', gT("Token code for this participant")); - $replFields[] = array('OPTOUTURL', gT("URL for a respondent to opt-out of this survey")); - $replFields[] = array('OPTINURL', gT("URL for a respondent to opt-in to this survey")); + $replFields['EMAIL']= gT("Email from the token"); + $replFields['TOKEN']= gT("Token code for this participant"); + $replFields['OPTOUTURL']= gT("URL for a respondent to opt-out of this survey"); + $replFields['OPTINURL']= gT("URL for a respondent to opt-in to this survey"); + // $replFields['SID']= gT("Survey ID"); case 'email-registration': - $replFields[] = array('FIRSTNAME', gT("First name from token")); - $replFields[] = array('LASTNAME', gT("Last name from token")); - $replFields[] = array('SURVEYNAME', gT("Name of the survey")); - $replFields[] = array('SURVEYDESCRIPTION', gT("Description of the survey")); + $replFields['FIRSTNAME']= gT("First name from token"); + $replFields['LASTNAME']= gT("Last name from token"); + $replFields['SURVEYNAME']= gT("Survey title"); + $replFields['SID']= gT("Survey ID"); + $replFields['SURVEYDESCRIPTION']= gT("Survey description"); $attributes = getTokenFieldsAndNames($surveyid, true); foreach ($attributes as $attributefield => $attributedescription) { - $replFields[] = array(strtoupper($attributefield), sprintf(gT("Token attribute: %s"), $attributedescription['description'])); + $replFields[strtoupper($attributefield)] = sprintf(gT("Token attribute: %s"), $attributedescription['description']); } - $replFields[] = array('ADMINNAME', gT("Name of the survey administrator")); - $replFields[] = array('ADMINEMAIL', gT("Email address of the survey administrator")); - $replFields[] = array('SURVEYURL', gT("URL of the survey")); - $replFields[] = array('EXPIRY', gT("Survey expiration date")); + $replFields['ADMINNAME']= gT("Name of the survey administrator"); + $replFields['ADMINEMAIL']= gT("Email address of the survey administrator"); + $replFields['SURVEYURL']= gT("URL of the survey"); + $replFields['EXPIRY']= gT("Survey expiration date"); return array($replFields, false); case 'email-confirmation': - $replFields[] = array('TOKEN', gT("Token code for this participant")); - $replFields[] = array('FIRSTNAME', gT("First name from token")); - $replFields[] = array('LASTNAME', gT("Last name from token")); - $replFields[] = array('EMAIL', gT("Email from token")); - $replFields[] = array('SURVEYNAME', gT("Name of the survey")); - $replFields[] = array('SURVEYDESCRIPTION', gT("Description of the survey")); + $replFields['TOKEN']= gT("Token code for this participant"); + $replFields['FIRSTNAME']= gT("First name from token"); + $replFields['LASTNAME']= gT("Last name from token"); + $replFields['EMAIL']= gT("Email from token"); + $replFields['SURVEYNAME']= gT("Survey title"); + $replFields['SID']= gT("Survey ID"); + $replFields['SURVEYDESCRIPTION']= gT("Survey description"); $attributes = getTokenFieldsAndNames($surveyid, true); foreach ($attributes as $attributefield => $attributedescription) { - $replFields[] = array(strtoupper($attributefield), sprintf(gT("Token attribute: %s"), $attributedescription['description'])); + $replFields[strtoupper($attributefield)]= sprintf(gT("Token attribute: %s"), $attributedescription['description']); } - $replFields[] = array('ADMINNAME', gT("Name of the survey administrator")); - $replFields[] = array('ADMINEMAIL', gT("Email address of the survey administrator")); - $replFields[] = array('SURVEYURL', gT("URL of the survey")); - $replFields[] = array('EXPIRY', gT("Survey expiration date")); + $replFields['ADMINNAME']= gT("Name of the survey administrator"); + $replFields['ADMINEMAIL']= gT("Email address of the survey administrator"); + $replFields['SURVEYURL']= gT("URL of the survey"); + $replFields['EXPIRY']= gT("Survey expiration date"); // email-conf can accept insertans fields for non anonymous surveys if (isset($surveyid)) { @@ -318,25 +322,25 @@ private function _getReplacementFields($fieldtype, $surveyid) case 'editgroup_desc': // for translation case 'editquestion': // for translation case 'editquestion_help': // for translation - $replFields[] = array('TOKEN:FIRSTNAME', gT("First name from token")); - $replFields[] = array('TOKEN:LASTNAME', gT("Last name from token")); - $replFields[] = array('TOKEN:EMAIL', gT("Email from the token")); - $replFields[] = array('SID', gT("This question's survey ID number")); - $replFields[] = array('GID', gT("This question's group ID number")); - $replFields[] = array('QID', gT("This question's question ID number")); - $replFields[] = array('SGQ', gT("This question's SGQA code")); + $replFields['TOKEN:FIRSTNAME']= gT("First name from token"); + $replFields['TOKEN:LASTNAME']= gT("Last name from token"); + $replFields['TOKEN:EMAIL']= gT("Email from the token"); + $replFields['SID']= gT("This question's survey ID number"); + $replFields['GID']= gT("This question's group ID number"); + $replFields['QID']= gT("This question's question ID number"); + $replFields['SGQ']= gT("This question's SGQA code"); $attributes = getTokenFieldsAndNames($surveyid, true); foreach ($attributes as $attributefield => $attributedescription) { - $replFields[] = array('TOKEN:' . strtoupper($attributefield), sprintf(gT("Token attribute: %s"), $attributedescription['description'])); + $replFields['TOKEN:' . strtoupper($attributefield)]= sprintf(gT("Token attribute: %s"), $attributedescription['description']); } - $replFields[] = array('EXPIRY', gT("Survey expiration date")); + $replFields['EXPIRY']= gT("Survey expiration date"); case 'editanswer': return array($replFields, true); case 'assessment-text': - $replFields[] = array('TOTAL', gT("Overall assessment score")); - $replFields[] = array('PERC', gT("Assessment group score")); + $replFields['TOTAL']= gT("Overall assessment score"); + $replFields['PERC']= gT("Assessment group score"); return array($replFields, false); } } diff --git a/application/controllers/admin/questiongroups.php b/application/controllers/admin/questiongroups.php index c8efc21268f..50c74af9d24 100644 --- a/application/controllers/admin/questiongroups.php +++ b/application/controllers/admin/questiongroups.php @@ -209,6 +209,7 @@ public function insert($surveyid) $oGroup=new QuestionGroup; $oGroup->sid=$surveyid; if(isset($newGroupID)){ + switchMSSQLIdentityInsert('groups',true); $oGroup->gid=$newGroupID; } $oGroup->group_name = Yii::app()->request->getPost('group_name_' . $sLanguage,""); @@ -224,6 +225,10 @@ public function insert($surveyid) if(!isset($newGroupID)){ $newGroupID=$oGroup->gid; } + else + { + switchMSSQLIdentityInsert('groups',true); + } }else{ Yii::app()->setFlashMessage(CHtml::errorSummary($oGroup),'error'); } diff --git a/application/controllers/admin/questions.php b/application/controllers/admin/questions.php index 6ee5c384aa5..4caae9a93f5 100644 --- a/application/controllers/admin/questions.php +++ b/application/controllers/admin/questions.php @@ -897,8 +897,9 @@ public function getSubquestionRowForAllLanguages($surveyid, $gid, $qid, $codes, /** * AJAX Method to QuickAdd multiple Rows AJAX-based */ - public function getSubquestionRowQuickAdd( $surveyid, $gid, $qid, $codes, $language, $first, $scale_id, $type, $position, $assessmentvisible='' ) + public function getSubquestionRowQuickAdd( $surveyid, $gid, $qid, $codes, $language, $first, $scale_id, $type, $position=null, $assessmentvisible='' ) { + $qid = '{{quid_placeholder}}'; echo $this->getSubquestionRow( $surveyid, $gid, $qid, $codes, $language, $first, $scale_id, $type, $position, $assessmentvisible ); } /** @@ -1418,12 +1419,13 @@ public function deleteMultiple() if (is_object($oQuestion)) { - $aResults[$iQid]['question'] = viewHelper::flatEllipsizeText($oQuestion->question,true,0); - $aResults[$iQid]['result'] = $this->delete($oQuestion->sid, $oQuestion->gid, $iQid, true ); + $aResults[$iQid]['title'] = viewHelper::flatEllipsizeText($oQuestion->question,true,0); + $result = $this->delete($oQuestion->sid, $oQuestion->gid, $iQid, true ); + $aResults[$iQid]['result'] = $result['status']; } } - Yii::app()->getController()->renderPartial('/admin/survey/Question/massive_actions/_action_results', array('aResults'=>$aResults,'successLabel'=>gT('Deleted'))); + Yii::app()->getController()->renderPartial('ext.admin.survey.ListSurveysWidget.views.massive_actions._action_results', array('aResults'=>$aResults,'successLabel'=>gT('Deleted'))); } /** diff --git a/application/controllers/admin/remotecontrol.php b/application/controllers/admin/remotecontrol.php index eddd0e0a4c7..4afa2cc1305 100644 --- a/application/controllers/admin/remotecontrol.php +++ b/application/controllers/admin/remotecontrol.php @@ -66,10 +66,9 @@ public function run() } LSjsonRPCServer::handle($oHandler); } - foreach (App()->log->routes as $route) - { - $route->enabled = $route->enabled && !($route instanceOf CWebLogRoute); - } + foreach (App()->log->routes as $route) { + $route->enabled = $route->enabled && !($route instanceOf CWebLogRoute); + } exit; } else { @@ -80,15 +79,14 @@ public function run() /* @var $method ReflectionMethod */ if (substr($method->getName(),0,1) !== '_') { $list[$method->getName()] = array( - 'description' => str_replace(array("\r", "\r\n", "\n"), "