addElement('select', 'course', get_lang('Course'), $options); $form->addElement('file', 'file', get_lang('File')); $form->add_button('submit', get_lang('Submit')); $form->display(); if ($form->validate()) { $values = $form->getSubmitValues(); if (isset($_FILES['file']['tmp_name']) && !empty($_FILES['file']['tmp_name']) ) { $users = Import::csv_reader($_FILES['file']['tmp_name']); $courseId = $values['course']; $courseInfo = api_get_course_info_by_id($courseId); $courseCode = $courseInfo['code']; $cats = Category:: load( null, null, $courseCode, null, null, 0, false ); if (isset($cats[0])) { /** @var Category $cat */ $userList = array(); foreach ($users as $user) { $userInfo = api_get_user_info_from_official_code( $user['official_code'] ); if (!empty($userInfo)) { $userList[] = $userInfo; } } Category::exportAllCertificates( $cat->get_id(), $userList ); } } } Display :: display_footer();