예제 #1
0
    $course['exemplary_content']    = empty($course['exemplary_content']) ? false : true;
    $course['teachers']             = $course_teachers;
    //$course['user_id']              = $teacher_id;
    $course['wanted_code']          = $course['visual_code'];
    $course['gradebook_model_id']   = isset($course['gradebook_model_id']) ? $course['gradebook_model_id'] : null;
    // Fixing category code
    $course['course_category'] = $course['category_code'];
    $course_info = CourseManager::create_course($course);

    header('Location: course_list.php'.($course_info===false?'?action=show_msg&warn='.api_get_last_failure():''));
    exit;
}*/
// Display the form.
$content = $form->return_form();
//echo $content;
$em = Container::getEntityManager();
$request = Container::getRequest();
$course = new Course();
$builder = Container::getFormFactory()->createBuilder(new CourseType(), $course);
$form = $builder->getForm();
$form->handleRequest($request);
if ($form->isValid()) {
    $course = $form->getData();
    $em->persist($course);
    $em->flush();
    Container::addFlash(get_lang('Updated'));
    $url = Container::getRouter()->generate('main', array('name' => 'admin/course_list.php'));
    header('Location: ' . $url);
    exit;
}
echo Container::getTemplate()->render('ChamiloCoreBundle:Legacy:form.html.twig', array('form' => $form->createView(), 'url' => api_get_self()));
예제 #2
0
/**
 * Returns an escaped version of $_SERVER['PHP_SELF'] to avoid XSS injection
 * @return string   Escaped version of $_SERVER['PHP_SELF']
 */
function api_get_self()
{
    //return htmlentities($_SERVER['PHP_SELF']);
    return htmlentities(Container::getRequest()->server->get('PHP_SELF'));
    //return htmlentities(Container::getRequest()->getUri());
}