diff --git a/.scrutinizer.yml b/.scrutinizer.yml
index 3e91dae6989..d7ffe8f2054 100644
--- a/.scrutinizer.yml
+++ b/.scrutinizer.yml
@@ -1,5 +1,5 @@
filter:
- excluded_paths: [framework/*, locale/*, docs/*, fonts/*, third_party/*, application/libraries/admin/pclzip/*, application/extensions/*, application/views/*, application/third_party/*, images/*, styles/*, styles-public/*, templates/*, themes/*, tmp/*, upload/*]
+ excluded_paths: [framework/*, locale/*, docs/*, fonts/*, third_party/*, application/helpers/adodb/*, application/libraries/admin/http//*, application/libraries/admin/pclzip/*, application/extensions/*, application/views/*, application/third_party/*, images/*, styles/*, styles-public/*, templates/*, themes/*, tmp/*, upload/*]
paths: [application/*]
checks:
php:
@@ -7,4 +7,10 @@ checks:
duplication: true
one_class_per_file: true
coding_style:
- php: { }
\ No newline at end of file
+ php: { }
+
+# braces:
+# classes_functions:
+# class: new-line
+# function: new-line
+# closure: new-line
\ No newline at end of file
diff --git a/application/controllers/InstallerController.php b/application/controllers/InstallerController.php
index 991933b7f8a..1b115cda59a 100644
--- a/application/controllers/InstallerController.php
+++ b/application/controllers/InstallerController.php
@@ -372,8 +372,7 @@ private function stepDatabaseConfiguration()
'name' => '',
);
}
- elseif ($bDBExistsButEmpty) //&& !(returnGlobal('createdbstep2')==gT("Populate database")))
- {
+ elseif ($bDBExistsButEmpty) {
Yii::app()->session['populatedatabase'] = true;
//$this->connection->database = $model->dbname;
diff --git a/application/controllers/admin/surveyadmin.php b/application/controllers/admin/surveyadmin.php
index b4773160047..03815fea90b 100644
--- a/application/controllers/admin/surveyadmin.php
+++ b/application/controllers/admin/surveyadmin.php
@@ -657,8 +657,8 @@ public function deactivate($iSurveyID = null)
{
Yii::app()->user->setFlash('error', $message);
}
- if ($success === false) // TODO: What if two plugins change this?
- {
+ if ($success === false) {
+ // @todo: What if two plugins change this?
$aData['nostep'] = true;
$this->_renderWrappedTemplate('survey', 'deactivateSurvey_view', $aData);
return;
@@ -944,8 +944,7 @@ public function editSurvey_json()
{
$operation = Yii::app()->request->getPost('oper');
$iSurveyIDs = Yii::app()->request->getPost('id');
- if ($operation == 'del') // If operation is delete , it will delete, otherwise edit it
- {
+ if ($operation == 'del') { // If operation is delete , it will delete, otherwise edit it
foreach (explode(',', $iSurveyIDs) as $iSurveyID)
{
if (Permission::model()->hasSurveyPermission($iSurveyID, 'survey', 'delete'))
diff --git a/application/controllers/admin/surveypermission.php b/application/controllers/admin/surveypermission.php
index 06f07a20be2..41c048b950b 100644
--- a/application/controllers/admin/surveypermission.php
+++ b/application/controllers/admin/surveypermission.php
@@ -122,8 +122,7 @@ public function index($iSurveyID)
if (Permission::model()->hasSurveyPermission($iSurveyID, 'surveysecurity', 'update'))
{
- if ($PermissionRow['uid'] != Yii::app()->user->getId() || Permission::model()->hasGlobalPermission('superadmin', 'read')) // Can not update own security
- {
+ if ($PermissionRow['uid'] != Yii::app()->user->getId() || Permission::model()->hasGlobalPermission('superadmin', 'read')) { // Can not update own security
$surveysecurity .= CHtml::form(array("admin/surveypermission/sa/set/surveyid/{$iSurveyID}"), 'post', array('style'=>"display:inline;"))
."";
$surveysecurity .= \CHtml::hiddenField('action', 'setsurveysecurity');
@@ -468,8 +467,8 @@ function set($surveyid)
}
elseif ($action == "setusergroupsurveysecurity")
{
- if (!Permission::model()->hasGlobalPermission('superadmin', 'read') && !in_array($postusergroupid, getUserGroupList(null, 'simplegidarray'))) // User can not change own security (except for superadmin ?)
- {
+ if (!Permission::model()->hasGlobalPermission('superadmin', 'read') && !in_array($postusergroupid, getUserGroupList(null, 'simplegidarray'))) {
+ // User can not change own security (except for superadmin ?)
$this->getController()->error('Access denied');
}
}
diff --git a/application/controllers/admin/tokens.php b/application/controllers/admin/tokens.php
index 3c006b1f4f0..bb1ac543bb8 100644
--- a/application/controllers/admin/tokens.php
+++ b/application/controllers/admin/tokens.php
@@ -56,8 +56,7 @@ public function index($iSurveyId)
// CHECK TO SEE IF A TOKEN TABLE EXISTS FOR THIS SURVEY
- if (!$survey->hasTokensTable) //If no tokens table exists
- {
+ if (!$survey->hasTokensTable) { //If no tokens table exists
self::_newtokentable($iSurveyId);
}
else
@@ -220,8 +219,7 @@ public function bounceprocessing($iSurveyId)
}
$readbounce = imap_body($mbox, $sMessageID, FT_UID); // Put read
- if (isset($thissurvey['bounceremove']) && $thissurvey['bounceremove']) // TODO Y or just true, and a imap_delete
- {
+ if (isset($thissurvey['bounceremove']) && $thissurvey['bounceremove']) { // TODO Y or just true, and a imap_delete
$deletebounce = imap_delete($mbox, $sMessageID, FT_UID); // Put delete
}
}
@@ -432,7 +430,7 @@ public function editMultiple()
// Email
if (trim(Yii::app()->request->getPost('email', 'lskeep')) != 'lskeep') {
- $isValid = preg_match('/^([a-zA-Z0-9.!#$%&’*+\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+))(,([a-zA-Z0-9.!#$%&’*+\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)))*$/', Yii::app()->request->getPost('email'));
+ $isValid = preg_match('/^([a-zA-Z0-9.!#$%&’*+\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+))(,([a-zA-Z0-9.!#$%&’*+\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)))*$/', Yii::app()->request->getPost('email'));
if ($isValid) {
$aData['email'] = 'lskeep';
} else {
@@ -1049,8 +1047,7 @@ public function managetokenattributes($iSurveyId)
}
// CHECK TO SEE IF A TOKEN TABLE EXISTS FOR THIS SURVEY
$bTokenExists = $survey->hasTokensTable;
- if (!$bTokenExists) //If no tokens table exists
- {
+ if (!$bTokenExists) { //If no tokens table exists
self::_newtokentable($iSurveyId);
}
Yii::app()->loadHelper("surveytranslator");
@@ -1434,8 +1431,7 @@ public function email($iSurveyId, $tokenids = null)
$to[] = ($emrow['firstname']." ".$emrow['lastname']." <{$sEmailaddress}>");
}
- foreach ($emrow as $attribute => $value) // LimeExpressionManager::loadTokenInformation use $oToken->attributes
- {
+ foreach ($emrow as $attribute => $value) {
$fieldsarray['{'.strtoupper($attribute).'}'] = $value;
}
@@ -1665,8 +1661,7 @@ public function exportdialog($iSurveyId)
// CHECK TO SEE IF A TOKEN TABLE EXISTS FOR THIS SURVEY
$iSurveyId = sanitize_int($iSurveyId);
- if (!Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'export'))//EXPORT FEATURE SUBMITTED BY PIETERJAN HEYSE
- {
+ if (!Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'export')) {
Yii::app()->session['flashmessage'] = gT("You do not have permission to access this page.");
$this->getController()->redirect(array("/admin/survey/sa/view/surveyid/{$iSurveyId}"));
}
@@ -2051,8 +2046,7 @@ public function import($iSurveyId)
App()->getClientScript()->registerScriptFile(App()->getConfig('adminscripts').'tokensimport.js');
$aEncodings = aEncodingsArray();
- if (Yii::app()->request->isPostRequest) // && Yii::app()->request->getPost('subaction')=='upload')
- {
+ if (Yii::app()->request->isPostRequest) {
$sUploadCharset = Yii::app()->request->getPost('csvcharset');
if (!array_key_exists($sUploadCharset, $aEncodings))// Validate sUploadCharset
{
@@ -2077,12 +2071,10 @@ public function import($iSurveyId)
{
Yii::app()->setFlashMessage(sprintf(gT("Sorry, this file is too large. Only files up to %01.2f MB are allowed."), getMaximumFileUploadSize() / 1024 / 1024), 'error');
}
- elseif (strtolower($oFile->getExtensionName()) != 'csv')// && !in_array($oFile->getType(),$aCsvMimetypes)
- {
+ elseif (strtolower($oFile->getExtensionName()) != 'csv') {
Yii::app()->setFlashMessage(gT("Only CSV files are allowed."), 'error');
}
- elseif (!@$oFile->saveAs($sFileName)) //!@move_uploaded_file($sFileTmpName, $sFileName))
- {
+ elseif (!@$oFile->saveAs($sFileName)) {
Yii::app()->setFlashMessage(sprintf(gT("Upload file not found. Check your permissions and path (%s) for the upload directory"), $sPath), 'error');
}
else
@@ -2283,8 +2275,9 @@ public function import($iSurveyId)
{
if ($aWriteArray[$key] == "")
unset($aWriteArray[$key]);
- if (substr($value, 0, 1) == '"' && substr($value, -1) == '"')// Fix CSV quote
- $value = substr($value, 1, -1);
+ if (substr($value, 0, 1) == '"' && substr($value, -1) == '"') { // Fix CSV quote
+ $value = substr($value, 1, -1);
+ }
}
// Some default value : to be moved to Token model rules in future release ?
// But think we have to accept invalid email etc ... then use specific scenario
diff --git a/application/controllers/admin/useraction.php b/application/controllers/admin/useraction.php
index b9553f5ec17..9e6c8196662 100644
--- a/application/controllers/admin/useraction.php
+++ b/application/controllers/admin/useraction.php
@@ -192,8 +192,7 @@ public function deluser()
$postuserid = $this->_getPostOrParam("uid");
$postuser = flattenText($this->_getPostOrParam("user"));
- if ($oInitialAdmin && $oInitialAdmin->uid == $postuserid) // it's the original superadmin !!!
- {
+ if ($oInitialAdmin && $oInitialAdmin->uid == $postuserid) { // it's the original superadmin !!!
Yii::app()->setFlashMessage(gT("Initial Superadmin cannot be deleted!"), 'error');
$this->getController()->redirect(array("admin/user/sa/index"));
return;
@@ -282,8 +281,7 @@ public function deleteFinalUser($result, $transfer_surveys_to)
$postuser = flattenText(Yii::app()->request->getPost("user"));
// Never delete initial admin (with findByAttributes : found the first user without parent)
$oInitialAdmin = User::model()->findByAttributes(array('parent_id' => 0));
- if ($oInitialAdmin && $oInitialAdmin->uid == $postuserid) // it's the original superadmin !!!
- {
+ if ($oInitialAdmin && $oInitialAdmin->uid == $postuserid) { // it's the original superadmin !!!
Yii::app()->setFlashMessage(gT("Initial Superadmin cannot be deleted!"), 'error');
$this->getController()->redirect(array("admin/user/sa/index"));
}
diff --git a/application/core/LSYii_Validators.php b/application/core/LSYii_Validators.php
index f5d8fd6965e..eccfc37460d 100644
--- a/application/core/LSYii_Validators.php
+++ b/application/core/LSYii_Validators.php
@@ -44,9 +44,9 @@ class LSYii_Validators extends CValidator {
public function __construct()
{
- if (Yii::app()->getConfig('DBVersion') < 172) // Permission::model exist only after 172 DB version
+ if (Yii::app()->getConfig('DBVersion') < 172) { // Permission::model exist only after 172 DB version
return $this->xssfilter = ($this->xssfilter && Yii::app()->getConfig('filterxsshtml'));
-
+ }
$this->xssfilter = ($this->xssfilter && Yii::app()->getConfig('filterxsshtml') && !Permission::model()->hasGlobalPermission('superadmin', 'read'));
return null;
}
@@ -146,17 +146,17 @@ public function xssFilter($value)
/** Construction of new string with unfiltered EM and filtered HTML **/
$sNewValue = "";
foreach ($aValues as $key=>$aValue) {
- if ($aValue[2] == "STRING")
- $sNewValue .= $bCountIsOk ? $aFilteredValues[$key][0] : $filter->purify($aValue[0]); // If EM is broken : can throw invalid $key
- else {
+ if ($aValue[2] == "STRING") {
+ $sNewValue .= $bCountIsOk ? $aFilteredValues[$key][0] : $filter->purify($aValue[0]); // If EM is broken : can throw invalid $key
+ } else {
$sExpression = trim($aValue[0], '{}');
$sNewValue .= "{";
$aParsedExpressions = $oExpressionManager->Tokenize($sExpression, true);
foreach ($aParsedExpressions as $aParsedExpression)
{
- if ($aParsedExpression[2] == 'DQ_STRING')
- $sNewValue .= "\"".$filter->purify($aParsedExpression[0])."\""; // This disallow complex HTML construction with XSS
- elseif ($aParsedExpression[2] == 'SQ_STRING')
+ if ($aParsedExpression[2] == 'DQ_STRING') {
+ $sNewValue .= "\"".$filter->purify($aParsedExpression[0])."\""; // This disallow complex HTML construction with XSS
+ } elseif ($aParsedExpression[2] == 'SQ_STRING')
$sNewValue .= "'".$filter->purify($aParsedExpression[0])."'";
else
$sNewValue .= $aParsedExpression[0];
diff --git a/application/helpers/admin/import_helper.php b/application/helpers/admin/import_helper.php
index 4b95a01631e..1357558287a 100644
--- a/application/helpers/admin/import_helper.php
+++ b/application/helpers/admin/import_helper.php
@@ -116,7 +116,9 @@ function XMLImportGroup($sFullFilePath, $iNewSID)
}
$iOldSID = $insertdata['sid'];
$insertdata['sid'] = $iNewSID;
- if (!isset($aGIDReplacements[$insertdata['gid']]) || trim($insertdata['title']) == '') continue; // Skip questions with invalid group id
+ if (!isset($aGIDReplacements[$insertdata['gid']]) || trim($insertdata['title']) == '') { // Skip questions with invalid group id
+ continue;
+ }
$insertdata['gid'] = $aGIDReplacements[$insertdata['gid']];
$oldqid = $insertdata['qid']; unset($insertdata['qid']); // save the old qid
@@ -153,10 +155,14 @@ function XMLImportGroup($sFullFilePath, $iNewSID)
$insertdata[(string) $key] = (string) $value;
}
$insertdata['sid'] = $iNewSID;
- if (!isset($aGIDReplacements[$insertdata['gid']])) continue; // Skip questions with invalid group id
+ if (!isset($aGIDReplacements[$insertdata['gid']])) { // Skip questions with invalid group id
+ continue;
+ }
$insertdata['gid'] = $aGIDReplacements[(int) $insertdata['gid']]; ;
$oldsqid = (int) $insertdata['qid']; unset($insertdata['qid']); // save the old qid
- if (!isset($aQIDReplacements[(int) $insertdata['parent_qid']])) continue; // Skip subquestions with invalid parent_qids
+ if (!isset($aQIDReplacements[(int) $insertdata['parent_qid']])) { // Skip questions with invalid parent qid
+ continue;
+ }
$insertdata['parent_qid'] = $aQIDReplacements[(int) $insertdata['parent_qid']]; // remap the parent_qid
// now translate any links
@@ -193,7 +199,9 @@ function XMLImportGroup($sFullFilePath, $iNewSID)
foreach ($row as $key=>$value) {
$insertdata[(string) $key] = (string) $value;
}
- if (!isset($aQIDReplacements[(int) $insertdata['qid']])) continue; // Skip questions with invalid group id
+ if (!isset($aQIDReplacements[(int) $insertdata['qid']])) { // Skip questions with invalid group id
+ continue;
+ }
$insertdata['qid'] = $aQIDReplacements[(int) $insertdata['qid']]; // remap the parent_qid
@@ -215,7 +223,9 @@ function XMLImportGroup($sFullFilePath, $iNewSID)
$insertdata[(string) $key] = (string) $value;
}
unset($insertdata['qaid']);
- if (!isset($aQIDReplacements[(int) $insertdata['qid']])) continue; // Skip questions with invalid group id
+ if (!isset($aQIDReplacements[(int) $insertdata['qid']])) { // Skip questions with invalid group id
+ continue;
+ }
$insertdata['qid'] = $aQIDReplacements[(int) $insertdata['qid']]; // remap the parent_qid
@@ -245,7 +255,9 @@ function XMLImportGroup($sFullFilePath, $iNewSID)
}
$insertdata['qid'] = $aQIDReplacements[(int) $insertdata['qid']]; // remap the qid
if ($insertdata['sqid'] > 0) {
- if (!isset($aQIDReplacements[(int) $insertdata['sqid']])) continue; // If SQID is invalid skip the default value
+ if (!isset($aQIDReplacements[(int) $insertdata['sqid']])) { // Skip questions with invalid subquestion id
+ continue;
+ }
$insertdata['sqid'] = $aQIDReplacements[(int) $insertdata['sqid']]; // remap the subquestion id
}
@@ -268,16 +280,22 @@ function XMLImportGroup($sFullFilePath, $iNewSID)
if (isset($aQIDReplacements[$insertdata['qid']])) {
$insertdata['qid'] = $aQIDReplacements[$insertdata['qid']]; // remap the qid
}
- else continue; // a problem with this answer record -> don't consider
+ else { // a problem with this answer record -> don't consider
+ continue;
+ }
if (isset($aQIDReplacements[$insertdata['cqid']])) {
$insertdata['cqid'] = $aQIDReplacements[$insertdata['cqid']]; // remap the qid
}
- else continue; // a problem with this answer record -> don't consider
+ else { // a problem with this answer record -> don't consider
+ continue;
+ }
list($oldcsid, $oldcgid, $oldqidanscode) = explode("X", $insertdata["cfieldname"], 3);
- if ($oldcgid != $oldgid) // this means that the condition is in another group (so it should not have to be been exported -> skip it
+ if ($oldcgid != $oldgid) {
+ // this means that the condition is in another group (so it should not have to be been exported -> skip it
continue;
+ }
unset($insertdata["cid"]);
@@ -1284,7 +1302,9 @@ function XMLImportSurvey($sFullFilePath, $sXMLdata = NULL, $sNewSurveyName = NUL
$insertdata[(string) $key] = (string) $value;
}
$insertdata['qid'] = $aQIDReplacements[(int) $insertdata['qid']]; // remap the qid
- if (isset($aQIDReplacements[(int) $insertdata['sqid']])) $insertdata['sqid'] = $aQIDReplacements[(int) $insertdata['sqid']]; // remap the subquestion id
+ if (isset($aQIDReplacements[(int) $insertdata['sqid']])) { // remap the subquestion id
+ $insertdata['sqid'] = $aQIDReplacements[(int) $insertdata['sqid']];
+ }
if ($insertdata)
XSSFilterArray($insertdata);
// now translate any links
@@ -1308,20 +1328,26 @@ function XMLImportSurvey($sFullFilePath, $sXMLdata = NULL, $sNewSurveyName = NUL
if (isset($aQIDReplacements[$insertdata['qid']])) {
$insertdata['qid'] = $aQIDReplacements[$insertdata['qid']]; // remap the qid
}
- else continue; // a problem with this answer record -> don't consider
+ else { // a problem with this answer record -> don't consider
+ continue;
+ }
if ($insertdata['cqid'] != 0) {
if (isset($aQIDReplacements[$insertdata['cqid']]))
{
$oldcqid = $insertdata['cqid']; //Save for cfield transformation
$insertdata['cqid'] = $aQIDReplacements[$insertdata['cqid']]; // remap the qid
}
- else continue; // a problem with this answer record -> don't consider
+ else { // a problem with this answer record -> don't consider
+ continue;
+ }
list($oldcsid, $oldcgid, $oldqidanscode) = explode("X", $insertdata["cfieldname"], 3);
// replace the gid for the new one in the cfieldname(if there is no new gid in the $aGIDReplacements array it means that this condition is orphan -> error, skip this record)
- if (!isset($aGIDReplacements[$oldcgid]))
- continue;
+ if (!isset($aGIDReplacements[$oldcgid])){
+ continue;
+ }
+
}
unset($insertdata["cid"]);
@@ -1632,8 +1658,9 @@ function XMLImportResponses($sFullFilePath, $iSurveyID, $aFieldReMap = array())
if (!$oXMLReader->isEmptyElement)
{
$oXMLReader->read();
- if (in_array($sFieldname, $DestinationFields)) // some old response tables contain invalid column names due to old bugs
+ if (in_array($sFieldname, $DestinationFields)) { // some old response tables contain invalid column names due to old bugs
$aInsertData[$sFieldname] = $oXMLReader->value;
+ }
$oXMLReader->read();
} else
{
@@ -1822,15 +1849,14 @@ function CSVImportResponses($sFullFilePath, $iSurveyId, $aOptions = array())
}
if ($oSurvey) {
// First rule for id and submitdate
- if (is_int($iIdKey)) // Rule for id: only if id exists in vvimport file
- {
+ if (is_int($iIdKey)) { // Rule for id: only if id exists in vvimport file
if (!$bExistingsId) // If not exist : allways import it
{
$oSurvey->id = $aResponses[$iIdKey];
$iMaxId = ($aResponses[$iIdKey] > $iMaxId) ? $aResponses[$iIdKey] : $iMaxId;
}
- elseif ($aOptions['sExistingId'] == 'replace' || $aOptions['sExistingId'] == 'replaceanswers')// Set it depending with some options
- {
+ elseif ($aOptions['sExistingId'] == 'replace' || $aOptions['sExistingId'] == 'replaceanswers') {
+ // Set it depending with some options
$oSurvey->id = $aResponses[$iIdKey];
}
}
@@ -1879,8 +1905,8 @@ function CSVImportResponses($sFullFilePath, $iSurveyId, $aOptions = array())
$aResponsesInserted[] = $aResponses[$iIdReponsesKey];
}
}
- else // Actually can not be, leave it if we have a $oSurvey->validate() in future release
- {
+ else {
+ // Actually can not be, leave it if we have a $oSurvey->validate() in future release
$oTransaction->rollBack();
$aResponsesError[] = $aResponses[$iIdReponsesKey];
}
@@ -2171,8 +2197,7 @@ function TSVImportSurvey($sFullFilePath)
// when a multi-lang tsv-file without information on the group id/number (old style) is imported,
// we make up this information by giving a number 0..[numberofgroups-1] per language.
// the number and order of groups per language should be the same, so we can also import these files
- if ($lastglang != $glang) //reset counter on language change
- {
+ if ($lastglang != $glang) { //reset counter on language change
$iGroupcounter = 0;
}
$lastglang = $glang;
@@ -2318,8 +2343,7 @@ function TSVImportSurvey($sFullFilePath)
{
; // these are fake rows to show naming of comment and filecount fields
}
- elseif ($sqname == 'other' && $lastother == "Y") // If last question have other to Y : it's not a real SQ row
- {
+ elseif ($sqname == 'other' && $lastother == "Y") { // If last question have other to Y : it's not a real SQ row
if ($qtype == "!" || $qtype == "L")
{
// only used to set default value for 'other' in these cases
diff --git a/application/helpers/export_helper.php b/application/helpers/export_helper.php
index f64c4beadfe..af2660c38a2 100644
--- a/application/helpers/export_helper.php
+++ b/application/helpers/export_helper.php
@@ -377,7 +377,7 @@ function SPSSGetValues($field = array(), $qidattributes = null, $language) {
$answers['size'] = $size;
return $answers;
} else {
- /* Not managed (currently): url, IP, … */
+ /* Not managed (currently): url, IP, … */
return;
}
}
@@ -722,12 +722,16 @@ function buildXMLFromQuery($xmlwriter, $Query, $tagname = '', $excludes = array(
foreach ($Row as $Key=>$Value)
{
if (!isset($exclude[$Key])) {
- if (!(is_null($Value))) // If the $value is null don't output an element at all
- {
- if (is_numeric($Key[0])) $Key = '_'.$Key; // mask invalid element names with an underscore
+ if (!(is_null($Value))) { // If the $value is null don't output an element at all
+ if (is_numeric($Key[0])) {
+ // mask invalid element names with an underscore
+ $Key = '_'.$Key;
+ }
$Key = str_replace('#', '-', $Key);
- if (!$xmlwriter->startElement($Key)) safeDie('Invalid element key: '.$Key);
- // Remove invalid XML characters
+ if (!$xmlwriter->startElement($Key)) { // Remove invalid XML characters
+ safeDie('Invalid element key: '.$Key);
+ }
+
if ($Value !== '') {
$Value = str_replace(']]>', ']] >', $Value);
$xmlwriter->writeCData(preg_replace('/[^\x9\xA\xD\x20-\x{D7FF}\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF}]/u', '', $Value));
@@ -768,8 +772,7 @@ function surveyGetXMLStructure($iSurveyID, $xmlwriter, $exclude = array())
WHERE {{assessments}}.sid=$iSurveyID";
buildXMLFromQuery($xmlwriter, $query);
- if (!isset($exclude['conditions']))
- {
+ if (!isset($exclude['conditions'])) {
//Condition table
$cquery = "SELECT DISTINCT {{conditions}}.*
FROM {{conditions}}, {{questions}}
diff --git a/application/helpers/frontend_helper.php b/application/helpers/frontend_helper.php
index d877b58a17d..1d3c2bd0181 100644
--- a/application/helpers/frontend_helper.php
+++ b/application/helpers/frontend_helper.php
@@ -35,16 +35,14 @@ function loadanswers()
$oCriteria->join = "LEFT JOIN {{saved_control}} ON t.id={{saved_control}}.srid";
$oCriteria->condition = "{{saved_control}}.sid=:sid";
$aParams = array(':sid'=>$surveyid);
- if (isset($scid)) //Would only come from email : we don't need it ....
- {
+ if (isset($scid)) { //Would only come from email : we don't need it ....
$oCriteria->addCondition("{{saved_control}}.scid=:scid");
$aParams[':scid'] = $scid;
}
$oCriteria->addCondition("{{saved_control}}.identifier=:identifier");
$aParams[':identifier'] = $sLoadName;
- if (in_array(Yii::app()->db->getDriverName(), array('mssql', 'sqlsrv', 'dblib')))
- {
+ if (in_array(Yii::app()->db->getDriverName(), array('mssql', 'sqlsrv', 'dblib'))) {
// To be validated with mssql, think it's not needed
$oCriteria->addCondition("(CAST({{saved_control}}.access_code as varchar(64))=:md5_code OR CAST({{saved_control}}.access_code as varchar(64))=:sha256_code)");
} else
diff --git a/application/helpers/qanda_helper.php b/application/helpers/qanda_helper.php
index 1e5a82d7c07..ea2045d1f18 100644
--- a/application/helpers/qanda_helper.php
+++ b/application/helpers/qanda_helper.php
@@ -268,8 +268,7 @@ function retrieveAnswers($ia)
}
- if (isset($values)) //Break apart $values array returned from switch
- {
+ if (isset($values)) { //Break apart $values array returned from switch
//$answer is the html code to be printed
//$inputnames is an array containing the names of each input field
list($answer, $inputnames) = $values;
@@ -342,8 +341,7 @@ function retrieveAnswers($ia)
// START: