Update entities name.

1.10.x
Julio Montoya 11 years ago
parent 6af9760bfa
commit f03c5fbe03
  1. 12
      main/inc/lib/api.lib.php
  2. 8
      main/inc/lib/events.lib.inc.php
  3. 15
      main/inc/lib/usermanager.lib.php

@ -10,7 +10,7 @@
use \ChamiloSession as Session;
use Symfony\Component\Validator\Constraints as Assert;
use ChamiloLMS\CoreBundle\Entity\User;
use ChamiloLMS\UserBundle\Entity\User;
use ChamiloLMS\CoreBundle\Entity\Course;
/**
@ -6949,3 +6949,13 @@ function api_is_unoconv_installed()
}
return false;
}
function api_get_role_name_from_status($status)
{
switch ($status) {
case COURSEMANAGER:
return 'ROLE_TEACHER';
case STUDENT:
return 'ROLE_STUDENT';
}
}

@ -2,6 +2,7 @@
/* See license terms in /license.txt */
/**
* EVENTS LIBRARY
* @ŧodo add listeners
*
* This is the events library for Chamilo.
* Include/require it in your code to use its functionality.
@ -11,7 +12,7 @@
*
* @package chamilo.library
*/
use ChamiloLMS\CoreBundle\Entity\User;
use Application\Sonata\UserBundle\Entity\User;
use ChamiloLMS\CoreBundle\Entity\Role;
/**
@ -35,13 +36,10 @@ function event_login(User $user)
)";
Database::query($sql);
$roles = $user->getRolesObj();
$roles = $user->getRoles();
// auto subscribe
/** @var Role $role */
foreach ($roles as $role) {
$role = $role->getRole();
$userStatusParsed = 'student';
switch ($role) {

@ -337,13 +337,13 @@ class UserManager
}
// Adding user
/** @var ChamiloLMS\Entity\User $user */
/** @var ChamiloLMS\UserBundle\Entity\User $user */
$em = Database::getManager();
$user = $em->getRepository('ChamiloLMSCoreBundle:User')->find($return);
$role = $em->getRepository('ChamiloLMSCoreBundle:Role')->find($status);
$user->getRolesObj()->add($role);
$roleName = api_get_role_name_from_status($status);
$user->addRole($roleName);
$em->persist($user);
$em->flush();
@ -791,13 +791,10 @@ class UserManager
}
// Adding user
/** @var ChamiloLMS\Entity\User $user */
$em = Database::getManager()
/** @var ChamiloLMS\UserBundle\Entity\User $user */
$em = Database::getManager();
$user = $em->getRepository('ChamiloLMSCoreBundle:User')->find($user_id);
$role = $em->getRepository('ChamiloLMSCoreBundle:Role')->find($status);
$user->getRolesObj()->remove(0);
$user->getRolesObj()->add($role);
$user->addRole(api_get_role_name_from_status($status));
$em->persist($user);
$em->flush();

Loading…
Cancel
Save