1
DaBoyz
XoopsFormSelectUser
  • 2004/1/13 0:50

  • DaBoyz

  • Just popping in

  • Posts: 79

  • Since: 2002/8/8 1


How could I sort the users by alphabetic order using this function ?

$xoopsid_select = new XoopsFormSelectUser(_MA_DBV_PLAYERXOOPSID,'player_xoopsid',yes,$player_xoopsid,1,false);
$form->addElement($xoopsid_select);



2
Mithrandir
Re: XoopsFormSelectUser

Unfortunately, you'd have to hack that function to include a criteria element to pass on to the XoopsMemberHandler::getUserList($criteria = false) function. So no quick fix for that one.

3
DaBoyz
Re: XoopsFormSelectUser
  • 2004/1/13 11:44

  • DaBoyz

  • Just popping in

  • Posts: 79

  • Since: 2002/8/8 1


Thanks for the answer ...

So this one is going to join the others "Xoops Core redone" list & class functions ... ... half of used actually ...

4
DaBoyz
Re: XoopsFormSelectUser
  • 2004/1/13 15:00

  • DaBoyz

  • Just popping in

  • Posts: 79

  • Since: 2002/8/8 1


OK, I did it ...

class XoopsDBLists extends XoopsLists {

// ----- DISPLAY USER LIST SORT BY NAME ----- //
// To replace displayUsers in modules/system/admin/users.php

function &getUserList() {
    global 
$xoopsDB;
    
$myts =& MyTextSanitizer::getInstance();
    
$sql "SELECT uid,uname FROM ".$xoopsDB->prefix("users")." ORDER BY uname";
    
$result=$xoopsDB->query($sql) or die(mysql_error());
    
$user_list = array();
    
$user_list[] = '----';
    while (list(
$uid,$uname) = $xoopsDB->fetchRow($result)) {
        
$user_list[trim($uid)] = $myts->makeTboxData4Show($uname);
    }
    
reset($user_list);
    return 
$user_list;    
}

}


And you could display it with :

// Users List
    
$user_array XoopsDBLists::getUserList();
    
$xoopsid_select = new XoopsFormSelect(_MA_DBV_PLAYERXOOPSID,'player_xoopsid',$player_xoopsid);
    
$xoopsid_select->addOptionArray($user_array);
    
$form->addElement($xoopsid_select);

5
Mithrandir
Re: XoopsFormSelectUser

After a bit of digging, I think you could also do it like this:
//Make a new Criteria
$ordercrit = new Criteria();
//Set it to sort by uname (NOT TESTED) Default is ASC
$ordercrit->setSort('uname');
//Get all users ordered by uname ASC
$user_array XoopsMemberHandler::getUserList($ordercrit);
$xoopsid_select = new XoopsFormSelect(_MA_DBV_PLAYERXOOPSID,'player_xoopsid',$player_xoopsid);
$xoopsid_select->addOptionArray($user_array);
$form->addElement($xoopsid_select);


But I'm not entirely sure if it will work correctly when there is no "WHERE" clause with a column - but at least you won't have to hack/add functions.

6
DaBoyz
Re: XoopsFormSelectUser
  • 2004/1/13 16:11

  • DaBoyz

  • Just popping in

  • Posts: 79

  • Since: 2002/8/8 1


It doesn't work for me ...

And I need also a blank value because you are not obliged to choose a member.

There is a little bug (previous post also modified) :

I change :

$sql "SELECT uid,uname FROM ".$xoopsDB->prefix("users")."";

to
$sql "SELECT uid,uname FROM ".$xoopsDB->prefix("users")." ORDER BY uname";


And delete :

asort($user_list);


Otherwise, you have the Member name sort by name but case sensitive (B,D,b,d,...).

7
hunden
Re: XoopsFormSelectUser
  • 2005/9/10 7:52

  • hunden

  • Just popping in

  • Posts: 23

  • Since: 2005/5/21


Hi!

Maybe a stupid question but.. which files you guys changed??

8
bricex
Re: XoopsFormSelectUser
  • 2005/9/30 19:24

  • bricex

  • Just popping in

  • Posts: 71

  • Since: 2003/1/16


can u explain which file has to be modified?
thanks
...

9
highlander
Re: XoopsFormSelectUser
  • 2005/9/30 19:50

  • highlander

  • Not too shy to talk

  • Posts: 151

  • Since: 2004/12/5


DaBoyz is modifing the following file
modules/system/admin/users.php

greetings Highlander
So, I'm in the park wondering why frisbees get larger as they get closer when suddenly, it hits me...
http://www.AnimalPedigree.com

Login

Who's Online

392 user(s) are online (259 user(s) are browsing Support Forums)


Members: 0


Guests: 392


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits