Fix category lp update see BT#5763

1.10.x
Julio Montoya 10 years ago
parent a667f5b11a
commit 1ea0bfe499
  1. 8
      main/newscorm/learnpath.class.php
  2. 13
      main/newscorm/lp_add_category.php
  3. 11
      src/Chamilo/CourseBundle/Entity/CLpCategory.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();

@ -19,15 +19,22 @@ if (!$is_allowed_to_edit) {
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');

@ -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;

Loading…
Cancel
Save