Minor - fix queries due recent changes in the entities

pull/2650/head
Julio Montoya 7 years ago
parent b5d55fbe32
commit dd9166f822
  1. 4
      main/inc/ajax/user_manager.ajax.php
  2. 10
      main/inc/lib/sessionmanager.lib.php
  3. 18
      src/CoreBundle/Entity/SessionRelCourseRelUser.php
  4. 12
      src/CoreBundle/Repository/CourseCategoryRepository.php
  5. 14
      src/UserBundle/Repository/UserRepository.php

@ -294,8 +294,8 @@ switch ($action) {
if (api_is_multiple_url_enabled()) {
$qb
->innerJoin('ChamiloCoreBundle:AccessUrlRelUser', 'uru', Join::WITH, 'u.userId = uru.userId')
->andWhere('uru.accessUrlId = '.$urlId);
->innerJoin('ChamiloCoreBundle:AccessUrlRelUser', 'uru', Join::WITH, 'u.id = uru.user')
->andWhere('uru.url = '.$urlId);
}
$qb

@ -3416,10 +3416,10 @@ class SessionManager
$noCoach = false
) {
// Definition of variables
$userId = intval($userId);
$userId = (int) $userId;
$sessionId = !empty($sessionId) ? intval($sessionId) : api_get_session_id();
$courseId = !empty($courseId) ? intval($courseId) : api_get_course_id();
$sessionId = !empty($sessionId) ? (int) $sessionId : api_get_session_id();
$courseId = !empty($courseId) ? (int) $courseId : api_get_course_id();
if (empty($sessionId) || empty($courseId) || empty($userId)) {
return false;
@ -3498,8 +3498,8 @@ class SessionManager
return Database::affected_rows($result) > 0;
}
$sql = "INSERT INTO $tblSessionRelCourseRelUser(session_id, c_id, user_id, status)
VALUES($sessionId, $courseId, $userId, 2)";
$sql = "INSERT INTO $tblSessionRelCourseRelUser(session_id, c_id, user_id, status, visibility)
VALUES($sessionId, $courseId, $userId, 2, 1)";
$result = Database::query($sql);
return Database::affected_rows($result) > 0;

@ -99,11 +99,15 @@ class SessionRelCourseRelUser
}
/**
* @param mixed $user
* @param $user
*
* @return $this
*/
public function setUser($user)
{
$this->user = $user;
return $this;
}
/**
@ -116,10 +120,14 @@ class SessionRelCourseRelUser
/**
* @param Session $session
*
* @return $this
*/
public function setSession($session)
{
$this->session = $session;
return $this;
}
/**
@ -132,10 +140,14 @@ class SessionRelCourseRelUser
/**
* @param Course $course
*
* @return $this
*/
public function setCourse($course)
{
$this->course = $course;
return $this;
}
/**
@ -201,7 +213,7 @@ class SessionRelCourseRelUser
*
* @param int $legalAgreement
*
* @return SessionRelCourseRelUser
* @return $this
*/
public function setLegalAgreement($legalAgreement)
{
@ -215,7 +227,7 @@ class SessionRelCourseRelUser
*
* @return int
*/
public function getLegalAgreement()
public function getLegalAgreement(): int
{
return $this->legalAgreement;
}

@ -29,14 +29,14 @@ class CourseCategoryRepository extends EntityRepository
'ChamiloCoreBundle:AccessUrlRelCourseCategory',
'a',
Join::WITH,
'c = a.courseCategoryId'
'c = a.courseCategory'
)
->where($qb->expr()->eq('a.accessUrlId', $accessUrl))
->where($qb->expr()->eq('a.url', $accessUrl))
->orderBy('c.treePos', 'ASC')
;
if ($allowBaseCategories) {
$qb->orWhere($qb->expr()->eq('a.accessUrlId', 1));
$qb->orWhere($qb->expr()->eq('a.url', 1));
}
$query = $qb->getQuery();
@ -60,14 +60,14 @@ class CourseCategoryRepository extends EntityRepository
'ChamiloCoreBundle:AccessUrlRelCourseCategory',
'a',
Join::WITH,
'c = a.courseCategoryId'
'c = a.courseCategory'
)
->where(
$qb->expr()->eq('a.accessUrlId', $accessUrl)
$qb->expr()->eq('a.url', $accessUrl)
);
if ($allowBaseCategories) {
$qb->orWhere($qb->expr()->eq('a.accessUrlId', 1));
$qb->orWhere($qb->expr()->eq('a.url', 1));
}
$count = $qb->getQuery()->getSingleScalarResult();

@ -190,8 +190,8 @@ class UserRepository extends EntityRepository
$queryBuilder->innerJoin(
'ChamiloCoreBundle:AccessUrlRelUser',
'auru',
\Doctrine\ORM\Query\Expr\Join::WITH,
'u.id = auru.userId'
Join::WITH,
'u.id = auru.user'
);
}
@ -201,7 +201,7 @@ class UserRepository extends EntityRepository
->setParameter('query', "$query%");
if ($accessUrlId > 0) {
$queryBuilder->andWhere('auru.accessUrlId = :url')
$queryBuilder->andWhere('auru.url = :url')
->setParameter(':url', $accessUrlId);
}
@ -430,7 +430,7 @@ class UserRepository extends EntityRepository
U.active = 1 AND
U.status != 6 AND
U.id != $currentUserId AND
R.portal = $accessUrlId";
R.url = $accessUrlId";
} else {
$dql = "SELECT DISTINCT U
FROM ChamiloCoreBundle:AccessUrlRelUser R, ChamiloCoreBundle:UserRelUser UF
@ -443,7 +443,7 @@ class UserRepository extends EntityRepository
UF.userId = $currentUserId AND
UF.friendUserId != $currentUserId AND
U = R.user AND
R.portal = $accessUrlId";
R.url = $accessUrlId";
}
} elseif (
api_get_setting('allow_social_tool') === 'false' &&
@ -458,7 +458,7 @@ class UserRepository extends EntityRepository
U.active = 1 AND
U.status != 6 AND
U.id != $currentUserId AND
R.portal = $accessUrlId";
R.url = $accessUrlId";
} else {
$time_limit = api_get_setting('time_limit_whosonline');
$online_time = time() - $time_limit * 60;
@ -1228,7 +1228,7 @@ class UserRepository extends EntityRepository
$list = [];
/** @var AccessUrlRelUser $portal */
foreach ($portals as $portal) {
$portalInfo = \UrlManager::get_url_data_from_id($portal->getAccessUrlId());
$portalInfo = \UrlManager::get_url_data_from_id($portal->getUrl()->getId());
$list[] = $portalInfo['url'];
}
}

Loading…
Cancel
Save