Marius Cramer
2013-10-14 d9bcf68e395d6156645a7974b1a992aa6e6c00aa
commit | author | age
532ae5 1 <?php
L 2
3 /*
4 Copyright (c) 2007, Till Brehm, projektfarm Gmbh
5 All rights reserved.
6
7 Redistribution and use in source and binary forms, with or without modification,
8 are permitted provided that the following conditions are met:
9
10     * Redistributions of source code must retain the above copyright notice,
11       this list of conditions and the following disclaimer.
12     * Redistributions in binary form must reproduce the above copyright notice,
13       this list of conditions and the following disclaimer in the documentation
14       and/or other materials provided with the distribution.
15     * Neither the name of ISPConfig nor the names of its contributors
16       may be used to endorse or promote products derived from this software without
17       specific prior written permission.
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 require_once('../lib/config.inc.php');
32 require_once('../lib/app.inc.php');
33
34 $app->uses('tpl');
35
36 //** Top Naviation
37 if(isset($_GET['nav']) && $_GET['nav'] == 'top') {
38
39     $app->tpl->newTemplate('topnav.tpl.htm');
40
41     //* Check User Login and current module
42     if(isset($_SESSION["s"]["user"]) && $_SESSION["s"]["user"]['active'] == 1 && is_array($_SESSION['s']['module'])) {
43         //* Loading modules of the user and building top navigation
44         $modules = explode(',', $_SESSION['s']['user']['modules']);
45         /*
46          * If the dashboard is in the list of modules it always has to be the first!
47          */
2696e1 48         asort($modules);
532ae5 49         if (in_array('dashboard', $modules)) {
L 50             $key = array_search('dashboard', $modules);
51             unset($modules[$key]);
52             $modules = array_merge(array('dashboard'), $modules);
53         }
54         if(is_array($modules)) {
55             foreach($modules as $mt) {
56                 if(is_file($mt.'/lib/module.conf.php')) {
57                     if(!preg_match("/^[a-z]{2,20}$/i", $mt)) die('module name contains unallowed chars.');
58                     include_once($mt.'/lib/module.conf.php');
e75e35 59                     $language = (isset($_SESSION['s']['user']['language']))?$_SESSION['s']['user']['language']:$conf['language'];
T 60                     $app->load_language_file('web/'.$mt.'/lib/'.$language.'.lng');
532ae5 61                     $active = ($module['name'] == $_SESSION['s']['module']['name']) ? 1 : 0;
L 62                     $topnav[] = array(    'title'     => $app->lng($module['title']),
63                             'active'     => $active,
64                             'module'    => $module['name']);
65                 }
66             }
67         }
68     } else {
69         //*  Loading Login Module
70         include_once('login/lib/module.conf.php');
71         $_SESSION['s']['module'] = $module;
72         $topnav[] = array(    'title'     => 'Login',
73                 'active'     => 1);
74         $module = null;
75         unset($module);
76     }
77
78     //* Topnavigation
79     $app->tpl->setLoop('nav_top',$topnav);
80
81 }
82
83 //** Side Naviation
84 if(isset($_GET['nav']) && $_GET['nav'] == 'side') {
85
86     if(isset($_SESSION['s']['module']['name']) && is_file($_SESSION['s']['module']['name'].'/lib/custom_menu.inc.php')) {
87         include_once($_SESSION['s']['module']['name'].'/lib/custom_menu.inc.php');
88     } else {
89     
90         $app->tpl->newTemplate('sidenav.tpl.htm');
91
92         //* translating module navigation
93         $nav_translated = array();
94         if(isset($_SESSION['s']['module']['nav']) && is_array($_SESSION['s']['module']['nav'])) {
95             foreach($_SESSION['s']['module']['nav'] as $nav) {
96                 $tmp_items = array();
97                 foreach($nav['items'] as $item) {
98                     $item['title'] = $app->lng($item['title']);
99                     $tmp_items[] = $item;
100                 }
101                 $nav['title'] = $app->lng($nav['title']);
102                 $nav['startpage'] = $nav['items'][0]['link'];
103                 $nav['items'] = $tmp_items;
104                 $nav_translated[] = $nav;
105             }
106         } else {
107             $nav_translated = null;
108         }
109         $app->tpl->setLoop('nav_left',$nav_translated);
110     
111     }
112
113 }
114
115 $app->tpl_defaults();
116 $app->tpl->pparse();
117
cf71a4 118 ?>