Simple status box for the sidebar.
[elgg_plugins.git] / openid_client / missing.php
blob8be7673b4c96460186f8934ee61e6a735d966351
1 <?php
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'));
9 $error = false;
10 if (!$name) {
11 $messages[] = gettext("You must provide a name.");
12 $error = true;
14 if (!$email || !validateEmailSyntax($email)) {
15 $messages[] = gettext("You must provide a valid email address.");
16 $error = true;
19 if (empty($code) || !($details = get_record('invitations','code',$code))) {
20 $messages[] = $invalid_code_msg;
21 $error = true;
24 if (!$error) {
25 // looks good
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') {
36 //activate and login
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);
45 exit;
46 } elseif ($details) {
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(
58 sitename,
59 templates_draw(array(
60 'body' => $body,
61 'title' => gettext("OpenID information"),
62 'context' => 'contentholder'
67 } else {
68 // bad code - not much to do but inform user
69 $_SESSION['messages'] = $messages;
70 header("Location: " . $CFG->wwwroot);
71 exit;