Commit 3bfcb5cc authored by Robert Lyon's avatar Robert Lyon

Bug 1660177: Allow saml missing modules error messages to show php7 vs php5 info

To make it easier for admins to know which PHP modules to install

behatnotneeded

Change-Id: Ib58750436426f87b3e6c4fc41c639b930f0a6a56
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent ac1a92ae
......@@ -33,6 +33,10 @@ class AuthInstanceException extends UserException {
return array_merge(parent::strings(),
array('title' => $this->get_sitename() . ': Authentication problem'));
}
public function render_exception() {
return $this->get_string('message') . "\n\n" . preg_replace('/<br\s?\/?>/ius', "\n", $this->getMessage());
}
}
/**
......
......@@ -41,7 +41,7 @@ if (get_field('auth_installed', 'active', 'name', 'saml') != 1) {
}
if (!extension_loaded('mcrypt')) {
throw new AuthInstanceException(get_string('errornomcrypt','auth.saml'));
throw new AuthInstanceException(get_string_php_version('errornomcrypt','auth.saml'));
}
$sp = 'default-sp';
......
......@@ -27,7 +27,9 @@ $string['errnosamluser'] = 'No user found';
$string['errorssphpsetup'] = 'SAML is not set up correctly. You Need to run "make ssphp" from the commandline first.';
$string['errorbadlib'] = 'The SimpleSAMLPHP library\'s "autoloader" file was not found at %s.<br>Make sure you install SimpleSAMLphp via "make ssphp" and the file is readable.';
$string['errornomcrypt'] = 'The PHP library "mcrypt" must be installed for auth/saml. Make sure you install and activate mcrypt, e.g.:<br>sudo apt-get install php5-mcrypt<br>sudo php5enmod mcrypt<br>Then restart your web server.';
$string['errornomcrypt7php'] = 'The PHP library "mcrypt" must be installed for auth/saml. Make sure you install and activate mcrypt, e.g.:<br>sudo apt-get install php7.0-mcrypt<br>sudo phpenmod mcrypt<br>Then restart your web server.';
$string['errornomemcache'] = 'A memcache server is needed for auth/saml. Either list the paths to your memcache servers in the $cfg->memcacheservers config variable or install memcache locally.<br>To install the PHP library "memcache" locally:<br>sudo apt-get install php5-memcache<br>sudo php5enmod memcache<br>Then restart you web server.';
$string['errornomemcache7php'] = 'A memcache server is needed for auth/saml. Either list the paths to your memcache servers in the $cfg->memcacheservers config variable or install memcache locally.<br>To install the PHP library "memcache" locally:<br>sudo apt-get install php-memcache<br>sudo phpenmod memcache<br>Then restart you web server.';
$string['errorbadconfig'] = 'The SimpleSAMLPHP config directory %s is incorrect.';
$string['errorbadmetadata'] = 'Badly formed SAML metadata. Ensure XML contains one valid Identity Provider.';
$string['errorduplicateidp1'] = 'The Identity Provider "%s" is already in use by institution "%s". Ensure the XML contains one valid and unique Identity Provider.';
......
......@@ -456,7 +456,7 @@ class PluginAuthSaml extends PluginAuth {
$libchecks = '';
// Make sure mcrypt exists
if (!extension_loaded('mcrypt')) {
$libchecks .= '<li>' . get_string('errornomcrypt', 'auth.saml') . '</li>';
$libchecks .= '<li>' . get_string_php_version('errornomcrypt', 'auth.saml') . '</li>';
}
// Make sure the simplesamlphp files have been installed via 'make ssphp'
if (!file_exists(get_config('docroot') .'auth/saml/extlib/simplesamlphp/vendor/autoload.php')) {
......@@ -465,7 +465,7 @@ class PluginAuthSaml extends PluginAuth {
// Make sure we can use 'memcache' with simplesamlphp as 'phpsession' doesn't work correctly in many situations
$memcacheservers_config = get_config('memcacheservers');
if (empty($memcacheservers_config) && !extension_loaded('memcache')) {
$libchecks .= '<li>' . get_string('errornomemcache', 'auth.saml') . '</li>';
$libchecks .= '<li>' . get_string_php_version('errornomemcache', 'auth.saml') . '</li>';
}
if (!empty($libchecks)) {
$libcheckstr = '<div class="alert alert-danger"><ul class="unstyled">' . $libchecks . '</ul></div>';
......
......@@ -41,7 +41,7 @@ if (get_field('auth_installed', 'active', 'name', 'saml') != 1) {
}
if (!extension_loaded('mcrypt')) {
throw new AuthInstanceException(get_string('errornomcrypt', 'auth.saml'));
throw new AuthInstanceException(get_string_php_version('errornomcrypt', 'auth.saml'));
}
if (!file_exists(get_config('docroot') . 'auth/saml/extlib/simplesamlphp/vendor/autoload.php')) {
......
......@@ -42,7 +42,7 @@ if (get_field('auth_installed', 'active', 'name', 'saml') != 1) {
}
if (!extension_loaded('mcrypt')) {
throw new AuthInstanceException(get_string('errornomcrypt', 'auth.saml'));
throw new AuthInstanceException(get_string_php_version('errornomcrypt', 'auth.saml'));
}
if (!file_exists(get_config('docroot') . 'auth/saml/extlib/simplesamlphp/vendor/autoload.php')) {
......
......@@ -41,7 +41,7 @@ if (get_field('auth_installed', 'active', 'name', 'saml') != 1) {
}
if (!extension_loaded('mcrypt')) {
throw new AuthInstanceException(get_string('errornomcrypt', 'auth.saml'));
throw new AuthInstanceException(get_string_php_version('errornomcrypt', 'auth.saml'));
}
if (!file_exists(get_config('docroot') . 'auth/saml/extlib/simplesamlphp/vendor/autoload.php')) {
......
......@@ -41,7 +41,7 @@ if (get_field('auth_installed', 'active', 'name', 'saml') != 1) {
}
if (!extension_loaded('mcrypt')) {
throw new AuthInstanceException(get_string('errornomcrypt', 'auth.saml'));
throw new AuthInstanceException(get_string_php_version('errornomcrypt', 'auth.saml'));
}
if (!file_exists(get_config('docroot') . 'auth/saml/extlib/simplesamlphp/vendor/autoload.php')) {
......
......@@ -41,7 +41,7 @@ if (get_field('auth_installed', 'active', 'name', 'saml') != 1) {
}
if (!extension_loaded('mcrypt')) {
throw new AuthInstanceException(get_string('errornomcrypt', 'auth.saml'));
throw new AuthInstanceException(get_string_php_version('errornomcrypt', 'auth.saml'));
}
if (!file_exists(get_config('docroot') . 'auth/saml/extlib/simplesamlphp/vendor/autoload.php')) {
......
......@@ -307,6 +307,16 @@ function get_string($identifier, $section='mahara') {
return get_string_location($identifier, $section, $variables);
}
function get_string_php_version($identifier, $section = 'mahara') {
if (version_compare(PHP_VERSION, '7.0.0') >= 0
&& string_exists($identifier . '7php', $section)) {
return get_string($identifier . '7php', $section);
}
else {
return get_string($identifier, $section);
}
}
function get_string_from_language($lang, $identifier, $section='mahara') {
$variables = func_get_args();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment