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 /*! \brief Some common needed messages */
10 class msgPool
11 {
13 public static function selectToView($type,$o_type = "")
14 {
15 if($o_type == ""){
16 return(sprintf(_("Select to list objects of type '%s'."),$type));
17 }elseif($o_type == "contains"){
18 return(sprintf(_("Select to list objects containig '%s'."),$type));
19 }elseif($o_type == "enabled"){
20 return(sprintf(_("Select to list objects that have '%s' enabled"),$type));
21 }elseif($o_type == "subsearch"){
22 return(_("Select to search within subtrees"));
23 }elseif($o_type == "subsearch_small"){
24 return(_("Search in subtrees"));
25 }
27 }
30 public static function deleteInfo($name= "",$type = "")
31 {
32 if ($name == "") {
33 if($type == ""){
34 return (_("This object will be deleted!"));
35 }else{
36 return (sprintf(_("This '%s' object will be deleted!"), $type));
37 }
38 }
39 if (!is_array($name)){
40 if($type == ""){
41 return (sprintf(_("This object will be deleted: %s"), "<br><br><i>$name</i>"));
42 }else{
43 return (sprintf(_("This '%s' object will be deleted: %s"),$type, "<br><br><i>$name</i>"));
44 }
45 }
46 if (count($name) == 1){
47 if($type == ""){
48 return (_("This object will be deleted:")."<br>".msgPool::buildList($name));
49 }else{
50 return (sprintf(_("This '%s' object will be deleted:"),$type). "<br>".msgPool::buildList($name));
51 }
52 }
53 if($type == ""){
54 return (sprintf(_("These objects will be deleted: %s"), "<br>".msgPool::buildList($name)));
55 }else{
56 return (sprintf(_("These '%s' objects will be deleted: %s"),$type, "<br>".msgPool::buildList($name)));
57 }
58 }
61 public static function permDelete($name= "")
62 {
63 if ($name == "") {
64 return (_("You have no permission to delete this object!"));
65 }
67 if (!is_array($name)){
68 return (_("You have no permission to delete the object:")."<br><br><i>$name</i>");
69 }
71 if (count($name) == 1){
72 return (_("You have no permission to delete the object:")."<br>".msgPool::buildList($name));
73 }
75 return (_("You have no permission to delete these objects:")."<br>".msgPool::buildList($name));
76 }
79 public static function permCreate($name= "")
80 {
81 if ($name == "") {
82 return (_("You have no permission to create this object!"));
83 }
85 if (!is_array($name)){
86 return (_("You have no permission to create the object:")."<br><br><i>$name</i>");
87 }
89 if (count($name) == 1){
90 return (_("You have no permission to create the object:")."<br>".msgPool::buildList($name));
91 }
93 return (_("You have no permission to create these objects:")."<br>".msgPool::buildList($name));
94 }
97 public static function permModify($name= "")
98 {
99 if ($name == "") {
100 return (_("You have no permission to modify this object!"));
101 }
103 if (!is_array($name)){
104 return (_("You have no permission to modify the object:")."<br><br><i>$name</i>");
105 }
107 if (count($name) == 1){
108 return (_("You have no permission to modify the object:")."<br>".msgPool::buildList($name));
109 }
111 return (_("You have no permission to modify these objects:")."<br>".msgPool::buildList($name));
112 }
115 public static function permView($name= "")
116 {
117 if ($name == "") {
118 return (_("You have no permission to view this object!"));
119 }
121 if (!is_array($name)){
122 return (_("You have no permission to view the object:")."<br><br><i>$name</i>");
123 }
125 if (count($name) == 1){
126 return (_("You have no permission to view the object:")."<br>".msgPool::buildList($name));
127 }
129 return (_("You have no permission to view these objects:")."<br>".msgPool::buildList($name));
130 }
133 public static function permMove($name= "")
134 {
135 if ($name == "") {
136 return (_("You have no permission to move this object!"));
137 }
139 if (!is_array($name)){
140 return (_("You have no permission to move the object:")."<br><br><i>$name</i>");
141 }
143 if (count($name) == 1){
144 return (_("You have no permission to move the object:")."<br>".msgPool::buildList($name));
145 }
147 return (_("You have no permission to move these objects:")."<br>".msgPool::buildList($name));
148 }
151 public static function dbconnect($name, $error= "", $dbinfo= "")
152 {
153 if ($error != ""){
154 $error= "<br><br><i>"._("Error").":</i> ".$error;
155 }
156 if ($dbinfo != ""){
157 $error.= "<br><br><i>"._("Connection information").":</i> ".$dbinfo;
158 }
159 return (sprintf(_("Cannot connect to %s database!"), $name).$error);
160 }
163 public static function dbselect($name, $error= "", $dbinfo= "")
164 {
165 if ($error != ""){
166 $error= "<br><br><i>"._("Error").":</i> ".$error;
167 }
168 if ($dbinfo != ""){
169 $error.= "<br><br><i>"._("Connection information").":</i> ".$dbinfo;
170 }
171 return (sprintf(_("Cannot select %s database!"), $name).$error);
172 }
175 public static function noserver($name)
176 {
177 return (sprintf(_("No %s server defined!"), $name));
178 }
181 public static function dbquery($name, $error= "", $dbinfo= "")
182 {
183 if ($error != ""){
184 $error= "<br><br><i>"._("Error").":</i> ".$error;
185 }
186 if ($dbinfo != ""){
187 $error.= "<br><br><i>"._("Connection information").":</i> ".$dbinfo;
188 }
189 return (sprintf(_("Cannot query %s database!"), $name).$error);
190 }
193 public static function reserved($name)
194 {
195 return (sprintf(_("The field '%s' contains a reserved keyword!"), $name));
196 }
199 public static function cmdnotfound($type, $plugin)
200 {
201 return (sprintf(_("Command specified as %s hook for plugin '%s' does not exist!"), $type, $plugin));
202 }
205 public static function cmdinvalid($type, $command = "",$plugin="")
206 {
207 if(empty($command)){
208 return (sprintf(_("'%s' command is invalid!"), $type));
209 }elseif($command != "" && $plugin != ""){
210 return (sprintf(_("'%s' command (%s) for plugin %s is invalid!"), $type,$command,$plugin));
211 }elseif($plugin != "" && $command =""){
212 return (sprintf(_("'%s' command for plugin %s is invalid!"), $type,$plugin));
213 }else{
214 return (sprintf(_("'%s' command (%s) is invalid!"), $type,$command));
215 }
216 }
219 public static function cmdexecfailed($type, $command = "",$plugin="")
220 {
221 if(empty($command)){
222 return (sprintf(_("Cannot execute '%s' command!"), $type));
223 }elseif($command != "" && $plugin != ""){
224 return (sprintf(_("Cannot execute '%s' command (%s) for plugin %s!"), $type,$command,$plugin));
225 }elseif($plugin != "" && $command =""){
226 return (sprintf(_("Cannot execute '%s' command for plugin %s!"), $type,$plugin));
227 }else{
228 return (sprintf(_("Cannot execute '%s' command (%s)!"), $type,$command));
229 }
230 }
233 public static function toobig($name, $min= "")
234 {
235 if ($min == ""){
236 return (sprintf(_("Value for '%s' is too large!"), $name));
237 } else {
238 return (sprintf(_("'%s' must be smaller than %s!"), $name, $min));
239 }
240 }
243 public static function toosmall($name, $min= "")
244 {
245 if ($min == ""){
246 return (sprintf(_("Value for '%s' is too small!"), $name));
247 } else {
248 return (sprintf(_("'%s' must be %d or above!"), $name, $min));
249 }
250 }
253 public static function depends($name1, $name2)
254 {
255 return (sprintf(_("'%s' depends on '%s' - please provide both values!"), $name1, $name2));
256 }
259 public static function duplicated($name)
260 {
261 return (sprintf(_("There is already an entry with this '%s' attribute in the system!"), $name));
262 }
265 public static function required($name)
266 {
267 return (sprintf(_("The required field '%s' is empty!"), $name));
268 }
271 public static function invalid($name, $data= "", $regex= "", $example= "")
272 {
273 /* Stylize example */
274 if ($example != ""){
275 $example= "<br><br><i>"._("Example").":</i> ".$example;
276 }
278 /* If validChars are posted, take data and paint all invalid
279 characters... */
280 if ($regex) {
281 $result= "";
282 $mismatch= "";
283 foreach (str_split($data) as $currentChar){
284 if (preg_match("$regex", $currentChar)){
285 $result.= $currentChar;
286 } else {
287 $result.= "<font style='color:red;text-decoration:underline;'>".htmlentities($currentChar)."</font>";
288 $mismatch.= $currentChar;
289 }
290 }
292 return sprintf(_("The Field '%s' contains invalid characters"), $name).". ".
293 (strlen($mismatch)==1?sprintf(_("'%s' is not allowed:"), htmlentities($mismatch)):sprintf(_("'%s' are not allowed!"), htmlentities($mismatch))).
294 "<br><br> \"$result\"$example";
295 } else {
296 return sprintf(_("The Field '%s' contains invalid characters!"), $name)."!$example";
297 }
298 }
301 public static function missingext($name)
302 {
303 return sprintf(_("Missing %s PHP extension!"), $name);
304 }
307 public static function cancelButton()
308 {
309 return sprintf(_("Cancel"));
310 }
313 public static function okButton()
314 {
315 return sprintf(_("Ok"));
316 }
319 public static function applyButton()
320 {
321 return sprintf(_("Apply"));
322 }
325 public static function saveButton()
326 {
327 return sprintf(_("Save"));
328 }
331 public static function addButton($what= "")
332 {
333 return $what == "" ? sprintf(_("Add")): sprintf(_("Add %s"), $what);
334 }
337 public static function delButton($what= "")
338 {
339 return $what == "" ? sprintf(_("Delete")): sprintf(_("Delete %s"), $what);
340 }
343 public static function setButton($what= "")
344 {
345 return $what == "" ? sprintf(_("Set")): sprintf(_("Set %s"), $what);
346 }
349 public static function editButton($what= "")
350 {
351 return $what == "" ? sprintf(_("Edit...")): sprintf(_("Edit %s..."), $what);
352 }
355 public static function backButton($what= "")
356 {
357 return _("Back");
358 }
361 public static function buildList($data)
362 {
363 $objects= "<ul>";
364 foreach ($data as $key => $value){
365 if (is_numeric($key)){
366 $objects.= "<li>\n<i>$value</i></li>";
367 } else {
368 $objects.= "<li>\n$value (<i>$key</i>)</li>";
369 }
370 }
371 $objects.= "</ul>";
372 return($objects);
373 }
375 public static function noValidExtension($name)
376 {
377 return sprintf(_("This account has no valid %s extensions!"), $name);
378 }
380 public static function featuresEnabled($name, $depends= "")
381 {
382 if ($depends == ""){
383 return sprintf(_("This account has %s settings enabled. You can disable them by clicking below."), $name);
384 } else {
385 if (count($depends) == 1){
386 return sprintf(_("This account has %s settings enabled. To disable them, you'll need to remove the %s settings first!"), $name, $depends);
387 } else {
388 $deps= "";
389 foreach ($depends as $dep){
390 $deps.= "$dep / ";
391 }
392 $deps= preg_replace("/ \/ $/", "", $deps);
393 return sprintf(_("This account has %s settings enabled. To disable them, you'll need to remove the %s settings first!"), $name, $deps);
394 }
395 }
396 }
399 public static function featuresDisabled($name, $depends= "")
400 {
401 if ($depends == ""){
402 return sprintf(_("This account has %s settings disabled. You can enable them by clicking below."), $name);
403 } else {
404 if (count($depends) == 1){
405 return sprintf(_("This account has %s settings disabled. To enable them, you'll need to add the %s settings first!"), $name, $depends);
406 } else {
407 $deps= "";
408 foreach ($depends as $dep){
409 $deps.= "$dep / ";
410 }
411 $deps= preg_replace("/ \/ $/", "", $deps);
412 return sprintf(_("This account has %s settings disabled. To enable them, you'll need to add the %s settings first!"), $name, $deps);
413 }
414 }
415 }
418 public static function addFeaturesButton($name)
419 {
420 return sprintf(_("Add %s settings"), $name);
421 }
424 public static function removeFeaturesButton($name)
425 {
426 return sprintf(_("Remove %s settings"), $name);
427 }
430 public static function clickEditToChange()
431 {
432 return _("Click the 'Edit' button below to change informations in this dialog");
433 }
436 public static function months()
437 {
438 return array(_("January"), _("February"), _("March"), _("April"),
439 _("May"), _("June"), _("July"), _("August"), _("September"),
440 _("October"), _("November"), _("December"));
441 }
444 public static function weekdays()
445 {
446 return array( _("Sunday"), _("Monday"), _("Tuesday"), _("Wednesday"), _("Thursday"), _("Friday"), _("Saturday"));
447 }
450 public static function mysqlerror($error, $plugin= "")
451 {
452 /* Assign headline depending on type */
453 $headline= _("MySQL operation failed!");
454 return $headline."<br><br><i>"._("Error").":</i> ".$error;
455 }
458 public static function ldaperror($error, $dn= "", $type= 0, $plugin= "")
459 {
460 /* Assign headline depending on type */
461 $typemap= array(1 => _("read operation"), _("add operation"), _("modify operation"),
462 _("delete operation"), _("search operation"), _("authentication"));
464 if (isset($typemap[$type])){
465 $headline= sprintf(_("LDAP %s failed!"), $typemap[$type]);
466 } else {
467 $headline= _("LDAP operation failed!");
468 }
470 /* Fill DN information */
471 if ($dn != ""){
472 $dn_info= "<br><br><i>"._("Object").":</i> ".LDAP::fix($dn);
473 }
475 return $headline.$dn_info."<br><br><i>"._("Error").":</i> ".$error;
476 }
479 public static function incorrectUpload($reason= "")
480 {
481 if ($reason == ""){
482 return _("Upload failed!");
483 }
485 return sprintf(_("Upload failed: %s"), "<br><br><i>$reason</i>");
486 }
489 public static function siError($error= "")
490 {
491 if ($error == ""){
492 return _("Communication failure with the infrastructure service!");
493 }
494 return sprintf(_("Communication failure with the infrastructure service: %s"), "<br><br>"._("Error").": ".$error);
495 }
498 public static function stillInUse($type, $objects= array())
499 {
500 if (!is_array($objects)){
501 return sprintf(_("This '%s' is still in use by this object: %s"), $type, "<br><br>".$objects);
502 }
503 if (count($objects) == 1){
504 return sprintf(_("This '%s' is still in use by this object: %s"), $type, "<br>".msgPool::buildList($objects));
505 }
506 if (count($objects) == 0){
507 return sprintf(_("This '%s' is still in use."), $type);
508 }
509 return sprintf(_("This '%s' is still in use by these objects: %s"), $type, "<br>".msgPool::buildList($objects));
510 }
513 public static function fileDoesNotExist($file)
514 {
515 return sprintf(_("File '%s' does not exist!"), $file);
516 }
519 public static function cannotReadFile($file)
520 {
521 return sprintf(_("Cannot open file '%s' for reading!"), $file);
522 }
525 public static function cannotWriteFile($file)
526 {
527 return sprintf(_("Cannot open file '%s' for writing!"), $file);
528 }
531 public static function invalidConfigurationAttribute($attr)
532 {
533 return sprintf(_("The value for '%s' is currently unconfigured or invalid, please check your configuration file!"), $attr);
534 }
537 public static function cannotDeleteFile($file)
538 {
539 return sprintf(_("Cannot delete file '%s'!"), $file);
540 }
543 public static function cannotCreateFolder($path)
544 {
545 return sprintf(_("Cannot create folder '%s'!"), $path);
546 }
549 public static function cannotDeleteFolder($path)
550 {
551 return sprintf(_("Cannot delete folder '%s'!"), $path);
552 }
555 public static function checkingFor($what)
556 {
557 return sprintf(_("Checking for %s support"), $what);
558 }
561 public static function installPhpModule($what)
562 {
563 return sprintf(_("Install and activate the %s PHP module."), $what);
564 }
567 public static function class_not_found($plugin)
568 {
569 return (sprintf(_("Cannot initialize class '%s'! Maybe there is a plugin missing in your gosa setup?"), $plugin));
570 }
571 }
572 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
573 ?>