Code

Updated messages
[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(_("Select to list objects of type '%s'."));
16     }elseif($o_type == "contains"){
17       return(_("Select to list objects containig '%s'."));
18     }
20   }
23   public static function deleteInfo($name= "",$type = "")
24   {
25     if ($name == "") { 
26       if($type == ""){
27         return (_("This object will be deleted!"));
28       }else{
29         return (sprintf(_("This '%s' object will be deleted!"), $type));
30       }
31     }
32     if (!is_array($name)){
33       if($type == ""){
34         return (sprintf(_("This object will be deleted: %s"), "<br><br><i>$name</i>"));
35       }else{
36         return (sprintf(_("This '%s' object will be deleted: %s"),$type, "<br><br><i>$name</i>"));
37       }
38     }
39     if (count($name) == 1){
40       if($type == ""){
41         return (_("This object will be deleted:")."<br>".msgPool::buildList($name));
42       }else{
43         return (sprintf(_("This '%s' object will be deleted:"),$type, "<br>".msgPool::buildList($name)));
44       }
45     }
46     if($type == ""){
47       return (sprintf(_("These objects will be deleted: %s"), "<br>".msgPool::buildList($name)));
48     }else{
49       return (sprintf(_("These '%s' objects will be deleted: %s"),$type, "<br>".msgPool::buildList($name)));
50     }
51   }
54   public static function permDelete($name= "")
55   {
56     if ($name == "") { 
57       return (_("You have no permission to delete this object!"));
58     }
60     if (!is_array($name)){
61       return (_("You have no permission to delete the object:")."<br><br><i>$name</i>");
62     }
64     if (count($name) == 1){
65       return (_("You have no permission to delete the object:")."<br>".msgPool::buildList($name));
66     }
68     return (_("You have no permission to delete these objects:")."<br>".msgPool::buildList($name));
69   }
72   public static function permCreate($name= "")
73   {
74     if ($name == "") { 
75       return (_("You have no permission to create this object!"));
76     }
78     if (!is_array($name)){
79       return (_("You have no permission to create the object:")."<br><br><i>$name</i>");
80     }
82     if (count($name) == 1){
83       return (_("You have no permission to create the object:")."<br>".msgPool::buildList($name));
84     }
86     return (_("You have no permission to create these objects:")."<br>".msgPool::buildList($name));
87   }
90   public static function permModify($name= "")
91   {
92     if ($name == "") { 
93       return (_("You have no permission to modify this object!"));
94     }
96     if (!is_array($name)){
97       return (_("You have no permission to modify the object:")."<br><br><i>$name</i>");
98     }
100     if (count($name) == 1){
101       return (_("You have no permission to modify the object:")."<br>".msgPool::buildList($name));
102     }
104     return (_("You have no permission to modify these objects:")."<br>".msgPool::buildList($name));
105   }
108   public static function permView($name= "")
109   {
110     if ($name == "") { 
111       return (_("You have no permission to view this object!"));
112     }
114     if (!is_array($name)){
115       return (_("You have no permission to view the object:")."<br><br><i>$name</i>");
116     }
118     if (count($name) == 1){
119       return (_("You have no permission to view the object:")."<br>".msgPool::buildList($name));
120     }
122     return (_("You have no permission to view these objects:")."<br>".msgPool::buildList($name));
123   }
126   public static function permMove($name= "")
127   {
128     if ($name == "") { 
129       return (_("You have no permission to move this object!"));
130     }
132     if (!is_array($name)){
133       return (_("You have no permission to move the object:")."<br><br><i>$name</i>");
134     }
136     if (count($name) == 1){
137       return (_("You have no permission to move the object:")."<br>".msgPool::buildList($name));
138     }
140     return (_("You have no permission to move these objects:")."<br>".msgPool::buildList($name));
141   }
144   public static function dbconnect($name, $error= "", $dbinfo= "")
145   {
146     if ($error != ""){
147       $error= "<br><br><i>"._("Error").":</i> ".$error;
148     }
149     if ($dbinfo != ""){
150       $error.= "<br><br><i>"._("Connection information").":</i> ".$dbinfo;
151     }
152     return (sprintf(_("Cannot connect to %s database!"), $name).$error);
153   }
156   public static function dbselect($name, $error= "", $dbinfo= "")
157   {
158     if ($error != ""){
159       $error= "<br><br><i>"._("Error").":</i> ".$error;
160     }
161     if ($dbinfo != ""){
162       $error.= "<br><br><i>"._("Connection information").":</i> ".$dbinfo;
163     }
164     return (sprintf(_("Cannot select %s database!"), $name).$error);
165   }
168   public static function noserver($name)
169   {
170     return (sprintf(_("No %s server defined!"), $name));
171   }
174   public static function dbquery($name, $error= "", $dbinfo= "")
175   {
176     if ($error != ""){
177       $error= "<br><br><i>"._("Error").":</i> ".$error;
178     }
179     if ($dbinfo != ""){
180       $error.= "<br><br><i>"._("Connection information").":</i> ".$dbinfo;
181     }
182     return (sprintf(_("Cannot query %s database!"), $name).$error);
183   }
186   public static function reserved($name)
187   {
188     return (sprintf(_("The field '%s' contains a reserved keyword!"), $name));
189   }
192   public static function cmdnotfound($type, $plugin)
193   {
194     return (sprintf(_("Command specified as %s hook for plugin '%s' does not exist!"), $type, $plugin));
195   }
198   public static function cmdinvalid($type, $command = "",$plugin="")
199   {
200     if(empty($command)){
201       return (sprintf(_("'%s' command is invalid!"), $type));
202     }elseif($command != "" && $plugin != ""){
203       return (sprintf(_("'%s' command (%s) for plugin %s is invalid!"), $type,$command,$plugin));
204     }elseif($plugin != "" && $command =""){
205       return (sprintf(_("'%s' command for plugin %s is invalid!"), $type,$plugin));
206     }else{
207       return (sprintf(_("'%s' command (%s) is invalid!"), $type,$command));
208     }
209   }
212   public static function cmdexecfailed($type, $command = "",$plugin="")
213   {
214     if(empty($command)){
215       return (sprintf(_("Cannot execute '%s' command!"), $type));
216     }elseif($command != "" && $plugin != ""){
217       return (sprintf(_("Cannot execute '%s' command (%s) for plugin %s!"), $type,$command,$plugin));
218     }elseif($plugin != "" && $command =""){
219       return (sprintf(_("Cannot execute '%s' command for plugin %s!"), $type,$plugin));
220     }else{
221       return (sprintf(_("Cannot execute '%s' command (%s)!"), $type,$command));
222     }
223   }
226   public static function toobig($name, $min= "")
227   {
228     if ($min == ""){
229       return (sprintf(_("Value for '%s' is too large!"), $name));
230     } else {
231       return (sprintf(_("'%s' must be smaller than %d!"), $name, $min));
232     }
233   }
236   public static function toosmall($name, $min= "")
237   {
238     if ($min == ""){
239       return (sprintf(_("Value for '%s' is too small!"), $name));
240     } else {
241       return (sprintf(_("'%s' must be %d or above!"), $name, $min));
242     }
243   }
246   public static function depends($name1, $name2)
247   {
248     return (sprintf(_("'%s' depends on '%s' - please provide both values!"), $name1, $name2));
249   }
252   public static function duplicated($name)
253   {
254     return (sprintf(_("There is already an entry with this '%s' attribute in the system!"), $name));
255   }
258   public static function required($name)
259   {
260     return (sprintf(_("The required field '%s' is empty!"), $name));
261   }
264   public static function invalid($name, $data= "", $regex= "", $example= "")
265   {
266     /* Stylize example */
267     if ($example != ""){
268       $example= "<br><br><i>"._("Example").":</i> ".$example;
269     }
271     /* If validChars are posted, take data and paint all invalid
272        characters... */
273     if ($regex) {
274       $result= "";
275       $mismatch= "";
276       foreach (str_split($data) as $currentChar){
277         if (preg_match("$regex", $currentChar)){
278           $result.= $currentChar;
279         } else {
280           $result.= "<font style='color:red;text-decoration:underline;'>".htmlentities($currentChar)."</font>";
281           $mismatch.= $currentChar;
282         }
283       }
285       return sprintf(_("The Field '%s' contains invalid characters"), $name).". ".
286         (strlen($mismatch)==1?sprintf(_("'%s' is not allowed:"), htmlentities($mismatch)):sprintf(_("'%s' are not allowed!"), htmlentities($mismatch))).
287         "<br><br> \"$result\"$example";
288     } else {
289       return sprintf(_("The Field '%s' contains invalid characters"!), $name)."!$example";
290     }
291   }
294   public static function missingext($name)
295   {
296     return sprintf(_("Missing %s PHP extension!"), $name);
297   }
300   public static function cancelButton()
301   {
302     return sprintf(_("Cancel"));
303   }
306   public static function okButton()
307   {
308     return sprintf(_("Ok"));
309   }
312   public static function applyButton()
313   {
314     return sprintf(_("Apply"));
315   }
318   public static function saveButton()
319   {
320     return sprintf(_("Save"));
321   }
324   public static function addButton($what= "")
325   {
326     return $what == "" ? sprintf(_("Add")): sprintf(_("Add %s"), $what);
327   }
330   public static function delButton($what= "")
331   {
332     return $what == "" ? sprintf(_("Delete")): sprintf(_("Delete %s"), $what);
333   }
336   public static function setButton($what= "")
337   {
338     return $what == "" ? sprintf(_("Set")): sprintf(_("Set %s"), $what);
339   }
342   public static function editButton($what= "")
343   {
344     return $what == "" ? sprintf(_("Edit...")): sprintf(_("Edit %s..."), $what);
345   }
348   public static function backButton($what= "")
349   {
350     return _("Back");
351   }
354   public static function buildList($data)
355   {
356     $objects= "";
357     foreach ($data as $key => $value){
358       if (is_numeric($key)){
359         $objects.= "<br>\n<i>$value</i>";
360       } else {
361         $objects.= "<br>\n$value (<i>$key</i>)";
362       }
363     }
364   }
366   public static function noValidExtension($name)
367   {
368     return sprintf(_("This account has no valid %s extensions!"), $name);
369   }
371   public static function featuresEnabled($name, $depends= "")
372   {
373     if ($depends == ""){
374       return sprintf(_("This account has %s settings enabled. You can disable them by clicking below."), $name);
375     } else {
376       if (count($depends) == 1){
377         return sprintf(_("This account has %s settings enabled. To disable them, you'll need to remove the %s settings first!"), $name, $depends);
378       } else {
379         $deps= "";
380         foreach ($depends as $dep){
381           $deps.= "$dep / ";
382         }
383         $deps= preg_replace("/ \/ $/", "", $deps);
384         return sprintf(_("This account has %s settings enabled. To disable them, you'll need to remove the %s settings first!"), $name, $deps);
385       }
386     }
387   }
390   public static function featuresDisabled($name, $depends= "")
391   {
392     if ($depends == ""){
393       return sprintf(_("This account has %s settings disabled. You can enable them by clicking below."), $name);
394     } else {
395       if (count($depends) == 1){
396         return sprintf(_("This account has %s settings disabled. To enable them, you'll need to add the %s settings first!"), $name, $depends);
397       } else {
398         $deps= "";
399         foreach ($depends as $dep){
400           $deps.= "$dep / ";
401         }
402         $deps= preg_replace("/ \/ $/", "", $deps);
403         return sprintf(_("This account has %s features settings. To disable them, you'll need to add the %s settings first!"), $name, $deps);
404       }
405     }
406   }
409   public static function addFeaturesButton($name)
410   {
411     return sprintf(_("Add %s settings"), $name);
412   }
415   public static function removeFeaturesButton($name)
416   {
417     return sprintf(_("Remove %s settings"), $name);
418   }
421   public static function clickEditToChange()
422   {
423     return _("Click the 'Edit' button below to change informations in this dialog");
424   }
427   public static function months()
428   {
429     return array(_("January"), _("February"), _("March"), _("April"),
430         _("May"), _("June"), _("July"), _("August"), _("September"),
431         _("October"), _("November"), _("December"));
432   }
435   public static function weekdays()
436   {
437     return array( _("Sunday"), _("Monday"), _("Tuesday"), _("Wednesday"), _("Thursday"), _("Friday"), _("Saturday"));
438   }
441   public static function ldaperror($error, $dn= "", $type= 0, $plugin= "")
442   {
443     /* Assign headline depending on type */
444     $typemap= array(1 => _("read operation"), _("add operation"), _("modify operation"),
445         _("delete operation"), _("search operation"), _("authentication"));
447     if (isset($typemap[$type])){
448       $headline= sprintf(_("LDAP %s failed!"), $typemap[$type]);
449     } else {
450       $headline= _("LDAP operation failed!");
451     }
453     /* Fill DN information */
454     if ($dn != ""){
455       $dn_info= "<br><br><i>"._("Object").":</i> ".LDAP::fix($dn);
456     }
458     return $headline.$dn_info."<br><br><i>"._("Error").":</i> ".$error;
459   }
462   function incorrectUpload($reason= "")
463   {
464     if ($reason == ""){
465       return _("Upload failed!");
466     }
468     return sprintf(_("Upload failed: %s"), "<br><br><i>$reason</i>");
469   }
472   function siError($error= "")
473   {
474     if ($error == ""){
475       return _("Communication failure with the infrastructure service!");
476     }
477     return sprintf(_("Communication failure with the infrastructure service: %s"), "<br><br>"._("Error").": ".$error);
478   }
481 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
482 ?>