Add course as resource node, add resource node when adding a doc

pull/3016/head
Julio Montoya 5 years ago
parent ff6347b849
commit b75c6edda0
  1. 15
      main/inc/lib/add_course.lib.inc.php
  2. 2
      main/inc/lib/document.lib.php
  3. 7
      main/inc/lib/fileUpload.lib.php

@ -865,9 +865,8 @@ class AddCourse
$course_id = 0; $course_id = 0;
if ($ok_to_register_course) { if ($ok_to_register_course) {
$courseManager = Container::$container->get('chamilo_core.entity.manager.course_manager'); $repo = Container::getCourseRepository();
/** @var \Chamilo\CoreBundle\Entity\Course $course */ $course = new \Chamilo\CoreBundle\Entity\Course();
$course = $courseManager->create();
$urlId = 1; $urlId = 1;
if (api_get_current_access_url_id() !== -1) { if (api_get_current_access_url_id() !== -1) {
$urlId = api_get_current_access_url_id(); $urlId = api_get_current_access_url_id();
@ -886,7 +885,6 @@ class AddCourse
->setDiskQuota($disk_quota) ->setDiskQuota($disk_quota)
->setCreationDate(new \DateTime()) ->setCreationDate(new \DateTime())
->setExpirationDate(new \DateTime($expiration_date)) ->setExpirationDate(new \DateTime($expiration_date))
//->setLastEdit()
->setDepartmentName($department_name) ->setDepartmentName($department_name)
->setDepartmentUrl($department_url) ->setDepartmentUrl($department_url)
->setSubscribe($subscribe) ->setSubscribe($subscribe)
@ -894,11 +892,16 @@ class AddCourse
->setVisualCode($visual_code) ->setVisualCode($visual_code)
->addUrl($url) ->addUrl($url)
; ;
$repo->getEntityManager()->persist($course);
$courseManager->save($course, true); $repo->getEntityManager()->flush();
$course_id = $course->getId(); $course_id = $course->getId();
if ($course_id) { if ($course_id) {
$repo->addResourceNode(
$course,
api_get_user_entity(api_get_user_id()),
$url
);
$sort = api_max_sort_value('0', api_get_user_id()); $sort = api_max_sort_value('0', api_get_user_id());
// Default true // Default true
$addTeacher = isset($params['add_user_as_teacher']) ? $params['add_user_as_teacher'] : true; $addTeacher = isset($params['add_user_as_teacher']) ? $params['add_user_as_teacher'] : true;

@ -6338,7 +6338,7 @@ class DocumentManager
$readonly = (int) $readonly; $readonly = (int) $readonly;
$documentRepo = Container::getDocumentRepository(); $documentRepo = Container::getDocumentRepository();
$parentNode = null; $parentNode = $courseEntity;
if (!empty($parentId)) { if (!empty($parentId)) {
$parent = $documentRepo->find($parentId); $parent = $documentRepo->find($parentId);
if ($parent) { if ($parent) {

@ -1488,10 +1488,11 @@ function create_unexisting_directory(
$session_id $session_id
); );
$em = Database::getManager(); if ($documentData) {
$document = $em->getRepository('ChamiloCourseBundle:CDocument')->find($documentData['iid']); $document = Container::getDocumentRepository()->find($documentData['iid']);
return $document; return $document;
}
} }
return false; return false;

Loading…
Cancel
Save