Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into questionobject_prot…
Browse files Browse the repository at this point in the history
…otype1
  • Loading branch information
olleharstedt committed Sep 5, 2016
2 parents f4a9cb6 + 6d98e16 commit 250b1e6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
Expand Up @@ -38,6 +38,7 @@
<select name="active" id='Survey_active' class="form-control">
<option value="" <?php if( $this->model->active==""){echo "selected";}?>><?php eT('(Any)');?></option>
<option value="Y" <?php if( $this->model->active=="Y"){echo "selected";}?>><?php eT('Active');?></option>
<option value="R" <?php if( $this->model->active=="R"){echo "selected";}?>><?php eT('Active and running');?></option>
<option value="N" <?php if( $this->model->active=="N"){echo "selected";}?>><?php eT('Inactive');?></option>
<option value="E" <?php if( $this->model->active=="E"){echo "selected";}?>><?php eT('Active but expired');?></option>
<option value="S" <?php if( $this->model->active=="S"){echo "selected";}?>><?php eT('Active but not yet started');?></option>
Expand Down
8 changes: 5 additions & 3 deletions application/helpers/frontend_helper.php
Expand Up @@ -2333,9 +2333,11 @@ function SetSurveyLanguage($surveyid, $sLanguage)
{
$default_survey_language= Survey::model()->findByPk($surveyid)->language;
$additional_survey_languages = Survey::model()->findByPk($surveyid)->getAdditionalLanguages();
if (!isset($sLanguage) || ($sLanguage=='')
|| !( in_array($sLanguage,$additional_survey_languages) || $sLanguage==$default_survey_language)
)
if (
empty($sLanguage) //check if there
|| (!in_array($sLanguage, $additional_survey_languages)) //Is the language in the survey-language array
|| ($default_survey_language == $sLanguage) //Is the $default_language the chosen language?
)
{
// Language not supported, fall back to survey's default language
$_SESSION['survey_'.$surveyid]['s_lang'] = $default_survey_language;
Expand Down
15 changes: 14 additions & 1 deletion application/models/Survey.php
Expand Up @@ -1016,12 +1016,25 @@ public function search()

if($this->active == "E")
{
$criteria->compare("t.active",'Y');
$criteria->addCondition("t.expires <'$sNow'");
}
if($this->active == "S")
{
$criteria->compare("t.active",'Y');
$criteria->addCondition("t.startdate >'$sNow'");
}
if($this->active == "R")
{
$now = new CDbExpression("NOW()");

$criteria->compare("t.active",'Y');
$subCriteria = new CDbCriteria;
$subCriteria->addCondition($now.' BETWEEN t.startdate AND t.expires', 'OR');
$subCriteria->addCondition('t.startdate IS NULL', "OR");
$subCriteria->addCondition('t.expires IS NULL', "OR");
$criteria->mergeWith($subCriteria);
}
}
}

Expand All @@ -1042,7 +1055,7 @@ public function search()
$criteriaPerm->compare('permissions.read_p', '1', false, 'OR');
$criteria->mergeWith($criteriaPerm, 'AND');
}

// $criteria->addCondition("t.blabla == 'blub'");
$dataProvider=new CActiveDataProvider('Survey', array(
'sort'=>$sort,
'criteria'=>$criteria,
Expand Down

0 comments on commit 250b1e6

Please sign in to comment.