Skip to content
Snippets Groups Projects
Commit 4e82f2e0 authored by Jared Hancock's avatar Jared Hancock
Browse files

Merge pull request #3062 from protich/issue/org-delete


org: Remove users from deleted org.

Reviewed-By: default avatarJared Hancock <jared@osticket.com>
parents 09798687 45dd2a66
No related branches found
No related tags found
No related merge requests found
......@@ -229,6 +229,17 @@ class ModelMeta implements ArrayAccess {
return $this->fields;
}
function getByPath($path) {
if (is_string($path))
$path = explode('__', $path);
$root = $this;
foreach ($path as $P) {
list($root, ) = $root['joins'][$P]['fkey'];
$root = $root::getMeta();
}
return $root;
}
/**
* Create a new instance of the model, optionally hydrating it with the
* given hash table. The constructor is not called, which leaves the
......@@ -2249,9 +2260,22 @@ class SqlCompiler {
// Handle relationship comparisons with model objects
elseif ($value instanceof VerySimpleModel) {
$criteria = array();
foreach ($value->pk as $f=>$v) {
$f = $field . '__' . $f;
$criteria[$f] = $v;
// Avoid a join if possible. Use the local side of the
// relationship
if (count($value->pk) === 1) {
$path = explode('__', $field);
$relationship = array_pop($path);
$lmodel = $model::getMeta()->getByPath($path);
$local = $lmodel['joins'][$relationship]['local'];
$path = $path ? (implode('__', $path) . '__') : '';
foreach ($value->pk as $v) {
$criteria["{$path}{$local}"] = $v;
}
}
else {
foreach ($value->pk as $f=>$v) {
$criteria["{$field}__{$f}"] = $v;
}
}
$filter[] = $this->compileQ(new Q($criteria), $model, $slot);
}
......
......@@ -309,7 +309,7 @@ if($ticket->isOverdue())
<span id="user-<?php echo $ticket->getOwnerId(); ?>-email"><?php echo $ticket->getEmail(); ?></span>
</td>
</tr>
<?php if ($user->getOrgId()) { ?>
<?php if ($user->getOrganization()) { ?>
<tr>
<th><?php echo __('Organization'); ?>:</th>
<td><i class="icon-building"></i>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment