Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Display Number of Comments a user has made  (Read 18572 times)

0 Members and 1 Guest are viewing this topic.

nickfzx

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 285
Display Number of Comments a user has made
« on: March 17, 2007, 09:48:12 pm »

Ok, this one shouldn't be too hard.

Basically you know on this forum it say how many posts I have made.  Well would be cool if it said how many comments a user has made in coppermine gallery next to each comment they make.

I don't think this should be too hard to make.  Was looking at the database and it looks like all I would have to do is go into the comments table...give the user ID I want the comment count for...if there is no entry then it is 0 comments for that user, if it there is an entry then the number of rows associated with that UserID is the comment count.

Any flaws in my evil plan?  Or should I just jump in and start coding it?
« Last Edit: March 28, 2007, 07:56:07 am by GauGau »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: Number of Comments
« Reply #1 on: March 18, 2007, 02:47:58 pm »

Or should I just jump in and start coding it?
Start coding it ;D. Without having taken a look into the code, my guess is though that you'll have to add some queries, which might have a performance impact.
Logged

nickfzx

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 285
Re: Number of Comments
« Reply #2 on: March 20, 2007, 05:31:10 am »

The raw query is this:
Code: [Select]
SELECT COUNT( * ) AS `Rows`
FROM `cpg_comments`
WHERE author_id = XX
XX being the the author_id variable in the theme file.

not sure how efficient it is or how much extra strain it will put on your server.

in the next post I will outline how to integrate it with your theme file.
« Last Edit: March 20, 2007, 06:18:21 am by nickfzx »
Logged

nickfzx

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 285
Re: Number of Comments
« Reply #3 on: March 20, 2007, 06:16:26 am »

so if anyone wants to display the total number of comments that a user has made in coppermine next to each comment this is what to do:

you will need to copy these two sections from theme.inc.php to theme.php if you have not already:
Code: [Select]
// Displays comments for a specific picture
...
and
Code: [Select]
// HTML template for the display of comments
...

so now in theme.php find:
Code: [Select]
<b>{MSG_AUTHOR}</b>replace with:
Code: [Select]
<b>{MSG_AUTHOR} {NUMBER_COMMENTS}</b>find:
Code: [Select]
($row['author_id'] == 0 ) ? $profile_lnk = stripslashes($row['msg_author']): $profile_lnk = "<a href=\"profile.php?uid={$row['author_id']}\">".stripslashes($row['msg_author'])."</a>";after add:
Code: [Select]
$authorid = $row['author_id'];
$number_of_comments = sprintf("SELECT COUNT( * ) AS `Rows` FROM cpg_comments WHERE author_id=$authorid");
$resultx = mysql_query($number_of_comments);
$bow = mysql_fetch_assoc($resultx);
find:
Code: [Select]
            '{AUTHOR_ID}' => $row['author_id']replace with:
Code: [Select]
            '{AUTHOR_ID}' => $row['author_id'],
    '{NUMBER_COMMENTS}' => $bow['Rows']

and thats it...it will just display the number next to the username of the commenter with no explanation of what it means so you may want to format it a little nicer or give an explanation.

I've tested it and it works with no visible side effects, let me know if you have any troubles.
Logged

nickfzx

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 285
Re: Number of Comments
« Reply #4 on: March 27, 2007, 10:50:11 pm »

a valid mod no?  ;D

see it in action here:
http://www.amateurillustrator.com/galleries/displayimage.php?album=topn&cat=0&pos=0

notice the comment counter next to each username.
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: Display Number of Comments a user has made
« Reply #5 on: March 28, 2007, 07:57:57 am »

It's recommended to use the coppermine query functions.
Logged

nickfzx

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 285
Re: Display Number of Comments a user has made
« Reply #6 on: March 28, 2007, 12:03:32 pm »

ah ok, I will look into changing it.

What are the reasons for using the copper mine query functions...is it just for clarity or does it affect the way it works?
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: Display Number of Comments a user has made
« Reply #7 on: March 29, 2007, 08:14:32 am »

Makes your mod more robust in case that the queries should change in future versions (e.g. maintenance releases).
Logged

andi_k

  • Coppermine newbie
  • Offline Offline
  • Posts: 19
Re: Number of Comments
« Reply #8 on: June 28, 2007, 02:19:03 pm »


find:
Code: [Select]
($row['author_id'] == 0 ) ? $profile_lnk = stripslashes($row['msg_author']): $profile_lnk = "<a href=\"profile.php?uid={$row['author_id']}\">".stripslashes($row['msg_author'])."</a>";after add:
Code: [Select]
$authorid = $row['author_id'];
$number_of_comments = sprintf("SELECT COUNT( * ) AS `Rows` FROM cpg_comments WHERE author_id=$authorid");
$resultx = mysql_query($number_of_comments);
$bow = mysql_fetch_assoc($resultx);

I cannot find this.
Logged

DaBe

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 110
Re: Display Number of Comments a user has made
« Reply #9 on: January 01, 2008, 11:09:55 pm »

hello

How I can use this mod in the userlist also usermgr.php ?

and is the mod compatible with 1.4.14 coppermine version with modpack?


thx
Logged

Dogbot

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 23
Re: Display Number of Comments a user has made
« Reply #10 on: August 13, 2008, 11:29:12 am »

How would or could you edit this so that only the comments made by members on other members photos where counted?

.D.
Logged
Pages: [1]   Go Up
 

Page created in 0.02 seconds with 20 queries.