Add sessions list for platform admins (other than session creators) in certificates report - refs BT#9442

1.10.x
Yannick Warnier 10 years ago
parent 02ab654c33
commit 2a7851f488
  1. 2
      main/gradebook/certificate_report.php
  2. 23
      main/inc/lib/sessionmanager.lib.php

@ -34,7 +34,7 @@ if (api_is_student_boss()) {
$userList = GroupPortalManager::getGroupUsersByUser($userId);
$sessionsList = SessionManager::getSessionsFollowedForGroupAdmin($userId);
} else {
$sessionsList = SessionManager::getSessionsCoachedByUser($userId);
$sessionsList = SessionManager::getSessionsCoachedByUser($userId, false, api_is_platform_admin());
}
foreach ($sessionsList as $session) {

@ -3341,26 +3341,36 @@ class SessionManager
/**
* The general coach (field: session.id_coach)
* @param int $user_id user id
* @param boolean $asPlatformAdmin The user is platform admin, return everything
* @return array
*/
public static function get_sessions_by_general_coach($user_id)
public static function get_sessions_by_general_coach($user_id, $asPlatformAdmin = false)
{
$session_table = Database::get_main_table(TABLE_MAIN_SESSION);
$user_id = intval($user_id);
// Session where we are general coach
$sql = "SELECT DISTINCT *
FROM $session_table
WHERE id_coach = $user_id";
FROM $session_table";
if (!$asPlatformAdmin) {
$sql .= " WHERE id_coach = $user_id";
}
if (api_is_multiple_url_enabled()) {
$tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$access_url_id = api_get_current_access_url_id();
$sqlCoach = '';
if (!$asPlatformAdmin) {
$sqlCoach = " id_coach = $user_id AND ";
}
if ($access_url_id != -1) {
$sql = 'SELECT DISTINCT session.*
FROM ' . $session_table . ' session INNER JOIN ' . $tbl_session_rel_access_url . ' session_rel_url
ON (session.id = session_rel_url.session_id)
WHERE id_coach = ' . $user_id . ' AND access_url_id = ' . $access_url_id;
WHERE '.$sqlCoach.' access_url_id = ' . $access_url_id;
}
}
$sql .= ' ORDER by name';
@ -5446,12 +5456,13 @@ class SessionManager
* Get the session coached by a user (general coach and course-session coach)
* @param int $coachId The coach id
* @param boolean $checkSessionRelUserVisibility Check the session visibility
* @param boolean $asPlatformAdmin The user is a platform admin and we want all sessions
* @return array The session list
*/
public static function getSessionsCoachedByUser($coachId, $checkSessionRelUserVisibility = false)
public static function getSessionsCoachedByUser($coachId, $checkSessionRelUserVisibility = false, $asPlatformAdmin = false)
{
// Get all sessions where $coachId is the general coach
$sessions = self::get_sessions_by_general_coach($coachId);
$sessions = self::get_sessions_by_general_coach($coachId, $asPlatformAdmin);
// Get all sessions where $coachId is the course - session coach
$courseSessionList = self::getCoursesListByCourseCoach($coachId);
$sessionsByCoach = array();

Loading…
Cancel
Save