From cd1935ea20cc2284a5e9ad50bb5dc1a009043961 Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@osticket.com> Date: Tue, 2 Dec 2014 01:34:24 +0000 Subject: [PATCH] bug: Fix installer initial data load --- include/class.dept.php | 10 ++++++++-- include/class.group.php | 9 +++++++++ include/class.i18n.php | 4 ++-- include/i18n/en_US/department.yaml | 18 +++++++++--------- include/i18n/en_US/group.yaml | 12 ++++++------ 5 files changed, 34 insertions(+), 19 deletions(-) diff --git a/include/class.dept.php b/include/class.dept.php index d6d1fd924..b8aaf8b45 100644 --- a/include/class.dept.php +++ b/include/class.dept.php @@ -368,9 +368,15 @@ class Dept extends VerySimpleModel { return self::getDepartments(array('publiconly'=>true)); } - static function create($vars, &$errors) { + static function create($vars, &$errors=array()) { $dept = parent::create($vars); - $dept->create = SqlFunction::NOW(); + $dept->created = SqlFunction::NOW(); + return $dept; + } + + static function __create($vars, &$errors) { + $dept = self::create($vars); + $dept->save(); return $dept; } diff --git a/include/class.group.php b/include/class.group.php index 635228974..48fe6dba4 100644 --- a/include/class.group.php +++ b/include/class.group.php @@ -164,6 +164,15 @@ class Group extends VerySimpleModel { return $group; } + static function __create($vars, &$errors) { + $g = self::create($vars); + $g->save(); + if ($vars['depts']) + $g->updateDeptAccess($vars['depts']); + + return $g; + } + function save($refetch=false) { if ($this->dirty) { $this->updated = SqlFunction::NOW(); diff --git a/include/class.i18n.php b/include/class.i18n.php index d5d524a97..5941b44d4 100644 --- a/include/class.i18n.php +++ b/include/class.i18n.php @@ -49,7 +49,7 @@ class Internationalization { function loadDefaultData() { # notrans -- do not translate the contents of this array $models = array( - 'department.yaml' => 'Dept::create', + 'department.yaml' => 'Dept::__create', 'sla.yaml' => 'SLA::create', 'form.yaml' => 'DynamicForm::create', 'list.yaml' => 'DynamicList::create', @@ -63,7 +63,7 @@ class Internationalization { // Ticket 'ticket_status.yaml' => 'TicketStatus::__create', // Note that group requires department - 'group.yaml' => 'Group::create', + 'group.yaml' => 'Group::__create', 'file.yaml' => 'AttachmentFile::create', 'sequence.yaml' => 'Sequence::__create', ); diff --git a/include/i18n/en_US/department.yaml b/include/i18n/en_US/department.yaml index 3de7de70b..34d135a7d 100644 --- a/include/i18n/en_US/department.yaml +++ b/include/i18n/en_US/department.yaml @@ -12,24 +12,24 @@ # The very first group listed in this document will be the primary # department of the initial staff member -- the administrator. --- -- id: 1 - name: Support - signature: | +- dept_id: 1 + dept_name: Support + dept_signature: | Support Department ispublic: 1 group_membership: 1 -- id: 2 - name: Sales - signature: | +- dept_id: 2 + dept_name: Sales + dept_signature: | Sales and Customer Retention ispublic: 1 sla_id: 1 group_membership: 1 -- id: 3 - name: Maintenance - signature: | +- dept_id: 3 + dept_name: Maintenance + dept_signature: | Maintenance Department ispublic: 0 group_membership: 0 diff --git a/include/i18n/en_US/group.yaml b/include/i18n/en_US/group.yaml index bc65037e1..66acefa23 100644 --- a/include/i18n/en_US/group.yaml +++ b/include/i18n/en_US/group.yaml @@ -32,8 +32,8 @@ # The very first group listed in this document will be the primary group of # the initial staff member -- the administrator. --- -- isactive: 1 - name: Lion Tamers +- group_enabled: 1 + group_name: Lion Tamers notes: | System overlords. These folks (initially) have full control to all the departments they have access to. @@ -50,8 +50,8 @@ depts: [1, 2, 3] -- isactive: 1 - name: Elephant Walkers +- group_enabled: 1 + group_name: Elephant Walkers notes: | Inhabitants of the ivory tower can_create_tickets: 1 @@ -67,8 +67,8 @@ depts: [1, 2, 3] -- isactive: 1 - name: Flea Trainers +- group_enabled: 1 + group_name: Flea Trainers notes: | Lowly staff members can_create_tickets: 1 -- GitLab