Index-Blöcke werden jetzt vond en Modulen selbst bereitgestellt
bernd

bernd commited on 2012-03-08 14:33:17
Zeige 14 geänderte Dateien mit 168 Einfügungen und 36 Löschungen.


git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@2223 87cf0b9e-d624-0410-a070-f6ee81989793
... ...
@@ -352,5 +352,19 @@ function html_datepicker($nameprefix, $timestamp)
352 352
   return $ret;
353 353
 }
354 354
 
355
+function get_modules_info() 
356
+{
357
+  $modules = config('modules');
358
+  $modconfig = array();
359
+  foreach ($modules AS $name) {
360
+    $modconfig[$name] = NULL;
361
+    if (file_exists('modules/'.$name.'/module.info')) {
362
+      $modconfig[$name] = parse_ini_file('modules/'.$name.'/module.info');
363
+    }
364
+  }
365
+  return $modconfig;
366
+}
367
+
368
+
355 369
 
356 370
 ?>
... ...
@@ -40,7 +40,7 @@ if (isset($_POST['password1']) && $_POST['password1'] != '')
40 40
       change_mailaccount(get_mailaccount_id($accname), array('password' => $_POST['password1']));
41 41
     }
42 42
     if (! $debugmode)
43
-      header('Location: chpass');
43
+      header('Location: /');
44 44
     else
45 45
       output('');
46 46
   }
... ...
@@ -17,6 +17,7 @@ if ($id != 0)
17 17
 
18 18
 $accountlogin = false;
19 19
 if ($_SESSION['role'] == ROLE_VMAIL_ACCOUNT) {
20
+  $section = 'email_edit';
20 21
   $id = get_vmail_id_by_emailaddr($_SESSION['mailaccount']);
21 22
   $account = get_account_details($id, false);
22 23
   $accountlogin = true;
... ...
@@ -0,0 +1,3 @@
1
+name = email
2
+description = Verwaltung von E-Mail-Adressen und POP3/IMAP-Accounts
3
+permission = Verwaltung von E-Mail-Einstellungen
... ...
@@ -18,6 +18,7 @@ if ($_GET['action'] == 'edit')
18 18
   $accountlogin = ($_SESSION['role'] == ROLE_VMAIL_ACCOUNT);
19 19
 
20 20
   if ($accountlogin) {
21
+    $section = 'email_edit';
21 22
     $id = get_vmail_id_by_emailaddr($_SESSION['mailaccount']);
22 23
     $account = get_account_details($id, false);
23 24
     // Leere das, sonst werden die vervielfacht
... ...
@@ -157,7 +158,7 @@ if ($_GET['action'] == 'edit')
157 158
 
158 159
   if (! ($debugmode || we_have_an_error())) {
159 160
     if ($accountlogin) {
160
-      header('Location: ../index/index');
161
+      header('Location: /');
161 162
     } else {
162 163
       header('Location: vmail');
163 164
     }
... ...
@@ -0,0 +1,26 @@
1
+<?php
2
+
3
+if ($_SESSION['role'] & ROLE_SYSTEMUSER) {
4
+  $shortcuts[] = array( 'section' => 'E-Mail', 
5
+                        'weight'  => 40, 
6
+                        'file'    => 'vmail', 
7
+                        'icon'    => 'email.png', 
8
+                        'title'   => 'E-Mail-Adressen verwalten',
9
+                        'alert'   => NULL );
10
+}
11
+if ($_SESSION['role'] & ROLE_MAILACCOUNT || $_SESSION['role'] & ROLE_VMAIL_ACCOUNT) {
12
+  $shortcuts[] = array( 'section' => 'E-Mail', 
13
+                        'weight'  => 50, 
14
+                        'file'    => 'chpass', 
15
+                        'icon'    => 'pwchange.png', 
16
+                        'title'   => 'Passwort ändern',
17
+                        'alert'   => NULL );
18
+}
19
+if ($_SESSION['role'] & ROLE_VMAIL_ACCOUNT) {
20
+  $shortcuts[] = array( 'section' => 'E-Mail', 
21
+                        'weight'  => 40, 
22
+                        'file'    => 'edit', 
23
+                        'icon'    => 'cog.png', 
24
+                        'title'   => 'E-Mail-Einstellungen',
25
+                        'alert'   => NULL );
26
+}
... ...
@@ -54,48 +54,38 @@ output('<p>Herzlich willkommen, '.$role.".</p>\n");
54 54
 output("<p>Auf der linken Seite sehen Sie ein Auswahlmenü mit den Funktionen, die Ihnen in diesem Webinterface zur Verfügung stehen.</p>
55 55
 <p>Nachfolgend sehen Sie eine Auswahl typischer Aufgaben.</p>\n");
56 56
 
57
-output("<div class=\"overview\">");
58
-
59
-if (have_module('email') && ($_SESSION['role'] & ROLE_MAILACCOUNT || $_SESSION['role'] & ROLE_VMAIL_ACCOUNT)) {
60
-  output("<div class=\"block\">".internal_link("../email/chpass", "<img src=\"{$prefix}images/pwchange.png\" alt=\"\" /> Passwort ändern ")."</div>");
57
+$modules = get_modules_info();
58
+
59
+$my_shortcuts = array();
60
+foreach ($modules as $modname => $info) {
61
+  if (file_exists('modules/'.$modname.'/shortcuts.php')) {
62
+    $shortcuts = array();
63
+    include('modules/'.$modname.'/shortcuts.php');
64
+    foreach ($shortcuts as $shortcut) {
65
+      $shortcut['module'] = $modname;
66
+      $my_shortcuts[$shortcut['weight']] = $shortcut;
61 67
     }
62
-
63
-if (have_module('email') && ($_SESSION['role'] & ROLE_VMAIL_ACCOUNT)) {
64
-  output("<div class=\"block\">".internal_link("../email/edit", "<img src=\"{$prefix}images/cog.png\" alt=\"\" /> E-Mail-Einstellungen ")."</div>");
65 68
   }
66
-
67
-if ($_SESSION['role'] & ROLE_CUSTOMER || $_SESSION['role'] & ROLE_SYSTEMUSER) {
68
-  output("<div class=\"block\">".internal_link("chpass", "<img src=\"{$prefix}images/pwchange.png\" alt=\"\" /> Passwort ändern ")."</div>");
69 69
 }
70
+krsort($my_shortcuts);
71
+DEBUG($my_shortcuts);
70 72
 
71
-if (have_module('invoice') && $_SESSION['role'] & ROLE_CUSTOMER) {
72
-  require_once('modules/invoice/include/invoice.php');
73
-  $unpayed_invoices = 0;
74
-  $my_invoices = my_invoices();
75
-  foreach($my_invoices AS $inv) {
76
-    if ($inv['bezahlt'] == 0)
77
-      $unpayed_invoices++;
78
-  }
79
-  $extra = '';
80
-  if ($unpayed_invoices > 0)
81
-    $extra = '<span style="color: red;">('.$unpayed_invoices.' unbezahlt)</span>';
82
-  output("<div class=\"block\">".internal_link("../invoice/current", "<img src=\"{$prefix}images/invoice.png\" alt=\"\" /> Ihre Rechnungen {$extra}")."</div>");
83
-}
84 73
 
85
-if ($_SESSION['role'] & ROLE_SYSTEMUSER) {
86
-  if (have_module('email'))
87
-    output("<div class=\"block\">".internal_link("../email/vmail", "<img src=\"{$prefix}images/email.png\" alt=\"\" /> E-Mail-Adressen verwalten ")."</div>");
88
-  if (have_module('vhosts'))
89
-    output("<div class=\"block\">".internal_link("../vhosts/vhosts", "<img src=\"{$prefix}images/webserver.png\" alt=\"\" /> Webserver-Einstellungen ")."</div>");
90
-  if (have_module('mysql'))
91
-    output("<div class=\"block\">".internal_link("../mysql/databases", "<img src=\"{$prefix}images/mysql.png\" alt=\"\" /> MySQL-Datenbanken ")."</div>");
74
+output("<div class=\"overview\">");
75
+foreach ($my_shortcuts as $shortcut) {
76
+    $icon = "images/default.png";
77
+    if (file_exists("images/".$shortcut['icon'])) {
78
+      $icon = "images/".$shortcut['icon'];
79
+    }
80
+    $alert = '';
81
+    if (isset($shortcut['alert']) && $shortcut['alert']) {
82
+      $alert = '<br /><span style="color: red;">('.$shortcut['alert'].')</span>';
92 83
     }
84
+    output("<div class=\"block\">".internal_link($prefix.'go/'.$shortcut['module'].'/'.$shortcut['file'], "<img src=\"{$prefix}{$icon}\" alt=\"\" /> {$shortcut['title']} {$alert}")."</div>");
93 85
   
94
-if (have_module('jabber') && $_SESSION['role'] & ROLE_CUSTOMER) {
95
-  output("<div class=\"block\">".internal_link("../jabber/accounts", "<img src=\"{$prefix}images/jabber.png\" alt=\"\" /> Jabber-Accounts ")."</div>");
96 86
 }
87
+output('</div>');
97 88
 
98
-output("</div>");
99 89
 
100 90
 if (have_module('email') && $_SESSION['role'] & ROLE_VMAIL_ACCOUNT) {
101 91
   include('modules/email/vmailoverview.php');
... ...
@@ -0,0 +1,3 @@
1
+name = index
2
+description = System-Modul für An- und Abmeldung
3
+permission = An- und Abmeldung an diesem Webinterface
... ...
@@ -0,0 +1,10 @@
1
+<?php
2
+
3
+if ($_SESSION['role'] & ROLE_CUSTOMER || $_SESSION['role'] & ROLE_SYSTEMUSER) {
4
+  $shortcuts[] = array( 'section' => 'administration', 
5
+                        'weight'  => 90, 
6
+                        'file'    => 'chpass', 
7
+                        'icon'    => 'pwchange.png', 
8
+                        'title'   => 'Passwort ändern',
9
+                        'alert'   => NULL );
10
+}
... ...
@@ -0,0 +1,22 @@
1
+<?php
2
+
3
+if ($_SESSION['role'] & ROLE_CUSTOMER) {
4
+  $alert = NULL;
5
+  include_once('modules/invoice/include/invoice.php');
6
+  $unpayed_invoices = 0;
7
+  $my_invoices = my_invoices();
8
+  foreach($my_invoices AS $inv) {
9
+    if ($inv['bezahlt'] == 0)
10
+      $unpayed_invoices++;
11
+  }
12
+  if ($unpayed_invoices > 0) {
13
+    $alert = $unpayed_invoices.' unbezahlt';
14
+  }
15
+  
16
+  $shortcuts[] = array( 'section' => 'administration', 
17
+                        'weight'  => 50, 
18
+                        'file'    => 'current', 
19
+                        'icon'    => 'invoice.png', 
20
+                        'title'   => 'Ihre Rechnungen',
21
+                        'alert'   => $alert );
22
+}
... ...
@@ -0,0 +1,10 @@
1
+<?php
2
+
3
+if ($_SESSION['role'] & ROLE_CUSTOMER) {
4
+  $shortcuts[] = array( 'section' => 'Jabber', 
5
+                        'weight'  => 10, 
6
+                        'file'    => 'accounts', 
7
+                        'icon'    => 'jabber.png', 
8
+                        'title'   => 'Jabber-Accounts',
9
+                        'alert'   => NULL );
10
+}
... ...
@@ -0,0 +1,10 @@
1
+<?php
2
+
3
+if ($_SESSION['role'] & ROLE_SYSTEMUSER) {
4
+  $shortcuts[] = array( 'section' => 'Datenbank', 
5
+                        'weight'  => 20, 
6
+                        'file'    => 'databases', 
7
+                        'icon'    => 'mysql.png', 
8
+                        'title'   => 'MySQL-Datenbanken',
9
+                        'alert'   => NULL );
10
+}
... ...
@@ -0,0 +1,42 @@
1
+<?php
2
+
3
+if ($_SESSION['role'] & ROLE_SYSTEMUSER) {
4
+  $shortcuts[] = array( 'section' => 'Webserver', 
5
+                        'weight'  => 30, 
6
+                        'file'    => 'vhosts', 
7
+                        'icon'    => 'webserver.png', 
8
+                        'title'   => 'Webserver-Einstellungen',
9
+                        'alert'   => NULL );
10
+}
11
+if ($_SESSION['role'] & ROLE_SYSTEMUSER) {
12
+  $alert = '';
13
+  include_once('modules/vhosts/include/certs.php');
14
+  $certs = user_certs();
15
+  if (count($certs) > 0)
16
+  {
17
+    $num_expired = 0;
18
+    $num_warn = 0;
19
+    foreach ($certs as $c)
20
+    {
21
+      if ($c['valid_until'] <= date('Y-m-d')) {
22
+        $num_expired++;
23
+      } elseif ($c['valid_until'] <= date('Y-m-d', time()+(30*24*3600))) {
24
+        $num_warn++;
25
+      }
26
+    }
27
+    if ($num_expired > 0) {
28
+      $alert .= 'Zertifikate abgelaufen';
29
+    } elseif ($num_warn > 0) {
30
+      $alert .= 'Zertifikate bald abgelaufen';
31
+    }
32
+  }
33
+ 
34
+  if ($alert) {
35
+    $shortcuts[] = array( 'section' => 'Webserver', 
36
+                          'weight'  => 80, 
37
+                          'file'    => 'certs', 
38
+                          'icon'    => 'secure.png', 
39
+                          'title'   => 'SSL-Zertifikate',
40
+                          'alert'   => $alert );
41
+  }
42
+}
... ...
@@ -244,7 +244,7 @@ div.vmailoverview {
244 244
   padding: 1em;
245 245
   /*background-color: #b2c2cb;*/
246 246
   width: 10em;
247
-  min-height: 5em;
247
+  min-height: 7em;
248 248
   text-align: center;
249 249
   background-color: #eee;
250 250
 }
251 251