summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlezvous.ca>2008-06-22 12:16:07 -0400
committerEvan Prodromou <evan@controlezvous.ca>2008-06-22 12:16:07 -0400
commit4fd1f6246ddc272192b293a5e5d5cb9dbd3e1cdf (patch)
tree3bd109be8ace3a4c227a5f90fa7e5b0e7ebd7cd9 /actions
parent403039510c5cc95010dacb773120779da4c43fe8 (diff)
correctly use Confirm_address
darcs-hash:20080622161607-34904-d8e042b80fe6acd3cb6ad763216a0b1817752cac.gz
Diffstat (limited to 'actions')
-rw-r--r--actions/confirmaddress.php40
-rw-r--r--actions/profilesettings.php5
-rw-r--r--actions/register.php5
3 files changed, 31 insertions, 19 deletions
diff --git a/actions/confirmaddress.php b/actions/confirmaddress.php
index 72b42c2a7..76f79da05 100644
--- a/actions/confirmaddress.php
+++ b/actions/confirmaddress.php
@@ -33,27 +33,37 @@ class ConfirmemailAction extends Action {
$this->client_error(_t('No confirmation code.'));
return;
}
- $confirm_email = Confirm_email::staticGet('code', $code);
- if (!$confirm_email) {
+ $confirm = Confirm_address::staticGet('code', $code);
+ if (!$confirm) {
$this->client_error(_t('Confirmation code not found.'));
return;
}
$cur = common_current_user();
- if ($cur->id != $confirm_email->user_id) {
+ if ($cur->id != $confirm->user_id) {
$this->client_error(_t('That confirmation code is not for you!'));
return;
}
- if ($cur->email == $confirm_email->email) {
- $this->client_error(_t('That email address is already confirmed.'));
- return;
- }
+ $type = $confirm->address_type;
+ if (!in_array($type, array('email', 'jabber', 'sms'))) {
+ $this->server_error(_t('Unrecognized address type ') . $type);
+ return;
+ }
+ if ($cur->$type == $confirm->address) {
+ $this->client_error(_t('That address has already been confirmed.'));
+ return;
+ }
$cur->query('BEGIN');
$orig_user = clone($cur);
+
+ $cur->$type = $confirm->address;
+
+ if ($type == 'sms') {
+ $cur->carrier = ($confirm->address_extra)+0;
+ }
- $cur->email = $confirm_email->email;
- $result = $cur->updateKeys($orig_user);
+ $result = $cur->updateKeys($orig_user);
if (!$result) {
common_log_db_error($cur, 'UPDATE', __FILE__);
@@ -61,20 +71,20 @@ class ConfirmemailAction extends Action {
return;
}
- $result = $confirm_email->delete();
+ $result = $confirm->delete();
if (!$result) {
- common_log_db_error($confirm_email, 'DELETE', __FILE__);
+ common_log_db_error($confirm, 'DELETE', __FILE__);
$this->server_error(_t('Couldn\'t delete email confirmation.'));
return;
}
$cur->query('COMMIT');
-
- common_show_header(_t('Confirm E-mail Address'));
+
+ common_show_header(_t('Confirm Address'));
common_element('p', NULL,
- _t('The email address "') . $cur->email .
+ _t('The address "') . $cur->email .
_t('" has been confirmed for your account.'));
- common_show_footer(_t('Confirm E-mail Address'));
+ common_show_footer();
}
}
diff --git a/actions/profilesettings.php b/actions/profilesettings.php
index 5f157e3fe..673258f82 100644
--- a/actions/profilesettings.php
+++ b/actions/profilesettings.php
@@ -138,10 +138,10 @@ class ProfilesettingsAction extends SettingsAction {
# We don't update email directly; it gets done by confirmemail
- $confirm = new Confirm_email();
$confirm->code = common_good_rand(16);
$confirm->user_id = $user->id;
- $confirm->email = $email;
+ $confirm->address = $email;
+ $confirm->address_type = 'email';
$result = $confirm->insert();
@@ -150,6 +150,7 @@ class ProfilesettingsAction extends SettingsAction {
common_server_error(_t('Couldnt confirm email.'));
return FALSE;
}
+
# XXX: try not to do this in the middle of a transaction
mail_confirm_address($confirm->code,
diff --git a/actions/register.php b/actions/register.php
index 2bb4f12f0..862ca2a78 100644
--- a/actions/register.php
+++ b/actions/register.php
@@ -120,10 +120,11 @@ class RegisterAction extends Action {
if ($email) {
- $confirm = new Confirm_email();
+ $confirm = new Confirm_address();
$confirm->code = common_good_rand(16);
$confirm->user_id = $user->id;
- $confirm->email = $email;
+ $confirm->address = $email;
+ $confirm->address_type = 'email';
$result = $confirm->insert();
if (!$result) {