I am developing a hack to allow xoopsmembers to be searched by group and rank.
I am posting this unfinished hack here in case other people better at php want to help me to develop this.
Current problems to solve:---------------------------
1) the array within the array: user groups within the userdata array- how can I access these for both matching in the search, and for displaying in the smarty template?
2) XoopsFormSelectGroup- how to use?
(see below for where I want to use these)
So far I have got the searchresults section of index.php to be able to access this information, as follows:
section to get groups(added just after
$start = (!empty($HTTP_POST_VARS['start'])) ? intval($HTTP_POST_VARS['start']) : 0;
$member_handler =& xoops_gethandler('member');
$total = $member_handler->getUserCount($criteria);
//----------------------hack show groups by samuels- edited by simonvl------------------------
function GetGroupsNames ($uid)
{
$member_handler =& xoops_gethandler('member');
$User= new XoopsUser($uid);
$user_groups=$User->getGroups();
$count = count($user_groups);
//$groups =& $member_handler->getGroups();
for ($i=0;$i<$count;$i++)
{
$thisgroup =& $member_handler->getGroup($user_groups[$i]);
$g[$i]=$thisgroup->getVar('name');
}
return ($g);
}
This gets the groups each user found by the search is subscribed to and pust them in the array $g, where $g['0'] is the first group the user was assigned, etc.
The next bit puts this info into the $userdata array which xoopsmembers uses to store info and put it into a smarty variable as an array.Added after
$userdata['id'] = $foundusers[$j]->getVar("uid");
$userdata['groups'] = GetGroupsNames($userdata['id']);
$usergroupinfo = $userdata['groups'];
echo $usergroupinfo['0']; //just for testing
// this bit thanks to Mithrandir:
$rank = $foundusers[$j]->rank();
$userdata['rank'] = $rank['title'];
$rankinfo = $userdata['rank'];
echo $rankinfo; //just for testing
At the moment, this successfully echos the rank information of each user, but of course returns "array" for the group.
using this for the search formI can add a standard text matching search field for user ranks, or a selection box, or a hidden field that only lets visitors see certain ranked users- this I might use for a custom implementation of ranks on my site as a classification system.
Now, I want to select groups and put their name into the search form, to find members in that group. Should I use
XoopsFormSelectGroup($caption, $name, $include_anon=false, $value=null, $size=1, $multiple=false) (and if so, how!)
or should I use a normal xoopsformselect element and name the groups (making the implementation less flexible)?
Also, how do you get it to try to match the entry to all of the values in the array $g?
Ultimately, I would like members to be able to search all members, but anonymous visitors to be only allowed to search (and view) special members, moderators and admins- these are the society committee members at chillout.org.uk
Anyone want to help out here?
Thanks in advance
Simon