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= "";
284 mb_internal_encoding('UTF-8');
285 for($i=0; $i<=mb_strlen($data);$i++){
286 $currentChar= mb_substr($data, $i,1);
287 if (preg_match("$regex", $currentChar)){
288 $result.= $currentChar;
289 } else {
290 $result.= "<font style='color:red;text-decoration:underline;'>".($currentChar)."</font>";
291 $mismatch.= $currentChar;
292 }
293 }
295 return sprintf(_("The Field '%s' contains invalid characters"), $name).". ".
296 (strlen($mismatch)==1?sprintf(_("'%s' is not allowed:"), $mismatch):sprintf(_("'%s' are not allowed!"), $mismatch)).
297 "<br><br> \"$result\"$example";
298 } else {
299 return sprintf(_("The Field '%s' contains invalid characters!"), $name)."!$example";
300 }
301 }
304 public static function missingext($name)
305 {
306 return sprintf(_("Missing %s PHP extension!"), $name);
307 }
310 public static function cancelButton()
311 {
312 return sprintf(_("Cancel"));
313 }
316 public static function okButton()
317 {
318 return sprintf(_("Ok"));
319 }
322 public static function applyButton()
323 {
324 return sprintf(_("Apply"));
325 }
328 public static function saveButton()
329 {
330 return sprintf(_("Save"));
331 }
334 public static function addButton($what= "")
335 {
336 return $what == "" ? sprintf(_("Add")): sprintf(_("Add %s"), $what);
337 }
340 public static function delButton($what= "")
341 {
342 return $what == "" ? sprintf(_("Delete")): sprintf(_("Delete %s"), $what);
343 }
346 public static function setButton($what= "")
347 {
348 return $what == "" ? sprintf(_("Set")): sprintf(_("Set %s"), $what);
349 }
352 public static function editButton($what= "")
353 {
354 return $what == "" ? sprintf(_("Edit...")): sprintf(_("Edit %s..."), $what);
355 }
358 public static function backButton($what= "")
359 {
360 return _("Back");
361 }
364 public static function buildList($data)
365 {
366 $objects= "<ul>";
367 foreach ($data as $key => $value){
368 if (is_numeric($key)){
369 $objects.= "<li>\n<i>$value</i></li>";
370 } else {
371 $objects.= "<li>\n$value (<i>$key</i>)</li>";
372 }
373 }
374 $objects.= "</ul>";
375 return($objects);
376 }
378 public static function noValidExtension($name)
379 {
380 return sprintf(_("This account has no valid %s extensions!"), $name);
381 }
383 public static function featuresEnabled($name, $depends= "")
384 {
385 if ($depends == ""){
386 return sprintf(_("This account has %s settings enabled. You can disable them by clicking below."), $name);
387 } else {
388 if (count($depends) == 1){
389 return sprintf(_("This account has %s settings enabled. To disable them, you'll need to remove the %s settings first!"), $name, $depends);
390 } else {
391 $deps= "";
392 foreach ($depends as $dep){
393 $deps.= "$dep / ";
394 }
395 $deps= preg_replace("/ \/ $/", "", $deps);
396 return sprintf(_("This account has %s settings enabled. To disable them, you'll need to remove the %s settings first!"), $name, $deps);
397 }
398 }
399 }
402 public static function featuresDisabled($name, $depends= "")
403 {
404 if ($depends == ""){
405 return sprintf(_("This account has %s settings disabled. You can enable them by clicking below."), $name);
406 } else {
407 if (count($depends) == 1){
408 return sprintf(_("This account has %s settings disabled. To enable them, you'll need to add the %s settings first!"), $name, $depends);
409 } else {
410 $deps= "";
411 foreach ($depends as $dep){
412 $deps.= "$dep / ";
413 }
414 $deps= preg_replace("/ \/ $/", "", $deps);
415 return sprintf(_("This account has %s settings disabled. To enable them, you'll need to add the %s settings first!"), $name, $deps);
416 }
417 }
418 }
421 public static function addFeaturesButton($name)
422 {
423 return sprintf(_("Add %s settings"), $name);
424 }
427 public static function removeFeaturesButton($name)
428 {
429 return sprintf(_("Remove %s settings"), $name);
430 }
433 public static function clickEditToChange()
434 {
435 return _("Click the 'Edit' button below to change informations in this dialog");
436 }
439 public static function months()
440 {
441 return array(_("January"), _("February"), _("March"), _("April"),
442 _("May"), _("June"), _("July"), _("August"), _("September"),
443 _("October"), _("November"), _("December"));
444 }
447 public static function weekdays()
448 {
449 return array( _("Sunday"), _("Monday"), _("Tuesday"), _("Wednesday"), _("Thursday"), _("Friday"), _("Saturday"));
450 }
453 public static function mysqlerror($error, $plugin= "")
454 {
455 /* Assign headline depending on type */
456 $headline= _("MySQL operation failed!");
457 return $headline."<br><br><i>"._("Error").":</i> ".$error;
458 }
461 public static function ldaperror($error, $dn= "", $type= 0, $plugin= "")
462 {
463 /* Assign headline depending on type */
464 $typemap= array(1 => _("read operation"), _("add operation"), _("modify operation"),
465 _("delete operation"), _("search operation"), _("authentication"));
467 if (isset($typemap[$type])){
468 $headline= sprintf(_("LDAP %s failed!"), $typemap[$type]);
469 } else {
470 $headline= _("LDAP operation failed!");
471 }
473 /* Fill DN information */
474 if ($dn != ""){
475 $dn_info= "<br><br><i>"._("Object").":</i> ".LDAP::fix($dn);
476 }
478 return $headline.$dn_info."<br><br><i>"._("Error").":</i> ".$error;
479 }
482 public static function incorrectUpload($reason= "")
483 {
484 if ($reason == ""){
485 return _("Upload failed!");
486 }
488 return sprintf(_("Upload failed: %s"), "<br><br><i>$reason</i>");
489 }
492 public static function siError($error= "")
493 {
494 if ($error == ""){
495 return _("Communication failure with the infrastructure service!");
496 }
497 return sprintf(_("Communication failure with the infrastructure service: %s"), "<br><br>"._("Error").": ".$error);
498 }
501 public static function stillInUse($type, $objects= array())
502 {
503 if (!is_array($objects)){
504 return sprintf(_("This '%s' is still in use by this object: %s"), $type, "<br><br>".$objects);
505 }
506 if (count($objects) == 1){
507 return sprintf(_("This '%s' is still in use by this object: %s"), $type, "<br>".msgPool::buildList($objects));
508 }
509 if (count($objects) == 0){
510 return sprintf(_("This '%s' is still in use."), $type);
511 }
512 return sprintf(_("This '%s' is still in use by these objects: %s"), $type, "<br>".msgPool::buildList($objects));
513 }
516 public static function fileDoesNotExist($file)
517 {
518 return sprintf(_("File '%s' does not exist!"), $file);
519 }
522 public static function cannotReadFile($file)
523 {
524 return sprintf(_("Cannot open file '%s' for reading!"), $file);
525 }
528 public static function cannotWriteFile($file)
529 {
530 return sprintf(_("Cannot open file '%s' for writing!"), $file);
531 }
534 public static function invalidConfigurationAttribute($attr)
535 {
536 return sprintf(_("The value for '%s' is currently unconfigured or invalid, please check your configuration file!"), $attr);
537 }
540 public static function cannotDeleteFile($file)
541 {
542 return sprintf(_("Cannot delete file '%s'!"), $file);
543 }
546 public static function cannotCreateFolder($path)
547 {
548 return sprintf(_("Cannot create folder '%s'!"), $path);
549 }
552 public static function cannotDeleteFolder($path)
553 {
554 return sprintf(_("Cannot delete folder '%s'!"), $path);
555 }
558 public static function checkingFor($what)
559 {
560 return sprintf(_("Checking for %s support"), $what);
561 }
564 public static function installPhpModule($what)
565 {
566 return sprintf(_("Install and activate the %s PHP module."), $what);
567 }
570 public static function class_not_found($plugin)
571 {
572 return (sprintf(_("Cannot initialize class '%s'! Maybe there is a plugin missing in your gosa setup?"), $plugin));
573 }
576 public static function check_base()
577 {
578 return _("The supplied base is not valid and has been reset to the previous value!");
579 }
581 }
582 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
583 ?>