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 }
197 public static function cmdinvalid($type, $command = "",$plugin="")
198 {
199 if(empty($command)){
200 return (sprintf(_("The configured '%s' command is not a valid command."), $type));
201 }elseif($command != "" && $plugin != ""){
202 return (sprintf(_("The configured '%s' command (%s) in plugin %s is not a valid command."), $type,$command,$plugin));
203 }elseif($plugin != "" && $command =""){
204 return (sprintf(_("The configured '%s' command in plugin %s is not a valid command."), $type,$plugin));
205 }else{
206 return (sprintf(_("The configured '%s' command (%s) is not a valid command."), $type,$command));
207 }
208 }
210 public static function cmdexecfailed($type, $command = "",$plugin="")
211 {
212 if(empty($command)){
213 return (sprintf(_("The configured '%s' command wasn't successfully executed."), $type));
214 }elseif($command != "" && $plugin != ""){
215 return (sprintf(_("The configured '%s' command (%s) in plugin %s wasn't successfully executed."), $type,$command,$plugin));
216 }elseif($plugin != "" && $command =""){
217 return (sprintf(_("The configured '%s' command in plugin %s wasn't successfully executed."), $type,$plugin));
218 }else{
219 return (sprintf(_("The configured '%s' command (%s) wasn't successfully executed."), $type,$command));
220 }
221 }
222 public static function toobig($name, $min= "")
223 {
224 if ($min == ""){
225 return (sprintf(_("Value for '%s' is too large!"), $name));
226 } else {
227 return (sprintf(_("'%s' must be smaller than %d!"), $name, $min));
228 }
229 }
232 public static function toosmall($name, $min= "")
233 {
234 if ($min == ""){
235 return (sprintf(_("Value for '%s' is too small!"), $name));
236 } else {
237 return (sprintf(_("'%s' must be %d or above!"), $name, $min));
238 }
239 }
242 public static function depends($name1, $name2)
243 {
244 return (sprintf(_("'%s' depends on '%s' - please provide both values!"), $name1, $name2));
245 }
248 public static function duplicated($name)
249 {
250 return (sprintf(_("There is already an entry with this '%s' attribute in the system!"), $name));
251 }
254 public static function required($name)
255 {
256 return (sprintf(_("The required field '%s' is empty!"), $name));
257 }
260 public static function invalid($name, $data= "", $regex= "", $example= "")
261 {
262 /* Stylize example */
263 if ($example != ""){
264 $example= "<br><br><i>"._("Example").":</i> ".$example;
265 }
267 /* If validChars are posted, take data and paint all invalid
268 characters... */
269 if ($regex) {
270 $result= "";
271 $mismatch= "";
272 foreach (str_split($data) as $currentChar){
273 if (preg_match("$regex", $currentChar)){
274 $result.= $currentChar;
275 } else {
276 $result.= "<font style='color:red;text-decoration:underline;'>".htmlentities($currentChar)."</font>";
277 $mismatch.= $currentChar;
278 }
279 }
281 return sprintf(_("The Field '%s' contains invalid characters"), $name).". ".
282 (strlen($mismatch)==1?sprintf(_("'%s' is not allowed:"), htmlentities($mismatch)):sprintf(_("'%s' are not allowed."), htmlentities($mismatch))).
283 "<br><br> \"$result\"$example";
284 } else {
285 return sprintf(_("The Field '%s' contains invalid characters"), $name)."!$example";
286 }
287 }
290 public static function missingext($name)
291 {
292 return sprintf(_("Missing %s PHP extension!"), $name);
293 }
296 public static function cancelButton()
297 {
298 return sprintf(_("Cancel"));
299 }
302 public static function okButton()
303 {
304 return sprintf(_("Ok"));
305 }
308 public static function applyButton()
309 {
310 return sprintf(_("Apply"));
311 }
314 public static function saveButton()
315 {
316 return sprintf(_("Save"));
317 }
320 public static function addButton($what= "")
321 {
322 return $what == "" ? sprintf(_("Add")): sprintf(_("Add %s"), $what);
323 }
326 public static function delButton($what= "")
327 {
328 return $what == "" ? sprintf(_("Delete")): sprintf(_("Delete %s"), $what);
329 }
332 public static function setButton($what= "")
333 {
334 return $what == "" ? sprintf(_("Set")): sprintf(_("Set %s"), $what);
335 }
338 public static function editButton($what= "")
339 {
340 return $what == "" ? sprintf(_("Edit...")): sprintf(_("Edit %s..."), $what);
341 }
344 public static function backButton($what= "")
345 {
346 return _("Back");
347 }
350 public static function buildList($data)
351 {
352 $objects= "";
353 foreach ($data as $key => $value){
354 if (is_numeric($key)){
355 $objects.= "<br>\n<i>$value</i>";
356 } else {
357 $objects.= "<br>\n$value (<i>$key</i>)";
358 }
359 }
360 }
362 public static function noValidExtension($name)
363 {
364 return sprintf(_("This account has no valid %s extensions!"), $name);
365 }
367 public static function featuresEnabled($name, $depends= "")
368 {
369 if ($depends == ""){
370 return sprintf(_("This account has %s settings enabled. You can disable them by clicking below."), $name);
371 } else {
372 if (count($depends) == 1){
373 return sprintf(_("This account has %s settings enabled. To disable them, you'll need to remove the %s settings first!"), $name, $depends);
374 } else {
375 $deps= "";
376 foreach ($depends as $dep){
377 $deps.= "$dep / ";
378 }
379 $deps= preg_replace("/ \/ $/", "", $deps);
380 return sprintf(_("This account has %s settings enabled. To disable them, you'll need to remove the %s settings first!"), $name, $deps);
381 }
382 }
383 }
386 public static function featuresDisabled($name, $depends= "")
387 {
388 if ($depends == ""){
389 return sprintf(_("This account has %s settings disabled. You can enable them by clicking below."), $name);
390 } else {
391 if (count($depends) == 1){
392 return sprintf(_("This account has %s settings disabled. To enable them, you'll need to add the %s settings first!"), $name, $depends);
393 } else {
394 $deps= "";
395 foreach ($depends as $dep){
396 $deps.= "$dep / ";
397 }
398 $deps= preg_replace("/ \/ $/", "", $deps);
399 return sprintf(_("This account has %s features settings. To disable them, you'll need to add the %s settings first!"), $name, $deps);
400 }
401 }
402 }
405 public static function addFeaturesButton($name)
406 {
407 return sprintf(_("Add %s settings"), $name);
408 }
411 public static function removeFeaturesButton($name)
412 {
413 return sprintf(_("Remove %s settings"), $name);
414 }
417 public static function clickEditToChange()
418 {
419 return _("Click the 'Edit' button below to change informations in this dialog");
420 }
423 public static function months()
424 {
425 return array(_("January"), _("February"), _("March"), _("April"),
426 _("May"), _("June"), _("July"), _("August"), _("September"),
427 _("October"), _("November"), _("December"));
428 }
431 public static function weekdays()
432 {
433 return array( _("Sunday"), _("Monday"), _("Tuesday"), _("Wednesday"), _("Thursday"), _("Friday"), _("Saturday"));
434 }
437 public static function ldaperror($error, $dn= "", $type= 0, $plugin= "")
438 {
439 /* Assign headline depending on type */
440 $typemap= array(1 => _("read operation"), _("add operation"), _("modify operation"),
441 _("delete operation"), _("search operation"), _("authentication"));
443 if (isset($typemap[$type])){
444 $headline= sprintf(_("LDAP %s failed!"), $typemap[$type]);
445 } else {
446 $headline= _("LDAP operation failed!");
447 }
449 /* Fill DN information */
450 if ($dn != ""){
451 $dn_info= "<br><br><i>"._("Object").":</i> ".LDAP::fix($dn);
452 }
454 return $headline.$dn_info."<br><br><i>"._("Error").":</i> ".$error;
455 }
458 function incorrectUpload($reason= "")
459 {
460 if ($reason == ""){
461 return _("Upload failed!");
462 }
464 return sprintf(_("Upload failed: %s"), "<br><br><i>$reason</i>");
465 }
468 function siError($error= "")
469 {
470 if ($error == ""){
471 return _("Communication failure with the infrastructure service!");
472 }
473 return sprintf(_("Communication failure with the infrastructure service: %s"), "<br><br>"._("Error").": ".$error);
474 }
476 }
477 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
478 ?>