diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index 7771802bc98bd051261fac91c6dc92f4d7f27a6a..618602df317dc89a0f9a3204b4e94ab585c0813b 100644 --- a/include/class.dynamic_forms.php +++ b/include/class.dynamic_forms.php @@ -336,7 +336,7 @@ class DynamicFormEntry extends VerySimpleModel { function getAnswer($name) { foreach ($this->getAnswers() as $ans) if ($ans->getField()->get('name') == $name) - return $ans->getValue(); + return $ans; return null; } function setAnswer($name, $value, $id=false) { diff --git a/include/class.forms.php b/include/class.forms.php index 356c504da90a38d2357975e5777a310c5e3d3ee1..c815c978ffe79e617aa207d77bb49de342e1300b 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -514,6 +514,10 @@ class PhoneField extends FormField { } } + function to_database($value) { + return preg_replace('/[()+. -]/', '', $value); + } + function toString($value) { list($phone, $ext) = explode("X", $value, 2); $phone=Format::phone($phone); diff --git a/include/class.ticket.php b/include/class.ticket.php index 8afb80f38fc10098fc729dff987152221d1e7508..fc6499529e616f9f1eea0557a916d64e93e92299 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -303,17 +303,17 @@ class Ticket { } function getPhone() { - list($phone, $ext) = explode(" ", $this->_answers['phone'], 2); + list($phone, $ext) = $this->getPhoneNumber(); return $phone; } function getPhoneExt() { - list($phone, $ext) = explode(" ", $this->_answers['phone'], 2); + list($phone, $ext) = $this->getPhoneNumber(); return $ext; } function getPhoneNumber() { - return $this->_answers['phone']; + return (string)$this->getOwner()->getPhoneNumber(); } function getSource() { @@ -1891,8 +1891,7 @@ class Ticket { // fields into local scope for filtering and banning purposes $user_form = UserForm::getInstance(); $user_info = $user_form->getClean(); - if ($user_form->isValid()) - $vars += $user_info; + $vars += $user_info; //Check for 403 if ($vars['email'] && Validator::is_email($vars['email'])) { diff --git a/include/class.user.php b/include/class.user.php index 3366bdeb4ef42b2196578234c328fdcbf5808428..b1aae2e7c993cb56e217444555ff0da26ee5c7dd 100644 --- a/include/class.user.php +++ b/include/class.user.php @@ -79,11 +79,14 @@ class User extends UserModel { // Try and lookup by email address $user = User::lookup(array('emails__address'=>$data['email'])); if (!$user) { - $user = User::create(array('name'=>$data['name'], + $user = User::create(array( + 'name'=>$data['name'], + 'created'=>new SqlFunction('NOW'), + 'updated'=>new SqlFunction('NOW'), 'default_email'=> UserEmail::create(array('address'=>$data['email'])) )); - $user->save(); + $user->save(true); $user->emails->add($user->default_email); // Attach initial custom fields @@ -106,6 +109,12 @@ class User extends UserModel { return $this->name; } + function getPhoneNumber() { + foreach ($this->getDynamicData() as $e) + if ($a = $e->getAnswer('phone')) + return $a; + } + function getName() { return new PersonsName($this->name); } @@ -120,8 +129,8 @@ class User extends UserModel { $tag = strtolower($tag); foreach ($this->getDynamicData() as $e) - if ($e->getAnswer($tag)) - return $e; + if ($a = $e->getAnswer($tag)) + return $a; } function getDynamicData() { @@ -150,6 +159,8 @@ class User extends UserModel { $this->name = $parts[1].' '.$parts[0].' '.$parts[2]; break; } + if (count($this->dirty)) + $this->set('updated', new SqlFunction('NOW')); return parent::save($refetch); } } diff --git a/include/staff/ticket-view.inc.php b/include/staff/ticket-view.inc.php index 78714bbd350ecec85281830bb579e6d9ce6a02c8..c4ff817014099a07c15d28afb8d34bfa36010073 100644 --- a/include/staff/ticket-view.inc.php +++ b/include/staff/ticket-view.inc.php @@ -182,6 +182,10 @@ if($ticket->isOverdue()) <?php echo $ticket->getEmail(); ?> </td> </tr> + <tr> + <th>Phone:</th> + <td><?php echo $ticket->getPhoneNumber(); ?></td> + </tr> <tr> <th>Source:</th> <td><?php