3 require_once(dirname(dirname(dirname(__FILE__
)))."/includes.php");
4 require_once('openid_includes.php');
6 $code = optional_param('code');
7 $name = trim(optional_param('name'));
8 $email = trim(optional_param('email'));
11 $messages[] = gettext("You must provide a name.");
14 if (!$email ||
!validateEmailSyntax($email)) {
15 $messages[] = gettext("You must provide a valid email address.");
19 if (empty($code) ||
!($details = get_record('invitations','code',$code))) {
20 $messages[] = $invalid_code_msg;
27 if ($code{0} == 'a') {
28 // need to confirm first
29 $details->email
= $email;
30 set_field('invitations','email',$email,'ident',$details->ident
);
31 $details->name
= $name;
32 set_field('invitations','name',$name,'ident',$details->ident
);
33 openid_client_send_activate_confirmation_message($details);
34 $messages[] = $activate_confirmation1 . $email . $activate_confirmation2;
35 } elseif ($code{0} == 'n') {
37 $messages[] = $created_external_msg." $email, $name";
38 set_field('users','name',$name,'ident',$details->owner
);
39 set_field('users','active','yes','ident',$details->owner
);
40 $user = get_record_select('users',"ident = ? AND user_type = ? ", array($details->owner
,'external'));
41 $USER = init_user_var($user);
43 $_SESSION['messages'] = $messages;
44 header("Location: " . $CFG->wwwroot
);
47 // regenerate the form
48 $user = get_record_select('users',"ident = ? AND user_type = ? ", array($details->owner
,'external'));
49 $openid_url = $user->username
;
50 $email_confirmation = openid_client_check_email_confirmation($openid_url);
51 $body = openid_client_generate_missing_data_form($openid_url,$email,$fullname,$email_confirmation,$code);
53 define("context", "OpenID register");
55 templates_page_setup();
57 echo templates_page_draw( array(
61 'title' => gettext("OpenID information"),
62 'context' => 'contentholder'
68 // bad code - not much to do but inform user
69 $_SESSION['messages'] = $messages;
70 header("Location: " . $CFG->wwwroot
);