Skip to content

Commit

Permalink
gevUserUtils::getDirectSuperiors: more edgecases.
Browse files Browse the repository at this point in the history
  • Loading branch information
klees committed Oct 30, 2015
1 parent 5c1fd9b commit 263e07e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Services/GEV/Utils/classes/class.gevUserUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -1215,12 +1215,20 @@ public function getDirectSuperiors() {
}

$superiors = $tree->getSuperiors($ref_id);
$user_is_superior = in_array($this->user_id, $superiors);
$in_initial_orgus = $i < $initial_amount;

// I always need to go one org unit up if we are in the original
// orgu and the user is superior there.
if ( $in_initial_orgus && $user_is_superior) {
$orgus[] = $tree->getParent($ref_id);
}

// Skip the orgu if there are no superiors there.
if ( count($superiors) == 0
|| ( $i < $initial_amount
|| ( $in_initial_orgus
// This is only about the org units the user actually is a member of
&& in_array($this->user_id, $superiors)
&& $user_is_superior
// If a user is an employee and a superior in one orgunit, he
// actually seem to be his own superior.
&& !in_array($this->user_id, $tree->getEmployees($ref_id)))
Expand Down

0 comments on commit 263e07e

Please sign in to comment.