/** * Check if a Serivce Provider (SP) is enabled in the plugin settings. * * @param string $source the name of the SP to check * * @return bool true is enabled, false in all other cases */ function simplesaml_is_enabled_source($source) { $result = false; if (!empty($source)) { $enabled_sources = simplesaml_get_enabled_sources(); if (!empty($enabled_sources) && in_array($source, $enabled_sources)) { $result = true; } } return $result; }
<?php /** * Offer the ability to limit the logon widget to only show one SAML/CAS source */ // prevent crashes in the plugin is not yet configured if (!is_callable('simplesaml_get_enabled_sources')) { return true; } $sources = simplesaml_get_enabled_sources(); if (empty($sources)) { echo elgg_echo('simplesaml:settings:warning:configuration:sources'); return; } $widget = elgg_extract('entity', $vars); $options_values = ['all' => elgg_echo('all')]; foreach ($sources as $source) { $options_values[$source] = simplesaml_get_source_label($source); } echo '<div>'; echo elgg_echo('simplesaml:widget:select_source'); echo elgg_view('input/dropdown', ['name' => 'params[samlsource]', 'value' => $widget->samlsource, 'options_values' => $options_values, 'class' => 'mls']); echo '</div>';
/** * Check if a Service Provider (SP) is enabled in the plugin settings. * * @param string $source the name of the SP to check * * @return bool */ function simplesaml_is_enabled_source($source) { if (empty($source)) { return false; } $enabled_sources = simplesaml_get_enabled_sources(); if (empty($enabled_sources)) { return false; } return in_array($source, $enabled_sources); }