From 0becedf4e7f1ea686e9b7ef90d3d2b279355db85 Mon Sep 17 00:00:00 2001 From: Carsten Schmitz Date: Sat, 7 Dec 2013 00:23:05 +0100 Subject: [PATCH] Dev Some variable refactoring --- application/controllers/AdminController.php | 159 +++++++-------- .../controllers/InstallerController.php | 193 +++++++++--------- application/controllers/OptinController.php | 46 ++--- application/controllers/OptoutController.php | 122 +++++------ application/controllers/PluginsController.php | 158 +++++++------- .../survey/QuestionGroups/import_view.php | 2 +- 6 files changed, 328 insertions(+), 352 deletions(-) diff --git a/application/controllers/AdminController.php b/application/controllers/AdminController.php index 3326c7b4e7d..3335c816a1d 100644 --- a/application/controllers/AdminController.php +++ b/application/controllers/AdminController.php @@ -28,11 +28,11 @@ protected function _init() { parent::_init(); App()->getComponent('bootstrap')->init(); - $updatelastcheck = getGlobalSetting('updatelastcheck'); + $sUpdateLastCheck = getGlobalSetting('updatelastcheck'); $this->_sessioncontrol(); - if (Yii::app()->getConfig('buildnumber') != "" && Yii::app()->getConfig('updatecheckperiod') > 0 && $updatelastcheck < dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", "-". Yii::app()->getConfig('updatecheckperiod')." days")) + if (Yii::app()->getConfig('buildnumber') != "" && Yii::app()->getConfig('updatecheckperiod') > 0 && $sUpdateLastCheck < dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", "-". Yii::app()->getConfig('updatecheckperiod')." days")) updateCheck(); //unset(Yii::app()->session['FileManagerContext']); @@ -57,39 +57,39 @@ protected function _init() * @param string|array $url URL. Either a string. Or array with keys url and title * @return void */ - public function error($message, $url = array()) + public function error($message, $sURL = array()) { $clang = $this->lang; $this->_getAdminHeader(); - $output = "
\n"; - $output .= '
'.$clang->gT('Error').'

'."\n"; - $output .= $message . '

'."\n"; - if (!empty($url) && !is_array($url)) + $sOutput = "
\n"; + $sOutput .= '
'.$clang->gT('Error').'

'."\n"; + $sOutput .= $message . '

'."\n"; + if (!empty($sURL) && !is_array($sURL)) { - $title = $clang->gT('Back'); + $sTitle = $clang->gT('Back'); } - elseif (!empty($url['url'])) + elseif (!empty($sURL['url'])) { - if (!empty($url['title'])) + if (!empty($sURL['title'])) { - $title = $url['title']; + $sTitle = $sURL['title']; } else { - $title = $clang->gT('Back'); + $sTitle = $clang->gT('Back'); } - $url = $url['url']; + $sURL = $sURL['url']; } else { - $title = $clang->gT('Main Admin Screen'); - $url = $this->createUrl('/admin'); + $sTitle = $clang->gT('Main Admin Screen'); + $sURL = $this->createUrl('/admin'); } - $output .= '

'."\n"; - $output .= '
'."\n"; - $output .= '
'."\n"; - echo $output; + $sOutput .= '

'."\n"; + $sOutput .= ''."\n"; + $sOutput .= ''."\n"; + echo $sOutput; $this->_getAdminFooter('http://manual.limesurvey.org', $clang->gT('LimeSurvey online manual')); @@ -140,8 +140,8 @@ public function run($action) // Check if the DB is up to date if (Yii::app()->db->schema->getTable('{{surveys}}')) { - $usrow = getGlobalSetting('DBVersion'); - if ((int) $usrow < Yii::app()->getConfig('dbversionnumber') && $action != 'update' && $action != 'authentication') + $sDBVersion = getGlobalSetting('DBVersion'); + if ((int) $sDBVersion < Yii::app()->getConfig('dbversionnumber') && $action != 'update' && $action != 'authentication') $this->redirect(array('/admin/update/sa/db')); } @@ -177,14 +177,14 @@ public function run($action) */ public function actions() { - $actions = $this->getActionClasses(); + $aActions = $this->getActionClasses(); - foreach ($actions as $action => $class) + foreach ($aActions as $action => $class) { - $actions[$action] = "application.controllers.admin.{$class}"; + $aActions[$action] = "application.controllers.admin.{$class}"; } - return $actions; + return $aActions; } public function getActionClasses() @@ -233,7 +233,7 @@ public function getActionClasses() */ public function _GetSessionUserRights($loginID) { - $user = User::model()->findByPk($loginID); + $oUser = User::model()->findByPk($loginID); // SuperAdmins // * original superadmin with uid=1 unless manually changed and defined @@ -242,17 +242,10 @@ public function _GetSessionUserRights($loginID) // Let's check if I am the Initial SuperAdmin - $user = User::model()->findByAttributes(array('parent_id' => 0)); + $oUser = User::model()->findByAttributes(array('parent_id' => 0)); - if (!is_null($user) && $user->uid == $loginID) - $initialSuperadmin=true; - else - $initialSuperadmin=false; - - if ($initialSuperadmin === true) - { + if (!is_null($oUser) && $oUser->uid == $loginID) Yii::app()->session['USER_RIGHT_INITIALSUPERADMIN'] = 1; - } else Yii::app()->session['USER_RIGHT_INITIALSUPERADMIN'] = 0; } @@ -270,55 +263,55 @@ public function _getAdminHeader($meta = false, $return = false) if (empty(Yii::app()->session['adminlang'])) Yii::app()->session["adminlang"] = Yii::app()->getConfig("defaultlang"); - $data = array(); - $data['adminlang'] = Yii::app()->session['adminlang']; + $aData = array(); + $aData['adminlang'] = Yii::app()->session['adminlang']; //$data['admin'] = getLanguageRTL; - $data['test'] = "t"; - $data['languageRTL']=""; - $data['styleRTL']=""; + $aData['test'] = "t"; + $aData['languageRTL']=""; + $aData['styleRTL']=""; Yii::app()->loadHelper("surveytranslator"); if (getLanguageRTL(Yii::app()->session["adminlang"])) { - $data['languageRTL'] = " dir=\"rtl\" "; - $data['bIsRTL']=true; + $aData['languageRTL'] = " dir=\"rtl\" "; + $aData['bIsRTL']=true; } else { - $data['bIsRTL']=false; + $aData['bIsRTL']=false; } - $data['meta']=""; + $aData['meta']=""; if ($meta) { - $data['meta']=$meta; + $aData['meta']=$meta; } - $data['baseurl'] = Yii::app()->baseUrl . '/'; - $data['datepickerlang']=""; + $aData['baseurl'] = Yii::app()->baseUrl . '/'; + $aData['datepickerlang']=""; if (Yii::app()->session["adminlang"] != 'en') Yii::app()->getClientScript()->registerScriptFile(App()->baseUrl . "/third_party/jqueryui/development-bundle/ui/i18n/jquery.ui.datepicker-" . Yii::app()->session['adminlang'] .".js"); - $data['sitename'] = Yii::app()->getConfig("sitename"); - $data['admintheme'] = Yii::app()->getConfig("admintheme"); - $data['firebug'] = useFirebug(); + $aData['sitename'] = Yii::app()->getConfig("sitename"); + $aData['admintheme'] = Yii::app()->getConfig("admintheme"); + $aData['firebug'] = useFirebug(); if (!empty(Yii::app()->session['dateformat'])) - $data['formatdata'] = getDateFormatData(Yii::app()->session['dateformat']); + $aData['formatdata'] = getDateFormatData(Yii::app()->session['dateformat']); - $out = $this->renderPartial("/admin/super/header", $data, true); + $sOutput = $this->renderPartial("/admin/super/header", $aData, true); if ($return) { - return $out; + return $sOutput; } else { - echo $out; + echo $sOutput; } } @@ -334,31 +327,31 @@ public function _getAdminHeader($meta = false, $return = false) public function _getAdminFooter($url, $explanation, $return = false) { $clang = $this->lang; - $data['clang'] = $clang; + $aData['clang'] = $clang; - $data['versionnumber'] = Yii::app()->getConfig("versionnumber"); + $aData['versionnumber'] = Yii::app()->getConfig("versionnumber"); - $data['buildtext'] = ""; + $aData['buildtext'] = ""; if(Yii::app()->getConfig("buildnumber")!="") { - $data['buildtext']= "Build ".Yii::app()->getConfig("buildnumber"); + $aData['buildtext']= "Build ".Yii::app()->getConfig("buildnumber"); } //If user is not logged in, don't print the version number information in the footer. if (empty(Yii::app()->session['loginID'])) { - $data['versionnumber']=""; - $data['versiontitle']=""; - $data['buildtext']=""; + $aData['versionnumber']=""; + $aData['versiontitle']=""; + $aData['buildtext']=""; } else { - $data['versiontitle'] = $clang->gT('Version'); + $aData['versiontitle'] = $clang->gT('Version'); } - $data['imageurl'] = Yii::app()->getConfig("imageurl"); - $data['url'] = $url; + $aData['imageurl'] = Yii::app()->getConfig("imageurl"); + $aData['url'] = $url; - return $this->renderPartial("/admin/super/footer", $data, $return); + return $this->renderPartial("/admin/super/footer", $aData, $return); } @@ -373,12 +366,12 @@ public function _getAdminFooter($url, $explanation, $return = false) */ public function _showMessageBox($title,$message,$class="header ui-widget-header") { - $data['title'] = $title; - $data['message'] = $message; - $data['class'] = $class; - $data['clang'] = $this->lang; + $aData['title'] = $title; + $aData['message'] = $message; + $aData['class'] = $class; + $aData['clang'] = $this->lang; - $this->renderPartial('/admin/super/messagebox', $data); + $this->renderPartial('/admin/super/messagebox', $aData); } /** @@ -397,36 +390,36 @@ public function _showadminmenu($surveyid = false) { $clang = $this->lang; - $data['clang']= $clang; + $aData['clang']= $clang; if (Yii::app()->session['pw_notify'] && Yii::app()->getConfig("debug")<2) { Yii::app()->session['flashmessage'] = $clang->gT("Warning: You are still using the default password ('password'). Please change your password and re-login again."); } - $data['showupdate'] = (Yii::app()->session['USER_RIGHT_SUPERADMIN'] == 1 && getGlobalSetting("updatenotification")!='never' && getGlobalSetting("updateavailable")==1 && Yii::app()->getConfig("updatable") ); - if($data['showupdate']) + $aData['showupdate'] = (Yii::app()->session['USER_RIGHT_SUPERADMIN'] == 1 && getGlobalSetting("updatenotification")!='never' && getGlobalSetting("updateavailable")==1 && Yii::app()->getConfig("updatable") ); + if($aData['showupdate']) { - $data['aUpdateVersions'] = json_decode(getGlobalSetting("updateversions"),true); + $aData['aUpdateVersions'] = json_decode(getGlobalSetting("updateversions"),true); $aUpdateTexts=array(); - foreach ($data['aUpdateVersions'] as $aVersion) + foreach ($aData['aUpdateVersions'] as $aVersion) { $aUpdateTexts[]=$aVersion['versionnumber'].'('.$aVersion['build'].')'; } - $data['sUpdateText']=implode(' '.$clang->gT('or').' ',$aUpdateTexts); + $aData['sUpdateText']=implode(' '.$clang->gT('or').' ',$aUpdateTexts); } - $data['surveyid'] = $surveyid; - $data['iconsize'] = Yii::app()->getConfig('adminthemeiconsize'); - $data['sImageURL'] = Yii::app()->getConfig('adminimageurl'); - $this->renderPartial("/admin/super/adminmenu", $data); + $aData['surveyid'] = $surveyid; + $aData['iconsize'] = Yii::app()->getConfig('adminthemeiconsize'); + $aData['sImageURL'] = Yii::app()->getConfig('adminimageurl'); + $this->renderPartial("/admin/super/adminmenu", $aData); } public function _loadEndScripts() { - static $out = false; - if ($out) + static $bRendered = false; + if ($bRendered) return true; - $out = true; + $bRendered = true; if (empty(Yii::app()->session['metaHeader'])) Yii::app()->session['metaHeader'] = ''; diff --git a/application/controllers/InstallerController.php b/application/controllers/InstallerController.php index 36cec4a2696..989dd2ad9d0 100644 --- a/application/controllers/InstallerController.php +++ b/application/controllers/InstallerController.php @@ -151,9 +151,9 @@ private function stepWelcome() foreach(getLanguageData(true, $sCurrentLanguage) as $sKey => $aLanguageInfo) { - $languages[htmlspecialchars($sKey)] = sprintf('%s - %s', $aLanguageInfo['nativedescription'], $aLanguageInfo['description']); + $aLanguages[htmlspecialchars($sKey)] = sprintf('%s - %s', $aLanguageInfo['nativedescription'], $aLanguageInfo['description']); } - $aData['languages']=$languages; + $aData['languages']=$aLanguages; $this->render('/installer/welcome_view',$aData); } @@ -195,7 +195,7 @@ public function stepViewLicense() private function stepPreInstallationCheck() { $aData['clang'] = $clang = $this->lang; - $model = new InstallerConfigForm(); + $oModel = new InstallerConfigForm(); //usual data required by view $aData['title'] = $clang->gT('Pre-installation check'); $aData['descp'] = $clang->gT('Pre-installation check for LimeSurvey ').Yii::app()->getConfig('versionnumber'); @@ -204,10 +204,10 @@ private function stepPreInstallationCheck() $aData['phpVersion'] = phpversion(); // variable storing next button link.initially null $aData['next'] = ''; - $aData['dbtypes']=$model->supported_db_types; + $aData['dbtypes']=$oModel->supported_db_types; $bProceed = $this->_check_requirements($aData); - $aData['dbtypes']=$model->supported_db_types; + $aData['dbtypes']=$oModel->supported_db_types; if(count($aData['dbtypes'])==0) { @@ -236,20 +236,20 @@ private function stepDatabaseConfiguration() $aData['descp'] = $clang->gT('Please enter the database settings you want to use for LimeSurvey:'); $aData['classesForStep'] = array('off','off','off','on','off','off'); $aData['progressValue'] = 40; - $aData['model'] = $model = new InstallerConfigForm; + $aData['model'] = $oModel = new InstallerConfigForm; if(isset($_POST['InstallerConfigForm'])) { - $model->attributes = $_POST['InstallerConfigForm']; + $oModel->attributes = $_POST['InstallerConfigForm']; //run validation, if it fails, load the view again else proceed to next step. - if($model->validate()) { - $sDatabaseType = $model->dbtype; - $sDatabaseName = $model->dbname; - $sDatabaseUser = $model->dbuser; - $sDatabasePwd = $model->dbpwd; - $sDatabasePrefix = $model->dbprefix; - $sDatabaseLocation = $model->dblocation; + if($oModel->validate()) { + $sDatabaseType = $oModel->dbtype; + $sDatabaseName = $oModel->dbname; + $sDatabaseUser = $oModel->dbuser; + $sDatabasePwd = $oModel->dbpwd; + $sDatabasePrefix = $oModel->dbprefix; + $sDatabaseLocation = $oModel->dblocation; $sDatabasePort = ''; if (strpos($sDatabaseLocation, ':')!==false) { @@ -272,9 +272,9 @@ private function stepDatabaseConfiguration() if (self::_dbConnect($aDbConfig, array())) { $bDBConnectionWorks = true; } else { - $model->addError('dblocation', $clang->gT('Connection with database failed. Please check database location, user name and password and try again.')); - $model->addError('dbpwd',''); - $model->addError('dbuser',''); + $oModel->addError('dblocation', $clang->gT('Connection with database failed. Please check database location, user name and password and try again.')); + $oModel->addError('dbpwd',''); + $oModel->addError('dbuser',''); } } @@ -283,7 +283,7 @@ private function stepDatabaseConfiguration() { //saving the form data foreach(array('dbname', 'dbtype', 'dbpwd', 'dbuser', 'dbprefix') as $sStatusKey) { - Yii::app()->session[$sStatusKey] = $model->$sStatusKey; + Yii::app()->session[$sStatusKey] = $oModel->$sStatusKey; } Yii::app()->session['dbport'] = $sDatabasePort; Yii::app()->session['dblocation'] = $sDatabaseLocation; @@ -301,7 +301,7 @@ private function stepDatabaseConfiguration() } } - $dbexistsbutempty = ($bDBExists && $bTablesDoNotExist); + $bDBExistsButEmpty = ($bDBExists && $bTablesDoNotExist); //store them in session Yii::app()->session['databaseexist'] = $bDBExists; @@ -322,22 +322,22 @@ private function stepDatabaseConfiguration() exit(); } - if (in_array($model->dbtype, array('mysql', 'mysqli'))) { + if (in_array($oModel->dbtype, array('mysql', 'mysqli'))) { //for development - use mysql in the strictest mode //Checked) if (Yii::app()->getConfig('debug')>1) { $this->connection->createCommand("SET SESSION SQL_MODE='STRICT_ALL_TABLES,ANSI'")->execute(); } - $versioninfo = $this->connection->getServerVersion(); - if (version_compare($versioninfo,'4.1','<')) + $sMySQLVersion = $this->connection->getServerVersion(); + if (version_compare($sMySQLVersion,'4.1','<')) { - die("
Error: You need at least MySQL version 4.1 to run LimeSurvey. Your version:".$versioninfo); + die("
Error: You need at least MySQL version 4.1 to run LimeSurvey. Your version:".$sMySQLVersion); } @$this->connection->createCommand("SET CHARACTER SET 'utf8'")->execute(); //Checked @$this->connection->createCommand("SET NAMES 'utf8'")->execute(); //Checked } // Setting dateformat for mssql driver. It seems if you don't do that the in- and output format could be different - if (in_array($model->dbtype, array('mssql', 'sqlsrv', 'dblib'))) { + if (in_array($oModel->dbtype, array('mssql', 'sqlsrv', 'dblib'))) { @$this->connection->createCommand('SET DATEFORMAT ymd;')->execute(); //Checked @$this->connection->createCommand('SET QUOTED_IDENTIFIER ON;')->execute(); //Checked } @@ -360,7 +360,7 @@ private function stepDatabaseConfiguration() $aValues['adminoutputText'].= "\t\n" ."".$clang->gT("Database doesn't exist!")."

\n" - .$clang->gT("The database you specified does not exist:")."

\n".$model->dbname."

\n" + .$clang->gT("The database you specified does not exist:")."

\n".$oModel->dbname."

\n" .$clang->gT("LimeSurvey can attempt to create this database for you.")."

\n"; $aValues['next'] = array( @@ -369,13 +369,13 @@ private function stepDatabaseConfiguration() 'name' => '', ); } - elseif ($dbexistsbutempty) //&& !(returnGlobal('createdbstep2')==$clang->gT("Populate database"))) + elseif ($bDBExistsButEmpty) //&& !(returnGlobal('createdbstep2')==$clang->gT("Populate database"))) { Yii::app()->session['populatedatabase'] = true; //$this->connection->database = $model->dbname; // //$this->connection->createCommand("USE DATABASE `".$model->dbname."`")->execute(); - $aValues['adminoutputText'].= sprintf($clang->gT('A database named "%s" already exists.'),$model->dbname)."

\n" + $aValues['adminoutputText'].= sprintf($clang->gT('A database named "%s" already exists.'),$oModel->dbname)."

\n" .$clang->gT("Do you want to populate that database now by creating the necessary tables?")."

"; $aValues['next'] = array( @@ -384,7 +384,7 @@ private function stepDatabaseConfiguration() 'name' => 'createdbstep2', ); } - elseif (!$dbexistsbutempty) + elseif (!$bDBExistsButEmpty) { //DB EXISTS, CHECK FOR APPROPRIATE UPGRADES //$this->connection->database = $model->dbname; @@ -571,21 +571,21 @@ function stepPopulateDb() //$data1['adminoutput'] = ''; //$data1['adminoutput'] .= sprintf("Database `%s` has been successfully populated.",$dbname)."

\n"; //$data1['adminoutput'] .= ""; - $confirmation = sprintf($clang->gT("Database %s has been successfully populated."), sprintf('%s', Yii::app()->session['dbname'])); + $sConfirmation = sprintf($clang->gT("Database %s has been successfully populated."), sprintf('%s', Yii::app()->session['dbname'])); } else { - $confirmation = $clang->gT('Database was populated but there were errors:').'

'; } Yii::app()->session['tablesexist'] = true; Yii::app()->session['step3'] = true; - Yii::app()->session['optconfig_message'] = $confirmation; + Yii::app()->session['optconfig_message'] = $sConfirmation; unset(Yii::app()->session['populatedatabase']); $this->redirect(array('installer/optional')); @@ -612,14 +612,11 @@ private function stepOptionalConfiguration() //run validation, if it fails, load the view again else proceed to next step. if($model->validate()) { - $adminLoginPwd = $model->adminLoginPwd; - $confirmPwd = $model->confirmPwd; - $defaultuser = $model->adminLoginName; - $defaultpass = $model->adminLoginPwd; - $siteadminname = $model->adminName; - $siteadminbounce = $siteadminemail = $model->adminEmail; - $sitename = $model->siteName; - $defaultlang = $model->surveylang; + $sDefaultAdminUserName = $model->adminLoginName; + $sDefaultAdminPassword = $model->adminLoginPwd; + $sDefaultAdminRealName = $model->adminName; + $sDefaultSiteLanguage = $model->surveylang; + $sDefaultAdminEmail = $model->adminEmail; $aData['title'] = $clang->gT("Database configuration"); $aData['descp'] = $clang->gT("Please enter the database settings you want to use for LimeSurvey:"); @@ -631,15 +628,15 @@ private function stepOptionalConfiguration() //checking DB Connection if ($this->connection->getActive() == true) { - $password_hash=hash('sha256', $defaultpass); + $sPasswordHash=hash('sha256', $sDefaultAdminPassword); try { $user=new User; - $user->users_name=$defaultuser; - $user->password=$password_hash; - $user->full_name=$siteadminname; + $user->users_name=$sDefaultAdminUserName; + $user->password=$sPasswordHash; + $user->full_name=$sDefaultAdminRealName; $user->parent_id=0; - $user->lang=$defaultlang; - $user->email=$siteadminemail; + $user->lang=$sDefaultSiteLanguage; + $user->email=$sDefaultAdminEmail; $user->save(); $permission=new Permission; @@ -666,8 +663,8 @@ private function stepOptionalConfiguration() $aData['descp'] = $clang->gT("LimeSurvey has been installed successfully."); $aData['classesForStep'] = array('off','off','off','off','off','off'); $aData['progressValue'] = 100; - $aData['user'] = $defaultuser; - $aData['pwd'] = $defaultpass; + $aData['user'] = $sDefaultAdminUserName; + $aData['pwd'] = $sDefaultAdminPassword; $this->render('/installer/success_view', $aData); return; @@ -714,7 +711,7 @@ public function loadLibrary($library) * @param array $data return theme variables * @return bool requirements met */ - private function _check_requirements(&$data) + private function _check_requirements(&$aData) { // proceed variable check if all requirements are true. If any of them is false, proceed is set false. $bProceed = true; //lets be optimistic! @@ -753,11 +750,11 @@ function is_writable_recursive($sDirectory) * @param string $image return * @return bool result */ - function check_PHPFunction($function, &$image) + function check_PHPFunction($sFunctionName, &$sImage) { - $result = function_exists($function); - $image = check_HTML_image($result); - return $result; + $bExists = function_exists($sFunctionName); + $sImage = check_HTML_image($bExists); + return $bExists; } /** @@ -770,11 +767,11 @@ function check_PHPFunction($function, &$image) * @param string $keyError key for error data * @return bool result of check (that it is writeable which implies existance) */ - function check_PathWriteable($path, $type, &$data, $base, $keyError, $bRecursive=false) + function check_PathWriteable($path, $type, &$aData, $base, $keyError, $bRecursive=false) { - $result = false; - $data[$base.'Present'] = 'Not Found'; - $data[$base.'Writable'] = ''; + $bResult = false; + $aData[$base.'Present'] = 'Not Found'; + $aData[$base.'Writable'] = ''; switch($type) { case 1: $exists = is_file($path); @@ -787,20 +784,20 @@ function check_PathWriteable($path, $type, &$data, $base, $keyError, $bRecursive } if ($exists) { - $data[$base.'Present'] = 'Found'; + $aData[$base.'Present'] = 'Found'; if ((!$bRecursive && is_writable($path)) || ($bRecursive && is_writable_recursive($path))) { - $data[$base.'Writable'] = 'Writable'; - $result = true; + $aData[$base.'Writable'] = 'Writable'; + $bResult = true; } else { - $data[$base.'Writable'] = 'Unwritable'; + $aData[$base.'Writable'] = 'Unwritable'; } } - $result || $data[$keyError] = true; + $bResult || $aData[$keyError] = true; - return $result; + return $bResult; } /** @@ -833,39 +830,39 @@ function check_DirectoryWriteable($directory, &$data, $base, $keyError, $bRecurs // version check if (version_compare(PHP_VERSION, '5.1.6', '<')) - $bProceed = !$data['verror'] = true; + $bProceed = !$aData['verror'] = true; if ($this->return_bytes(ini_get('memory_limit'))/1024/1024<64) - $bProceed = !$data['bMemoryError'] = true; + $bProceed = !$aData['bMemoryError'] = true; // mbstring library check - if (!check_PHPFunction('mb_convert_encoding', $data['mbstringPresent'])) + if (!check_PHPFunction('mb_convert_encoding', $aData['mbstringPresent'])) $bProceed = false; // JSON library check - if (!check_PHPFunction('json_encode', $data['bJSONPresent'])) + if (!check_PHPFunction('json_encode', $aData['bJSONPresent'])) $bProceed = false; // ** file and directory permissions checking ** // config directory - if (!check_DirectoryWriteable(Yii::app()->getConfig('rootdir').'/application/config', $data, 'config', 'derror') ) + if (!check_DirectoryWriteable(Yii::app()->getConfig('rootdir').'/application/config', $aData, 'config', 'derror') ) $bProceed = false; // templates directory check - if (!check_DirectoryWriteable(Yii::app()->getConfig('tempdir').'/', $data, 'tmpdir', 'tperror',true) ) + if (!check_DirectoryWriteable(Yii::app()->getConfig('tempdir').'/', $aData, 'tmpdir', 'tperror',true) ) $bProceed = false; //upload directory check - if (!check_DirectoryWriteable(Yii::app()->getConfig('uploaddir').'/', $data, 'uploaddir', 'uerror',true) ) + if (!check_DirectoryWriteable(Yii::app()->getConfig('uploaddir').'/', $aData, 'uploaddir', 'uerror',true) ) $bProceed = false; // Session writable check $session = Yii::app()->session; /* @var $session CHttpSession */ $sessionWritable = ($session->get('saveCheck', null)==='save'); - $data['sessionWritable'] = $sessionWritable; - $data['sessionWritableImg'] = check_HTML_image($sessionWritable); + $aData['sessionWritable'] = $sessionWritable; + $aData['sessionWritableImg'] = check_HTML_image($sessionWritable); if (!$sessionWritable){ // For recheck, try to set the value again $session['saveCheck'] = 'save'; @@ -876,21 +873,21 @@ function check_DirectoryWriteable($directory, &$data, $base, $keyError, $bRecurs // gd library check if (function_exists('gd_info')) { - $data['gdPresent'] = check_HTML_image(array_key_exists('FreeType Support', gd_info())); + $aData['gdPresent'] = check_HTML_image(array_key_exists('FreeType Support', gd_info())); } else { - $data['gdPresent'] = check_HTML_image(false); + $aData['gdPresent'] = check_HTML_image(false); } // ldap library check - check_PHPFunction('ldap_connect', $data['ldapPresent']); + check_PHPFunction('ldap_connect', $aData['ldapPresent']); // php zip library check - check_PHPFunction('zip_open', $data['zipPresent']); + check_PHPFunction('zip_open', $aData['zipPresent']); // zlib php library check - check_PHPFunction('zlib_get_coding_type', $data['zlibPresent']); + check_PHPFunction('zlib_get_coding_type', $aData['zlibPresent']); // imap php library check - check_PHPFunction('imap_open', $data['bIMAPPresent']); + check_PHPFunction('imap_open', $aData['bIMAPPresent']); return $bProceed; } @@ -983,7 +980,7 @@ function _writeConfigFile() //} //else //{ - $showScriptName = 'true'; + $sShowScriptName = 'true'; //} if (stripos($_SERVER['SERVER_SOFTWARE'], 'apache') !== false || (ini_get('security.limit_extensions') && ini_get('security.limit_extensions')!='')) { @@ -994,7 +991,7 @@ function _writeConfigFile() $sURLFormat='get'; // Fall back to get if an Apache server cannot be determined reliably } - $dbdata = " '$sDsn'," . "\n"; if ($sDatabaseType!='sqlsrv' && $sDatabaseType!='dblib' ) { - $dbdata .="\t\t\t" . "'emulatePrepare' => true," . "\n"; + $sConfig .="\t\t\t" . "'emulatePrepare' => true," . "\n"; } - $dbdata .="\t\t\t" . "'username' => '".addslashes($sDatabaseUser)."'," . "\n" + $sConfig .="\t\t\t" . "'username' => '".addslashes($sDatabaseUser)."'," . "\n" ."\t\t\t" . "'password' => '".addslashes($sDatabasePwd)."'," . "\n" ."\t\t\t" . "'charset' => 'utf8'," . "\n" ."\t\t\t" . "'tablePrefix' => '$sDatabasePrefix'," . "\n"; if (in_array($sDatabaseType, array('mssql', 'sqlsrv', 'dblib'))) { - $dbdata .="\t\t\t" ."'initSQLs'=>array('SET DATEFORMAT ymd;','SET QUOTED_IDENTIFIER ON;')," . "\n"; + $sConfig .="\t\t\t" ."'initSQLs'=>array('SET DATEFORMAT ymd;','SET QUOTED_IDENTIFIER ON;')," . "\n"; } - $dbdata .="\t\t" . ")," . "\n" + $sConfig .="\t\t" . ")," . "\n" ."\t\t" . "" . "\n" ."\t\t" . "// Uncomment the following line if you need table-based sessions". "\n" @@ -1072,7 +1069,7 @@ function _writeConfigFile() ."\t\t" . "'urlManager' => array(" . "\n" ."\t\t\t" . "'urlFormat' => '{$sURLFormat}'," . "\n" ."\t\t\t" . "'rules' => require('routes.php')," . "\n" - ."\t\t\t" . "'showScriptName' => $showScriptName," . "\n" + ."\t\t\t" . "'showScriptName' => $sShowScriptName," . "\n" ."\t\t" . ")," . "\n" ."\t" . "" . "\n" @@ -1091,7 +1088,7 @@ function _writeConfigFile() . "/* Location: ./application/config/config.php */"; if (is_writable(APPPATH . 'config')) { - file_put_contents(APPPATH . 'config/config.php', $dbdata); + file_put_contents(APPPATH . 'config/config.php', $sConfig); Yii::app()->session['configFileWritten'] = true; $oUrlManager = Yii::app()->getComponent('urlManager'); /* @var $oUrlManager CUrlManager */ @@ -1112,9 +1109,9 @@ function _writeConfigFile() */ function _getRandomString() { - $totalChar = 64; // number of chars in the sid + $iTotalChar = 64; // number of chars in the sid $sResult=''; - for ($i=0;$i<$totalChar;$i++) + for ($i=0;$i<$iTotalChar;$i++) { $sResult.=chr(rand(33,126)); } @@ -1134,9 +1131,9 @@ function _getDsn($sDatabaseType, $sDatabaseLocation, $sDatabasePort, $sDatabaseN case 'mysqli': // MySQL allow unix_socket for database location, then test if $sDatabaseLocation start with "/" if(substr($sDatabaseLocation,0,1)=="/") - $dsn = "mysql:unix_socket={$sDatabaseLocation};dbname={$sDatabaseName};"; + $sDSN = "mysql:unix_socket={$sDatabaseLocation};dbname={$sDatabaseName};"; else - $dsn = "mysql:host={$sDatabaseLocation};port={$sDatabasePort};dbname={$sDatabaseName};"; + $sDSN = "mysql:host={$sDatabaseLocation};port={$sDatabasePort};dbname={$sDatabaseName};"; break; case 'pgsql': if (empty($sDatabasePwd)) @@ -1146,25 +1143,25 @@ function _getDsn($sDatabaseType, $sDatabaseLocation, $sDatabasePort, $sDatabaseN // (including the ";" and the potential dbname) as part of the password definition. $sDatabasePwd = '""'; } - $dsn = "pgsql:host={$sDatabaseLocation};port={$sDatabasePort};user={$sDatabaseUser};password={$sDatabasePwd};"; + $sDSN = "pgsql:host={$sDatabaseLocation};port={$sDatabasePort};user={$sDatabaseUser};password={$sDatabasePwd};"; if ($sDatabaseName!='') { - $dsn.="dbname={$sDatabaseName};"; + $sDSN.="dbname={$sDatabaseName};"; } break; case 'dblib' : - $dsn = $sDatabaseType.":host={$sDatabaseLocation};dbname={$sDatabaseName}"; + $sDSN = $sDatabaseType.":host={$sDatabaseLocation};dbname={$sDatabaseName}"; break; case 'mssql' : case 'sqlsrv': if ($sDatabasePort!=''){$sDatabaseLocation=$sDatabaseLocation.','.$sDatabasePort;} - $dsn = $sDatabaseType.":Server={$sDatabaseLocation};Database={$sDatabaseName}"; + $sDSN = $sDatabaseType.":Server={$sDatabaseLocation};Database={$sDatabaseName}"; break; default: throw new Exception(sprintf('Unknown database type "%s".', $sDatabaseType)); } - return $dsn; + return $sDSN; } /** @@ -1253,8 +1250,8 @@ function _dbConnect($aDbConfig = array(), $aData = array()) */ function return_bytes($sValue) { $sValue = trim($sValue); - $last = strtolower($sValue[strlen($sValue)-1]); - switch($last) { + $sLast = strtolower($sValue[strlen($sValue)-1]); + switch($sLast) { // The 'G' modifier is available since PHP 5.1.0 case 'g': $sValue *= 1024; diff --git a/application/controllers/OptinController.php b/application/controllers/OptinController.php index d4a8bb98115..89ce2438c8a 100644 --- a/application/controllers/OptinController.php +++ b/application/controllers/OptinController.php @@ -42,63 +42,63 @@ function actiontokens($surveyid, $token, $langcode = '') // Get passed language from form, so that we dont loose this! if (!isset($sLanguageCode) || $sLanguageCode == "" || !$sLanguageCode) { - $baselang = Survey::model()->findByPk($iSurveyID)->language; + $sBaseLanguage = Survey::model()->findByPk($iSurveyID)->language; Yii::import('application.libraries.Limesurvey_lang', true); - $clang = new Limesurvey_lang($baselang); + $clang = new Limesurvey_lang($sBaseLanguage); } else { $sLanguageCode = sanitize_languagecode($sLanguageCode); Yii::import('application.libraries.Limesurvey_lang', true); $clang = new Limesurvey_lang($sLanguageCode); - $baselang = $sLanguageCode; + $sBaseLanguage = $sLanguageCode; } Yii::app()->lang = $clang; - $thissurvey=getSurveyInfo($iSurveyID,$baselang); + $aSurveyInfo=getSurveyInfo($iSurveyID,$sBaseLanguage); - if ($thissurvey == false || !tableExists("{{tokens_{$iSurveyID}}}")) + if ($aSurveyInfo == false || !tableExists("{{tokens_{$iSurveyID}}}")) { - $html = $clang->gT('This survey does not seem to exist.'); + $sMessage = $clang->gT('This survey does not seem to exist.'); } else { - $tokenInstance = Token::model($iSurveyID)->findByAttributes(array('token' => $token)); + $oToken = Token::model($iSurveyID)->findByAttributes(array('token' => $token)); - if (!isset($tokenInstance)) + if (!isset($oToken)) { - $html = $clang->gT('You are not a participant in this survey.'); + $sMessage = $clang->gT('You are not a participant in this survey.'); } else { - if ($tokenInstance->emailstatus =='OptOut') + if ($oToken->emailstatus =='OptOut') { - $tokenInstance->emailstatus = 'OK'; - $tokenInstance->save(); - $html = $clang->gT('You have been successfully added back to this survey.'); + $oToken->emailstatus = 'OK'; + $oToken->save(); + $sMessage = $clang->gT('You have been successfully added back to this survey.'); } - elseif ($tokenInstance->emailstatus == 'OK') + elseif ($oToken->emailstatus == 'OK') { - $html = $clang->gT('You are already a part of this survey.'); + $sMessage = $clang->gT('You are already a part of this survey.'); } else { - $html = $clang->gT('You have been already removed from this survey.'); + $sMessage = $clang->gT('You have been already removed from this survey.'); } } } //PRINT COMPLETED PAGE - if (!$thissurvey['templatedir']) + if (!$aSurveyInfo['templatedir']) { - $thistpl=getTemplatePath(Yii::app()->getConfig("defaulttemplate")); + $sTemplate=getTemplatePath(Yii::app()->getConfig("defaulttemplate")); } else { - $thistpl=getTemplatePath($thissurvey['templatedir']); + $sTemplate=getTemplatePath($aSurveyInfo['templatedir']); } - $this->_renderHtml($html,$thistpl,$clang,$thissurvey); + $this->_renderHtml($sMessage,$sTemplate,$clang,$aSurveyInfo); } private function _renderHtml($html,$thistpl, $oLanguage, $aSurveyInfo) @@ -107,9 +107,9 @@ private function _renderHtml($html,$thistpl, $oLanguage, $aSurveyInfo) doHeader(); $aSupportData=array('thissurvey'=>$aSurveyInfo, 'clang'=>$oLanguage); echo templatereplace(file_get_contents($thistpl.DIRECTORY_SEPARATOR.'startpage.pstpl'),array(), $aSupportData); - $data['html'] = $html; - $data['thistpl'] = $thistpl; - $this->render('/opt_view',$data); + $aData['html'] = $html; + $aData['thistpl'] = $thistpl; + $this->render('/opt_view',$aData); echo templatereplace(file_get_contents($thistpl.DIRECTORY_SEPARATOR.'endpage.pstpl'),array(), $aSupportData); doFooter(); } diff --git a/application/controllers/OptoutController.php b/application/controllers/OptoutController.php index dc7fbee71ca..4d7975d2163 100644 --- a/application/controllers/OptoutController.php +++ b/application/controllers/OptoutController.php @@ -28,18 +28,11 @@ class OptoutController extends LSYii_Controller { * */ function actiontokens() { - $surveyid=Yii::app()->request->getQuery('surveyid'); - $langcode=Yii::app()->request->getQuery('langcode'); - $token=Yii::app()->request->getQuery('token'); - + $iSurveyID=Yii::app()->request->getQuery('surveyid'); + $sLanguageCode=Yii::app()->request->getQuery('langcode'); + $sToken=sanitize_token(Yii::app()->request->getQuery('token')); Yii::app()->loadHelper('database'); Yii::app()->loadHelper('sanitize'); - $sLanguageCode = $langcode; - - $iSurveyID = $surveyid; - $sToken = $token; - $sToken = sanitize_token($sToken); - if (!$iSurveyID) //IF there is no survey id, redirect back to the default public page { $this->redirect(array('/')); @@ -49,59 +42,59 @@ function actiontokens() // Get passed language from form, so that we dont lose this! if (!isset($sLanguageCode) || $sLanguageCode == "" || !$sLanguageCode) { - $baselang = Survey::model()->findByPk($iSurveyID)->language; + $sBaseLanguage = Survey::model()->findByPk($iSurveyID)->language; Yii::import('application.libraries.Limesurvey_lang', true); - $clang = new Limesurvey_lang($baselang); + $clang = new Limesurvey_lang($sBaseLanguage); } else { $sLanguageCode = sanitize_languagecode($sLanguageCode); Yii::import('application.libraries.Limesurvey_lang', true); $clang = new Limesurvey_lang($sLanguageCode); - $baselang = $sLanguageCode; + $sBaseLanguage = $sLanguageCode; } Yii::app()->lang = $clang; - $thissurvey=getSurveyInfo($iSurveyID,$baselang); + $aSurveyInfo=getSurveyInfo($iSurveyID,$sBaseLanguage); - if ($thissurvey==false || !tableExists("{{tokens_{$iSurveyID}}}")){ - $html = $clang->gT('This survey does not seem to exist.'); + if ($aSurveyInfo==false || !tableExists("{{tokens_{$iSurveyID}}}")){ + $sMessage = $clang->gT('This survey does not seem to exist.'); } else { - $tokenInstance = Token::model($iSurveyID)->findByAttributes($sToken); + $oToken = Token::model($iSurveyID)->findByAttributes($sToken); - if (!isset($tokenInstance)) + if (!isset($oToken)) { - $html = $clang->gT('You are not a participant in this survey.'); + $sMessage = $clang->gT('You are not a participant in this survey.'); } else { - if ($tokenInstance->emailstatus == 'OK') + if ($oToken->emailstatus == 'OK') { - $tokenInstance->emailstatus = 'OptOut'; - $tokenInstance->save(); - $html = $clang->gT('You have been successfully removed from this survey.'); + $oToken->emailstatus = 'OptOut'; + $oToken->save(); + $sMessage = $clang->gT('You have been successfully removed from this survey.'); } else { - $html = $clang->gT('You have been already removed from this survey.'); + $sMessage = $clang->gT('You have been already removed from this survey.'); } } } //PRINT COMPLETED PAGE - if (!$thissurvey['templatedir']) + if (!$aSurveyInfo['templatedir']) { - $thistpl=getTemplatePath(Yii::app()->getConfig("defaulttemplate")); + $sTemplate=getTemplatePath(Yii::app()->getConfig("defaulttemplate")); } else { - $thistpl=getTemplatePath($thissurvey['templatedir']); + $sTemplate=getTemplatePath($aSurveyInfo['templatedir']); } - $this->_renderHtml($html,$thistpl,$thissurvey); + $this->_renderHtml($sMessage,$sTemplate,$aSurveyInfo); } /* This function is run when opting out of the participants system. The other function /optout/token @@ -111,18 +104,11 @@ function actiontokens() * */ function actionparticipants() { - $surveyid=Yii::app()->request->getQuery('surveyid'); - $langcode=Yii::app()->request->getQuery('langcode'); - $token=Yii::app()->request->getQuery('token'); - + $iSurveyID=Yii::app()->request->getQuery('surveyid'); + $sLanguageCode=Yii::app()->request->getQuery('langcode'); + $sToken=sanitize_token(Yii::app()->request->getQuery('token')); Yii::app()->loadHelper('database'); Yii::app()->loadHelper('sanitize'); - $sLanguageCode = $langcode; - - $iSurveyID = $surveyid; - $sToken = $token; - $sToken = sanitize_token($sToken); - if (!$iSurveyID) //IF there is no survey id, redirect back to the default public page { $this->redirect(array('/')); @@ -132,74 +118,74 @@ function actionparticipants() // Get passed language from form, so that we dont lose this! if (!isset($sLanguageCode) || $sLanguageCode == "" || !$sLanguageCode) { - $baselang = Survey::model()->findByPk($iSurveyID)->language; + $sBaseLanguage = Survey::model()->findByPk($iSurveyID)->language; Yii::import('application.libraries.Limesurvey_lang', true); - $clang = new Limesurvey_lang($baselang); + $clang = new Limesurvey_lang($sBaseLanguage); } else { $sLanguageCode = sanitize_languagecode($sLanguageCode); Yii::import('application.libraries.Limesurvey_lang', true); $clang = new Limesurvey_lang($sLanguageCode); - $baselang = $sLanguageCode; + $sBaseLanguage = $sLanguageCode; } Yii::app()->lang = $clang; - $thissurvey=getSurveyInfo($iSurveyID,$baselang); + $aSurveyInfo=getSurveyInfo($iSurveyID,$sBaseLanguage); - if ($thissurvey==false || !tableExists("{{tokens_{$iSurveyID}}}")){ - $html = $clang->gT('This survey does not seem to exist.'); + if ($aSurveyInfo==false || !tableExists("{{tokens_{$iSurveyID}}}")){ + $sMessage = $clang->gT('This survey does not seem to exist.'); } else { - $tokenInstance = Token::model($iSurveyID)->findByAttributes(array('token' => $sToken)); - if (!isset($tokenInstance)) + $oToken = Token::model($iSurveyID)->findByAttributes(array('token' => $sToken)); + if (!isset($oToken)) { - $html = $clang->gT('You are not a participant in this survey.'); + $sMessage = $clang->gT('You are not a participant in this survey.'); } else { - if ($tokenInstance->emailstatus == 'OK') + if ($oToken->emailstatus == 'OK') { - $tokenInstance->emailstatus = 'OptOut'; - $tokenInstance->save(); - $html = $clang->gT('You have been successfully removed from this survey.'); + $oToken->emailstatus = 'OptOut'; + $oToken->save(); + $sMessage = $clang->gT('You have been successfully removed from this survey.'); } else { - $html = $clang->gT('You have been already removed from this survey.'); + $sMessage = $clang->gT('You have been already removed from this survey.'); } - if(!empty($tokenInstance->participant_id)) + if(!empty($oToken->participant_id)) { //Participant also exists in central db - $cpdb = Participant::model()->findByPk($tokenInstance->participant_id); - if($cpdb->blacklisted=="Y") + $oParticipant = Participant::model()->findByPk($oToken->participant_id); + if($oParticipant->blacklisted=="Y") { - $html .= "
"; - $html .= $clang->gT("You have already been removed from the central participants list for this site"); + $sMessage .= "
"; + $sMessage .= $clang->gT("You have already been removed from the central participants list for this site"); } else { - $cpdb->blacklisted='Y'; - $cpdb->save(); - $html .= "
"; - $html .= $clang->gT("You have been removed from the central participants list for this site"); + $oParticipant->blacklisted='Y'; + $oParticipant->save(); + $sMessage .= "
"; + $sMessage .= $clang->gT("You have been removed from the central participants list for this site"); } } } } //PRINT COMPLETED PAGE - if (!$thissurvey['templatedir']) + if (!$aSurveyInfo['templatedir']) { - $thistpl=getTemplatePath(Yii::app()->getConfig("defaulttemplate")); + $sTemplate=getTemplatePath(Yii::app()->getConfig("defaulttemplate")); } else { - $thistpl=getTemplatePath($thissurvey['templatedir']); + $sTemplate=getTemplatePath($aSurveyInfo['templatedir']); } - $this->_renderHtml($html,$thistpl, $thissurvey); + $this->_renderHtml($sMessage,$sTemplate, $aSurveyInfo); } private function _renderHtml($html, $thistpl, $aSurveyInfo) @@ -208,9 +194,9 @@ private function _renderHtml($html, $thistpl, $aSurveyInfo) doHeader(); $aSupportData=array('thissurvey'=>$aSurveyInfo); echo templatereplace(file_get_contents($thistpl.DIRECTORY_SEPARATOR.'startpage.pstpl'),array(), $aSupportData); - $data['html'] = $html; - $data['thistpl'] = $thistpl; - $this->render('/opt_view',$data); + $aData['html'] = $html; + $aData['thistpl'] = $thistpl; + $this->render('/opt_view',$aData); echo templatereplace(file_get_contents($thistpl.DIRECTORY_SEPARATOR.'endpage.pstpl'),array(), $aSupportData); doFooter(); } diff --git a/application/controllers/PluginsController.php b/application/controllers/PluginsController.php index 4a2787ed743..42074cb7133 100644 --- a/application/controllers/PluginsController.php +++ b/application/controllers/PluginsController.php @@ -13,58 +13,58 @@ class PluginsController extends LSYii_Controller public function accessRules() { - $rules = array( + $aRules = array( array('allow', 'roles' => array('administrator')), - array('allow', 'actions' => array('direct')), + array('allow', 'actions' => array('direct')), array('deny') ); // Note the order; rules are numerically indexed and we want to // parents rules to be executed only if ours dont apply. - return array_merge($rules, parent::accessRules()); + return array_merge($aRules, parent::accessRules()); } public function actionIndex() { - $pluginManager = App()->getPluginManager(); + $oPluginManager = App()->getPluginManager(); // Scan the plugins folder. - $discoveredPlugins = $pluginManager->scanPlugins(); - $installedPlugins = $pluginManager->getInstalledPlugins(); - $installedNames = array_map(function ($installedPlugin) { return $installedPlugin->name; }, $installedPlugins); + $aDiscoveredPlugins = $oPluginManager->scanPlugins(); + $aInstalledPlugins = $oPluginManager->getInstalledPlugins(); + $aInstalledNames = array_map(function ($installedPlugin) { return $installedPlugin->name; }, $aInstalledPlugins); // Install newly discovered plugins. - foreach ($discoveredPlugins as $discoveredPlugin) + foreach ($aDiscoveredPlugins as $discoveredPlugin) { - if (!in_array($discoveredPlugin['pluginClass'], $installedNames)) + if (!in_array($discoveredPlugin['pluginClass'], $aInstalledNames)) { - $plugin = new Plugin(); - $plugin->name = $discoveredPlugin['pluginClass']; - $plugin->active = 0; - $plugin->save(); + $oPlugin = new Plugin(); + $oPlugin->name = $discoveredPlugin['pluginClass']; + $oPlugin->active = 0; + $oPlugin->save(); } } - $plugins = Plugin::model()->findAll(); + $aoPlugins = Plugin::model()->findAll(); $data = array(); - foreach ($plugins as $plugin) + foreach ($aoPlugins as $oPlugin) { /* @var $plugin Plugin */ - if (array_key_exists($plugin->name, $discoveredPlugins)) { - $pluginSettings = App()->getPluginManager()->loadPlugin($plugin->name, $plugin->id)->getPluginSettings(false); + if (array_key_exists($oPlugin->name, $aDiscoveredPlugins)) { + $aPluginSettings = App()->getPluginManager()->loadPlugin($oPlugin->name, $oPlugin->id)->getPluginSettings(false); $data[] = array( - 'id' => $plugin->id, - 'name' => $discoveredPlugins[$plugin->name]['pluginName'], - 'description' => $discoveredPlugins[$plugin->name]['description'], - 'active' => $plugin->active, - 'settings'=>$pluginSettings, - 'new' => !in_array($plugin->name, $installedNames) + 'id' => $oPlugin->id, + 'name' => $aDiscoveredPlugins[$oPlugin->name]['pluginName'], + 'description' => $aDiscoveredPlugins[$oPlugin->name]['description'], + 'active' => $oPlugin->active, + 'settings'=>$aPluginSettings, + 'new' => !in_array($oPlugin->name, $aInstalledNames) ); } else { // This plugin is missing, maybe the files were deleted but the record was not removed from the database // Now delete this record. Depending on the plugin the settings will be preserved - App()->user->setFlash('pluginDelete'.$plugin->id,sprintf(gT("Plugin '%s' was missing and is removed from the database."), $plugin->name)); - $plugin->delete(); + App()->user->setFlash('pluginDelete'.$oPlugin->id,sprintf(gT("Plugin '%s' was missing and is removed from the database."), $oPlugin->name)); + $oPlugin->delete(); } } echo $this->render('/plugins/index', compact('data')); @@ -72,76 +72,76 @@ public function actionIndex() public function actionActivate($id) { - $plugin = Plugin::model()->findByPk($id); - if (!is_null($plugin)) { - $status = $plugin->active; - if ($status == 0) { + $oPlugin = Plugin::model()->findByPk($id); + if (!is_null($oPlugin)) { + $iStatus = $oPlugin->active; + if ($iStatus == 0) { // Load the plugin: - App()->getPluginManager()->loadPlugin($plugin->name, $id); - $result = App()->getPluginManager()->dispatchEvent(new PluginEvent('beforeActivate', $this), $plugin->name); + App()->getPluginManager()->loadPlugin($oPlugin->name, $id); + $result = App()->getPluginManager()->dispatchEvent(new PluginEvent('beforeActivate', $this), $oPlugin->name); if ($result->get('success', true)) { - $status = 1; + $iStatus = 1; } else { - $message = $result->get('message', gT('Failed to activate the plugin.')); - App()->user->setFlash('pluginActivation', $message); + $sMessage = $result->get('message', gT('Failed to activate the plugin.')); + App()->user->setFlash('pluginActivation', $sMessage); $this->redirect(array('plugins/')); } } - $plugin->active = $status; - $plugin->save(); + $oPlugin->active = $iStatus; + $oPlugin->save(); } $this->redirect(array('plugins/')); } public function actionDeactivate($id) { - $plugin = Plugin::model()->findByPk($id); - if (!is_null($plugin)) { - $status = $plugin->active; - if ($status == 1) { - $result = App()->getPluginManager()->dispatchEvent(new PluginEvent('beforeDeactivate', $this), $plugin->name); + $oPlugin = Plugin::model()->findByPk($id); + if (!is_null($oPlugin)) { + $iStatus = $oPlugin->active; + if ($iStatus == 1) { + $result = App()->getPluginManager()->dispatchEvent(new PluginEvent('beforeDeactivate', $this), $oPlugin->name); if ($result->get('success', true)) { - $status = 0; + $iStatus = 0; } else { $message = $result->get('message', gT('Failed to deactivate the plugin.')); App()->user->setFlash('pluginActivation', $message); $this->redirect(array('plugins/')); } } - $plugin->active = $status; - $plugin->save(); + $oPlugin->active = $iStatus; + $oPlugin->save(); } $this->redirect(array('plugins/')); } - public function actionDirect($plugin, $function) - { - $event = new PluginEvent('newDirectRequest'); - // The intended target of the call. - $event->set('target', $plugin); - // The name of the function. - $event->set('function', $function); - $event->set('request', App()->request); + public function actionDirect($plugin, $function) + { + $oEvent = new PluginEvent('newDirectRequest'); + // The intended target of the call. + $oEvent->set('target', $plugin); + // The name of the function. + $oEvent->set('function', $function); + $oEvent->set('request', App()->request); - App()->getPluginManager()->dispatchEvent($event); - - $out = ''; - foreach($event->getAllContent() as $content) - { - $out .= $content->getContent(); - } + App()->getPluginManager()->dispatchEvent($oEvent); + + $sOutput = ''; + foreach($oEvent->getAllContent() as $content) + { + $sOutput .= $content->getContent(); + } - if (!empty($out)) - { - $this->renderText($out); - } - } + if (!empty($sOutput)) + { + $this->renderText($sOutput); + } + } public function actionConfigure($id) { - $plugin = Plugin::model()->findByPk($id)->attributes; - $pluginObject = App()->getPluginManager()->loadPlugin($plugin['name'], $plugin['id']); + $arPlugin = Plugin::model()->findByPk($id)->attributes; + $oPluginObject = App()->getPluginManager()->loadPlugin($arPlugin['name'], $arPlugin['id']); - if ($plugin === null) + if ($arPlugin === null) { Yii::app()->user->setFlash('pluginmanager', 'Plugin not found'); $this->redirect(array('plugins/')); @@ -149,19 +149,19 @@ public function actionConfigure($id) // If post handle data. if (App()->request->isPostRequest) { - $settings = $pluginObject->getPluginSettings(false); - $save = array(); - foreach ($settings as $name => $setting) - { - $save[$name] = App()->request->getPost($name, null); + $aSettings = $oPluginObject->getPluginSettings(false); + $aSave = array(); + foreach ($aSettings as $name => $setting) + { + $aSave[$name] = App()->request->getPost($name, null); - } - $pluginObject->saveSettings($save); - Yii::app()->user->setFlash('pluginmanager', 'Settings saved'); + } + $oPluginObject->saveSettings($aSave); + Yii::app()->user->setFlash('pluginmanager', 'Settings saved'); } - $settings = $pluginObject->getPluginSettings(); - if (empty($settings)) { + $aSettings = $oPluginObject->getPluginSettings(); + if (empty($aSettings)) { // And show a message Yii::app()->user->setFlash('pluginmanager', 'This plugin has no settings'); $this->forward('plugins/index', true); @@ -172,10 +172,10 @@ public function actionConfigure($id) public function filters() { - $filters = array( + $aFilters = array( 'accessControl' ); - return array_merge(parent::filters(), $filters); + return array_merge(parent::filters(), $aFilters); } public function __get($property) diff --git a/application/views/admin/survey/QuestionGroups/import_view.php b/application/views/admin/survey/QuestionGroups/import_view.php index 01cf7b48c9e..48575135a0c 100644 --- a/application/views/admin/survey/QuestionGroups/import_view.php +++ b/application/views/admin/survey/QuestionGroups/import_view.php @@ -6,7 +6,7 @@
eT("Success") ?>

gT("Question group import summary") ?>