You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.8 KiB
65 lines
1.8 KiB
7 years ago
|
<?php
|
||
|
/* For licensing terms, see /license.txt */
|
||
|
|
||
|
use Chamilo\CoreBundle\Entity\Portfolio;
|
||
|
|
||
|
$categories = $em
|
||
|
->getRepository('ChamiloCoreBundle:PortfolioCategory')
|
||
|
->findBy([
|
||
|
'user' => $user,
|
||
|
]);
|
||
|
|
||
|
$form = new FormValidator('add_portfolio', 'post', $baseUrl.'action=add_item');
|
||
6 years ago
|
if (api_get_configuration_value('save_titles_as_html')) {
|
||
5 years ago
|
$form->addHtmlEditor('title', get_lang('Title'), true, false, ['ToolbarSet' => 'TitleAsHtml']);
|
||
6 years ago
|
} else {
|
||
|
$form->addText('title', get_lang('Title'));
|
||
|
$form->applyFilter('title', 'trim');
|
||
|
}
|
||
7 years ago
|
$form->addHtmlEditor('content', get_lang('Content'), true, false, ['ToolbarSet' => 'NotebookStudent']);
|
||
|
$form->addSelectFromCollection('category', get_lang('Category'), $categories, [], true);
|
||
|
$form->addButtonCreate(get_lang('Create'));
|
||
|
|
||
|
if ($form->validate()) {
|
||
|
$values = $form->exportValues();
|
||
|
$currentTime = new DateTime(
|
||
|
api_get_utc_datetime(),
|
||
|
new DateTimeZone('UTC')
|
||
|
);
|
||
|
|
||
|
$portfolio = new Portfolio();
|
||
|
$portfolio
|
||
|
->setTitle($values['title'])
|
||
|
->setContent($values['content'])
|
||
|
->setUser($user)
|
||
|
->setCourse($course)
|
||
|
->setSession($session)
|
||
|
->setCategory(
|
||
|
$em->find('ChamiloCoreBundle:PortfolioCategory', $values['category'])
|
||
|
)
|
||
|
->setCreationDate($currentTime)
|
||
|
->setUpdateDate($currentTime);
|
||
|
|
||
|
$em->persist($portfolio);
|
||
|
$em->flush();
|
||
|
|
||
|
Display::addFlash(
|
||
5 years ago
|
Display::return_message(get_lang('Portfolio item added'), 'success')
|
||
7 years ago
|
);
|
||
|
|
||
|
header("Location: $baseUrl");
|
||
|
exit;
|
||
|
}
|
||
|
|
||
5 years ago
|
$toolName = get_lang('Add item to portfolio');
|
||
7 years ago
|
$interbreadcrumb[] = [
|
||
|
'name' => get_lang('Portfolio'),
|
||
|
'url' => $baseUrl,
|
||
|
];
|
||
|
|
||
|
$actions[] = Display::url(
|
||
|
Display::return_icon('back.png', get_lang('Back'), [], ICON_SIZE_MEDIUM),
|
||
|
$baseUrl
|
||
|
);
|
||
|
$content = $form->returnForm();
|