Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/LimeSurvey/LimeSurvey.git
Browse files Browse the repository at this point in the history
…into master_RC_AuthPlugin

Dev: fix conflict
* 'master' of https://github.com/LimeSurvey/LimeSurvey.git: (84 commits)
  Dev: remove deprecated code _GetSessionUserRights Dev: USER_RIGHT_INITIALSUPERADMIN replaced by config Dev: and not used since 2.6lts or before
  Fixed issue #13200: LDAP Auth plugin user autocreate broken Dev: just unsubscribe from beforeHasPermission when needed Dev: i hate to find a one line fix after testing, hacking for hours …
  Dev: removed special characters from sidemenu
  Dev: minimal changes and typo fixing
  Dev: translate surveymenuentried
  Fixed issue: language error
  Fixed issue #13212: missing translation frontend survey
  Fixed issue: Emailtemplate reset not working
  Fixed issue #13215: Missing string
  Fixed issue #13216: missing translation
  Updated translation: Catalan by qualitatuvic Updated translation: German by c_schmitz Updated translation: Hungarian by kkd Updated translation: Norwegian (Bokmål) by pmonstad Updated translation: Polish by elissa Updated translation: German (Informal) by c_schmitz Updated translation: Polish (Informal) by elissa
  Fixed issue #13193: Unable to update question type (simple selector)
  Dev: added a demomode command to not only restore mint status but also install some demo surveys
  Fixed issue: Demo rendered unusable with wipe command
  New feature #12240: Validation settings for "array by column" question type
  Fixed issue #13190 : Remove text or uncheck checkbox automatically not work
  Updated translation: Danish by abc99 Updated translation: Georgian by zch5368
  Updated translation: German by c_schmitz Updated translation: Hungarian by kkd Updated translation: Japanese by nomoto Updated translation: Norwegian (Bokmål) by pmonstad Updated translation: Romanian by cdorin
  Fixed issue: Captcha not showing
  Removed translation: Papiamento (Aruba)
  ...

# Conflicts:
#	application/helpers/remotecontrol/remotecontrol_handle.php
  • Loading branch information
Shnoulle committed Jan 19, 2018
2 parents becba13 + 543257f commit abef4c6
Show file tree
Hide file tree
Showing 139 changed files with 3,120 additions and 1,846 deletions.
139 changes: 139 additions & 0 deletions application/commands/DemomodeCommand.php
@@ -0,0 +1,139 @@
<?php
/*
* LimeSurvey (tm)
* Copyright (C) 2011 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
class DemomodeCommand extends CConsoleCommand
{

public function run($sArgument)
{
if (isset($sArgument) && isset($sArgument[0]) && $sArgument[0] = 'yes') {
echo "\n###### Restoring installation to demomode #####\n";
echo "|| Resetting Database\n";
$this->_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;
}

}
}
11 changes: 11 additions & 0 deletions application/commands/WipeCommand.php
Expand Up @@ -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}}";
Expand Down Expand Up @@ -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();
Expand All @@ -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.';
Expand Down
4 changes: 4 additions & 0 deletions application/commands/console.php
Expand Up @@ -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']);
Expand Down
88 changes: 88 additions & 0 deletions application/config/fonts.php
@@ -0,0 +1,88 @@
<?php if (!defined('BASEPATH')) {
exit('No direct script access allowed');
}
/**
* Font packages
* @license GPL v3
* core path is application/core/packages
*
* Note: When debug mode, asset manager is turned off by default.
* To enjoy this feature, add to your package definition a 'devBaseUrl' with the relative url to your package
*
*/
$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 > 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',
),
),

);
10 changes: 7 additions & 3 deletions application/config/internal.php
Expand Up @@ -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'
),
Expand Down Expand Up @@ -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',
),

Expand All @@ -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"),
Expand All @@ -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'),
),

),
Expand Down

0 comments on commit abef4c6

Please sign in to comment.