Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1] 2   Go Down

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

0 Members and 1 Guest are viewing this topic.

Streamer

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 26
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: 26
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: 15764
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

phill104

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 4885
    • 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: 15764
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: 26
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: 15764
Re: Search by username?
« Reply #7 on: March 07, 2012, 11:43:36 am »

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: 15764
Re: Search by username?
« Reply #8 on: March 07, 2012, 11:46:42 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.
Logged

phill104

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 4885
    • Windsurf.me
Re: Search by username?
« Reply #9 on: March 07, 2012, 03: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: 15764
Re: Search by username?
« Reply #10 on: March 07, 2012, 03:49:32 pm »

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

phill104

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 4885
    • Windsurf.me
Re: Search by username?
« Reply #11 on: March 07, 2012, 10: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: 947
  • +Tinyportal Support team.
Re: Re: Search by username?
« Reply #12 on: March 07, 2012, 11:22:03 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.

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.1.4  / Tinyportal 3.0.0, bridged with Coppermine 1.6.25, plus cpmfetch 2.0.0

heavensportal

  • Coppermine frequent poster
  • ***
  • Country: 00
  • Offline Offline
  • Posts: 259
    • The Fantasy Attic
Re: Search by username?
« Reply #13 on: March 08, 2012, 12: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: 15764
Re: Search by username?
« Reply #14 on: March 08, 2012, 09: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
  • ***
  • Country: 00
  • Offline Offline
  • Posts: 259
    • The Fantasy Attic
Re: Re: Search by username?
« Reply #15 on: March 08, 2012, 09: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: 15764
Re: Search by username?
« Reply #16 on: March 08, 2012, 09: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
  • ***
  • Country: 00
  • Offline Offline
  • Posts: 259
    • The Fantasy Attic
Re: Search by username?
« Reply #17 on: March 08, 2012, 10:00:06 am »

ok and don't worry I confuse easy
Logged

Αndré

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

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: 15764
Re: Search by username?
« Reply #19 on: March 08, 2012, 11:13:03 am »

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.034 seconds with 19 queries.