validate() && isset($_GET['newtypeselected'])) { // reload page, this time with a parameter indicating the selected type header('Location: '.api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat']) . '&typeselected='.$typeform->exportValue('select_link') . '&course_code=' . Security::remove_XSS($_GET['course_code'])); exit; } // link type selected, show 2nd form to retrieve the link data if (isset($_GET['typeselected']) && $_GET['typeselected'] != '0') { error_log(__LINE__); $addform = new LinkAddEditForm(LinkAddEditForm :: TYPE_ADD, $category[0], intval($_GET['typeselected']), null, 'add_link', api_get_self() . '?selectcat=' . $_GET['selectcat'] . '&typeselected=' . $_GET['typeselected'] . '&course_code=' . $_GET['course_code']); error_log(__LINE__); if ($addform->validate()) { error_log(__LINE__); $addvalues = $addform->exportValues(); $link= LinkFactory :: create($_GET['typeselected']); $link->set_user_id(api_get_user_id()); if($category[0]->get_course_code() == '' && !empty($_GET['course_code'])) { error_log(__LINE__); $link->set_course_code(Database::escape_string($_GET['course_code'])); } else { error_log(__LINE__); $link->set_course_code($category[0]->get_course_code()); } error_log(__LINE__); $link->set_category_id($category[0]->get_id()); if ($link->needs_name_and_description()) $link->set_name($addvalues['name']); else $link->set_ref_id($addvalues['select_link']); $link->set_weight($addvalues['weight']); if ($link->needs_max()) $link->set_max($addvalues['max']); $link->set_date(strtotime($addvalues['date'])); if ($link->needs_name_and_description()) $link->set_description($addvalues['description']); $link->set_visible(empty ($addvalues['visible']) ? 0 : 1); $link->add(); error_log(__LINE__); if ($addvalues['addresult'] == 1) { header('Location: gradebook_add_result.php?selecteval=' . $link->get_ref_id()); exit; } else { header('Location: gradebook.php?linkadded=&selectcat=' . $_GET['selectcat']); exit; } } } $interbreadcrumb[]= array ( 'url' => 'gradebook.php?selectcat=' . $_GET['selectcat'], 'name' => get_lang('Gradebook' )); Display :: display_header(get_lang('MakeLink')); if (isset ($typeform)) $typeform->display(); if (isset ($addform)) $addform->display(); Display :: display_footer(); ?>