Exemplo n.º 1
0
    $module = $_GET['mod'];
} else {
    display_error($string['fatalerrormsg0'], $string['fatalerrormsg1'], true);
}
$session = date_utils::get_current_academic_year();
$modID = module_utils::get_idMod($module, $mysqli);
// Translate module code into ID
$mod_details = module_utils::get_full_details_by_ID($modID, $mysqli);
if ($mod_details === false) {
    $msg = sprintf($string['nomodule'], $module);
    display_error('Module ID error', $msg, false, true);
}
if ($mod_details['active'] == 1 and $mod_details['selfenroll'] == 1 and isset($_POST['submit'])) {
    if (!$userObject->has_role('Student')) {
        // Add role of 'Student' if current user doesn't have it.
        UserUtils::add_role('Student', $userObject->get_user_ID(), $mysqli);
    }
    // Insert new module enrollment
    UserUtils::add_student_to_module($userObject->get_user_ID(), $modID, 1, $_POST['session'], $mysqli);
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta http-equiv="content-type" content="text/html;charset=<?php 
echo $configObject->get('cfg_page_charset');
?>
" />
  
  <title><?php