Support Forum Softcomplex logo
About Us  | Services  | Download  | Order  | Support  | |
| Search | Today's Posts | Stats | Board Rules | Not logged in [ Login | Register ]
go to bottom
Last active: Never

Printable Version | Subscribe | Add to Favourites   Post new thread
Author: Subject: Hiding nodes based on permissions (pro verson, php)
bentmyers
Newbie

Posts: 1
Registered: 9/20/2007
Member Is Offline
posted on 9/30/2007 at 11:29 PM Reply With Quote
Hiding nodes based on permissions (pro verson, php)


I'm trying to use tree menu pro to generate a dynamic menu from my database. The user access variables are in a comma delineated set (ex: 1,4,17,24) and the page permissions are in a similar set (ex: 2,4,15,56,57). In this example, the 4 matches in both, so the user would be able to see the page.

I edited items.php to query the permissions field in the db table and then compare the user's access session variable with the field from the db, but it's not generating the correct menu.

Code:

$sql = "SELECT * FROM $tn WHERE $pidfn=$id";
$result = mysql_query($sql);

if (mysql_num_rows($result) == 0) return;
while ($row = mysql_fetch_assoc($result)) {

$clink = $row[$lfn];
$cid = $row[$idfn];

// ****
// **** START CUSTOMIZATION **** //
// ****
// **** THIS ARRAY WILL CONTAIN THE ACCESS PRIVS OF THE PAGE
// **** IF IT'S PRIVS MATCH THE PRIVS IN THE sess_access VARIABLE, THE USER CAN SEE THE PAGE
$accessVar = FALSE;
$pageAccessArray = $row[page_permission];
$pageAccessArray = explode(",",$pageAccessArray);
$userAccessArray = explode(",",$user_permissions); //**** $user_permissions IS A SESSION VARIABLE ASSIGNED WHEN THE USER LOGS IN **** //

if(in_array("0",$pageAccessArray))
$accessVar = TRUE;
else
{
for($i=0;$i<count($userAccessArray);$i++)
{
$thisItem = $userAccessArray[$i];
if(in_array($thisItem,$pageAccessArray))
$accessVar = TRUE;
}
}

// ****
// **** END CUSTOMIZATION
// ****


if($accessVar == TRUE)
{
if ($id == 0) echo 'var '.$vn.' = [';

if(!$vn) echo ',';
$vn = 0;
echo " ['$row[$cfn]', "$clink", ";
if($id == 0) echo "{'st':1}";
else echo "0";
build_hierarchy($cid, $vn, $tn, $idfn, $pidfn, $cfn, $lfn);
echo ']';
}
else
build_hierarchy($cid, $vn, $tn, $idfn, $pidfn, $cfn, $lfn);
}
mysql_free_result($result);
if($id == 0) echo "];";



The menu will give me a few seemingly random nodes, but not the correct structure.
Anyone have any ideas on how to correct this?
Thanks!
View User's Profile View All Posts By User U2U Member
Post new thread

Related Links:
Tigra Tree Menu
Product Demonstrations Live Demos:
Frames targeting
Win help style
Free Download Free Download
Free Download Menu Builders
Online Builder
Product Documentation Documentation:
Documenation Page
Support Forum Technical Support
Support Forum
   
Tigra Tree Menu PRO
Product Demonstrations Live Demos
Multiple Trees
Frames Targeting
Icons and Styles Overloading
Event Handling
Performance Test
Version 1.2 features
Product Documentation Documentation
Documenation Page
Change Log
Support Forum Technical Support
Support Forum
Customer Care System
Order Now ORDER NOW!
Add to Cart
View Cart
 

Go To Top


Powered by XMB 1.9.1 Nexus
Developed By Aventure Media & The XMB Group © 2002-2004