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

Conversation

TomoTsuyuki
Copy link

Show permission error if the user doesn't have permission.

image

$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.

@TomoTsuyuki TomoTsuyuki force-pushed the issue87-hide-block-by-capability branch from 9cd924e to 3ac512a Compare October 25, 2023 02:18
@TomoTsuyuki
Copy link
Author

Rebased with the latest master branch.

@TomoTsuyuki TomoTsuyuki force-pushed the issue87-hide-block-by-capability branch from 3ac512a to 7e126bb Compare November 21, 2023 02:17
@Syxton Syxton merged commit 003273a into Syxton:master Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants