Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #87 Do not display content if a user does not have permission #93

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions block_massaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ public function get_content(): stdClass {
$this->content->footer = '';

if ($this->page->user_is_editing()) {
$blockcontext = context_block::instance($this->instance->id);
if (!has_capability('block/massaction:use', $blockcontext)) {
$this->content->text = get_string('nopermissions', 'error', get_string('massaction:use', 'block_massaction'));
return $this->content;

Choose a reason for hiding this comment

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

Wondering why we need to display anything at all? IMHO we don't need to display content at all if user don't have permissions. But let's leave it up to the maintainer to decide.

Copy link
Author

Choose a reason for hiding this comment

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

If a user adds the block without use permission, I think we need to show something for the block.
It's probably better not to allow to add the block if user doesn't have use permission.

I'm leaving this as I updated.
Please let me know which solution is better.

Choose a reason for hiding this comment

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

Block can be already in a course when a user with caps to see the block, but without caps to do anything with mass actions accessing a course.

Copy link
Owner

Choose a reason for hiding this comment

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

I think the best method is to show the "No permission" message. I could see it being confusing if a user added the block but didn't see the block. They would probably think that the block wasn't added correctly. For as rare as this case would probably be I think I can live with it.

}

$applicableformatkey = 'course-view-' . $COURSE->format;
$iscoursecompatible = in_array($applicableformatkey, array_keys($this->applicable_formats()))
Expand Down