Skip to content

Commit

Permalink
Fix checkintegrity and implement Survey_Common_Action::_renderWrapped…
Browse files Browse the repository at this point in the history
…Template().

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_yii@11797 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
GautamGupta committed Dec 29, 2011
1 parent 17c93af commit 7837491
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions application/controllers/admin/checkintegrity.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* @package LimeSurvey
* @subpackage Backend
*/
class CheckIntegrity extends CAction
class CheckIntegrity extends Survey_Common_Action
{

public function run()
Expand All @@ -34,15 +34,22 @@ public function run()
$this->index();
}

/**
* Renders template(s) wrapped in header and footer
*
* @param string|array $aViewUrls View url(s)
* @param array $aData Data to be passed on. Optional.
*/
function _renderWrappedTemplate($aViewUrls = array(), $aData = array())
{
parent::_renderWrappedTemplate('checkintegrity', $aViewUrls, $aData);
}

public function index()
{
if (Yii::app()->session['USER_RIGHT_CONFIGURATOR'] == 1) {
$aData = $this->_checkintegrity();
$this->getController()->_getAdminHeader();
$this->getController()->_showadminmenu();
$aData['clang'] = Yii::app()->lang;
$this->getController()->render('/admin/checkintegrity/check_view', $aData);
$this->getController()->_getAdminFooter('http://docs.limesurvey.org', $this->getController()->lang->gT('LimeSurvey online manual'));
$this->_renderWrappedTemplate('check_view', $aData);
}
}

Expand All @@ -69,11 +76,7 @@ public function fixredundancy()
}
}

$this->getController()->_getAdminHeader();
$this->getController()->_showadminmenu();
$aData['clang'] = $clang;
$this->getController()->render('/admin/checkintegrity/fix_view', $aData);
$this->getController()->_getAdminFooter('http://docs.limesurvey.org', Yii::app()->lang->gT('LimeSurvey online manual'));
$this->_renderWrappedTemplate('fix_view', $aData);
}
}

Expand Down Expand Up @@ -142,11 +145,7 @@ public function fixintegrity()
$aData = $this->_deleteOrphanTokenTables($aDelete['orphantokentables'], $aData, $clang);
}

$this->getController()->_getAdminHeader();
$this->getController()->_showadminmenu();
$aData['clang'] = $clang;
$this->getController()->render('/admin/checkintegrity/fix_view', $aData);
$this->getController()->_getAdminFooter('http://docs.limesurvey.org', Yii::app()->lang->gT('LimeSurvey online manual'));
$this->_renderWrappedTemplate('fix_view', $aData);
}
}

Expand Down Expand Up @@ -411,7 +410,7 @@ protected function _checkintegrity()
}

if ($condition['cqid'] != 0) { // skip case with cqid=0 for codnitions on {TOKEN:EMAIL} for instance
$iRowCount = count(Questions::model()->findAllByPk($condition['cqid']));
$iRowCount = Questions::model()->countByAttributes(array('qid' => $condition['cqid']));
if (Questions::model()->hasErrors()) safe_die(Questions::model()->getError());
if (!$iRowCount) {
$aDelete['conditions'][] = array('cid' => $condition['cid'], 'reason' => $clang->gT('No matching CQID'));
Expand Down Expand Up @@ -439,7 +438,7 @@ protected function _checkintegrity()
if (Question_attributes::model()->hasErrors()) safe_die(Question_attributes::model()->getError());
foreach ($question_attributes as $question_attribute)
{
$iRowCount = count(Questions::model()->findAllByPk($question_attribute['qid']));
$iRowCount = Questions::model()->countByAttributes(array('qid' => $question_attribute['qid']));
if (Questions::model()->hasErrors()) safe_die(Questions::model()->getError());
if (!$iRowCount < 1) {
$aDelete['questionattributes'][] = array('qid' => $question_attribute['qid']);
Expand Down Expand Up @@ -479,7 +478,7 @@ protected function _checkintegrity()
$quotas = Quota::model()->findAll();
if (Quota::model()->hasErrors()) safe_die(Quota::model()->getError());
$ids = array();
foreach ($quotas as $quota) $ids[] = $survey['id'];
foreach ($quotas as $quota) $ids[] = $quota['id'];
$criteria = new CDbCriteria;
$criteria->addNotInCondition('quotals_quota_id', $ids);

Expand Down Expand Up @@ -543,7 +542,7 @@ protected function _checkintegrity()
if (Answers::model()->hasErrors()) safe_die(Answers::model()->getError());
foreach ($answers as $answer)
{
$iAnswerCount = count(Questions::model()->findAllByPk($answer['qid']));
$iAnswerCount = Questions::model()->countByAttributes(array('qid' => $answer['qid']));
if (Questions::model()->hasErrors()) safe_die(Questions::model()->getError());
if (!$iAnswerCount) {
$aDelete['answers'][] = array('qid' => $answer['qid'], 'code' => $answer['code'], 'reason' => $clang->gT('No matching question'));
Expand Down

0 comments on commit 7837491

Please sign in to comment.