aboutsummaryrefslogtreecommitdiff
path: root/mod/twitter_api/actions
diff options
context:
space:
mode:
authorBrett Profitt <brett.profitt@gmail.com>2011-08-25 10:00:38 -0700
committerBrett Profitt <brett.profitt@gmail.com>2011-08-25 10:00:38 -0700
commitdccc333c765bb28da55b4a55d9c916acdb88413a (patch)
treebdd26a0b4cd85241a19b7fcb2c0770f0ac3eb9f0 /mod/twitter_api/actions
parentec7b94a64aef23b85866ecdac8e8acc712d29bb6 (diff)
parent003cb81c7888f4d2fd763e5814027c6f8d71186f (diff)
downloadelgg-dccc333c765bb28da55b4a55d9c916acdb88413a.tar.gz
elgg-dccc333c765bb28da55b4a55d9c916acdb88413a.tar.bz2
Merge branch 'master' of github.com:brettp/Elgg
Diffstat (limited to 'mod/twitter_api/actions')
-rw-r--r--mod/twitter_api/actions/twitter_api/interstitial_settings.php53
1 files changed, 53 insertions, 0 deletions
diff --git a/mod/twitter_api/actions/twitter_api/interstitial_settings.php b/mod/twitter_api/actions/twitter_api/interstitial_settings.php
new file mode 100644
index 000000000..5f742efd8
--- /dev/null
+++ b/mod/twitter_api/actions/twitter_api/interstitial_settings.php
@@ -0,0 +1,53 @@
+<?php
+/**
+ * Save settings for first time logins with twitter
+ */
+elgg_make_sticky_form('twitter_api_interstitial');
+
+$display_name = get_input('display_name');
+$email = get_input('email');
+$password_1 = get_input('password_1');
+$password_2 = get_input('password_2');
+
+if (!$display_name) {
+ register_error(elgg_echo('twitter_api:interstitial:no_display_name'));
+ forward(REFERER);
+}
+
+if ($email && !is_email_address($email)) {
+ register_error(elgg_echo('twitter_api:interstitial:invalid_email'));
+ forward(REFERER);
+}
+
+$existing_user = get_user_by_email($email);
+if ($email && $existing_user) {
+ register_error(elgg_echo('twitter_api:interstitial:existing_email'));
+ forward(REFERER);
+}
+
+if ($password_1 && !($password_1 == $password_2)) {
+ register_error(elgg_echo('twitter_api:interstitial:password_mismatch'));
+ forward(REFERER);
+}
+
+$user = elgg_get_logged_in_user_entity();
+$user->name = $display_name;
+
+if ($email) {
+ $user->email = $email;
+}
+
+if ($password_1) {
+ $user->salt = generate_random_cleartext_password();
+ $user->password = generate_user_password($user, $password_1);
+}
+
+if (!$user->save()) {
+ register_error(elgg_echo('twitter_api:interstitial:cannot_save'));
+ forward(REFERER);
+}
+
+elgg_clear_sticky_form('twitter_api_interstitial');
+
+system_message(elgg_echo('twitter_api:interstitial:saved'));
+forward('/'); \ No newline at end of file