Code

Updated pool
[gosa.git] / gosa-core / include / utils / class_msgPool.inc
1 <?php
3 class msgPool
4 {
5   public static function permDelete($name= "")
6   {
7     if ($name == "") { 
8       return (_("You have no permission to delete this object!"));
9     }
11     if (!is_array($name)){
12       return (_("You have no permission to delete the object:")."<br><br><i>$name</i>");
13     }
15     msgPool::buildList($name);
16     if (count($name) == 1){
17       return (_("You have no permission to delete the object:")."<br>".msgPool::buildList($name));
18     }
20     return (_("You have no permission to delete these objects:")."<br>".msgPool::buildList($name));
21   }
24   public static function permCreate($name= "")
25   {
26     if ($name == "") { 
27       return (_("You have no permission to create this object!"));
28     }
30     if (!is_array($name)){
31       return (_("You have no permission to create the object:")."<br><br><i>$name</i>");
32     }
34     if (count($name) == 1){
35       return (_("You have no permission to create the object:")."<br>".msgPool::buildList($name));
36     }
38     return (_("You have no permission to create these objects:")."<br>".msgPool::buildList($name));
39   }
42   public static function permModify($name= "")
43   {
44     if ($name == "") { 
45       return (_("You have no permission to modify this object!"));
46     }
48     if (!is_array($name)){
49       return (_("You have no permission to modify the object:")."<br><br><i>$name</i>");
50     }
52     if (count($name) == 1){
53       return (_("You have no permission to modify the object:")."<br>".msgPool::buildList($name));
54     }
56     return (_("You have no permission to modify these objects:")."<br>".msgPool::buildList($name));
57   }
60   public static function permMove($name= "")
61   {
62     if ($name == "") { 
63       return (_("You have no permission to move this object!"));
64     }
66     if (!is_array($name)){
67       return (_("You have no permission to move the object:")."<br><br><i>$name</i>");
68     }
70     if (count($name) == 1){
71       return (_("You have no permission to move the object:")."<br>".msgPool::buildList($name));
72     }
74     return (_("You have no permission to move these objects:")."<br>".msgPool::buildList($name));
75   }
78   public static function dbconnect($name, $error= "", $dbinfo= "")
79   {
80     if ($error != ""){
81       $error= "<br><br><i>"._("Error").":</i> ".$error;
82     }
83     if ($dbinfo != ""){
84       $error= "<br><br><i>"._("Connection information").":</i> ".$dbinfo;
85     }
86     return (sprintf(_("Cannot connect to %s database!"), $name).$error);
87   }
90   public static function dbselect($name, $error= "", $dbinfo= "")
91   {
92     if ($error != ""){
93       $error= "<br><br><i>"._("Error").":</i> ".$error;
94     }
95     if ($dbinfo != ""){
96       $error= "<br><br><i>"._("Connection information").":</i> ".$dbinfo;
97     }
98     return (sprintf(_("Cannot select %s database!"), $name).$error);
99   }
102   public static function dbquery($name, $error= "", $dbinfo= "")
103   {
104     if ($error != ""){
105       $error= "<br><br><i>"._("Error").":</i> ".$error;
106     }
107     if ($dbinfo != ""){
108       $error= "<br><br><i>"._("Connection information").":</i> ".$dbinfo;
109     }
110     return (sprintf(_("Cannot query %s database!"), $name).$error);
111   }
114   public static function reserved($name)
115   {
116     return (sprintf(_("The field '%s' contains a reserved keyword!"), $name));
117   }
120   public static function cmdnotfound($type, $plugin)
121   {
122     return (sprintf(_("Command specified as %s hook for plugin '%s' does not exist!"), $type, $plugin));
123   }
126   public static function toobig($name, $min= "")
127   {
128     if ($min == ""){
129       return (sprintf(_("Value for '%s' is too big!"), $name));
130     } else {
131       return (sprintf(_("'%s' must be smaller than %d!"), $name, $min));
132     }
133   }
136   public static function toosmall($name, $min= "")
137   {
138     if ($min == ""){
139       return (sprintf(_("Value for '%s' is too small!"), $name));
140     } else {
141       return (sprintf(_("'%s' must be %d or above!"), $name, $min));
142     }
143   }
146   public static function bigger($name1, $name2)
147   {
148     return (sprintf(_("'%s' should be bigger than '%s'!"), $name1, $name2));
149   }
152   public static function smaller($name1, $name2)
153   {
154     return (sprintf(_("'%s' should be smaller than '%s'!"), $name1, $name2));
155   }
158   public static function depends($name1, $name2)
159   {
160     return (sprintf(_("'%s' depends on '%s' - please provide both values!"), $name1, $name2));
161   }
164   public static function duplicated($name)
165   {
166     return (sprintf(_("There is already an entry with this '%s' attribute in the system!"), $name));
167   }
170   public static function required($name)
171   {
172     return (sprintf(_("The required field '%s' is empty!"), $name));
173   }
176   public static function invalid($name, $data= "", $regex= "", $example= "")
177   {
178     /* Stylize example */
179     if ($example != ""){
180       $example= "<br><br><i>"._("Example").":</i> ".$example;
181     }
183     /* If validChars are posted, take data and paint all invalid
184        characters... */
185     if ($regex) {
186       $result= "";
187       $mismatch= "";
188       foreach (str_split($data) as $currentChar){
189         if (preg_match("$regex", $currentChar)){
190           $result.= $currentChar;
191         } else {
192           $result.= "<font style='color:red;text-decoration:underline;'>".htmlentities($currentChar)."</font>";
193           $mismatch.= $currentChar;
194         }
195       }
197       return sprintf(_("The Field '%s' contains invalid characters"), $name).". ".
198              (strlen($mismatch)==1?sprintf(_("'%s' is not allowed:"), htmlentities($mismatch)):sprintf(_("'%s' are not allowed."), htmlentities($mismatch))).
199              "<br><br> \"$result\"$example";
200     } else {
201       return sprintf(_("The Field '%s' contains invalid characters"), $name)."!$example";
202     }
203   }
206   public static function missingext($name)
207   {
208     return sprintf(_("Missing %s PHP extension!"), $name);
209   }
212   public static function cancelButton()
213   {
214     return sprintf(_("Cancel"));
215   }
218   public static function okButton()
219   {
220     return sprintf(_("Ok"));
221   }
224   public static function applyButton()
225   {
226     return sprintf(_("Apply"));
227   }
230   public static function saveButton()
231   {
232     return sprintf(_("Save"));
233   }
236   public static function addButton($what= "")
237   {
238     return $what == "" ? sprintf(_("Add"): sprintf(_("Add %s"), $what));
239   }
242   public static function delButton($what= "")
243   {
244     return $what == "" ? sprintf(_("Delete"): sprintf(_("Delete %s"), $what));
245   }
248   public static function setButton($what= "")
249   {
250     return $what == "" ? sprintf(_("Set"): sprintf(_("Set %s"), $what));
251   }
254   public static function editButton($what= "")
255   {
256     return $what == "" ? sprintf(_("Edit..."): sprintf(_("Edit %s..."), $what));
257   }
260   public static function buildList($data)
261   {
262     $objects= "";
263     foreach ($name as $key => $value){
264       if (is_numeric($key)){
265         $objects.= "<br>\n<i>$value</i>";
266       } else {
267         $objects.= "<br>\n$key (<i>$value</i>)";
268       }
269     }
270   }