diff options
author | Cash Costello <cash.costello@gmail.com> | 2011-12-11 06:38:23 -0500 |
---|---|---|
committer | Cash Costello <cash.costello@gmail.com> | 2011-12-11 06:38:23 -0500 |
commit | d9bf22a0e29c2a70049443a0ae8521a2c0492c8b (patch) | |
tree | c7599a9169d5def7df56c480ad6d67f312443d6f /actions | |
download | elgg-d9bf22a0e29c2a70049443a0ae8521a2c0492c8b.tar.gz elgg-d9bf22a0e29c2a70049443a0ae8521a2c0492c8b.tar.bz2 |
initial commit for git repository
Diffstat (limited to 'actions')
-rw-r--r-- | actions/admin.php | 34 | ||||
-rw-r--r-- | actions/login.php | 4 | ||||
-rw-r--r-- | actions/missing.php | 54 | ||||
-rw-r--r-- | actions/sync.php | 57 |
4 files changed, 149 insertions, 0 deletions
diff --git a/actions/admin.php b/actions/admin.php new file mode 100644 index 000000000..568c852a5 --- /dev/null +++ b/actions/admin.php @@ -0,0 +1,34 @@ +<?php
+
+// let admins configure the OpenID client
+
+require_once(dirname(dirname(__FILE__)).'/models/model.php');
+
+admin_gatekeeper();
+
+$always_sync = get_input('always_sync');
+$sso = get_input('sso','no');
+$default_server = trim(get_input('default_server'));
+$greenlist = trim(get_input('greenlist'));
+$yellowlist = trim(get_input('yellowlist'));
+$redlist = trim(get_input('redlist'));
+
+set_plugin_setting('default_server',$default_server,'openid_client');
+if ($always_sync) {
+ set_plugin_setting('always_sync',$always_sync,'openid_client');
+} else {
+ set_plugin_setting('always_sync','no','openid_client');
+}
+if ($sso) {
+ set_plugin_setting('sso',$sso,'openid_client');
+} else {
+ set_plugin_setting('sso','no','openid_client');
+}
+set_plugin_setting('greenlist',$greenlist,'openid_client');
+set_plugin_setting('yellowlist',$yellowlist,'openid_client');
+set_plugin_setting('redlist',$redlist,'openid_client');
+
+system_message(elgg_echo('openid_client:admin_response'));
+
+forward($CONFIG->wwwroot . "pg/openid_client/admin");
+
diff --git a/actions/login.php b/actions/login.php new file mode 100644 index 000000000..44b8233fd --- /dev/null +++ b/actions/login.php @@ -0,0 +1,4 @@ +<?php
+require_once(dirname(dirname(__FILE__)).'/models/model.php');
+
+openid_client_handle_login();
diff --git a/actions/missing.php b/actions/missing.php new file mode 100644 index 000000000..f18bad65a --- /dev/null +++ b/actions/missing.php @@ -0,0 +1,54 @@ +<?php
+require_once(dirname(dirname(__FILE__)).'/models/model.php');
+
+global $CONFIG;
+set_context('openid');
+$code = get_input('openid_code');
+$name = trim(get_input('name'));
+$email = trim(get_input('email'));
+$error = false;
+if (!$name) {
+ register_error(elgg_echo("openid_client:missing_name_error"));
+ $error = true;
+}
+if (!$email || !validate_email_address($email)) {
+ register_error(elgg_echo("openid_client:invalid_email_error"));
+ $error = true;
+}
+
+if (empty($code) || !($details = openid_client_get_invitation($code))) {
+ register_error(elgg_echo("openid_client:invalid_code_error"));
+ $error = true;
+}
+
+if (!$error) {
+ // looks good
+
+ if ($code{0} == 'a') {
+ // need to confirm first
+ $details->email = $email;
+ $details->name = $name;
+ openid_client_send_activate_confirmation_message($details);
+ system_message(sprintf(elgg_echo("openid_client:activate_confirmation"),$email));
+ } elseif ($code{0} == 'n') {
+ //activate and login
+ $user = get_user($details->owner);
+ $user->email = $email;
+ $user->name = $name;
+ $user->active = 'yes';
+ $user->save();
+ system_message(sprintf(elgg_echo("openid_client:created_openid_account"),$email, $name));
+ login($user);
+ }
+ forward();
+} elseif ($details) {
+ // regenerate the form
+ $user = get_user($details->owner);
+ $openid_url = $user->alias;
+ $email_confirmation = openid_client_check_email_confirmation($openid_url);
+ $body = openid_client_generate_missing_data_form($openid_url,$email,$fullname,$email_confirmation,$code);
+ page_draw(elgg_echo('openid_client:information_title'),$body);
+} else {
+ // bad code - not much to do but inform user
+ forward();
+}
diff --git a/actions/sync.php b/actions/sync.php new file mode 100644 index 000000000..3f93df9df --- /dev/null +++ b/actions/sync.php @@ -0,0 +1,57 @@ +<?php
+require_once(dirname(dirname(__FILE__)).'/models/model.php');
+
+set_context('openid');
+global $CONFIG;
+
+if (isloggedin()) {
+
+ $userid = get_loggedin_userid();
+ $user = get_user($userid);
+ $namechange = get_input('namechange');
+ $emailchange = get_input('emailchange');
+ $nosync = get_input('nosync');
+
+ if ($namechange) {
+ $name = get_input('new_name');
+ $user->name = $name;
+ system_message(sprintf(elgg_echo("openid_client:name_updated"),$name));
+ }
+
+ if ($emailchange) {
+ $i_code = get_input('i_code');
+ if (empty($i_code)) {
+ $new_email = get_input('new_email');
+ // this is an email address change request from a yellow OpenID, so the
+ // email address change must be confirmed with an email message
+ if (get_user_by_email($email)) {
+ register_error(sprintf(elgg_echo("openid_client:email_in_use"),$email));
+ } else {
+ $details = openid_client_create_invitation('c',$user->username,$userid,$new_email,$user->name);
+ openid_client_send_change_confirmation_message($details);
+ system_message(sprintf(elgg_echo("openid_client:change_confirmation"), $email));
+ }
+ } elseif (!($details = openid_client_get_invitation($i_code))) {
+ register_error(elgg_echo("openid_client:invalid_code_error"));
+ } else {
+ // this is an email address change request from a green OpenID, so the
+ // email address change does not need to be confirmed
+
+ $email = $details->email;
+ $ident = $details->owner;
+ if (get_user_by_email($email)) {
+ register_error(sprintf(elgg_echo("openid_client:email_in_use"),$email));
+ } else {
+ $user->email;
+ system_message(sprintf(elgg_echo("openid_client:email_updated"),$email));
+ }
+ }
+ }
+
+ if ($nosync) {
+ $store = new OpenID_ElggStore();
+ $store->addNoSyncStatus($user);
+ }
+}
+
+forward();
|