Skip to content

Commit

Permalink
#8175 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
alex committed Oct 2, 2013
1 parent 446139c commit c616d09
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 7 deletions.
22 changes: 19 additions & 3 deletions application/controllers/admin/database.php
Expand Up @@ -1016,9 +1016,7 @@ function index($sa = null)
}
$updatearray= array('admin'=> Yii::app()->request->getPost('admin'),
'expires'=>$expires,
'adminemail'=> Yii::app()->request->getPost('adminemail'),
'startdate'=>$startdate,
'bounce_email'=> Yii::app()->request->getPost('bounce_email'),
'anonymized'=> Yii::app()->request->getPost('anonymized'),
'faxto'=> Yii::app()->request->getPost('faxto'),
'format'=> Yii::app()->request->getPost('format'),
Expand Down Expand Up @@ -1059,6 +1057,24 @@ function index($sa = null)
'googleanalyticsstyle'=>trim(Yii::app()->request->getPost('googleanalyticsstyle')),
'tokenlength'=>$tokenlength
);


$warning = '';
// make sure we only update admin email if it is valid
if (validateEmailAddress(Yii::app()->request->getPost('adminemail'))
|| empty(Yii::app()->request->getPost('adminemail'))) {
$updatearray['adminemail'] = Yii::app()->request->getPost('adminemail');
} else {
$warning .= $clang->gT("Warning! Notification email was not updated because it was not valid.").'<br/>';
}
// make sure we only update bounce email if it is valid
if (validateEmailAddress(Yii::app()->request->getPost('bounce_email'))
|| empty(Yii::app()->request->getPost('bounce_email'))) {
$updatearray['bounce_email'] = Yii::app()->request->getPost('bounce_email');
} else {
$warning .= $clang->gT("Warning! Bounce email was not updated because it was not valid.").'<br/>';
}

// use model
$Survey=Survey::model()->findByPk($surveyid);
foreach ($updatearray as $k => $v)
Expand Down Expand Up @@ -1106,7 +1122,7 @@ function index($sa = null)

if ($usresult)
{
Yii::app()->session['flashmessage'] = $clang->gT("Survey settings were successfully saved.");
Yii::app()->session['flashmessage'] = $warning.$clang->gT("Survey settings were successfully saved.");
}
else
{
Expand Down
12 changes: 11 additions & 1 deletion application/controllers/admin/globalsettings.php
Expand Up @@ -166,8 +166,18 @@ private function _saveSettings()
setGlobalSetting('emailsmtpdebug', sanitize_int(Yii::app()->request->getPost('emailsmtpdebug','0')));
setGlobalSetting('emailsmtpuser', strip_tags(returnGlobal('emailsmtpuser')));
setGlobalSetting('filterxsshtml', strip_tags($_POST['filterxsshtml']));
$warning = '';
// make sure emails are valid before saving them
if (validateEmailAddress($_POST['siteadminbounce']) || empty($_POST['siteadminbounce'])) {
setGlobalSetting('siteadminbounce', strip_tags($_POST['siteadminbounce']));
} else {
$warning .= $clang->gT("Warning! Admin bounce email was not saved because it was not valid.").'<br/>';
}
if (validateEmailAddress($_POST['siteadminemail']) || empty($_POST['siteadminemail'])) {
setGlobalSetting('siteadminemail', strip_tags($_POST['siteadminemail']));
} else {
$warning .= $clang->gT("Warning! Admin email was not saved because it was not valid.").'<br/>';
}
setGlobalSetting('siteadminname', strip_tags($_POST['siteadminname']));
setGlobalSetting('shownoanswer', sanitize_int($_POST['shownoanswer']));
setGlobalSetting('showxquestions', ($_POST['showxquestions']));
Expand Down Expand Up @@ -195,7 +205,7 @@ private function _saveSettings()
setGlobalSetting('timeadjust', $savetime);
setGlobalSetting('usercontrolSameGroupPolicy', strip_tags($_POST['usercontrolSameGroupPolicy']));

Yii::app()->session['flashmessage'] = $clang->gT("Global settings were saved.");
Yii::app()->session['flashmessage'] = $warning.$clang->gT("Global settings were saved.");

$url = htmlspecialchars_decode(Yii::app()->session['refurl']);
if($url){Yii::app()->getController()->redirect($url);}
Expand Down
18 changes: 15 additions & 3 deletions application/controllers/admin/surveyadmin.php
Expand Up @@ -1546,8 +1546,6 @@ function insert($iSurveyID=null)
'owner_id' => Yii::app()->session['loginID'],
'admin' => $_POST['admin'],
'active' => 'N',
'adminemail' => $_POST['adminemail'],
'bounce_email' => $_POST['bounce_email'],
'anonymized' => $_POST['anonymized'],
'faxto' => $_POST['faxto'],
'format' => $_POST['format'],
Expand Down Expand Up @@ -1585,6 +1583,20 @@ function insert($iSurveyID=null)
'tokenlength' => $_POST['tokenlength']
);

$warning = '';
// make sure we only update emails if they are valid
if (validateEmailAddress($_POST['adminemail']) || empty($_POST['adminemail'])) {
$aInsertData['adminemail'] = $_POST['adminemail'];
} else {
$aInsertData['adminemail'] = '';
$warning .= $this->getController()->lang->gT("Warning! Notification email was not updated because it was not valid.").'<br/>';
}
if (validateEmailAddress($_POST['bounce_email']) || empty($_POST['bounce_email'])) {
$aInsertData['bounce_email'] = $_POST['bounce_email'];
} else {
$aInsertData['bounce_email'] = '';
$warning .= $this->getController()->lang->gT("Warning! Bounce email was not updated because it was not valid.").'<br/>';
}

if (!is_null($iSurveyID))
{
Expand Down Expand Up @@ -1636,7 +1648,7 @@ function insert($iSurveyID=null)
$langsettings = new Surveys_languagesettings;
$langsettings->insertNewSurvey($aInsertData);

Yii::app()->session['flashmessage'] = $this->getController()->lang->gT("Survey was successfully added.");
Yii::app()->session['flashmessage'] = $warning.$this->getController()->lang->gT("Survey was successfully added.");

// Update survey permissions
Survey_permissions::model()->giveAllSurveyPermissions(Yii::app()->session['loginID'], $iNewSurveyid);
Expand Down

0 comments on commit c616d09

Please sign in to comment.