1 (edited by 2008-08-24 13:13:04)

Topic: [HACK] sort users

Name: sort users
Author: NyNe
CuteNews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description: Sort your users by username instead of by registration date.
Instructions:
open editusers.mdu

find:

    <tr>
    <td width=130 bgcolor="#F7F6F4">
     [u]Username[/u]
    <td width=197 bgcolor="#F7F6F4">
    [u]registration date[/u]
    <td width=2 bgcolor="#F7F6F4">
     
    <td width=83 bgcolor="#F7F6F4">
    [u]written news[/u]
    <td width=132 bgcolor="#F7F6F4">
    [u]Access Level[/u]
    <td width=93 bgcolor="#F7F6F4">
    [u]action[/u]
    </tr>';

    $all_users = file("./data/users.db.php");


replace with:

// Sort users v1.0 - Start addblock
    <tr>
    <td width=120 bgcolor="#F7F6F4">
     [u]Username[/u] [[url=http://cutephp.com/forum/index.php?mod=editusers&action=list&sortus=2&sortad=a]A[/url]][[url=http://cutephp.com/forum/index.php?mod=editusers&action=list&sortus=2&sortad=d]D[/url]]
    <td width=220 bgcolor="#F7F6F4">
    [u]registration date[/u] [[url=http://cutephp.com/forum/index.php?mod=editusers&action=list&sortus=0&sortad=a]A[/url]][[url=http://cutephp.com/forum/index.php?mod=editusers&action=list&sortus=0&sortad=d]D[/url]]
    <td width=2 bgcolor="#F7F6F4">
     
    <td width=90 bgcolor="#F7F6F4">
    [u]posts[/u] [[url=http://cutephp.com/forum/index.php?mod=editusers&action=list&sortus=6&sortad=a]A[/url]][[url=http://cutephp.com/forum/index.php?mod=editusers&action=list&sortus=6&sortad=d]D[/url]]
    <td width=132 bgcolor="#F7F6F4">
    [u]Access Level[/u] [[url=http://cutephp.com/forum/index.php?mod=editusers&action=list&sortus=1&sortad=a]A[/url]][[url=http://cutephp.com/forum/index.php?mod=editusers&action=list&sortus=1&sortad=d]D[/url]]
    <td width=93 bgcolor="#F7F6F4">
    [u]action[/u]
    </tr>';

    $all_users = file("./data/users.db.php");
if (isset($sortus)) {
if (!function_exists('sortcmp')) {
 function sortcmp($a, $b) {
  global $all_users, $sortus;

  $users_a = explode('|', $all_users[$a]);
  $users_b = explode('|', $all_users[$b]);

  return strnatcasecmp($users_a[$sortus], $users_b[$sortus]);
 }
}
uksort($all_users, 'sortcmp');
if ($sortad=="d") { $all_users = array_reverse($all_users); }
Unset($sortus);
}
// Sort users v1.0 - End addblock

credit to the sort news hack (this code was pretty much ripped and made from it)