|
|
|
@ -1,6 +1,8 @@ |
|
|
|
|
<?php |
|
|
|
|
/* For licensing terms, see /license.txt */ |
|
|
|
|
|
|
|
|
|
use Chamilo\SkillBundle\Entity\Level; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Add a skill Level. |
|
|
|
|
* |
|
|
|
@ -27,14 +29,14 @@ $id = isset($_GET['id']) ? $_GET['id'] : ''; |
|
|
|
|
|
|
|
|
|
$item = null; |
|
|
|
|
if (!empty($id)) { |
|
|
|
|
/** @var \Chamilo\SkillBundle\Entity\Level $item */ |
|
|
|
|
/** @var Level $item */ |
|
|
|
|
$item = $em->getRepository('ChamiloSkillBundle:Level')->find($id); |
|
|
|
|
if (!$item) { |
|
|
|
|
api_not_allowed(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$form = new FormValidator('Level', 'GET', api_get_self().'?action='.$action.'&id='.$id); |
|
|
|
|
$form = new FormValidator('level', 'GET', api_get_self().'?action='.$action.'&id='.$id); |
|
|
|
|
$form->addText('name', get_lang('Name')); |
|
|
|
|
$form->addText('short_name', get_lang('ShortName')); |
|
|
|
|
$form->addSelectFromCollection('profile_id', get_lang('Profile'), $profiles); |
|
|
|
@ -49,29 +51,37 @@ if (!empty($item)) { |
|
|
|
|
'profile_id' => $item->getProfile()->getId(), |
|
|
|
|
]); |
|
|
|
|
} |
|
|
|
|
$formToDisplay = $form->returnForm(); |
|
|
|
|
|
|
|
|
|
$formToDisplay = ''; |
|
|
|
|
|
|
|
|
|
$interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('PlatformAdmin')]; |
|
|
|
|
$interbreadcrumb[] = ['url' => api_get_self(), 'name' => get_lang('SkillProfile')]; |
|
|
|
|
$interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin/skill.php', 'name' => get_lang('ManageSkillsLevels')]; |
|
|
|
|
$interbreadcrumb[] = ['url' => api_get_self(), 'name' => get_lang('SkillLevel')]; |
|
|
|
|
|
|
|
|
|
$tpl = new Template($action); |
|
|
|
|
switch ($action) { |
|
|
|
|
case 'add': |
|
|
|
|
$tpl->assign('form', $formToDisplay); |
|
|
|
|
$formToDisplay = $form->returnForm(); |
|
|
|
|
if ($form->validate()) { |
|
|
|
|
$values = $form->exportValues(); |
|
|
|
|
$item = new \Chamilo\SkillBundle\Entity\Level(); |
|
|
|
|
if (isset($values['profile_id']) && !empty($values['profile_id'])) { |
|
|
|
|
$profile = $em->getRepository('ChamiloSkillBundle:Profile')->find($values['profile_id']); |
|
|
|
|
if ($profile) { |
|
|
|
|
$item = new Level(); |
|
|
|
|
$item->setName($values['name']); |
|
|
|
|
$item->setShortName($values['short_name']); |
|
|
|
|
$profile = $em->getRepository('ChamiloSkillBundle:Profile')->find($values['profile_id']); |
|
|
|
|
$item->setProfile($profile); |
|
|
|
|
|
|
|
|
|
$em->persist($item); |
|
|
|
|
$em->flush(); |
|
|
|
|
Display::addFlash(Display::return_message(get_lang('Added'))); |
|
|
|
|
} else { |
|
|
|
|
Display::addFlash(Display::return_message(get_lang('Added'))); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
Display::addFlash(Display::return_message(get_lang('YouNeedToCreateASkillProfile'))); |
|
|
|
|
} |
|
|
|
|
header('Location: '.$listAction); |
|
|
|
|
exit; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$toolbarAction = Display::url( |
|
|
|
|
Display::return_icon( |
|
|
|
|
'list_badges.png', |
|
|
|
@ -84,7 +94,7 @@ switch ($action) { |
|
|
|
|
); |
|
|
|
|
break; |
|
|
|
|
case 'edit': |
|
|
|
|
$tpl->assign('form', $formToDisplay); |
|
|
|
|
$formToDisplay = $form->returnForm(); |
|
|
|
|
$toolbarAction = Display::url( |
|
|
|
|
Display::return_icon( |
|
|
|
|
'list_badges.png', |
|
|
|
@ -102,7 +112,9 @@ switch ($action) { |
|
|
|
|
$item->setName($values['name']); |
|
|
|
|
$item->setShortName($values['short_name']); |
|
|
|
|
$profile = $em->getRepository('ChamiloSkillBundle:Profile')->find($values['profile_id']); |
|
|
|
|
if ($profile) { |
|
|
|
|
$item->setProfile($profile); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$em->persist($item); |
|
|
|
|
$em->flush(); |
|
|
|
@ -121,8 +133,11 @@ switch ($action) { |
|
|
|
|
$listAction, |
|
|
|
|
['title' => get_lang('List')] |
|
|
|
|
); |
|
|
|
|
if ($item) { |
|
|
|
|
$em->remove($item); |
|
|
|
|
$em->flush(); |
|
|
|
|
Display::addFlash(Display::return_message(get_lang('Deleted'))); |
|
|
|
|
} |
|
|
|
|
header('Location: '.$listAction); |
|
|
|
|
exit; |
|
|
|
|
|
|
|
|
@ -140,12 +155,11 @@ switch ($action) { |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$tpl = new Template($action); |
|
|
|
|
$tpl->assign('form', $formToDisplay); |
|
|
|
|
$tpl->assign('list', $list); |
|
|
|
|
$templateName = $tpl->get_template('admin/skill_level.tpl'); |
|
|
|
|
$contentTemplate = $tpl->fetch($templateName); |
|
|
|
|
$tpl->assign( |
|
|
|
|
'actions', |
|
|
|
|
Display::toolbarAction('toolbar', [$toolbarAction]) |
|
|
|
|
); |
|
|
|
|
$tpl->assign('actions', Display::toolbarAction('toolbar', [$toolbarAction])); |
|
|
|
|
$tpl->assign('content', $contentTemplate); |
|
|
|
|
$tpl->display_one_col_template(); |
|
|
|
|