TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

June 26, 2024, 09:19:53 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,280
  • Total Topics: 21,227
  • Online today: 319
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 274
  • Total: 274

ssi_membergroup function not working right

Started by npereira, March 19, 2008, 02:46:00 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

npereira

Hi,

I need to know how to set up the ssi in a PHPBOX so that I show all the members part of group ID 36, not only the ones on-line
Right now I have this:

require("/home/web/public_html/SSI.php");
ssi_membergroup($groupid = 36, $additional = 0, $sort = 1, $sortorder = 1, $output_method = 'echo');


But this does not work. It does not show ALL the members of that group which there is 12... it only shows 4 of them...?!?

Please help, Thanks

JPDeni

Where did you get the function? I don't find it in my SSI.php.

Maybe you could paste the function here so we're all working with the same code to start with.

npereira

it's part of a mod ssi function from SMF.
the code in SSI_membergroup.xml

<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
<id>SleePy:SSI_Membergroup</id>
<version>1.0</version>
<file name="$boarddir/SSI.php">
<operation>
<search position="end"></search>
<add><![CDATA[

// Show From all from a member group. Great for Rosters.
function ssi_membergroup($groupid = 1, $additional = 0, $sort = 1, $sortorder = 1, $output_method = 'echo')
{
global $db_prefix, $user_info, $scripturl, $modSettings, $txt, $sc;
//-- $mgroup = Group Number
//-- $Additional = Search Additional Groups as well
//-- $sort = How to sort the names. ID Number(2) or realname(1 default).
//-- $sortorder = Sort ASC or DESC

//Lets get some checks done for the sake of the script not returning errors
//if the groupids are array we need to make them valid.
if(is_array($groupid))
$groupid = array_map('intval',$groupid);

//Well the groupid is a single id.. lets make it valid..
if(!is_array($groupid))
$groupid = (int) $groupid;

//Either its off or its on.. Should also stop use of array..
if(($additional !=0 && $additional !=1) || ($sort !=2 && $sort !=1) || ($sortorder !=2 && $sortorder !=1))
fatal_error('Invalid Input for this ssi_function');

//We shouldn't be getting Group 0. Fix it by Showing Admin Group..
if($groupid == 0)
$groupid = 1;

//Set our output to something its better than nothing.
$membergroup = array();

//Find out if our groups we are looking at is in an array or not..
if(is_array($groupid))
{
//Array has multiple groups so if we want to search additional as well we have to loop it.
if(isset($additional) && $additional != 0)
{
//lets just clear additional instead of a new variable.
$additional = '';
foreach($groupid as $add)
$additional .= '
OR FIND_IN_SET('.$add.', additionalGroups)';
}
$request = db_query("
SELECT ID_MEMBER, realname, ID_GROUP
FROM {$db_prefix}members
WHERE ID_GROUP IN (" . implode(', ',$groupid) . ")".$additional."
ORDER BY '".($sort == 2 ? 'ID_MEMBER' : 'realname')."' ".($sortorder == 2 ? 'DESC' : 'ASC')."", __FILE__, __LINE__);
}
else
$request = db_query("
SELECT ID_MEMBER, realname, ID_GROUP
FROM {$db_prefix}members
WHERE ID_GROUP = " . $groupid . ($additional == 1 ? "
OR FIND_IN_SET(" . $groupid . ", additionalGroups)" : "")."
ORDER BY '".($sort == 2 ? 'ID_MEMBER' : 'realname')."' ".($sortorder == 2 ? 'DESC' : 'ASC')."", __FILE__, __LINE__);

//We got the query. Now lets get it into a nice little array..
while ($row = mysql_fetch_assoc($request))
$membergroup[] = array(
'id' => $row['ID_MEMBER'],
'name' => $row['realname']
);
mysql_free_result($request);

//If they dont want to echo.. So lets give it to them..
if ($output_method != 'echo')
return $membergroup;

//Well they want it echo so lets echo...
foreach ($membergroup as $mem)
echo '
<a href="'.$scripturl.'?action=profile;u='.$mem['id'].'" class="ssi_membergroup" id="ssi_member_'.$mem['id'].'">'.$mem['name'].'</a><br/>';
}

]]></add>
</operation>
</file>
</modification>

JPDeni

It might have been a bit better if you would have just posted the code from your SSI.php file. I figured it out, though.

I don't know why it wouldn't print out all of them. The code looks like it should work.

It might be easier if you used code to just display what you want.


global $db_prefix, $scripturl;

$request = db_query("
                SELECT ID_MEMBER, realname
                FROM {$db_prefix}members
                WHERE ID_GROUP = 36
                ORDER BY realname", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
  echo '
    <a href="'.$scripturl.'?action=profile;u='.$row['ID_MEMBER'].'">'.$row['realname'].'</a><br/>';

npereira

For some strange reason, your code also does not work.... only 2

JPDeni

Is your group 36 a post-based group or one that's assigned to members? If it's post-based, I don't think you're going to be able to get it at all.

If it's an assigned group, I've not got a clue why it wouldn't work.

bloc

#6
You need to set "additional" value to 1, not 0, so it searches the members which have that group as additional - not primary. Only 4 prob have it as primary by the sound of it.

EDIT: for the first function displayed.

npereira

fixed... SMF was saying there was 12 members in the group same as if you selected the membergroup "2008 Supporters) you would see all 12 members, yet when I went to each of the members profiles and look at the account related settings for Primary member group, only the 2 members would be in the "2008 Supporters" group everyone else (the 10 other) had Primary group as "site supporter" but secondary group was "2008 supporter".

So is there 2 types of groups?

npereira

LOL !

I was writting the above message as you replied Bloc !

Thanks !

IchBin

took you 35 minutes to post after Bloc? lol