Subversion Repositories phpLibraryV2

Rev

Rev 29 | Rev 31 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 29 Rev 30
Line 79... Line 79...
79
      }
79
      }
80
      return $this->menuBlockString;
80
      return $this->menuBlockString;
81
   }
81
   }
82
   
82
   
83
   // just an entry point to displayMenu, with root of inputRecords and level 0
83
   // just an entry point to displayMenu, with root of inputRecords and level 0
84
   function DBMenu2String ( $rootDir = '', $toAdd = null ) {
84
   function DBMenu2String ( $rootDir = '', $toAdd = null, $permissions = array() ) {
85
      foreach ( $toAdd as $additional ) {
85
      foreach ( $toAdd as $additional ) {
86
         $this->inputRecords[] = $additional;
86
         $this->inputRecords[] = $additional;
87
      }
87
      }
88
      //print "<pre>\n" . print_r( $this, true) . "</pre>"; die;
88
      //print "<pre>\n" . print_r( $this, true) . "</pre>"; die;
89
      return $this->htmlMenu( $this->inputRecords, 0, $rootDir, $toAdd );
89
      return $this->htmlMenu( $this->inputRecords, 0, $rootDir, $permissions );
90
   }
90
   }
91
   
91
   
92
   // function takes a menu level and creates an HTML Menu items from it. If a node has children, will
92
   // function takes a menu level and creates an HTML Menu items from it. If a node has children, will
93
   // recursively call itself for each child node.
93
   // recursively call itself for each child node.
94
   private function htmlMenu ($menu, $level=0, $rootDir = '' ) {
94
   private function htmlMenu ($menu, $level=0, $rootDir = '', $permissions = array() ) {
95
      $result = '';
95
      $result = '';
96
      foreach ($menu as $key => $value) { // process each array entry
96
      foreach ($menu as $key => $value) { // process each array entry
-
 
97
         // ignore if there is a permission and it is false
-
 
98
         if ( isset( $permissions[$value['shortname']] ) && ! $permissions[$value['shortname']] ) {
-
 
99
            continue;
-
 
100
         }
97
         if ($value[$this->urlName]) { // this is a link, so it is a live menu option
101
         if ($value[$this->urlName]) { // this is a link, so it is a live menu option
98
            $result .= insertValuesIntoQuery( $this->menuItemString, array( 'url' => $rootDir . $value[$this->urlName], 'caption' => $value[$this->captionName], 'level' => $level) );
102
            $result .= insertValuesIntoQuery( $this->menuItemString, array( 'url' => $rootDir . $value[$this->urlName], 'caption' => $value[$this->captionName], 'level' => $level) );
99
         } else { // not a link, so just create the text
103
         } else { // not a link, so just create the text
100
            $result .= insertValuesIntoQuery( $this->menuHeaderString, array( 'caption' => $value[$this->captionName], 'level' => $level) );
104
            $result .= insertValuesIntoQuery( $this->menuHeaderString, array( 'caption' => $value[$this->captionName], 'level' => $level) );
101
         }
105
         }
102
         if ( isset($value['children'])) { // if it has children, process them
106
         if ( isset($value['children'])) { // if it has children, process them
103
            $result .=  $this->htmlMenu($value['children'], $level+1, $rootDir);
107
            $result .=  $this->htmlMenu($value['children'], $level+1, $rootDir, $permissions);
104
         }
108
         }
105
      }
109
      }
106
      /*
110
      /*
107
      // if they want anything added, do it here.
111
      // if they want anything added, do it here.
108
      foreach ( $toAdd as $key => $value ) {
112
      foreach ( $toAdd as $key => $value ) {