View Issue Details

IDProjectCategoryView StatusLast Update
19275DevelopmentOtherpublic2026-11-20 17:11
ReporterDenisChenu Assigned To 
PrioritynoneSeverityminor 
Status acknowledgedResolutionopen 
Summary19275: Create function in model with relation to Surevy to check Permission
Description

We have a lot of model in relation to a specific survey
It can be great to have a way to check permission on Survey (parent) directly in model

Steps To Reproduce

Steps to reproduce

See : 19252: User should not be able to read and edit the survey quota of other user. (https://bugs.limesurvey.org/view.php?id=19252)

Expected result

Can check directly Quota::model()->findByPk()->Permission('update')

Actual result

Create the system in controiller

TagsNo tags attached.

Users monitoring this issue

There are no users monitoring this issue.

Activities

DenisChenu

DenisChenu

2023-11-23 16:51

developer   ~78692

And idea :

  1. Question->checkPermission check permission on Survey/content
  2. Questioni10n->checkPermission check permission on Question
  3. Answer->checkPermission check permission on Survey/content (or Question ? )
    etc …

A new event is added to model->checkPermission can be interesting
New event of existing event, but with model == "Question"

c_schmitz

c_schmitz

2026-11-20 17:11

administrator   ~87846

Checked against current master (7.x):

  • The bug behind this request (#19252) is fixed. QuotasController loads the quota first (getQuotaWithPermission()) and takes the survey ID from the quota, not from the request.
  • PermissionInterface / PermissionTrait exist, but only Survey, SurveysGroups, SurveysInGroup and LabelSet implement them. No survey child model has a permission method yet.
  • Models with a survey relation that could get one: Question, QuestionGroup, Quota, QuotaMember, Response, SurveyLanguageSetting, Surveymenu, SurveyURLParameter, Token. Answer, QuestionL10n and QuotaLanguageSetting have no direct relation and would go through their parent.
  • Possible approach: one trait that delegates to $this->survey->hasPermission(<permission name of the model>, $crud). Each model declares its permission name (quotas, surveycontent, tokens, responses, ...). This needs a new method name, because PermissionInterface::hasPermission() expects the permission name as first parameter.
  • No new event is needed for the basic case: the delegation ends in Permission::hasPermission(), which already fires beforeHasPermission. That event does not know which child model was checked, though.
  • The change is backward compatible, so it can target develop-minor. QuotasController is a good first consumer, other controllers can follow step by step.

Issue History

Date Modified Username Field Change
2023-11-23 16:36 DenisChenu New Issue
2023-11-23 16:51 DenisChenu Note Added: 78692
2023-11-23 16:51 DenisChenu Bug heat 0 => 2
2026-11-19 22:50 c_schmitz Status new => acknowledged
2026-11-20 10:33 c_schmitz Category Security => (No Category)
2026-11-20 17:11 c_schmitz Project Bug reports => Development
2026-11-20 17:11 c_schmitz Category (No Category) => Other
2026-11-20 17:11 c_schmitz Note Added: 87846