| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | $Rev: 254 $ | $LastChangedBy: brieb $ |
|---|
| 4 | $LastChangedDate: 2007-08-07 18:38:38 -0600 (Tue, 07 Aug 2007) $ |
|---|
| 5 | +-------------------------------------------------------------------------+ |
|---|
| 6 | | Copyright (c) 2004 - 2010, Kreotek LLC | |
|---|
| 7 | | All rights reserved. | |
|---|
| 8 | +-------------------------------------------------------------------------+ |
|---|
| 9 | | | |
|---|
| 10 | | Redistribution and use in source and binary forms, with or without | |
|---|
| 11 | | modification, are permitted provided that the following conditions are | |
|---|
| 12 | | met: | |
|---|
| 13 | | | |
|---|
| 14 | | - Redistributions of source code must retain the above copyright | |
|---|
| 15 | | notice, this list of conditions and the following disclaimer. | |
|---|
| 16 | | | |
|---|
| 17 | | - Redistributions in binary form must reproduce the above copyright | |
|---|
| 18 | | notice, this list of conditions and the following disclaimer in the | |
|---|
| 19 | | documentation and/or other materials provided with the distribution. | |
|---|
| 20 | | | |
|---|
| 21 | | - Neither the name of Kreotek LLC nor the names of its contributore may | |
|---|
| 22 | | be used to endorse or promote products derived from this software | |
|---|
| 23 | | without specific prior written permission. | |
|---|
| 24 | | | |
|---|
| 25 | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
|---|
| 26 | | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
|---|
| 27 | | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | |
|---|
| 28 | | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
|---|
| 29 | | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
|---|
| 30 | | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
|---|
| 31 | | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
|---|
| 32 | | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
|---|
| 33 | | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
|---|
| 34 | | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
|---|
| 35 | | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
|---|
| 36 | | | |
|---|
| 37 | +-------------------------------------------------------------------------+ |
|---|
| 38 | */ |
|---|
| 39 | |
|---|
| 40 | class topMenu{ |
|---|
| 41 | |
|---|
| 42 | var $db; |
|---|
| 43 | |
|---|
| 44 | function topMenu($db){ |
|---|
| 45 | $this->db = $db; |
|---|
| 46 | |
|---|
| 47 | $querystatement = " |
|---|
| 48 | SELECT |
|---|
| 49 | `id`, |
|---|
| 50 | `name`, |
|---|
| 51 | `link`, |
|---|
| 52 | `uuid`, |
|---|
| 53 | `roleid` |
|---|
| 54 | FROM |
|---|
| 55 | `menu` |
|---|
| 56 | WHERE |
|---|
| 57 | `parentid` = '' |
|---|
| 58 | OR |
|---|
| 59 | `parentid` IS NULL |
|---|
| 60 | ORDER BY |
|---|
| 61 | `displayorder`; |
|---|
| 62 | "; |
|---|
| 63 | |
|---|
| 64 | $this->menuresult = $this->db->query($querystatement); |
|---|
| 65 | |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | function getSubItems($parentid){ |
|---|
| 70 | $querystatement = " |
|---|
| 71 | SELECT |
|---|
| 72 | `id`, |
|---|
| 73 | `name`, |
|---|
| 74 | `link`, |
|---|
| 75 | `roleid` |
|---|
| 76 | FROM |
|---|
| 77 | `menu` |
|---|
| 78 | WHERE |
|---|
| 79 | `parentid` = '".$parentid."' |
|---|
| 80 | ORDER BY |
|---|
| 81 | `displayorder`; |
|---|
| 82 | "; |
|---|
| 83 | |
|---|
| 84 | $queryresult = $this->db->query($querystatement); |
|---|
| 85 | |
|---|
| 86 | if ($this->db->numRows($queryresult)<1) return false; else return $queryresult; |
|---|
| 87 | } |
|---|
| 88 | |
|---|
| 89 | |
|---|
| 90 | function display(){ |
|---|
| 91 | |
|---|
| 92 | ?> |
|---|
| 93 | <div id="menu"> |
|---|
| 94 | <h1><a href="<?php echo APP_PATH.DEFAULT_LOAD_PAGE ?>" title="<?php echo htmlQuotes(APPLICATION_NAME);?>" name="toptop"><span><?php echo APPLICATION_NAME;?></span></a></h1> |
|---|
| 95 | |
|---|
| 96 | <div id="menuRighthand"><?php echo htmlQuotes(trim($_SESSION["userinfo"]["firstname"]." ".$_SESSION["userinfo"]["lastname"]))?> </div> |
|---|
| 97 | |
|---|
| 98 | <ul id="menuBar"> |
|---|
| 99 | <?php |
|---|
| 100 | $submenustring=""; |
|---|
| 101 | |
|---|
| 102 | while($menurecord = $this->db->fetchArray($this->menuresult)){ |
|---|
| 103 | |
|---|
| 104 | if(hasRights($menurecord["roleid"])){ |
|---|
| 105 | if($menurecord["link"]) { |
|---|
| 106 | if(strpos($menurecord["link"],"http")!==0 && strpos($menurecord["link"],"javascript")!==0) |
|---|
| 107 | $menurecord["link"]=APP_PATH.$menurecord["link"]; |
|---|
| 108 | ?><li class="firstLevel"><a href="<?php echo $menurecord["link"]?>"><?php echo $menurecord["name"]?></a></li><?php |
|---|
| 109 | } else { |
|---|
| 110 | |
|---|
| 111 | ?><li class="firstLevel"><a href="#toptop" class="topMenus" id="menu<?php echo $menurecord["id"]?>"><?php echo $menurecord["name"]; ?></a></li><li class="submenusli"><ul class="submenuitems" id="submenu<?php echo $menurecord["id"]?>"><?php |
|---|
| 112 | |
|---|
| 113 | $subitemsquery = $this->getSubItems($menurecord["uuid"]); |
|---|
| 114 | |
|---|
| 115 | if($subitemsquery){ |
|---|
| 116 | $sep=false; |
|---|
| 117 | |
|---|
| 118 | while($subrecord=$this->db->fetchArray($subitemsquery)){ |
|---|
| 119 | if($subrecord["name"]=="----") |
|---|
| 120 | $sep=true; |
|---|
| 121 | else{ |
|---|
| 122 | if(hasRights($subrecord["roleid"])){ |
|---|
| 123 | if(strpos($subrecord["link"],"http")!==0 && strpos($subrecord["link"],"javascript")!==0) |
|---|
| 124 | $subrecord["link"]=APP_PATH.$subrecord["link"]; |
|---|
| 125 | if(strpos($subrecord["link"],"javascript")===0) |
|---|
| 126 | $subrecord["link"]="#\" onclick=\"".str_replace("javascript:","",$subrecord["link"]); |
|---|
| 127 | ?><li <?php if($sep) echo " class=\"menuSep\" "?>><a href="<?php echo $subrecord["link"]?>"> <?php echo $subrecord["name"] ?></a></li><?php |
|---|
| 128 | $sep=false; |
|---|
| 129 | }//end if |
|---|
| 130 | }//end if |
|---|
| 131 | }//end while |
|---|
| 132 | |
|---|
| 133 | }//end if |
|---|
| 134 | ?></ul></li><?php ; |
|---|
| 135 | |
|---|
| 136 | }//end if |
|---|
| 137 | |
|---|
| 138 | }//end if |
|---|
| 139 | |
|---|
| 140 | }//end while |
|---|
| 141 | ?></ul></div><?php |
|---|
| 142 | |
|---|
| 143 | }//end method |
|---|
| 144 | }// end class |
|---|
| 145 | |
|---|
| 146 | ?> |
|---|