Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.

groupaccess

One of the most important things with user levels is a way to limit access to the access level the user or guest have.
By using the groupaccess() function you can easily make sure only those items in a MySQL query the user has access to will be enabled.

groupaccess

Quote

groupaccess ( string $field )


Parameters
field
The MySQL field where you want to check the access from

Return Values
This function will return the $field with the correct values of access the current user or guest has.

Example
Code
<?php
echo groupaccess("field_1");
?>


Lets see what happens when we run this function. Notice how it changes depending of the users rights.

Output from above example

For guests groupaccess() will return this:

Quote

(field_1='0')
For members groupaccess() will return this:

Quote

(field_1='0' OR field_1='101')
For Administrators groupaccess() will return this:

Quote

(field_1='0' OR field_1='101' OR field_1='102')
For Super Administrators groupaccess() will return this:

Quote

1 = 1


groupaccess() advanced example
Code
<?php
$result = dbquery(
 "SELECT item, access
 FROM ".DB_TABLE."
 WHERE ".groupaccess('access')."
 ORDER BY item DESC"
);
 ?>


Output from above example

For guests groupaccess() will return this:

Quote

$result = dbquery(
"SELECT item, access
FROM ".DB_TABLE."
WHERE (access='0')
ORDER BY item DESC"
);


For members groupaccess() will return this:

Quote

$result = dbquery(
"SELECT item, access
FROM ".DB_TABLE."
WHERE (access='0' OR access='101')
ORDER BY item DESC"
);


For Administrators groupaccess() will return this:

Quote

$result = dbquery(
"SELECT item, access
FROM ".DB_TABLE."
WHERE (access='0' OR access='101' OR access='102')
ORDER BY item DESC"
);


For Super Administrators groupaccess() will return this:

Quote

$result = dbquery(
"SELECT item, access
FROM ".DB_TABLE."
WHERE 1 = 1
ORDER BY item DESC"
);