Navigation Menu

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: Add permission check for edit question.
  • Loading branch information
olleharstedt committed Apr 15, 2016
1 parent 88f3073 commit ec54b9f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion application/controllers/admin/questiongroups.php
Expand Up @@ -391,7 +391,7 @@ public function edit($surveyid, $gid)
$gid = sanitize_int($gid);
$aViewUrls = $aData = array();

if (Permission::model()->hasSurveyPermission($surveyid, 'surveycontent', 'read'))
if (Permission::model()->hasSurveyPermission($surveyid, 'surveycontent', 'update'))
{
Yii::app()->session['FileManagerContext'] = "edit:group:{$surveyid}";

Expand Down
13 changes: 13 additions & 0 deletions application/controllers/admin/questions.php
Expand Up @@ -861,6 +861,12 @@ public function _editsubquestion($surveyid, $gid, $qid)
*/
public function newquestion($surveyid)
{
if (!Permission::model()->hasSurveyPermission($surveyid,'surveycontent','create'))
{
Yii::app()->user->setFlash('error', gT("Access denied"));
$this->getController()->redirect(Yii::app()->request->urlReferrer);
}

Yii::app()->loadHelper('admin/htmleditor');
$surveyid = $iSurveyID = $aData['surveyid'] = sanitize_int($surveyid);
App()->getClientScript()->registerPackage('qTip2');
Expand Down Expand Up @@ -1031,6 +1037,13 @@ public function index($sa, $surveyid, $gid, $qid=null)
// Prepare selector Mode TODO: with and without image
if (!$adding)
{
// Abort if user lacks edit permission
if (!Permission::model()->hasSurveyPermission($surveyid,'surveycontent','edit'))
{
Yii::app()->user->setFlash('error', gT("Access denied"));
$this->getController()->redirect(Yii::app()->request->urlReferrer);
}

Yii::app()->session['FileManagerContext'] = "edit:question:{$surveyid}";
$aData['display']['menu_bars']['qid_action'] = 'editquestion';

Expand Down

0 comments on commit ec54b9f

Please sign in to comment.