Пример #1
0
 $header = array(array(get_lang('Code'), true), array(get_lang('Title'), true), array(get_lang('Status'), true), array(get_lang('TimeSpentInTheCourse'), true), array(get_lang('TotalPostsInAllForums'), true), array('', false));
 $headerList = array();
 foreach ($header as $item) {
     $headerList[] = $item[0];
 }
 $csvContent[] = array();
 $csvContent[] = array(get_lang('Sessions'));
 foreach ($sessions as $session_item) {
     $data = array();
     $personal_course_list = array();
     $id_session = $session_item['session_id'];
     $csvContent[] = array($session_item['session_name']);
     $csvContent[] = $headerList;
     foreach ($session_item['courses'] as $my_course) {
         $courseInfo = api_get_course_info_by_id($my_course['real_id']);
         $sessionStatus = SessionManager::get_user_status_in_session($user['user_id'], $courseInfo['real_id'], $id_session);
         $status = null;
         switch ($sessionStatus) {
             case 0:
             case STUDENT:
                 $status = get_lang('Student');
                 break;
             case 2:
                 $status = get_lang('CourseCoach');
                 break;
         }
         $tools = '<a href="course_information.php?code=' . $courseInfo['code'] . '&id_session=' . $id_session . '">' . Display::return_icon('synthese_view.gif', get_lang('Overview')) . '</a>' . '<a href="' . $courseInfo['course_public_url'] . '?id_session=' . $id_session . '">' . Display::return_icon('course_home.gif', get_lang('CourseHomepage')) . '</a>';
         if ($my_course['status'] == STUDENT) {
             $tools .= '<a href="user_information.php?action=unsubscribeSessionCourse&course_code=' . $courseInfo['code'] . '&user_id=' . $user['user_id'] . '&id_session=' . $id_session . '">' . Display::return_icon('delete.png', get_lang('Delete')) . '</a>';
         }
         $timeSpent = api_time_to_hms(Tracking::get_time_spent_on_the_course($user['user_id'], $courseInfo['real_id'], $id_session));
Пример #2
0
if (empty($session_id)) {
    if (CourseManager::is_user_subscribed_in_course($user_id, $course_code) || api_check_user_access_to_legal($course_info['visibility'])) {
        $user_accepted_legal = CourseManager::is_user_accepted_legal($user_id, $course_code);
        if ($user_accepted_legal || $user_pass_open_course) {
            //Redirect to course home
            header('Location: ' . $url);
            exit;
        }
    } else {
        api_not_allowed();
    }
} else {
    if (api_is_platform_admin()) {
        header('Location: ' . $url);
    }
    $userStatus = SessionManager::get_user_status_in_session($user_id, $course_code, $session_id);
    if (isset($userStatus) || api_check_user_access_to_legal($course_info['visibility'])) {
        $user_accepted_legal = CourseManager::is_user_accepted_legal($user_id, $course_code, $session_id);
        if ($user_accepted_legal || $user_pass_open_course) {
            // Redirect to course session home.
            header('Location: ' . $url);
            exit;
        }
    } else {
        api_not_allowed();
    }
}
Display::display_header();
echo $pluginMessage;
if ($hideForm == false) {
    $form->display();
 /**
  * Unsubscribe user from session
  *
  * @param int session id
  * @param int user id
  * @param int reason of unsubscription see function get_session_change_user_reasons()
  * @return bool true in case of success, false in case of error
  */
 public static function unsubscribe_user_from_session($session_id, $user_id)
 {
     $session_id = intval($session_id);
     $user_id = intval($user_id);
     $reason_id = intval($reason_id);
     $tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
     $tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
     $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
     $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
     $user_status = SessionManager::get_user_status_in_session($session_id, $user_id);
     if ($user_status['moved_to'] != 0) {
         //You can't subscribe a user that was moved
         return false;
     }
     $delete_sql = "DELETE FROM {$tbl_session_rel_user} WHERE id_session = '{$session_id}' AND id_user ='******' AND relation_type<>" . SESSION_RELATION_TYPE_RRHH . "";
     $result = Database::query($delete_sql);
     $return = Database::affected_rows($result);
     // Update number of users
     $update_sql = "UPDATE {$tbl_session} SET nbr_users = nbr_users - {$return} WHERE id='{$session_id}' ";
     Database::query($update_sql);
     // Get the list of courses related to this session
     $course_list = SessionManager::get_course_list_by_session_id($session_id);
     if (!empty($course_list)) {
         foreach ($course_list as $course) {
             $courseId = $course['id'];
             // Delete user from course
             $result = Database::query("DELETE FROM {$tbl_session_rel_course_rel_user} WHERE id_session='{$session_id}' AND c_id='{$courseId}' AND id_user='******'");
             if (Database::affected_rows($result)) {
                 // Update number of users in this relation
                 Database::query("UPDATE {$tbl_session_rel_course} SET nbr_users=nbr_users - 1 WHERE id_session='{$session_id}' AND c_id ='{$courseId}'");
             }
         }
     }
     return true;
 }
Пример #4
0
if (empty($session_id)) {
    if (CourseManager::is_user_subscribed_in_course($user_id, $course_code) || api_check_user_access_to_legal($course_info['visibility'])) {
        $user_accepted_legal = CourseManager::is_user_accepted_legal($user_id, $course_code);
        if ($user_accepted_legal || $user_pass_open_course) {
            //Redirect to course home
            header('Location: ' . $url);
            exit;
        }
    } else {
        api_not_allowed();
    }
} else {
    if (api_is_platform_admin()) {
        header('Location: ' . $url);
    }
    $userStatus = SessionManager::get_user_status_in_session($user_id, $course_info['real_id'], $session_id);
    if (isset($userStatus) || api_check_user_access_to_legal($course_info['visibility'])) {
        $user_accepted_legal = CourseManager::is_user_accepted_legal($user_id, $course_code, $session_id);
        if ($user_accepted_legal || $user_pass_open_course) {
            // Redirect to course session home.
            header('Location: ' . $url);
            exit;
        }
    } else {
        api_not_allowed();
    }
}
Display::display_header();
echo $pluginMessage;
if ($hideForm == false) {
    $form->display();
 static function check_if_user_is_subscribe_to_session($user_id, $session_id, $message = null, $before = array())
 {
     $user_session_status = SessionManager::get_user_status_in_session($session_id, $user_id);
     if (!empty($user_session_status)) {
         return array('entity' => 'session_rel_user', 'before' => $before, 'after' => $user_session_status, 'message' => "User {$user_id} added to Session {$session_id}  - user relation_type in session: {$user_session_status['relation_type']}- {$message} ", 'status_id' => self::TRANSACTION_STATUS_SUCCESSFUL);
     } else {
         return array('message' => "User {$user_id} was NOT added to Session {$session_id}  - {$message}", 'status_id' => self::TRANSACTION_STATUS_FAILED);
     }
 }
Пример #6
0
if (api_is_platform_admin()) {
    $sessions = SessionManager::get_sessions_admin(array('order' => 'name'));
} else {
    $sessions = SessionManager::get_sessions_by_general_coach(api_get_session_id());
}
$message = null;
$session_to_select = array();
foreach ($sessions as $session) {
    if ($session_id != $session['id']) {
        $session_to_select[$session['id']] = $session['name'];
    }
}
$session_name = api_get_session_name($session_id);
$user_info = api_get_user_info($user_id);
//Check if user was already moved
$user_status = SessionManager::get_user_status_in_session($session_id, $user_id);
if (isset($user_status['moved_to']) && $user_status['moved_to'] != 0 || $user_status['moved_status'] == SessionManager::SESSION_CHANGE_USER_REASON_ENROLLMENT_ANNULATION) {
    api_not_allowed(true);
}
$form = new FormValidator('change_user_session', 'post', api_get_self());
$form->addElement('hidden', 'user_id', $user_id);
$form->addElement('hidden', 'id_session', $session_id);
$form->addElement('header', get_lang('ChangeUserSession'));
$form->addElement('label', get_lang('User'), '<b>' . $user_info['complete_name'] . '</b>');
$form->addElement('label', get_lang('CurrentSession'), $session_name);
$form->addElement('select', 'reason_id', get_lang('Action'), SessionManager::get_session_change_user_reasons(), array('id' => 'reason_id'));
$form->addElement('select', 'new_session_id', get_lang('SessionDestination'), $session_to_select, array('id' => 'new_session_id'));
$form->addElement('button', 'submit', get_lang('Change'));
$content = $form->return_form();
if ($form->validate()) {
    $values = $form->getSubmitValues();
Пример #7
0
 $header = array(array(get_lang('Code'), true), array(get_lang('Title'), true), array(get_lang('Status'), true), array(get_lang('TimeSpentInTheCourse'), true), array(get_lang('TotalPostsInAllForums'), true), array('', false));
 $headerList = array();
 foreach ($header as $item) {
     $headerList[] = $item[0];
 }
 $csvContent[] = array();
 $csvContent[] = array(get_lang('Sessions'));
 foreach ($sessions as $session_item) {
     $data = array();
     $personal_course_list = array();
     $id_session = $session_item['session_id'];
     $csvContent[] = array($session_item['session_name']);
     $csvContent[] = $headerList;
     foreach ($session_item['courses'] as $my_course) {
         $courseInfo = api_get_course_info($my_course['code']);
         $sessionStatus = SessionManager::get_user_status_in_session($user['user_id'], $my_course['code'], $id_session);
         $status = null;
         switch ($sessionStatus) {
             case 0:
             case STUDENT:
                 $status = get_lang('Student');
                 break;
             case 2:
                 $status = get_lang('CourseCoach');
                 break;
         }
         $tools = '<a href="course_information.php?code=' . $courseInfo['code'] . '&id_session=' . $id_session . '">' . Display::return_icon('synthese_view.gif', get_lang('Overview')) . '</a>' . '<a href="' . api_get_path(WEB_COURSE_PATH) . $courseInfo['path'] . '?id_session=' . $id_session . '">' . Display::return_icon('course_home.gif', get_lang('CourseHomepage')) . '</a>';
         if ($my_course['status'] == STUDENT) {
             $tools .= '<a href="user_information.php?action=unsubscribe&course_code=' . $courseInfo['code'] . '&user_id=' . $user['user_id'] . '">' . Display::return_icon('delete.png', get_lang('Delete')) . '</a>';
         }
         $timeSpent = api_time_to_hms(Tracking::get_time_spent_on_the_course($user['user_id'], $courseInfo['code'], $id_session));