versprochen ist versprochen

Ich poste erst einmal die veränderte memberlist.php
Vorher werde ich noch einmal kurz beschreiben, warum ich das gemacht habe. Es geht mir darum, ein custom_profile_field sortierbar zu machen, weil Mitglieder des Forums u.U. ein Interesse daran haben, sich persönlich zu treffen - und da scheint eine Sortierung nach Plz/Wohnort sinnvoll zu sein.
Wenn das mit den code-Änderungen "zu wild" ist, dann gebt bitte Bescheid. Ansonsten werde ich auch noch die zugehörige Änderungen an der html-Datei posten und beschreiben, was ich noch gemacht habe.
Ach ja: ohne Gewähr und Gewehr

Gruß und schönen 1. Advent
cpg
phpBB3/memberlist.php
suche
Code: Alles auswählen
case 'livesearch':
$username_chars = $request->variable('username', '', true);
$sql = 'SELECT username, user_id, user_colour
FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_type', $user_types) . '
AND username_clean ' . $db->sql_like_expression(utf8_clean_string($username_chars) . $db->get_any_char());
$result = $db->sql_query_limit($sql, 10);
$user_list = array();
while ($row = $db->sql_fetchrow($result))
{
$user_list[] = array(
'user_id' => (int) $row['user_id'],
'result' => $row['username'],
'username_full' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
'display' => get_username_string('no_profile', $row['user_id'], $row['username'], $row['user_colour']),
);
}
$db->sql_freeresult($result);
$json_response = new \phpbb\json_response();
$json_response->send(array(
'keyword' => $username_chars,
'results' => $user_list,
));
break;
ersetze mit
Code: Alles auswählen
case 'livesearch':
$username_chars = $request->variable('username', '', true);
$sql = 'SELECT username, user_id, user_colour, location_mysearch
FROM ' . USERS_TABLE . ' u
LEFT JOIN " . PROFILE_FIELDS_DATA_TABLE . " fd ON (u.user_id = fd.user_id)
WHERE ' . $db->sql_in_set('user_type', $user_types) . '
AND username_clean ' . $db->sql_like_expression(utf8_clean_string($username_chars) . $db->get_any_char());
$result = $db->sql_query_limit($sql, 10);
$user_list = array();
while ($row = $db->sql_fetchrow($result))
{
$user_list[] = array(
'user_id' => (int) $row['user_id'],
'result' => $row['username'],
'location_mysearch' => $row['location_mysearch'],
'username_full' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
'display' => get_username_string('no_profile', $row['user_id'], $row['username'], $row['user_colour']),
);
}
$db->sql_freeresult($result);
$json_response = new \phpbb\json_response();
$json_response->send(array(
'keyword' => $username_chars,
'results' => $user_list,
));
break;
Code: Alles auswählen
$user_list = array();
while ($row = $db->sql_fetchrow($result))
{
$user_list[] = array(
'user_id' => (int) $row['user_id'],
'result' => $row['username'],
'username_full' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
'display' => get_username_string('no_profile', $row['user_id'], $row['username'], $row['user_colour']),
);
}
Code: Alles auswählen
$user_list = array();
while ($row = $db->sql_fetchrow($result))
{
$user_list[] = array(
'user_id' => (int) $row['user_id'],
'result' => $row['username'],
'location_mysearch' => $row['location_mysearch'],
'username_full' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
'display' => get_username_string('no_profile', $row['user_id'], $row['username'], $row['user_colour']),
);
}
Code: Alles auswählen
$sort_key_text = array('a' => $user->lang['SORT_USERNAME'], 'c' => $user->lang['SORT_JOINED'], 'd' => $user->lang['SORT_POST_COUNT']);
$sort_key_sql = array('a' => 'u.username_clean', 'c' => 'u.user_regdate', 'd' => 'u.user_posts');
Code: Alles auswählen
$sort_key_text = array('a' => $user->lang['SORT_USERNAME'], 'c' => $user->lang['SORT_JOINED'], 'd' => $user->lang['SORT_POST_COUNT'], 'n' => $user->lang['SORT_LOCATION_MYSEARCH']);
$sort_key_sql = array('a' => 'u.username_clean', 'c' => 'u.user_regdate', 'd' => 'u.user_posts', 'n' => 'u.location_mysearch');
$sort_key_text['n'] = $user->lang['LOCATION_MYSEARCH'];
$sort_key_sql['n'] = 'pf_location_mysearch';
Code: Alles auswählen
$search_params = array('username', 'email', 'jabber', 'search_group_id', 'joined_select', 'active_select', 'count_select', 'joined', 'active', 'count', 'ip');
Code: Alles auswählen
$search_params = array('username', 'location_mysearch', 'email', 'jabber', 'search_group_id', 'joined_select', 'active_select', 'count_select', 'joined', 'active', 'count', 'ip');
Code: Alles auswählen
$username = $request->variable('username', '', true);
$email = strtolower($request->variable('email', ''));
ersetze mit
Code: Alles auswählen
$username = $request->variable('username', '', true);
$location_mysearch = $request->variable('location_mysearch', '', true . '*');
$email = strtolower($request->variable('email', ''));
Code: Alles auswählen
$sql_where .= ($username) ? ' AND u.username_clean ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), utf8_clean_string($username))) : '';
Code: Alles auswählen
$sql_where .= ($username) ? ' AND u.username_clean ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), utf8_clean_string($username))) : '';
//next cpg
$sql_where .= mb_strtolower($location_mysearch) ? ' AND LOWER(pf_location_mysearch) ' . $db->sql_like_expression(str_replace('*', $db->any_char, mb_strtolower($location_mysearch,'utf-8'))) . ' ' : '';
Code: Alles auswählen
$sql_where .= ($search_group_id) ? " AND u.user_id = ug.user_id AND ug.group_id = $search_group_id AND ug.user_pending = 0 " : '';
Code: Alles auswählen
}
$sql_where .= mb_strtolower($location_mysearch) ? ' AND LOWER(pf_location_mysearch) ' . $db->sql_like_expression(str_replace('*', $db->any_char, mb_strtolower($location_mysearch,'utf-8'))) . ' ' : '';
$sql_where .= ($search_group_id) ? " AND u.user_id = ug.user_id AND ug.group_id = $search_group_id AND ug.user_pending = 0 " : '';
Code: Alles auswählen
'username' => array('username', '', true),
'email' => array('email', ''),
Code: Alles auswählen
'username' => array('username', '', true),
'location_mysearch' => array('location_mysearch', '', true. '*'),
'email' => array('email', ''),
Code: Alles auswählen
'USERNAME' => $username,
'EMAIL' => $email,
ersetze mit
Code: Alles auswählen
'USERNAME' => $username,
'LOCATION_MYSEARCH' => $location_mysearch,
'EMAIL' => $email,
Code: Alles auswählen
'S_INACTIVE' => $row['user_type'] == USER_INACTIVE,
'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $row['username']),
Code: Alles auswählen
'S_INACTIVE' => $row['user_type'] == USER_INACTIVE,
'S_LOCATION_MYSEARCH' => (isset($cp_row['row']) && sizeof($cp_row['row'])) ? true : false,
'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $row['username']),
Code: Alles auswählen
'U_SORT_USERNAME' => $sort_url . '&sk=a&sd=' . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a'),
Code: Alles auswählen
'U_SORT_USERNAME' => $sort_url . '&sk=a&sd=' . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a'),
'U_SORT_LOCATION_MYSEARCH' => $sort_url . '&sk=n&sd=' . (($sort_key == 'n' && $sort_dir == 'a') ? 'd' : 'a'),
Code: Alles auswählen
'U_LIST_CHAR' => $sort_url . '&sk=a&sd=' . (($sort_key == 'l' && $sort_dir == 'd') ? 'a' : 'd'),
ersetze mit
Code: Alles auswählen
'U_LIST_CHAR' => $sort_url . '&sk=a&sd=' . (($sort_key == 'l' && $sort_dir == 'd') ? 'a' : 'd'),
'LOCATION_MYSEARCH' => ($data['location_mysearch']) ? $data['location_mysearch'] : '',