Skip to content

Commit

Permalink
Allow student boss to assign badges to users - Refs BT#10651
Browse files Browse the repository at this point in the history
  • Loading branch information
jloguercio committed Jul 1, 2016
1 parent 15b5921 commit d64d55d
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
2 changes: 1 addition & 1 deletion main/badge/assign.php
Expand Up @@ -13,7 +13,7 @@

require_once '../inc/global.inc.php';

if (!api_is_platform_admin(false, true)) {
if (!api_is_platform_admin(false, true) && !api_is_student_boss()) {
api_not_allowed(true);
}

Expand Down
6 changes: 6 additions & 0 deletions main/mySpace/myStudents.php
Expand Up @@ -356,6 +356,12 @@ function show_image(image,width,height) {
Display::return_icon('login_as.png', get_lang('LoginAs'), null, ICON_SIZE_MEDIUM).'</a>&nbsp;&nbsp;';
}

echo Display::url(
Display::return_icon('skill-badges.png', get_lang('AssignSkill'), null, ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH) . 'badge/assign.php?' . http_build_query(['user' => $student_id])
);


echo '</div>';

// is the user online ?
Expand Down
58 changes: 58 additions & 0 deletions src/Chamilo/UserBundle/Entity/Repository/UserRepository.php
Expand Up @@ -172,4 +172,62 @@ public function getCoachesForSessionCourse(Session $session, Course $course)

return $queryBuilder->getQuery()->getResult();
}

/**
* Get the sessions admins for a user
* @param \Chamilo\UserBundle\Entity\User $user The user
* @return array
*/
public function getSessionAdmins($user)
{
$queryBuilder = $this->createQueryBuilder('u');
$queryBuilder
->distinct()
->innerJoin(
'ChamiloCoreBundle:SessionRelUser',
'su',
Join::WITH,
$queryBuilder->expr()->eq('u', 'su.user')
)
->innerJoin(
'ChamiloCoreBundle:SessionRelCourseRelUser',
'scu',
Join::WITH,
$queryBuilder->expr()->eq('su.session', 'scu.session')
)
->where(
$queryBuilder->expr()->eq('scu.user', $user->getId())
)
->andWhere(
$queryBuilder->expr()->eq('su.relationType', SESSION_RELATION_TYPE_RRHH)
);

return $queryBuilder->getQuery()->getResult();
}

/**
* Get the student bosses for a user
* @param User $user The user
* @return array
*/
public function getStudentBosses($user)
{
$queryBuilder = $this->createQueryBuilder('u');
$queryBuilder
->distinct()
->innerJoin(
'ChamiloCoreBundle:UserRelUser',
'uu',
Join::WITH,
$queryBuilder->expr()->eq('u.id', 'uu.friendUserId')
)
->where(
$queryBuilder->expr()->eq('uu.relationType', USER_RELATION_TYPE_BOSS)
)
->andWhere(
$queryBuilder->expr()->eq('uu.userId', $user->getId())
);

return $queryBuilder->getQuery()->getResult();
}
}

0 comments on commit d64d55d

Please sign in to comment.