Skip to content

Commit

Permalink
Revert "Fixed issue #09571: Permission Survey : global Permission are…
Browse files Browse the repository at this point in the history
… not tested"

This reverts commit c36267d.
Must review some behaviour
  • Loading branch information
Shnoulle committed Mar 18, 2015
1 parent c36267d commit f74e006
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion application/controllers/admin/surveyadmin.php
Expand Up @@ -575,7 +575,7 @@ public function getSurveys_json()
$dateformatdetails = getDateFormatData(Yii::app()->session['dateformat']);

$oSurvey = new Survey;
if (!Permission::model()->hasGlobalPermission('surveys','read'))
if (!Permission::model()->hasGlobalPermission('superadmin','read'))
$oSurvey->permission(Yii::app()->user->getId());

$aSurveys = $oSurvey->with(array('languagesettings'=>array('condition'=>'surveyls_language=language'), 'owner'))->findAll();
Expand Down
4 changes: 2 additions & 2 deletions application/helpers/common_helper.php
Expand Up @@ -135,7 +135,7 @@ function getSurveyList($returnarray=false, $surveyid=false)

if(is_null($cached)) {
$args = array('order'=>'surveyls_title');
if (!Permission::model()->hasGlobalPermission('surveys','read'))
if (!Permission::model()->hasGlobalPermission('superadmin','read'))
{
$surveyidresult = Survey::model()->permission(Yii::app()->user->getId())->with('defaultlanguage')->findAll($args);
} else {
Expand Down Expand Up @@ -7589,7 +7589,7 @@ function getSerialClass($sSerial) {
$aTypes = array('s' => 'string', 'a' => 'array', 'b' => 'bool', 'i' => 'int', 'd' => 'float', 'N;' => 'NULL');

$aParts = explode(':', $sSerial, 4);
return isset($aTypes[$aParts[0]]) ? $aTypes[$aParts[0]] : ( isset($aParts[2]) ? trim($aParts[2], '"') : null);
return isset($aTypes[$aParts[0]]) ? $aTypes[$aParts[0]] : trim($aParts[2], '"');
}

// Closing PHP tag intentionally omitted - yes, it is okay
Expand Down
7 changes: 4 additions & 3 deletions application/models/Permission.php
Expand Up @@ -491,6 +491,7 @@ function hasPermission($iEntityID, $sEntityName, $sPermission, $sCRUD, $iUserID=
// If you own a survey you have access to the whole survey
if ($iUserID==$aSurveyInfo['owner_id']) return true;
}

// Check if superadmin and cache it
if (!isset($aPermissionCache[0]['global'][$iUserID]['superadmin']['read_p']))
{
Expand Down Expand Up @@ -548,8 +549,8 @@ function hasGlobalPermission($sPermission, $sCRUD, $iUserID=null)
*/
function hasSurveyPermission($iSurveyID, $sPermission, $sCRUD, $iUserID=null)
{
return ($this->hasGlobalPermission('surveys',$sCRUD,$iUserID) || $this->hasPermission($iSurveyID, 'survey', $sPermission, $sCRUD, $iUserID));
}
return $this->hasPermission($iSurveyID, 'survey', $sPermission, $sCRUD, $iUserID);
}

/**
* Returns true if a user has permission to use a certain template
Expand All @@ -560,7 +561,7 @@ function hasSurveyPermission($iSurveyID, $sPermission, $sCRUD, $iUserID=null)
*/
function hasTemplatePermission($sTemplateName, $sCRUD='read', $iUserID=null)
{
return ($this->hasGlobalPermission('templates',$sCRUD,$iUserID) || $this->hasPermission(0, 'template', $sTemplateName, $sCRUD, $iUserID));
return $this->hasPermission(0, 'template', $sTemplateName, $sCRUD, $iUserID);
}

/**
Expand Down

0 comments on commit f74e006

Please sign in to comment.