Code

Removed Back
[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 toobig($name, $min= "")
199   {
200     if ($min == ""){
201       return (sprintf(_("Value for '%s' is too large!"), $name));
202     } else {
203       return (sprintf(_("'%s' must be smaller than %d!"), $name, $min));
204     }
205   }
208   public static function toosmall($name, $min= "")
209   {
210     if ($min == ""){
211       return (sprintf(_("Value for '%s' is too small!"), $name));
212     } else {
213       return (sprintf(_("'%s' must be %d or above!"), $name, $min));
214     }
215   }
218   public static function depends($name1, $name2)
219   {
220     return (sprintf(_("'%s' depends on '%s' - please provide both values!"), $name1, $name2));
221   }
224   public static function duplicated($name)
225   {
226     return (sprintf(_("There is already an entry with this '%s' attribute in the system!"), $name));
227   }
230   public static function required($name)
231   {
232     return (sprintf(_("The required field '%s' is empty!"), $name));
233   }
236   public static function invalid($name, $data= "", $regex= "", $example= "")
237   {
238     /* Stylize example */
239     if ($example != ""){
240       $example= "<br><br><i>"._("Example").":</i> ".$example;
241     }
243     /* If validChars are posted, take data and paint all invalid
244        characters... */
245     if ($regex) {
246       $result= "";
247       $mismatch= "";
248       foreach (str_split($data) as $currentChar){
249         if (preg_match("$regex", $currentChar)){
250           $result.= $currentChar;
251         } else {
252           $result.= "<font style='color:red;text-decoration:underline;'>".htmlentities($currentChar)."</font>";
253           $mismatch.= $currentChar;
254         }
255       }
257       return sprintf(_("The Field '%s' contains invalid characters"), $name).". ".
258         (strlen($mismatch)==1?sprintf(_("'%s' is not allowed:"), htmlentities($mismatch)):sprintf(_("'%s' are not allowed."), htmlentities($mismatch))).
259         "<br><br> \"$result\"$example";
260     } else {
261       return sprintf(_("The Field '%s' contains invalid characters"), $name)."!$example";
262     }
263   }
266   public static function missingext($name)
267   {
268     return sprintf(_("Missing %s PHP extension!"), $name);
269   }
272   public static function cancelButton()
273   {
274     return sprintf(_("Cancel"));
275   }
278   public static function okButton()
279   {
280     return sprintf(_("Ok"));
281   }
284   public static function applyButton()
285   {
286     return sprintf(_("Apply"));
287   }
290   public static function saveButton()
291   {
292     return sprintf(_("Save"));
293   }
296   public static function addButton($what= "")
297   {
298     return $what == "" ? sprintf(_("Add")): sprintf(_("Add %s"), $what);
299   }
302   public static function delButton($what= "")
303   {
304     return $what == "" ? sprintf(_("Delete")): sprintf(_("Delete %s"), $what);
305   }
308   public static function setButton($what= "")
309   {
310     return $what == "" ? sprintf(_("Set")): sprintf(_("Set %s"), $what);
311   }
314   public static function editButton($what= "")
315   {
316     return $what == "" ? sprintf(_("Edit...")): sprintf(_("Edit %s..."), $what);
317   }
320   public static function backButton($what= "")
321   {
322     return _("Back");
323   }
326   public static function buildList($data)
327   {
328     $objects= "";
329     foreach ($data as $key => $value){
330       if (is_numeric($key)){
331         $objects.= "<br>\n<i>$value</i>";
332       } else {
333         $objects.= "<br>\n$value (<i>$key</i>)";
334       }
335     }
336   }
338   public static function noValidExtension($name)
339   {
340     return sprintf(_("This account has no valid %s extensions!"), $name);
341   }
343   public static function featuresEnabled($name, $depends= "")
344   {
345     if ($depends == ""){
346       return sprintf(_("This account has %s settings enabled. You can disable them by clicking below."), $name);
347     } else {
348       if (count($depends) == 1){
349         return sprintf(_("This account has %s settings enabled. To disable them, you'll need to remove the %s settings first!"), $name, $depends);
350       } else {
351         $deps= "";
352         foreach ($depends as $dep){
353           $deps.= "$dep / ";
354         }
355         $deps= preg_replace("/ \/ $/", "", $deps);
356         return sprintf(_("This account has %s settings enabled. To disable them, you'll need to remove the %s settings first!"), $name, $deps);
357       }
358     }
359   }
362   public static function featuresDisabled($name, $depends= "")
363   {
364     if ($depends == ""){
365       return sprintf(_("This account has %s settings disabled. You can enable them by clicking below."), $name);
366     } else {
367       if (count($depends) == 1){
368         return sprintf(_("This account has %s settings disabled. To enable them, you'll need to add the %s settings first!"), $name, $depends);
369       } else {
370         $deps= "";
371         foreach ($depends as $dep){
372           $deps.= "$dep / ";
373         }
374         $deps= preg_replace("/ \/ $/", "", $deps);
375         return sprintf(_("This account has %s features settings. To disable them, you'll need to add the %s settings first!"), $name, $deps);
376       }
377     }
378   }
381   public static function addFeaturesButton($name)
382   {
383     return sprintf(_("Add %s settings"), $name);
384   }
387   public static function removeFeaturesButton($name)
388   {
389     return sprintf(_("Remove %s settings"), $name);
390   }
393   public static function clickEditToChange()
394   {
395     return _("Click the 'Edit' button below to change informations in this dialog");
396   }
399   public static function months()
400   {
401     return array(_("January"), _("February"), _("March"), _("April"),
402         _("May"), _("June"), _("July"), _("August"), _("September"),
403         _("October"), _("November"), _("December"));
404   }
407   public static function weekdays()
408   {
409     return array( _("Sunday"), _("Monday"), _("Tuesday"), _("Wednesday"), _("Thursday"), _("Friday"), _("Saturday"));
410   }
413   public static function ldaperror($error, $dn= "", $type= 0, $plugin= "")
414   {
415     /* Assign headline depending on type */
416     $typemap= array(1 => _("read operation"), _("add operation"), _("modify operation"),
417         _("delete operation"), _("search operation"), _("authentication"));
419     if (isset($typemap[$type])){
420       $headline= sprintf(_("LDAP %s failed!"), $typemap[$type]);
421     } else {
422       $headline= _("LDAP operation failed!");
423     }
425     /* Fill DN information */
426     if ($dn != ""){
427       $dn_info= "<br><br><i>"._("Object").":</i> ".LDAP::fix($dn);
428     }
430     return $headline.$dn_info."<br><br><i>"._("Error").":</i> ".$error;
431   }
434   function incorrectUpload($reason= "")
435   {
436     if ($reason == ""){
437       return _("Upload failed!");
438     }
440     return sprintf(_("Upload failed: %s"), "<br><br><i>$reason</i>");
441   }
444 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
445 ?>