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 answers_html
  • Loading branch information
Shnoulle committed Aug 9, 2016
2 parents bbb31cc + 014022b commit 0594977
Show file tree
Hide file tree
Showing 127 changed files with 11,619 additions and 3,200 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -4,6 +4,7 @@
/upload/templates/*
/upload/labels/*
/tmp/runtime/HTML
/tmp/runtime/*.log*
/application/controllers/admin/updater.php
/tmp/*.html
/tmp/*.lss
Expand All @@ -27,4 +28,4 @@ application/config/_config.php
!readme.txt
/tmp/runtime/URI/*.ser
/tmp/runtime/CSS/*.ser
launch.json
launch.json
7 changes: 0 additions & 7 deletions application/config/config-defaults.php
Expand Up @@ -574,13 +574,6 @@
*/
$config['InsertansUnsupportedtypes'] = array();

/**
* This parameter sets if and what update notifications are shown to the administrator. Valid values are 'never', 'stable', 'both' (for stable and unstable)
* Default is 'stable'
* @var string
*/
$config['updatenotification'] = 'both';

// Proxy settings for ComfortUpdate
/**
* Set these if you are behind a proxy and want to update LS using ComfortUpdate
Expand Down
20 changes: 20 additions & 0 deletions application/config/third_party.php
Expand Up @@ -260,6 +260,26 @@
)
),

// Decimal.js calculate in js
'decimal' => array(
'basePath' => 'third_party.decimal',
'js' => array(
'decimal.js'
),
'depends' => array(
)
),

// Moment.js use real simple dateTime modification
'moment' => array(
'basePath' => 'third_party.moment',
'js' => array(
'moment-with-locales.min.js'
),
'depends' => array(
)
),

// leaflet, needed for short text question with map (OSM)
'leaflet' => array(
'basePath' => 'third_party.leaflet',
Expand Down
4 changes: 2 additions & 2 deletions application/config/version.php
Expand Up @@ -13,10 +13,10 @@
*/

$config['versionnumber'] = "2.50+";
$config['dbversionnumber'] = 258;
$config['dbversionnumber'] = 259;
$config['buildnumber'] = '';
$config['updatable'] = true;
$config['assetsversionnumber'] = '29';
$config['assetsversionnumber'] = '31';
return $config;

?>
4 changes: 3 additions & 1 deletion application/controllers/AdminController.php
Expand Up @@ -41,6 +41,7 @@ protected function _init()
if (!Yii::app()->getConfig("editedaction")) {Yii::app()->setConfig("editedaction", returnGlobal('editedaction'));} // for html editor integration

AdminTheme::staticRegisterScriptFile('ADMIN_SCRIPT_PATH', 'admin_core.js' );
AdminTheme::staticRegisterScriptFile('ADMIN_SCRIPT_PATH', 'notifications.js' );
}

/**
Expand Down Expand Up @@ -221,7 +222,8 @@ public function getActionClasses()
'tokens' => 'tokens',
'translate' => 'translate',
'update' => 'update',
'pluginhelper' => 'PluginHelper'
'pluginhelper' => 'PluginHelper',
'notification' => 'NotificationController'
);
}

Expand Down
37 changes: 30 additions & 7 deletions application/controllers/RegisterController.php
Expand Up @@ -36,6 +36,16 @@ class RegisterController extends LSYii_Controller {
*/
private $sMailMessage;

public function actions()
{
return array(
'captcha' => array(
'class' => 'CCaptchaAction',
'backColor'=>0xf6f6f6
)
);
}

public function actionAJAXRegisterForm($surveyid)
{
Yii::app()->loadHelper('database');
Expand Down Expand Up @@ -73,6 +83,7 @@ public function actionIndex($sid = null)
$iSurveyId=$sid;
else
$iSurveyId=Yii::app()->request->getPost('sid');

$oSurvey=Survey::model()->find("sid=:sid",array(':sid'=>$iSurveyId));

$sLanguage = Yii::app()->request->getParam('lang');
Expand Down Expand Up @@ -128,10 +139,12 @@ public function getRegisterErrors($iSurveyId){
if (function_exists("ImageCreate") && isCaptchaEnabled('registrationscreen',$aSurveyInfo['usecaptcha']) )
{
$sLoadsecurity=Yii::app()->request->getPost('loadsecurity','');
$sSecAnswer=(isset($_SESSION['survey_'.$iSurveyId]['secanswer']))?$_SESSION['survey_'.$iSurveyId]['secanswer']:"";
if ($sLoadsecurity!=$sSecAnswer)
$captcha=Yii::app()->getController()->createAction("captcha");
$captchaCorrect = $captcha->validate( $sLoadsecurity, false);

if (!$captchaCorrect)
{
$this->aRegisterErrors[] = gT("The answer to the security question is incorrect.");
$this->aRegisterErrors[] = gT("Your answer to the security question was not correct - please try again.");
}
}

Expand Down Expand Up @@ -182,10 +195,16 @@ public function getRegisterForm($iSurveyId)
$aData['bCaptcha'] = function_exists("ImageCreate") && isCaptchaEnabled('registrationscreen', $aSurveyInfo['usecaptcha']);
$aReplacement['REGISTERFORM']=$this->renderPartial('registerForm',$aData,true);
if(is_array($this->aRegisterErrors))
$sRegisterError=implode('<br />',$this->aRegisterErrors);
{
$sRegisterError="<div class='alert alert-danger' role='alert'>"
.implode('<br />',$this->aRegisterErrors)
."</div>";
}
else
{
$sRegisterError='';

}

$aReplacement['REGISTERERROR'] = $sRegisterError;
$aReplacement['REGISTERMESSAGE1'] = gT("You must be registered to complete this survey");
if($sStartDate=$this->getStartDate($iSurveyId))
Expand Down Expand Up @@ -448,6 +467,8 @@ private function display($iSurveyId)
$aData['aRegisterErrors']=$this->aRegisterErrors;
$aData['sMessage']=$this->sMessage;

$oTemplate = Template::model()->getInstance('', $iSurveyId);
Yii::app()->clientScript->registerPackage( 'survey-template' );
sendCacheHeaders();
doHeader();
$aViewData['sTemplate']=$sTemplate;
Expand All @@ -460,14 +481,16 @@ private function display($iSurveyId)
$aViewData['aData']=$aData;
// Test if we come from index or from register
if(empty(App()->clientScript->scripts)){
$oTemplate = Template::model()->getInstance('', $iSurveyId);
Yii::app()->clientScript->registerPackage( 'survey-template' );
App()->getClientScript()->registerPackage('jqueryui');
App()->getClientScript()->registerPackage('jquery-touch-punch');
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts')."survey_runtime.js");
useFirebug();
$this->render('/register/display',$aViewData);
}else{
// urvey/index need renderPartial
$this->renderPartial('/register/display',$aViewData);
// Survey/index need renderPartial
echo $this->renderPartial('/register/display',$aViewData, true, true);
}
doFooter();
}
Expand Down
7 changes: 6 additions & 1 deletion application/controllers/SurveyController.php
Expand Up @@ -36,6 +36,7 @@ protected function _init()
if (!Yii::app()->getConfig("action")) {Yii::app()->setConfig("action", returnGlobal('action'));} //Desired action
if (!Yii::app()->getConfig("subaction")) {Yii::app()->setConfig("subaction", returnGlobal('subaction'));} //Desired subaction
if (!Yii::app()->getConfig("editedaction")) {Yii::app()->setConfig("editedaction", returnGlobal('editedaction'));} // for html editor integration
Yii::app()->clientScript->registerPackage('decimal'); // decimal
}

/**
Expand Down Expand Up @@ -68,7 +69,11 @@ public function actions()
'statistics_user' => 'application.controllers.statistics_user',
'tcpdf_check' => 'application.controllers.tcpdf_check',
'uploader' => 'application.controllers.uploader',
'verification' => 'application.controllers.verification'
'verification' => 'application.controllers.verification',
'captcha' => array(
'class' => 'CCaptchaAction',
'backColor'=>0xf6f6f6
)
);
}

Expand Down
151 changes: 151 additions & 0 deletions application/controllers/admin/NotificationController.php
@@ -0,0 +1,151 @@
<?php

/**
* Mostly for Ajax actions
*/
class NotificationController extends Survey_Common_Action
{

/**
* List all notifications for a user
*/
public function index()
{
$this->checkPermission();

$data = array();
$data['model'] = Notification::model();

$this->_renderWrappedTemplate(null, array('notification/index'), $data);
}

/**
* Get notification as JSON
*
* @param int $notId Notification id
* @return string JSON
*/
public function getNotificationAsJSON($notId)
{
$this->checkPermission();

$not = Notification::model()->findByPk($notId);

if ($not)
{
echo json_encode(array('result' => $not->getAttributes()));
}
else
{
echo json_encode(array('error' => 'Found no notification with id ' . $notId));
}
}

/**
* Mark notification as read
*
* @param int $notId Notification id
* @return string JSON
*/
public function notificationRead($notId)
{
$this->checkPermission();

try
{
$not = Notification::model()->findByPk($notId);
$result = $not->markAsRead();
echo json_encode(array('result' => $result));
}
catch (Exception $ex)
{
echo json_encode(array('error' => $ex->getMessage()));
}

}

/**
* Spits out html used in admin menu
* @param int|null $surveyId
* @param bool $showLoader Whether or not to show spinning loader instead of notification list
* @return string
*/
public function actionGetMenuWidget($surveyId = null, $showLoader = false)
{
$this->checkPermission();

echo self::getMenuWidget($surveyId, $showLoader);
}

/**
* Delete all notifications for this user and this survey
* @param int|null $surveyId
* @return void
*/
public function clearAllNotifications($surveyId = null)
{
Notification::model()->deleteAll(
'entity = \'user\' AND entity_id = ' . Yii::app()->user->id
);

if (is_int($surveyId))
{
Notification::model()->deleteAll(
'entity = \'survey\' AND entity_id = ' . $surveyId
);
}
}

/**
* Die if user is not logged in
* @return void
*/
protected function checkPermission()
{
// Abort if user is not logged in
if(Yii::app()->user->isGuest)
{
die('No permission');
}
}

/**
* Get menu HTML for notifications
*
* @param int|null $surveyId
* @param bool $showLoader If true, show spinning loader instead of messages (fetch them using ajax)
* @return string HTML
*/
public static function getMenuWidget($surveyId = null, $showLoader = false) {
$data = array();
$data['surveyId'] = $surveyId;
$data['showLoader'] = $showLoader;
$data['clearAllNotificationsUrl'] = Yii::app()->createUrl('admin/notification', array(
'sa' => 'clearAllNotifications',
'surveyId' => $surveyId
));
$data['updateUrl'] = Notification::getUpdateUrl($surveyId);
$data['nrOfNewNotifications'] = Notification::countNewNotifications($surveyId);
$data['nrOfNotifications'] = Notification::countNotifications($surveyId);
$data['nrOfImportantNotifications'] = Notification::countImportantNotifications($surveyId);
$data['bellColor'] = $data['nrOfNewNotifications'] == 0 ? 'text-success' : 'text-warning';

// If we have any important notification we might as well load everything
if ($data['nrOfImportantNotifications'] > 0)
{
$data['showLoader'] = false;
}

// Only load all messages when we're not showing spinning loader
if (!$data['showLoader'])
{
$data['notifications'] = Notification::getNotifications($surveyId);
}

return Yii::app()->getController()->renderPartial(
'/admin/super/admin_notifications',
$data,
true
);
}
}
1 change: 1 addition & 0 deletions application/controllers/admin/PluginHelper.php
Expand Up @@ -32,6 +32,7 @@ public function sidebody($surveyId, $plugin, $method)
$aData['sideMenuBehaviour'] = getGlobalSetting('sideMenuBehaviour');
$aData['content'] = $content;
$aData['activated'] = $surveyinfo['active'];
$aData['sideMenuOpen'] = false; // TODO: Assume this for all plugins?
$this->_renderWrappedTemplate(null, array('super/sidebody'), $aData);

}
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/globalsettings.php
Expand Up @@ -98,7 +98,7 @@ private function _displaySettings()

$data['fullpagebar']['savebutton']['form'] = 'frmglobalsettings';
$data['fullpagebar']['saveandclosebutton']['form'] = 'frmglobalsettings';
$data['fullpagebar']['closebutton']['url'] = 'admin/'; // Close button
$data['fullpagebar']['closebutton']['url'] = Yii::app()->createUrl('admin/'); // Close button

// List of available encodings
$data['aEncodings'] = aEncodingsArray();
Expand Down
5 changes: 5 additions & 0 deletions application/controllers/admin/statistics.php
Expand Up @@ -519,6 +519,11 @@ public function run($surveyid = 0, $subaction = null)
$aData['fresults'] = (isset($aData['fresults']))?$aData['fresults']:false;
$aData['dateformatdetails'] = getDateFormatData(Yii::app()->session['dateformat']);

if (!isset($aData['result']))
{
$aData['result'] = null;
}

$this->_renderWrappedTemplate('export', 'statistics_view', $aData);

}
Expand Down
8 changes: 5 additions & 3 deletions application/controllers/admin/surveyadmin.php
Expand Up @@ -657,11 +657,13 @@ public function activate($iSurveyID)
$aData['surveyid'] = $iSurveyID;
$surveyinfo = Survey::model()->findByPk($iSurveyID)->surveyinfo;
$aData['title_bar']['title'] = $surveyinfo['surveyls_title']." (".gT("ID").":".$iSurveyID.")";
// Die if this is not possible
// Redirect if this is not possible
if (!isset($aData['aSurveysettings']['active']) || $aData['aSurveysettings']['active'] == 'Y')
$this->getController()->error('Survey not active');
{
Yii::app()->setFlashMessage(gT("This survey is already active."),'error');
$this->getController()->redirect(array('admin/survey','sa'=>'view','surveyid'=>$iSurveyID));

$qtypes = getQuestionTypeList('', 'array');
} $qtypes = getQuestionTypeList('', 'array');
Yii::app()->loadHelper("admin/activate");

if (Yii::app()->request->getPost('ok')=='')
Expand Down

0 comments on commit 0594977

Please sign in to comment.