Skip to content

Commit

Permalink
Dev Fixed Scrutinizer issues
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Dec 11, 2017
1 parent 55b552c commit 117e5e4
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 32 deletions.
3 changes: 1 addition & 2 deletions application/core/LSYii_Locale.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ class LSYii_Locale extends CLocale
* Converts a locale ID to its canonical form.
* In canonical form, a locale ID consists of only underscores and lower-case letters.
* @param string $id the locale ID to be converted
* @return string the locale ID in canonical form
* @return Clocale The locale ID in canonical form
*/

public static function getInstance($id)
{
// Fix up the LimeSurvey language code for Yii
Expand Down
59 changes: 30 additions & 29 deletions application/core/Survey_Common_Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public function renderInternal($_viewFile_, $_data_ = null, $_return_ = false)
*
* @param string $sAction
* @param array $aViewUrls
* @param array|null $aData
* @param array $aData
* @return string
*/
private function renderCentralContents($sAction, $aViewUrls, $aData = [])
Expand Down Expand Up @@ -312,7 +312,7 @@ private function renderCentralContents($sAction, $aViewUrls, $aData = [])
* Comments starting with //// indicate how it should work in the future
*
* @param string $sAction Current action, the folder to fetch views from
* @param string|array $aViewUrls View url(s)
* @param array $aViewUrls View url(s)
* @param array $aData Data to be passed on. Optional.
*/
protected function _renderWrappedTemplate($sAction = '', $aViewUrls = array(), $aData = array())
Expand Down Expand Up @@ -361,7 +361,7 @@ protected function _updatenotification()
/**
* Display notifications
*/
function _notifications()
private function _notifications()
{
$aMessage = App()->session['arrayNotificationMessages'];
unset(App()->session['arrayNotificationMessages']);
Expand All @@ -372,7 +372,7 @@ function _notifications()
* Survey summary
* @param array $aData
*/
function _nsurveysummary($aData)
private function _nsurveysummary($aData)
{
if (isset($aData['display']['surveysummary'])) {
if ((empty($aData['display']['menu_bars']['surveysummary']) || !is_string($aData['display']['menu_bars']['surveysummary'])) && !empty($aData['gid'])) {
Expand All @@ -386,7 +386,7 @@ function _nsurveysummary($aData)
* Header
* @param array $aData
*/
function _showHeaders($aData)
private function _showHeaders($aData)
{
if (!isset($aData['display']['header']) || $aData['display']['header'] !== false) {
// Send HTTP header
Expand All @@ -395,7 +395,6 @@ function _showHeaders($aData)
}
}


/**
* _showadminmenu() function returns html text for the administration button bar
*
Expand Down Expand Up @@ -460,14 +459,14 @@ public function _showadminmenu($aData)
return null;
}

function _titlebar($aData)
private function _titlebar($aData)
{
if (isset($aData['title_bar'])) {
$this->getController()->renderPartial("/admin/super/title_bar", $aData);
}
}

function _tokenbar($aData)
private function _tokenbar($aData)
{
if (isset($aData['token_bar'])) {

Expand All @@ -488,7 +487,7 @@ function _tokenbar($aData)
* @since 2014-09-30
* @author Olle Haerstedt
*/
function _organizequestionbar($aData)
private function _organizequestionbar($aData)
{
if (isset($aData['organizebar'])) {
if (isset($aData['questionbar']['closebutton']['url'])) {
Expand Down Expand Up @@ -543,7 +542,7 @@ public function _questionbar($aData)

$qrrow = $qrrow->attributes;
$aData['languagelist'] = $oSurvey->getAllLanguages();
$aData['qtypes'] = $qtypes = getQuestionTypeList('', 'array');
$aData['qtypes'] = getQuestionTypeList('', 'array');
$aData['action'] = $action;
$aData['surveyid'] = $iSurveyID;
$aData['qid'] = $qid;
Expand Down Expand Up @@ -573,8 +572,7 @@ public function _questionbar($aData)
$aData['questionbar']['closebutton']['url'] = Yii::app()->request->getUrlReferrer(Yii::app()->createUrl($sAlternativeUrl));
}
$questionsummary .= $this->getController()->renderPartial('/admin/survey/Question/questionbar_view', $aData, true);
$finaldata['display'] = $questionsummary;
$this->getController()->renderPartial('/survey_view', $finaldata);
$this->getController()->renderPartial('/survey_view', ['display'=>$questionsummary]);
} else {
Yii::app()->session['flashmessage'] = gT("Invalid survey ID");
$this->getController()->redirect(array("admin/index"));
Expand Down Expand Up @@ -732,7 +730,7 @@ function _surveybar($aData)
|| Permission::model()->hasSurveyPermission($iSurveyID, 'surveycontent', 'update')
|| !is_null($extraToolsMenuItems);

$iConditionCount = Condition::model()->with(Array('questions'=>array('condition'=>'sid ='.$iSurveyID)))->count();
$iConditionCount = Condition::model()->with(array('questions'=>array('condition'=>'sid ='.$iSurveyID)))->count();

$aData['surveycontent'] = Permission::model()->hasSurveyPermission($iSurveyID, 'surveycontent', 'update');
$aData['conditionscount'] = ($iConditionCount > 0);
Expand Down Expand Up @@ -765,7 +763,6 @@ function _surveybar($aData)
$aData['permission'] = true;
} else {
$aData['gid'] = $gid = null;
$qid = null;
$aData['permission'] = false;
}

Expand All @@ -775,9 +772,9 @@ function _surveybar($aData)
$aData['groups'] = "<option>".gT("None")."</option>";
}

$aData['GidPrev'] = $GidPrev = getGidPrevious($iSurveyID, $gid);
$aData['GidPrev'] = getGidPrevious($iSurveyID, $gid);

$aData['GidNext'] = $GidNext = getGidNext($iSurveyID, $gid);
$aData['GidNext'] = getGidNext($iSurveyID, $gid);
$aData['iIconSize'] = Yii::app()->getConfig('adminthemeiconsize');

if (isset($aData['surveybar']['closebutton']['url'])) {
Expand All @@ -791,12 +788,11 @@ function _surveybar($aData)
}
}


/**
* Show side menu for survey view
* @param array $aData all the needed data
*/
function _surveysidemenu($aData)
private function _surveysidemenu($aData)
{
$iSurveyID = $aData['surveyid'];

Expand All @@ -809,8 +805,7 @@ function _surveysidemenu($aData)
if (Permission::model()->hasSurveyPermission($iSurveyID, 'surveycontent', 'read')) {
$aData['permission'] = true;
} else {
$aData['gid'] = $gid = null;
$qid = null;
$aData['gid'] = null;
$aData['permission'] = false;
}

Expand Down Expand Up @@ -933,17 +928,17 @@ private function _listquestions($aData)

// Global filter
if (isset($_GET['Question'])) {
$model->attributes = $_GET['Question'];
$model->setAttributes($_GET['Question'],false);
}

// Filter group
if (isset($_GET['gid'])) {
$model->gid = $_GET['gid'];
$model->gid = $_GET['gid'];
}

// Set number of page
if (isset($_GET['pageSize'])) {
Yii::app()->user->setState('pageSize', (int) $_GET['pageSize']);
Yii::app()->user->setState('pageSize', (int) $_GET['pageSize']);
}

// We filter the current survey id
Expand Down Expand Up @@ -1188,28 +1183,35 @@ protected function _filterImportedResources($extractdir, $destdir)
}

$dh = opendir($extractdir);

if (!$dh)
{
$aErrorFilesInfo[] = array(
"filename" => '',
"status" => gT("Extracted files not found - maybe a permission problem?")
);
return array($aImportedFilesInfo, $aErrorFilesInfo);
}
while ($direntry = readdir($dh)) {
if ($direntry != "." && $direntry != "..") {
if (is_file($extractdir."/".$direntry)) {
// is a file
$extfile = substr(strrchr($direntry, '.'), 1);
$extfile = (string)substr(strrchr($direntry, '.'), 1);
if (!(stripos(','.Yii::app()->getConfig('allowedresourcesuploads').',', ','.$extfile.',') === false)) {
// Extension allowed
if (!copy($extractdir."/".$direntry, $destdir."/".$direntry)) {
$aErrorFilesInfo[] = Array(
$aErrorFilesInfo[] = array(
"filename" => $direntry,
"status" => gT("Copy failed")
);
} else {
$aImportedFilesInfo[] = Array(
$aImportedFilesInfo[] = array(
"filename" => $direntry,
"status" => gT("OK")
);
}
} else {
// Extension forbidden
$aErrorFilesInfo[] = Array(
$aErrorFilesInfo[] = array(
"filename" => $direntry,
"status" => gT("Forbidden Extension")
);
Expand All @@ -1222,7 +1224,6 @@ protected function _filterImportedResources($extractdir, $destdir)
return array($aImportedFilesInfo, $aErrorFilesInfo);
}


/**
* Creates a temporary directory
*
Expand Down
2 changes: 1 addition & 1 deletion application/helpers/viewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public static function putSeparator($sString, $separator)
* @param boolean $bFlat : flattenText or not : completely flat (not like flattenText from common_helper)
* @param integer $iAbbreviated : max string text (if true : allways flat), 0 or false : don't abbreviated
* @param string $sEllipsis if abbreviated : the char to put at end (or middle)
* @param integer $fPosition if abbreviated position to split (in % : 0 to 1)
* @param float $fPosition if abbreviated position to split (in % : 0 to 1)
*
* @return string
*/
Expand Down
6 changes: 6 additions & 0 deletions application/models/SurveysGroups.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* @property string $created
* @property string $modified
* @property integer $created_by
* @property object $parentgroup
* @property boolean $hasSurveys
*/
class SurveysGroups extends LSActiveRecord
{
Expand Down Expand Up @@ -205,6 +207,10 @@ public function getParentTitle()
}
}

/**
* Returns true if survey group has surveys
* @return boolean
*/
public function getHasSurveys()
{
$nbSurvey = Survey::model()->countByAttributes(array("gsid"=>$this->gsid));
Expand Down

0 comments on commit 117e5e4

Please sign in to comment.