Hi!
I have in my template.php (custom theme) the following code to present a comments along with EDIT and DELETE Links:

function custome_comment_list_result_html($comments) {
  global $user;
  $user = user_load($user->uid);
  $result = '';
  
  foreach ($comments as $key => $value) {
    $postTime = format_date($value['data']['created'],'medium','H:i, d F, Y',NULL,NULL);
    
    $result .= '<div class="comment-entry">'; 
    $result .= '<div id="comment-'.$value['data']['cid'].'" class="comment-image">';
    $result .= $value['data']['pic'];
    $result .= '</div>';
    $result .= '<div class="comment-content">';
    $result .= '<div class="name">'.$value['data']['name'];
    $result .= '<div class="date"><span aria-hidden="true" class="glyphicon glyphicon-time"></span>'.$postTime.'</div>'; 
    $result .= '</div>';
    if (($user->uid == $comment->uid && user_access('edit own comments')) || user_access('administer comments')) { 
    $result .= '<div class="description">'.$value['data']['body'].'</div>';
    $result .= '<div class="name">';
    $result .= '<a href="'.$value['data']['edit'].'"><div class="reply"><span aria-hidden="true" class="glyphicon glyphicon-comment"></span> Изменить<span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></div></a>'; 
    $result .= '<a href="'.$value['data']['delete'].'"><div class="reply"><span aria-hidden="true" class="glyphicon glyphicon-comment"></span> Удалить</div></div></a>';
    $result .= '</div>';
    }else{
    $result .= '<div class="description">'.$value['data']['body'].'</div>';
    $result .= '</div>';
      }
    $result .= '<div class="clear"></div>';

But if the

user_access('administer comments')

permission works perfectly, the following code

($user->uid == $comment->uid && user_access('edit own comments'))

does not work and I can't see, where the fault is. Please, can you help me?

Sincerely, Svetlana

Comments

mmerrill219’s picture

If you goto /themes/bartik/templates/comments/comment.tpl.php

All of this logic is handled with:

<?php 
hide($content['links']);
print render($content['links']); 
?>

The logic you are recreating is already in the core comment module:
/cbhomeorg-dev/docroot/modules/comment/comment.module

Jeff Burnz’s picture

Agree with @mmerrill219, there no need to recreate such logic, you can and should use the template files and it's handy theming functions. For example you having to recreate access controls - simply not necessary (most of the time) if you theme with proper Drupal functions and methods etc.

taecelle’s picture

Hi!
Thank you very much. But the problem is - it's not my theme, i'm not a developer. I bought it and now try to modify a little bit for my site. So I need to put inside some logic, I can't just delete all of this and copy the code from Bartic instead.