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