Code

Updated kerberos service. Closes #460
[gosa.git] / gosa-core / include / utils / class_msgPool.inc
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 {
12   public static function selectToView($type,$o_type = "")
13   {
14     if($o_type == ""){
15       return(sprintf(_("Select to list objects of type '%s'."),$type));
16     }elseif($o_type == "contains"){
17       return(sprintf(_("Select to list objects containig '%s'."),$type));
18     }elseif($o_type == "enabled"){
19       return(sprintf(_("Select to list objects that have '%s' enabled"),$type));
20     }elseif($o_type == "subsearch"){
21       return(_("Select to search within subtrees"));
22     }elseif($o_type == "subsearch_small"){
23       return(_("Search in subtrees"));
24     }
26   }
29   public static function deleteInfo($name= "",$type = "")
30   {
31     if ($name == "") { 
32       if($type == ""){
33         return (_("This object will be deleted!"));
34       }else{
35         return (sprintf(_("This '%s' object will be deleted!"), $type));
36       }
37     }
38     if (!is_array($name)){
39       if($type == ""){
40         return (sprintf(_("This object will be deleted: %s"), "<br><br><i>$name</i>"));
41       }else{
42         return (sprintf(_("This '%s' object will be deleted: %s"),$type, "<br><br><i>$name</i>"));
43       }
44     }
45     if (count($name) == 1){
46       if($type == ""){
47         return (_("This object will be deleted:")."<br>".msgPool::buildList($name));
48       }else{
49         return (sprintf(_("This '%s' object will be deleted:"),$type). "<br>".msgPool::buildList($name));
50       }
51     }
52     if($type == ""){
53       return (sprintf(_("These objects will be deleted: %s"), "<br>".msgPool::buildList($name)));
54     }else{
55       return (sprintf(_("These '%s' objects will be deleted: %s"),$type, "<br>".msgPool::buildList($name)));
56     }
57   }
60   public static function permDelete($name= "")
61   {
62     if ($name == "") { 
63       return (_("You have no permission to delete this object!"));
64     }
66     if (!is_array($name)){
67       return (_("You have no permission to delete the object:")."<br><br><i>$name</i>");
68     }
70     if (count($name) == 1){
71       return (_("You have no permission to delete the object:")."<br>".msgPool::buildList($name));
72     }
74     return (_("You have no permission to delete these objects:")."<br>".msgPool::buildList($name));
75   }
78   public static function permCreate($name= "")
79   {
80     if ($name == "") { 
81       return (_("You have no permission to create this object!"));
82     }
84     if (!is_array($name)){
85       return (_("You have no permission to create the object:")."<br><br><i>$name</i>");
86     }
88     if (count($name) == 1){
89       return (_("You have no permission to create the object:")."<br>".msgPool::buildList($name));
90     }
92     return (_("You have no permission to create these objects:")."<br>".msgPool::buildList($name));
93   }
96   public static function permModify($name= "")
97   {
98     if ($name == "") { 
99       return (_("You have no permission to modify this object!"));
100     }
102     if (!is_array($name)){
103       return (_("You have no permission to modify the object:")."<br><br><i>$name</i>");
104     }
106     if (count($name) == 1){
107       return (_("You have no permission to modify the object:")."<br>".msgPool::buildList($name));
108     }
110     return (_("You have no permission to modify these objects:")."<br>".msgPool::buildList($name));
111   }
114   public static function permView($name= "")
115   {
116     if ($name == "") { 
117       return (_("You have no permission to view this object!"));
118     }
120     if (!is_array($name)){
121       return (_("You have no permission to view the object:")."<br><br><i>$name</i>");
122     }
124     if (count($name) == 1){
125       return (_("You have no permission to view the object:")."<br>".msgPool::buildList($name));
126     }
128     return (_("You have no permission to view these objects:")."<br>".msgPool::buildList($name));
129   }
132   public static function permMove($name= "")
133   {
134     if ($name == "") { 
135       return (_("You have no permission to move this object!"));
136     }
138     if (!is_array($name)){
139       return (_("You have no permission to move the object:")."<br><br><i>$name</i>");
140     }
142     if (count($name) == 1){
143       return (_("You have no permission to move the object:")."<br>".msgPool::buildList($name));
144     }
146     return (_("You have no permission to move these objects:")."<br>".msgPool::buildList($name));
147   }
150   public static function dbconnect($name, $error= "", $dbinfo= "")
151   {
152     if ($error != ""){
153       $error= "<br><br><i>"._("Error").":</i> ".$error;
154     }
155     if ($dbinfo != ""){
156       $error.= "<br><br><i>"._("Connection information").":</i> ".$dbinfo;
157     }
158     return (sprintf(_("Cannot connect to %s database!"), $name).$error);
159   }
162   public static function dbselect($name, $error= "", $dbinfo= "")
163   {
164     if ($error != ""){
165       $error= "<br><br><i>"._("Error").":</i> ".$error;
166     }
167     if ($dbinfo != ""){
168       $error.= "<br><br><i>"._("Connection information").":</i> ".$dbinfo;
169     }
170     return (sprintf(_("Cannot select %s database!"), $name).$error);
171   }
174   public static function noserver($name)
175   {
176     return (sprintf(_("No %s server defined!"), $name));
177   }
180   public static function dbquery($name, $error= "", $dbinfo= "")
181   {
182     if ($error != ""){
183       $error= "<br><br><i>"._("Error").":</i> ".$error;
184     }
185     if ($dbinfo != ""){
186       $error.= "<br><br><i>"._("Connection information").":</i> ".$dbinfo;
187     }
188     return (sprintf(_("Cannot query %s database!"), $name).$error);
189   }
192   public static function reserved($name)
193   {
194     return (sprintf(_("The field '%s' contains a reserved keyword!"), $name));
195   }
198   public static function cmdnotfound($type, $plugin)
199   {
200     return (sprintf(_("Command specified as %s hook for plugin '%s' does not exist!"), $type, $plugin));
201   }
204   public static function cmdinvalid($type, $command = "",$plugin="")
205   {
206     if(empty($command)){
207       return (sprintf(_("'%s' command is invalid!"), $type));
208     }elseif($command != "" && $plugin != ""){
209       return (sprintf(_("'%s' command (%s) for plugin %s is invalid!"), $type,$command,$plugin));
210     }elseif($plugin != "" && $command =""){
211       return (sprintf(_("'%s' command for plugin %s is invalid!"), $type,$plugin));
212     }else{
213       return (sprintf(_("'%s' command (%s) is invalid!"), $type,$command));
214     }
215   }
218   public static function cmdexecfailed($type, $command = "",$plugin="")
219   {
220     if(empty($command)){
221       return (sprintf(_("Cannot execute '%s' command!"), $type));
222     }elseif($command != "" && $plugin != ""){
223       return (sprintf(_("Cannot execute '%s' command (%s) for plugin %s!"), $type,$command,$plugin));
224     }elseif($plugin != "" && $command =""){
225       return (sprintf(_("Cannot execute '%s' command for plugin %s!"), $type,$plugin));
226     }else{
227       return (sprintf(_("Cannot execute '%s' command (%s)!"), $type,$command));
228     }
229   }
232   public static function toobig($name, $min= "")
233   {
234     if ($min == ""){
235       return (sprintf(_("Value for '%s' is too large!"), $name));
236     } else {
237       return (sprintf(_("'%s' must be smaller than %d!"), $name, $min));
238     }
239   }
242   public static function toosmall($name, $min= "")
243   {
244     if ($min == ""){
245       return (sprintf(_("Value for '%s' is too small!"), $name));
246     } else {
247       return (sprintf(_("'%s' must be %d or above!"), $name, $min));
248     }
249   }
252   public static function depends($name1, $name2)
253   {
254     return (sprintf(_("'%s' depends on '%s' - please provide both values!"), $name1, $name2));
255   }
258   public static function duplicated($name)
259   {
260     return (sprintf(_("There is already an entry with this '%s' attribute in the system!"), $name));
261   }
264   public static function required($name)
265   {
266     return (sprintf(_("The required field '%s' is empty!"), $name));
267   }
270   public static function invalid($name, $data= "", $regex= "", $example= "")
271   {
272     /* Stylize example */
273     if ($example != ""){
274       $example= "<br><br><i>"._("Example").":</i> ".$example;
275     }
277     /* If validChars are posted, take data and paint all invalid
278        characters... */
279     if ($regex) {
280       $result= "";
281       $mismatch= "";
282       foreach (str_split($data) as $currentChar){
283         if (preg_match("$regex", $currentChar)){
284           $result.= $currentChar;
285         } else {
286           $result.= "<font style='color:red;text-decoration:underline;'>".htmlentities($currentChar)."</font>";
287           $mismatch.= $currentChar;
288         }
289       }
291       return sprintf(_("The Field '%s' contains invalid characters"), $name).". ".
292         (strlen($mismatch)==1?sprintf(_("'%s' is not allowed:"), htmlentities($mismatch)):sprintf(_("'%s' are not allowed!"), htmlentities($mismatch))).
293         "<br><br> \"$result\"$example";
294     } else {
295       return sprintf(_("The Field '%s' contains invalid characters!"), $name)."!$example";
296     }
297   }
300   public static function missingext($name)
301   {
302     return sprintf(_("Missing %s PHP extension!"), $name);
303   }
306   public static function cancelButton()
307   {
308     return sprintf(_("Cancel"));
309   }
312   public static function okButton()
313   {
314     return sprintf(_("Ok"));
315   }
318   public static function applyButton()
319   {
320     return sprintf(_("Apply"));
321   }
324   public static function saveButton()
325   {
326     return sprintf(_("Save"));
327   }
330   public static function addButton($what= "")
331   {
332     return $what == "" ? sprintf(_("Add")): sprintf(_("Add %s"), $what);
333   }
336   public static function delButton($what= "")
337   {
338     return $what == "" ? sprintf(_("Delete")): sprintf(_("Delete %s"), $what);
339   }
342   public static function setButton($what= "")
343   {
344     return $what == "" ? sprintf(_("Set")): sprintf(_("Set %s"), $what);
345   }
348   public static function editButton($what= "")
349   {
350     return $what == "" ? sprintf(_("Edit...")): sprintf(_("Edit %s..."), $what);
351   }
354   public static function backButton($what= "")
355   {
356     return _("Back");
357   }
360   public static function buildList($data)
361   {
362     $objects= "";
363     foreach ($data as $key => $value){
364       if (is_numeric($key)){
365         $objects.= "<br>\n<i>$value</i>";
366       } else {
367         $objects.= "<br>\n$value (<i>$key</i>)";
368       }
369     }
370     return($objects);
371   }
373   public static function noValidExtension($name)
374   {
375     return sprintf(_("This account has no valid %s extensions!"), $name);
376   }
378   public static function featuresEnabled($name, $depends= "")
379   {
380     if ($depends == ""){
381       return sprintf(_("This account has %s settings enabled. You can disable them by clicking below."), $name);
382     } else {
383       if (count($depends) == 1){
384         return sprintf(_("This account has %s settings enabled. To disable them, you'll need to remove the %s settings first!"), $name, $depends);
385       } else {
386         $deps= "";
387         foreach ($depends as $dep){
388           $deps.= "$dep / ";
389         }
390         $deps= preg_replace("/ \/ $/", "", $deps);
391         return sprintf(_("This account has %s settings enabled. To disable them, you'll need to remove the %s settings first!"), $name, $deps);
392       }
393     }
394   }
397   public static function featuresDisabled($name, $depends= "")
398   {
399     if ($depends == ""){
400       return sprintf(_("This account has %s settings disabled. You can enable them by clicking below."), $name);
401     } else {
402       if (count($depends) == 1){
403         return sprintf(_("This account has %s settings disabled. To enable them, you'll need to add the %s settings first!"), $name, $depends);
404       } else {
405         $deps= "";
406         foreach ($depends as $dep){
407           $deps.= "$dep / ";
408         }
409         $deps= preg_replace("/ \/ $/", "", $deps);
410         return sprintf(_("This account has %s features settings. To disable them, you'll need to add the %s settings first!"), $name, $deps);
411       }
412     }
413   }
416   public static function addFeaturesButton($name)
417   {
418     return sprintf(_("Add %s settings"), $name);
419   }
422   public static function removeFeaturesButton($name)
423   {
424     return sprintf(_("Remove %s settings"), $name);
425   }
428   public static function clickEditToChange()
429   {
430     return _("Click the 'Edit' button below to change informations in this dialog");
431   }
434   public static function months()
435   {
436     return array(_("January"), _("February"), _("March"), _("April"),
437         _("May"), _("June"), _("July"), _("August"), _("September"),
438         _("October"), _("November"), _("December"));
439   }
442   public static function weekdays()
443   {
444     return array( _("Sunday"), _("Monday"), _("Tuesday"), _("Wednesday"), _("Thursday"), _("Friday"), _("Saturday"));
445   }
448   public static function ldaperror($error, $dn= "", $type= 0, $plugin= "")
449   {
450     /* Assign headline depending on type */
451     $typemap= array(1 => _("read operation"), _("add operation"), _("modify operation"),
452         _("delete operation"), _("search operation"), _("authentication"));
454     if (isset($typemap[$type])){
455       $headline= sprintf(_("LDAP %s failed!"), $typemap[$type]);
456     } else {
457       $headline= _("LDAP operation failed!");
458     }
460     /* Fill DN information */
461     if ($dn != ""){
462       $dn_info= "<br><br><i>"._("Object").":</i> ".LDAP::fix($dn);
463     }
465     return $headline.$dn_info."<br><br><i>"._("Error").":</i> ".$error;
466   }
469   public static function incorrectUpload($reason= "")
470   {
471     if ($reason == ""){
472       return _("Upload failed!");
473     }
475     return sprintf(_("Upload failed: %s"), "<br><br><i>$reason</i>");
476   }
479   public static function siError($error= "")
480   {
481     if ($error == ""){
482       return _("Communication failure with the infrastructure service!");
483     }
484     return sprintf(_("Communication failure with the infrastructure service: %s"), "<br><br>"._("Error").": ".$error);
485   }
488   public static function stillInUse($type, $objects= array())
489   {
490     if (!is_array($objects)){
491       return sprintf(_("This '%s' is still in use by this object: %s"), $type, "<br><br>".$objects);
492     }
493     if (count($objects) == 1){
494       return sprintf(_("This '%s' is still in use by this object: %s"), $type, "<br><br>".msgPool::buildList($objects));
495     }
496     if (count($objects) == 0){
497       return sprintf(_("This '%s' is still in use."), $type);
498     }
499     return sprintf(_("This '%s' is still in use by these objects: %s"), $type, "<br><br>".msgPool::buildList($objects));
500   }
503   public static function fileDoesNotExist($file)
504   {
505     return sprintf(_("File '%s' does not exist!"), $file);
506   }
509   public static function cannotReadFile($file)
510   {
511     return sprintf(_("Cannot open file '%s' for reading!"), $file);
512   }
515   public static function cannotWriteFile($file)
516   {
517     return sprintf(_("Cannot open file '%s' for writing!"), $file);
518   }
521   public static function cannotDeleteFile($file)
522   {
523     return sprintf(_("Cannot delete file '%s'!"), $file);
524   }
527   public static function cannotCreateFolder($path)
528   {
529     return sprintf(_("Cannot create folder '%s'!"), $path);
530   }
533   public static function cannotDeleteFolder($path)
534   {
535     return sprintf(_("Cannot delete folder '%s'!"), $path);
536   }
539   public static function checkingFor($what)
540   {
541     return sprintf(_("Checking for %s support"), $what);
542   }
545   public static function installPhpModule($what)
546   {
547     return sprintf(_("Install and activate the %s PHP module."), $what);
548   }
551 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
552 ?>