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 /pages | |
download | elgg-d9bf22a0e29c2a70049443a0ae8521a2c0492c8b.tar.gz elgg-d9bf22a0e29c2a70049443a0ae8521a2c0492c8b.tar.bz2 |
initial commit for git repository
Diffstat (limited to 'pages')
-rw-r--r-- | pages/admin.php | 27 | ||||
-rw-r--r-- | pages/confirm.php | 46 | ||||
-rw-r--r-- | pages/reset.php | 12 | ||||
-rw-r--r-- | pages/sso.php | 52 |
4 files changed, 137 insertions, 0 deletions
diff --git a/pages/admin.php b/pages/admin.php new file mode 100644 index 000000000..9390e5b00 --- /dev/null +++ b/pages/admin.php @@ -0,0 +1,27 @@ +<?php
+require_once(dirname(dirname(__FILE__)).'/models/model.php');
+
+// let admins configure the OpenID client
+
+admin_gatekeeper();
+
+set_context('admin');
+
+$title = elgg_echo('openid_client:admin_title');
+
+$content = elgg_view_title($title);
+
+$content .= elgg_view("openid_client/forms/admin",
+ array(
+ 'default_server' => get_plugin_setting('default_server','openid_client'),
+ 'always_sync' => get_plugin_setting('always_sync','openid_client'),
+ 'sso' => get_plugin_setting('sso','openid_client'),
+ 'greenlist' => get_plugin_setting('greenlist','openid_client'),
+ 'yellowlist' => get_plugin_setting('yellowlist','openid_client'),
+ 'redlist' => get_plugin_setting('redlist','openid_client'),
+ ));
+
+
+$body = elgg_view_layout("two_column_left_sidebar", '', $content);
+
+page_draw($title, $body);
diff --git a/pages/confirm.php b/pages/confirm.php new file mode 100644 index 000000000..1f2668620 --- /dev/null +++ b/pages/confirm.php @@ -0,0 +1,46 @@ +<?php
+
+// This used to be an action, but as it is sent in an email message
+// with unknown response time, it cannot have an action time stamp
+// and so is now just a page
+
+require_once(dirname(dirname(__FILE__)).'/models/model.php');
+
+set_context('openid');
+$code = get_input('code');
+if (empty($code)) {
+ register_error(elgg_echo("openid_client:missing_confirmation_code"));
+} elseif ($code{0} == 'a') {
+ // request to activate an account
+ if (!$details = openid_client_get_invitation($code)) {
+ register_error(elgg_echo("openid_client:invalid_code_error"));
+ } else {
+ // OK, everything seems to be in order, so activate this user
+ $user = get_user($details->new_owner);
+ $user->email = $details->email;
+ $user->name = $details->name;
+ $user->active = 'yes';
+ $user->save();
+ system_message(sprintf(elgg_echo("openid_client:account_created"), $details->username));
+ openid_client_remove_invitation($code);
+ }
+
+} elseif ($code{0} == 'c') {
+ // request to change an email address
+ if (!$details = openid_client_get_invitation($code)) {
+ register_error(elgg_echo("openid_client:invalid_code_error"));
+ } else {
+ // OK, everything seems to be in order, so change the email address
+ $user = get_user($details->new_owner);
+ $user->email = $details->email;
+ $user->save();
+ system_message(sprintf(elgg_echo('openid_client:email_changed'),$details->email));
+ openid_client_remove_invitation($code);
+ }
+}
+
+if(isset($body) && $body) {
+ page_draw(elgg_echo('openid_client:confirmation_title'),$body);
+} else {
+ forward();
+}
diff --git a/pages/reset.php b/pages/reset.php new file mode 100644 index 000000000..aa85f3386 --- /dev/null +++ b/pages/reset.php @@ -0,0 +1,12 @@ +<?php
+require_once(dirname(dirname(__FILE__)).'/models/model.php');
+
+admin_gatekeeper();
+
+set_context('openid');
+
+$store = new OpenID_ElggStore();
+$store->resetAssociations();
+$store->resetNonces();
+
+print "OpenID store reset";
diff --git a/pages/sso.php b/pages/sso.php new file mode 100644 index 000000000..a0098ce72 --- /dev/null +++ b/pages/sso.php @@ -0,0 +1,52 @@ +<?php
+require_once(dirname(dirname(__FILE__)).'/models/model.php');
+global $CONFIG;
+
+$sso = get_plugin_setting('sso','openid_client');
+if (!isloggedin() && ($sso == 'yes')) {
+ openid_client_handle_login();
+} else {
+ forward();
+}
+exit;
+// $url = $CONFIG->wwwroot.'action/openid_client/login';
+// $ts = time();
+// $token = generate_action_token($ts);
+// $fields = array(
+// '__elgg_token'=>$token,
+// '__elgg_ts'=>$ts,
+// 'passthru_url'=>'',
+// 'externalservice'=>'',
+// 'username'=>urlencode($openid_url),
+// );
+//
+// //url-ify the data for the POST
+// foreach($fields as $key=>$value) {
+// $fields_string .= $key.'='.$value.'&';
+// }
+// rtrim($fields_string,'&');
+//
+// //open connection
+// $ch = curl_init();
+//
+// //set the url, number of POST vars, POST data
+// curl_setopt($ch,CURLOPT_URL,$url);
+// //curl_setopt($ch,CURLOPT_POST,count($fields));
+// curl_setopt($ch,CURLOPT_POST,true);
+// curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
+// curl_setopt($ch,CURLOPT_RETURNTRANSFER,false);
+// curl_setopt($ch,CURLOPT_FAILONERROR,true);
+// //curl_setopt($ch,CURLOPT_HEADER, true);
+// curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
+//
+// //execute post
+// curl_exec($ch);
+//
+// //print_r (curl_getinfo($ch));
+//
+// //print $result;
+//
+// //close connection
+// curl_close($ch);
+
+?>
\ No newline at end of file |