4 * @author Martin Dougiamas
5 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
6 * @package moodle multiauth
8 * Authentication Plugin: NNTP Authentication
10 * Authenticates against an NNTP server.
12 * 2006-08-31 File created.
15 // This page cannot be called directly
16 if (!isset($CFG)) exit;
19 * NNTP authentication plugin.
21 class auth_plugin_nntp
{
24 * The configuration details for the plugin.
31 function auth_plugin_nntp() {
32 $this->config
= get_config('auth/nntp');
36 * Returns true if the username and password work and false if they are
37 * wrong or don't exist.
39 * @param string $username The username
40 * @param string $password The password
41 * @returns bool Authentication success or failure.
43 function user_login ($username, $password) {
44 if (! function_exists('imap_open')) {
45 print_error('auth_nntpnotinstalled','auth');
51 // try each multiple host
52 $hosts = split(';', $this->config
->host
);
53 foreach ($hosts as $host) {
54 $host = '{' . trim($host) . ':' . $this->config
->port
. '/nntp}';
57 $connection = imap_open($host, $username, $password, OP_HALFOPEN
);
58 error_reporting($CFG->debug
);
61 imap_close($connection);
69 * Returns true if this authentication plugin is 'internal'.
73 function is_internal() {
78 * Returns true if this authentication plugin can change the user's
83 function can_change_password() {
88 * Prints a form for configuring this authentication plugin.
90 * This function is called from admin/auth.php, and outputs a full page with
91 * a form for configuring this plugin.
93 * @param array $page An object containing all the data for this page.
95 function config_form($config, $err) {
96 include "config.html";
100 * Processes and stores configuration data for this authentication plugin.
102 function process_config($config) {
103 // set to defaults if undefined
104 if (!isset ($config->host
)) {
105 $config->host
= '127.0.0.1';
107 if (!isset ($config->port
)) {
108 $config->port
= '119';
110 if (!isset($config->changepasswordurl
)) {
111 $config->changepasswordurl
= '';
115 set_config('host', $config->host
, 'auth/nntp');
116 set_config('port', $config->port
, 'auth/nntp');
117 set_config('changepasswordurl', $config->changepasswordurl
, 'auth/nntp');