PDA

View Full Version : Custom value search in userDB back to profile for adminCP like (Quick Email Finder)


Skyrider
05-30-2015, 11:32 AM
I was wondering if there's an easy way for me to add a code into the admin_index_xx hook to search inside a specific field and result to the users profile in admincp? Much like the Quick Email Finder, but rather than the email, searching another field inside the user table. I attempted to replicate the code of Quick Email Finder and try to make it work, but thus far not working.

Not referring specific which field, as I have multiple fields in mind in the end. I was just hoping someone could push me into the right direction. For what it's worth, these fields inside the user table is not default from a vB installation.

--------------- Added 1433074760 at 1433074760 ---------------

For those who are confused. I merely wish to create a custom MySQL field search, in a specific table resulting in the username as a result from the AdminCP. Exactly like the Quick Email Finder, or the username finder, etc.

Skyrider
07-10-2015, 02:48 PM
Any help regarding this would still be nice :). Can also be a custom PHP file with database searches.

kh99
07-11-2015, 10:58 AM
Hmm, I'm not sure why it would be a problem to seach the profile fields the same way as emails, except for the fact that the added profile fields are in the userfield table instead of the user table. But you could do a JOIN to add those fields on.

Skyrider
07-11-2015, 01:15 PM
What exactly do you mean with userfield?

If I would take an example here:
https://vborg.vbsupport.ru/showthread.php?t=228667

<![CDATA[if (can_administer('canadminusers')) { print_table_start(); print_table_header($vbphrase['quick_email_finder']); print_label_row($vbphrase['quick_email_finder'], ' <form action="user.php?do=find" method="post" style="display:inline"> <input type="hidden" name="s" value="' . $vbulletin->session->vars['sessionhash'] . '" /> <input type="hidden" name="adminhash" value="' . ADMINHASH . '" /> <input type="hidden" name="do" value="find" /> <input type="text" class="bginput" name="user[email]" size="30" tabindex="1" /> <input type="submit" value=" ' . $vbphrase['find'] . ' " class="button" tabindex="1" /> </form> ', '', 'top', NULL, false ); print_table_footer(2, '', '', false); }]]>

If I take a look at the code and PHP, the email checks the user table on the email field and results back to the user profile.

Do you happen to have an example? I might as well show which field I'm trying to search.

Within the USER table there's a "steam_link" field. With example of how it looks like:

76561197983696188|0|0

^ Would be my steamID. I'd like that ID to be searchable in either a PHP file or within the adminCP that when I enter 76561197983696188 it'll go back to my profile. The |0|0 at the end should be ignored though, as in the search shouldn't take that into consideration in the results.

kh99
07-11-2015, 01:36 PM
OK, I think I misunderstood you. I thought you said you tried to take existing code from the admincp and change it to search for other fields. But you were talking about a mod that uses admicp/user.php to do a specific search. Anyway, the do='find' section of user.php looks like it should be able to do a search for any field in any of the existing columns of the user tables, or in custom profile fields. But if I understand you, you're saying you've added a column to the user table and now you want to be able to search it? Then if you want to do it the way that mod does it (using user.php), I think you'd need to modify the fetch_user_search_sql() function in adminfunctions_user.php to be able to add the condition to search your field.

Skyrider
07-11-2015, 01:57 PM
Thanks, checking out that PHP file right now. From the looks of it, I assume I need to add a row like this:

$condition .= iif($user['email'], " AND {$prefix}email LIKE '%" . $vbulletin->db->escape_string_like($user['email']) . "%'");

Do I need to add more rows, like the print_input_row?

kh99
07-11-2015, 02:11 PM
Oh right. I guess you'd at least want to display that field on the results page. It looks like that's in the do = 'find2' section. Maybe you just need to add ifs for your field and add it to the $header and $cell arrays like the others are doing, but I don't know. You might also want it on the standard user edit page.

From your other posts here I'm guessing you're capable of figuring it out, probably even faster than I could :) Or maybe someone else already knows.

Skyrider
07-11-2015, 02:19 PM
Oh right. I guess you'd at least want to display that field on the results page. It looks like that's in the do = 'find2' section. Maybe you just need to add ifs for your field and add it to the $header and $cell arrays like the others are doing, but I don't know. You might also want it on the standard user edit page.

From your other posts here I'm guessing you're capable of figuring it out, probably even faster than I could :) Or maybe someone else already knows.
The steam_link result itself doesn't really matter to me. What I'm aiming for is that when I search for a field entry (field: steam_link) with example entry: 76561197983696188 that it forwards me to the users profile instead :).

So in short: AdminCP -> Search for 76561197983696188 -> ID found on a users profile -> Redirects the users VBulletin Profile

Not sure if this'll work though:
$condition .= iif($user['steam_link'], " AND {$prefix}steam_link LIKE '%" . $vbulletin->db->escape_string_like($user['steam_link']) . "%'");


I don't mind if it's a separated custom PHP file (like creating your own PHP page on vBulletin) that gives the same result. As long it does what I'm aiming for :D.

kh99
07-11-2015, 02:24 PM
Well, it looks like the results page redirects to the user profile if there is only one result, so I think you're all set there.

Skyrider
07-11-2015, 02:29 PM
Indeed I am, thanks :). It's working perfectly. Thanks for the tip where to look for. Really appreciate it.

Now I have to figure out how to create a secondary row within the adminCP so below the "quick email finder" there's "quick ID finder".

EDIT, found it.. thanks! :D