Skip to content
modules.php 2.01 KiB
Newer Older
latham's avatar
latham committed
<?php

class dashlet_modules {
latham's avatar
latham committed
	function show() {
		global $app, $conf;
latham's avatar
latham committed
		//* Loading Template
		$app->uses('tpl');
latham's avatar
latham committed
		$tpl = new tpl;
		$tpl->newTemplate("dashlets/templates/modules.htm");
latham's avatar
latham committed
		$wb = array();
		$lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_dashlet_modules.lng';
		if(is_file($lng_file)) include $lng_file;
latham's avatar
latham committed
		$tpl->setVar($wb);
latham's avatar
latham committed
		/*
		 * 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.');
					include_once '../' . $mt.'/lib/module.conf.php';
latham's avatar
latham committed
					/* We don't want to show the dashboard */
					if ($mt != 'dashboard') {
Marius Cramer's avatar
Marius Cramer committed
						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
						$module_title = $app->lng($module['title']);
						if(function_exists('mb_strlen')) {
							if(mb_strlen($module_title, "UTF-8") > 8) $module_title = mb_substr($module_title, 0, 7, "UTF-8").'..';
							if(strlen($module_title) > 8) $module_title = substr($module_title, 0, 7).'..';
						$mod[$module['order'].'-'.$module['name']] = array( 'modules_title'  => $module_title,
							'modules_startpage' => $module['startpage'],
							'modules_name'   => $module['name']);
Marius Cramer's avatar
Marius Cramer committed
			ksort($mod);
latham's avatar
latham committed
			$tpl->setloop('modules', $mod);
		}
latham's avatar
latham committed
		return $tpl->grab();