User Access Control - I Need Some Expert Help

13 posts by 4 authors in: Forums > CMS Builder
Last Post: May 25, 2012   (RSS)

By robin - May 24, 2012

Hi Perch,

In the code you've posted, if a user doesn't have any category access the sql will end up looking like:
WHERE num IN (1,)
...and SQL really dislikes a trailing comma. You could re-arrange your code a bit to fix the problem. Something like this that checks if categoryAccess has any value, and if not assigns it to 1:

<?php
$categoryAccess = join( ",", explode( "\t", trim( $CURRENT_USER['categoryAccess'], "\t" ) ) );
if(!$categoryAccess) {
$categoryAccess = "1";
}
?>


Hope that helps,
Robin
Robin
Programmer
interactivetools.com

By robin - May 25, 2012

Hey Perch,

CMS Builder will often still use list code even when people are just accessing the data. Is it a MySQL error or a php error due to $CURRENT_USER not being set? A strategic @ should take care of the php problem:

$categoryAccess = join( ",", explode( "\t", trim( @$CURRENT_USER['categoryAccess'], "\t" ) ) );

Hope that helps,
Robin
Robin
Programmer
interactivetools.com