Skip to content

Commit

Permalink
GCI task #7132251 - Port the functionality 'Activate survey' to the Y…
Browse files Browse the repository at this point in the history
…ii PHP framework - Done by Gaurav Narula

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_yii@11487 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed Nov 25, 2011
1 parent ecd61be commit d1058d2
Show file tree
Hide file tree
Showing 4 changed files with 197 additions and 203 deletions.
52 changes: 29 additions & 23 deletions application/controllers/admin/surveyaction.php
Expand Up @@ -35,7 +35,7 @@ class SurveyAction extends Survey_Common_Action {
* @return void
*/
public function run($sa = '', $action = '', $sid = 0)
{
{
if (Yii::app()->session['USER_RIGHT_SUPERADMIN'] != 1)
{
die();
Expand All @@ -45,6 +45,8 @@ public function run($sa = '', $action = '', $sid = 0)
{
if ($sa == 'listsurveys')
$this->route('listsurveys', array());
elseif ($sa == 'activate')
$this->route('activate', array('surveyid'));
elseif ($sa == 'ajaxgetusers')
$this->route('ajaxgetusers', array());
elseif ($sa == 'ajaxowneredit')
Expand Down Expand Up @@ -94,7 +96,7 @@ public function run($sa = '', $action = '', $sid = 0)
}
}
Yii::app()->session['flashmessage'] = sprintf($message, $actioncount);
$this->getController()->render('admin/survey/listsurveys');
//$this->getController()->render('/admin/survey/listsurveys');
}

/**
Expand Down Expand Up @@ -608,7 +610,7 @@ function deactivate($surveyid = null)
$deactivateresult = Yii::app()->db->createCommand($setsequence)->query();
$setidx="ALTER INDEX {{{$toldtable}}}_idx RENAME TO {{{$tnewtable}}}_idx;";
$deactivateresult = Yii::app()->db->createCommand($setidx)->query();
}
}
$toldtable="{{tokens_{$postsid}}}";
$tnewtable="{{old_tokens_{$postsid}_{$date}}}";
$tdeactivateresult = Yii::app()->db->createCommand()->renameTable($toldtable, $tnewtable);
Expand Down Expand Up @@ -653,9 +655,9 @@ function deactivate($surveyid = null)
if (Yii::app()->db->getDrivername()=='postgre')
{
$deactivateresult = Yii::app()->db->createCommand()->renameTable($oldtable.'_id_seq',$newtable.'_id_seq');
$setsequence= "ALTER TABLE $newtable ALTER COLUMN id SET DEFAULT nextval('{$newtable}_id_seq'::regclass);";
$setsequence="ALTER TABLE $newtable ALTER COLUMN id SET DEFAULT nextval('{$newtable}_id_seq'::regclass);";
$deactivateresult = Yii::app()->db->createCommand($setsequence)->execute();
}
}

$deactivateresult = Yii::app()->db->createCommand()->renameTable($oldtable, $newtable);

Expand Down Expand Up @@ -699,20 +701,20 @@ function activate($iSurveyID)
{
$iSurveyID=(int) $iSurveyID;

$css_admin_includes[] = $this->config->item('styleurl')."admin/default/superfish.css";
$this->config->set_item("css_admin_includes", $css_admin_includes);
$css_admin_includes[] = Yii::app()->getConfig('styleurl')."admin/default/superfish.css";
Yii::app()->getConfig("css_admin_includes", $css_admin_includes);
$data['aSurveysettings'] = getSurveyInfo($iSurveyID);
if (!isset($data['aSurveysettings']['active']) || $data['aSurveysettings']['active']=='Y') die(); // Die if this is not possible

self::_getAdminHeader();
self::_showadminmenu($iSurveyID);
self::_surveybar($iSurveyID);
$this->getController()->_getAdminHeader();
$this->getController()->_showadminmenu($iSurveyID);
//$this->getController()->_surveybar($iSurveyID);



$qtypes=getqtypelist('','array');
$this->load->helper("admin/activate");
$_POST = $this->input->post();
Yii::app()->loadHelper("admin/activate");
//$_POST = $this->input->post();


if (!isset($_POST['ok']) || !$_POST['ok'])
Expand All @@ -732,29 +734,33 @@ function activate($iSurveyID)
$data['failedgroupcheck'] = $failedgroupcheck;
$data['aSurveysettings'] = getSurveyInfo($iSurveyID);

$this->load->view("admin/survey/activateSurvey_view",$data);
$this->getController()->render("/admin/survey/activateSurvey_view",$data);
//IF ANY OF THE CHECKS FAILED, PRESENT THIS SCREEN


}
else
{
$this->load->model("surveys_model");
$this->surveys_model->updateSurvey(array('anonymized'=>$this->input->post('anonymized'),
'datestamp'=>$this->input->post('datestamp'),
'ipaddr'=>$this->input->post('ipaddr'),
'refurl'=>$this->input->post('refurl'),
'savetimings'=>$this->input->post('savetimings')),
array('sid'=>$iSurveyID));
$survey = Survey::model()->findByAttributes(array('sid' => $iSurveyID));
if(!is_null($survey))
{
$survey->anonymized = $_POST['anonymized'];
$survey->datestamp = $_POST['datestamp'];
$survey->ipaddr = $_POST['ipaddr'];
$survey->refurl = $_POST['refurl'];
$survey->savetimings = $_POST['savetimings'];
$survey->save();
}

$activateoutput = activateSurvey($iSurveyID);
$displaydata['display'] = $activateoutput;
$this->load->view('survey_view',$displaydata);
$this->getController()->render('/survey_view',$displaydata);
}

self::_loadEndScripts();
$this->getController()->_loadEndScripts();


self::_getAdminFooter("http://docs.limesurvey.org", $this->getController()->lang->gT("LimeSurvey online manual"));
$this->getController()->_getAdminFooter("http://docs.limesurvey.org", $this->getController()->lang->gT("LimeSurvey online manual"));

}

Expand Down

0 comments on commit d1058d2

Please sign in to comment.