1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564
|
<?php
define ("LDAP_READ", 1);
define ("LDAP_ADD", 2);
define ("LDAP_MOD", 3);
define ("LDAP_DEL", 4);
define ("LDAP_SEARCH", 5);
define ("LDAP_AUTH", 6);
/*! \brief Some common needed messages */
class msgPool
{
public static function deleteInfo($name= "",$type = "")
{
if ($name == "") {
if($type == ""){
return (_("This object will be deleted!"));
}else{
return (sprintf(_("This %s object will be deleted!"), bold($type)));
}
}
if (!is_array($name)){
if($type == ""){
return (sprintf(_("This object will be deleted: %s"), "<br><br>$name"));
}else{
return (sprintf(_("This %s object will be deleted: %s"), bold($type), "<br><br>$name"));
}
}
if (count($name) == 1){
if($type == ""){
return (_("This object will be deleted:")."<br>".msgPool::buildList($name));
}else{
return (sprintf(_("This %s object will be deleted:"), bold($type)). "<br>".msgPool::buildList($name));
}
}
if($type == ""){
return (sprintf(_("These objects will be deleted: %s"), "<br><br>".msgPool::buildList($name)));
}else{
return (sprintf(_("These %s objects will be deleted: %s"), bold($type), "<br>".msgPool::buildList($name)));
}
}
public static function permDelete($name= "")
{
if ($name == "") {
return (_("You have no permission to delete this object!"));
}
if (!is_array($name)){
return (_("You have no permission to delete the object:")."<br><br>$name");
}
if (count($name) == 1){
return (_("You have no permission to delete the object:")."<br>".msgPool::buildList($name));
}
return (_("You have no permission to delete these objects:")."<br>".msgPool::buildList($name));
}
public static function permCreate($name= "")
{
if ($name == "") {
return (_("You have no permission to create this object!"));
}
if (!is_array($name)){
return (_("You have no permission to create the object:")."<br><br>$name");
}
if (count($name) == 1){
return (_("You have no permission to create the object:")."<br>".msgPool::buildList($name));
}
return (_("You have no permission to create these objects:")."<br>".msgPool::buildList($name));
}
public static function permModify($name= "")
{
if ($name == "") {
return (_("You have no permission to modify this object!"));
}
if (!is_array($name)){
return (_("You have no permission to modify the object:")."<br><br>$name");
}
if (count($name) == 1){
return (_("You have no permission to modify the object:")."<br>".msgPool::buildList($name));
}
return (_("You have no permission to modify these objects:")."<br>".msgPool::buildList($name));
}
public static function permView($name= "")
{
if ($name == "") {
return (_("You have no permission to view this object!"));
}
if (!is_array($name)){
return (_("You have no permission to view the object:")."<br><br>$name");
}
if (count($name) == 1){
return (_("You have no permission to view the object:")."<br>".msgPool::buildList($name));
}
return (_("You have no permission to view these objects:")."<br>".msgPool::buildList($name));
}
public static function permMove($name= "")
{
if ($name == "") {
return (_("You have no permission to move this object!"));
}
if (!is_array($name)){
return (_("You have no permission to move the object:")."<br><br>$name");
}
if (count($name) == 1){
return (_("You have no permission to move the object:")."<br>".msgPool::buildList($name));
}
return (_("You have no permission to move these objects:")."<br>".msgPool::buildList($name));
}
public static function dbconnect($name, $error= "", $dbinfo= "")
{
if ($error != ""){
$error= "<br><br>"._("Error").": ".bold($error);
}
if ($dbinfo != ""){
$error.= "<br><br>"._("Connection information").": ".bold($dbinfo);
}
return (sprintf(_("Cannot connect to %s database!"), bold($name)).$error);
}
public static function noserver($name)
{
return (sprintf(_("No %s server defined!"), bold($name)));
}
public static function dbquery($name, $error= "", $dbinfo= "")
{
if ($error != ""){
$error= "<br><br>"._("Error").": ".bold($error);
}
if ($dbinfo != ""){
$error.= "<br><br>"._("Connection information").": ".bold($dbinfo);
}
return (sprintf(_("Cannot query %s database!"), bold($name)).$error);
}
public static function reserved($name)
{
return (sprintf(_("The field %s contains a reserved keyword!"), bold($name)));
}
public static function cmdnotfound($type, $plugin)
{
return (sprintf(_("Command specified as %s hook for plugin %s does not exist!"), bold($type), bold($plugin)));
}
public static function cmdinvalid($type, $command = "",$plugin="")
{
if(empty($command)){
return (sprintf(_("%s command is invalid!"), bold($type)));
}elseif($command != "" && $plugin != ""){
return (sprintf(_("%s command (%s) for plugin %s is invalid!"), bold($type), bold($command) ,bold($plugin)));
}elseif($plugin != "" && $command =""){
return (sprintf(_("%s command for plugin %s is invalid!"), bold($type), bold($plugin)));
}else{
return (sprintf(_("%s command (%s) is invalid!"), bold($type), bold($command)));
}
}
public static function cmdexecfailed($type, $command = "",$plugin="")
{
if(empty($command)){
return (sprintf(_("Cannot execute %s command!"), bold($type)));
}elseif($command != "" && $plugin != ""){
return (sprintf(_("Cannot execute %s command (%s) for plugin %s!"), bold($type), bold($command), bold($plugin)));
}elseif($plugin != "" && $command =""){
return (sprintf(_("Cannot execute %s command for plugin %s!"), bold($type), bold($plugin)));
}else{
return (sprintf(_("Cannot execute %s command (%s)!"), bold($type), bold($command)));
}
}
public static function toobig($name, $min= "")
{
if ($min == ""){
return (sprintf(_("Value for %s is too large!"), bold($name)));
} else {
return (sprintf(_("%s must be smaller than %s!"), bold($name), bold($min)));
}
}
public static function toosmall($name, $min= "")
{
if ($min == ""){
return (sprintf(_("Value for %s is too small!"), bold($name)));
} else {
return (sprintf(_("%s must be %s or above!"), bold($name), bold($min)));
}
}
public static function depends($name1, $name2)
{
return (sprintf(_("%s depends on %s - please provide both values!"), bold($name1), bold($name2)));
}
public static function duplicated($name)
{
return (sprintf(_("There is already an entry with this %s attribute in the system!"), bold($name)));
}
public static function required($name)
{
return (sprintf(_("The required field %s is empty!"), bold($name)));
}
public static function invalid($name, $data= "", $regex= "", $example= "")
{
/* Stylize example */
if ($example != ""){
$example= "<br><br>"._("Example").": ".bold($example);
}
/* If validChars are posted, take data and paint all invalid
characters... */
if ($regex) {
$result= "";
$mismatch= "";
mb_internal_encoding('UTF-8');
for($i=0; $i<=mb_strlen($data);$i++){
$currentChar= mb_substr($data, $i,1);
if (preg_match("$regex", $currentChar)){
$result.= $currentChar;
} else {
$result.= "<font style='color:red;text-decoration:underline;'>".($currentChar)."</font>";
$mismatch.= $currentChar;
}
}
return sprintf(_("The Field %s contains invalid characters"), bold($name)).". ".
(strlen($mismatch)==1?sprintf(_("%s is not allowed:"), bold($mismatch)):sprintf(_("%s are not allowed!"), bold($mismatch))).
"<br><br> \"$result\"$example";
} else {
return sprintf(_("The Field %s contains invalid characters!"), bold($name))."!$example";
}
}
public static function missingext($name)
{
return sprintf(_("Missing %s PHP extension!"), bold($name));
}
public static function cancelButton()
{
return sprintf(_("Cancel"));
}
public static function okButton()
{
return sprintf(_("OK"));
}
public static function applyButton()
{
return sprintf(_("Apply"));
}
public static function saveButton()
{
return sprintf(_("Save"));
}
public static function addButton($what= "")
{
return $what == "" ? sprintf(_("Add")): sprintf(_("Add %s"), $what);
}
public static function delButton($what= "")
{
return $what == "" ? sprintf(_("Delete")): sprintf(_("Delete %s"), $what);
}
public static function setButton($what= "")
{
return $what == "" ? sprintf(_("Set")): sprintf(_("Set %s"), $what);
}
public static function editButton($what= "")
{
return $what == "" ? sprintf(_("Edit...")): sprintf(_("Edit %s..."), $what);
}
public static function backButton($what= "")
{
return _("Back");
}
public static function buildList($data)
{
$objects= "<ul class='object-list'>";
foreach ($data as $key => $value){
if (is_numeric($key)){
$objects.= "<li>\n".LDAP::makeReadable($value)."</li>";
} else {
$objects.= "<li>\n$value <span>".LDAP::makeReadable($key)."</span></li>";
}
}
$objects.= "</ul>";
return($objects);
}
public static function noValidExtension($name)
{
return sprintf(_("This account has no valid %s extensions!"), bold($name));
}
public static function featuresEnabled($name, $depends= "")
{
if ($depends == ""){
return sprintf(_("This account has %s settings enabled. You can disable them by clicking below."), bold($name));
} else {
if (count($depends) == 1){
return sprintf(_("This account has %s settings enabled. To disable them, you'll need to remove the %s settings first!"), bold($name), bold($depends));
} else {
$deps= "";
foreach ($depends as $dep){
$deps.= "$dep / ";
}
$deps= preg_replace("/ \/ $/", "", $deps);
return sprintf(_("This account has %s settings enabled. To disable them, you'll need to remove the %s settings first!"), bold($name), bold($deps));
}
}
}
public static function featuresDisabled($name, $depends= "")
{
if ($depends == ""){
return sprintf(_("This account has %s settings disabled. You can enable them by clicking below."), bold($name));
} else {
if (count($depends) == 1){
return sprintf(_("This account has %s settings disabled. To enable them, you'll need to add the %s settings first!"), bold($name), bold($depends));
} else {
$deps= "";
foreach ($depends as $dep){
$deps.= "$dep / ";
}
$deps= preg_replace("/ \/ $/", "", $deps);
return sprintf(_("This account has %s settings disabled. To enable them, you'll need to add the %s settings first!"), bold($name), bold($deps));
}
}
}
public static function addFeaturesButton($name)
{
return sprintf(_("Add %s settings"), $name);
}
public static function removeFeaturesButton($name)
{
return sprintf(_("Remove %s settings"), $name);
}
public static function clickEditToChange()
{
return _("Click the 'Edit' button below to change informations in this dialog");
}
public static function months()
{
return array(_("January"), _("February"), _("March"), _("April"),
_("May"), _("June"), _("July"), _("August"), _("September"),
_("October"), _("November"), _("December"));
}
public static function weekdays()
{
return array( _("Sunday"), _("Monday"), _("Tuesday"), _("Wednesday"), _("Thursday"), _("Friday"), _("Saturday"));
}
public static function mysqlerror($error, $plugin= "")
{
/* Assign headline depending on type */
$headline= _("MySQL operation failed!");
return $headline."<br><br>"._("Error").": ".bold($error);
}
public static function ldaperror($error, $dn= "", $type= 0, $plugin= "")
{
/* Assign headline depending on type */
$typemap= array(1 => _("read operation"), _("add operation"), _("modify operation"),
_("delete operation"), _("search operation"), _("authentication"));
if (isset($typemap[$type])){
$headline= sprintf(_("LDAP %s failed!"), bold($typemap[$type]));
} else {
$headline= _("LDAP operation failed!");
}
/* Fill DN information */
$dn_info="";
if ($dn != ""){
$dn_info= "<br><br>"._("Object").": ".bold(LDAP::fix($dn));
}
return $headline.$dn_info."<br><br>"._("Error").": ".bold($error);
}
public static function incorrectUpload($reason= "")
{
if ($reason == ""){
return _("Upload failed!");
}
return sprintf(_("Upload failed: %s"), "<br><br>".bold($reason));
}
public static function siError($error= "")
{
if ($error == ""){
return _("Communication failure with the infrastructure service!");
}
return sprintf(_("Communication failure with the infrastructure service: %s"), "<br><br>".$error);
}
public static function rpcError($error= "")
{
if ($error == ""){
return _("Communication failure with the GOsa-NG service!");
}
return sprintf(_("Communication failure with the GOsa-NG service: %s"), "<br><br>".$error);
}
public static function stillInUse($type, $objects= array())
{
if (!is_array($objects)){
return sprintf(_("This %s is still in use by this object: %s"), bold($type), "<br><br>".$objects);
}
if (count($objects) == 1){
return sprintf(_("This %s is still in use by this object: %s"), bold($type), "<br>".msgPool::buildList($objects));
}
if (count($objects) == 0){
return sprintf(_("This %s is still in use."), bold($type));
}
return sprintf(_("This %s is still in use by these objects: %s"), bold($type), "<br>".msgPool::buildList($objects));
}
public static function fileDoesNotExist($file)
{
return sprintf(_("File %s does not exist!"), bold($file));
}
public static function cannotReadFile($file)
{
return sprintf(_("Cannot open file %s for reading!"), bold($file));
}
public static function cannotWriteFile($file)
{
return sprintf(_("Cannot open file %s for writing!"), bold($file));
}
public static function invalidConfigurationAttribute($attr)
{
return sprintf(_("The value for %s is currently unconfigured or invalid, please check your configuration file!"), bold($attr));
}
public static function cannotDeleteFile($file)
{
return sprintf(_("Cannot delete file %s!"), bold($file));
}
public static function cannotCreateFolder($path)
{
return sprintf(_("Cannot create folder %s!"), bold($path));
}
public static function cannotDeleteFolder($path)
{
return sprintf(_("Cannot delete folder %s!"), bold($path));
}
public static function checkingFor($what)
{
return sprintf(_("Checking for %s support"), bold($what));
}
public static function installPhpModule($what)
{
return sprintf(_("Install and activate the %s PHP module."), bold($what));
}
public static function class_not_found($plugin)
{
return (sprintf(_("Cannot initialize class %s! Maybe there is a plugin missing in your gosa setup?"), bold($plugin)));
}
public static function check_base()
{
return _("The supplied base is not valid and has been reset to its previous value!");
}
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
|