Skip to content

Commit

Permalink
Fixed issue #10829: Survey admins presented with inappropriate control
Browse files Browse the repository at this point in the history
buttons

Dev: Hide tools menu if no items are permitted.
  • Loading branch information
olleharstedt committed Apr 15, 2016
1 parent f9cefc7 commit 65d409f
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 93 deletions.
12 changes: 9 additions & 3 deletions application/core/Survey_Common_Action.php
Expand Up @@ -764,7 +764,7 @@ function _surveybar($aData)
// Survey permission item
$aData['surveysecurity'] = Permission::model()->hasSurveyPermission($iSurveyID, 'surveysecurity', 'read');
// CHANGE QUESTION GROUP ORDER BUTTON
$aData['surveycontent'] = Permission::model()->hasSurveyPermission($iSurveyID, 'surveycontent', 'read');
$aData['surveycontentread'] = Permission::model()->hasSurveyPermission($iSurveyID, 'surveycontent', 'read');
$aData['groupsum'] = (getGroupSum($iSurveyID, $surveyinfo['language']) > 1);
// SET SURVEY QUOTAS BUTTON
$aData['quotas'] = Permission::model()->hasSurveyPermission($iSurveyID, 'quotas', 'read');
Expand All @@ -784,13 +784,19 @@ function _surveybar($aData)
// Only show survey properties menu if at least one item is permitted
$aData['showSurveyPropertiesMenu'] =
$aData['surveylocale']
$aData['surveylocale']
|| $aData['surveysettings']
|| $aData['surveysecurity']
|| $aData['surveycontent']
|| $aData['surveycontentread']
|| $aData['quotas']
|| $aData['assessments'];

// Only show tools menu if at least one item is permitted
$aData['showToolsMenu'] =
$aData['surveydelete']
|| $aData['surveytranslate']
|| Permission::model()->hasSurveyPermission($iSurveyID, 'surveycontent', 'update');

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

$aData['surveycontent'] = Permission::model()->hasSurveyPermission($iSurveyID, 'surveycontent', 'update');
Expand Down
182 changes: 92 additions & 90 deletions application/views/admin/survey/surveybar_view.php
Expand Up @@ -205,7 +205,7 @@
</li>
<?php endif; ?>

<?php if($surveycontent): ?>
<?php if($surveycontentread): ?>
<!-- survey content -->

<?php if($onelanguage): ?>
Expand All @@ -225,17 +225,17 @@

<!-- Survey logic file -->
<li class="dropdown-header"><?php eT("Survey logic file");?></li>
<?php foreach ($languagelist as $tmp_lang): ?>
<!-- Languages -->

<li>
<a href='<?php echo $this->createUrl("admin/expressions/sa/survey_logic_file/sid/$surveyid/lang/$tmp_lang");?>'>
<span class="icon-expressionmanagercheck" ></span>
<?php echo getLanguageNameFromCode($tmp_lang,false);?>
</a>
</li>
<?php endforeach; ?>
<?php endif; ?>
<?php foreach ($languagelist as $tmp_lang): ?>
<!-- Languages -->

<li>
<a href='<?php echo $this->createUrl("admin/expressions/sa/survey_logic_file/sid/$surveyid/lang/$tmp_lang");?>'>
<span class="icon-expressionmanagercheck" ></span>
<?php echo getLanguageNameFromCode($tmp_lang,false);?>
</a>
</li>
<?php endforeach; ?>
<?php endif; ?>
<?php endif; ?>
</ul>
</div>
Expand All @@ -248,100 +248,102 @@


<!-- TOOLS -->
<div class="btn-group hidden-xs">
<?php if ($showToolsMenu): ?>
<div class="btn-group hidden-xs">

<!-- Main button dropdown -->
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="icon-tools" ></span>
<?php eT('Tools');?><span class="caret"></span>
</button>

<!-- dropdown -->
<ul class="dropdown-menu">
<?php if ($surveydelete): ?>

<!-- Delete survey -->
<li>
<a href="<?php echo $this->createUrl("admin/survey/sa/delete/surveyid/{$surveyid}"); ?>">
<span class="glyphicon glyphicon-trash" ></span>
<?php eT("Delete survey");?>
</a>
</li>
<?php endif; ?>

<?php if ($surveytranslate): ?>
<!-- surveytranslate -->
<!-- Main button dropdown -->
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="icon-tools" ></span>
<?php eT('Tools');?><span class="caret"></span>
</button>

<?php if($hasadditionallanguages): ?>
<!-- dropdown -->
<ul class="dropdown-menu">
<?php if ($surveydelete): ?>

<!-- Quick-translation -->
<li>
<a href="<?php echo $this->createUrl("admin/translate/sa/index/surveyid/{$surveyid}");?>">
<span class="fa fa-language" ></span>
<?php eT("Quick-translation");?>
</a>
</li>
<!-- Delete survey -->
<li>
<a href="<?php echo $this->createUrl("admin/survey/sa/delete/surveyid/{$surveyid}"); ?>">
<span class="glyphicon glyphicon-trash" ></span>
<?php eT("Delete survey");?>
</a>
</li>
<?php endif; ?>

<?php else: ?>
<?php if ($surveytranslate): ?>
<!-- surveytranslate -->

<!-- Quick-translation disabled -->
<li>
<a href="#" onclick="alert('<?php eT("Currently there are no additional languages configured for this survey.", "js");?>');" >
<span class="fa fa-language" ></span>
<?php eT("Quick-translation");?>
</a>
</li>
<?php endif; ?>
<?php endif; ?>
<?php if($hasadditionallanguages): ?>

<?php if (Permission::model()->hasSurveyPermission($surveyid,'surveycontent','update')): ?>
<li>
<?php if ($conditionscount>0):?>
<!-- Quick-translation -->
<li>
<a href="<?php echo $this->createUrl("admin/translate/sa/index/surveyid/{$surveyid}");?>">
<span class="fa fa-language" ></span>
<?php eT("Quick-translation");?>
</a>
</li>

<!-- condition -->
<a href="<?php echo $this->createUrl("/admin/conditions/sa/index/subaction/resetsurveylogic/surveyid/{$surveyid}"); ?>">
<span class="icon-resetsurveylogic" ></span>
<?php eT("Reset conditions");?>
</a>
<?php else: ?>

<!-- condition disabled -->
<a href="#" onclick="alert('<?php eT("Currently there are no conditions configured for this survey.", "js"); ?>');" >
<span class="icon-resetsurveylogic" ></span>
<?php eT("Reset conditions");?>
</a>
<!-- Quick-translation disabled -->
<li>
<a href="#" onclick="alert('<?php eT("Currently there are no additional languages configured for this survey.", "js");?>');" >
<span class="fa fa-language" ></span>
<?php eT("Quick-translation");?>
</a>
</li>
<?php endif; ?>
</li>
<?php endif; ?>

<?php if(!$activated): ?>
<?php if (Permission::model()->hasSurveyPermission($surveyid,'surveycontent','update')): ?>
<li>
<li role="separator" class="divider"></li>

<!-- Regenerate question codes -->
<li class="dropdown-header">
<?php eT("Regenerate question codes");?>
</li>
<?php if ($conditionscount>0):?>

<!-- Straight -->
<li>
<a href="<?php echo $this->createUrl("/admin/survey/regenquestioncodes/surveyid/{$surveyid}/subaction/straight"); ?>">
<span class="icon-resetsurveylogic" ></span>
<?php eT("Straight");?>
</a>
</li>
<!-- condition -->
<a href="<?php echo $this->createUrl("/admin/conditions/sa/index/subaction/resetsurveylogic/surveyid/{$surveyid}"); ?>">
<span class="icon-resetsurveylogic" ></span>
<?php eT("Reset conditions");?>
</a>
<?php else: ?>

<!-- By question group -->
<li>
<a href="<?php echo $this->createUrl("/admin/survey/regenquestioncodes/surveyid/{$surveyid}/subaction/bygroup"); ?>">
<span class="icon-resetsurveylogic" ></span>
<?php eT("By question group");?>
</a>
</li>
<!-- condition disabled -->
<a href="#" onclick="alert('<?php eT("Currently there are no conditions configured for this survey.", "js"); ?>');" >
<span class="icon-resetsurveylogic" ></span>
<?php eT("Reset conditions");?>
</a>
<?php endif; ?>
</li>

<?php if(!$activated): ?>
<li>
<li role="separator" class="divider"></li>

<!-- Regenerate question codes -->
<li class="dropdown-header">
<?php eT("Regenerate question codes");?>
</li>

<!-- Straight -->
<li>
<a href="<?php echo $this->createUrl("/admin/survey/regenquestioncodes/surveyid/{$surveyid}/subaction/straight"); ?>">
<span class="icon-resetsurveylogic" ></span>
<?php eT("Straight");?>
</a>
</li>

<!-- By question group -->
<li>
<a href="<?php echo $this->createUrl("/admin/survey/regenquestioncodes/surveyid/{$surveyid}/subaction/bygroup"); ?>">
<span class="icon-resetsurveylogic" ></span>
<?php eT("By question group");?>
</a>
</li>
</li>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
</ul>
</div>
</ul>
</div>
<?php endif; ?>


<!-- Display / Export -->
Expand Down

0 comments on commit 65d409f

Please sign in to comment.