Re: [gkornbluth] User Access Control - I Need Some Expert Help
OK,
This is what I tried:
<?php if($CURRENT_USER): ?>
<?php $categoryAccess = '1'; ?>
<?php $categoryAccess .= ',' . join( ",", explode( "\t", trim( $CURRENT_USER['categoryAccess'], "\t" ) ) ); ?>
SELECT num, name
FROM `<?php echo $TABLE_PREFIX;?>category`
WHERE num
IN (<?php echo $categoryAccess;?>)
GROUP BY num
<?php else: ?>
SELECT num, name
FROM `<?php echo $TABLE_PREFIX;?>category`
<?php endif ?>
This appears to take care of the non $CURRENT_USER problem - but there is still an issue with registered users who have not been assigned any categoryAccess.
When such a user attempts to create a record they receive this error:
Warning: Cannot modify header information - headers already sent by (output started at /server/path/cms/lib/menus/header.php:13) in /server/path/lib/database_functions.php on line 548 There was an error creating the list field 'category'. MySQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') GROUP BY num' at line 4
If I've got my code (above) right then I can't understand what's going on. The code gives categoryAccess a default value of 1 so we should have this:
WHERE num IN (1)
...but for some reason it still can't build the category menu.
:0/
Perch
NB: The error above also appears on the front of the site.