libdir . '/tablelib.php'; require_once($CFG->libdir.'/adminlib.php'); $adminroot = admin_get_root(); admin_externalpage_setup('userauthentication', $adminroot); // get currently installed and enabled auth plugins $authsavailable = get_list_of_plugins('auth'); if (empty($CFG->auth_plugins_enabled)) { set_config('auth_plugins_enabled', $CFG->auth); $CFG->auth_plugins_enabled = $CFG->auth; } $authsenabled = explode(',', $CFG->auth_plugins_enabled); // save form if ($form = data_submitted()) { if (!confirm_sesskey()) { error(get_string('confirmsesskeybad', 'error')); } if (! isset($form->guestloginbutton)) { $form->guestloginbutton = 1; } if (empty($form->alternateloginurl)) { $form->alternateloginurl = ''; } if (empty($form->register)) { $form->register = 'manual'; } set_config('guestloginbutton', $form->guestloginbutton); set_config('alternateloginurl', $form->alternateloginurl); set_config('auth', $form->register); // add $CFG->auth to auth_plugins_enabled list if (!array_search($form->register, $authsenabled)) { $authsenabled[] = $form->register; $authsenabled = array_unique($authsenabled); set_config('auth_plugins_enabled', implode(',', $authsenabled)); } } // grab GET/POST parameters $params = new object(); $params->action = optional_param('action', '', PARAM_ACTION); $params->auth = optional_param('auth', $CFG->auth, PARAM_ALPHANUM); //////////////////////////////////////////////////////////////////////////////// // process actions switch ($params->action) { case 'disable': // remove from enabled list $key = array_search($params->auth, $authsenabled); if ($key !== false and $params->auth != $CFG->auth) { unset($authsenabled[$key]); set_config('auth_plugins_enabled', implode(',', $authsenabled)); } break; case 'enable': // check auth plugin is valid first if (!exists_auth_plugin($params->auth)) { error(get_string('pluginnotinstalled', 'auth', $params->auth), $url); } // add to enabled list if (!array_search($params->auth, $authsenabled)) { $authsenabled[] = $params->auth; $authsenabled = array_unique($authsenabled); set_config('auth_plugins_enabled', implode(',', $authsenabled)); } break; case 'down': $key = array_search($params->auth, $authsenabled); // check auth plugin is valid if ($key === false) { error(get_string('pluginnotenabled', 'auth', $params->auth), $url); } // move down the list if ($key < (count($authsenabled) - 1)) { $fsave = $authsenabled[$key]; $authsenabled[$key] = $authsenabled[$key + 1]; $authsenabled[$key + 1] = $fsave; set_config('auth_plugins_enabled', implode(',', $authsenabled)); } break; case 'up': $key = array_search($params->auth, $authsenabled); // check auth is valid if ($key === false) { error(get_string('pluginnotenabled', 'auth', $params->auth), $url); } // move up the list if ($key >= 1) { $fsave = $authsenabled[$key]; $authsenabled[$key] = $authsenabled[$key - 1]; $authsenabled[$key - 1] = $fsave; set_config('auth_plugins_enabled', implode(',', $authsenabled)); } break; case 'save': // save settings set_config('auth_plugins_enabled', implode(',', $authsenabled)); set_config('auth', $authsenabled[0]); redirect("auth.php?sesskey=$USER->sesskey", get_string('changessaved'), 1); break; default: break; } // display strings $txt = get_strings(array('authenticationplugins', 'users', 'administration', 'settings', 'edit', 'name', 'enable', 'disable', 'up', 'down', 'none')); $txt->updown = "$txt->up/$txt->down"; // construct the display array, with enabled auth plugins at the top, in order $displayauths = array(); $registrationauths = array(); $registrationauths['manual'] = $txt->disable; foreach ($authsenabled as $auth) { $displayauths[$auth] = get_string("auth_{$auth}title", 'auth'); $authplugin = get_auth_plugin($auth); if (method_exists($authplugin, 'user_signup')) { $registrationauths[$auth] = get_string("auth_{$auth}title", 'auth'); } } foreach ($authsavailable as $auth) { if (!array_key_exists($auth, $displayauths)) { $displayauths[$auth] = get_string("auth_{$auth}title", 'auth'); } $authplugin = get_auth_plugin($auth); if (method_exists($authplugin, 'user_signup')) { $registrationauths[$auth] = get_string("auth_{$auth}title", 'auth'); } } // build the display table $table = new flexible_table('auth_admin_table'); $table->define_columns(array('name', 'enable', 'order', 'settings')); $table->column_style('enable', 'text-align', 'center'); $table->column_style('order', 'text-align', 'center'); $table->column_style('settings', 'text-align', 'center'); $table->define_headers(array($txt->name, $txt->enable, $txt->updown, $txt->settings)); $table->define_baseurl("{$CFG->wwwroot}/{$CFG->admin}/auth.php"); $table->set_attribute('id', 'blocks'); $table->set_attribute('class', 'flexible generaltable generalbox'); $table->set_attribute('style', 'margin:auto;'); $table->set_attribute('cellpadding', '5'); $table->setup(); // iterate through auth plugins and add to the display table $updowncount = 1; $authcount = count($authsenabled); $url = "auth.php?sesskey=" . sesskey(); foreach ($displayauths as $auth => $name) { // hide/show link if (in_array($auth, $authsenabled)) { $hideshow = ""; $hideshow .= "pixpath}/i/hide.gif\" class=\"icon\" alt=\"disable\" />"; // $hideshow = ""; $enabled = true; $displayname = "$name"; } else { $hideshow = ""; $hideshow .= "pixpath}/i/show.gif\" class=\"icon\" alt=\"enable\" />"; // $hideshow = ""; $enabled = false; $displayname = "$name"; } // up/down link (only if auth is enabled) $updown = ''; if ($enabled) { if ($updowncount > 1) { $updown .= ""; $updown .= "pixpath}/t/up.gif\" alt=\"up\" /> "; } else { $updown .= "pixpath}/spacer.gif\" class=\"icon\" alt=\"\" /> "; } if ($updowncount < $authcount) { $updown .= ""; $updown .= "pixpath}/t/down.gif\" alt=\"down\" />"; } else { $updown .= "pixpath}/spacer.gif\" class=\"icon\" alt=\"\" />"; } ++ $updowncount; } // settings link $settings = "sesskey}&auth=$auth\">{$txt->settings}"; // add a row to the table $table->add_data(array($displayname, $hideshow, $updown, $settings)); } // output form admin_externalpage_print_header($adminroot); print_simple_box(get_string('configauthenticationplugins', 'admin'), 'center', '700'); echo "
frametarget id=\"authmenu\" method=\"post\" action=\"auth.php\">"; echo "
sesskey."\" />
"; print_table($table); //////////////////////////////////////////////////////////////////////////////// $guestoptions[0] = get_string("hide"); $guestoptions[1] = get_string("show"); echo '
'; print_heading(get_string('auth_common_settings', 'auth')); echo ''; // User self registration echo "\n"; echo "\n"; echo "\n"; echo "\n"; // Login as guest button enabled echo "\n"; echo "\n"; echo "\n"; echo "\n"; /// An alternate url for the login form. It means we can use login forms that are integrated /// into non-moodle pages echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; print_string("selfregistration", "auth"); echo ":\n"; choose_from_menu($registrationauths, "register", $CFG->auth, ""); echo "\n"; print_string("selfregistration_help", "auth"); echo "
\n"; print_string("guestloginbutton", "auth"); echo ":\n"; choose_from_menu($guestoptions, "guestloginbutton", $CFG->guestloginbutton, ""); echo "\n"; print_string("showguestlogin","auth"); echo "
\n"; print_string('alternateloginurl', 'auth'); echo "\n"; echo '\n"; echo "\n"; print_string('alternatelogin', 'auth', htmlspecialchars($CFG->wwwroot.'/login/index.php')); echo "
\n"; //////////////////////////////////////////////////////////////////////////////// echo '
'; echo '
'; admin_externalpage_print_footer($adminroot); ?>