modules.php 2.01 KB
Newer Older
latham's avatar
latham committed
1
2
3
<?php

class dashlet_modules {
4

latham's avatar
latham committed
5
6
	function show() {
		global $app, $conf;
7

latham's avatar
latham committed
8
9
		//* Loading Template
		$app->uses('tpl');
10

latham's avatar
latham committed
11
12
		$tpl = new tpl;
		$tpl->newTemplate("dashlets/templates/modules.htm");
13

latham's avatar
latham committed
14
15
		$wb = array();
		$lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_dashlet_modules.lng';
16
		if(is_file($lng_file)) include $lng_file;
latham's avatar
latham committed
17
		$tpl->setVar($wb);
18

latham's avatar
latham committed
19
20
21
22
23
24
25
26
27
		/*
		 * Show all modules, the user is allowed to use
		*/
		$modules = explode(',', $_SESSION['s']['user']['modules']);
		$mod = array();
		if(is_array($modules)) {
			foreach($modules as $mt) {
				if(is_file('../' . $mt . '/lib/module.conf.php')) {
					if(!preg_match("/^[a-z]{2,20}$/i", $mt)) die('module name contains unallowed chars.');
28
					include_once '../' . $mt.'/lib/module.conf.php';
latham's avatar
latham committed
29
30
					/* We don't want to show the dashboard */
					if ($mt != 'dashboard') {
Marius Cramer's avatar
Marius Cramer committed
31
32
33
34
35
36
37
38
39
40
41
42
43
						if($mt == 'dns'){
							$dns_servers = $app->db->queryOneRecord("SELECT COUNT(*) as cnt FROM server WHERE dns_server = 1 AND active = 1");
							if($dns_servers['cnt'] == 0) continue;
						}
						if($mt == 'mail'){
							$mail_servers = $app->db->queryOneRecord("SELECT COUNT(*) as cnt FROM server WHERE mail_server = 1 AND active = 1");
							if($mail_servers['cnt'] == 0) continue;
						}
						if($mt == 'sites'){
							$web_servers = $app->db->queryOneRecord("SELECT COUNT(*) as cnt FROM server WHERE web_server = 1 AND active = 1");
							if($web_servers['cnt'] == 0) continue;
						}
					
latham's avatar
latham committed
44
						$module_title = $app->lng($module['title']);
45
						if(function_exists('mb_strlen')) {
46
							if(mb_strlen($module_title, "UTF-8") > 8) $module_title = mb_substr($module_title, 0, 7, "UTF-8").'..';
47
						} else {
48
							if(strlen($module_title) > 8) $module_title = substr($module_title, 0, 7).'..';
49
						}
50
						$mod[$module['order'].'-'.$module['name']] = array( 'modules_title'  => $module_title,
51
52
							'modules_startpage' => $module['startpage'],
							'modules_name'   => $module['name']);
latham's avatar
latham committed
53
54
55
					}
				}
			}
Marius Cramer's avatar
Marius Cramer committed
56
			ksort($mod);
latham's avatar
latham committed
57
58
			$tpl->setloop('modules', $mod);
		}
59

latham's avatar
latham committed
60
		return $tpl->grab();
61

latham's avatar
latham committed
62
	}
63

latham's avatar
latham committed
64
65
66
67
68
69
70
71
72
}








73
?>