Sarcoth
02-24-2010, 02:10 PM
I'm trying to get my query to only pull usergroups that have been selected. This isn't a permission to view thing, it is more like choosing which usergroups will be displayed.
Here is my current query:
$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)
WHERE (usergroup.showrosteraddpermissions = 1)
");
This works great, but it requires that I add a column to the usergroup table and then I have to go into each usergroup via the admincp and select YES if I want them to be added to the query. It can be a bit tiresome doing it that way.
What I'd like to do is to set up a option menu for my mod and just type in the usergroups I want to be allowed in the query. Here is what I have in my product.xml file:
<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>
I also have the correct phrasetype's in there as well and this is appearing in the options menu when the xml is installed. The only problem is that I can't figure out what to do with my query so that only the usergroups in the showroster_displayed_groups appear in the query.
I've tried a lot of different idea's, but it always ends in a database error. Does anyone have any thoughts on what I could do. Even a small suggestion in the right direction would be appreciated.
Thank you for your time.
Here is my current query:
$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)
WHERE (usergroup.showrosteraddpermissions = 1)
");
This works great, but it requires that I add a column to the usergroup table and then I have to go into each usergroup via the admincp and select YES if I want them to be added to the query. It can be a bit tiresome doing it that way.
What I'd like to do is to set up a option menu for my mod and just type in the usergroups I want to be allowed in the query. Here is what I have in my product.xml file:
<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>
I also have the correct phrasetype's in there as well and this is appearing in the options menu when the xml is installed. The only problem is that I can't figure out what to do with my query so that only the usergroups in the showroster_displayed_groups appear in the query.
I've tried a lot of different idea's, but it always ends in a database error. Does anyone have any thoughts on what I could do. Even a small suggestion in the right direction would be appreciated.
Thank you for your time.