Commit 966794b1 authored by Chenu Denis's avatar Chenu Denis
Browse files

[fix] Fix maxtstep final fix and release

parent 5f18cb7a
......@@ -4,11 +4,11 @@
<name>reloadAnyResponse</name>
<type>plugin</type>
<creationDate>2018-04-18</creationDate>
<lastUpdate>2020-11-20</lastUpdate>
<lastUpdate>2021-19-01</lastUpdate>
<author>Denis Chenu</author>
<authorUrl>https://extensions.sondages.pro/reloadanyresponse</authorUrl>
<supportUrl>https://support.sondages.pro/</supportUrl>
<version>3.3.2</version>
<version>3.4.0</version>
<license>GNU Affero General Public License v3.0</license>
<description><![CDATA[Allow to reload any response for admin user and respondant.]]></description>
</metadata>
......
<?php
/**
* This file is part of reloadAnyResponse plugin
* @version 0.1.0
* @version 0.2.0
*/
namespace reloadAnyResponse\models;
use Yii;
......@@ -69,12 +69,12 @@ class responseMaxstep extends CActiveRecord
/**
* return the current max step
* Return the current max step for survey and response
* @param integer $sid survey
* @param integer $srid : response id
* @return int|null current max step , null if error
* @return int|null current max step , null if not set
*/
public function getMaxstep($sid, $srid)
public static function getMaxstep($sid, $srid)
{
$oResponseMaxstep = self::model()->findByPk(array('sid'=>$sid,'srid'=>$srid));
if(!$oResponseMaxstep) {
......
......@@ -5,7 +5,7 @@
* @author Denis Chenu <denis@sondages.pro>
* @copyright 2018-2020 Denis Chenu <http://www.sondages.pro>
* @license AGPL v3
* @version 3.4.0-beta2
* @version 3.4.0
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -749,9 +749,15 @@ class reloadAnyResponse extends PluginBase {
$oResponses = $this->getEvent()->get('responses');
$oResponse = $this->getEvent()->get('response');/* Get the current response set */
$token = App()->getRequest()->getParam('token');
/* control multi access to token with token and allow edit reponse */
$oSurvey = Survey::model()->findByPk($surveyId);
if(empty($oSurvey) || $oSurvey->tokenanswerspersistence != "Y") {
return;
}
if($srid == 'new' && $token && $this->_getIsActivated('allowTokenUser',$surveyId) ) {
if($oSurvey->tokenanswerspersistence != "Y" || $oSurvey->showwelcome != 'Y') {
if($oSurvey->tokenanswerspersistence != "Y" || $oSurvey->showwelcome != 'Y' || $oSurvey->format == 'A') {
/* Check if create or not … */
$this->getEvent()->set('response',false);
return;
......@@ -762,11 +768,7 @@ class reloadAnyResponse extends PluginBase {
if (!$this->_getCurrentSetting('multiAccessTime',$surveyId)) {
return;
}
/* control multi access to token with token and allow edit reponse */
$oSurvey = Survey::model()->findByPk($surveyId);
if(empty($oSurvey) || $oSurvey->tokenanswerspersistence != "Y") {
return;
}
if (is_null($oResponse)) {
if(empty($oResponses[0]->submitdate) || $oSurvey->alloweditaftercompletion == 'Y') {
$oResponse = $oResponses[0];
......
......@@ -2,7 +2,7 @@
/**
* This file is part of reloadAnyResponse plugin
* Helpers for other plugin : reload or create responses
* @version 0.2.0
* @version 0.2.1
*/
namespace reloadAnyResponse;
use Yii;
......@@ -62,10 +62,8 @@ class reloadResponse
$_SESSION['survey_'.$surveyId]['s_lang'] = $this->language;
$currentStep = $maxStep = $oResponse->lastpage;
if($keepMaxStep) {
$reloadmaxStep = \reloadAnyResponse\models\responseMaxstep::model()->findByPk(
array('sid'=>$surveyId, 'srid'=>$this->srid)
);
if ($reloadmaxStep > $currentStep) {
$reloadmaxStep = \reloadAnyResponse\models\responseMaxstep::getMaxstep($surveyId, $this->srid);
if ($reloadmaxStep && $reloadmaxStep > $currentStep) {
$maxStep = $reloadmaxStep;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment