Skip to content

Commit

Permalink
Fixed some bugs with connecting.
Browse files Browse the repository at this point in the history
Conflicts:

	applications/dashboard/js/entry.js
  • Loading branch information
tburry committed Nov 7, 2011
1 parent e3d7ec1 commit c6fbc33
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
11 changes: 9 additions & 2 deletions applications/dashboard/controllers/class.entrycontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -399,7 +406,7 @@ public function Connect($Method) {
$ExistingUsers);
}

if (!isset($NameFound)) {
if (!isset($NameFound) && !$IsPostBack) {
$this->Form->SetFormValue('ConnectName', $this->Form->GetFormValue('Name'));
}

Expand Down Expand Up @@ -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());

Expand Down
2 changes: 1 addition & 1 deletion applications/dashboard/js/entry.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
1 change: 1 addition & 0 deletions applications/dashboard/locale/en-CA/definitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,5 +170,6 @@ function Plural($Number, $Singular, $Plural) {
$Definition['Warning: This is for advanced users.'] = '<b>Warning</b>: 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).
24 changes: 15 additions & 9 deletions applications/dashboard/models/class.usermodel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit c6fbc33

Please sign in to comment.