FusionDirectory
 All Data Structures Files Functions Variables
class_msgPool.inc
Go to the documentation of this file.
1 <?php
2 
3 /*
4  This code is part of FusionDirectory (http://www.fusiondirectory.org/)
5  Copyright (C) 2003-2010 Cajus Pollmeier
6  Copyright (C) 2011-2016 FusionDirectory
7 
8  This program is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
21 */
22 
28 define ("LDAP_READ", 1);
29 define ("LDAP_ADD", 2);
30 define ("LDAP_MOD", 3);
31 define ("LDAP_DEL", 4);
32 define ("LDAP_SEARCH", 5);
33 define ("LDAP_AUTH", 6);
34 
38 class msgPool {
39 
40  public static function selectToView($type, $o_type = "")
41  {
42  if ($o_type == "") {
43  return sprintf(_("Select to list objects of type '%s'."), $type);
44  } elseif ($o_type == "contains") {
45  return sprintf(_("Select to list objects containig '%s'."), $type);
46  } elseif ($o_type == "enabled") {
47  return sprintf(_("Select to list objects that have '%s' enabled"), $type);
48  } elseif ($o_type == "subsearch") {
49  return _("Select to search within subtrees");
50  } elseif ($o_type == "subsearch_small") {
51  return _("Search in subtrees");
52  }
53 
54  }
55 
63  public static function deleteInfo($name = "", $type = "")
64  {
65  if ($name == "") {
66  if ($type == "") {
67  return _("This object will be deleted!");
68  } else {
69  return sprintf(_("This '%s' object will be deleted!"), $type);
70  }
71  }
72  if (!is_array($name)) {
73  if ($type == "") {
74  return sprintf(_("This object will be deleted: %s"), "<br><br><i>$name</i>");
75  } else {
76  return sprintf(_("This '%s' object will be deleted: %s"), $type, "<br><br><i>$name</i>");
77  }
78  }
79  if (count($name) == 1) {
80  if ($type == "") {
81  return _("This object will be deleted:")."<br>".msgPool::buildList($name);
82  } else {
83  return sprintf(_("This '%s' object will be deleted:"), $type). "<br>".msgPool::buildList($name);
84  }
85  }
86  if ($type == "") {
87  return sprintf(_("These objects will be deleted: %s"), "<br>".msgPool::buildList($name));
88  } else {
89  return sprintf(_("These '%s' objects will be deleted: %s"), $type, "<br>".msgPool::buildList($name));
90  }
91  }
92 
98  public static function permDelete($name = "")
99  {
100  if ($name == "") {
101  return _("You have no permission to delete this object!");
102  }
103 
104  if (!is_array($name)) {
105  return _("You have no permission to delete the object:")."<br><br><i>$name</i>";
106  }
107 
108  if (count($name) == 1) {
109  return _("You have no permission to delete the object:")."<br>".msgPool::buildList($name);
110  }
111 
112  return _("You have no permission to delete these objects:")."<br>".msgPool::buildList($name);
113  }
114 
120  public static function permCreate($name = "")
121  {
122  if ($name == "") {
123  return _("You have no permission to create this object!");
124  }
125 
126  if (!is_array($name)) {
127  return _("You have no permission to create the object:")."<br><br><i>$name</i>";
128  }
129 
130  if (count($name) == 1) {
131  return _("You have no permission to create the object:")."<br>".msgPool::buildList($name);
132  }
133 
134  return _("You have no permission to create these objects:")."<br>".msgPool::buildList($name);
135  }
136 
143  public static function permModify($name = '', $field = '')
144  {
145  if ($name == '') {
146  return _('You have no permission to modify this object!');
147  }
148 
149  if (!is_array($name)) {
150  if ($field != '') {
151  return sprintf(_('You have no permission to modify the field "%s" of object "%s"'), $field, $name);
152  } else {
153  return sprintf(_('You have no permission to modify the object:<br/>%s'), '<br/><i>'.$name.'</i>');
154  }
155  }
156 
157  if (count($name) == 1) {
158  return sprintf(_('You have no permission to modify the object:<br/>%s'), msgPool::buildList($name));
159  }
160 
161  return sprintf(_('You have no permission to modify these objects:<br/>%s'), msgPool::buildList($name));
162  }
163 
169  public static function permView($name = "")
170  {
171  if ($name == "") {
172  return _("You have no permission to view this object!");
173  }
174 
175  if (!is_array($name)) {
176  return _("You have no permission to view the object:")."<br><br><i>$name</i>";
177  }
178 
179  if (count($name) == 1) {
180  return _("You have no permission to view the object:")."<br>".msgPool::buildList($name);
181  }
182 
183  return _("You have no permission to view these objects:")."<br>".msgPool::buildList($name);
184  }
185 
191  public static function permMove($name = "")
192  {
193  if ($name == "") {
194  return _("You have no permission to move this object!");
195  }
196 
197  if (!is_array($name)) {
198  return _("You have no permission to move the object:")."<br><br><i>$name</i>";
199  }
200 
201  if (count($name) == 1) {
202  return _("You have no permission to move the object:")."<br>".msgPool::buildList($name);
203  }
204 
205  return _("You have no permission to move these objects:")."<br>".msgPool::buildList($name);
206  }
207 
217  public static function dbconnect($name, $error = "", $dbinfo = "")
218  {
219  if ($error != "") {
220  $error = "<br><br><i>"._("Error").":</i> ".$error;
221  }
222  if ($dbinfo != "") {
223  $error .= "<br><br><i>"._("Connection information").":</i> ".$dbinfo;
224  }
225  return sprintf(_("Cannot connect to %s database!"), $name).$error;
226  }
227 
237  public static function dbselect($name, $error = "", $dbinfo = "")
238  {
239  if ($error != "") {
240  $error = "<br><br><i>"._("Error").":</i> ".$error;
241  }
242  if ($dbinfo != "") {
243  $error .= "<br><br><i>"._("Connection information").":</i> ".$dbinfo;
244  }
245  return sprintf(_("Cannot select %s database!"), $name).$error;
246  }
247 
253  public static function noserver($name)
254  {
255  return sprintf(_("No %s server defined!"), $name);
256  }
257 
267  public static function dbquery($name, $error = "", $dbinfo = "")
268  {
269  if ($error != "") {
270  $error = "<br><br><i>"._("Error").":</i> ".$error;
271  }
272  if ($dbinfo != "") {
273  $error .= "<br><br><i>"._("Connection information").":</i> ".$dbinfo;
274  }
275  return sprintf(_("Cannot query %s database!"), $name).$error;
276  }
277 
283  public static function reserved($name)
284  {
285  return sprintf(_("The field '%s' contains a reserved keyword!"), $name);
286  }
287 
295  public static function cmdnotfound($type, $plugin)
296  {
297  return sprintf(_("Command specified as %s hook for plugin '%s' does not exist!"), $type, $plugin);
298  }
299 
309  public static function cmdinvalid($type, $command = "", $plugin = "")
310  {
311  if ($command == "") {
312  if ($plugin == "") {
313  return sprintf(_("'%s' command is invalid!"), $type);
314  } else {
315  return sprintf(_("'%s' command for plugin %s is invalid!"), $type, $plugin);
316  }
317  } else {
318  if ($plugin == "") {
319  return sprintf(_("'%s' command (%s) is invalid!"), $type, $command);
320  } else {
321  return sprintf(_("'%s' command (%s) for plugin %s is invalid!"), $type, $command, $plugin);
322  }
323  }
324  }
325 
335  public static function cmdexecfailed($type, $command = "", $plugin = "")
336  {
337  if ($command == "") {
338  if ($plugin == "") {
339  return sprintf(_("Cannot execute '%s' command!"), $type);
340  } else {
341  return sprintf(_("Cannot execute '%s' command for plugin %s!"), $type, $plugin);
342  }
343  } else {
344  if ($plugin == "") {
345  return sprintf(_("Cannot execute '%s' command (%s)!"), $type, $command);
346  } else {
347  return sprintf(_("Cannot execute '%s' command (%s) for plugin %s!"), $type, $command, $plugin);
348  }
349  }
350  }
351 
359  public static function toobig($name, $min = "")
360  {
361  if ($min == "") {
362  return sprintf(_("Value for '%s' is too large!"), $name);
363  } else {
364  return sprintf(_("'%s' must be smaller than %s!"), $name, $min);
365  }
366  }
367 
375  public static function toosmall($name, $min = "")
376  {
377  if ($min == "") {
378  return sprintf(_("Value for '%s' is too small!"), $name);
379  } else {
380  return sprintf(_("'%s' must be %d or above!"), $name, $min);
381  }
382  }
383 
391  public static function depends($name1, $name2)
392  {
393  return sprintf(_("'%s' depends on '%s' - please provide both values!"), $name1, $name2);
394  }
395 
401  public static function duplicated($name, $dn = NULL)
402  {
403  if ($dn == NULL) {
404  return sprintf(_("There is already an entry with this '%s' attribute in the system!"), $name);
405  } else {
406  return sprintf(_("The entry '%s' already use this '%s' attribute!"), $dn, $name);
407  }
408  }
409 
415  public static function required($name)
416  {
417  return sprintf(_("The required field '%s' is empty!"), $name);
418  }
419 
431  public static function invalid($name, $data = "", $regex = "", $example = "")
432  {
433  /* Stylize example */
434  if ($example != "") {
435  $example = "<br><br><i>"._("Example:")."</i> ".$example;
436  }
437 
438  /* If validChars are posted, take data and paint all invalid
439  characters... */
440  if ($regex) {
441  $result = "";
442  $mismatch = "";
443 
444  mb_internal_encoding('UTF-8');
445  for ($i = 0; $i <= mb_strlen($data); $i++) {
446  $currentChar = mb_substr($data, $i, 1);
447  if (preg_match("$regex", $currentChar)) {
448  $result .= $currentChar;
449  } else {
450  $result .= '<span style="color:red;text-decoration:underline;">'.($currentChar).'</span>';
451  $mismatch .= $currentChar;
452  }
453  }
454 
455  return sprintf(_("The field '%s' contains invalid characters"), $name).". ".
456  ((strlen($mismatch) == 1) ? sprintf(_("'%s' is not allowed:"), $mismatch) : sprintf(_("'%s' are not allowed!"), $mismatch)).
457  "<br><br> \"$result\"$example";
458  } else {
459  return sprintf(_("The field '%s' contains invalid characters"), $name)."!$example";
460  }
461  }
462 
468  public static function missingext($name)
469  {
470  return sprintf(_("Missing %s PHP extension!"), $name);
471  }
472 
476  public static function cancelButton()
477  {
478  return _("Cancel");
479  }
480 
484  public static function okButton()
485  {
486  return _("Ok");
487  }
488 
492  public static function applyButton()
493  {
494  return _("Apply");
495  }
496 
500  public static function saveButton()
501  {
502  return _("Save");
503  }
504 
510  public static function addButton($what = '')
511  {
512  return (($what == '') ? sprintf(_('Add')) : sprintf(_('Add %s'), $what));
513  }
514 
520  public static function delButton($what = '')
521  {
522  return (($what == '') ? sprintf(_('Delete')) : sprintf(_('Delete %s'), $what));
523  }
524 
530  public static function editButton($what = '')
531  {
532  return (($what == '') ? sprintf(_('Edit...')) : sprintf(_('Edit %s...'), $what));
533  }
534 
538  public static function backButton()
539  {
540  return _('Back');
541  }
542 
548  public static function buildList($data)
549  {
550  $objects = "<ul>";
551  foreach ($data as $key => $value) {
552  if (is_numeric($key)) {
553  $objects .= "<li>\n<i>$value</i></li>";
554  } else {
555  $objects .= "<li>\n$value (<i>$key</i>)</li>";
556  }
557  }
558  $objects .= "</ul>";
559  return $objects;
560  }
561 
567  public static function noValidExtension($name)
568  {
569  return sprintf(_("This account has no valid %s extensions!"), $name);
570  }
571 
579  public static function featuresEnabled($name, $depends = "")
580  {
581  if (($depends == "") || (is_array($depends) && count($depends) == 0)) {
582  return sprintf(_("This account has %s settings enabled. You can disable them by clicking below."), $name);
583  } else {
584  if (count($depends) == 1) {
585  if (is_array($depends)) {
586  $depends = $depends[0];
587  }
588  return sprintf(_("This account has %s settings enabled. To disable them, you'll need to remove the %s settings first!"), $name, $depends);
589  } else {
590  $deps = "";
591  foreach ($depends as $dep) {
592  $deps .= "$dep / ";
593  }
594  $deps = preg_replace("/ \/ $/", "", $deps);
595  return sprintf(_("This account has %s settings enabled. To disable them, you'll need to remove the %s settings first!"), $name, $deps);
596  }
597  }
598  }
599 
607  public static function featuresDisabled($name, array $depends = array(), array $conflicts = array())
608  {
609  if (empty($depends) && empty($conflicts)) {
610  return sprintf(_('This account has %s settings disabled. You can enable them by clicking below.'), $name);
611  } elseif (!empty($depends)) {
612  return sprintf(_('This account has %s settings disabled. To enable them, you\'ll need to add the %s settings first!'), $name, implode(' / ', $depends));
613  } else {
614  return sprintf(_('This account has %s settings disabled. To enable them, you\'ll need to disable the %s settings first!'), $name, implode(' / ', $conflicts));
615  }
616  }
617 
623  public static function addFeaturesButton($name)
624  {
625  return sprintf(_("Add %s settings"), $name);
626  }
627 
634  public static function removeFeaturesButton($name)
635  {
636  return sprintf(_("Remove %s settings"), $name);
637  }
638 
642  public static function clickEditToChange()
643  {
644  return _("Click the 'Edit' button below to change information in this dialog");
645  }
646 
650  public static function months()
651  {
652  return array(_("January"), _("February"), _("March"), _("April"),
653  _("May"), _("June"), _("July"), _("August"), _("September"),
654  _("October"), _("November"), _("December"));
655  }
656 
661  public static function weekdays()
662  {
663  return array( _("Sunday"), _("Monday"), _("Tuesday"), _("Wednesday"), _("Thursday"), _("Friday"), _("Saturday"));
664  }
665 
677  public static function ldaperror($error, $dn = '', $type = 0, $plugin = '')
678  {
679  /* Assign headline depending on type */
680  $typemap = array(1 => _('read operation'), _('add operation'), _('modify operation'),
681  _('delete operation'), _('search operation'), _('authentication'));
682 
683  if (isset($typemap[$type])) {
684  $msg = sprintf(_('LDAP %s failed!'), $typemap[$type]);
685  } else {
686  $msg = _('LDAP operation failed!');
687  }
688 
689  /* Fill DN information */
690  if ($dn != '') {
691  $msg .= '<br/><br/><i>'._('Object').':</i> '.$dn;
692  }
693 
694  $msg .= '<br/><br/><i>'._('Error').':</i> '.$error;
695 
696  return $msg;
697  }
698 
704  public static function incorrectUpload($reason = "")
705  {
706  if ($reason == "") {
707  return _("Upload failed!");
708  }
709 
710  return sprintf(_("Upload failed: %s"), "<br><br><i>$reason</i>");
711  }
712 
718  public static function siError($error = "")
719  {
720  if ($error == "") {
721  return _("Communication failure with the infrastructure service!");
722  }
723  return sprintf(_("Communication failure with the infrastructure service: %s"), "<br><br>"._("Error").": ".$error);
724  }
725 
733  public static function stillInUse($type, $objects = array())
734  {
735  if (!is_array($objects)) {
736  return sprintf(_("This '%s' is still in use by this object: %s"), $type, "<br><br>".$objects);
737  }
738  if (count($objects) == 1) {
739  return sprintf(_("This '%s' is still in use by this object: %s"), $type, "<br>".msgPool::buildList($objects));
740  }
741  if (count($objects) == 0) {
742  return sprintf(_("This '%s' is still in use."), $type);
743  }
744  return sprintf(_("This '%s' is still in use by these objects: %s"), $type, "<br>".msgPool::buildList($objects));
745  }
746 
752  public static function fileDoesNotExist($file)
753  {
754  return sprintf(_("File '%s' does not exist!"), $file);
755  }
756 
762  public static function cannotReadFile($file)
763  {
764  return sprintf(_("Cannot open file '%s' for reading!"), $file);
765  }
766 
772  public static function cannotWriteFile($file)
773  {
774  return sprintf(_("Cannot open file '%s' for writing!"), $file);
775  }
776 
782  public static function invalidConfigurationAttribute($attr)
783  {
784  return sprintf(_("The value for '%s' is currently unconfigured or invalid, please check your configuration file!"), $attr);
785  }
786 
792  public static function cannotDeleteFile($file)
793  {
794  return sprintf(_("Cannot delete file '%s'!"), $file);
795  }
796 
802  public static function cannotCreateFolder($path)
803  {
804  return sprintf(_("Cannot create folder '%s'!"), $path);
805  }
806 
812  public static function cannotDeleteFolder($path)
813  {
814  return sprintf(_("Cannot delete folder '%s'!"), $path);
815  }
816 
822  public static function checkingFor($what)
823  {
824  return sprintf(_("Checking for %s support"), $what);
825  }
826 
832  public static function installPhpModule($what)
833  {
834  return sprintf(_("Install and activate the %s PHP module."), $what);
835  }
836 
842  public static function installPearModule($what)
843  {
844  return sprintf(_("Install and activate the %s Pear module."), $what);
845  }
846 
852  public static function class_not_found($plugin)
853  {
854  return sprintf(_("Cannot initialize class '%s'! Maybe there is a plugin missing in your FusionDirectory setup?"), $plugin);
855  }
856 
860  public static function check_base()
861  {
862  return _("The supplied base is not valid and has been reset to the previous value!");
863  }
864 }
865 ?>
static backButton()
Text for a back button.
static applyButton()
Text for an apply button.
static toobig($name, $min="")
Display error about too larged value.
static months()
Build an array with the months.
static cancelButton()
Text for a cancel button.
static installPhpModule($what)
Display install or activate a PHP module.
static featuresEnabled($name, $depends="")
List the features settings enabled.
static cannotDeleteFolder($path)
Display error when cannot delete a folder.
static cannotDeleteFile($file)
Display error when cannot delete a file.
static siError($error="")
Display error about communication failure with the infrastructure service.
static required($name)
Display error about required field empty.
static installPearModule($what)
Display install or activate a PEAR module.
static ldaperror($error, $dn= '', $type=0, $plugin= '')
Display LDAP error.
static checkingFor($what)
Display checking for a support.
static permView($name="")
Display that we have no permission to view an object.
static featuresDisabled($name, array $depends=array(), array $conflicts=array())
List the features settings disabled.
static addFeaturesButton($name)
Display Add features button.
static dbquery($name, $error="", $dbinfo="")
Display informations about database query.
static toosmall($name, $min="")
Display error about too small value.
static dbconnect($name, $error="", $dbinfo="")
Display informations about database connection.
static saveButton()
Text for a save button.
static weekdays()
Build an array with the days of a week. Start by Sunday.
static permMove($name="")
Display that we have no permission to move an object.
static invalid($name, $data="", $regex="", $example="")
Display error about invalid characters.
static okButton()
Text for a ok button.
static reserved($name)
Display field contains reserved keyword.
static check_base()
Display error when checking the base.
static cannotWriteFile($file)
Display file isn't writable.
static addButton($what= '')
Text for an add button.
static dbselect($name, $error="", $dbinfo="")
Display informations about database select.
static duplicated($name, $dn=NULL)
Display error about existing entry in the system.
static cmdinvalid($type, $command="", $plugin="")
Display that a command doesn't valid in this plugin.
static deleteInfo($name="", $type="")
Display the deleted informations.
static cmdexecfailed($type, $command="", $plugin="")
Display that a command execution failed in this plugin.
static noValidExtension($name)
Display error about invalid extension from account.
static cannotReadFile($file)
Display file isn't readable.
static permDelete($name="")
Display that we have no permission to delete an object.
static invalidConfigurationAttribute($attr)
Display error in the configuration.
This class contains all the messages for the various actions.
static editButton($what= '')
Text for an edit button.
static permCreate($name="")
Display that we have no permission to create an object.
static incorrectUpload($reason="")
Display error about an incorrect upload.
static missingext($name)
Display about missing PHP extension.
static permModify($name= '', $field= '')
Display that we have no permission to modify an object.
static delButton($what= '')
Text for an delete button.
static depends($name1, $name2)
Display a dependence between two objects.
static buildList($data)
a list from an array
static fileDoesNotExist($file)
Display file doesn't exist.
static class_not_found($plugin)
Display error when a class is not found.
static noserver($name)
Display error about no server found.
static cannotCreateFolder($path)
Display error when cannot create a folder.
static stillInUse($type, $objects=array())
Display which it still in use.
static cmdnotfound($type, $plugin)
Display that a command doesn't exist in this plugin.
static removeFeaturesButton($name)
Display Remove features button.
static clickEditToChange()
Display : Click the 'Edit' button below to change information in this dialog.