Skip to content

Commit

Permalink
Merge branch 'MDL-74341' of https://github.com/paulholden/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
snake committed Apr 7, 2022
2 parents 748608b + c00a97c commit 7310711
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions reportbuilder/classes/form/audience.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ protected function get_context_for_dynamic_submission(): context {
protected function check_access_for_dynamic_submission(): void {
$audience = $this->get_audience();

$report = $audience->get_persistent()->get_report();
permission::require_can_edit_report($report);

// Check whether we are able to add/edit the current audience.
$audience->get_persistent()->get('id') === 0
? $audience->require_user_can_add()
Expand All @@ -121,10 +124,6 @@ public function process_dynamic_submission() {
$formdata = $this->get_data();
$audience = $this->get_audience();

// Check permissions.
$report = manager::get_report_from_id($formdata->reportid);
permission::require_can_edit_report($report->get_report_persistent());

$configdata = $audience::retrieve_configdata($formdata);
if (!$formdata->id) {
// New audience.
Expand Down
4 changes: 2 additions & 2 deletions reportbuilder/classes/local/audiences/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public function get_persistent(): audience {
*
* @throws report_access_exception
*/
public function require_user_can_add(): void {
final public function require_user_can_add(): void {
if (!$this->user_can_add()) {
throw new report_access_exception('errorreportedit');
}
Expand All @@ -265,7 +265,7 @@ public function require_user_can_add(): void {
*
* @throws report_access_exception
*/
public function require_user_can_edit(): void {
final public function require_user_can_edit(): void {
if (!$this->user_can_edit()) {
throw new report_access_exception('errorreportedit');
}
Expand Down

0 comments on commit 7310711

Please sign in to comment.