Skip to content

Commit

Permalink
Merge pull request osTicket#3062 from protich/issue/org-delete
Browse files Browse the repository at this point in the history
org: Remove users from deleted org.

Reviewed-By: Jared Hancock <[email protected]>
  • Loading branch information
greezybacon committed Apr 24, 2016
2 parents 0979868 + 45dd2a6 commit 4e82f2e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
30 changes: 27 additions & 3 deletions include/class.orm.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,17 @@ function getFieldNames() {
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
Expand Down Expand Up @@ -2249,9 +2260,22 @@ function compileQ(Q $Q, $model, $slot=false) {
// 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);
}
Expand Down
2 changes: 1 addition & 1 deletion include/staff/ticket-view.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ class="icon-folder-close-alt icon-fixed-width"></i> %s</a></li>',
<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>
Expand Down

0 comments on commit 4e82f2e

Please sign in to comment.