1. Chris Zurlinden
  2. Newbies area
  3. Tuesday, 06 October 2009
  4.  Subscribe via email
i would like to count all comments a user made

Thats why i hacked your code a bit.
First i had to add a field jos_users.comments

then in comment.class.php i added the following
[CODE]
function setUser()
{
$database =& JFactory::getDBO();

/* also in post ! and notification */
$query = "SELECT * FROM jos_users WHERE id='".$this->_userid."' LIMIT 1";
$database->SetQuery($query);
$result = $database->loadAssocList();
if ($result) {
$user = $result[0];
$this->_usertype = $user['usertype'];
$this->_tname = $this->_use_name ? $user['name'] : $user['username'];
$this->_temail = $user['email'];
$this->_tcomments = $user['comments'];# added by zurli
}

}
[/CODE]

and then more below i changed this
[CODE]
#Commentscounter edit by zurli
$this->_tcomments = $this->_tcomments+1;
$query = "
UPDATE jos_users SET
comments=$this->_tcomments
WHERE id=$userid";
$database->SetQuery($query);
$database->Query() or die(_JOOMLACOMMENT_EDITINGFAILED . "\n $query";);
#End Commentscounter edit by zurli

$database->SetQuery("
INSERT INTO jos_comment
(contentid,component,ip,userid,usertype,date,name,email,website,notify,title,comment,published,voting_yes,voting_no,parentid)
VALUES(
'$this->_content_id',
'$com',
'$ip',
'$userid',
'',
'$createdate',
'$name',
'$email',
'$website',
'$notify',
'$title',
'$comment',
'$published',
'0',
'0',
'$parent_id'
)";);
$result=$database->Query() or die(_JOOMLACOMMENT_SAVINGFAILED); //.$database->getQuery());

[/CODE]

what you think about solution
Responses (6)


There are %s replies to this question. If you want to see them you need a valid subscription.
If you have a valid subscription, please login now.
Visit store now

Last questions

Dowload all Hotspots entries
Hi there, I'm looking for a way to dowload all the Hotspots entries. I've got t...
0 Replies
Posted on Sunday, 06 April 2025
  • #kml
  • #download
Set number of hotspots / user groups
Hi, I'm working with Hotspots for my new website and I love it! After trying ...
0 Replies
Posted on Monday, 31 March 2025
J5 compatibility for Hotspots
Hi guys, Just started to update my old J3x website. Is there J5 compatibility p...
1 Replies
Posted on Monday, 24 February 2025
  • #Hotspots
  • #hotspots Joomla 5
Text size in the comment input form
Hello. How can I increase the font size in the comment input field? For examp...
0 Replies
Posted on Wednesday, 26 February 2025
  • #CComment 6
Problem with enlarged image
Hello. When you click on the image in the comments, it does not appear in the ce...
1 Replies
Posted on Wednesday, 26 February 2025