Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

Unanticipated User Role setting causes error

Ouverte
#28 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
38/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
À l'abandon
Stack technique
php

Piste de recherche

Commencez dans CommentingPlugin::showComments et comparez views/public/comments.php avec le fichier proposé views/public/commentingHeader.php. Suivez les vérifications de rôles pour l’affichage et l’ajout de commentaires, puis vérifiez qu’un rôle autorisé à commenter, mais pas à voir les commentaires, reçoit toujours le label, le message flash et le formulaire de commentaire sans erreur.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

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.

Langage dominant
PHP
Étoiles
4
Forks
5
Métriques de merge des PR
Aucune PR mergée en 30 j

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de omeka/plugin-Commenting

Toutes les issues de omeka/plugin-Commenting

Issues similaires

Plus d'issues PHP

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.