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: [wanted] aviod same images in "new comments"  (Read 8265 times)

0 Members and 1 Guest are viewing this topic.

Bruz

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 54
[wanted] aviod same images in "new comments"
« on: March 08, 2004, 07:59:30 pm »

Hi!

I have this problem:

(http://www.kingbruz.de/Fotos/question/question.jpg)

I want to avoid the same picture shown up that often, I just need the newest comment with one picture...
Is it possible to do so, if one picture has more than one comment?

THX in advance
Bruz
Logged
(http://www.kingbruz.de/Fotos/signatur_cpg.php)

get your statistik-hack here

Bruz

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 54
[wanted] aviod same images in "new comments"
« Reply #1 on: March 11, 2004, 07:15:16 am »

Is anybody else interested in this feature?

And is it possible?
Logged
(http://www.kingbruz.de/Fotos/signatur_cpg.php)

get your statistik-hack here

Bruz

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 54
[wanted] aviod same images in "new comments"
« Reply #2 on: March 13, 2004, 01:40:27 pm »

I really need to geht rid of multiple pictures in the 'last comments', because by now, 12 people gave their comment to one picture...
It doesn't really looks good, if there is only one picture 4 times...(see my screenshot above)

gaugau: is it possible to show a picture only once?
Logged
(http://www.kingbruz.de/Fotos/signatur_cpg.php)

get your statistik-hack here

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
[wanted] aviod same images in "new comments"
« Reply #3 on: March 13, 2004, 01:50:43 pm »

It surely is, but requires looking into it. At the moment, I'm busy to get cpg1.3.0 on the way, so I won't look into this "problem" right now. Maybe someone else is willing to do so?

GauGau
Logged

Tarique Sani

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 2712
    • http://tariquesani.net
[wanted] aviod same images in "new comments"
« Reply #4 on: March 13, 2004, 03:01:30 pm »

Open functions.inc.php somewhere around line 505 will a section like

Code: [Select]
case 'lastcom': // Last comments

in that section a bit lower down is the SQL query which you will have to modify to get unique pid - fix that query and you will have what you want....

Also IMO this is unlikely to be a main stream feature
Logged
SANIsoft PHP applications for E Biz

Bruz

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 54
[wanted] aviod same images in "new comments"
« Reply #5 on: March 13, 2004, 03:38:02 pm »

Ok, I took a look - and I managed to solve nearly everything on my own in the past - but this is a little bit to...complex for me :(

Code: [Select]
       // Meta albums
        switch($album){
        case 'lastcom': // Last comments
                if ($ALBUM_SET && $CURRENT_CAT_NAME) {
                        $album_name = $album_name = $lang_meta_album_names['lastcom'].' - '. $CURRENT_CAT_NAME;
                } else {
                        $album_name = $lang_meta_album_names['lastcom'];
                }
                $result = db_query("SELECT COUNT(*) from {$CONFIG['TABLE_COMMENTS']}, {$CONFIG['TABLE_PICTURES']}  WHERE approved = 'YES' AND {$CONFIG['TABLE_COMMENTS']}.pid = {$CONFIG['TABLE_PICTURES']}.pid $ALBUM_SET");
                $nbEnr = mysql_fetch_array($result);
                $count = $nbEnr[0];
                mysql_free_result($result);

                if($select_columns == '*'){
                        $select_columns = 'p.*';
                } else {
                        $select_columns = str_replace('pid', 'c.pid', $select_columns).', msg_id, author_id, msg_author, UNIX_TIMESTAMP(msg_date) as msg_date, msg_body, aid';
                }

                $result = db_query("SELECT $select_columns FROM {$CONFIG['TABLE_COMMENTS']} as c, {$CONFIG['TABLE_PICTURES']} as p WHERE approved = 'YES' AND c.pid = p.pid $ALBUM_SET ORDER by msg_id DESC $limit");
                $rowset = db_fetch_rowset($result);
                mysql_free_result($result);

                if ($set_caption) foreach ($rowset as $key => $row){
                        if ($row['author_id']) {
                            $user_link = '<a href ="profile.php?uid='.$row['author_id'].'">'.$row['msg_author'].'</a>';
                        } else {
                                $user_link = $row['msg_author'];
                        }
                        $msg_body = strlen($row['msg_body']) > 50 ? @substr($row['msg_body'],0,50)."...": $row['msg_body'];
                        $caption = '<span class="thumb_title">'.$user_link.'</span>'.'<span class="thumb_caption">'.localised_date($row['msg_date'], $lastcom_date_fmt).'</span>'.'<span class="thumb_caption">'.$msg_body.'</span>';
                        $rowset[$key]['caption_text'] = $caption;
                }
                return $rowset;
                break;


I really dont know how to change this to match what I want...
Logged
(http://www.kingbruz.de/Fotos/signatur_cpg.php)

get your statistik-hack here

Tarique Sani

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 2712
    • http://tariquesani.net
[wanted] aviod same images in "new comments"
« Reply #6 on: March 13, 2004, 03:50:24 pm »

Which part is complex?

Code: [Select]
SELECT $select_columns FROM {$CONFIG['TABLE_COMMENTS']} as c, {$CONFIG['TABLE_PICTURES']} as p WHERE approved = 'YES' AND c.pid = p.pid $ALBUM_SET ORDER by msg_id DESC $limit

This is the query you need to modify, do something like

Code: [Select]
echo"SELECT $select_columns FROM {$CONFIG['TABLE_COMMENTS']} as c, {$CONFIG['TABLE_PICTURES']} as p WHERE approved = 'YES' AND c.pid = p.pid $ALBUM_SET ORDER by msg_id DESC $limit"
just before or after the db_query

This will show you the expanded / evaluated SQL copy this, Open phpMyAdmin (I presume you have one) and run tthe query there - start tweaking the query till you get one which fits what you want - paste that back into the file and you are done :)

As a bonus you get to learn more SQL than you already know.
Logged
SANIsoft PHP applications for E Biz

Bruz

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 54
[wanted] aviod same images in "new comments"
« Reply #7 on: March 14, 2004, 01:51:42 pm »

hmm... I've added
Code: [Select]
echo("$result")

right after
Code: [Select]
$result = db_query("SELECT $select_columns FROM {$CONFIG['TABLE_COMMENTS']} as c, {$CONFIG['TABLE_PICTURES']} as p WHERE approved = 'YES' AND c.pid = p.pid $ALBUM_SET ORDER by msg_id DESC $limit");

but this gives me only 'Resource id #35' - SQL-querys are not really my thing...
Logged
(http://www.kingbruz.de/Fotos/signatur_cpg.php)

get your statistik-hack here

Tarique Sani

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 2712
    • http://tariquesani.net
[wanted] aviod same images in "new comments"
« Reply #8 on: March 14, 2004, 02:14:12 pm »

Read what I have ask you to do and compare it to what you have done - If you still can't figure it out then I would suggest - just wait for someone to do it for you OR hire someone to do it for you
Logged
SANIsoft PHP applications for E Biz

Bruz

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 54
[wanted] aviod same images in "new comments"
« Reply #9 on: March 14, 2004, 02:14:59 pm »

well, I did what you told me - but it just wirtes
"echo"SELECT $select_columns FROM {$CONFIG['TABLE_COMMENTS']} as c, {$CONFIG['TABLE_PICTURES']} as p WHERE approved = 'YES' AND c.pid = p.pid $ALBUM_SET ORDER by msg_id DESC $limit""
above my "last comments" table
Maybe I understood you wrong?
Logged
(http://www.kingbruz.de/Fotos/signatur_cpg.php)

get your statistik-hack here

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
[wanted] aviod same images in "new comments"
« Reply #10 on: March 14, 2004, 03:13:22 pm »

like Tarique said: maybe you should get someone else's help to do this - as neither Tarique nor another dev is going to give you copy'n paste-ready code for your request. If we walked you through each and every step of developing this tiny mod, we could as well do it by ourselves. Learning PHP by looking at other's code and slighty changing it is a great method - if you don't understand a step, you should consult the php documentation. It's fun to find things out step by step, give it a try.

GauGau
Logged
Pages: [1]   Go Up
 

Page created in 0.022 seconds with 19 queries.