TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,970
  • Latest: bynw
Stats
  • Total Posts: 196,054
  • Total Topics: 21,337
  • Online today: 572
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 137
  • Total: 137

Caused by Guest Comments ???

Started by wildenborch, September 15, 2015, 09:21:05 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

wildenborch

I/m not sure if the following is also caused by the new functionality that guests can post comments but if I click the show latest comments in the USER block in the left menu I get the message Sorry, you are not allowed to comment

When, in the addressbar I type ?action=tpmod;sa=showcomments;showall
I see all comments. Without the ;showall i get te message Sorry, you are not allowed to comment.

BTW, it would be nice if this showall listing would also include a delete comment button (if logged in as admin!)

Best regards,
Fred

Rodebaert.nl
smf version 2.0.10
TP version 1.1
Default Forum Language is english
Browser Firefox
No mods installed

illori

if(!$context['TPortal']['showall'])
echo '
<tr><td colspan="5" class="titlebg" align="right"><a href="' . $scripturl . '?action=tpmod;sa=showcomments;showall">' . $txt['tp-showall'] . '</a></td></tr>';
}
else
echo '
<tr><td colspan="5" class="windowbg2">' . $txt['tp-nocomments'] . '</td></tr>';


i think this is related to the fact that tp-nocomments has been defined 2 times. maybe one is a mistake?
  D:\wamp\www\TinyPortal\Themes\default\languages\TPmodules.english-utf8.php (2 hits)
Line 43: $txt['tp-nocomments'] = 'There are no replies on your comments.';
Line 48: $txt['tp-nocomments'] = 'Sorry, you are not allowed to comment';
  D:\wamp\www\TinyPortal\Themes\default\languages\TPmodules.english.php (2 hits)
Line 43: $txt['tp-nocomments'] = 'There are no replies on your comments.';
Line 48: $txt['tp-nocomments'] = 'Sorry, you are not allowed to comment';

illori

also a guests comments have a bug in the profile link/name

Written by 0 on Today at 06:00:08 pm

it should say guest instead of 0 and not link to the profile of a user with id of 0.

lurkalot

I noticed that in the image I sent you. but forgot to mention it.  :-[

wildenborch

illori,

To which php file do you refer?

Best regards,
Fred

illori

that code is in TPmodules.template.php, i dont have a solution for the issue so far but that is where the code is.

illori

replace the function in TPsubs.template.php with the following...
function article_comments($render = true)
{
global $scripturl, $txt, $settings, $context;

if(in_array('comments', $context['TPortal']['article']['visual_options']))
{
echo '
<h2 class="titlebg" style="padding: 0 1em;">' . $txt['tp-comments'] . '  ' . (tp_hidepanel('articlecomments', false, true, '5px 5px 0 5px')) . '</h2>
<div id="articlecomments"' . (in_array('articlecomments',$context['tp_panels']) ? ' style="display: none;"' : '') . '>
<div class="windowbg2" style="padding: 1em 2em;">';

$counter = 1;
if(isset($context['TPortal']['article']['comment_posts']))
{
foreach($context['TPortal']['article']['comment_posts'] as $comment)
{
if ($comment['posterID'] == 0)
echo '
<div class="othercomment">
<a id="comment'.$comment['id'].'"></a>
<strong>' . $counter++ .') ' . $comment['subject'] . '</strong>
<div class="middletext" style="padding-top: 0.5em;"> '.$txt['tp-by'].' '.$txt['guest_title'].' '. $txt['on'] . ' ' . $comment['date'] . '</div>
' . (($comment['is_new'] && $context['user']['is_logged']) ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="" />' : '') . '
<div class="textcomment"><div class="body">' . $comment['text'] . '</div></div><br />';
else
echo '
<div class="' . ($context['TPortal']['article']['authorID']!=$comment['posterID'] ? 'mycomment' : 'othercomment') . '">
<a id="comment'.$comment['id'].'"></a>
<span class="comment_author">' . (!empty($comment['avatar']['image']) ? $comment['avatar']['image'] : '') . '</span>
<strong>' . $counter++ .') ' . $comment['subject'] . '</strong>
' . (($comment['is_new'] && $context['user']['is_logged']) ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="" />' : '') . '
<div class="middletext" style="padding-top: 0.5em;"> '.$txt['tp-by'].' <a href="'.$scripturl.'?action=profile;u='.$comment['posterID'].'">'.$comment['poster'].'</a>
' . $txt['on'] . ' ' . $comment['date'] . '</div>
<div class="textcomment"><div class="body">' . $comment['text'] . '</div></div><br />';


// can we edit the comment or are the owner of it?
if(allowedTo('tp_articles') || $comment['posterID'] == $context['user']['id'] && !$context['user']['is_guest'])
echo '
<div class="buttonlist align_right"><ul><li><a class="active" href="' . $scripturl . '?action=tpmod;sa=killcomment' . $comment['id'] . '" onclick="javascript:return confirm(\'' . $txt['tp-confirmdelete'] . '\')"><span>' . $txt['tp-delete'] . '</span></a></li></ul></div><br />';

echo '
</div>';
}
echo '
</div>';
}
}

if(in_array('commentallow', $context['TPortal']['article']['visual_options']) && !empty($context['TPortal']['can_artcomment']))
{
echo '
<div class="windowbg" style="margin-top: 10px; padding: 1em;">
<form accept-charset="' . $context['character_set'] . '"  name="tp_article_comment" action="' . $scripturl . '?action=tpmod;sa=comment" method="post" style="margin: 0; padding: 0;">
<input name="tp_article_comment_title" type="text" style="width: 99%;" value="Re: ' . strip_tags($context['TPortal']['article']['subject']) . '">
<textarea style="width: 99%; height: 8em;" name="tp_article_bodytext"></textarea>
';

if (!empty($context['TPortal']['articles_comment_captcha']) )
{
loadtemplate('GenericControls');
echo '
<div class="">
<span' . (!empty($context['post_error']['need_qr_verification']) ? ' class="error"' : ''). '>
<strong>' . $txt['verification'] . ':</strong>
</span>
' . (template_control_verification($context['visual_verification_id'], 'all')). '
</div>';

}

echo '
<br />&nbsp;<input id="tp_article_comment_submit" type="submit" value="' . $txt['tp-submit'] . '">
<input name="tp_article_type" type="hidden" value="article_comment">
<input name="tp_article_id" type="hidden" value="' . $context['TPortal']['article']['id'] . '">
<input type="hidden" name="sc" value="' . $context['session_id'] . '" />
</form>
</div>';
}
else
echo '
<div style="padding: 1ex;" class="windowbg"><em>' . $txt['tp-cannotcomment'] . '</em></div>';

echo '
</div>';

}


now your guests will now have the correct text for the date stamp.

let me know if you run into any other errors in this template... i think i made some other changes

$code .= ' is now echo '

if that does not fix it all, i can post my file.

illori

the issue with showall, is that as a guest or as a registered user? so far i have not duplicated it.

it would not be so easy for me to add the delete button, so i am not at this time.

wildenborch

illori,

Thank you very much for this help!

I have changed the code and now the id of the poster is indeed Guest instead of 0.

What do you mean with " i think i made some other changes

$code .= ' is now echo ' " Do I have to change this too? Where?

Further, in the "recent comments" block http://www.tinyportal.net/index.php?topic=31176.msg279657#msg279657
the guest comments do not show. That why I added a ID 0 member in the smf_members table. I know that this should not be "fixed" like this but for now it works for me.

If you wish, see www.vanveen-nl.com

Best regards,
Fred


illori

if you are not getting errors using that code then dont worry about the code to echo thing.

This website is proudly hosted on Crocweb Cloud Website Hosting.