Refactor code, move code inside CoreBundle

pull/3262/head
Julio Montoya 5 years ago
parent a75e82ac08
commit c40939da44
  1. 2
      public/main/inc/lib/add_course.lib.inc.php
  2. 11
      public/main/inc/lib/api.lib.php
  3. 80
      public/main/inc/lib/usermanager.lib.php
  4. 11
      public/main/webservices/api/tests/SaveUserTest.php
  5. 1
      src/CoreBundle/Controller/Admin/AdminController.php
  6. 1
      src/CoreBundle/Controller/CourseHomeController.php
  7. 10
      src/CoreBundle/Controller/ResourceApiController.php
  8. 6
      src/CoreBundle/Entity/AbstractResource.php
  9. 13
      src/CoreBundle/Entity/AccessUrl.php
  10. 9
      src/CoreBundle/Entity/Course.php
  11. 1
      src/CoreBundle/Entity/CourseCategory.php
  12. 4
      src/CoreBundle/Entity/CourseRelUser.php
  13. 2
      src/CoreBundle/Entity/Illustration.php
  14. 3
      src/CoreBundle/Entity/Listener/CourseListener.php
  15. 5
      src/CoreBundle/Entity/Listener/ResourceListener.php
  16. 3
      src/CoreBundle/Entity/Listener/SessionListener.php
  17. 2
      src/CoreBundle/Entity/PersonalFile.php
  18. 1
      src/CoreBundle/Entity/ResourceComment.php
  19. 12
      src/CoreBundle/Entity/ResourceFile.php
  20. 9
      src/CoreBundle/Entity/ResourceLink.php
  21. 11
      src/CoreBundle/Entity/ResourceNode.php
  22. 1
      src/CoreBundle/Entity/ResourceType.php
  23. 12
      src/CoreBundle/Entity/Session.php
  24. 1
      src/CoreBundle/Entity/SessionCategory.php
  25. 2
      src/CoreBundle/Entity/Ticket.php
  26. 1
      src/CoreBundle/Entity/TicketAssignedLog.php
  27. 1
      src/CoreBundle/Entity/Tool.php
  28. 31
      src/CoreBundle/Entity/User.php
  29. 5
      src/CoreBundle/EventListener/CourseAccessListener.php
  30. 4
      src/CoreBundle/EventListener/CourseListener.php
  31. 2
      src/CoreBundle/EventListener/SessionAccessListener.php
  32. 5
      src/CoreBundle/EventSubscriber/ResolveResourceFileContentUrlSubscriber.php
  33. 2
      src/CoreBundle/Repository/IllustrationRepository.php
  34. 38
      src/CoreBundle/Repository/ResourceRepository.php
  35. 38
      src/CoreBundle/Repository/UserRepository.php
  36. 2
      src/CoreBundle/Resources/config/repositories.yml
  37. 30
      src/CoreBundle/Resources/config/services.yml
  38. 6
      src/CoreBundle/ToolChain.php
  39. 8
      src/CourseBundle/Entity/CDocument.php
  40. 2
      src/CourseBundle/Entity/CExerciseCategory.php
  41. 2
      src/CourseBundle/Entity/CGroupInfo.php
  42. 2
      src/CourseBundle/Entity/CQuiz.php
  43. 2
      src/CourseBundle/Entity/CTool.php
  44. 2
      src/CourseBundle/Repository/CForumPostRepository.php
  45. 2
      src/CourseBundle/Repository/CShortcutRepository.php
  46. 28
      src/CourseBundle/Resources/config/services.yml
  47. 11
      tests/datafiller/data_users.php
  48. 30
      tests/scripts/migrate_item_property.php

@ -831,7 +831,7 @@ class AddCourse
}
// Adding the course to an URL.
UrlManager::add_course_to_url($course_id, $accessUrlId);
//UrlManager::add_course_to_url($course_id, $accessUrlId);
// Add event to the system log.
$user_id = api_get_user_id();

@ -1689,7 +1689,12 @@ function api_get_user_info_from_entity(
$result['registration_date'] = $user->getRegistrationDate()->format('Y-m-d H:i:s');
$result['hr_dept_id'] = $user->getHrDeptId();
$result['expiration_date'] = $user->getExpirationDate()->format('Y-m-d H:i:s');
$result['last_login'] = $user->getLastLogin()->format('Y-m-d H:i:s');
$result['last_login'] = null;
if ($user->getLastLogin()) {
$result['last_login'] = $user->getLastLogin()->format('Y-m-d H:i:s');
}
$result['competences'] = $user->getCompetences();
$result['diplomas'] = $user->getDiplomas();
$result['teach'] = $user->getTeach();
@ -3846,12 +3851,12 @@ function api_not_allowed(
$message = null,
$responseCode = 0
) {
throw new Exception('You are not allowed');
/*throw new Exception('You are not allowed');
$message = empty($message) ? get_lang('You are not allowed') : $message;
Session::write('error_message', $message);
header('Location: '.api_get_path(WEB_PUBLIC_PATH).'error');
exit;
exit;*/
}
/**

@ -2,7 +2,7 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\ExtraField as EntityExtraField;
use Chamilo\CoreBundle\Entity\Resource\ResourceNode;
use Chamilo\CoreBundle\Entity\ResourceNode;
use Chamilo\CoreBundle\Entity\SkillRelUser;
use Chamilo\CoreBundle\Entity\SkillRelUserComment;
use Chamilo\CoreBundle\Framework\Container;
@ -63,7 +63,6 @@ class UserManager
* Create/update/delete methods are available in the UserManager
* (based in the Sonata\UserBundle\Entity\UserManager).
*
* @return \Sonata\UserBundle\Entity\UserManager
*/
public static function getManager()
{
@ -311,10 +310,7 @@ class UserManager
}
$userManager = self::getManager();
/** @var User $user */
$user = $userManager->createUser();
$user = new User();
$user
->setLastname($lastName)
->setFirstname($firstName)
@ -339,48 +335,48 @@ class UserManager
$user->setExpirationDate($expirationDate);
}
try {
$factory = Container::$container->get('Chamilo\CoreBundle\Repository\ResourceFactory');
$repo = $factory->createRepository('global', 'users');
$userManager->updateUser($user);
$em = Database::getManager();
$repo = Container::$container->get('Chamilo\CoreBundle\Repository\UserRepository');
$repo->updateUser($user, false);
/*$factory = Container::$container->get('Chamilo\CoreBundle\Repository\ResourceFactory');
$repo = $factory->createRepository('global', 'users');*/
// Add user as a node
if ($addUserToNode) {
$resourceNode = new ResourceNode();
$resourceNode
->setTitle($loginName)
->setCreator(api_get_user_entity($creatorId))
->setResourceType($repo->getResourceType())
// ->setParent($url->getResourceNode())
;
$em->persist($resourceNode);
$user->setResourceNode($resourceNode);
}
// Add user as a node
if ($addUserToNode) {
$resourceNode = new ResourceNode();
$resourceNode
->setTitle($loginName)
->setCreator(api_get_user_entity($creatorId))
->setResourceType($repo->getResourceType())
// ->setParent($url->getResourceNode())
;
$repo->getEntityManager()->persist($resourceNode);
$user->setResourceNode($resourceNode);
}
$em->persist($user);
$em->flush($user);
$repo->getEntityManager()->persist($user);
$userId = $user->getId();
$userId = $user->getId();
// Add user to a group
$statusToGroup = [
COURSEMANAGER => 'TEACHER',
STUDENT => 'STUDENT',
DRH => 'RRHH',
SESSIONADMIN => 'SESSION_ADMIN',
STUDENT_BOSS => 'STUDENT_BOSS',
INVITEE => 'INVITEE',
];
// Add user to a group
$statusToGroup = [
COURSEMANAGER => 'TEACHER',
STUDENT => 'STUDENT',
DRH => 'RRHH',
SESSIONADMIN => 'SESSION_ADMIN',
STUDENT_BOSS => 'STUDENT_BOSS',
INVITEE => 'INVITEE',
];
$group = Container::$container->get('Chamilo\CoreBundle\Repository\GroupRepository')->findOneBy(['code' => $statusToGroup[$status]]);
if ($group) {
$user->addGroup($group);
$repo->updateUser($user);
}
$group = Container::$container->get('Chamilo\CoreBundle\Repository\GroupRepository')->findOneBy(['code' => $statusToGroup[$status]]);
if ($group) {
$user->addGroup($group);
$userManager->updateUser($user);
}
$em->flush();
$repo->getEntityManager()->flush();
} catch (Exception $e) {
error_log($e->getMessage());
}
if (!empty($userId)) {
$return = $userId;
$sql = "UPDATE $table_user SET user_id = $return WHERE id = $return";

@ -2,7 +2,7 @@
/* For licensing terms, see /license.txt */
require_once __DIR__.'/V2TestCase.php';
require_once __DIR__.'/../../../../vendor/autoload.php';
require_once __DIR__.'/../../../../../vendor/autoload.php';
/**
* Class SaveUserTest
@ -28,11 +28,12 @@ class SaveUserTest extends V2TestCase
$loginName = 'testUser'.time();
$email = 'testUser@local';
$status = 5;
$userId = $this->integer(
[
'loginname' => $loginName,
'firstname' => 'Małgorzata',
'lastname' => 'Summer',
'firstname' => $loginName,
'lastname' => $loginName,
'original_user_id_name' => 'external_user_id',
'original_user_id_value' => $loginName,
'email' => $email,
@ -74,8 +75,8 @@ class SaveUserTest extends V2TestCase
'original_user_id_value' => $loginName,
'status' => 5,
'password' => 'test',
'firstname' => 'Małgorzata',
'lastname' => 'Summer',
'firstname' => $loginName,
'lastname' => $loginName,
'extra' => [
['field_name' => $extraFieldName, 'field_value' => $extraFieldOriginalValue],
],

@ -11,6 +11,7 @@ use Symfony\Component\Routing\Annotation\Route;
/**
* Class Administrator.
*
* @Route("/admin")
*/
class AdminController extends BaseController

@ -120,7 +120,6 @@ class CourseHomeController extends ToolBaseController
'tool'
);
$result = $qb->getQuery()->getResult();
$tools = [];
/** @var CTool $item */
foreach ($result as $item) {

@ -34,9 +34,6 @@ class ResourceApiController extends AbstractController implements CourseControll
use ResourceControllerTrait;
use ControllerTrait;
/**
*
*/
public function getResourcesListAction($id, Request $request)
{
$repository = $this->getRepositoryFromRequest($request);
@ -57,9 +54,6 @@ class ResourceApiController extends AbstractController implements CourseControll
return $qb->getQuery()->getResult();
}
/**
*
*/
public function getResourceAction($id, Request $request)
{
$repository = $this->getRepositoryFromRequest($request);
@ -71,8 +65,6 @@ class ResourceApiController extends AbstractController implements CourseControll
return $resource;
}
/**
*/
public function getResourceCommentsAction($id, Request $request, $paramFetcher)
{
$repository = $this->getRepositoryFromRequest($request);
@ -87,8 +79,6 @@ class ResourceApiController extends AbstractController implements CourseControll
return $resource->getResourceNode()->getComments()->matching($criteria);
}
/**
*/
public function postResourceCommentAction($id, Request $request)
{
$repository = $this->getRepositoryFromRequest($request);

@ -6,8 +6,6 @@ namespace Chamilo\CoreBundle\Entity;
use ApiPlatform\Core\Annotation\ApiSubresource;
use APY\DataGridBundle\Grid\Mapping as GRID;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\Session;
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
@ -27,9 +25,7 @@ abstract class AbstractResource
* @ApiSubresource()
* @Groups({"resource_node:read", "resource_node:write", "document:read","document:write"})
* @GRID\Column(field="resourceNode.createdAt", title="Date added", type="datetime")
* @ORM\OneToOne(
* targetEntity="Chamilo\CoreBundle\Entity\ResourceNode", cascade={"remove"}, orphanRemoval=true
* )
* @ORM\OneToOne(targetEntity="Chamilo\CoreBundle\Entity\ResourceNode", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\JoinColumn(name="resource_node_id", referencedColumnName="id", onDelete="CASCADE")
*/
public $resourceNode;

@ -4,14 +4,18 @@
namespace Chamilo\CoreBundle\Entity;
use Chamilo\CoreBundle\Entity\AbstractResource;
use Chamilo\CoreBundle\Entity\ResourceInterface;
use ApiPlatform\Core\Annotation\ApiResource;
use Chamilo\CoreBundle\Traits\CourseTrait;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
/**
* AccessUrl.
* @ApiResource(
* normalizationContext={"groups"={"access_url:read"}, "swagger_definition_name"="Read"},
* denormalizationContext={"groups"={"access_url:write","course_category:write"}},
* )
*
* @Gedmo\Tree(type="nested")
* @ORM\Table(name="access_url")
@ -109,6 +113,9 @@ class AccessUrl extends AbstractResource implements ResourceInterface
/**
* @var string
* @Assert\NotBlank()
*
* @Groups({"access_url:read", "access_url:write"})
*
* @ORM\Column(name="url", type="string", length=255, nullable=false, unique=false)
*/

@ -11,9 +11,6 @@ use ApiPlatform\Core\Annotation\ApiSubresource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
use Chamilo\CoreBundle\Entity\AbstractResource;
use Chamilo\CoreBundle\Entity\ResourceInterface;
use Chamilo\CoreBundle\Entity\ResourceLink;
use Chamilo\CourseBundle\Entity\CGroupInfo;
use Chamilo\CourseBundle\Entity\CTool;
use Doctrine\Common\Collections\ArrayCollection;
@ -98,7 +95,7 @@ class Course extends AbstractResource implements ResourceInterface
* @var CourseRelUser[]|ArrayCollection
*
* @ApiSubresource()
*
* @Groups({"course:read"})
* "orphanRemoval" is needed to delete the CourseRelUser relation
* in the CourseAdmin class. The setUsers, getUsers, removeUsers and
* addUsers methods need to be added.
@ -431,11 +428,11 @@ class Course extends AbstractResource implements ResourceInterface
public function setTools($tools)
{
foreach ($tools as $tool) {
$this->addTools($tool);
$this->addTool($tool);
}
}
public function addTools(CTool $tool)
public function addTool(CTool $tool)
{
$tool->setCourse($this);
$this->tools[] = $tool;

@ -16,6 +16,7 @@ use Symfony\Component\Validator\Constraints as Assert;
/**
* CourseCategory.
*
* @ApiResource(
* normalizationContext={"groups"={"course_category:read", "course:read"}, "swagger_definition_name"="Read"},
* denormalizationContext={"groups"={"course_category:write", "course:write"}},

@ -13,7 +13,6 @@ use Symfony\Component\Serializer\Annotation\Groups;
*
* @ApiResource(
* shortName="CourseSubscription",
* attributes={"security"="is_granted('ROLE_ADMIN')"},
* normalizationContext={"groups"={"course_rel_user:read"}}
* )
*
@ -25,7 +24,6 @@ use Symfony\Component\Serializer\Annotation\Groups;
* }
* )
* @ORM\Entity
* @ORM\Table(name="course_rel_user")
*/
class CourseRelUser
{
@ -39,6 +37,8 @@ class CourseRelUser
protected $id;
/**
* @Groups({"course:read"})
*
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\User", inversedBy="courses", cascade={"persist"})
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/

@ -6,8 +6,6 @@ namespace Chamilo\CoreBundle\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use APY\DataGridBundle\Grid\Mapping as GRID;
use Chamilo\CoreBundle\Entity\AbstractResource;
use Chamilo\CoreBundle\Entity\ResourceInterface;
use Chamilo\CourseBundle\Traits\PersonalResourceTrait;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;

@ -61,8 +61,6 @@ class CourseListener
//$url = $course->getCurrentUrl();
//$repo = $args->getEntityManager()->getRepository('ChamiloCoreBundle:Course');
///$this->checkLimit($repo, $course, $url);
///
// $repo = $args->getEntityManager()->getRepository('ChamiloCoreBundle:Course');
$this->toolChain->addToolsInCourse($this->toolRepository, $course);
}
}
@ -71,6 +69,7 @@ class CourseListener
{
/** @var AccessUrlRelCourse $urlRelCourse */
if ($course) {
/*$urlRelCourse = $course->getUrls()->first();
$url = $urlRelCourse->getUrl();*/
//$url = $course->getCurrentUrl();

@ -5,6 +5,7 @@
namespace Chamilo\CoreBundle\Entity\Listener;
use Chamilo\CoreBundle\Entity\AbstractResource;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\ResourceNode;
use Chamilo\CoreBundle\ToolChain;
use Cocur\Slugify\SlugifyInterface;
@ -34,6 +35,10 @@ class ResourceListener
public function prePersist(AbstractResource $resource, LifecycleEventArgs $args)
{
if (!$resource instanceof Course) {
return true;
}
// Add resource node
$em = $args->getEntityManager();
$id = $this->request->getCurrentRequest()->getSession()->get('access_url_id');

@ -5,11 +5,8 @@
namespace Chamilo\CoreBundle\Entity\Listener;
use Chamilo\CoreBundle\Entity\AccessUrl;
use Chamilo\CoreBundle\Entity\AccessUrlRelSession;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Repository\SessionRepository;
use Chamilo\CoreBundle\ToolChain;
use Cocur\Slugify\SlugifyInterface;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Core\Security;

@ -5,8 +5,6 @@
namespace Chamilo\CoreBundle\Entity;
use APY\DataGridBundle\Grid\Mapping as GRID;
use Chamilo\CoreBundle\Entity\AbstractResource;
use Chamilo\CoreBundle\Entity\ResourceInterface;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;

@ -5,7 +5,6 @@
namespace Chamilo\CoreBundle\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Traits\TimestampableAgoTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;

@ -10,6 +10,7 @@ use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
use Chamilo\CoreBundle\Controller\CreateResourceFileAction;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Symfony\Component\HttpFoundation\File\File;
@ -17,7 +18,6 @@ use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Chamilo\CoreBundle\Controller\CreateResourceFileAction;
//
//* attributes={"security"="is_granted('ROLE_ADMIN')"},
@ -414,20 +414,12 @@ class ResourceFile
}
}
/**
* @return string|null
*/
public function getContentUrl(): ?string
{
return $this->contentUrl;
}
/**
* @param string|null $contentUrl
*
* @return ResourceFile
*/
public function setContentUrl(?string $contentUrl): ResourceFile
public function setContentUrl(?string $contentUrl): self
{
$this->contentUrl = $contentUrl;

@ -12,8 +12,8 @@ use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* normalizationContext={"groups"={"resource_link:read", "course:read"}},
*
* shortName="ResourceLink",
* normalizationContext={"groups"={"resource_link:read", "course:read"}}
* )
* @ORM\Entity
* @ORM\Table(name="resource_link")
@ -28,12 +28,12 @@ class ResourceLink
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\GeneratedValue
*/
protected $id;
/**
* @Groups({"resource_link:read", "resource_node:read", "course:read"})
*
*
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\ResourceNode", inversedBy="resourceLinks")
* @ORM\JoinColumn(name="resource_node_id", referencedColumnName="id", onDelete="SET NULL")
@ -41,7 +41,6 @@ class ResourceLink
protected $resourceNode;
/**
* @Groups({"resource_link:read", "resource_node:read", "course:read"})
*
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course", inversedBy="resourceLinks")
* @ORM\JoinColumn(name="c_id", referencedColumnName="id", nullable=true)

@ -5,14 +5,11 @@
namespace Chamilo\CoreBundle\Entity;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Annotation\ApiSubresource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Traits\TimestampableAgoTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Criteria;
@ -73,8 +70,6 @@ class ResourceNode
protected $slug;
/**
* @Groups({"resource_node:read", "resource_node:write"})
*
* @ORM\ManyToOne(targetEntity="ResourceType")
* @ORM\JoinColumn(name="resource_type_id", referencedColumnName="id", nullable=false)
*/
@ -85,7 +80,7 @@ class ResourceNode
*
* @var ResourceLink[]
*
* @ORM\OneToMany(targetEntity="ResourceLink", mappedBy="resourceNode", cascade={"remove"})
* @ORM\OneToMany(targetEntity="ResourceLink", mappedBy="resourceNode", cascade={"persist", "remove"})
*/
protected $resourceLinks;
@ -111,6 +106,9 @@ class ResourceNode
protected $creator;
/**
* @ApiSubresource()
*
* @Groups({"resource_node:read", "document:read"})
* @Gedmo\TreeParent
* @ORM\ManyToOne(
* targetEntity="ResourceNode",
@ -139,6 +137,7 @@ class ResourceNode
protected $children;
/**
* @Groups({"resource_node:read", "document:read"})
* @Gedmo\TreePath(appendId=true,separator="`")
*
* @ORM\Column(name="path", type="text", nullable=true)

@ -4,7 +4,6 @@
namespace Chamilo\CoreBundle\Entity;
use Chamilo\CoreBundle\Entity\Tool;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Symfony\Component\Validator\Constraints as Assert;

@ -1290,28 +1290,18 @@ class Session
return $this;
}
/**
* @return User
*/
public function getSessionAdmin(): User
{
return $this->sessionAdmin;
}
/**
* @param User $sessionAdmin
*
* @return Session
*/
public function setSessionAdmin(User $sessionAdmin): Session
public function setSessionAdmin(User $sessionAdmin): self
{
$this->sessionAdmin = $sessionAdmin;
return $this;
}
public function isUserGeneralCoach(User $user): bool
{
$generalCoach = $this->getGeneralCoach();

@ -10,6 +10,7 @@ use Symfony\Component\Serializer\Annotation\Groups;
/**
* SessionCategory.
*
* @ApiResource(
* normalizationContext={"groups"={"session_category:read"}, "swagger_definition_name"="Read"},
* denormalizationContext={"groups"={"session_category:write"}},

@ -4,8 +4,6 @@
namespace Chamilo\CoreBundle\Entity;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\Session;
use Doctrine\ORM\Mapping as ORM;
/**

@ -4,7 +4,6 @@
namespace Chamilo\CoreBundle\Entity;
use Chamilo\CoreBundle\Entity\User;
use Doctrine\ORM\Mapping as ORM;
/**

@ -4,7 +4,6 @@
namespace Chamilo\CoreBundle\Entity;
use Chamilo\CoreBundle\Entity\ResourceType;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\Mapping as ORM;

@ -10,7 +10,6 @@ use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Annotation\ApiSubresource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\BooleanFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use Chamilo\CoreBundle\Entity\ResourceNode;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Criteria;
@ -112,7 +111,7 @@ class User implements UserInterface, EquatableInterface
/**
* @var string
* @Groups({"user:read", "user:write"})
* @Groups({"user:read", "user:write", "course:read"})
* @Assert\NotBlank()
* @ORM\Column(name="username", type="string", length=100, nullable=false, unique=true)
*/
@ -582,8 +581,8 @@ class User implements UserInterface, EquatableInterface
$this->groups = new ArrayCollection();
//$this->extraFields = new ArrayCollection();
//$this->userId = 0;
//$this->createdAt = new \DateTime();
//$this->updatedAt = new \DateTime();
$this->createdAt = new \DateTime();
$this->updatedAt = new \DateTime();
$this->enabled = false;
$this->locked = false;
@ -1485,8 +1484,6 @@ class User implements UserInterface, EquatableInterface
return $this;
}
/**
* Set lastLogin.
*
@ -2125,40 +2122,24 @@ class User implements UserInterface, EquatableInterface
return $this;
}
/**
* @return string
*/
public function getWebsite(): string
{
return $this->website;
}
/**
* @param string $website
*
* @return User
*/
public function setWebsite(string $website): User
public function setWebsite(string $website): self
{
$this->website = $website;
return $this;
}
/**
* @return string
*/
public function getBiography(): string
{
return $this->biography;
}
/**
* @param string $biography
*
* @return User
*/
public function setBiography(string $biography): User
public function setBiography(string $biography): self
{
$this->biography = $biography;
@ -2174,6 +2155,4 @@ class User implements UserInterface, EquatableInterface
return $this->courseGroupsAsTutor->matching($criteria);
}
}

@ -2,11 +2,12 @@
/* For licensing terms, see /license.txt */
namespace Chamilo\CourseBundle\EventListener;
namespace Chamilo\CoreBundle\EventListener;
use Chamilo\CoreBundle\Entity\TrackECourseAccess;
use Chamilo\CourseBundle\Event\CourseAccess;
use Doctrine\ORM\EntityManager;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
/**
@ -19,7 +20,7 @@ class CourseAccessListener
protected $em;
/**
* @var \Symfony\Component\HttpFoundation\Request
* @var Request
*/
protected $request;

@ -2,7 +2,7 @@
/* For licensing terms, see /license.txt */
namespace Chamilo\CourseBundle\EventListener;
namespace Chamilo\CoreBundle\EventListener;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\User;
@ -73,6 +73,7 @@ class CourseListener
$courseFromSession = $sessionHandler->get('course');
if ($courseId === $courseFromSession->getId()) {
$course = $courseFromSession;
$courseInfo = $sessionHandler->get('_course');
}
}
@ -80,6 +81,7 @@ class CourseListener
/** @var EntityManager $em */
$em = $container->get('doctrine')->getManager();
$course = $em->getRepository('ChamiloCoreBundle:Course')->find($courseId);
//dump("get course from DB $courseId");
$courseInfo = api_get_course_info($course->getCode());
}

@ -2,7 +2,7 @@
/* For licensing terms, see /license.txt */
namespace Chamilo\CourseBundle\EventListener;
namespace Chamilo\CoreBundle\EventListener;
use Chamilo\CoreBundle\Entity\TrackECourseAccess;
use Chamilo\CourseBundle\Event\SessionAccess;

@ -6,13 +6,12 @@ namespace Chamilo\CoreBundle\EventSubscriber;
use ApiPlatform\Core\EventListener\EventPriorities;
use ApiPlatform\Core\Util\RequestAttributesExtractor;
use Chamilo\CoreBundle\Entity\Resource\ResourceFile;
use Chamilo\CoreBundle\Entity\ResourceFile;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\ViewEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\RouterInterface;
use Vich\UploaderBundle\Storage\StorageInterface;
class ResolveResourceFileContentUrlSubscriber implements EventSubscriberInterface
@ -65,8 +64,6 @@ class ResolveResourceFileContentUrlSubscriber implements EventSubscriberInterfac
];
$mediaObject->contentUrl = $this->generator->generate('chamilo_core_resource_view_file', $params);
//$mediaObject->contentUrl = $this->storage->resolveUri($mediaObject, 'file');
}
}
}

@ -6,9 +6,9 @@ namespace Chamilo\CoreBundle\Repository;
use APY\DataGridBundle\Grid\Column\Column;
use APY\DataGridBundle\Grid\Grid;
use Chamilo\CoreBundle\Entity\AbstractResource;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\Illustration;
use Chamilo\CoreBundle\Entity\AbstractResource;
use Chamilo\CoreBundle\Entity\ResourceFile;
use Chamilo\CoreBundle\Entity\ResourceNode;
use Chamilo\CoreBundle\Entity\Session;

@ -8,8 +8,8 @@ use APY\DataGridBundle\Grid\Action\RowAction;
use APY\DataGridBundle\Grid\Row;
use Chamilo\CoreBundle\Component\Resource\Settings;
use Chamilo\CoreBundle\Component\Resource\Template;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\AbstractResource;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\ResourceFile;
use Chamilo\CoreBundle\Entity\ResourceInterface;
use Chamilo\CoreBundle\Entity\ResourceLink;
@ -26,7 +26,6 @@ use Chamilo\CourseBundle\Entity\CGroupInfo;
use Cocur\Slugify\SlugifyInterface;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\EntityRepository as BaseEntityRepository;
use Doctrine\ORM\QueryBuilder;
use League\Flysystem\FilesystemInterface;
use Symfony\Component\Filesystem\Exception\FileNotFoundException;
@ -41,7 +40,7 @@ use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
* Class ResourceRepository.
* Extends EntityRepository is needed to process settings.
*/
class ResourceRepository extends BaseEntityRepository
class ResourceRepository extends EntityRepository
{
/**
* @var EntityRepository
@ -254,21 +253,21 @@ class ResourceRepository extends BaseEntityRepository
public function addResourceToCourse(AbstractResource $resource, int $visibility, User $creator, Course $course, Session $session = null, CGroupInfo $group = null, UploadedFile $file = null)
{
$node = $this->createNodeForResource($resource, $creator, $course->getResourceNode(), $file);
$resourceNode = $this->createNodeForResource($resource, $creator, $course->getResourceNode(), $file);
$this->addResourceNodeToCourse($node, $visibility, $course, $session, $group);
$this->addResourceNodeToCourse($resourceNode, $visibility, $course, $session, $group);
}
public function addResourceToCourseWithParent(AbstractResource $resource, ResourceNode $parentNode, int $visibility, User $creator, Course $course, Session $session = null, CGroupInfo $group = null, UploadedFile $file = null)
{
$node = $this->createNodeForResource($resource, $creator, $parentNode, $file);
$resourceNode = $this->createNodeForResource($resource, $creator, $parentNode, $file);
$this->addResourceNodeToCourse($node, $visibility, $course, $session, $group);
$this->addResourceNodeToCourse($resourceNode, $visibility, $course, $session, $group);
}
public function addResourceNodeToCourse(ResourceNode $resourceNode, int $visibility, Course $course, Session $session = null, CGroupInfo $group = null, User $toUser = null): void
{
if (empty($visibility)) {
if (0 === $visibility) {
$visibility = ResourceLink::VISIBILITY_PUBLISHED;
}
@ -304,15 +303,14 @@ class ResourceRepository extends BaseEntityRepository
}
$em = $this->getEntityManager();
$em->persist($resourceNode);
$em->persist($link);
}
public function addResourceToMe(ResourceNode $resourceNode): ResourceLink
{
$resourceLink = new ResourceLink();
$resourceLink
->setResourceNode($resourceNode)
;
$resourceLink->setResourceNode($resourceNode);
$this->getEntityManager()->persist($resourceLink);
$this->getEntityManager()->flush();
@ -353,15 +351,15 @@ class ResourceRepository extends BaseEntityRepository
return $resourceLink;
}
public function addResourceToCourseGroup(
ResourceNode $resourceNode,
CGroupInfo $group
) {
$exists = $resourceNode->getResourceLinks()->exists(function ($key, $element) use ($group) {
if ($element->getGroup()) {
return $group->getIid() == $element->getGroup()->getIid();
public function addResourceToCourseGroup(ResourceNode $resourceNode, CGroupInfo $group)
{
$exists = $resourceNode->getResourceLinks()->exists(
function ($key, $element) use ($group) {
if ($element->getGroup()) {
return $group->getIid() == $element->getGroup()->getIid();
}
}
});
);
if (false === $exists) {
$resourceLink = new ResourceLink();
@ -863,7 +861,6 @@ class ResourceRepository extends BaseEntityRepository
$em = $this->getEntityManager();
$resourceType = $this->getResourceType();
$resourceNode = new ResourceNode();
$resourceName = $resource->getResourceName();
$extension = $this->slugify->slugify(pathinfo($resourceName, PATHINFO_EXTENSION));
@ -875,6 +872,7 @@ class ResourceRepository extends BaseEntityRepository
$slug = sprintf('%s.%s', $this->slugify->slugify($originalBasename), $originalExtension);
}
$resourceNode = new ResourceNode();
$resourceNode
->setTitle($resourceName)
->setSlug($slug)

@ -16,6 +16,7 @@ use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Entity\SessionRelCourseRelUser;
use Chamilo\CoreBundle\Entity\SkillRelUser;
use Chamilo\CoreBundle\Entity\SkillRelUserComment;
use Chamilo\CoreBundle\Entity\Ticket;
use Chamilo\CoreBundle\Entity\TrackEAccess;
use Chamilo\CoreBundle\Entity\TrackEAttempt;
use Chamilo\CoreBundle\Entity\TrackECourseAccess;
@ -45,10 +46,10 @@ use Chamilo\CourseBundle\Entity\CStudentPublication;
use Chamilo\CourseBundle\Entity\CStudentPublicationComment;
use Chamilo\CourseBundle\Entity\CSurveyAnswer;
use Chamilo\CourseBundle\Entity\CWiki;
use Chamilo\CoreBundle\Entity\Ticket;
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\Query\Expr\Join;
use Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
use Symfony\Component\Security\Core\User\UserInterface;
@ -65,6 +66,16 @@ use Symfony\Component\Serializer\Serializer;
*/
class UserRepository extends ResourceRepository implements UserLoaderInterface, PasswordUpgraderInterface
{
/**
* @var UserPasswordEncoderInterface
*/
protected $encoder;
public function setEncoder(UserPasswordEncoderInterface $encoder){
$this->encoder = $encoder;
}
public function loadUserByUsername($username)
{
return $this->findBy(['username' => $username]);
@ -80,26 +91,35 @@ class UserRepository extends ResourceRepository implements UserLoaderInterface,
}
}
public function updateCanonicalFields(UserInterface $user)
public function canonicalize($string)
{
//$user->setUsernameCanonical($this->canonicalizeUsername($user->getUsername()));
//$user->setEmailCanonical($this->canonicalizeEmail($user->getEmail()));
$encoding = mb_detect_encoding($string);
$result = $encoding
? mb_convert_case($string, MB_CASE_LOWER, $encoding)
: mb_convert_case($string, MB_CASE_LOWER);
return $result;
}
public function updateCanonicalFields(UserInterface $user)
{
$user->setUsernameCanonical($this->canonicalize($user->getUsername()));
$user->setEmailCanonical($this->canonicalize($user->getEmail()));
}
/**
* {@inheritDoc}
*/
public function updatePassword(UserInterface $user)
{
//UserPasswordEncoderInterface $passwordEncoder
if (0 !== strlen($password = $user->getPlainPassword())) {
// $encoder = $this->getEncoder($user);
$password = $this->encoder->encodePassword($user, $password);
$user->setPassword($password);
$user->eraseCredentials();
// $encoder = $this->getEncoder($user);
//$user->setPassword($encoder->encodePassword($password, $user->getSalt()));
//$user->eraseCredentials();
}
}
public function upgradePassword(UserInterface $user, string $newEncodedPassword): void
{
// this code is only an example; the exact code will depend on

@ -34,5 +34,7 @@ services:
Chamilo\CoreBundle\Repository\UserRepository:
arguments:
$className: 'Chamilo\CoreBundle\Entity\User'
calls:
- [setEncoder, ['@security.user_password_encoder.generic']]
Chamilo\CoreBundle\Repository\GroupRepository: ~

@ -153,6 +153,36 @@ services:
tags:
- {name: doctrine.orm.entity_listener, entity_manager: default, lazy: true}
chamilo_course.listener.course:
class: Chamilo\CoreBundle\EventListener\CourseListener
calls:
- [setContainer, ['@service_container']]
tags:
- {name: kernel.event_listener, event: kernel.request, method: onKernelRequest, priority: 6}
- {name: kernel.event_listener, event: kernel.response, method: onKernelResponse}
- {name: kernel.event_listener, event: kernel.controller, method: onKernelController}
# Sets the user access in a course listener
chamilo_course.listener.course_access:
class: Chamilo\CoreBundle\EventListener\CourseAccessListener
arguments:
- '@doctrine.orm.entity_manager'
calls:
- [setRequest, ['@request_stack']]
tags:
- {name: kernel.event_listener, event: chamilo_course.course.access, method: onCourseAccessEvent}
# Sets the user access in a course session listener
chamilo_course.listener.session_access:
class: Chamilo\CoreBundle\EventListener\SessionAccessListener
arguments:
- '@doctrine.orm.entity_manager'
calls:
- [setRequest, ['@request_stack']]
tags:
- {name: kernel.event_listener, event: chamilo_course.course.session, method: onSessionAccessEvent}
# When Course entity is loaded
chamilo_core.listener.course:
class: Chamilo\CoreBundle\Entity\Listener\CourseListener

@ -170,10 +170,6 @@ class ToolChain
foreach ($tools as $tool) {
$visibility = in_array($tool->getName(), $toolVisibility, true);
$criteria = ['name' => $tool->getName()];
// Skip global tools.
/*if ($tool->isCourseTool() === false) {
continue;
}*/
if (!isset($toolList[$tool->getName()])) {
continue;
}
@ -190,7 +186,7 @@ class ToolChain
;
$toolRepository->addResourceToCourse($courseTool, ResourceLink::VISIBILITY_PUBLISHED, $user, $course);
$course->addTools($courseTool);
$course->addTool($courseTool);
}
return $course;

@ -5,21 +5,19 @@
namespace Chamilo\CourseBundle\Entity;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Annotation\ApiSubresource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
use APY\DataGridBundle\Grid\Mapping as GRID;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\AbstractResource;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\ResourceInterface;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CourseBundle\Traits\ShowCourseResourcesInSessionTrait;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
//* attributes={"security"="is_granted('ROLE_ADMIN')"},
/**
* @ApiResource(
@ -27,7 +25,7 @@ use Symfony\Component\Serializer\Annotation\Groups;
* normalizationContext={"groups"={"document:read", "resource_node:read"}},
* denormalizationContext={"groups"={"document:write"}}
* )
* @ApiFilter(SearchFilter::class, properties={"title": "partial", "resourceNode": "exact"})
* @ApiFilter(SearchFilter::class, properties={"title": "partial", "resourceNode.parent": "exact"})
* @ApiFilter(
* OrderFilter::class,
* properties={

@ -5,8 +5,8 @@
namespace Chamilo\CourseBundle\Entity;
use APY\DataGridBundle\Grid\Mapping as GRID;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\AbstractResource;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\ResourceInterface;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;

@ -4,8 +4,8 @@
namespace Chamilo\CourseBundle\Entity;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\AbstractResource;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\ResourceInterface;
use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Traits\CourseTrait;

@ -4,8 +4,8 @@
namespace Chamilo\CourseBundle\Entity;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\AbstractResource;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\ResourceInterface;
use Chamilo\CourseBundle\Traits\ShowCourseResourcesInSessionTrait;
use Doctrine\ORM\Event\LifecycleEventArgs;

@ -5,8 +5,8 @@
namespace Chamilo\CourseBundle\Entity;
use APY\DataGridBundle\Grid\Mapping as GRID;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\AbstractResource;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\ResourceInterface;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Entity\Tool;

@ -4,8 +4,8 @@
namespace Chamilo\CourseBundle\Repository;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\AbstractResource;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Repository\ResourceRepository;
use Chamilo\CourseBundle\Entity\CForumPost;

@ -4,8 +4,8 @@
namespace Chamilo\CourseBundle\Repository;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\AbstractResource;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\ResourceNode;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Entity\User;

@ -162,31 +162,3 @@ services:
$className: 'Chamilo\CourseBundle\Entity\CTool'
# Event Listeners
chamilo_course.listener.course:
class: Chamilo\CourseBundle\EventListener\CourseListener
calls:
- [setContainer, ['@service_container']]
tags:
- {name: kernel.event_listener, event: kernel.request, method: onKernelRequest, priority: 6}
- {name: kernel.event_listener, event: kernel.response, method: onKernelResponse}
- {name: kernel.event_listener, event: kernel.controller, method: onKernelController}
# Sets the user access in a course listener
chamilo_course.listener.course_access:
class: Chamilo\CourseBundle\EventListener\CourseAccessListener
arguments:
- '@doctrine.orm.entity_manager'
calls:
- [setRequest, ['@request_stack']]
tags:
- {name: kernel.event_listener, event: chamilo_course.course.access, method: onCourseAccessEvent}
# Sets the user access in a course session listener
chamilo_course.listener.session_access:
class: Chamilo\CourseBundle\EventListener\SessionAccessListener
arguments:
- '@doctrine.orm.entity_manager'
calls:
- [setRequest, ['@request_stack']]
tags:
- {name: kernel.event_listener, event: chamilo_course.course.session, method: onSessionAccessEvent}

@ -439,17 +439,6 @@ $users[] = [
'creator_id' => 1,
'active' => 1,
];
$users[] = [
'username' => 'mdolata',
'pass' => 'mdolata',
'firstname' => 'Małgorzata',
'lastname' => 'Summer',
'status' => 5,
'auth_source' => 'platform',
'email' => 'mdolata@example.com',
'creator_id' => 1,
'active' => 1,
];
$users[] = [
'username' => 'adaniel',
'pass' => 'adaniel',

@ -3,11 +3,11 @@
use Chamilo\CourseBundle\Entity\CDocument;
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CoreBundle\Entity\Resource\ResourceNode;
use Chamilo\CoreBundle\Entity\Resource\ResourceLink;
use Chamilo\CoreBundle\Entity\Resource\ResourceFile;
use Chamilo\CoreBundle\Entity\Resource\ResourceType;
use Chamilo\CoreBundle\Entity\Resource\ResourceRight;
use Chamilo\CoreBundle\Entity\ResourceNode;
use Chamilo\CoreBundle\Entity\ResourceLink;
use Chamilo\CoreBundle\Entity\ResourceFile;
use Chamilo\CoreBundle\Entity\ResourceType;
use Chamilo\CoreBundle\Entity\ResourceRight;
use Chamilo\MediaBundle\Entity\Media;
use Chamilo\CoreBundle\Security\Authorization\Voter\ResourceNodeVoter;
@ -25,10 +25,10 @@ echo 'change course id in the query';
require_once __DIR__.'/../../main/inc/global.inc.php';
$sql = "SELECT
d.id,
$sql = "SELECT
d.id,
d.c_id,
d.session_id,
d.session_id,
i.to_group_id,
i.to_user_id,
i.iid,
@ -36,18 +36,18 @@ $sql = "SELECT
insert_date,
lastedit_date,
tool,
visibility
FROM c_item_property i
INNER JOIN c_document d
ON (d.iid = i.ref AND i.c_id = d.c_id)
WHERE
i.tool = 'document' AND
visibility
FROM c_item_property i
INNER JOIN c_document d
ON (d.iid = i.ref AND i.c_id = d.c_id)
WHERE
i.tool = 'document' AND
d.c_id = 12
ORDER BY d.path";
$result = Database::query($sql);
$em = Database::getManager();
$resourceType = $em->getRepository('ChamiloCoreBundle:Resource\ResourceType')->findOneBy(['name' => 'document']);
$resourceType = $em->getRepository('ChamiloCoreBundle:ResourceType')->findOneBy(['name' => 'document']);
$coursePath = api_get_path(SYS_PATH).'app/courses/';
$mediaManager = Container::$container->get('sonata.media.manager.media');
$documentManager = $em->getRepository('ChamiloCourseBundle:CDocument');

Loading…
Cancel
Save