function execute() { $model = new connectionUserModel(); $login = ConnectionHelper::userLogin(); $user = array_map(function ($a) use($model) { $data = $model->getInfo($a['id']); return array('id' => $data['id'], 'key' => $data['id'], 'name' => $data['first_name'], 'status' => $data['online'] ? 'online' : 'offline', 'avatar' => '/photo/thumb/' . $data['avatar']['id'], 'nickname' => $data['first_name'], 'camera' => isset($data['camera']) && $data['camera'] == 1 ? $data['stream'] : false); }, $model->getContact($login['id'])); echo json_encode(array('contact' => $user)); exit; }