Advanced search  

News:

cpg1.5.36 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.34 or older update to this latest version as soon as possible.
[more]

Pages: [1] 2   Go Down

Author Topic: Search by username?  (Read 15170 times)

0 Members and 1 Guest are viewing this topic.

Streamer

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 21
Search by username?
« on: August 27, 2010, 07:20:22 PM »

Any possibility to add search by username. There was such an option at 1.4 but now its removed (why?). I didnt find any plug-in etc about that.
Logged

papukaija

  • Contributor
  • Coppermine frequent poster
  • ***
  • Country: 00
  • Offline Offline
  • Posts: 333
Re: Search by username?
« Reply #1 on: August 28, 2010, 04:55:27 PM »

Please post a link to your gallery as requested by board rules.
Logged

Streamer

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 21
Re: Search by username?
« Reply #2 on: August 30, 2010, 08:32:59 AM »

Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15037
Re: Search by username?
« Reply #3 on: September 02, 2010, 12:44:18 PM »

What/where do you want to search by username? The meta albums lastupby and lastcomby still exists in cpg1.5.x and I cannot remember that we had other possibilities in cpg1.4.x.
Logged

Phill Luckhurst

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 4273
    • Windsurf.me
Re: Search by username?
« Reply #4 on: September 02, 2010, 01:41:52 PM »

In search.php Andre. In 1.4.x there was an "ownername" check box (take a look at the demo) but we dropped that in 1.5.x for some reason which I am not sure of.
Logged
It is a mistake to think you can solve any major problems just with potatoes.

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15037
Re: Search by username?
« Reply #5 on: September 02, 2010, 02:22:13 PM »

We dropped the column 'owner_name' some time ago. I think that was the reason. A simple JOIN can solve that in standalone versions.
Logged

Streamer

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 21
Re: Search by username?
« Reply #6 on: September 02, 2010, 08:01:38 PM »

Ok, thanks for the answer.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15037
Re: Search by username?
« Reply #7 on: March 07, 2012, 12:43:36 PM »

This seems to work:

1. Open search.php, find
Code: [Select]
$customs
$ip
and above, add
Code: [Select]
                                        <tr>
                                                <td><input type="checkbox" name="owner_name" id="owner_name" class="checkbox" /><label for="owner_name" class="clickable_option">Owner name</label></td>
                                                <td>&nbsp;</td>
                                        </tr>


2. Open thumbnails.php, find
Code: [Select]
$allowed = array('title', 'caption', 'keywords', 'filename', 'pic_raw_ip', 'pic_hdr_ip', 'user1', 'user2', 'user3', 'user4', 'type');and replace with
Code: [Select]
$allowed = array('title', 'caption', 'keywords', 'filename', 'pic_raw_ip', 'pic_hdr_ip', 'user1', 'user2', 'user3', 'user4', 'type', 'owner_name');

3. Open include/search.inc.php, find
Code: [Select]
$allowed = array('title', 'caption', 'keywords', 'filename', 'pic_raw_ip', 'pic_hdr_ip', 'user1', 'user2', 'user3', 'user4');and below, add
Code: [Select]
// Use actual column name for search by user name
if ($USER['search']['params']['owner_name']) {
    global $cpg_udb;
    $USER['search']['params'][$cpg_udb->field['username']] = 'on';
    $allowed[] = $cpg_udb->field['username'];
}

find
Code: [Select]
            $query = "SELECT COUNT(*) FROM {$CONFIG['TABLE_PICTURES']} AS p
                WHERE $sql
                AND ($sort_order)";
and replace with
Code: [Select]
            $query = "SELECT COUNT(*) FROM {$CONFIG['TABLE_PICTURES']} AS p
                INNER JOIN {$cpg_udb->usertable} AS u ON p.owner_id = u.{$cpg_udb->field['user_id']}
                WHERE $sql
                AND ($sort_order)";

find
Code: [Select]
            $query = "SELECT * FROM {$CONFIG['TABLE_PICTURES']} AS p WHERE " . $sql;and replace with
Code: [Select]
            $query = "SELECT p.*, u.{$cpg_udb->field['username']} AS owner_name FROM {$CONFIG['TABLE_PICTURES']} AS p
            INNER JOIN {$cpg_udb->usertable} AS u ON p.owner_id = u.{$cpg_udb->field['user_id']}
            WHERE " . $sql;
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15037
Re: Search by username?
« Reply #8 on: March 07, 2012, 12:46:42 PM »

Any reports / confirmation that it works in other galleries (in unbridged and bridged ones) are welcome, so that feature can be added back to Coppermine.
Logged

Phill Luckhurst

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 4273
    • Windsurf.me
Re: Search by username?
« Reply #9 on: March 07, 2012, 04:45:59 PM »

Seems to work well for me Andre.
Logged
It is a mistake to think you can solve any major problems just with potatoes.

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15037
Re: Search by username?
« Reply #10 on: March 07, 2012, 04:49:32 PM »

I assume you tested it in your Joomla bridged gallery?
Logged

Phill Luckhurst

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 4273
    • Windsurf.me
Re: Search by username?
« Reply #11 on: March 07, 2012, 11:39:07 PM »

Yes, but in my offline copy. I try not to fiddle with the live one except when I have the time to fix it after I break it. ;)
Logged
It is a mistake to think you can solve any major problems just with potatoes.

lurkalot

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 792
  • +Tinyportal Support team. +SMFArcade support team.
Re: Re: Search by username?
« Reply #12 on: March 08, 2012, 12:22:03 AM »

Any reports / confirmation that it works in other galleries (in unbridged and bridged ones) are welcome, so that feature can be added back to Coppermine.

Works for me Andre, on my testsite SMF 2.0.2 bridged with Coppermine 1.5.18.  Thanks for doing this, I was hoping you'd add it back in.  ;)
Logged
Running SMF 2.0.11  / Tinyportal 1.2, bridged with Coppermine 1.5.34, plus cpmfetch 2.0.0

heavensportal

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 240
    • The Fantasy Attic
Re: Search by username?
« Reply #13 on: March 08, 2012, 01:20:54 AM »

thank you for this code, will give it a try later tonight.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15037
Re: Search by username?
« Reply #14 on: March 08, 2012, 10:22:06 AM »

Unfortunately the language string has also been removed. I just compared the available language files for cpg1.4.x and cpg1.5.x. I think we can add that feature back to cpg1.5.x as well, as 31 of 33 available languages in cpg1.5.x also exist in cpg1.4.x.
Logged

heavensportal

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 240
    • The Fantasy Attic
Re: Re: Search by username?
« Reply #15 on: March 08, 2012, 10:43:25 AM »

Unfortunately the language string has also been removed. I just compared the available language files for cpg1.4.x and cpg1.5.x. I think we can add that feature back to cpg1.5.x as well, as 31 of 33 available languages in cpg1.5.x also exist in cpg1.4.x.

do you mean for the galleries that do not use english default or something else that I should add once I get the code edited into the files
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15037
Re: Search by username?
« Reply #16 on: March 08, 2012, 10:50:35 AM »

Just add the code as described. The language string is hard-coded in that example.


My last post was a reply to lurkalot's:
I was hoping you'd add it back in

Sorry for the confusion.
Logged

heavensportal

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 240
    • The Fantasy Attic
Re: Search by username?
« Reply #17 on: March 08, 2012, 11:00:06 AM »

ok and don't worry I confuse easy
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15037
Re: Search by username?
« Reply #18 on: March 08, 2012, 12:05:34 PM »

The current code change produces an error when "owner name" isn't selected. Additionally, the search result file count is wrong. Will post updated code for include/search.inc.php soon.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15037
Re: Search by username?
« Reply #19 on: March 08, 2012, 12:13:03 PM »

Step 1 and 2 stay the same.


3. Open include/search.inc.php, find
Code: [Select]
$allowed = array('title', 'caption', 'keywords', 'filename', 'pic_raw_ip', 'pic_hdr_ip', 'user1', 'user2', 'user3', 'user4');and below, add
Code: [Select]
global $cpg_udb;
// Use actual column name for search by owner name
if ($USER['search']['params']['owner_name']) {
    $USER['search']['params'][$cpg_udb->field['username']] = true;
    $allowed[] = $cpg_udb->field['username'];
}

find
Code: [Select]
            $query = "SELECT COUNT(*) FROM {$CONFIG['TABLE_PICTURES']} AS p
                WHERE $sql
                AND ($sort_order)";
and replace with
Code: [Select]
            $query = "SELECT COUNT(*) FROM {$CONFIG['TABLE_PICTURES']} AS p
                LEFT JOIN {$cpg_udb->usertable} AS u ON p.owner_id = u.{$cpg_udb->field['user_id']}
                WHERE $sql
                AND ($sort_order)";

find
Code: [Select]
            $query = "SELECT * FROM {$CONFIG['TABLE_PICTURES']} AS p WHERE " . $sql;

            $temp = str_replace('SELECT *', 'SELECT COUNT(*)', $query);
and replace with
Code: [Select]
            $query = "SELECT p.*, u.{$cpg_udb->field['username']} AS owner_name FROM {$CONFIG['TABLE_PICTURES']} AS p
            LEFT JOIN {$cpg_udb->usertable} AS u ON p.owner_id = u.{$cpg_udb->field['user_id']}
            WHERE " . $sql;

            $temp = str_replace("SELECT p.*, u.{$cpg_udb->field['username']} AS owner_name", 'SELECT COUNT(*)', $query);
Logged
Pages: [1] 2   Go Up
 

Page created in 0.076 seconds with 19 queries.