c8831f325e1dcfe3c343b852c70d66adbff12a36
1 <?php
2 define ("LDAP_READ", 1);
3 define ("LDAP_ADD", 2);
4 define ("LDAP_MOD", 3);
5 define ("LDAP_DEL", 4);
6 define ("LDAP_SEARCH", 5);
7 define ("LDAP_AUTH", 6);
9 class msgPool
10 {
11 public static function permDelete($name= "")
12 {
13 if ($name == "") {
14 return (_("You have no permission to delete this object!"));
15 }
17 if (!is_array($name)){
18 return (_("You have no permission to delete the object:")."<br><br><i>$name</i>");
19 }
21 msgPool::buildList($name);
22 if (count($name) == 1){
23 return (_("You have no permission to delete the object:")."<br>".msgPool::buildList($name));
24 }
26 return (_("You have no permission to delete these objects:")."<br>".msgPool::buildList($name));
27 }
30 public static function permCreate($name= "")
31 {
32 if ($name == "") {
33 return (_("You have no permission to create this object!"));
34 }
36 if (!is_array($name)){
37 return (_("You have no permission to create the object:")."<br><br><i>$name</i>");
38 }
40 if (count($name) == 1){
41 return (_("You have no permission to create the object:")."<br>".msgPool::buildList($name));
42 }
44 return (_("You have no permission to create these objects:")."<br>".msgPool::buildList($name));
45 }
48 public static function permModify($name= "")
49 {
50 if ($name == "") {
51 return (_("You have no permission to modify this object!"));
52 }
54 if (!is_array($name)){
55 return (_("You have no permission to modify the object:")."<br><br><i>$name</i>");
56 }
58 if (count($name) == 1){
59 return (_("You have no permission to modify the object:")."<br>".msgPool::buildList($name));
60 }
62 return (_("You have no permission to modify these objects:")."<br>".msgPool::buildList($name));
63 }
66 public static function permView($name= "")
67 {
68 if ($name == "") {
69 return (_("You have no permission to view this object!"));
70 }
72 if (!is_array($name)){
73 return (_("You have no permission to view the object:")."<br><br><i>$name</i>");
74 }
76 if (count($name) == 1){
77 return (_("You have no permission to view the object:")."<br>".msgPool::buildList($name));
78 }
80 return (_("You have no permission to view these objects:")."<br>".msgPool::buildList($name));
81 }
84 public static function permMove($name= "")
85 {
86 if ($name == "") {
87 return (_("You have no permission to move this object!"));
88 }
90 if (!is_array($name)){
91 return (_("You have no permission to move the object:")."<br><br><i>$name</i>");
92 }
94 if (count($name) == 1){
95 return (_("You have no permission to move the object:")."<br>".msgPool::buildList($name));
96 }
98 return (_("You have no permission to move these objects:")."<br>".msgPool::buildList($name));
99 }
102 public static function dbconnect($name, $error= "", $dbinfo= "")
103 {
104 if ($error != ""){
105 $error= "<br><br><i>"._("Error").":</i> ".$error;
106 }
107 if ($dbinfo != ""){
108 $error.= "<br><br><i>"._("Connection information").":</i> ".$dbinfo;
109 }
110 return (sprintf(_("Cannot connect to %s database!"), $name).$error);
111 }
114 public static function dbselect($name, $error= "", $dbinfo= "")
115 {
116 if ($error != ""){
117 $error= "<br><br><i>"._("Error").":</i> ".$error;
118 }
119 if ($dbinfo != ""){
120 $error.= "<br><br><i>"._("Connection information").":</i> ".$dbinfo;
121 }
122 return (sprintf(_("Cannot select %s database!"), $name).$error);
123 }
126 public static function noserver($name)
127 {
128 return (sprintf(_("No %s server defined!"), $name));
129 }
132 public static function dbquery($name, $error= "", $dbinfo= "")
133 {
134 if ($error != ""){
135 $error= "<br><br><i>"._("Error").":</i> ".$error;
136 }
137 if ($dbinfo != ""){
138 $error.= "<br><br><i>"._("Connection information").":</i> ".$dbinfo;
139 }
140 return (sprintf(_("Cannot query %s database!"), $name).$error);
141 }
144 public static function reserved($name)
145 {
146 return (sprintf(_("The field '%s' contains a reserved keyword!"), $name));
147 }
150 public static function cmdnotfound($type, $plugin)
151 {
152 return (sprintf(_("Command specified as %s hook for plugin '%s' does not exist!"), $type, $plugin));
153 }
156 public static function toobig($name, $min= "")
157 {
158 if ($min == ""){
159 return (sprintf(_("Value for '%s' is too large!"), $name));
160 } else {
161 return (sprintf(_("'%s' must be smaller than %d!"), $name, $min));
162 }
163 }
166 public static function toosmall($name, $min= "")
167 {
168 if ($min == ""){
169 return (sprintf(_("Value for '%s' is too small!"), $name));
170 } else {
171 return (sprintf(_("'%s' must be %d or above!"), $name, $min));
172 }
173 }
176 public static function depends($name1, $name2)
177 {
178 return (sprintf(_("'%s' depends on '%s' - please provide both values!"), $name1, $name2));
179 }
182 public static function duplicated($name)
183 {
184 return (sprintf(_("There is already an entry with this '%s' attribute in the system!"), $name));
185 }
188 public static function required($name)
189 {
190 return (sprintf(_("The required field '%s' is empty!"), $name));
191 }
194 public static function invalid($name, $data= "", $regex= "", $example= "")
195 {
196 /* Stylize example */
197 if ($example != ""){
198 $example= "<br><br><i>"._("Example").":</i> ".$example;
199 }
201 /* If validChars are posted, take data and paint all invalid
202 characters... */
203 if ($regex) {
204 $result= "";
205 $mismatch= "";
206 foreach (str_split($data) as $currentChar){
207 if (preg_match("$regex", $currentChar)){
208 $result.= $currentChar;
209 } else {
210 $result.= "<font style='color:red;text-decoration:underline;'>".htmlentities($currentChar)."</font>";
211 $mismatch.= $currentChar;
212 }
213 }
215 return sprintf(_("The Field '%s' contains invalid characters"), $name).". ".
216 (strlen($mismatch)==1?sprintf(_("'%s' is not allowed:"), htmlentities($mismatch)):sprintf(_("'%s' are not allowed."), htmlentities($mismatch))).
217 "<br><br> \"$result\"$example";
218 } else {
219 return sprintf(_("The Field '%s' contains invalid characters"), $name)."!$example";
220 }
221 }
224 public static function missingext($name)
225 {
226 return sprintf(_("Missing %s PHP extension!"), $name);
227 }
230 public static function cancelButton()
231 {
232 return sprintf(_("Cancel"));
233 }
236 public static function okButton()
237 {
238 return sprintf(_("Ok"));
239 }
242 public static function applyButton()
243 {
244 return sprintf(_("Apply"));
245 }
248 public static function saveButton()
249 {
250 return sprintf(_("Save"));
251 }
254 public static function addButton($what= "")
255 {
256 return $what == "" ? sprintf(_("Add")): sprintf(_("Add %s"), $what);
257 }
260 public static function delButton($what= "")
261 {
262 return $what == "" ? sprintf(_("Delete")): sprintf(_("Delete %s"), $what);
263 }
266 public static function setButton($what= "")
267 {
268 return $what == "" ? sprintf(_("Set")): sprintf(_("Set %s"), $what);
269 }
272 public static function editButton($what= "")
273 {
274 return $what == "" ? sprintf(_("Edit...")): sprintf(_("Edit %s..."), $what);
275 }
278 public static function backButton($what= "")
279 {
280 return $what == "" ? sprintf(_("Back...")): sprintf(_("Back %s..."), $what);
281 }
284 public static function buildList($data)
285 {
286 $objects= "";
287 foreach ($name as $key => $value){
288 if (is_numeric($key)){
289 $objects.= "<br>\n<i>$value</i>";
290 } else {
291 $objects.= "<br>\n$value (<i>$key</i>)";
292 }
293 }
294 }
296 public static function noValidExtension($name)
297 {
298 return sprintf(_("This account has no valid %s extensions!"), $name);
299 }
301 public static function featuresEnabled($name, $depends= "")
302 {
303 if ($depends == ""){
304 return sprintf(_("This account has %s settings enabled. You can disable them by clicking below."), $name);
305 } else {
306 if (count($depends) == 1){
307 return sprintf(_("This account has %s settings enabled. To disable them, you'll need to remove the %s settings first!"), $name, $depends);
308 } else {
309 $deps= "";
310 foreach ($depends as $dep){
311 $deps.= "$dep / ";
312 }
313 $deps= preg_replace("/ \/ $/", "", $deps);
314 return sprintf(_("This account has %s settings enabled. To disable them, you'll need to remove the %s settings first!"), $name, $deps);
315 }
316 }
317 }
320 public static function featuresDisabled($name, $depends= "")
321 {
322 if ($depends == ""){
323 return sprintf(_("This account has %s settings disabled. You can enable them by clicking below."), $name);
324 } else {
325 if (count($depends) == 1){
326 return sprintf(_("This account has %s settings disabled. To enable them, you'll need to add the %s settings first!"), $name, $depends);
327 } else {
328 $deps= "";
329 foreach ($depends as $dep){
330 $deps.= "$dep / ";
331 }
332 $deps= preg_replace("/ \/ $/", "", $deps);
333 return sprintf(_("This account has %s features settings. To disable them, you'll need to add the %s settings first!"), $name, $deps);
334 }
335 }
336 }
339 public static function addFeaturesButton($name)
340 {
341 return sprintf(_("Add %s settings"), $name);
342 }
345 public static function removeFeaturesButton($name)
346 {
347 return sprintf(_("Remove %s settings"), $name);
348 }
351 public static function clickEditToChange()
352 {
353 return _("Click the 'Edit' button below to change informations in this dialog");
354 }
357 public static function months()
358 {
359 return array(_("January"), _("February"), _("March"), _("April"),
360 _("May"), _("June"), _("July"), _("August"), _("September"),
361 _("October"), _("November"), _("December"));
362 }
365 public static function weekdays()
366 {
367 return array( _("Sunday"), _("Monday"), _("Tuesday"), _("Wednesday"), _("Thursday"), _("Friday"), _("Saturday"));
368 }
371 public static function ldaperror($error, $dn= "", $type= 0, $plugin= "")
372 {
373 /* Assign headline depending on type */
374 $typemap= array(1 => _("read operation"), _("add operation"), _("modify operation"),
375 _("delete operation"), _("search operation"), _("authentication"));
377 if (isset($typemap[$type])){
378 $headline= sprintf(_("LDAP %s failed!"), $typemap[$type]);
379 } else {
380 $headline= _("LDAP operation failed!");
381 }
383 /* Fill DN information */
384 if ($dn != ""){
385 $dn_info= "<br><br><i>"._("Object").":</i> ".LDAP::fix($dn);
386 }
388 return $headline.$dn_info."<br><br><i>"._("Error").":</i> ".$error;
389 }
392 }
394 ?>