Skip to content

Commit

Permalink
Dev Cleaned up some javascript in controllers. Moved some view files …
Browse files Browse the repository at this point in the history
…around.
  • Loading branch information
SamMousa committed Mar 22, 2015
1 parent 2e088f4 commit a553783
Show file tree
Hide file tree
Showing 56 changed files with 633 additions and 812 deletions.
12 changes: 6 additions & 6 deletions application/config/internal.php
Expand Up @@ -11,9 +11,9 @@
} else {
$userConfig = [];
}
@date_default_timezone_set(@date_default_timezone_get());
$internalConfig = array(
'basePath' => __DIR__ . '/../',
'timeZone' => 'UTC',
'sourceLanguage' => 'en',
'controllerNamespace' => '\\ls\\controllers',
'supportedLanguages' => include('locales.php'),
Expand Down Expand Up @@ -49,11 +49,11 @@
'class' => 'LocalizedFormatter'
],
'clientScript'=> [
'class' => 'ext.ExtendedClientScript.ExtendedClientScript',
'combineCss' => false,
'compressCss' => false,
'combineJs'=> YII_DEBUG,
'compressJs'=>false,
// 'class' => 'ext.ExtendedClientScript.ExtendedClientScript',
// 'combineCss' => false,
// 'compressCss' => false,
// 'combineJs'=> YII_DEBUG,
// 'compressJs'=>false,
'packages' => require('third_party.php'),
],
'urlManager' => [
Expand Down
1 change: 1 addition & 0 deletions application/controllers/AdminController.php
Expand Up @@ -32,6 +32,7 @@ protected function _init()
{
parent::_init();
App()->getComponent('bootstrap');
App()->clientScript->registerPackage('jquery');
$sUpdateLastCheck = getGlobalSetting('updatelastcheck');

$this->_sessioncontrol();
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/PluginsController.php
Expand Up @@ -80,7 +80,7 @@ public function actionDeactivate($id)
} elseif (in_array($id, SettingGlobal::get('authenticationPlugins', []))) {
App()->user->setFlash('error', "Cannot disable currently active authentication plugin.");
}

$pm = App()->pluginManager;
foreach ($pm->scanPlugins() as $pluginConfig) {
if ($pluginConfig->id === $id) {
Expand Down
27 changes: 26 additions & 1 deletion application/controllers/SurveysController.php
Expand Up @@ -45,7 +45,32 @@ public function actionView($id) {
$this->survey = $survey;
$this->render('view', ['survey' => $survey]);
}


public function actionActivate($id) {
$this->layout = 'survey';
$survey = $this->loadModel($id);
if (App()->request->isPostRequest) {
$survey->activate();
App()->user->setFlash('succcess', "Survey activated.");
$this->redirect(['surveys/view', 'id' => $survey->sid]);
}

$this->survey = $survey;
$this->render('activate', ['survey' => $survey]);
}

public function actionDeactivate($id) {
$this->layout = 'survey';
$survey = $this->loadModel($id);
if (App()->request->isPostRequest) {
$survey->deactivate();
App()->user->setFlash('succcess', "Survey deactivated.");
$this->redirect(['surveys/view', 'id' => $survey->sid]);
}

$this->survey = $survey;
$this->render('deactivate', ['survey' => $survey]);
}
public function filters()
{
return array_merge(parent::filters(), ['accessControl']);
Expand Down
4 changes: 3 additions & 1 deletion application/controllers/UploaderController.php
@@ -1,6 +1,9 @@
<?php
namespace ls\controllers;
use \Yii;
use \Survey;
use \PluginEvent;
use CClientScript;
/*
* LimeSurvey
* Copyright (C) 2007-2014 The LimeSurvey Project Team / Carsten Schmitz
Expand Down Expand Up @@ -281,7 +284,6 @@ function run($actionID)

$meta = '';
App()->getClientScript()->registerPackage('jqueryui');
App()->getClientScript()->registerPackage('jquery-superfish');
$sNeededScriptVar='
var uploadurl = "'.$this->createUrl('/uploader/index/mode/upload/').'";
var imageurl = "'.Yii::app()->getConfig('imageurl').'/";
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/assessments.php
Expand Up @@ -74,7 +74,7 @@ protected function _renderWrappedTemplate($sAction = 'assessments', $aViewUrls =
{
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('adminscripts') . 'assessments.js');
App()->getClientScript()->registerPackage('jquery-tablesorter');
App()->getClientScript()->registerPackage('jquery-superfish');


parent::_renderWrappedTemplate($sAction, $aViewUrls, $aData);
}
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/emailtemplates.php
Expand Up @@ -30,7 +30,7 @@ class emailtemplates extends Survey_Common_Action {
function index($iSurveyId)
{
$iSurveyId = sanitize_int($iSurveyId);
App()->getClientScript()->registerPackage('jquery-superfish');


Yii::app()->loadHelper('admin.htmleditor');
Yii::app()->loadHelper('surveytranslator');
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/export.php
Expand Up @@ -1112,7 +1112,7 @@ private function _xmlToJson($fileContents) {
*/
protected function _renderWrappedTemplate($sAction = 'export', $aViewUrls = array(), $aData = array())
{
App()->getClientScript()->registerPackage('jquery-superfish');


$aData['display']['menu_bars']['gid_action'] = 'exportstructureGroup';

Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/expressions.php
Expand Up @@ -24,7 +24,7 @@ function index()
}
if($needpermission && !App()->user->checkAccess('surveycontent', ['entity' => 'survey', 'entity_id' => $surveyid]))
{
App()->getClientScript()->registerPackage('jquery-superfish');

$message['title']= gT('Access denied!');
$message['message']= gT('You do not have sufficient rights to access this page.');
$message['class']= "error";
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/printablesurvey.php
Expand Up @@ -32,7 +32,7 @@ function index($surveyid, $lang = null)
if(!App()->user->checkAccess('surveycontent', ['entity' => 'survey', 'entity_id' => $surveyid]))
{
$aData['surveyid'] = $surveyid;
App()->getClientScript()->registerPackage('jquery-superfish');

$message['title']= gT('Access denied!');
$message['message']= gT('You do not have sufficient rights to access this page.');
$message['class']= "error";
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/questiongroups.php
Expand Up @@ -402,7 +402,7 @@ public function update($gid)
*/
protected function _renderWrappedTemplate($sAction = 'survey/QuestionGroups', $aViewUrls = array(), $aData = array())
{
App()->getClientScript()->registerPackage('jquery-superfish');

parent::_renderWrappedTemplate($sAction, $aViewUrls, $aData);
}
}
2 changes: 0 additions & 2 deletions application/controllers/admin/questions.php
Expand Up @@ -1296,8 +1296,6 @@ public function ajaxValidate($surveyid,$qid=false){
*/
protected function _renderWrappedTemplate($sAction = 'survey/Question', $aViewUrls = array(), $aData = array())
{
App()->getClientScript()->registerPackage('superfish');
App()->getClientScript()->registerPackage('jquery-msdropdown');
parent::_renderWrappedTemplate($sAction, $aViewUrls, $aData);
}
}
2 changes: 1 addition & 1 deletion application/controllers/admin/quotas.php
Expand Up @@ -546,7 +546,7 @@ function getQuotaAnswers($iQuestionId, $iSurveyId, $iQuotaId)
*/
protected function _renderWrappedTemplate($sAction = 'quotas', $aViewUrls = array(), $aData = array())
{
App()->getClientScript()->registerPackage('jquery-superfish');

App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('adminscripts') . '/quotas.js');
parent::_renderWrappedTemplate($sAction, $aViewUrls, $aData);
}
Expand Down
4 changes: 2 additions & 2 deletions application/controllers/admin/responses.php
Expand Up @@ -281,7 +281,7 @@ public function view($iSurveyID, $iId, $sBrowseLang = '')
else
{
$aData['surveyid'] = $iSurveyID;
App()->getClientScript()->registerPackage('jquery-superfish');

$message['title']= gT('Access denied!');
$message['message']= gT('You do not have sufficient rights to access this page.');
$message['class']= "error";
Expand Down Expand Up @@ -975,7 +975,7 @@ function oldbrowse($iSurveyID)
else
{
$aData['surveyid'] = $iSurveyID;
App()->getClientScript()->registerPackage('jquery-superfish');

$message['title']= gT('Access denied!');
$message['message']= gT('You do not have sufficient rights to access this page.');
$message['class']= "error";
Expand Down
9 changes: 6 additions & 3 deletions application/controllers/admin/surveyadmin.php
Expand Up @@ -267,6 +267,10 @@ public function view($iSurveyID, $gid = null, $qid = null)
*/
public function deactivate($iSurveyID = null)
{
$survey = Survey::model()->findByPk($iSurveyID);

$survey->deactivate();
die();
$iSurveyID = Yii::app()->request->getPost('sid', $iSurveyID);
$iSurveyID = sanitize_int($iSurveyID);
$date = date('YmdHis'); //'His' adds 24hours+minutes to name to allow multiple deactiviations in a day
Expand Down Expand Up @@ -412,10 +416,9 @@ public function activate($iSurveyID)
$survey->refurl = Yii::app()->request->getPost('refurl');
$survey->savetimings = Yii::app()->request->getPost('savetimings');
$survey->save();
Survey::model()->resetCache(); // Make sure the saved values will be picked up
}

$aResult=activateSurvey($iSurveyID);
$aResult = $survey->activate();
if (isset($aResult['error']))
{
$aViewUrls['output']= "<br />\n<div class='messagebox ui-corner-all'>\n" .
Expand Down Expand Up @@ -1671,7 +1674,7 @@ function insert($iSurveyID=null)
*/
protected function _renderWrappedTemplate($sAction = 'survey', $aViewUrls = array(), $aData = array())
{
App()->getClientScript()->registerPackage('jquery-superfish');

parent::_renderWrappedTemplate($sAction, $aViewUrls, $aData);
}

Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/surveypermission.php
Expand Up @@ -654,7 +654,7 @@ function surveyright($surveyid)
*/
protected function _renderWrappedTemplate($sAction = 'authentication', $aViewUrls = array(), $aData = array())
{
App()->getClientScript()->registerPackage('jquery-superfish');

parent::_renderWrappedTemplate($sAction, $aViewUrls, $aData);
}

Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/templates.php
Expand Up @@ -344,7 +344,7 @@ public function index($editfile = 'startpage.pstpl', $screenname = 'welcome', $t
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('adminscripts') . "admin_core.js");
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('adminscripts') . 'templates.js');
App()->getClientScript()->registerPackage('ace');
App()->getClientScript()->registerPackage('jquery-superfish');

$this->_renderWrappedTemplate('templates', $aViewUrls);

if ($screenname != 'welcome')
Expand Down
4 changes: 2 additions & 2 deletions application/core/Survey_Common_Action.php
Expand Up @@ -528,7 +528,7 @@ function _surveybar($iSurveyID, $gid=null)
//$surveyinfo = array_map('htmlspecialchars', $surveyinfo);
$activated = ($surveyinfo['active'] == 'Y');

App()->getClientScript()->registerPackage('jquery-superfish');

App()->getClientScript()->registerPackage('jquery-cookie');
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('adminscripts') . 'surveytoolbar.js');

Expand Down Expand Up @@ -884,7 +884,7 @@ function _browsemenubar($iSurveyID, $title='')
$aData['thissurvey'] = getSurveyInfo($iSurveyID);
$aData['sImageURL'] = Yii::app()->getConfig("adminimageurl");
$aData['surveyid'] = $iSurveyID;
App()->getClientScript()->registerPackage('jquery-superfish');


$tmp_survlangs = Survey::model()->findByPk($iSurveyID)->additionalLanguages;
$baselang = Survey::model()->findByPk($iSurveyID)->language;
Expand Down
4 changes: 3 additions & 1 deletion application/core/WebApplication.php
Expand Up @@ -20,7 +20,9 @@
* Implements global config
* @property CLogRouter $log Log router component.
* @property LocalizedFormatter $format
* @property \ls\pluginmanager\PluginManager $pluginManager
* @property \ls\pluginmanager\PluginManager $pluginManager
* @property CDbConnection $db
* @property CHttpRequest $request;
* @property WebUser $user
*/
class WebApplication extends CWebApplication
Expand Down
120 changes: 3 additions & 117 deletions application/helpers/admin/activate_helper.php
Expand Up @@ -251,127 +251,13 @@ function checkQuestions($postsid, $iSurveyID, $qtypes)

function activateSurvey($iSurveyID, $simulate = false)
{
$createsurvey='';
$activateoutput='';
$createsurveytimings='';
$fieldstiming = array();
$createsurveydirectory=false;
//Check for any additional fields for this survey and create necessary fields (token and datestamp)
$prow = Survey::model()->findByAttributes(array('sid' => $iSurveyID));

//Get list of questions for the base language
$fieldmap = createFieldMap($iSurveyID,'full',true,false,getBaseLanguageFromSurveyID($iSurveyID));

$createsurvey = array();

foreach ($fieldmap as $j=>$arow) //With each question, create the appropriate field(s)
{
switch($arow['type'])
{
case 'startlanguage':
$createsurvey[$arow['fieldname']] = "string(20) NOT NULL";
break;
case 'id':
$createsurvey[$arow['fieldname']] = "pk";
break;
case "startdate":
case "datestamp":
$createsurvey[$arow['fieldname']] = "datetime NOT NULL";
break;
case "submitdate":
$createsurvey[$arow['fieldname']] = "datetime";
break;
case "lastpage":
$createsurvey[$arow['fieldname']] = "integer";
break;
case "N": //Numerical
case "K": //Multiple Numerical
$createsurvey[$arow['fieldname']] = "decimal (30,10)";
break;
case "S": //SHORT TEXT
$createsurvey[$arow['fieldname']] = "text";
break;
case "L": //LIST (RADIO)
case "!": //LIST (DROPDOWN)
case "M": //Multiple choice
case "P": //Multiple choice with comment
case "O": //DROPDOWN LIST WITH COMMENT
if ($arow['aid'] != 'other' && strpos($arow['aid'],'comment')===false && strpos($arow['aid'],'othercomment')===false)
{
$createsurvey[$arow['fieldname']] = "string(5)";
}
else
{
$createsurvey[$arow['fieldname']] = "text";
}
break;
case "U": //Huge text
case "Q": //Multiple short text
case "T": //LONG TEXT
case ";": //Multi Flexi
case ":": //Multi Flexi
$createsurvey[$arow['fieldname']] = "text";
break;
case "D": //DATE
$createsurvey[$arow['fieldname']] = "datetime";
break;
case "5": //5 Point Choice
case "G": //Gender
case "Y": //YesNo
case "X": //Boilerplate
$createsurvey[$arow['fieldname']] = "string(1)";
break;
case "I": //Language switch
$createsurvey[$arow['fieldname']] = "string(20)";
break;
case "|":
$createsurveydirectory = true;
if (strpos($arow['fieldname'], "_"))
$createsurvey[$arow['fieldname']] = "integer";
else
$createsurvey[$arow['fieldname']] = "text";
break;
case "ipaddress":
if ($prow->ipaddr == "Y")
$createsurvey[$arow['fieldname']] = "string";
break;
case "url":
if ($prow->refurl == "Y")
$createsurvey[$arow['fieldname']] = "string";
break;
case "token":
$createsurvey[$arow['fieldname']] = "string(36)";
break;
case '*': // Equation
$createsurvey[$arow['fieldname']] = "text";
break;
default:
$createsurvey[$arow['fieldname']] = "string(5)";
}
if ($prow->anonymized == 'N' && !array_key_exists('token',$createsurvey)) {
$createsurvey['token'] = "string(36)";
}
if ($simulate){
$tempTrim = trim($createsurvey);
$brackets = strpos($tempTrim,"(");
if ($brackets === false){
$type = substr($tempTrim,0,2);
}
else{
$type = substr($tempTrim,0,2);
}
$arrSim[] = array($type);
}
}

if ($simulate){
return array('dbengine'=>$CI->db->databasetabletype, 'dbtype'=>Yii::app()->db->driverName, 'fields'=>$arrSim);
}


// If last question is of type MCABCEFHP^QKJR let's get rid of the ending coma in createsurvey
//$createsurvey = rtrim($createsurvey, ",\n")."\n"; // Does nothing if not ending with a comma


Survey::model()->findByPk($iSurveyID)->activate();
die();
$tabname = "{{survey_{$iSurveyID}}}";
Yii::app()->loadHelper("database");
try
Expand Down

0 comments on commit a553783

Please sign in to comment.