Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

JoomlaTune Support Forum    JComments component    Suggestions, Wishlists & Feature Requests    Topic: [ToDo] Limit of comments
Pages: [1]   Go Down
  Print  
Author Topic: [ToDo] Limit of comments  (Read 2117 times)
0 Members and 1 Guest are viewing this topic.
Diabl0pl
Newbie
*

Karma: 0
Offline Offline

Posts: 5


« on: August 27, 2010, 01:12:38 »

Hi!
I really like JComments Component, but tere is something that bothers me and doesn't let me use it.
I'd like to make a limit of comments to one article, for example 3. Is this possible, to make comment editor disappear after publishing third comment? Something like that was possible in Mxcomment only, but this is very old component and nobody uses this, btw it has freaky bad editor.

PS. I was trying to use these settings:
One page of comments and three comments on page, whitch should do what i say, but it doesn't and it shows every comment and doesn't make editor disappear.

Please, help me!
« Last Edit: August 27, 2010, 13:52:37 by smart » Logged
smart
Administrator
Hero Member
*****

Karma: 146
Offline Offline

Gender: Male
Posts: 2579



WWW
« Reply #1 on: August 27, 2010, 13:52:26 »

Ok, this feature will be implemented in next JComments version.
Logged

If you use JComments, please post a rating and a review at the Joomla! Extensions Directory
Diabl0pl
Newbie
*

Karma: 0
Offline Offline

Posts: 5


« Reply #2 on: August 29, 2010, 23:04:56 »

 Smiley Thank you very much!
Would it be wrong if I asked when can I expect next version? Wink)
Logged
smart
Administrator
Hero Member
*****

Karma: 146
Offline Offline

Gender: Male
Posts: 2579



WWW
« Reply #3 on: August 30, 2010, 15:06:33 »

I'm workin' too hard on new version and can say that it will be released ASAP. But I need to make some changes in language files and update translations. If you need this feature I could explain how to implement it.

1. Open file /components/com_jcomments/jcomments.php
2. Find and remove code:
Code: (php)
if ($config->getInt('comments_locked', 0) == 1) {
$config->set('enable_rss', 0);
$tmpl->addVar('tpl_index', 'comments-form-locked', 1);
}
3. Find and replace code:
Code: (php)
$commentsCount = JCommentsModel::getCommentsCount($object_id, $object_group);
with
Code: (php)
$commentsCount = JCommentsModel::getCommentsCount($object_id, $object_group);
$commentsPerObject = $config->getInt('max_comments_per_object');

if ($commentsPerObject != 0 && $commentsCount == $commentsPerObject) {
$config->set('comments_locked', 1);
}

if ($config->getInt('comments_locked', 0) == 1) {
$config->set('enable_rss', 0);
$tmpl->addVar('tpl_index', 'comments-form-locked', 1);
}

4. Open file /administrator/components/com_jcomments/admin.jcomments.html.php
5. Find code:
Code: (php)
<tr align="left" valign="top">
<td><?php echo JText::_('AP_ENABLE_NESTED_QUOTES'); ?></td>
<td><?php echo JCommentsHTML::yesnoSelectList'cfg_enable_nested_quotes''class="inputbox"'$config->get('enable_nested_quotes'), JText::_('A_YES'), JText::_('A_NO')); ?></td>
<td><?php echo JText::_('AP_ENABLE_NESTED_QUOTES_DESC'); ?></td>
</tr>
and insert after it:
Code: (php)
<tr align="left" valign="top">
<td><?php echo JText::_('AP_MAX_COMMENTS_PER_OBJECT'); ?></td>
<td><input type="text" class="inputbox" size="5" name="cfg_max_comments_per_object" value="<?php echo $config->getInt('max_comments_per_object'); ?>" /></td>
<td><?php echo JText::_('AP_MAX_COMMENTS_PER_OBJECT_DESC'); ?></td>
</tr>

6. Open file /components/com_jcomments/jcomments.ajax.php
7. Find code:
Code: (php)
$values = JCommentsAJAX::prepareValues( $_POST );
$userIP = $acl->getUserIP();
add after:
Code: (php)
$object_group = trim(strip_tags($values['object_group']));
$object_group = preg_replace('#[^0-9A-Za-z\-\_\,\.]#is', '', $object_group);
$object_id = isset($values['object_id']) ? intval($values['object_id']) : '';

$commentsPerObject = $config->getInt('max_comments_per_object');
if ($commentsPerObject > 0) {
$commentsCount = JCommentsModel::getCommentsCount($object_id, $object_group);
if ($commentsCount == $commentsPerObject) {
$message = $config->get('message_locked');
if (empty($message)) {
$message = $config->get('ERROR_CANT_COMMENT');
}
$message = JCommentsAJAX::escapeMessage($message);
$response->addAlert($message);
return $response;
}
}


Thats all. After this you'll need to set this parameter in JComments settings.


« Last Edit: August 31, 2010, 01:46:02 by smart » Logged

If you use JComments, please post a rating and a review at the Joomla! Extensions Directory
Diabl0pl
Newbie
*

Karma: 0
Offline Offline

Posts: 5


« Reply #4 on: August 31, 2010, 01:05:20 »

It works, but there is a simple problem.
I'll try to explain as simple as I can.
For example I set limit of comments at 3.
User A posts comment #1, user B posts 2nd comment and if user C post comment number 3, he can still see editor after posting. If he waited enough time to send another comment he could be able to send comment #4.
After that comments aren't blocked in this article  and there is no limit. Users can comment it with no problem.
Is there any way to configure this?
Logged
smart
Administrator
Hero Member
*****

Karma: 146
Offline Offline

Gender: Male
Posts: 2579



WWW
« Reply #5 on: August 31, 2010, 01:46:50 »

I've updated quick solution with steps 6 and 7. There is additional check before storing comment.
Logged

If you use JComments, please post a rating and a review at the Joomla! Extensions Directory
Diabl0pl
Newbie
*

Karma: 0
Offline Offline

Posts: 5


« Reply #6 on: August 31, 2010, 04:15:40 »

Thank you VERY VERY MUCH! I must say that you are the best administrator I've met Smiley
Simple and useful posts. And what's the most important, you don't demand from users to know everything about Joomla!

Thank you very much!
« Last Edit: August 31, 2010, 19:52:04 by Diabl0pl » Logged
Pages: [1]   Go Up
  Print  
JoomlaTune Support Forum    JComments component    Suggestions, Wishlists & Feature Requests    Topic: [ToDo] Limit of comments
 
Jump to: