if (!company::check_canedit_user($companyid, $user->id)) { print_error('invaliduserid'); } if (is_primary_admin($user->id)) { print_error('nopermissions', 'error', '', 'delete the primary admin user'); } if ($confirm != md5($delete)) { $fullname = fullname($user, true); echo $OUTPUT->heading(get_string('deleteuser', 'block_iomad_company_admin') . " " . $fullname); $optionsyes = array('delete' => $delete, 'confirm' => md5($delete), 'sesskey' => sesskey()); echo $OUTPUT->confirm(get_string('deletecheckfull', 'block_iomad_company_admin', "'{$fullname}'"), new moodle_url('editusers.php', $optionsyes), 'editusers.php'); echo $OUTPUT->footer(); die; } else { // Actually delete the user. company_user::delete($user->id); } } else { if ($suspend and confirm_sesskey()) { // Delete a selected user, after confirmation. if (!iomad::has_capability('block/iomad_company_admin:editusers', $systemcontext)) { print_error('nopermissions', 'error', '', 'suspend a user'); } if (!($user = $DB->get_record('user', array('id' => $suspend)))) { print_error('nousers', 'error'); } if (!company::check_canedit_user($companyid, $user->id)) { print_error('invaliduserid'); } if (is_primary_admin($user->id)) { print_error('nopermissions', 'error', '', 'delete the primary admin user');