0111b6f4829787585fe7625e4e5254ec55ccd856
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 }elseif($o_type == "descsearch"){
26 return(_("Select to search within descriptions"));
27 }elseif($o_type == "descsearch_small"){
28 return(_("Search in descriptions"));
29 }
31 }
34 public static function deleteInfo($name= "",$type = "")
35 {
36 if ($name == "") {
37 if($type == ""){
38 return (_("This object will be deleted!"));
39 }else{
40 return (sprintf(_("This '%s' object will be deleted!"), $type));
41 }
42 }
43 if (!is_array($name)){
44 if($type == ""){
45 return (sprintf(_("This object will be deleted: %s"), "<br><br><i>$name</i>"));
46 }else{
47 return (sprintf(_("This '%s' object will be deleted: %s"),$type, "<br><br><i>$name</i>"));
48 }
49 }
50 if (count($name) == 1){
51 if($type == ""){
52 return (_("This object will be deleted:")."<br>".msgPool::buildList($name));
53 }else{
54 return (sprintf(_("This '%s' object will be deleted:"),$type). "<br>".msgPool::buildList($name));
55 }
56 }
57 if($type == ""){
58 return (sprintf(_("These objects will be deleted: %s"), "<br>".msgPool::buildList($name)));
59 }else{
60 return (sprintf(_("These '%s' objects will be deleted: %s"),$type, "<br>".msgPool::buildList($name)));
61 }
62 }
65 public static function permDelete($name= "")
66 {
67 if ($name == "") {
68 return (_("You have no permission to delete this object!"));
69 }
71 if (!is_array($name)){
72 return (_("You have no permission to delete the object:")."<br><br><i>$name</i>");
73 }
75 if (count($name) == 1){
76 return (_("You have no permission to delete the object:")."<br>".msgPool::buildList($name));
77 }
79 return (_("You have no permission to delete these objects:")."<br>".msgPool::buildList($name));
80 }
83 public static function permCreate($name= "")
84 {
85 if ($name == "") {
86 return (_("You have no permission to create this object!"));
87 }
89 if (!is_array($name)){
90 return (_("You have no permission to create the object:")."<br><br><i>$name</i>");
91 }
93 if (count($name) == 1){
94 return (_("You have no permission to create the object:")."<br>".msgPool::buildList($name));
95 }
97 return (_("You have no permission to create these objects:")."<br>".msgPool::buildList($name));
98 }
101 public static function permModify($name= "")
102 {
103 if ($name == "") {
104 return (_("You have no permission to modify this object!"));
105 }
107 if (!is_array($name)){
108 return (_("You have no permission to modify the object:")."<br><br><i>$name</i>");
109 }
111 if (count($name) == 1){
112 return (_("You have no permission to modify the object:")."<br>".msgPool::buildList($name));
113 }
115 return (_("You have no permission to modify these objects:")."<br>".msgPool::buildList($name));
116 }
119 public static function permView($name= "")
120 {
121 if ($name == "") {
122 return (_("You have no permission to view this object!"));
123 }
125 if (!is_array($name)){
126 return (_("You have no permission to view the object:")."<br><br><i>$name</i>");
127 }
129 if (count($name) == 1){
130 return (_("You have no permission to view the object:")."<br>".msgPool::buildList($name));
131 }
133 return (_("You have no permission to view these objects:")."<br>".msgPool::buildList($name));
134 }
137 public static function permMove($name= "")
138 {
139 if ($name == "") {
140 return (_("You have no permission to move this object!"));
141 }
143 if (!is_array($name)){
144 return (_("You have no permission to move the object:")."<br><br><i>$name</i>");
145 }
147 if (count($name) == 1){
148 return (_("You have no permission to move the object:")."<br>".msgPool::buildList($name));
149 }
151 return (_("You have no permission to move these objects:")."<br>".msgPool::buildList($name));
152 }
155 public static function dbconnect($name, $error= "", $dbinfo= "")
156 {
157 if ($error != ""){
158 $error= "<br><br><i>"._("Error").":</i> ".$error;
159 }
160 if ($dbinfo != ""){
161 $error.= "<br><br><i>"._("Connection information").":</i> ".$dbinfo;
162 }
163 return (sprintf(_("Cannot connect to %s database!"), $name).$error);
164 }
167 public static function dbselect($name, $error= "", $dbinfo= "")
168 {
169 if ($error != ""){
170 $error= "<br><br><i>"._("Error").":</i> ".$error;
171 }
172 if ($dbinfo != ""){
173 $error.= "<br><br><i>"._("Connection information").":</i> ".$dbinfo;
174 }
175 return (sprintf(_("Cannot select %s database!"), $name).$error);
176 }
179 public static function noserver($name)
180 {
181 return (sprintf(_("No %s server defined!"), $name));
182 }
185 public static function dbquery($name, $error= "", $dbinfo= "")
186 {
187 if ($error != ""){
188 $error= "<br><br><i>"._("Error").":</i> ".$error;
189 }
190 if ($dbinfo != ""){
191 $error.= "<br><br><i>"._("Connection information").":</i> ".$dbinfo;
192 }
193 return (sprintf(_("Cannot query %s database!"), $name).$error);
194 }
197 public static function reserved($name)
198 {
199 return (sprintf(_("The field '%s' contains a reserved keyword!"), $name));
200 }
203 public static function cmdnotfound($type, $plugin)
204 {
205 return (sprintf(_("Command specified as %s hook for plugin '%s' does not exist!"), $type, $plugin));
206 }
209 public static function cmdinvalid($type, $command = "",$plugin="")
210 {
211 if(empty($command)){
212 return (sprintf(_("'%s' command is invalid!"), $type));
213 }elseif($command != "" && $plugin != ""){
214 return (sprintf(_("'%s' command (%s) for plugin %s is invalid!"), $type,$command,$plugin));
215 }elseif($plugin != "" && $command =""){
216 return (sprintf(_("'%s' command for plugin %s is invalid!"), $type,$plugin));
217 }else{
218 return (sprintf(_("'%s' command (%s) is invalid!"), $type,$command));
219 }
220 }
223 public static function cmdexecfailed($type, $command = "",$plugin="")
224 {
225 if(empty($command)){
226 return (sprintf(_("Cannot execute '%s' command!"), $type));
227 }elseif($command != "" && $plugin != ""){
228 return (sprintf(_("Cannot execute '%s' command (%s) for plugin %s!"), $type,$command,$plugin));
229 }elseif($plugin != "" && $command =""){
230 return (sprintf(_("Cannot execute '%s' command for plugin %s!"), $type,$plugin));
231 }else{
232 return (sprintf(_("Cannot execute '%s' command (%s)!"), $type,$command));
233 }
234 }
237 public static function toobig($name, $min= "")
238 {
239 if ($min == ""){
240 return (sprintf(_("Value for '%s' is too large!"), $name));
241 } else {
242 return (sprintf(_("'%s' must be smaller than %d!"), $name, $min));
243 }
244 }
247 public static function toosmall($name, $min= "")
248 {
249 if ($min == ""){
250 return (sprintf(_("Value for '%s' is too small!"), $name));
251 } else {
252 return (sprintf(_("'%s' must be %d or above!"), $name, $min));
253 }
254 }
257 public static function depends($name1, $name2)
258 {
259 return (sprintf(_("'%s' depends on '%s' - please provide both values!"), $name1, $name2));
260 }
263 public static function duplicated($name)
264 {
265 return (sprintf(_("There is already an entry with this '%s' attribute in the system!"), $name));
266 }
269 public static function required($name)
270 {
271 return (sprintf(_("The required field '%s' is empty!"), $name));
272 }
275 public static function invalid($name, $data= "", $regex= "", $example= "")
276 {
277 /* Stylize example */
278 if ($example != ""){
279 $example= "<br><br><i>"._("Example").":</i> ".$example;
280 }
282 /* If validChars are posted, take data and paint all invalid
283 characters... */
284 if ($regex) {
285 $result= "";
286 $mismatch= "";
287 foreach (str_split($data) as $currentChar){
288 if (preg_match("$regex", $currentChar)){
289 $result.= $currentChar;
290 } else {
291 $result.= "<font style='color:red;text-decoration:underline;'>".htmlentities($currentChar)."</font>";
292 $mismatch.= $currentChar;
293 }
294 }
296 return sprintf(_("The Field '%s' contains invalid characters"), $name).". ".
297 (strlen($mismatch)==1?sprintf(_("'%s' is not allowed:"), htmlentities($mismatch)):sprintf(_("'%s' are not allowed!"), htmlentities($mismatch))).
298 "<br><br> \"$result\"$example";
299 } else {
300 return sprintf(_("The Field '%s' contains invalid characters!"), $name)."!$example";
301 }
302 }
305 public static function missingext($name)
306 {
307 return sprintf(_("Missing %s PHP extension!"), $name);
308 }
311 public static function cancelButton()
312 {
313 return sprintf(_("Cancel"));
314 }
317 public static function okButton()
318 {
319 return sprintf(_("Ok"));
320 }
323 public static function applyButton()
324 {
325 return sprintf(_("Apply"));
326 }
329 public static function saveButton()
330 {
331 return sprintf(_("Save"));
332 }
335 public static function addButton($what= "")
336 {
337 return $what == "" ? sprintf(_("Add")): sprintf(_("Add %s"), $what);
338 }
341 public static function delButton($what= "")
342 {
343 return $what == "" ? sprintf(_("Delete")): sprintf(_("Delete %s"), $what);
344 }
347 public static function setButton($what= "")
348 {
349 return $what == "" ? sprintf(_("Set")): sprintf(_("Set %s"), $what);
350 }
353 public static function editButton($what= "")
354 {
355 return $what == "" ? sprintf(_("Edit...")): sprintf(_("Edit %s..."), $what);
356 }
359 public static function backButton($what= "")
360 {
361 return _("Back");
362 }
365 public static function buildList($data)
366 {
367 $objects= "<ul>";
368 foreach ($data as $key => $value){
369 if (is_numeric($key)){
370 $objects.= "<li>\n<i>$value</i></li>";
371 } else {
372 $objects.= "<li>\n$value (<i>$key</i>)</li>";
373 }
374 }
375 $objects.= "</ul>";
376 return($objects);
377 }
379 public static function noValidExtension($name)
380 {
381 return sprintf(_("This account has no valid %s extensions!"), $name);
382 }
384 public static function featuresEnabled($name, $depends= "")
385 {
386 if ($depends == ""){
387 return sprintf(_("This account has %s settings enabled. You can disable them by clicking below."), $name);
388 } else {
389 if (count($depends) == 1){
390 return sprintf(_("This account has %s settings enabled. To disable them, you'll need to remove the %s settings first!"), $name, $depends);
391 } else {
392 $deps= "";
393 foreach ($depends as $dep){
394 $deps.= "$dep / ";
395 }
396 $deps= preg_replace("/ \/ $/", "", $deps);
397 return sprintf(_("This account has %s settings enabled. To disable them, you'll need to remove the %s settings first!"), $name, $deps);
398 }
399 }
400 }
403 public static function featuresDisabled($name, $depends= "")
404 {
405 if ($depends == ""){
406 return sprintf(_("This account has %s settings disabled. You can enable them by clicking below."), $name);
407 } else {
408 if (count($depends) == 1){
409 return sprintf(_("This account has %s settings disabled. To enable them, you'll need to add the %s settings first!"), $name, $depends);
410 } else {
411 $deps= "";
412 foreach ($depends as $dep){
413 $deps.= "$dep / ";
414 }
415 $deps= preg_replace("/ \/ $/", "", $deps);
416 return sprintf(_("This account has %s settings disabled. To enable them, you'll need to add the %s settings first!"), $name, $deps);
417 }
418 }
419 }
422 public static function addFeaturesButton($name)
423 {
424 return sprintf(_("Add %s settings"), $name);
425 }
428 public static function removeFeaturesButton($name)
429 {
430 return sprintf(_("Remove %s settings"), $name);
431 }
434 public static function clickEditToChange()
435 {
436 return _("Click the 'Edit' button below to change informations in this dialog");
437 }
440 public static function months()
441 {
442 return array(_("January"), _("February"), _("March"), _("April"),
443 _("May"), _("June"), _("July"), _("August"), _("September"),
444 _("October"), _("November"), _("December"));
445 }
448 public static function weekdays()
449 {
450 return array( _("Sunday"), _("Monday"), _("Tuesday"), _("Wednesday"), _("Thursday"), _("Friday"), _("Saturday"));
451 }
454 public static function ldaperror($error, $dn= "", $type= 0, $plugin= "")
455 {
456 /* Assign headline depending on type */
457 $typemap= array(1 => _("read operation"), _("add operation"), _("modify operation"),
458 _("delete operation"), _("search operation"), _("authentication"));
460 if (isset($typemap[$type])){
461 $headline= sprintf(_("LDAP %s failed!"), $typemap[$type]);
462 } else {
463 $headline= _("LDAP operation failed!");
464 }
466 /* Fill DN information */
467 if ($dn != ""){
468 $dn_info= "<br><br><i>"._("Object").":</i> ".LDAP::fix($dn);
469 }
471 return $headline.$dn_info."<br><br><i>"._("Error").":</i> ".$error;
472 }
475 public static function incorrectUpload($reason= "")
476 {
477 if ($reason == ""){
478 return _("Upload failed!");
479 }
481 return sprintf(_("Upload failed: %s"), "<br><br><i>$reason</i>");
482 }
485 public static function siError($error= "")
486 {
487 if ($error == ""){
488 return _("Communication failure with the infrastructure service!");
489 }
490 return sprintf(_("Communication failure with the infrastructure service: %s"), "<br><br>"._("Error").": ".$error);
491 }
494 public static function stillInUse($type, $objects= array())
495 {
496 if (!is_array($objects)){
497 return sprintf(_("This '%s' is still in use by this object: %s"), $type, "<br><br>".$objects);
498 }
499 if (count($objects) == 1){
500 return sprintf(_("This '%s' is still in use by this object: %s"), $type, "<br>".msgPool::buildList($objects));
501 }
502 if (count($objects) == 0){
503 return sprintf(_("This '%s' is still in use."), $type);
504 }
505 return sprintf(_("This '%s' is still in use by these objects: %s"), $type, "<br>".msgPool::buildList($objects));
506 }
509 public static function fileDoesNotExist($file)
510 {
511 return sprintf(_("File '%s' does not exist!"), $file);
512 }
515 public static function cannotReadFile($file)
516 {
517 return sprintf(_("Cannot open file '%s' for reading!"), $file);
518 }
521 public static function cannotWriteFile($file)
522 {
523 return sprintf(_("Cannot open file '%s' for writing!"), $file);
524 }
527 public static function invalidConfigurationAttribute($attr)
528 {
529 return sprintf(_("The value for '%s' is currently unconfigured or invalid, please check your configuration file!"), $attr);
530 }
533 public static function cannotDeleteFile($file)
534 {
535 return sprintf(_("Cannot delete file '%s'!"), $file);
536 }
539 public static function cannotCreateFolder($path)
540 {
541 return sprintf(_("Cannot create folder '%s'!"), $path);
542 }
545 public static function cannotDeleteFolder($path)
546 {
547 return sprintf(_("Cannot delete folder '%s'!"), $path);
548 }
551 public static function checkingFor($what)
552 {
553 return sprintf(_("Checking for %s support"), $what);
554 }
557 public static function installPhpModule($what)
558 {
559 return sprintf(_("Install and activate the %s PHP module."), $what);
560 }
563 public static function class_not_found($plugin)
564 {
565 return (sprintf(_("Cannot initialize class '%s'! Maybe there is a plugin missing in your gosa setup?"), $plugin));
566 }
567 }
568 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
569 ?>