Unanticipated User Role setting causes error
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 38/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- php
- Domain
- authorization, backend
Research direction
Start in CommentingPlugin::showComments and compare views/public/comments.php with the proposed views/public/commentingHeader.php. Trace the role checks for viewing and adding comments, then verify that a role allowed to comment but not view comments still receives the label, flash message, and comment form without an error.
Written by the indexing model from the issue text.
Description
I came across an issue which gets triggered by the scenario that a certain User Role is able to make a comment, but not allowed to view them. In this case the $view variable along with $view->addHelperPath is not set since this is currently dependent on the ability to view comments. Also in this scenario the Label as well as the flash message does not get output, since they currently reside in views/public/comments.php, which gets bypassed.
To fix the issue, I updated the showComments function in CommentingPlugin to the following:
public static function showComments($args = array())
{
echo "<div id='comments-container'>";
// presume we will need the view in any case
if(isset($args['view'])) {
$view = $args['view'];
} else {
$view = get_view();
}
$view->addHelperPath(COMMENTING_PLUGIN_DIR . '/helpers', 'Commenting_View_Helper_');
// output the header
echo $view->partial('commentingHeader.php');
if( (get_option('commenting_allow_public') == 1)
|| (get_option('commenting_allow_public_view') == 1)
|| is_allowed('Commenting_Comment', 'show') ) {
$options = array('threaded'=> get_option('commenting_threaded'), 'approved'=>true);
$comments = isset($args['comments']) ? $args['comments'] : $view->getComments($options);
echo $view->partial('comments.php', array('comments'=>$comments, 'threaded'=>$options['threaded']));
}
if( (get_option('commenting_allow_public') == 1)
|| is_allowed('Commenting_Comment', 'add') ) {
echo "<div id='comment-main-container'>";
echo $view->getCommentForm();
echo "</div>";
}
echo "</div>";
}
This presumes that we need the $views set in any case.
I also created a new file views/public/commentingHeader.php which contains:
<?php $label = get_option('commenting_comments_label'); ?>
<?php if ($label == ''):?>
<h2><?php echo __('Comments'); ?></h2>
<?php else: ?>
<h2><?php echo $label; ?></h2>
<?php endif; ?>
<div id='comments-flash'><?php echo flash(true); ?></div>
This code has been removed from views/public/comments.php.
- Dominant language
- PHP
- Stars
- 4
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from omeka/plugin-Commenting
-
a11y
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
omeka/plugin-Commenting#70 ·
-
a11y
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
omeka/plugin-Commenting#67 ·
-
a11y
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
omeka/plugin-Commenting#64 ·
-
a11y
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
omeka/plugin-Commenting#63 ·
-
a11y
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
omeka/plugin-Commenting#62 ·
All issues in omeka/plugin-Commenting
Similar issues
-
sync-en
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
a11y
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
omeka/plugin-ExhibitBuilder#169 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
35-feedback
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day