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.
Please post a link to your gallery (http://forum.coppermine-gallery.net/index.php/topic,55415.msg270616.html#msg270616) as requested by board rules.
Sorry, forgot that. http://www.perhokalastajat.net/kuvagalleria/
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.
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.
We dropped the column 'owner_name' some time ago. I think that was the reason. A simple JOIN can solve that in standalone versions.
Ok, thanks for the answer.
This seems to work:
1. Open search.php, find
$customs
$ip
and above, add
<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> </td>
</tr>
2. Open thumbnails.php, find
$allowed = array('title', 'caption', 'keywords', 'filename', 'pic_raw_ip', 'pic_hdr_ip', 'user1', 'user2', 'user3', 'user4', 'type');
and replace with
$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
$allowed = array('title', 'caption', 'keywords', 'filename', 'pic_raw_ip', 'pic_hdr_ip', 'user1', 'user2', 'user3', 'user4');
and below, add
// 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
$query = "SELECT COUNT(*) FROM {$CONFIG['TABLE_PICTURES']} AS p
WHERE $sql
AND ($sort_order)";
and replace with
$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
$query = "SELECT * FROM {$CONFIG['TABLE_PICTURES']} AS p WHERE " . $sql;
and replace with
$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;
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.
Seems to work well for me Andre.
I assume you tested it in your Joomla bridged gallery?
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. ;)
Quote from: Αndré 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.
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. ;)
thank you for this code, will give it a try later tonight.
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.
Quote from: Αndré 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.
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
Just add the code as described. The language string is hard-coded in that example.
My last post was a reply to lurkalot's:
Quote from: lurkalot on March 07, 2012, 11:22:03 PM
I was hoping you'd add it back in
Sorry for the confusion.
ok and don't worry I confuse easy
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.
Step 1 and 2 stay the same (http://forum.coppermine-gallery.net/index.php/topic,66818.msg358834.html#msg358834).
3. Open include/search.inc.php, find
$allowed = array('title', 'caption', 'keywords', 'filename', 'pic_raw_ip', 'pic_hdr_ip', 'user1', 'user2', 'user3', 'user4');
and below, add
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
$query = "SELECT COUNT(*) FROM {$CONFIG['TABLE_PICTURES']} AS p
WHERE $sql
AND ($sort_order)";
and replace with
$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
$query = "SELECT * FROM {$CONFIG['TABLE_PICTURES']} AS p WHERE " . $sql;
$temp = str_replace('SELECT *', 'SELECT COUNT(*)', $query);
and replace with
$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);
ok thanks
After some thorough testing I think the modification is mature enough to go back to even the cpg1.5.x branch. Committed code changes and corresponding language strings in SVN revision 8321.
Please report any unexpected behavior as detailed as possible (using a bridged or unbridged gallery, which options have you checked, what have you searched for, ...).
after your fine edit instructions I went into search> entered name of artist > unchecked all and checked username then clicked search and yippeeee I got all his images like before
thank you so very much
no problems what so ever
Thanks a lot for adding search by user to 1.5.20!
Works nice but I don't know if it's necessary to be case sensitive?
The search isn't case sensitive for me. It may be case sensitive for you, depending on which collations you used for your tables.
Unfortunately a user in the German support board reported (http://forum.coppermine-gallery.net/index.php/topic,74857.0.html) that the search is broken in his bridged gallery, because the Coppermine DB user has no access to query the phpBB database.
Quote from: Αndré on May 02, 2012, 02:25:49 PM
Unfortunately a user in the German support board reported (http://forum.coppermine-gallery.net/index.php/topic,74857.0.html) that the search is broken in his bridged gallery, because the Coppermine DB user has no access to query the phpBB database.
Added check in SVN revision 8391 (http://coppermine.svn.sourceforge.net/viewvc/coppermine?view=revision&revision=8391). It fixes the above issue, but also disables the search by user name if there are no sufficient MySQL permissions.