From c6fbc330c9694907fe95b5ee90e1d0691b16860d Mon Sep 17 00:00:00 2001 From: Todd Burry Date: Mon, 7 Nov 2011 15:55:11 -0500 Subject: [PATCH] Fixed some bugs with connecting. Conflicts: applications/dashboard/js/entry.js --- .../controllers/class.entrycontroller.php | 11 +++++++-- applications/dashboard/js/entry.js | 2 +- .../dashboard/locale/en-CA/definitions.php | 1 + .../dashboard/models/class.usermodel.php | 24 ++++++++++++------- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/applications/dashboard/controllers/class.entrycontroller.php b/applications/dashboard/controllers/class.entrycontroller.php index e0495462e5b..7ba859ef723 100755 --- a/applications/dashboard/controllers/class.entrycontroller.php +++ b/applications/dashboard/controllers/class.entrycontroller.php @@ -338,8 +338,15 @@ public function Connect($Method) { // The user is already connected. $this->Form->SetFormValue('UserID', $UserID); + $User = Gdn::UserModel()->GetID($UserID, DATASET_TYPE_ARRAY); $Data = $this->Form->FormValues(); + // Don't overwrite the user photo if the user uploaded a new one. + $Photo = GetValue('Photo', $User); + if (GetValue('Photo', $Data) && $Photo && !StringBeginsWith($Photo, 'http')) { + unset($Data['Photo']); + } + // Synchronize the user's data. $UserModel->Save($Data, array('NoConfirmEmail' => TRUE)); @@ -399,7 +406,7 @@ public function Connect($Method) { $ExistingUsers); } - if (!isset($NameFound)) { + if (!isset($NameFound) && !$IsPostBack) { $this->Form->SetFormValue('ConnectName', $this->Form->GetFormValue('Name')); } @@ -500,7 +507,7 @@ public function Connect($Method) { $User['Password'] = RandomString(50); // some password is required $User['HashMethod'] = 'Random'; - $UserID = $UserModel->Register($User, array('CheckCaptcha' => FALSE)); + $UserID = $UserModel->Register($User, array('CheckCaptcha' => FALSE), array('NoConfirmEmail' => TRUE)); $User['UserID'] = $UserID; $this->Form->SetValidationResults($UserModel->ValidationResults()); diff --git a/applications/dashboard/js/entry.js b/applications/dashboard/js/entry.js index be3f4f22f9e..c5ec337e4d5 100755 --- a/applications/dashboard/js/entry.js +++ b/applications/dashboard/js/entry.js @@ -1,7 +1,7 @@ // This file contains javascript that is specific to the dashboard/entry controller. jQuery(document).ready(function($) { // Check to see if the selected email is valid - $('#Register input[name=$Email], body.register input[name$=Email]').blur(function() { + $('#Register input[name$=Email], body.register input[name$=Email]').blur(function() { var email = $(this).val(); if (email != '') { var checkUrl = gdn.url('/dashboard/user/emailavailable/'+encodeURIComponent(email)+'/x'); diff --git a/applications/dashboard/locale/en-CA/definitions.php b/applications/dashboard/locale/en-CA/definitions.php index 0ebd6ec5908..7b947dbc74c 100755 --- a/applications/dashboard/locale/en-CA/definitions.php +++ b/applications/dashboard/locale/en-CA/definitions.php @@ -170,5 +170,6 @@ function Plural($Number, $Singular, $Plural) { $Definition['Warning: This is for advanced users.'] = 'Warning: This is for advanced users and requires that you make additional changes to your web server. This is usually only available if you have dedicated or vps hosting. Do not attempt this if you do not know what you are doing.'; $Definition['Activity.Delete'] = '×'; $Definition['Draft.Delete'] = '×'; +$Definition['ConnectName'] = 'Username'; // TODO: PROVIDE TRANSLATIONS FOR ALL CONFIGURATION SETTINGS THAT ARE EDITABLE ON ADMIN FORMS (ie. Vanilla.Comments.MaxLength, etc). \ No newline at end of file diff --git a/applications/dashboard/models/class.usermodel.php b/applications/dashboard/models/class.usermodel.php index d709404e763..4833f08785c 100755 --- a/applications/dashboard/models/class.usermodel.php +++ b/applications/dashboard/models/class.usermodel.php @@ -823,17 +823,23 @@ public function Save($FormPostValues, $Settings = FALSE) { if (isset($Fields['Email']) && $UserID == Gdn::Session()->UserID && $Fields['Email'] != Gdn::Session()->User->Email && !Gdn::Session()->CheckPermission('Garden.Users.Edit')) { $User = Gdn::Session()->User; $Attributes = Gdn::Session()->User->Attributes; - $EmailKey = TouchValue('EmailKey', $Attributes, RandomString(8)); + + $ConfirmEmailRoleID = C('Garden.Registration.ConfirmEmailRole'); + if (RoleModel::Roles($ConfirmEmailRoleID)) { + // The confirm email role is set and it exists so go ahead with the email confirmation. + $EmailKey = TouchValue('EmailKey', $Attributes, RandomString(8)); + + if ($RoleIDs) + $ConfirmedEmailRoles = $RoleIDs; + else + $ConfirmedEmailRoles = ConsolidateArrayValuesByKey($this->GetRoles($UserID), 'RoleID'); + $Attributes['ConfirmedEmailRoles'] = $ConfirmedEmailRoles; - if ($RoleIDs) - $ConfirmedEmailRoles = $RoleIDs; - else - $ConfirmedEmailRoles = ConsolidateArrayValuesByKey($this->GetRoles($UserID), 'RoleID'); - $Attributes['ConfirmedEmailRoles'] = $ConfirmedEmailRoles; + $RoleIDs = (array)C('Garden.Registration.ConfirmEmailRole'); - $RoleIDs = (array)C('Garden.Registration.ConfirmEmailRole'); - $SaveRoles = TRUE; - $Fields['Attributes'] = serialize($Attributes); + $SaveRoles = TRUE; + $Fields['Attributes'] = serialize($Attributes); + } } }