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:
...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:
Hope that helps,
Robin
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
Programmer
interactivetools.com
Re: [robin] User Access Control - I Need Some Expert Help
By Perchpole - May 24, 2012
Hi, Robin -
Thanks for this. It seems to work well.
My only concern is the issue of the non $CURRENT_USER...
I can understand why the system would break when a $CURRENT_USER attempted to create a record (because the editor couldn't build the category list, etc..) but I can't quite get my head around why an ordinary visitor to the site would also trigger the same problem?
Visitors aren't interacting with the back-end of CMSB - so why are they seeing the same MySQL error?
:oS
Perch
Thanks for this. It seems to work well.
My only concern is the issue of the non $CURRENT_USER...
I can understand why the system would break when a $CURRENT_USER attempted to create a record (because the editor couldn't build the category list, etc..) but I can't quite get my head around why an ordinary visitor to the site would also trigger the same problem?
Visitors aren't interacting with the back-end of CMSB - so why are they seeing the same MySQL error?
:oS
Perch
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:
Hope that helps,
Robin
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
Programmer
interactivetools.com