diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index 1a7aa8d314..4767c62367 100755 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -10045,11 +10045,11 @@ EOD; public static function updateCategory($params) { $em = Database::getManager(); + /** @var CLpCategory $item */ $item = $em->find('ChamiloCourseBundle:CLpCategory', $params['id']); if ($item) { $item->setName($params['name']); - $item->setCId($params['c_id']); - $em->persist($item); + $em->merge($item); $em->flush(); } } @@ -10060,6 +10060,7 @@ EOD; public static function moveUpCategory($id) { $em = Database::getManager(); + /** @var CLpCategory $item */ $item = $em->find('ChamiloCourseBundle:CLpCategory', $id); if ($item) { $position = $item->getPosition() - 1; @@ -10075,6 +10076,7 @@ EOD; public static function moveDownCategory($id) { $em = Database::getManager(); + /** @var CLpCategory $item */ $item = $em->find('ChamiloCourseBundle:CLpCategory', $id); if ($item) { $position = $item->getPosition() + 1; @@ -10114,7 +10116,7 @@ EOD; array('name' => 'ASC') );*/ - //Using doctrine extensions + // Using doctrine extensions $items = $em->getRepository('ChamiloCourseBundle:CLpCategory')->getBySortableGroupsQuery( array('cId' => $courseId) )->getResult(); diff --git a/main/newscorm/lp_add_category.php b/main/newscorm/lp_add_category.php index f3346f230b..9999ac037b 100644 --- a/main/newscorm/lp_add_category.php +++ b/main/newscorm/lp_add_category.php @@ -12,68 +12,36 @@ api_protect_course_script(); require 'learnpath_functions.inc.php'; require 'resourcelinker.inc.php'; -$language_file = 'learnpath'; - -/* Header and action code */ - -$currentstyle = api_get_setting('stylesheets'); -$htmlHeadXtra[] = ''; - -/* Constants and variables */ - $is_allowed_to_edit = api_is_allowed_to_edit(null, true); -$isStudentView = isset($_REQUEST['isStudentView']) ? $_REQUEST['isStudentView'] : null; -$learnpath_id = isset($_REQUEST['lp_id']) ? $_REQUEST['lp_id'] : null; - -/* MAIN CODE */ - -if ((!$is_allowed_to_edit) || ($isStudentView)) { - //error_log('New LP - User not authorized in lp_add.php'); - header('location:lp_controller.php?action=view&lp_id='.$learnpath_id); +if (!$is_allowed_to_edit) { + header('location:lp_controller.php?action=list&'.api_get_cidreq()); exit; } -$interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => get_lang('LearningPaths')); +$interbreadcrumb[] = array( + 'url' => 'lp_controller.php?action=list?'.api_get_cidreq(), + 'name' => get_lang('LearningPaths'), +); -$form = new FormValidator('lp_add_category', 'post', 'lp_controller.php'); +$form = new FormValidator( + 'lp_add_category', + 'post', + 'lp_controller.php?'.api_get_cidreq() +); // Form title $form->addElement('header', null, get_lang('AddLPCategory')); // Title -$form->addElement('text', 'name', api_ucfirst(get_lang('Name')), array('class' => 'span6')); +$form->addElement('text', 'name', api_ucfirst(get_lang('Name'))); $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required'); $form->addElement('hidden', 'action', 'add_lp_category'); $form->addElement('hidden', 'c_id', api_get_course_int_id()); $form->addElement('hidden', 'id', 0); -$form->addElement('style_submit_button', 'Submit', get_lang('Save'),'class="save"'); +$form->addButtonSave(get_lang('Save')); if ($form->validate()) { $values = $form->getSubmitValues(); diff --git a/src/Chamilo/CourseBundle/Entity/CLpCategory.php b/src/Chamilo/CourseBundle/Entity/CLpCategory.php index 7367a998af..62cb2d8af3 100644 --- a/src/Chamilo/CourseBundle/Entity/CLpCategory.php +++ b/src/Chamilo/CourseBundle/Entity/CLpCategory.php @@ -19,7 +19,7 @@ class CLpCategory * * @ORM\Column(name="iid", type="integer") * @ORM\Id - * @ORM\GeneratedValue(strategy="AUTO") + * @ORM\GeneratedValue */ private $iid; @@ -51,6 +51,7 @@ class CLpCategory public function setCId($cId) { $this->cId = $cId; + return $this; } @@ -111,11 +112,19 @@ class CLpCategory return $this->name; } + /** + * @param int $position + */ public function setPosition($position) { $this->position = $position; + + return $this; } + /** + * @return int + */ public function getPosition() { return $this->position;