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 |
|
b1a6a5
|
31 |
require_once '../lib/config.inc.php'; |
MC |
32 |
require_once '../lib/app.inc.php'; |
532ae5
|
33 |
|
L |
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 |
*/ |
a563d5
|
48 |
/* |
2696e1
|
49 |
asort($modules); |
532ae5
|
50 |
if (in_array('dashboard', $modules)) { |
L |
51 |
$key = array_search('dashboard', $modules); |
|
52 |
unset($modules[$key]); |
|
53 |
$modules = array_merge(array('dashboard'), $modules); |
|
54 |
} |
a563d5
|
55 |
*/ |
532ae5
|
56 |
if(is_array($modules)) { |
L |
57 |
foreach($modules as $mt) { |
|
58 |
if(is_file($mt.'/lib/module.conf.php')) { |
|
59 |
if(!preg_match("/^[a-z]{2,20}$/i", $mt)) die('module name contains unallowed chars.'); |
a563d5
|
60 |
if($mt == 'dns'){ |
MC |
61 |
$dns_servers = $app->db->queryOneRecord("SELECT COUNT(*) as cnt FROM server WHERE dns_server = 1 AND active = 1"); |
|
62 |
if($dns_servers['cnt'] == 0) continue; |
|
63 |
} |
|
64 |
if($mt == 'mail'){ |
|
65 |
$mail_servers = $app->db->queryOneRecord("SELECT COUNT(*) as cnt FROM server WHERE mail_server = 1 AND active = 1"); |
|
66 |
if($mail_servers['cnt'] == 0) continue; |
|
67 |
} |
|
68 |
if($mt == 'sites'){ |
|
69 |
$web_servers = $app->db->queryOneRecord("SELECT COUNT(*) as cnt FROM server WHERE web_server = 1 AND active = 1"); |
|
70 |
if($web_servers['cnt'] == 0) continue; |
|
71 |
} |
|
72 |
|
b1a6a5
|
73 |
include_once $mt.'/lib/module.conf.php'; |
e75e35
|
74 |
$language = (isset($_SESSION['s']['user']['language']))?$_SESSION['s']['user']['language']:$conf['language']; |
T |
75 |
$app->load_language_file('web/'.$mt.'/lib/'.$language.'.lng'); |
532ae5
|
76 |
$active = ($module['name'] == $_SESSION['s']['module']['name']) ? 1 : 0; |
0e14d7
|
77 |
$topnav[$module['order'].'-'.$module['name']] = array( 'title' => $app->lng($module['title']), |
b1a6a5
|
78 |
'active' => $active, |
MC |
79 |
'module' => $module['name']); |
532ae5
|
80 |
} |
L |
81 |
} |
a563d5
|
82 |
ksort($topnav); |
532ae5
|
83 |
} |
L |
84 |
} else { |
|
85 |
//* Loading Login Module |
b1a6a5
|
86 |
include_once 'login/lib/module.conf.php'; |
532ae5
|
87 |
$_SESSION['s']['module'] = $module; |
b1a6a5
|
88 |
$topnav[] = array( 'title' => 'Login', |
MC |
89 |
'active' => 1); |
532ae5
|
90 |
$module = null; |
L |
91 |
unset($module); |
|
92 |
} |
|
93 |
|
|
94 |
//* Topnavigation |
b1a6a5
|
95 |
$app->tpl->setLoop('nav_top', $topnav); |
532ae5
|
96 |
|
L |
97 |
} |
|
98 |
|
|
99 |
//** Side Naviation |
|
100 |
if(isset($_GET['nav']) && $_GET['nav'] == 'side') { |
|
101 |
|
|
102 |
if(isset($_SESSION['s']['module']['name']) && is_file($_SESSION['s']['module']['name'].'/lib/custom_menu.inc.php')) { |
b1a6a5
|
103 |
include_once $_SESSION['s']['module']['name'].'/lib/custom_menu.inc.php'; |
532ae5
|
104 |
} else { |
b1a6a5
|
105 |
|
532ae5
|
106 |
$app->tpl->newTemplate('sidenav.tpl.htm'); |
L |
107 |
|
|
108 |
//* translating module navigation |
|
109 |
$nav_translated = array(); |
|
110 |
if(isset($_SESSION['s']['module']['nav']) && is_array($_SESSION['s']['module']['nav'])) { |
|
111 |
foreach($_SESSION['s']['module']['nav'] as $nav) { |
|
112 |
$tmp_items = array(); |
|
113 |
foreach($nav['items'] as $item) { |
|
114 |
$item['title'] = $app->lng($item['title']); |
|
115 |
$tmp_items[] = $item; |
|
116 |
} |
|
117 |
$nav['title'] = $app->lng($nav['title']); |
|
118 |
$nav['startpage'] = $nav['items'][0]['link']; |
|
119 |
$nav['items'] = $tmp_items; |
|
120 |
$nav_translated[] = $nav; |
|
121 |
} |
|
122 |
} else { |
|
123 |
$nav_translated = null; |
|
124 |
} |
b1a6a5
|
125 |
$app->tpl->setLoop('nav_left', $nav_translated); |
MC |
126 |
|
532ae5
|
127 |
} |
L |
128 |
|
|
129 |
} |
|
130 |
|
|
131 |
$app->tpl_defaults(); |
|
132 |
$app->tpl->pparse(); |
|
133 |
|
b1a6a5
|
134 |
?> |