From b4f125039e79ca9ab4850264471d7e3f56decd7b Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Fri, 22 May 2015 13:01:39 -0500 Subject: [PATCH] orgs: Fix error deleting organization Also, fix clearing users in an organization when removing the organization. --- include/class.organization.php | 9 ++++++++- include/staff/templates/org-delete.tmpl.php | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/class.organization.php b/include/class.organization.php index e79f18af0..6d3ceaeb1 100644 --- a/include/class.organization.php +++ b/include/class.organization.php @@ -407,9 +407,16 @@ implements TemplateVariable { if (!parent::delete()) return false; + // Remove users from this organization + User::objects() + ->filter(array('org' => $this)) + ->update(array('org_id' => 0)); + foreach ($this->getDynamicData(false) as $entry) { - $entry->delete(); + if (!$entry->delete()) + return false; } + return true; } static function fromVars($vars) { diff --git a/include/staff/templates/org-delete.tmpl.php b/include/staff/templates/org-delete.tmpl.php index 290d20e12..fe32251e3 100644 --- a/include/staff/templates/org-delete.tmpl.php +++ b/include/staff/templates/org-delete.tmpl.php @@ -26,7 +26,7 @@ if ($info['error']) { <?php foreach ($org->getDynamicData() as $entry) { ?> <tr><td colspan="2" style="border-bottom: 1px dotted black"><strong><?php - echo $entry->getForm()->get('title'); ?></strong></td></tr> + echo $entry->getTitle(); ?></strong></td></tr> <?php foreach ($entry->getAnswers() as $a) { ?> <tr style="vertical-align:top"><td style="width:30%;border-bottom: 1px dotted #ccc"><?php echo Format::htmlchars($a->getField()->get('label')); ?>:</td> -- GitLab