PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hello. This is the first time i try using php language end i've a small problem.
In this module this function give me all categories that a user can access.
$result = $xoopsDB->query("SELECT a.*, b.* FROM " . $xoopsDB->prefix("PDdownloads{$mydirnumber}_cat") . " a, ".$xoopsDB->prefix('group_permission')." b WHERE a.cid = b.gperm_itemid AND b.gperm_modid = $module_id AND b.gperm_name = \"PDDownCatPerm{$mydirnumber}\" AND b.gperm_groupid = $groups[0] AND a.pid = 0 ORDER BY a.weight");
Users can have more then 1 group and $groups array is list of all groups of a user.
The code i posted check only first group of a user
the sentence "AND b.gperm_groupid = $groups[0]" is probably the part i had to change but i don't now right sentence.
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I change sentence
with
Code:
AND (b.gperm_groupid = $groups[0] OR b.gperm_groupid = $groups[1])
but if I'm using an user that have only 1 group setting, my script don't work right.
Also, I needed a sentence that check if b.gperm_groupid is present in $group, but i don't know how many groups exist, so i can't write a code like you say.
For example if i need to do this with another language (for example cobol) i simply write perform until b.gperm_groupid = $groups(ind) or ind > 999
add 1 to ind
end-perform
for ($i=0; $i <=$myind; $i++) $result = $xoopsDB->query("SELECT a.*, b.* FROM " . $xoopsDB->prefix("PDdownloads{$mydirnumber}_cat") . " a, ".$xoopsDB->prefix('group_permission')." b WHERE a.cid = b.gperm_itemid AND b.gperm_modid = $module_id AND b.gperm_name = \"PDDownCatPerm{$mydirnumber}\" AND b.gperm_groupid = $groups[$i] AND a.pid = 0 ORDER BY a.weight");