Skip to content

Commit

Permalink
Merge branch 'develop' of git@github.com:LimeSurvey/LimeSurvey.git in…
Browse files Browse the repository at this point in the history
…to bs-package
  • Loading branch information
Shnoulle committed Dec 17, 2016
2 parents f7509b5 + 0fd6840 commit d5b0148
Show file tree
Hide file tree
Showing 259 changed files with 19,090 additions and 805 deletions.
5 changes: 1 addition & 4 deletions application/commands/PluginCommand.php
Expand Up @@ -17,14 +17,11 @@ class PluginCommand extends CConsoleCommand

public function actionCron($interval)
{

$pm = \Yii::app()->pluginManager;
$event = new PluginEvent('cron');
$event->set('interval', $interval);
$pm->dispatchEvent($event);


}
}

?>
?>
23 changes: 16 additions & 7 deletions application/commands/console.php
@@ -1,5 +1,5 @@
#!/usr/bin/php
<?php
<?php
/*
* LimeSurvey (tm)
* Copyright (C) 2011 The LimeSurvey Project Team / Carsten Schmitz
Expand All @@ -11,7 +11,7 @@
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
*
*
* File edited by Sam Mousa for Marcel Minke.
* This loader bypasses the default Yii loader and loads a custom console class instead.
*/
Expand All @@ -28,19 +28,27 @@
require_once(dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'framework' . DIRECTORY_SEPARATOR . 'yii.php');
// Load configuration.
$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');
$core = dirname($sCurrentDir) . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR;
if(isset($config['config'])){
$settings=array_merge($settings,$config['config']);
}
unset ($config['defaultController']);
unset ($config['config']);


/* fix runtime path, unsure you can lauch function anywhere (if you use php /var/www/limesurvey/... : can be /root/ for config */
$runtimePath=$settings['tempdir'].'/runtime';
if(!is_dir($runtimePath) || !is_writable($runtimePath)){
$runtimePath=str_replace($settings['rootdir'],dirname(dirname(dirname(__FILE__))),$runtimePath);
}
$config['runtimePath']=$runtimePath;

// fix for fcgi
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));

defined('YII_DEBUG') or define('YII_DEBUG',true);



if(isset($config))
{
Expand All @@ -49,8 +57,9 @@
define('APPPATH', Yii::app()->getBasePath() . DIRECTORY_SEPARATOR);
$app->commandRunner->addCommands(YII_PATH.'/cli/commands');
$env=@getenv('YII_CONSOLE_COMMANDS');
if(!empty($env))
if(!empty($env)){
$app->commandRunner->addCommands($env);
}
}
$app->run();
?>
?>
3 changes: 3 additions & 0 deletions application/config/config-defaults.php
Expand Up @@ -680,5 +680,8 @@
// Side Menu behaviout
$config['sideMenuBehaviour']='adaptive';

// Hide update key
$config['hide_update_key']=false;

return $config;
//settings deleted
49 changes: 49 additions & 0 deletions application/config/internal.php
Expand Up @@ -51,6 +51,13 @@
// yiiwheels configuration
'yiiwheels' => realpath(__DIR__ . '/../extensions/yiiwheels'),
'vendor.twbs.bootstrap.dist',

// Twig aliases. We don't want to change the file ETwigViewRenderer, so we can update it without difficulties
// However, LimeSurvey directory tree is not a standard Yii Application tree.
// we use 'third_party' instead of 'vendor'
// This line just point application.vendor.Twig to application/third_party/Twig
// @see: ETwigViewRenderer::$twigPathAlias
'application.vendor.Twig'=>'application.third_party.Twig',
),

'modules'=>array(
Expand Down Expand Up @@ -82,6 +89,7 @@
'bootstrap.widgets.*',
'bootstrap.behaviors.*',
'yiiwheels.widgets.select2.WhSelect2',
'third_party.Twig.*'

),
'preload' => array ('log'),
Expand Down Expand Up @@ -170,6 +178,47 @@
'format'=>array(
'class'=>'application.extensions.CustomFormatter'
),

'twigRenderer' => array(
'class' => 'application.core.LSETwigViewRenderer',

// All parameters below are optional, change them to your needs
'fileExtension' => '.twig',
'options' => array(
'autoescape' => true,
),
// Those extensions, include the sendbox, will be done later in the process
'extensions' => array(
'Twig_Extension_Sandbox',
'Twig_Extension_StringLoader',
),
'globals' => array(
'html' => 'CHtml'
),
'functions' => array(
'rot13' => 'str_rot13',
),
'filters' => array(
'jencode' => 'CJSON::encode',
),
'sandboxConfig' => array(
'tags' => array('if', 'for'),
'filters' => array('escape'),
'methods' => array(),
'properties' => array(),
'functions' => array()
)

// Change template syntax to Smarty-like (not recommended)
// Could be use to manage potential conflict with Expression Manager
/*
'lexerOptions' => array(
'tag_comment' => array('{*', '*}'),
'tag_block' => array('{', '}'),
'tag_variable' => array('{$', '}')
),
*/
),
)
);

Expand Down
1 change: 0 additions & 1 deletion application/config/packages.php
Expand Up @@ -36,7 +36,6 @@
),
'depends' => array(
'limesurvey-public',
//'bootstrap', //limesurvey in future must work without boostrap
)
),
'template-default-ltr'=>array( /* complement for ltr */
Expand Down
4 changes: 2 additions & 2 deletions application/config/third_party.php
Expand Up @@ -7,8 +7,8 @@
/* Tag if debug is set : debug is set in user config file and this file is directly required in internal.php where $userConfig var arry is set */
/* 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 */
$minVersion = ($debug<2) ? ".min": "";
/* To add more easily min version : config > 2 , seems really an core dev issue to fix bootstrap.js ;) */
$minVersion = ($debug>2) ? "":".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'])){
Expand Down
4 changes: 2 additions & 2 deletions application/controllers/RegisterController.php
Expand Up @@ -147,9 +147,9 @@ public function getRegisterErrors($iSurveyId){
// Check the security question's answer
if (function_exists("ImageCreate") && isCaptchaEnabled('registrationscreen',$aSurveyInfo['usecaptcha']) )
{
$sLoadsecurity=Yii::app()->request->getPost('loadsecurity','');
$sLoadSecurity=Yii::app()->request->getPost('loadsecurity','');
$captcha=Yii::app()->getController()->createAction("captcha");
$captchaCorrect = $captcha->validate( $sLoadsecurity, false);
$captchaCorrect = $captcha->validate( $sLoadSecurity, false);

if (!$captchaCorrect)
{
Expand Down
67 changes: 44 additions & 23 deletions application/controllers/admin/templates.php
Expand Up @@ -79,11 +79,9 @@ public function templatezip($templatename)
*/
public function tmp($id)
{
$iTime= preg_replace("/[^0-9]$/", '', $id);
$iTime = $id = CHtml::encode($id);
$sFile = Yii::app()->getConfig("tempdir").DIRECTORY_SEPARATOR."template_temp_{$iTime}.html";

$id = CHtml::encode($id);

if(!is_file($sFile) || !file_exists($sFile)) {
die("Found no file with id " . $id);
}
Expand Down Expand Up @@ -596,7 +594,7 @@ public function templatesavechanges()
$this->getController()->redirect(array("admin/templates/sa/upload"));
}

$savefilename = gettemplatefilename(Yii::app()->getConfig('usertemplaterootdir') . "/" . $sTemplateName, $editfile);
$savefilename = gettemplatefilename($sTemplateName, $editfile);

if (is_writable($savefilename))
{
Expand Down Expand Up @@ -887,7 +885,8 @@ protected function _initialise($templatename, $screenname, $editfile, $showsumma
$screens['printanswers'] = gT('Print answers page','unescaped');
$screens['printablesurvey'] = gT('Printable survey page','unescaped');

// Page display blocks
/* pstpl file list */
/* used for call AND for pstl editable files list */
$SurveyList = array('startpage.pstpl',
'surveylist.pstpl',
'endpage.pstpl'
Expand All @@ -898,6 +897,7 @@ protected function _initialise($templatename, $screenname, $editfile, $showsumma
'navigator.pstpl',
'endpage.pstpl'
);
/* Not used : data updated during rendering */
$Question = array('startpage.pstpl',
'survey.pstpl',
'startgroup.pstpl',
Expand All @@ -913,27 +913,33 @@ protected function _initialise($templatename, $screenname, $editfile, $showsumma
'completed.pstpl',
'endpage.pstpl'
);
/* Not used */
$Clearall = array('startpage.pstpl',
'clearall.pstpl',
'endpage.pstpl'
);
/* Not used */
$Register = array('startpage.pstpl',
'survey.pstpl',
'register.pstpl',
'endpage.pstpl'
);
/* Not used */
$Save = array('startpage.pstpl',
'save.pstpl',
'endpage.pstpl'
);
/* Not used */
$Load = array('startpage.pstpl',
'load.pstpl',
'endpage.pstpl'
);
/* Not used */
$printtemplate = array('startpage.pstpl',
'printanswers.pstpl',
'endpage.pstpl'
);
/* Not used */
$printablesurveytemplate = array('print_survey.pstpl',
'print_group.pstpl',
'print_question.pstpl'
Expand Down Expand Up @@ -1092,18 +1098,20 @@ protected function _initialise($templatename, $screenname, $editfile, $showsumma
switch ($screenname)
{
case 'surveylist':
$aSurveyListTexts = array(
"nosid" => gT("You have not provided a survey identification number"),
"contact" => sprintf(gT("Please contact %s ( %s ) for further assistance."), Yii::app()->getConfig("siteadminname"), Yii::app()->getConfig("siteadminemail")),
"listheading" => gT("The following surveys are available:"),
"list" => $this->getController()->renderPartial('/admin/templates/templateeditor_surveylist_view', array(), true),
$aSurveyList = array(
'publicSurveys' => Survey::model()->active()->open()->public()->with('languagesettings')->findAll(),
'futureSurveys' => Survey::model()->active()->registration()->public()->with('languagesettings')->findAll(),
);
$aData['surveylist'] = $aSurveyListTexts;
$aData['aReplacements'] = $aGlobalReplacements;
$aReplacementSurveyList = array(
"SURVEYCONTACT" => sprintf(gT("Please contact %s ( %s ) for further assistance."), Yii::app()->getConfig("siteadminname"), Yii::app()->getConfig("siteadminemail")),
"SURVEYLISTHEADING" => gT("The following surveys are available:"),
"SURVEYLIST" => $this->getController()->renderPartial('/admin/templates/templateeditor_surveylist_view', $aSurveyList, true),
);
//$aData['surveylist'] = $aSurveyListTexts;
$aData['aReplacements'] = array_merge($aGlobalReplacements,$aReplacementSurveyList);
$myoutput[] = "";
//$myoutput[] = templatereplace(file_get_contents("$templatedir/startpage.pstpl"), array(), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate);
$files=$SurveyList;
foreach ($SurveyList as $qs)
foreach ($files as $qs)
{
$myoutput = array_merge($myoutput, doreplacement($oEditedTemplate->pstplPath . "/$qs", $aData, $oEditedTemplate));
}
Expand Down Expand Up @@ -1182,11 +1190,9 @@ protected function _initialise($templatename, $screenname, $editfile, $showsumma
'NAVIGATOR' => "$sMoveNext",
));
$files=$Welcome ;
foreach ($Welcome as $qs) {
foreach ($files as $qs) {
$myoutput = array_merge($myoutput, doreplacement($oEditedTemplate->pstplPath . "/$qs", $aData, $oEditedTemplate));
}

$myoutput = array_merge($myoutput, doreplacement($oEditedTemplate->pstplPath . "/endpage.pstpl", $aData, $oEditedTemplate));
break;

case 'register':
Expand Down Expand Up @@ -1216,17 +1222,33 @@ protected function _initialise($templatename, $screenname, $editfile, $showsumma
$files=$Save;
$aData['aReplacements'] = $aGlobalReplacements;
$myoutput[] = templatereplace(file_get_contents("$templatedir/startpage.pstpl"), array(), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate);
$myoutput[] = templatereplace(file_get_contents("$templatedir/save.pstpl"), array(), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate);
$aData['aReplacements']['SAVEHEADING'] = App()->getController()->renderPartial("/survey/frontpage/saveForm/heading",array(),true);
$aData['aReplacements']['SAVEMESSAGE'] = App()->getController()->renderPartial("/survey/frontpage/saveForm/message",array(),true);
$aData['aReplacements']['SAVEALERT'] = App()->getController()->renderPartial("/survey/frontpage/saveForm/anonymized",array(),true);
$aData['aReplacements']['SAVEERROR'] = "";
$saveForm = CHtml::beginForm(array("/survey/index","sid"=>$surveyid), 'post',array('id'=>'form-save'));
$saveForm .= App()->getController()->renderPartial("/survey/frontpage/saveForm/form",array('captcha'=>false),true);
$saveForm .= CHtml::endForm();
$aData['aReplacements']['SAVEFORM'] = $saveForm;
$myoutput = array_merge($myoutput, doreplacement($oEditedTemplate->pstplPath . "/save.pstpl", $aData, $oEditedTemplate));
$myoutput[] = templatereplace(file_get_contents("$templatedir/endpage.pstpl"), array(), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate);
$myoutput[] = "\n";
break;

case 'load':
$files=$Load;
$aData['aReplacements'] = $aGlobalReplacements;
$myoutput[] = templatereplace(file_get_contents("$templatedir/startpage.pstpl"), array(), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate);
$myoutput[] = templatereplace(file_get_contents("$templatedir/load.pstpl"), array(), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate);
$myoutput[] = templatereplace(file_get_contents("$templatedir/endpage.pstpl"), array(), $aData, 'Unspecified', false, NULL, array(), false, $oEditedTemplate);
$myoutput[] = templatereplace(file_get_contents("$templatedir/startpage.pstpl"), array(),$aData['aReplacements'], 'Unspecified', false, NULL, array(), false, $oEditedTemplate);
$aData['aReplacements']['LOADHEADING'] = App()->getController()->renderPartial("/survey/frontpage/loadForm/heading",array(),true);
$aData['aReplacements']['LOADMESSAGE'] = App()->getController()->renderPartial("/survey/frontpage/loadForm/message",array(),true);
$aData['aReplacements']['LOADERROR'] = "";
$loadForm = CHtml::beginForm(array("/survey/index","sid"=>$surveyid), 'post',array('id'=>'form-load'));
$loadForm .= App()->getController()->renderPartial("/survey/frontpage/loadForm/form",array('captcha'=>false),true);
$loadForm .= CHtml::endForm();
$aData['aReplacements']['LOADFORM'] = $loadForm;
$myoutput = array_merge($myoutput, doreplacement($oEditedTemplate->pstplPath . "/load.pstpl", $aData, $oEditedTemplate));
$myoutput[] = templatereplace(file_get_contents("$templatedir/endpage.pstpl"), $aData['aReplacements'], $aData['aReplacements'], 'Unspecified', false, NULL, array(), false, $oEditedTemplate);

$myoutput[] = "\n";
break;

Expand All @@ -1243,12 +1265,11 @@ protected function _initialise($templatename, $screenname, $editfile, $showsumma
$aData['aReplacements'] = $aGlobalReplacements;
$files=$CompletedTemplate;
$myoutput[] = "";
foreach ($CompletedTemplate as $qs)
foreach ($files as $qs)
{
$myoutput = array_merge($myoutput, doreplacement($oEditedTemplate->pstplPath . "/$qs", $aData, $oEditedTemplate));
}
break;

case 'printablesurvey':
$aData['aReplacements'] = $aGlobalReplacements;
$files=$printablesurveytemplate;
Expand Down

0 comments on commit d5b0148

Please sign in to comment.