diff --git a/include/errors/class_FusionDirectoryWarning.inc b/include/errors/class_FusionDirectoryWarning.inc new file mode 100644 index 0000000000000000000000000000000000000000..6422baf701cc3dc4fd56165b74e21039f21bdebb --- /dev/null +++ b/include/errors/class_FusionDirectoryWarning.inc @@ -0,0 +1,30 @@ +<?php +/* + This code is part of FusionDirectory (http://www.fusiondirectory.org/) + + Copyright (C) 2019-2020 FusionDirectory + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +/*! \class FusionDirectoryWarning +*/ +class FusionDirectoryWarning extends FusionDirectoryError +{ + public function computeMsgDialogParameters (): array + { + return [_('Warning'), $this->htmlMessage, WARNING_DIALOG, static::formatTrace($this)]; + } +} diff --git a/include/login/class_LoginMethod.inc b/include/login/class_LoginMethod.inc index 1753e49f19ad78b1e00f25aaf3b1d86eb768ba4b..183f609d619d04870bf6f44c3ab99724a60d6833 100644 --- a/include/login/class_LoginMethod.inc +++ b/include/login/class_LoginMethod.inc @@ -36,7 +36,7 @@ class LoginMethod } /*! \brief Runs schemaCheck if activated in configuration */ - static function runSchemaCheck () + static function runSchemaCheck (): bool { global $config; if ($config->get_cfg_value('schemaCheck') != 'TRUE') { @@ -51,9 +51,10 @@ class LoginMethod foreach ($str as $tr) { if (!$tr['STATUS']) { if ($tr['IS_MUST_HAVE']) { - return htmlescape(_('LDAP schema check reported errors:')).'<br/><br/><i>'.htmlescape($tr['MSG']).'</i>'; + throw new FusionDirectoryError(htmlescape(_('LDAP schema check reported errors:')).'<br/><br/><i>'.htmlescape($tr['MSG']).'</i>'); } else { - msg_dialog::display(_('LDAP schema error'), htmlescape($tr['MSG']), WARNING_DIALOG); + $warning = new FusionDirectoryWarning(nl2br(htmlescape(sprintf(_("LDAP schema error:\n%s"), $tr['MSG'])))); + $warning->display(); } } } @@ -81,7 +82,7 @@ class LoginMethod /*! \brief Check username for invalid characters and check password is not empty * Also trims username */ - static function validateUserInput () + static function validateUserInput (): bool { global $message, $smarty; static::$username = trim(static::$username); @@ -97,7 +98,7 @@ class LoginMethod } /*! \brief Performs an LDAP bind with $username and $password */ - static function ldapLoginUser () + static function ldapLoginUser (): bool { global $ui, $config, $message, $smarty; /* Login as user, initialize user ACL's */ @@ -116,7 +117,7 @@ class LoginMethod } /*! \brief Called after successful login, return FALSE if account is expired */ - static function loginAndCheckExpired () + static function loginAndCheckExpired (): bool { global $ui, $config, $plist, $message, $smarty;