Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
Conflicts:
	application/helpers/qanda_helper.php
	application/models/Survey.php
	application/views/admin/survey/Question/editQuestion_view.php
  • Loading branch information
LouisGac committed Apr 20, 2017
2 parents 5b619f2 + 510d31c commit 6123e2b
Show file tree
Hide file tree
Showing 14 changed files with 249 additions and 58 deletions.
2 changes: 1 addition & 1 deletion application/controllers/admin/questions.php
Expand Up @@ -1423,7 +1423,7 @@ public function deleteMultiple()
}
}

Yii::app()->getController()->renderPartial('/admin/survey/Question/massive_actions/_delete_results', array('aResults'=>$aResults));
Yii::app()->getController()->renderPartial('/admin/survey/Question/massive_actions/_action_results', array('aResults'=>$aResults,'successLabel'=>gT('Deleted')));
}

/**
Expand Down
57 changes: 56 additions & 1 deletion application/controllers/admin/surveyadmin.php
Expand Up @@ -62,7 +62,7 @@ public function deleteMultiple()
$aResults[$iSurveyID]['result'] = $oSurvey->deleteSurvey($iSurveyID, $recursive=true);
}

Yii::app()->getController()->renderPartial('ext.admin.survey.ListSurveysWidget.views.massive_actions._delete_results', array('aResults'=>$aResults));
Yii::app()->getController()->renderPartial('ext.admin.survey.ListSurveysWidget.views.massive_actions._action_results', array('aResults'=>$aResults,'successLabel'=>gT('Deleted')));
}

public function listsurveys()
Expand Down Expand Up @@ -997,6 +997,10 @@ public function copy()
{
$aExcludes['dates'] = true;
}
if (Yii::app()->request->getPost('copysurveyresetresponsestartid') == "1")
{
$aExcludes['reset_response_id'] = true;
}
if (!$iSurveyID)
{
$aData['sErrorMessage'] = gT("No survey ID has been provided. Cannot copy survey");
Expand Down Expand Up @@ -1040,10 +1044,18 @@ public function copy()
Question::model()->updateAll(array('relevance'=>'1'),'sid='.$aImportResults['newsid']);
QuestionGroup::model()->updateAll(array('grelevance'=>'1'),'sid='.$aImportResults['newsid']);
}
if (isset($aExcludes['reset_response_id']))
{
$oSurvey=Survey::model()->findByPk($aImportResults['newsid']);
$oSurvey->autonumber_start=0;
$oSurvey->save();
}
if (!isset($aExcludes['permissions']))
{
Permission::model()->copySurveyPermissions($iSurveyID,$aImportResults['newsid']);
}


}
else
{
Expand Down Expand Up @@ -1475,6 +1487,49 @@ function expire($iSurveyID)
$this->getController()->redirect(array('admin/survey/sa/view/surveyid/' . $iSurveyID));
}

function datetimesettings(){
$data = array(
'dateformatsettings'=>getDateFormatData(Yii::app()->session['dateformat']),
'showClear' => true,
'allowInputToggle' => true,
);

if ( Permission::model()->hasGlobalPermission('surveys','read')) {
echo json_encode($data);
}
}
/**
* Action to set expiry date to multiple surveys
*/
public function expireMultipleSurveys(){
$sSurveys = $_POST['sItems'];
$aSIDs = json_decode($sSurveys);
$aResults = array();
$expires = App()->request->getPost('expires');
$formatdata=getDateFormatData(Yii::app()->session['dateformat']);
Yii::import('application.libraries.Date_Time_Converter', true);
if (trim($expires)=="") {
$expires=null;
}
else {
$datetimeobj = new date_time_converter($expires, $formatdata['phpdate'].' H:i'); //new Date_Time_Converter($expires, $formatdata['phpdate'].' H:i');
$expires=$datetimeobj->convert("Y-m-d H:i:s");
}

foreach ($aSIDs as $sid){
$survey = Survey::model()->findByPk($sid);
$survey->expires =$expires;
$aResults[$survey->primaryKey]['title'] = ellipsize($survey->correct_relation_defaultlanguage->surveyls_title,30);
if($survey->save()){
$aResults[$survey->primaryKey]['result'] = true;
}else{
$aResults[$survey->primaryKey]['result'] = false;
}
}
Yii::app()->getController()->renderPartial('ext.admin.survey.ListSurveysWidget.views.massive_actions._action_results', array('aResults'=>$aResults,'successLabel'=>gT('OK')));
}


function getUrlParamsJSON($iSurveyID)
{
$iSurveyID = (int) $iSurveyID;
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/templates.php
Expand Up @@ -235,7 +235,7 @@ public function uploadfile()
$basedestdir = Yii::app()->getConfig('usertemplaterootdir');
$tempdir = Yii::app()->getConfig('tempdir');
$allowedtemplateuploads=Yii::app()->getConfig('allowedtemplateuploads');
$filename=sanitize_filename($_FILES['upload_file']['name'],false,false);// Don't force lowercase or alphanumeric
$filename=sanitize_filename($_FILES['upload_file']['name'],false,false,false);// Don't force lowercase or alphanumeric

$dirfilepath = $oEditedTemplate->filesPath;
if (!file_exists($dirfilepath))
Expand Down
6 changes: 4 additions & 2 deletions application/core/plugins/AuthLDAP/AuthLDAP.php
Expand Up @@ -108,7 +108,7 @@ class AuthLDAP extends ls\pluginmanager\AuthPluginBase
'groupsearchfilter' => array(
'type' => 'string',
'label' => 'Optional filter for group restriction',
'help' => 'Required if group search base set. E.g. (&(cn=limesurvey)(memberUid=$username))'
'help' => 'Required if group search base set. E.g. (&(cn=limesurvey)(memberUid=$username)) or (&(cn=limesurvey)(member=$userdn))'
)
);

Expand Down Expand Up @@ -515,7 +515,9 @@ public function newUserSession()
// If specifed, check group membership
if ($groupsearchbase != '' && $groupsearchfilter != '')
{
$filter = str_replace('$username', $username, $groupsearchfilter);
$keywords = array('$username','$userdn');
$substitutions = array($username,$userdn);
$filter = str_replace($keywords, $substitutions, $groupsearchfilter);
$groupsearchres = ldap_search($ldapconn, $groupsearchbase, $filter);
$grouprescount = ldap_count_entries($ldapconn, $groupsearchres);
if ($grouprescount < 1)
Expand Down
Expand Up @@ -25,6 +25,7 @@ $(document).on('click', '.listActions a', function ()
var $oCheckedItems = JSON.stringify($oCheckedItems);
var actionType = $that.data('actionType');


if( $oCheckedItems == '[]' ) {
//If no item selected, the error modal "please select first an item" is shown
// TODO: add a variable in the widget to replace "item" by the item type (e.g: survey, question, token, etc.)
Expand Down Expand Up @@ -241,13 +242,42 @@ function prepareBsSwitchInteger($gridid){
});
}

function prepareBsDateTimePicker($gridid){
var dateTimeSettings = getDefaultDateTimePickerSettings();
var dateTimeFormat = dateTimeSettings.dateformatsettings.jsdate+ ' HH:mm';
$('.date input').each(function(){
$(this).datetimepicker({
format: dateTimeFormat,
showClear: dateTimeSettings.showClear,
allowInputToggle: dateTimeSettings.allowInputToggle,
});
});

}
// get user session datetimesettings
function getDefaultDateTimePickerSettings() {
var url = 'index.php?r=admin/survey&sa=datetimesettings';
var mydata = [];
$.ajaxSetup({
async: false
});
$.getJSON( url, function( data ) {
mydata = data;
});
return mydata;
}


$(document).ready(function() {

prepareBsSwitchBoolean(gridId);
prepareBsSwitchInteger(gridId);


// Grid refresh: see point 3
$(document).on('actions-updated', '#'+gridId, function(){
prepareBsSwitchBoolean(gridId);
prepareBsSwitchInteger(gridId);
prepareBsDateTimePicker(gridId);
});
});
Expand Up @@ -73,6 +73,5 @@ public function run()

$this->render('listSurveys');


}
}
@@ -1,4 +1,6 @@
<?php
/** @var string $successLabel */

/**
* This view display the result of delete multiple action. It's rendered via ajax for the confirmation modal in survey list
*
Expand All @@ -22,7 +24,7 @@
</td>
<?php if ($result['result']):?>
<td class="text-success">
<?php eT('Deleted'); ?>
<?php echo $successLabel ?>
</td>
<?php else: ?>
<td class="text-warning">
Expand Down
@@ -0,0 +1,30 @@
<?php
/** @var AdminController $this */
$dateFormatDetails=getDateFormatData(Yii::app()->session['dateformat']);

?>
<?php $form = $this->beginWidget('CActiveForm', array('id'=>'survey-expiry',)); ?>

<div id='publication' class="tab-pane fade in">
<!-- Expiry date/time -->
<div class="form-group">
<label class="col-sm-6 control-label" for='expires'><?php eT("Expiry date/time:"); ?></label>
<div class="col-sm-6 has-feedback">
<?php Yii::app()->getController()->widget('yiiwheels.widgets.datetimepicker.WhDateTimePicker', array(
'name' => 'expires',
'id' => 'expires',
'value' => null,
'htmlOptions' => array('class' => 'form-control custom-data'),
'pluginOptions' => array(
'format' => $dateFormatDetails['jsdate'] . " HH:mm",
'allowInputToggle' =>true,
'showClear' => true,
'locale' => convertLStoDateTimePickerLocale(Yii::app()->session['adminlang'])
)
));
?>
</div>
</div>

</div>
<?php $this->endWidget(); ?>
@@ -1,4 +1,5 @@
<?php
/** @var ListSurveysWidget $this */
/**
* Render the selector for surveys massive actions.
*
Expand Down Expand Up @@ -96,6 +97,25 @@
'keepopen' => 'yes',
'sModalTitle' => gT('Export printable survey'),
'htmlModalBody' => gT('This will export a printable version of your survey.').' '.gT('Continue?'),
),
// Publication multiple
array(
// li element
'type' => 'action',
'action' => 'expire',
'url' => App()->createUrl('/admin/survey/sa/expireMultipleSurveys/'),
'iconClasses' => 'icon-expired',
'text' => gT("Set expiry date"),
'grid-reload' => 'yes',
// modal
'actionType' => 'modal',
'modalType' => 'yes-no',
'keepopen' => 'yes',
'sModalTitle' => gT('Set expiry date'),
'htmlModalBody' => $this->controller->renderFile(__DIR__.'/_expiry_dialog.php',array(),true),



),
),

Expand Down

0 comments on commit 6123e2b

Please sign in to comment.