diff --git a/account.php b/account.php index acab3bed62343c4ce5d0cc4e8f5247ec79af2e8b..2e081c7354bc828faecc9839d494f0b28258990e 100644 --- a/account.php +++ b/account.php @@ -27,9 +27,18 @@ if (!$cfg || !$cfg->isClientRegistrationEnabled()) { } elseif ($thisclient) { - $inc = isset($_GET['confirmed']) - ? 'registration.confirmed.inc.php' : 'profile.inc.php'; - $user = User::lookup($thisclient->getId()); + // Guest registering for an account + if ($thisclient->isGuest()) { + foreach ($thisclient->getForms() as $f) + if ($f->get('type') == 'U') + $user_form = $f; + } + // Existing client (with an account) updating profile + else { + $user = User::lookup($thisclient->getId()); + $inc = isset($_GET['confirmed']) + ? 'registration.confirmed.inc.php' : 'profile.inc.php'; + } } if ($user && $_POST) { @@ -49,8 +58,17 @@ elseif ($_POST) { elseif ($_POST['passwd2'] != $_POST['passwd1']) $errors['passwd1'] = 'Passwords do not match'; - elseif (!($user=User::fromForm($user_form))) + // XXX: The email will always be in use already if a guest is logged in + // and is registering for an account. Instead, + elseif (!($user = $thisclient ?: User::fromForm($user_form))) $errors['err'] = 'Unable to register account. See messages below'; + elseif (($addr = $user_form->getField('email')->getClean()) + && ClientAccount::lookupByUsername($addr)) { + $user_form->getField('email')->addError( + 'Email already registered. Would you like to <a href="login.php?e=' + .urlencode($addr).'" style="color:inherit"><strong>sign in</strong></a>?'); + $errors['err'] = 'Unable to register account. See messages below'; + } else { if (!($acct = ClientAccount::createForUser($user))) $errors['err'] = 'Internal error. Unable to create new account'; @@ -66,7 +84,7 @@ elseif ($_POST) { } } - if ($errors && $user) + if ($errors && $user && $user != $thisclient) $user->delete(); } diff --git a/assets/default/css/theme.css b/assets/default/css/theme.css index 195460e49c2f317d35be5151f7a54f86a4abb58b..d1934d7925135d76b89cbd0d819643f49a132361 100644 --- a/assets/default/css/theme.css +++ b/assets/default/css/theme.css @@ -219,6 +219,7 @@ h2 { border: 1px solid #a00; background: url('../images/icons/error.png') 10px 50% no-repeat #fff0f0; } +#msg_info { margin: 0; padding: 5px; margin-bottom: 10px; color: #3a87ad; border: 1px solid #bce8f1; background-color: #d9edf7; } .warning { background: #ffc; font-style: italic; diff --git a/include/client/view.inc.php b/include/client/view.inc.php index 469740f6c7e60d1c434d8b1d9709c4c27fcfe89e..0ff0dbdea738ab89eaa37a376dc1eff01d280115 100644 --- a/include/client/view.inc.php +++ b/include/client/view.inc.php @@ -8,7 +8,18 @@ $dept = $ticket->getDept(); if(!$dept || !$dept->isPublic()) $dept = $cfg->getDefaultDept(); -?> +if ($thisclient && $thisclient->isGuest() + && $cfg->isClientRegistrationEnabled()) { ?> + +<div id="msg_info"> + <i class="icon-compass icon-2x pull-left"></i> + <strong>Looking for your other tickets?</strong></br> + <a href="account.php?do=create">Register for an account</a> + or <a href="login.php">sign in</a> + for the best experience on our help desk.</div> + +<?php } ?> + <table width="800" cellpadding="1" cellspacing="0" border="0" id="ticketInfo"> <tr> <td colspan="2" width="100%">