----------------- [ Index ] -----------------
----------------- [ Introduction ] -----------------This mod replaces user selection drop down menu with text input field in ACP (Admin Control Panel). It will suggest user names while you type. If entered user name is not correct, administrator's will be used instead.
There is a side effect in this mod: if you type incorrect/non-existing user name and submit the forum, it will use your name instead without any warnings.
For the sake of experiment, I've tested this mod with over 2M members on my local computer. The result was: no performance lose, pages open instantly (except for "Send email" menu) and suggestions showed up with no lag.
But, unless you have lots of members, you probably don't need this mod.
P.S.
This mod uses
Yahoo! UI Library: AutoComplete javascript.
----------------- [ Screenshots ] -----------------Inline completing
Using wildcard
*
----------------- [ Changed files ] -----------------admin/admin_functions.php----------------- [ New files ] -----------------admin/userfind.php
admin/userfind.css
----------------- [ Installation ] -----------------Step_1 | Download attached package. Extract files and upload them to your 4images folder, preserving this tree structure: admin/userfind.php admin/userfind.css
|
|
|
Step_2 | Open admin/admin_functions.php Find: </head>
Insert ABOVE:
<!-- Combo-handled YUI CSS files: --> <link rel="stylesheet" type="text/css" href="<?php echo ROOT_PATH; ?>admin/userfind.css"> <!-- Combo-handled YUI JS files: --> <script type="text/javascript" src="http://yui.yahooapis.com/combo?2.6.0/build/yahoo/yahoo-min.js&2.6.0/build/event/event-min.js&2.6.0/build/connection/connection-min.js&2.6.0/build/dom/dom-min.js&2.6.0/build/datasource/datasource-min.js&2.6.0/build/autocomplete/autocomplete-min.js"></script>
|
|
|
Step_2.1 | Find:function show_user_select_row($title, $user_id, $i = 0) {
Replace it with:/* MOD ajax user select start replace
function show_user_select_row($title, $user_id, $i = 0) { */ $user_id_name_input = "user_id"; if (isset($HTTP_POST_VARS['user_id_name_input'])) { $user_id_name_input = $HTTP_POST_VARS['user_id_name_input']; } if (isset($HTTP_POST_VARS['user_id_name_i'])) { $n = intval($HTTP_POST_VARS['user_id_name_i']); for ($i = 0; $i <= $n; $i++) { if (isset($HTTP_POST_VARS['user_id_name_'.$i])) { if (isset($HTTP_POST_VARS['user_id_name_array']) && $HTTP_POST_VARS['user_id_name_array']) { $HTTP_POST_VARS[$user_id_name_input][$i] = get_user_id_by_name($HTTP_POST_VARS['user_id_name_'.$i]); } else { $HTTP_POST_VARS[$user_id_name_input.'_'.$i] = get_user_id_by_name($HTTP_POST_VARS['user_id_name_'.$i]); } } } } elseif (isset($HTTP_POST_VARS['user_id_name'])) { $HTTP_POST_VARS[$user_id_name_input] = get_user_id_by_name($HTTP_POST_VARS['user_id_name']); } function get_user_id_by_name($user_name) { global $site_db, $user_table_fields; $sql = "SELECT ".get_user_table_field("", "user_id")." FROM ".USERS_TABLE." WHERE ".get_user_table_field("", "user_name")." = '".$user_name."'"; $result = $site_db->query_firstrow($sql); return @$result['user_id']; }
function show_user_select_row($title, $user_id, $i = "", $size = 0, $input = "user_id", $array = 0, $orig = 0, $full = 1) { global $error, $lang, $HTTP_POST_VARS, $site_db, $user_table_fields, $user_select_row_cache, $site_sess, $textinput_size; if ($orig) { return _show_user_select_row($title, $user_id, $i); } $user_id_name = ""; if (isset($error[$input.'_'.$i]) || isset($error[$input])) { $title = sprintf("<span class=\"marktext\">%s *</span>", $title); } if (!$size) { $size = $textinput_size; } if (!$user_id) { $user_id = 0; } $user_id_array = array($user_id); if (isset($HTTP_POST_VARS[$input.'_'.$i])) { $user_id_array[] = $HTTP_POST_VARS[$input.'_'.$i]; } elseif ($array && isset($HTTP_POST_VARS[$input][$i])) { $user_id_array[] = $HTTP_POST_VARS[$input][$i]; } elseif (isset($HTTP_POST_VARS[$input]) && !is_array($HTTP_POST_VARS[$input])) { $user_id_array[] = $HTTP_POST_VARS[$input]; } if (isset($HTTP_POST_VARS['user_id_name_'.$i])) { $user_id_name = stripslashes($HTTP_POST_VARS['user_id_name_'.$i]); } elseif (isset($HTTP_POST_VARS['user_id_name'])) { $user_id_name = stripslashes($HTTP_POST_VARS['user_id_name']); } $sql = "SELECT ".get_user_table_field("", "user_name")." FROM ".USERS_TABLE." WHERE ".get_user_table_field("", "user_id")." IN (".implode(",", $user_id_array).")"; if ($result = $site_db->query_firstrow($sql)) { $user_id_name = $result['user_name']; } if ($full) { echo "<tr class=\"".get_row_bg()."\">\n<td><p class=\"rowtitle\">".$title."</p></td>\n"; echo "<td>\n"; } if ($input != "user_id") { echo "<input type=\"hidden\" name=\"user_id_name_input\" value=\"".$input."\">\n"; } echo "<input type=\"hidden\" name=\"user_id_name_array\" value=\"".$array."\">\n"; if ($i !== "") { echo "<input type=\"hidden\" name=\"user_id_name_i\" value=\"".$i."\">\n"; $i = "_".$i; } echo '<div class="yui-ac" style="width:'.($size/2).'em; padding-bottom:2em;">'; echo "<input type=\"text\" name=\"user_id_name".$i."\" id=\"user_id_name".$i."\" value=\"".format_text($user_id_name, 2)."\" size=\"".$size."\" style=\"width:".($size/2)."em;\" class=\"yui-ac-input\">\n"; echo '
<div id="usernameauto'.$i.'" class="yui-ac-container" style="width:'.($size/2).'em;"></div> </div> <script type="text/javascript" language="javascript"> YAHOO.example.BasicRemote = function() { // Use an XHRDataSource var oDS = new YAHOO.util.XHRDataSource("'.ROOT_PATH.'admin/userfind.php"); // Set the responseType oDS.responseType = YAHOO.util.XHRDataSource.TYPE_TEXT; // Define the schema of the delimited results oDS.responseSchema = { recordDelim: "\n", fieldDelim: "\t" }; // Enable caching oDS.maxCacheEntries = 10; // Instantiate the AutoComplete var oAC = new YAHOO.widget.AutoComplete("user_id_name'.$i.'", "usernameauto'.$i.'", oDS); // Enable type ahead oAC.typeAhead = false; // Enable a drop-shadow under the container element oAC.useShadow = true; // Display up to 30 results in the container oAC.maxResultsDisplayed = 30; return { oDS: oDS, oAC: oAC }; }(); </script>'; if ($full) { echo "</td>\n</tr>\n"; } }
function _show_user_select_row($title, $user_id, $i = 0) { /* MOD ajax user select end replace */
|
----------------- [ Tweaks ] -----------------1. | If you want inline auto complete (automatically selects and enters first name from the list) then set to true in admin/admin_functions.php:
// Enable type ahead oAC.typeAhead = false;
|
|
|
2. | By default first 30 names will be showed. You can change that number in admin/admin_functions.php:
// Display up to 30 results in the container oAC.maxResultsDisplayed = 30;
And in admin/userfind.php:
LIMIT 30";
|
----------------- [ Version history ] -----------------v1.1 (2008-11-21)
- Added support for non-standard use of the function. Needed for
[MOD] Batch Copy/Move/Edit Images. Redo
Step 2.1v1.0 (2008-11-21)
- First release