From 9190827111d7363eaa23be490563dfa5e85703ab Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Fri, 24 Jan 2014 20:07:38 +0000 Subject: [PATCH] forms: Fix ticket submission if already logged in If a client is already logged into the client portal and attempts to submit a new ticket, the ticket will be rejected if the contact-information form has a required field other than `name` and `email`. This patch fixes `class Client` so that the user-id is fetched from the database and made available via the `::getUserId()` method. This was already corrected in the `develop-next` branch for v1.8.1. The `uid` field is passed into `Ticket::create()` so the user form validation is bypassed. This commit should be ignored when merged into the 1.8.1 codebase. --- include/class.client.php | 10 ++++++++-- open.php | 3 +-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/class.client.php b/include/class.client.php index 7464b841c..b5d062c95 100644 --- a/include/class.client.php +++ b/include/class.client.php @@ -27,6 +27,7 @@ class Client { var $_answers; var $ticket_id; + var $user_id; var $ticketID; var $ht; @@ -42,7 +43,7 @@ class Client { if(!$id && !($id=$this->getId())) return false; - $sql='SELECT ticket.ticket_id, ticketID, email.address as email ' + $sql='SELECT ticket.ticket_id, ticketID, email.address as email, user.id as user_id ' .' FROM '.TICKET_TABLE.' ticket ' .' LEFT JOIN '.USER_TABLE.' user ON user.id = ticket.user_id' .' LEFT JOIN '.USER_EMAIL_TABLE.' email ON user.id = email.user_id' @@ -59,7 +60,8 @@ class Client { $this->ticket_id = $this->ht['ticket_id']; $this->ticketID = $this->ht['ticketID']; - $user = User::lookup(array('emails__address'=>$this->ht['email'])); + $user = User::lookup($this->ht['user_id']); + $this->user_id = $this->ht['user_id']; $this->fullname = $user->getFullName(); $this->username = $this->ht['email']; @@ -90,6 +92,10 @@ class Client { return $this->id; } + function getUserId() { + return $this->user_id; + } + function getEmail() { return $this->email; } diff --git a/open.php b/open.php index 706c9ccd4..a731e2132 100644 --- a/open.php +++ b/open.php @@ -21,8 +21,7 @@ if($_POST): $vars = $_POST; $vars['deptId']=$vars['emailId']=0; //Just Making sure we don't accept crap...only topicId is expected. if($thisclient) { - $vars['name']=$thisclient->getName(); - $vars['email']=$thisclient->getEmail(); + $vars['uid'] = $thisclient->getUserId(); } elseif($cfg->isCaptchaEnabled()) { if(!$_POST['captcha']) $errors['captcha']='Enter text shown on the image'; -- GitLab