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 }
372 public static function noValidExtension($name)
373 {
374 return sprintf(_("This account has no valid %s extensions!"), $name);
375 }
377 public static function featuresEnabled($name, $depends= "")
378 {
379 if ($depends == ""){
380 return sprintf(_("This account has %s settings enabled. You can disable them by clicking below."), $name);
381 } else {
382 if (count($depends) == 1){
383 return sprintf(_("This account has %s settings enabled. To disable them, you'll need to remove the %s settings first!"), $name, $depends);
384 } else {
385 $deps= "";
386 foreach ($depends as $dep){
387 $deps.= "$dep / ";
388 }
389 $deps= preg_replace("/ \/ $/", "", $deps);
390 return sprintf(_("This account has %s settings enabled. To disable them, you'll need to remove the %s settings first!"), $name, $deps);
391 }
392 }
393 }
396 public static function featuresDisabled($name, $depends= "")
397 {
398 if ($depends == ""){
399 return sprintf(_("This account has %s settings disabled. You can enable them by clicking below."), $name);
400 } else {
401 if (count($depends) == 1){
402 return sprintf(_("This account has %s settings disabled. To enable them, you'll need to add the %s settings first!"), $name, $depends);
403 } else {
404 $deps= "";
405 foreach ($depends as $dep){
406 $deps.= "$dep / ";
407 }
408 $deps= preg_replace("/ \/ $/", "", $deps);
409 return sprintf(_("This account has %s features settings. To disable them, you'll need to add the %s settings first!"), $name, $deps);
410 }
411 }
412 }
415 public static function addFeaturesButton($name)
416 {
417 return sprintf(_("Add %s settings"), $name);
418 }
421 public static function removeFeaturesButton($name)
422 {
423 return sprintf(_("Remove %s settings"), $name);
424 }
427 public static function clickEditToChange()
428 {
429 return _("Click the 'Edit' button below to change informations in this dialog");
430 }
433 public static function months()
434 {
435 return array(_("January"), _("February"), _("March"), _("April"),
436 _("May"), _("June"), _("July"), _("August"), _("September"),
437 _("October"), _("November"), _("December"));
438 }
441 public static function weekdays()
442 {
443 return array( _("Sunday"), _("Monday"), _("Tuesday"), _("Wednesday"), _("Thursday"), _("Friday"), _("Saturday"));
444 }
447 public static function ldaperror($error, $dn= "", $type= 0, $plugin= "")
448 {
449 /* Assign headline depending on type */
450 $typemap= array(1 => _("read operation"), _("add operation"), _("modify operation"),
451 _("delete operation"), _("search operation"), _("authentication"));
453 if (isset($typemap[$type])){
454 $headline= sprintf(_("LDAP %s failed!"), $typemap[$type]);
455 } else {
456 $headline= _("LDAP operation failed!");
457 }
459 /* Fill DN information */
460 if ($dn != ""){
461 $dn_info= "<br><br><i>"._("Object").":</i> ".LDAP::fix($dn);
462 }
464 return $headline.$dn_info."<br><br><i>"._("Error").":</i> ".$error;
465 }
468 public static function incorrectUpload($reason= "")
469 {
470 if ($reason == ""){
471 return _("Upload failed!");
472 }
474 return sprintf(_("Upload failed: %s"), "<br><br><i>$reason</i>");
475 }
478 public static function siError($error= "")
479 {
480 if ($error == ""){
481 return _("Communication failure with the infrastructure service!");
482 }
483 return sprintf(_("Communication failure with the infrastructure service: %s"), "<br><br>"._("Error").": ".$error);
484 }
487 public static function stillInUse($type, $objects= array())
488 {
489 if (!is_array($objects)){
490 return sprintf(_("This '%s' is still in use by this object: %s"), $type, "<br><br>".$objects);
491 }
492 if (count($objects) == 1){
493 return sprintf(_("This '%s' is still in use by this object: %s"), $type, "<br><br>".msgPool::buildList($objects));
494 }
495 return sprintf(_("This '%s' is still in use by these objects: %s"), $type, "<br><br>".msgPool::buildList($objects));
496 }
499 public static function fileDoesNotExist($file)
500 {
501 return sprintf(_("File '%s' does not exist!"), $file);
502 }
505 public static function cannotReadFile($file)
506 {
507 return sprintf(_("Cannot open file '%s' for reading!"), $file);
508 }
511 public static function cannotWriteFile($file)
512 {
513 return sprintf(_("Cannot open file '%s' for writing!"), $file);
514 }
517 public static function cannotDeleteFile($file)
518 {
519 return sprintf(_("Cannot delete file '%s'!"), $file);
520 }
523 public static function cannotCreateFolder($path)
524 {
525 return sprintf(_("Cannot create folder '%s'!"), $path);
526 }
529 public static function cannotDeleteFolder($path)
530 {
531 return sprintf(_("Cannot delete folder '%s'!"), $path);
532 }
535 public static function chooseToPlaceObjectIn($what)
536 {
537 return sprintf(_("Choose subtree to place %s in"), $what);
538 }
541 public static function checkingFor($what)
542 {
543 return sprintf(_("Checking for %s support"), $what);
544 }
547 }
548 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
549 ?>