From 3323e0138de2e9f88019b1b00b4b035856f1d8b2 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Mon, 5 Jan 2015 15:37:45 -0600 Subject: [PATCH] oops: Fix a few small issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix missing attachments join for Category (fixes #1654) * Fix crash on user account registration * Fix save button on user account (fixes #1655) — regression from bebc2d7 --- include/class.attachment.php | 7 +++++++ include/class.client.php | 8 +++----- include/class.faq.php | 5 +++-- include/class.user.php | 7 ++++--- include/staff/templates/user-account.tmpl.php | 1 + 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/include/class.attachment.php b/include/class.attachment.php index 5ada65726..005b82156 100644 --- a/include/class.attachment.php +++ b/include/class.attachment.php @@ -104,6 +104,13 @@ class AttachmentModel extends VerySimpleModel { ); } +class GenericAttachment extends VerySimpleModel { + static $meta = array( + 'table' => ATTACHMENT_TABLE, + 'pk' => array('id'), + ); +} + class GenericAttachments { var $id; diff --git a/include/class.client.php b/include/class.client.php index 39b8241c9..6ad2efc03 100644 --- a/include/class.client.php +++ b/include/class.client.php @@ -319,8 +319,6 @@ class EndUser extends BaseAuthenticatedUser { class ClientAccount extends UserAccount { - var $_extra; - function checkPassword($password, $autoupdate=true) { /*bcrypt based password match*/ @@ -395,12 +393,12 @@ class ClientAccount extends UserAccount { } } - if (!$vars['timezone_id']) - $errors['timezone_id']=__('Time zone selection is required'); + // Timezone selection is not required. System default is a valid + // fallback if ($errors) return false; - $this->set('timezone_id', $vars['timezone_id']); + $this->set('timezone', $vars['timezone']); $this->set('dst', isset($vars['dst']) ? 1 : 0); // Change language $this->set('lang', $vars['lang'] ?: null); diff --git a/include/class.faq.php b/include/class.faq.php index 9f4b30305..34e56f93e 100644 --- a/include/class.faq.php +++ b/include/class.faq.php @@ -29,14 +29,15 @@ class FAQ extends VerySimpleModel { 'constraint' => array( 'category_id' => 'Category.category_id' ), - ), /* XXX: Not yet implemented + ), 'attachments' => array( 'constraint' => array( "'F'" => 'GenericAttachment.type', 'faq_id' => 'GenericAttachment.object_id', ), 'list' => true, - ), */ + 'null' => true, + ), 'topics' => array( 'constraint' => array( 'faq_id' => 'FaqTopic.faq_id' diff --git a/include/class.user.php b/include/class.user.php index 001000437..d12bd009e 100644 --- a/include/class.user.php +++ b/include/class.user.php @@ -788,6 +788,7 @@ class UserAccountModel extends VerySimpleModel { ); var $_status; + var $_extra; function __construct() { call_user_func_array(array('parent', '__construct'), func_get_args()); @@ -860,7 +861,7 @@ class UserAccountModel extends VerySimpleModel { function getExtraAttr($attr=false, $default=null) { if (!isset($this->_extra)) - $this->_extra = JsonDataParser::decode($this->extra); + $this->_extra = JsonDataParser::decode($this->get('extra', '')); return $attr ? (@$this->_extra[$attr] ?: $default) : $this->_extra; } @@ -984,8 +985,8 @@ class UserAccount extends UserAccountModel { // TODO: Make sure the username is unique - if (!$vars['timezone']) - $errors['timezone'] = __('Time zone selection is required'); + // Timezone selection is not required. System default is a valid + // fallback // Changing password? if ($vars['passwd1'] || $vars['passwd2']) { diff --git a/include/staff/templates/user-account.tmpl.php b/include/staff/templates/user-account.tmpl.php index 82674810b..6319aeb96 100644 --- a/include/staff/templates/user-account.tmpl.php +++ b/include/staff/templates/user-account.tmpl.php @@ -15,6 +15,7 @@ if ($info['error']) { } elseif ($info['msg']) { echo sprintf('<p id="msg_notice">%s</p>', $info['msg']); } ?> +<form method="post" class="user" action="#users/<?php echo $user->getId(); ?>/manage" > <ul class="tabs" id="user-account-tabs"> <li <?php echo !$access? 'class="active"' : ''; ?>><a href="#user-account" ><i class="icon-user"></i> <?php echo __('User Information'); ?></a></li> -- GitLab