Marius Cramer
2013-11-14 7fe908c50c8dbc5cc05f571dbe11d66141caacd4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
 
class dashlet_modules {
 
    function show() {
        global $app, $conf;
 
        //* Loading Template
        $app->uses('tpl');
 
        $tpl = new tpl;
        $tpl->newTemplate("dashlets/templates/modules.htm");
 
        $wb = array();
        $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_dashlet_modules.lng';
        if(is_file($lng_file)) include $lng_file;
        $tpl->setVar($wb);
 
        /*
         * 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';
                    /* We don't want to show the dashboard */
                    if ($mt != 'dashboard') {
                        $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").'..';
                        } else {
                            if(strlen($module_title) > 8) $module_title = substr($module_title, 0, 7).'..';
                        }
                        $mod[] = array( 'modules_title'  => $module_title,
                            'modules_startpage' => $module['startpage'],
                            'modules_name'   => $module['name']);
                    }
                }
            }
 
            $tpl->setloop('modules', $mod);
        }
 
        return $tpl->grab();
 
    }
 
}
 
 
 
 
 
 
 
 
?>