summaryrefslogtreecommitdiffstats
path: root/library/Pbs/Notifier.php
blob: 5e685fd925ac5404b828dc78bd9c17537ff11dc7 (plain) (blame)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?php
/*
 * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
 * This program is free software distributed under the GPL version 2.
 * See http://gpl.openslx.org/
 *
 * If you have any feedback please consult http://feedback.openslx.org/ and
 * send your suggestions, praise, or complaints to feedback@openslx.org
 *
 * General information about OpenSLX can be found at http://openslx.org/
 */

class Pbs_Notifier {


  public static function notify($action, $result) {

    switch($action) {
    default:
        switch($result) {
        case "forbidden":
          $result = "errorbox";
          break;
        case "ok":
          $result = "okbox";
          break;
        case "error":
          $result = "warningbox";
          break;
        case "info":
          $result = "infobox";
          break;
        }
      $result = "<div class='$result'>$action</div>";
      break;
    case "delete":
      switch($result) {
      case "forbidden":
        $result = "<div class='errorbox'>Not allowed to delete this</div>";
        break;
      case "ok":
        $result = "<div class='okbox'>Delete sucessful</div>";
        break;
      case "error":
        $result = "<div class='warningbox'>Delete failed</div>";
        break;
      }
      break;
    case "certificate":
      switch($result) {
      case "forbidden":
        $result = "<div class='errorbox'>Your certificate has either expired or was revoked. Please contact a PBS Administrator</div>";
        break;
      }
      break;
    case "view":
      switch($result) {
      case "forbidden":
        $result = "<div class='errorbox'>Not allowed to see this</div>";
        break;
      }
      break;
    case "download":
      switch($result) {
      case "forbidden":
        $result = "<div class='errorbox'>Not allowed to download this</div>";
        break;
      case "404":
        $result = "<div class='errorbox'>The Resource was not found on the Server</div>";
        break;
      case "error":
        $result = "<div class='errorbox'>Download failed</div>";
        break;
      }
      break;
    case "modify":
      switch($result) {
      case "forbidden":
        $result = "<div class='errorbox'>Not allowed to modify this</div>";
        break;
      case "ok":
        $result = "<div class='okbox'>Modify sucessful</div>";
        break;
      case "error":
        $result = "<div class='warningbox'>Modify failed</div>";
        break;
      }
      break;
    case "create":
      switch($result) {
      case "forbidden":
        $result = "<div class='errorbox'>Not allowed to create this</div>";
        break;
      case "ok":
        $result = "<div class='okbox'>Creation sucessful</div>";
        break;
      case "error":
        $result = "<div class='warningbox'>Creation failed</div>";
        break;
      case "file":
        $result = "<div class='errorbox'>The File must be greater than 0 bytes</div>";
        break;
      }
      break;
    case "update":
      switch($result) {
      case "forbidden":
        $result = "<div class='errorbox'>Not allowed to update this</div>";
        break;
      case "404":
        $result = "<div class='errorbox'>The Resource was not found on the specified path</div>";
        break;
      case "ok":
        $result = "<div class='okbox'>Update sucessful</div>";
        break;
      case "error":
        $result = "<div class='warningbox'>Update failed</div>";
        break;
      }
      break;
    case "serial":
      switch($result) {
      case "noserial":
        $result = "<div class='errorbox'>Your PreBoot is broken, please download a new Version or contact a PBS Administrator</div>";
        break;
      }
      break;
    case "link":
      switch($result) {
      case "forbidden":
        $result = "<div class='errorbox'>Not allowed to link this</div>";
        break;
      case "ok":
        $result = "<div class='okbox'>Link sucessful</div>";
        break;
      case "error":
        $result = "<div class='warningbox'>Link failed</div>";
        break;
      }
      break;
    case "unlink":
      switch($result) {
      case "forbidden":
        $result = "<div class='errorbox'>Not allowed to unlink this</div>";
        break;
      case "ok":
        $result = "<div class='okbox'>Unlink sucessful</div>";
        break;
      case "error":
        $result = "<div class='warningbox'>Unlink failed</div>";
        break;
      }
      break;
    case "json":
      switch($result) {
      default: {
        $result = unserialize($result);

        $result2 = "<div class='infobox'>";
        $result2 .= "<table class='json'>";
        $result2 .= "<tr><td><b>info</b>: </td><td>".$result['info']."</td></tr>";
        $result2 .= "<tr><td><b>kernel</b>:  </td><td><a href=".$result['kernel'].">".$result['kernel']."<a></td></tr>";
        $result2 .= "<tr><td><b>initramfs</b>:  </td><td><a href=".$result['initramfs'].">".$result['initramfs']."<a></td></tr>";
        $result2 .= "<tr><td><b>kcl</b>:  </td><td><a href=".$result['kcl'].">".$result['kcl']."<a></td></tr>";
        $result2 .= "<tr><td><b>config</b>:  </td><td>".$result['config']."</td></tr>";
        $result2 .= "</table>";
        $result2 .= "</div>";
        $result = $result2;
      }
      break;
      case "forbidden":
        $result = "<div class='errorbox'>Not allowed to display ressources</div>";
        break;
      case "error":
        $result = "<div class='warningbox'>Displaying ressources failed</div>";
        break;
      }
      break;
    }
    return $result;

  }
}

?>