diff --git a/application/controllers/admin/checkintegrity.php b/application/controllers/admin/checkintegrity.php
index f86d227882d..d17a47c59e5 100644
--- a/application/controllers/admin/checkintegrity.php
+++ b/application/controllers/admin/checkintegrity.php
@@ -331,6 +331,8 @@ private function _deleteConditions(array $conditions, array $aData)
*/
protected function _checkintegrity()
{
+ /* Find is some fix is done */
+ $bDirectlyFixed=false;
// Delete survey permissions if the user does not exist
$oCriteria = new CDbCriteria;
$oCriteria->join = 'LEFT JOIN {{users}} u ON {{permissions}}.uid=u.uid';
@@ -340,7 +342,10 @@ protected function _checkintegrity()
$oCriteria->join = 'USING {{users}} u';
$oCriteria->condition = '{{permissions}}.uid=u.uid AND (u.uid IS NULL)';
}
- Permission::model()->deleteAll($oCriteria);
+ if(Permission::model()->deleteAll($oCriteria))
+ {
+ $bDirectlyFixed=true;
+ }
// Delete survey permissions if the survey does not exist
$oCriteria = new CDbCriteria;
@@ -351,19 +356,22 @@ protected function _checkintegrity()
$oCriteria->join = 'USING {{surveys}} s';
$oCriteria->condition = "{{permissions}}.entity_id=s.sid AND (s.sid IS NULL AND entity='survey')";
}
- Permission::model()->deleteAll($oCriteria);
-
+ if(Permission::model()->deleteAll($oCriteria))
+ {
+ $bDirectlyFixed=true;
+ }
// Deactivate surveys that have a missing response table
- $surveys = Survey::model()->findAll();
- foreach ($surveys as $survey)
+ $oSurveys = Survey::model()->findAll();
+ foreach ($oSurveys as $oSurvey)
{
- if ($survey['active']=='Y' && !tableExists("{{survey_{$survey['sid']}}}"))
+ if ($oSurvey->active=='Y' && !tableExists("{{survey_{$oSurvey->sid}}}"))
{
- Survey::model()->updateByPk($survey['sid'],array('active'=>'N'));
+ Survey::model()->updateByPk($survey->sid,array('active'=>'N'));
+ $bDirectlyFixed=true;
}
}
- unset($surveys);
+ unset($oSurveys);
@@ -390,6 +398,7 @@ protected function _checkintegrity()
$sNewTable = "old_survey_{$iSurveyID}_{$sDate}";
try {
$deactivateresult = Yii::app()->db->createCommand()->renameTable("{{{$sOldTable}}}", "{{{$sNewTable}}}");
+ $bDirectlyFixed=true;
} catch (CDbException $e) {
die ('Couldn\'t make backup of the survey table. Please try again. The database reported the following error:
' . htmlspecialchars($e) . '
');
}
@@ -409,6 +418,7 @@ protected function _checkintegrity()
$sNewTable = "old_tokens_{$iSurveyID}_{$sDate}";
try {
$deactivateresult = Yii::app()->db->createCommand()->renameTable("{{{$sOldTable}}}", "{{{$sNewTable}}}");
+ $bDirectlyFixed=true;
} catch (CDbException $e) {
die ('Couldn\'t make backup of the survey table. Please try again. The database reported the following error:
' . htmlspecialchars($e) . '
');
}
@@ -568,6 +578,7 @@ protected function _checkintegrity()
foreach ($insertdata as $k => $v)
$oLanguageSettings->$k = $v;
$usresult=$oLanguageSettings->save();
+ $bDirectlyFixed=true;
}
}
}
@@ -778,7 +789,11 @@ protected function _checkintegrity()
// the token table and remove if it doesn't.
- /* TODO */
+ /* Show a alert message is some fix is done */
+ if($bDirectlyFixed)
+ {
+ Yii::app()->setFlashMessage(gT("Some needed fix are already done."),'info');
+ }
return $aDelete;
}
diff --git a/application/helpers/common_helper.php b/application/helpers/common_helper.php
index 7fc69b96cd9..43cf3766da4 100644
--- a/application/helpers/common_helper.php
+++ b/application/helpers/common_helper.php
@@ -216,7 +216,19 @@ function getSurveyList($returnarray=false, $surveyid=false)
$surveynames = array();
foreach ($surveyidresult as $result)
{
- $surveynames[] = array_merge($result->attributes, $result->defaultlanguage->attributes);
+ if(!empty($result->defaultlanguage))
+ {
+ $surveynames[] = array_merge($result->attributes, $result->defaultlanguage->attributes);
+ }
+ elseif(empty($bCheckIntegrity))
+ {
+ $bCheckIntegrity=true;
+ Yii::app()->setFlashMessage(
+ sprintf(gT("One or more surveys seem broken, you must %s of the LimeSurvey database."),
+ CHtml::link(gT('check data integrity'),array("admin/checkintegrity"))
+ ),
+ 'error');
+ }
}
$cached = $surveynames;
diff --git a/application/views/admin/notifications/notifications.php b/application/views/admin/notifications/notifications.php
index 95e89a7ed7a..fcdd5f44c3c 100644
--- a/application/views/admin/notifications/notifications.php
+++ b/application/views/admin/notifications/notifications.php
@@ -1,38 +1,22 @@