I'm trying to get a query to only pull usergroups that have been selected in an options menu. The setting option is named showroster_displayed_groups which I installed via a products.xml file:
This isn't a permission to view thing, it is more like choosing which usergroups will be displayed.
Here is the current query and it works fine, except I can't figure out how to only pull the usergroups I entered above:
I know I need a WHERE option at the end, but I just haven't had any luck with anything I've tried.
One thing I tried was to do a query on the $vbulletin->options['showroster_display_groups']:
But, then I couldn't figure a way to compare that in the main query. I've also tried creating a new table in my database and then using that to compare within my query, but that just gave me database query errors.
I hate to admit it, but I'm stuck. I would appreciate any help, even a suggestion in the right direction.
Thank you for your time.
Code:
<settinggroup name="showroster" displayorder="65535"> <setting varname="showroster_displayed_groups" displayorder="10"> <datatype>free</datatype> <defaultvalue><![CDATA[19,13,24,20,17,18]]></defaultvalue> </setting> </settinggroup>
Here is the current query and it works fine, except I can't figure out how to only pull the usergroups I entered above:
PHP Code:
$users = $db->query_read_slave("
SELECT user.*, usergroup.usergroupid, usergroup.title, user.options, usertextfield.*, userfield.*,
IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid
FROM " . TABLE_PREFIX . "usergroup AS usergroup
LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.usergroupid = usergroup.usergroupid OR FIND_IN_SET(usergroup.usergroupid, user.membergroupids))
LEFT JOIN " . TABLE_PREFIX . "userfield AS userfield ON(userfield.userid = user.userid)
LEFT JOIN " . TABLE_PREFIX . "customprofilepic AS customprofilepic ON (user.userid = customprofilepic.userid)
LEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON(usertextfield.userid=user.userid)
");
One thing I tried was to do a query on the $vbulletin->options['showroster_display_groups']:
PHP Code:
$displaygroups = explode(',', $vbulletin->options['showroster_display_groups']);
I hate to admit it, but I'm stuck. I would appreciate any help, even a suggestion in the right direction.
Thank you for your time.
Comment