| Conditions | 6 |
| Paths | 5 |
| Total Lines | 42 |
| Code Lines | 30 |
| Lines | 0 |
| Ratio | 0 % |
| 1 | <?php |
||
| 17 | static function profiles_get () { |
||
| 18 | $User = User::instance(); |
||
| 19 | if ($User->guest()) { |
||
| 20 | throw new ExitException(403); |
||
| 21 | } |
||
| 22 | $fields = [ |
||
| 23 | 'id', |
||
| 24 | 'login', |
||
| 25 | 'username', |
||
| 26 | 'language', |
||
| 27 | 'timezone', |
||
| 28 | 'avatar' |
||
| 29 | ]; |
||
| 30 | $Page = Page::instance(); |
||
| 31 | $Route = Route::instance(); |
||
| 32 | if (isset($Route->route[1])) { |
||
| 33 | $id = _int(explode(',', $Route->route[1])); |
||
| 34 | $single = count($id) == 1; |
||
| 35 | if ( |
||
| 36 | !$User->admin() && |
||
| 37 | !( |
||
| 38 | $id = array_intersect($id, $User->get_contacts()) |
||
| 39 | ) |
||
| 40 | ) { |
||
| 41 | throw new ExitException('User is not in your contacts', 403); |
||
| 42 | } |
||
| 43 | if ($single) { |
||
| 44 | $Page->json($User->get($fields, $id[0])); |
||
| 45 | } else { |
||
| 46 | $Page->json( |
||
| 47 | array_map( |
||
| 48 | function ($id) use ($fields, $User) { |
||
| 49 | return $User->get($fields, $id); |
||
| 50 | }, |
||
| 51 | $id |
||
| 52 | ) |
||
| 53 | ); |
||
| 54 | } |
||
| 55 | } else { |
||
| 56 | throw new ExitException('Specified ids are expected', 400); |
||
| 57 | } |
||
| 58 | } |
||
| 59 | } |
||
| 60 |