getId(), null, null, false, false, null, null, null, null, null, null, HRM_REQUEST ); $requestOptions = []; foreach ($usersRequested as $userRequested) { $userInfo = api_get_user_info($userRequested['user_id']); if (!$userInfo) { continue; } $requestOptions[$userInfo['user_id']] = $userInfo['complete_name']; } $form = new FormValidator('require_user_linking'); $form->addUserAvatar('hrm', get_lang('Human Resources Manager'), 'medium'); $form->addSelectAjax( 'users', [get_lang('Link me to student'), get_lang('Link me to studentComment')], $requestOptions, [ 'multiple' => 'multiple', 'url' => api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=get_user_like', ] ); $form->addButtonSave(get_lang('Request linking with student')); $form->setDefaults([ 'hrm' => $hrm, 'users' => array_keys($requestOptions), ]); if ($form->validate()) { $values = $form->exportValues(); //Avoid self-subscribe as request $usersId = array_filter($values['users'], function ($userId) use ($hrm) { return (int) $userId != $hrm->getId(); }); UserManager::clearHrmRequestsForUser($hrm, $usersId); UserManager::requestUsersToHRManager($hrm->getId(), $usersId, false); Display::addFlash( Display::return_message(get_lang('Linking request added'), 'success') ); header('Location: '.api_get_self()); exit; } $usersAssigned = UserManager::get_users_followed_by_drh($hrm->getId()); $content = $form->returnForm(); $content .= Display::page_subheader(get_lang('List of users assigned to Human Resources manager')); $content .= '
'; foreach ($usersAssigned as $userAssigned) { $userAssigned = api_get_user_info($userAssigned['user_id']); $userPicture = isset($userAssigned["avatar_medium"]) ? $userAssigned["avatar_medium"] : $userAssigned["avatar"]; $studentLink = api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?student='.$userAssigned['user_id']; $content .= '
'; } $content .= '
'; $toolName = get_lang('Request linking to student'); $view = new Template($toolName); $view->assign('header', $toolName); $view->assign('content', $content); $view->display_one_col_template();