...
 
Commits (4)
......@@ -127,6 +127,26 @@ class Language
return al2gt($langs);
}
/*!
* \brief Checks if a locale is available
*
* \param string $lang Language locale to use
*/
public static function isAvailable (string $lang): bool
{
/* Store current locale */
$locale = setlocale(LC_ALL, 0);
/* Try to switch */
list ($language, , $char) = parse_gettext_lang($lang);
$langset = setlocale(LC_ALL, $lang, $language.'.'.$char);
/* Set current locale back */
setlocale(LC_ALL, $locale);
return ($langset !== FALSE);
}
/*!
* \brief Get the language for the user connecting
*
......
......@@ -139,19 +139,23 @@ class logging
if (empty($entry['object'])) {
$entry['object'] = 'none';
}
$tabObject = objects::create('auditEvent');
$baseObject = $tabObject->getBaseObject();
$baseObject->fdAuditDateTime = DateTime::createFromFormat('U.u', number_format($entry['timestamp'], 6, '.', ''));
$baseObject->fdAuditAction = $entry['action'];
$baseObject->fdAuditAuthorDN = $entry['user'];
$baseObject->fdAuditObjectType = $entry['objecttype'];
$baseObject->fdAuditObject = $entry['object'];
$baseObject->fdAuditAttributes = $entry['changes'];
$baseObject->fdAuditResult = $entry['result'];
$baseObject->base = $config->current['BASE'];
$message = $tabObject->save();
if (!empty($message)) {
msg_dialog::displayChecks($message);
try {
$tabObject = objects::create('auditEvent');
$baseObject = $tabObject->getBaseObject();
$baseObject->fdAuditDateTime = DateTime::createFromFormat('U.u', number_format($entry['timestamp'], 6, '.', ''));
$baseObject->fdAuditAction = $entry['action'];
$baseObject->fdAuditAuthorDN = $entry['user'];
$baseObject->fdAuditObjectType = $entry['objecttype'];
$baseObject->fdAuditObject = $entry['object'];
$baseObject->fdAuditAttributes = $entry['changes'];
$baseObject->fdAuditResult = $entry['result'];
$baseObject->base = $config->current['BASE'];
$message = $tabObject->save();
if (!empty($message)) {
msg_dialog::displayChecks($message);
}
} catch (FusionDirectoryException $e) {
msg_dialog::display(_('Error'), sprintf(_('Failed to log event (%s - %s): %s'), $entry['action'], $entry['objecttype'], $e->getMessage()), ERROR_DIALOG);
}
}
}
......@@ -533,6 +533,9 @@ class configInLdap extends simplePlugin
if (($this->fdPasswordDefaultHash == 'sasl') && ($this->fdSaslRealm == '') && ($this->fdSaslExop == '')) {
$messages[] = _('You need to fill saslRealm or saslExop in the configuration screen in order to use SASL');
}
if ($this->attributesAccess['fdLanguage']->hasChanged() && ($this->fdLanguage != '') && !Language::isAvailable($this->fdLanguage)) {
$messages[] = sprintf(_('It seems the selected language "%s" is not installed on the system. Please install it or select an other one.'), $this->fdLanguage);
}
return $messages;
}
......