diff --git a/include/class.i18n.php b/include/class.i18n.php index 59c2061ee6c5e789f6bcc6be04ff7becae332276..ecf2f92f653cbf059a4469507843d6553c5fba38 100644 --- a/include/class.i18n.php +++ b/include/class.i18n.php @@ -47,26 +47,30 @@ class Internationalization { function loadDefaultData() { # notrans -- do not translate the contents of this array $models = array( - 'department.yaml' => 'Dept', - 'sla.yaml' => 'SLA', - 'form.yaml' => 'DynamicForm', + 'department.yaml' => 'Dept::create', + 'sla.yaml' => 'SLA::create', + 'form.yaml' => 'DynamicForm::create', // Note that department, sla, and forms are required for // help_topic - 'help_topic.yaml' => 'Topic', - 'filter.yaml' => 'Filter', - 'team.yaml' => 'Team', + 'help_topic.yaml' => 'Topic::create', + 'filter.yaml' => 'Filter::create', + 'team.yaml' => 'Team::create', + // Organization + 'organization.yaml' => 'Organization::__create', // Note that group requires department - 'group.yaml' => 'Group', - 'file.yaml' => 'AttachmentFile', + 'group.yaml' => 'Group::create', + 'file.yaml' => 'AttachmentFile::create', ); $errors = array(); - foreach ($models as $yaml=>$m) - if ($objects = $this->getTemplate($yaml)->getData()) - foreach ($objects as $o) - // Model::create($o) - call_user_func_array( - array($m, 'create'), array($o, &$errors)); + foreach ($models as $yaml=>$m) { + if ($objects = $this->getTemplate($yaml)->getData()) { + foreach ($objects as $o) { + if ($m && is_callable($m)) + @call_user_func_array($m, array($o, &$errors)); + } + } + } // Priorities $priorities = $this->getTemplate('priority.yaml')->getData(); diff --git a/include/class.organization.php b/include/class.organization.php index 81937964e55c75302872cf1b20ac72c1915a3d4f..e80e435c75283e00308c0fa9894aca8e18b42199 100644 --- a/include/class.organization.php +++ b/include/class.organization.php @@ -102,7 +102,7 @@ class Organization extends OrganizationModel { function addDynamicData($data) { - $of = OrganizationForm::getInstance($this->id); + $of = OrganizationForm::getInstance($this->id, true); foreach ($of->getFields() as $f) if (isset($data[$f->get('name')])) $of->setAnswer($f->get('name'), $data[$f->get('name')]); @@ -116,7 +116,7 @@ class Organization extends OrganizationModel { if (!isset($this->_entries)) { $this->_entries = DynamicFormEntry::forOrganization($this->id)->all(); if (!$this->_entries) { - $g = OrganizationForm::getInstance($this->id); + $g = OrganizationForm::getInstance($this->id, true); $g->save(); $this->_entries[] = $g; } @@ -321,6 +321,19 @@ class Organization extends OrganizationModel { return $valid ? self::fromVars($form->getClean()) : null; } + // Custom create called by installer/upgrader to load initial data + static function __create($ht, &$error=false) { + + $ht['created'] = new SqlFunction('NOW'); + $org = Organization::create($ht); + // Add dynamic data (if any) + if ($ht['fields']) { + $org->save(true); + $org->addDynamicData($ht['fields']); + } + + return $org; + } } class OrganizationForm extends DynamicForm { @@ -343,8 +356,8 @@ class OrganizationForm extends DynamicForm { return static::$form; } - static function getInstance($object_id=0) { - if (!isset(static::$instance)) + static function getInstance($object_id=0, $new=false) { + if ($new || !isset(static::$instance)) static::$instance = static::getDefaultForm()->instanciate(); static::$instance->object_type = 'O'; @@ -368,7 +381,13 @@ class OrganizationForm extends DynamicForm { } } - $o =static::objects(); + if (!$form || !($o=static::objects())) + return false; + + // Create sample organization. + if (($orgs = $i18n->getTemplate('organization.yaml')->getData())) + foreach($orgs as $org) + Organization::__create($org); return $o[0]; } diff --git a/include/i18n/en_US/organization.yaml b/include/i18n/en_US/organization.yaml new file mode 100644 index 0000000000000000000000000000000000000000..dd5081b11061dd842ecc67d617cc1122abaa09e1 --- /dev/null +++ b/include/i18n/en_US/organization.yaml @@ -0,0 +1,21 @@ +# +# Initial organizations defined for the system. +# +# Fields: +# name - Descriptive name for the organization +# fields - custom fields +# +--- +- name: osTicket + fields: + address:| + 420 Desoto Street + Alexandria, LA 71301 + phone: (318) 290-3674 + website: http://osticket.com + notes: > + Not only do we develop the software, we also use it to manage + support for osTicket. Let us help you quickly implement and leverage + the full potential of osTicket's features and functionality. Contact + us for professional support or visit our website for documentation + and community support. diff --git a/scp/js/tips.js b/scp/js/tips.js index a1b7f88d53224c906dc83d7e51716285fd5cc3d3..ee7764f8097b5b5a1512cc9e98d521cfc3f8c494 100644 --- a/scp/js/tips.js +++ b/scp/js/tips.js @@ -9,7 +9,7 @@ jQuery(function() { var tip_box = $('<div>').addClass('tip_box'); var tip_shadow = $('<div>').addClass('tip_shadow'); var tip_content = $('<div>').addClass('tip_content').load(url, function() { - tip_content.prepend('<a href="#" class="tip_close">x</a>'); + tip_content.prepend('<a href="#" class="tip_close"><i class="icon-remove-circle"></i></a>'); }); var the_tip = tip_box.append(tip_arrow).append(tip_content).prepend(tip_shadow); diff --git a/setup/inc/class.installer.php b/setup/inc/class.installer.php index cc18ba3e949ced04453f15205329a297b4315b84..2f56574be91f858c2dcffe57bd0af6012e282038 100644 --- a/setup/inc/class.installer.php +++ b/setup/inc/class.installer.php @@ -259,7 +259,14 @@ class Installer extends SetupWizard { $errors = array(); $ticket_vars = $i18n->getTemplate('templates/ticket/installed.yaml') ->getData(); - $tid = Ticket::create($ticket_vars, $errors, 'api', false, false); + $ticket = Ticket::create($ticket_vars, $errors, 'api', false, false); + + if ($ticket + && ($org = Organization::objects()->order_by('id')->one())) { + + $user=User::lookup($ticket->getOwnerId()); + $user->setOrganization($org); + } //TODO: create another personalized ticket and assign to admin?? diff --git a/setup/install.php b/setup/install.php index 2bca44418e655637620993439f34ca1e0a0329f7..32db0a47a7a0354bd0068831f86b98a078afa7c6 100644 --- a/setup/install.php +++ b/setup/install.php @@ -100,8 +100,10 @@ switch(strtolower($_SESSION['ost_installer']['s'])) { break; case 'done': $inc='install-done.inc.php'; - if(!$installer->config_exists()) + if (!$installer->config_exists()) $inc='install-prereq.inc.php'; + else // Clear installer session + $_SESSION['ost_installer'] = array(); break; default: //Fail IF any of the old config files exists.