
September 23rd, 2009, 05:39 PM
|
 |
Super Moderator
|
|
Join Date: Apr 2007
Location: San Diego, CA
Posts: 1,667
Time spent in forums: 3 Days 10 m 43 sec
Reputation Power: 4
|
|
I use this
PHP Code:
function makeMenue($ODbo,$menue,$selected=''){
/***********************************************
* function:makeMenue
* Arguments: (obj)$ODbo, (str) menue, (str)selected menue item
* returns: html formated unordered list
* purpose: determine based on user, and meue what menue items a person can see
* Special Case: none
************************************************/
$user_roles = $_SESSION['Ouser']->user_roles;
//determine what menue to make
$menue_id = getMenueId($ODbo,$menue);
//determine which of these entries these roles can see.
$result = determineViewableEntries($ODbo, $menue_id,$user_roles);
if($result == -1){
return '';
}
//this should get entry id's where the user's role is appropriate
$output = buildMenue($ODbo,$result,$selected);
return $output;
}
PHP Code:
function buildMenue($ODbo,$result,$selected=''){
//echo $selected."";//debug
$output = '';
foreach($result as $entry_id){
//$entry_id = $row['MENUE_ENTRY_ID'];
$sql = "select * from menue_entries where id = $entry_id";
$entry_result = $ODbo->executeQuery($sql,'','ASSOC',0);
foreach($entry_result as $entry_row){
if($entry_row['DISPLAY_NAME'] == $selected){
$output .= "\n<li id=\"current\" ";
}else{
$output .= "\n<li id=\"$entry_row[DISPLAY_NAME]\"";
}
$output .= " class=\"$entry_row[DISPLAY_NAME]\">\n";
/*
I'm looking for a non cheezy workaround here
but I want an alternative that will allow me to embed js
into the LINK vs a real link
I think I'll use a key like JS or # to indicate that the follow
is js and should not be treated like a link.
TODO: disembed array references below.
*/
if(substr($entry_row['LINK'],0,1) == '#'){
$output .= " <span style='cursor:pointer !important; cursor:hand; color:blue' title=\"$entry_row[DISPLAY_NAME]\" name=\"$entry_row[DISPLAY_NAME]\" ";
$output .= $entry_row['LINK'];
$output .=" >$entry_row[DISPLAY_NAME]</span>\n</a>\n</li> ";
}else{
$output .= " <a href=\"$entry_row[LINK]\" name=\"$entry_row[DISPLAY_NAME]\"";
$output .= " title=\"$entry_row[DISPLAY_NAME]\">\n";
$output .= " <span>$entry_row[DISPLAY_NAME]</span>\n</a>\n</li> ";
}
$output .= " \n";
}
}
return $output;
}
__________________
There is no spoon.
|