Skip to content

Commit

Permalink
Introduce Survey_Common_Action::_renderWrappedTemplate(). Implemented…
Browse files Browse the repository at this point in the history
… in authentication and tokens.

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_yii@11794 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
GautamGupta committed Dec 28, 2011
1 parent 9cb3b0f commit eb4cdca
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 47 deletions.
17 changes: 7 additions & 10 deletions application/controllers/admin/authentication.php
Expand Up @@ -24,7 +24,7 @@
* @package LimeSurvey
* @subpackage Backend
*/
class Authentication extends CAction
class Authentication extends Survey_Common_Action
{
/**
* Executes the action based on given input
Expand Down Expand Up @@ -391,17 +391,14 @@ private function _getAuthenticationFailedErrorMessage()
}

/**
* Renders a template wrapped in header and footer
* @param string $szViewUrl
* @param array $aData
* Renders template(s) wrapped in header and footer
*
* @param string|array $aViewUrls View url(s)
* @param array $aData Data to be passed on. Optional.
*/
private function _renderWrappedTemplate($szViewUrl, $aData = array())
function _renderWrappedTemplate($aViewUrls = array(), $aData = array())
{
$aData['clang'] = $clang = $this->getController()->lang;

$this->getController()->_getAdminHeader();
$this->getController()->render('/admin/authentication/' . $szViewUrl, $aData);
$this->getController()->_getAdminFooter('http://docs.limesurvey.org', $clang->gT('LimeSurvey online manual'));
parent::_renderWrappedTemplate('authentication', $aViewUrls, $aData);
}

}
35 changes: 2 additions & 33 deletions application/controllers/admin/tokens.php
Expand Up @@ -70,41 +70,10 @@ public function run($sa = '')
* @param string|array $aViewUrls View url(s)
* @param array $aData Data to be passed on. Optional.
*/
private function _renderWrappedTemplate($aViewUrls = array(), $aData = array())
function _renderWrappedTemplate($aViewUrls = array(), $aData = array())
{
$aViewUrls = (array) $aViewUrls;

$aData['clang'] = $clang = $this->getController()->lang;
$aData['imageurl'] = Yii::app()->getConfig('imageurl');

$this->getController()->_getAdminHeader();
foreach ($aViewUrls as $sViewKey => $viewUrl)
{
if (empty($sViewKey) || is_numeric($sViewKey))
{
$this->getController()->render('/admin/token/'.$viewUrl, $aData);
}
else
{
switch ($sViewKey)
{
case 'message' :
if (empty($viewUrl['class']))
{
$this->getController()->_showMessageBox($viewUrl['title'], $viewUrl['message']);
}
else
{
$this->getController()->_showMessageBox($viewUrl['title'], $viewUrl['message'], $viewUrl['class']);
}
break;
case 'output' :
echo $viewUrl;
break;
}
}
}
$this->getController()->_getAdminFooter('http://docs.limesurvey.org', $clang->gT('LimeSurvey online manual'));
parent::_renderWrappedTemplate('token', $aViewUrls, $aData);
}

/**
Expand Down
53 changes: 49 additions & 4 deletions application/core/Survey_Common_Action.php
Expand Up @@ -44,6 +44,51 @@ protected function route($sa, array $get_vars)
return call_user_func_array(array($this, $sa), $func_args);
}

/**
* Renders template(s) wrapped in header and footer
*
* @param string $sAction Current action, the folder to fetch views from
* @param string|array $aViewUrls View url(s)
* @param array $aData Data to be passed on. Optional.
*/
function _renderWrappedTemplate($sAction = '', $aViewUrls = array(), $aData = array())
{
$aViewUrls = (array) $aViewUrls;

$aData['clang'] = $clang = $this->getController()->lang;

$this->getController()->_getAdminHeader();

foreach ($aViewUrls as $sViewKey => $viewUrl)
{
if (empty($sViewKey) || is_numeric($sViewKey))
{
$this->getController()->render("/admin/{$sAction}/{$viewUrl}", $aData);
}
else
{
switch ($sViewKey)
{
case 'message' :
if (empty($viewUrl['class']))
{
$this->getController()->_showMessageBox($viewUrl['title'], $viewUrl['message']);
}
else
{
$this->getController()->_showMessageBox($viewUrl['title'], $viewUrl['message'], $viewUrl['class']);
}
break;
case 'output' :
echo $viewUrl;
break;
}
}
}

$this->getController()->_getAdminFooter('http://docs.limesurvey.org', $clang->gT('LimeSurvey online manual'));
}

/**
* Shows admin menu for question
* @param int Survey id
Expand Down Expand Up @@ -276,7 +321,7 @@ function _surveybar($surveyid, $gid=null)
$condition = array('sid' => $surveyid, 'parent_qid' => 0, 'language' => $baselang);

//$sumquery3 = "SELECT * FROM ".db_table_name('questions')." WHERE sid={$surveyid} AND parent_qid=0 AND language='".$baselang."'"; //Getting a count of questions for this survey
$sumresult3 = Questions::model()->findAllByAttributes($condition); //$connect->Execute($sumquery3); //Checked
$sumresult3 = Questions::model()->findAllByAttributes($condition); //Checked
$sumcount3 = count($sumresult3);

$data['canactivate'] = $sumcount3 > 0 && bHasSurveyPermission($surveyid, 'surveyactivation', 'update');
Expand Down Expand Up @@ -333,7 +378,7 @@ function _surveybar($surveyid, $gid=null)
// TMSW Conditions->Relevance: How is conditionscount used? Should Relevance do the same?
$query = count(Conditions::model()->findAllByAttributes(array('qid' => $surveyid)));
$sumcount6 = $query; //$connect->GetOne($sumquery6); //Checked
$sumcount6 = $query; //Checked
$data['surveycontent'] = bHasSurveyPermission($surveyid, 'surveycontent', 'update');
$data['conditionscount'] = ($sumcount6 > 0);
// Eport menu item
Expand Down Expand Up @@ -402,13 +447,13 @@ function _surveysummary($surveyid, $action=null)

$condition = array('sid' => $surveyid, 'parent_qid' => 0, 'language' => $baselang);

$sumresult3 = Questions::model()->findAllByAttributes($condition); //$connect->Execute($sumquery3); //Checked
$sumresult3 = Questions::model()->findAllByAttributes($condition); //Checked
$sumcount3 = count($sumresult3);

$condition = array('sid' => $surveyid, 'language' => $baselang);

//$sumquery2 = "SELECT * FROM ".db_table_name('groups')." WHERE sid={$surveyid} AND language='".$baselang."'"; //Getting a count of groups for this survey
$sumresult2 = Groups::model()->findAllByAttributes($condition); //$connect->Execute($sumquery2); //Checked
$sumresult2 = Groups::model()->findAllByAttributes($condition); //Checked
$sumcount2 = count($sumresult2);

//SURVEY SUMMARY
Expand Down

0 comments on commit eb4cdca

Please sign in to comment.