Skip to content

Commit

Permalink
Fixed issue #14312: Importing participants from CSV is not possible f…
Browse files Browse the repository at this point in the history
…or user with survey/create global permission
  • Loading branch information
dominikvitt committed Dec 20, 2018
1 parent d6bc2c5 commit 2dc64f3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions application/controllers/admin/tokens.php
Expand Up @@ -1675,7 +1675,7 @@ public function importldap($iSurveyId)
$iSurveyId = (int) $iSurveyId;
$survey = Survey::model()->findByPk($iSurveyId);
$aData = array();
if (!Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'import')) {
if (!(Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'import') || Permission::model()->hasGlobalPermission('surveys', 'update'))) {
Yii::app()->session['flashmessage'] = gT("You do not have permission to access this page.");
$this->getController()->redirect(array("/admin/survey/sa/view/surveyid/{$iSurveyId}"));
}
Expand Down Expand Up @@ -1918,7 +1918,7 @@ public function import($iSurveyId)
$aData = array();
$iSurveyId = (int) $iSurveyId;
$survey = Survey::model()->findByPk($iSurveyId);
if (!Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'import')) {
if (!(Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'import') || Permission::model()->hasGlobalPermission('surveys', 'update'))) {
Yii::app()->session['flashmessage'] = gT("You do not have permission to access this page.");
$this->getController()->redirect(array("/admin/survey/sa/view/surveyid/{$iSurveyId}"));
}
Expand Down
6 changes: 3 additions & 3 deletions application/views/admin/token/token_bar.php
Expand Up @@ -14,7 +14,7 @@
<?php if( isset($token_bar['buttons']['view']) ): ?>

<!-- Display tokens -->
<?php if (Permission::model()->hasSurveyPermission($oSurvey->sid, 'tokens', 'read')): ?>
<?php if (Permission::model()->hasSurveyPermission($oSurvey->sid, 'tokens', 'read') || Permission::model()->hasGlobalPermission('surveys', 'update')): ?>
<a class="btn btn-default pjax" href='<?php echo $this->createUrl("admin/tokens/sa/browse/surveyid/$oSurvey->sid"); ?>' role="button">
<span class="fa fa-list-alt text-success"></span>
<?php eT("Display participants"); ?>
Expand All @@ -30,7 +30,7 @@

<!-- Add new token entry -->
<ul class="dropdown-menu">
<?php if (Permission::model()->hasSurveyPermission($oSurvey->sid, 'tokens', 'create')): ?>
<?php if (Permission::model()->hasSurveyPermission($oSurvey->sid, 'tokens', 'create') || Permission::model()->hasGlobalPermission('surveys', 'update')): ?>
<li>
<a class="pjax" href="<?php echo $this->createUrl("admin/tokens/sa/addnew/surveyid/$oSurvey->sid"); ?>" >
<span class="icon-add"></span>
Expand All @@ -48,7 +48,7 @@
<?php endif; ?>

<!-- Import tokens -->
<?php if (Permission::model()->hasSurveyPermission($oSurvey->sid, 'tokens', 'import')): ?>
<?php if (Permission::model()->hasSurveyPermission($oSurvey->sid, 'tokens', 'import') || Permission::model()->hasGlobalPermission('surveys', 'update')): ?>
<li role="separator" class="divider"></li>
<li>
<small><?php eT("Import participants from:"); ?></small>
Expand Down

4 comments on commit 2dc64f3

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point of view:

  1. Must be fixed in Permission::model :
    if ($this->hasGlobalPermission('surveys', 'update', $iUserID) && $sPermission == 'token' && ($sCRUD == 'import' || $sCRUD == 'export')) {
  2. Here : fixed with GUI but not with remote_control.

In fact current why

if ($this->hasGlobalPermission('surveys', 'update', $iUserID) && $sPermission == 'token' && ($sCRUD == 'import' || $sCRUD == 'export')) {
didn't work like attended ?

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better fix :

$sCRUD = 'update';

$sGlobalCRUD == 'update'

this fix this issue : 70c169d

@dominikvitt
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Case here is different, user doesn't have survey permissions, only global permissions.

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No,

Exactly THIS case :

        if ($this->hasGlobalPermission('surveys', 'update', $iUserID) && $sPermission == 'token' && ($sCRUD == 'import' || $sCRUD == 'export')) {
            $sCRUD = 'update';
        }

hasGlobalPermission , surveys

Please sign in to comment.