Skip to content

Commit

Permalink
Fixed issue #16528: After deleting a user who owned a survey, the sur…
Browse files Browse the repository at this point in the history
…vey list shows an error. (#1520)

Survey list fixed. Survey's overview, was also failing. Fixed it.
  • Loading branch information
gabrieljenik committed Sep 4, 2020
1 parent 555bdd6 commit 72f24a3
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions application/core/Survey_Common_Action.php
Expand Up @@ -1116,6 +1116,11 @@ public function _surveysummary($aData)
$aData['aAdditionalLanguages'] = $aAdditionalLanguages;
$aData['groups_count'] = $sumcount2;

$aData['owner'] = "-";
if (!is_null($oSurvey->owner)) {
$aData['owner'] = flattenText("{$oSurvey->owner->full_name} ({$oSurvey->owner->email})");
}

// We get the state of the quickaction
// If the survey is new (ie: it has no group), it is opened by default
$quickactionState = SettingsUser::getUserSettingValue('quickaction_state');
Expand Down
Expand Up @@ -86,7 +86,7 @@
'header' => gT('Owner'),
'name' => 'owner',
'type' => 'raw',
'value'=>'CHtml::link(CHtml::encode($data->owner->users_name), Yii::app()->createUrl("admin/survey/sa/view/",array("surveyid"=>$data->sid)))',
'value'=>'CHtml::link(CHtml::encode($data->ownerUserName), Yii::app()->createUrl("admin/survey/sa/view/",array("surveyid"=>$data->sid)))',
'headerHtmlOptions'=>array('class' => 'hidden-md hidden-sm hidden-xs'),
'htmlOptions' => array('class' => 'hidden-md hidden-sm hidden-xs has-link'),
),
Expand Down
2 changes: 1 addition & 1 deletion application/helpers/common_helper.php
Expand Up @@ -910,7 +910,7 @@ function getSurveyInfo($surveyid, $languagecode = '')
if (!isset($thissurvey['adminemail'])) {$thissurvey['adminemail'] = Yii::app()->getConfig('siteadminname'); }
if (!isset($thissurvey['urldescrip']) || $thissurvey['urldescrip'] == '') {$thissurvey['urldescrip'] = $thissurvey['surveyls_url']; }

$thissurvey['owner_username'] = $result->survey->owner->users_name;
$thissurvey['owner_username'] = $result->survey->ownerUserName;

$staticSurveyInfo[$surveyid][$languagecode] = $thissurvey;
}
Expand Down
9 changes: 9 additions & 0 deletions application/models/Survey.php
Expand Up @@ -1970,4 +1970,13 @@ public static function replacePolicyLink($dataSecurityNoticeLabel, $surveyId) {
return $dataSecurityNoticeLabel;

}

/**
* @return string
*/
public function getOwnerUserName()
{
return isset($this->owner["users_name"]) ? $this->owner["users_name"] : "";
}

}
2 changes: 1 addition & 1 deletion application/views/admin/survey/surveySummary_view.php
Expand Up @@ -247,7 +247,7 @@
<?php eT("Owner:");?>
</div>
<div class="col-8">
<?php echo flattenText("{$oSurvey->owner->full_name} ({$oSurvey->owner->email})");?>
<?php echo $owner;?>
</div>
</div>
</li>
Expand Down

1 comment on commit 72f24a3

@c-schmitz
Copy link
Contributor

@c-schmitz c-schmitz commented on 72f24a3 Sep 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you find out why the survey had no owner in the first place? I think the goal would be to prevent that.

Please sign in to comment.