Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function _assert( $expr, $msg){ if( !$expr ) print "<br/><b>ASSERTION FAIL: </b>{$msg}<br>"; }
- function prepareMenuTree($menuResults){
- /*
- Get instance of tree manager and build the tree
- */
- $treeManager = treeManager::get();
- $menuTree = $treeManager->getTree($menuResults, 'id','parent','display_order');
- /*
- Indent the tree
- */
- //$menuTree = $treeManager->slapTree($recordsTree, 1 ); //1 for indent count
- return $menuTree;
- }
- function prepareIndentedMenuTree($menuResults){
- /*
- Get instance of tree manager and build the tree
- */
- $treeManager = treeManager::get();
- $menuTree = $treeManager->getTree($menuResults, 'id','parent','display_order');
- /*
- Indent the tree
- */
- $menuIndentedTree = $treeManager->slapTree($menuTree, 1,'menu_title' ); //1 for indent count
- return $menuIndentedTree;
- }
- function prepareDropdownString($menuItem,$user_id){
- $itemString='';
- $itemString.='<li class="dropdown">';
- $itemString.='<a href="" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="'.$menuItem['icon_class'].'"></span> '.$menuItem['label'].' <span class="caret"></span></a>';
- $itemString.='<ul class="dropdown-menu">';
- foreach ($menuItem['children'] as $childItem){
- $authorizedGroups = array();
- foreach (fetchGroupsByMenu($childItem['id']) as $g) {
- $authorizedGroups[] = $g->group_id;
- }
- if($childItem['logged_in']==0 || (hasPerm($authorizedGroups,$user_id) || in_array(0,$authorizedGroups))) {
- $itemString.=prepareItemString($childItem,$user_id); }
- }
- $itemString.='</ul></li>';
- return $itemString;
- }
- function prepareItemString($menuItem,$user_id){
- $itemString = '';
- if ($menuItem['label']=='{{hr}}')
- $itemString = "<li class='divider'></li>";
- else
- if ($menuItem['link']=='users/verify_resend.php' || $menuItem['link']=='usersc/verify_resend.php') {
- $db = DB::getInstance();
- $query = $db->query("SELECT * FROM email");
- $results = $query->first();
- $email_act = $results->email_act;
- if ($email_act == 1)
- $itemString.='<li><a href="'.US_URL_ROOT.$menuItem['link'].'"><span class="'.$menuItem['icon_class'].'"></span> '.$menuItem['label'].'</a></li>';
- } else
- if ($menuItem['link']=='users/join.php' || $menuItem['link']=='usersc/join.php') {
- $db = DB::getInstance();
- $query = $db->query("SELECT * FROM settings");
- $results = $query->first();
- $registration = $results->registration;
- if ($registration == 1)
- $itemString .= '<li><a href="'.US_URL_ROOT.$menuItem['link'].'"><span class="'.$menuItem['icon_class'].'"></span> '.$menuItem['label'].'</a></li>';
- } else {
- if (substr($menuItem['label'],0,2)=="{{" && substr($menuItem['label'],-2,2)=="}}") {
- $key = substr($menuItem['label'],2,-2);
- if ($key == "username") {
- global $user;
- $menuItem['label'] = $user->data()->username;
- }
- else if ($key == "fname") {
- global $user;
- $menuItem['label'] = $user->data()->fname;
- }
- else
- $menuItem['label'] = lang($key);
- }
- if (substr($menuItem['link'],0,4) == "http")
- $itemString.='<li><a href="'.$menuItem['link'].'"><span class="'.$menuItem['icon_class'].'"></span> '.html_entity_decode($menuItem['label']).'</a></li>';
- else
- $itemString.='<li><a href="'.US_URL_ROOT.$menuItem['link'].'"><span class="'.$menuItem['icon_class'].'"></span> '.html_entity_decode($menuItem['label']).'</a></li>';
- }
- return $itemString;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement