commit | author | age
|
532ae5
|
1 |
<?php |
L |
2 |
|
|
3 |
class dashlet_modules { |
b1a6a5
|
4 |
|
532ae5
|
5 |
function show() { |
L |
6 |
global $app, $conf; |
b1a6a5
|
7 |
|
532ae5
|
8 |
//* Loading Template |
L |
9 |
$app->uses('tpl'); |
b1a6a5
|
10 |
|
532ae5
|
11 |
$tpl = new tpl; |
L |
12 |
$tpl->newTemplate("dashlets/templates/modules.htm"); |
b1a6a5
|
13 |
|
532ae5
|
14 |
$wb = array(); |
L |
15 |
$lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_dashlet_modules.lng'; |
b1a6a5
|
16 |
if(is_file($lng_file)) include $lng_file; |
532ae5
|
17 |
$tpl->setVar($wb); |
b1a6a5
|
18 |
|
532ae5
|
19 |
/* |
L |
20 |
* Show all modules, the user is allowed to use |
|
21 |
*/ |
|
22 |
$modules = explode(',', $_SESSION['s']['user']['modules']); |
|
23 |
$mod = array(); |
|
24 |
if(is_array($modules)) { |
|
25 |
foreach($modules as $mt) { |
|
26 |
if(is_file('../' . $mt . '/lib/module.conf.php')) { |
|
27 |
if(!preg_match("/^[a-z]{2,20}$/i", $mt)) die('module name contains unallowed chars.'); |
b1a6a5
|
28 |
include_once '../' . $mt.'/lib/module.conf.php'; |
532ae5
|
29 |
/* We don't want to show the dashboard */ |
L |
30 |
if ($mt != 'dashboard') { |
a563d5
|
31 |
if($mt == 'dns'){ |
MC |
32 |
$dns_servers = $app->db->queryOneRecord("SELECT COUNT(*) as cnt FROM server WHERE dns_server = 1 AND active = 1"); |
|
33 |
if($dns_servers['cnt'] == 0) continue; |
|
34 |
} |
|
35 |
if($mt == 'mail'){ |
|
36 |
$mail_servers = $app->db->queryOneRecord("SELECT COUNT(*) as cnt FROM server WHERE mail_server = 1 AND active = 1"); |
|
37 |
if($mail_servers['cnt'] == 0) continue; |
|
38 |
} |
|
39 |
if($mt == 'sites'){ |
|
40 |
$web_servers = $app->db->queryOneRecord("SELECT COUNT(*) as cnt FROM server WHERE web_server = 1 AND active = 1"); |
|
41 |
if($web_servers['cnt'] == 0) continue; |
|
42 |
} |
|
43 |
|
532ae5
|
44 |
$module_title = $app->lng($module['title']); |
8cf78b
|
45 |
if(function_exists('mb_strlen')) { |
b1a6a5
|
46 |
if(mb_strlen($module_title, "UTF-8") > 8) $module_title = mb_substr($module_title, 0, 7, "UTF-8").'..'; |
8cf78b
|
47 |
} else { |
b1a6a5
|
48 |
if(strlen($module_title) > 8) $module_title = substr($module_title, 0, 7).'..'; |
8cf78b
|
49 |
} |
a563d5
|
50 |
$mod[$module['order']] = array( 'modules_title' => $module_title, |
b1a6a5
|
51 |
'modules_startpage' => $module['startpage'], |
MC |
52 |
'modules_name' => $module['name']); |
532ae5
|
53 |
} |
L |
54 |
} |
|
55 |
} |
a563d5
|
56 |
ksort($mod); |
532ae5
|
57 |
$tpl->setloop('modules', $mod); |
L |
58 |
} |
b1a6a5
|
59 |
|
532ae5
|
60 |
return $tpl->grab(); |
b1a6a5
|
61 |
|
532ae5
|
62 |
} |
b1a6a5
|
63 |
|
532ae5
|
64 |
} |
L |
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
b1a6a5
|
73 |
?> |