Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| RightsLevelManager | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
4 | |
100.00% |
1 / 1 |
| getLevel | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
4 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace BO\Zmsentities\Helper; |
| 4 | |
| 5 | /** |
| 6 | * Special Class to manage rights by level for old db |
| 7 | * |
| 8 | * @todo Remove this class, keep no contraint on old DB schema in zmsentities |
| 9 | */ |
| 10 | class RightsLevelManager |
| 11 | { |
| 12 | public static $possibleRights = array( |
| 13 | 'superuser' => 90, |
| 14 | 'organisation' => 70, |
| 15 | 'department' => 50, |
| 16 | 'cluster' => 40, |
| 17 | 'useraccount' => 40, |
| 18 | 'scope' => 30, |
| 19 | 'departmentStats' => 25, |
| 20 | 'availability' => 20, |
| 21 | 'ticketprinter' => 15, |
| 22 | 'sms' => 10, |
| 23 | 'audit' => 5, |
| 24 | 'basic' => 0 |
| 25 | ); |
| 26 | |
| 27 | public static $accessRights = array( |
| 28 | 'superuser' => 1, |
| 29 | 'audit' => 1, |
| 30 | 'organisation' => 1, |
| 31 | 'department' => 1, |
| 32 | 'scope' => 1 |
| 33 | ); |
| 34 | |
| 35 | public static function getLevel($userRights) |
| 36 | { |
| 37 | $rightsLevel = 0; |
| 38 | foreach ($userRights as $rightName => $isSelected) { |
| 39 | $level = self::$possibleRights[$rightName]; |
| 40 | if ($isSelected && $level > $rightsLevel) { |
| 41 | $rightsLevel = $level; |
| 42 | } |
| 43 | } |
| 44 | return $rightsLevel; |
| 45 | } |
| 46 | } |