/**
     * This method return a content html, it's used inside get_block method for showing it inside dashboard interface
     * @return string  content html
     */
    public function get_content_html()
    {
        $content = '';
        $sessions = $this->sessions;
        $content = '<div style="margin:10px;">';
        $content .= '<h3><font color="#000">' . get_lang('YourSessionsList') . '</font></h3>';
        if (count($sessions) > 0) {
            $sessions_table = '<table class="data_table" width:"95%">';
            $sessions_table .= '<tr>
									<th >' . get_lang('Title') . '</th>
									<th >' . get_lang('Date') . '</th>
									<th width="100px">' . get_lang('NbCoursesPerSession') . '</th>
								</tr>';
            $i = 1;
            foreach ($sessions as $session) {
                $session_id = intval($session['id']);
                $title = $session['name'];
                $date_string = SessionManager::parse_session_dates($session);
                $count_courses_in_session = count(Tracking::get_courses_list_from_session($session_id));
                if ($i % 2 == 0) {
                    $class_tr = 'row_odd';
                } else {
                    $class_tr = 'row_even';
                }
                $sessions_table .= '<tr class="' . $class_tr . '">
										<td>' . $title . '</td>
										<td align="center">' . $date_string . '</td>
										<td align="center">' . $count_courses_in_session . '</td>
								   </tr>';
                $i++;
            }
            $sessions_table .= '</table>';
            $content .= $sessions_table;
        } else {
            $content .= get_lang('ThereIsNoInformationAboutYourSessions');
        }
        if (count($sessions) > 0) {
            $content .= '<div style="text-align:right;margin-top:10px;"><a href="' . api_get_path(WEB_CODE_PATH) . 'mySpace/session.php">' . get_lang('SeeMore') . '</a></div>';
        }
        $content .= '</div>';
        return $content;
    }
Esempio n. 2
0
}
$nb_sessions = count($a_sessions);
if ($export_csv) {
    $csv_content = array();
}
if ($nb_sessions > 0) {
    $table = new SortableTable('tracking', 'count_sessions_coached');
    $table->set_header(0, get_lang('Title'));
    $table->set_header(1, get_lang('Date'));
    $table->set_header(2, get_lang('NbCoursesPerSession'));
    $table->set_header(3, get_lang('Details'), false);
    $all_data = array();
    foreach ($a_sessions as $session) {
        $row = array();
        $row[] = $session['name'];
        $row[] = SessionManager::parse_session_dates($session);
        $row[] = count(Tracking::get_courses_list_from_session($session['id']));
        if ($export_csv) {
            $csv_content[] = $row;
        }
        if (isset($_GET['id_coach']) && $_GET['id_coach'] != '') {
            $row[] = '<a href="student.php?id_session=' . $session['id'] . '&id_coach=' . intval($_GET['id_coach']) . '"><img src="' . api_get_path(WEB_IMG_PATH) . '2rightarrow.gif" border="0" /></a>';
        } else {
            $row[] = '<a href="course.php?id_session=' . $session['id'] . '"><img src="' . api_get_path(WEB_IMG_PATH) . '2rightarrow.gif" border="0" /></a>';
        }
        $all_data[] = $row;
    }
    if (!isset($tracking_column)) {
        $tracking_column = 0;
    }
    if ($_GET['tracking_direction'] == 'DESC') {
        $data = array();
        $personal_course_list = array();
        $id_session = $session_item['session_id'];
        foreach ($session_item['courses'] as $my_course) {
            $courseInfo = api_get_course_info_by_id($my_course['id']);
            $row = array();
            $row[] = $courseInfo['code'];
            $row[] = $courseInfo['title'];
            //$row[] = $my_course['status'] == STUDENT ? get_lang('Student') : get_lang('Teacher');
            $roles = api_detect_user_roles($user['user_id'], $courseInfo['real_id'], $id_session);
            $row[] = api_get_roles_to_string($roles);
            $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>';
            $row[] = $tools;
            $data[] = $row;
        }
        $dates = SessionManager::parse_session_dates($session_item);
        echo Display::page_subheader($session_item['session_name'], ' ' . $dates);
        Display::display_sortable_table($header, $data, array(), array(), array('user_id' => intval($_GET['user_id'])));
    }
} else {
    Display::display_warning_message(get_lang('NoSessionsForThisUser'));
}
/**
 * Show the courses in which this user is subscribed
 */
$sql = 'SELECT * FROM ' . $table_course_user . ' cu, ' . $table_course . ' c' . ' WHERE cu.user_id = ' . $user['user_id'] . ' AND cu.c_id = c.id ' . ' AND cu.relation_type <> ' . COURSE_RELATION_TYPE_RRHH . ' ';
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
    $header = array();
    $header[] = array(get_lang('Code'), true);
    $header[] = array(get_lang('Title'), true);
 /**
  * Shows the general data for a particular meeting
  *
  * @param id	session id
  * @return string	session data
  */
 public static function show_session_data($id_session)
 {
     if ($id_session != strval(intval($id_session))) {
         return '';
     } else {
         $id_session = intval($id_session);
     }
     $session_info = api_get_session_info($id_session);
     $session_category = SessionManager::get_session_category($session_info['session_category_id']);
     $session_category_name = null;
     if (!empty($session_category)) {
         $session_category_name = $session_category['name'];
     }
     $user_info = api_get_user_info($session_info['id_coach']);
     $general_coach = null;
     if (!empty($user_info)) {
         $general_coach = $user_info['complete_name'] . ' (' . $user_info['username'] . ')';
     }
     $msg_date = SessionManager::parse_session_dates($session_info);
     $output = '';
     if (!empty($session_category)) {
         $output .= '<tr><td>' . get_lang('SessionCategory') . ': ' . '<b>' . $session_category_name . '</b></td></tr>';
     }
     $output .= '<tr>
                     <td style="width:50%">' . get_lang('SessionName') . ': ' . '<b>' . $session_info['name'] . '</b></td>
                     <td>' . get_lang('GeneralCoach') . ': ' . '<b>' . $general_coach . '</b></td></tr>';
     $output .= '<tr><td>' . get_lang('SessionIdentifier') . ': ' . Display::return_icon('star.png', ' ', array('align' => 'absmiddle')) . '</td>
                     <td>' . get_lang('Date') . ': ' . '<b>' . $msg_date . '</b></td></tr>';
     return $output;
 }
Esempio n. 5
0
                        }
                    }
                }
            }
        }
    }
}
$my_real_array = ArrayClass::msort($my_real_array, 'date', 'asc');
if (!empty($new_exercises)) {
    $my_real_array = array_merge($new_exercises, $my_real_array);
}
$back_url = '';
if (!empty($course_id)) {
    //$back_url = Display::url(Display::return_icon('back.png',get_lang('back.png')), api_get_path(WEB_CODE_PATH).'session/?session_id='.$session_id);
}
$dates = SessionManager::parse_session_dates($session_info);
echo Display::page_header($back_url . ' ' . $session_info['name'] . " <small>{$dates}<small>");
if (!empty($new_course_list)) {
    echo '<div id="session_course_list" class="row">';
    foreach ($new_course_list as $course_item) {
        echo '<div class="span3">';
        echo '<div class="big_icon">';
        echo Display::url(Display::return_icon('course.png', $course_item['only_title'], array(), ICON_SIZE_BIG), $course_item['link']);
        echo '</div>';
        echo '<div class="content">';
        echo $course_item['title'];
        echo '</div>';
        echo '</div>';
    }
    echo '</div>';
}
 /**
  * Gives a list of [session_category][session_id] for the current user.
  * @param integer $user_id
  * @param boolean optional true if we want to see expired sessions, false otherwise
  * @param boolean Whether to return only a count (true) or the full result (false)
  * @param boolean Whether to order by alphabetical order (false) or reverse-alphabetical (used in history to show latest sessions on top)
  * @return array  list of statuses [session_category][session_id]
  * @todo ensure multiple access urls are managed correctly
  */
 public static function get_sessions_by_category($user_id, $is_time_over = false, $get_count = false, $reverse_order = false, $start = 0, $maxPerPage = null, $categoryFilter = null, $ignore_visibility_for_admins = false)
 {
     // Database Table Definitions
     $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
     $tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
     $tbl_session_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
     $tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
     if ($user_id != strval(intval($user_id))) {
         return array();
     }
     $categories = array();
     $now = api_get_utc_datetime();
     // Get the list of sessions per user
     $condition_date_start1 = null;
     $condition_date_start2 = null;
     $condition_date_end1 = null;
     $condition_date_end2 = null;
     $order = ' ORDER BY name ';
     if ($reverse_order) {
         $order = ' ORDER BY name DESC ';
     }
     if ($is_time_over) {
         $condition_date_end1 = " AND ((session.access_end_date < '{$now}' AND access_end_date IS NOT NULL AND session.access_end_date != '0000-00-00 00:00:00' AND session.access_end_date != '' ) OR moved_to <> 0) ";
         $condition_date_end2 = " AND ((session.access_end_date < '{$now}' AND access_end_date IS NOT NULL AND session.access_end_date != '0000-00-00 00:00:00' AND session.access_end_date != '') ) ";
     } else {
         if (api_is_allowed_to_create_course()) {
             //Teachers can access the session depending in the access_coach date
             //$condition_date_start1 = " AND (session.coach_access_start_date <= '$now' OR session.coach_access_start_date = '0000-00-00 00:00:00') ";
             //$condition_date_start2 = " AND (session.coach_access_start_date <= '$now' OR session.coach_access_start_date = '0000-00-00 00:00:00') ";
         } else {
             //Student can't access before the start date or after the end date
             //$condition_date_start1 = " AND (session.access_start_date <= '$now' OR session.access_start_date = '0000-00-00 00:00:00') ";
             //$condition_date_start2 = " AND (session.access_start_date <= '$now' OR session.access_start_date = '0000-00-00 00:00:00') ";
             $condition_date_end1 = " AND (session.access_end_date >= '{$now}' OR session.access_end_date = '0000-00-00 00:00:00' OR session.access_end_date IS NULL ) ";
             $condition_date_end2 = " AND (session.access_end_date >= '{$now}' OR session.access_end_date = '0000-00-00 00:00:00' OR session.access_end_date IS NULL ) ";
         }
     }
     $select = "SELECT DISTINCT " . " session.id, " . " session.name, " . " access_start_date, " . " access_end_date, " . " coach_access_start_date, " . " coach_access_end_date, " . " display_start_date, " . " display_end_date, " . " session_category_id, " . " session_category.name as session_category_name, " . " session_category.date_start session_category_date_start, " . " session_category.date_end session_category_date_end, " . " id_coach ";
     $select_1 = ", moved_to, " . " moved_status, " . " scu.id_user";
     if ($get_count) {
         $select = "SELECT count(session.id) as total_rows ";
     }
     $select1 = " {$select} " . ($get_count ? '' : $select_1) . "\n                    FROM {$tbl_session} as session\n                    LEFT JOIN {$tbl_session_category} session_category\n                    ON (session_category_id = session_category.id) ";
     $sql1 = $select1 . " INNER JOIN {$tbl_session_course_user} as scu\n                ON (scu.id_session = session.id and scu.id_user = {$user_id})\n                LEFT JOIN {$tbl_session_user} su\n                ON su.id_session = session.id AND su.id_user = scu.id_user\n                WHERE scu.id_user = {$user_id} {$condition_date_end1}";
     // This is bad because we asumme the user is a coach which is not the case
     // Select specific to session coaches
     $select2 = " {$select} FROM {$tbl_session} as session LEFT JOIN {$tbl_session_category} session_category ON (session_category_id = session_category.id) ";
     $sql2 = $select2 . " WHERE session.id_coach = {$user_id} {$condition_date_end2} ";
     if (isset($categoryFilter) && $categoryFilter != '') {
         switch ($categoryFilter) {
             case 'no_category':
                 $sql1 .= "AND (session_category_id = 0 OR session_category_id IS NULL)";
                 $sql2 .= "AND (session_category_id = 0 OR session_category_id IS NULL)";
                 break;
             case 'with_category':
                 $sql1 .= "AND (session_category_id <> 0 AND session_category_id IS NOT NULL ) ";
                 $sql2 .= "AND (session_category_id <> 0 AND session_category_id IS NOT NULL )";
                 break;
             default:
                 if (!empty($categoryFilter) && is_numeric($categoryFilter)) {
                     $categoryFilter = intval($categoryFilter);
                     $sql1 .= "AND session_category_id = {$categoryFilter}";
                     $sql2 .= "AND session_category_id = {$categoryFilter}";
                 }
                 break;
         }
     }
     $sql3 = null;
     if ($get_count) {
         //$sql3 = $sql2;
         $sql3 = $sql1;
     } else {
         $sql1 .= $order;
         $sql2 .= $order;
     }
     if (isset($start) && isset($maxPerPage)) {
         $start = intval($start);
         $maxPerPage = intval($maxPerPage);
         $limitCondition = " LIMIT {$start}, {$maxPerPage}";
         $sql1 .= $limitCondition;
         $sql2 .= $limitCondition;
     }
     $join = array();
     $ordered_join = array();
     $ids = array();
     if ($get_count) {
         $result3 = Database::query($sql3);
         $row = Database::fetch_array($result3);
         return $row['total_rows'];
     } else {
         $result1 = Database::query($sql1);
         $result2 = Database::query($sql2);
     }
     if (Database::num_rows($result2) > 0) {
         // First take $row2, as it contains less data and this data is enough
         while ($row2 = Database::fetch_array($result2)) {
             $join[] = $row2;
             $ordered_join[] = $row2;
             $ids[] = $row2['id'];
         }
     }
     if (Database::num_rows($result1) > 0) {
         // Now add the diff with $row1, ordering elements as planned by query
         $i = 0;
         while ($row1 = Database::fetch_array($result1)) {
             if (!in_array($row1['id'], $ids)) {
                 if ($reverse_order) {
                     while (isset($join[$i]) && strcmp($row1['session_category_name'], $join[$i]['session_category_name']) <= 0) {
                         $ordered_join[] = $join[$i];
                         $i++;
                     }
                 } else {
                     while (isset($join[$i]) && strcmp($row1['session_category_name'], $join[$i]['session_category_name']) > 0) {
                         $ordered_join[] = $join[$i];
                         $i++;
                     }
                     if (isset($join[$i]) && strcmp($row1['session_category_name'], $join[$i]['session_category_name']) === 0) {
                         while (isset($join[$i]) && isset($row1['short_name']) && strcmp($row1['short_name'], $join[$i]['short_name']) > 0) {
                             $ordered_join[] = $join[$i];
                             $i++;
                         }
                     }
                 }
                 $ordered_join[] = $row1;
                 $join[] = $row1;
             }
         }
     }
     if (count($ordered_join) == 0) {
         $ordered_join = $join;
     }
     if (count($ordered_join) > 0) {
         foreach ($ordered_join as $row) {
             if ($get_count) {
                 return $row['total_rows'];
             }
             $categories[$row['session_category_id']]['session_category']['id'] = $row['session_category_id'];
             $categories[$row['session_category_id']]['session_category']['name'] = $row['session_category_name'];
             $categories[$row['session_category_id']]['session_category']['date_start'] = $row['session_category_date_start'];
             $categories[$row['session_category_id']]['session_category']['date_end'] = $row['session_category_date_end'];
             $session_id = $row['id'];
             // The only usage of $session_info is to call
             // api_get_session_date_validation, which only needs id and
             // dates from the session itself, so really no need to query
             // the session table again
             $session_info = $row;
             // Checking session visibility
             $visibility = api_get_session_visibility($session_id, null, $ignore_visibility_for_admins);
             switch ($visibility) {
                 case SESSION_VISIBLE_READ_ONLY:
                 case SESSION_VISIBLE:
                 case SESSION_AVAILABLE:
                     break;
                 case SESSION_INVISIBLE:
                     continue 2;
             }
             if ($is_time_over == false) {
                 $date_validation = api_get_session_date_validation($session_info, null, false, false);
                 if (!$date_validation) {
                     continue;
                 }
             }
             $categories[$row['session_category_id']]['sessions'][$row['id']]['session_name'] = $row['name'];
             $categories[$row['session_category_id']]['sessions'][$row['id']]['session_id'] = $row['id'];
             $categories[$row['session_category_id']]['sessions'][$row['id']]['id_coach'] = $row['id_coach'];
             if (isset($row['id_coach']) && !empty($row['id_coach'])) {
                 $user_info = api_get_user_info($row['id_coach']);
                 $categories[$row['session_category_id']]['sessions'][$row['id']]['coach_info'] = $user_info;
             }
             $categories[$row['session_category_id']]['sessions'][$row['id']]['access_start_date'] = $row['access_start_date'];
             $categories[$row['session_category_id']]['sessions'][$row['id']]['access_end_date'] = $row['access_end_date'];
             $categories[$row['session_category_id']]['sessions'][$row['id']]['coach_access_start_date'] = $row['coach_access_start_date'];
             $categories[$row['session_category_id']]['sessions'][$row['id']]['coach_access_end_date'] = $row['coach_access_end_date'];
             $date_message = SessionManager::parse_session_dates($row);
             $categories[$row['session_category_id']]['sessions'][$row['id']]['date_message'] = $date_message;
             $courses = UserManager::get_courses_list_by_session($user_id, $row['id']);
             $course_list = array();
             foreach ($courses as $course) {
                 //Checking course session visibility
                 $visibility = api_get_session_visibility($session_id, $course['id']);
                 if ($visibility == SESSION_INVISIBLE) {
                     continue;
                 }
                 $user_status_in_course = CourseManager::get_user_in_course_status($user_id, $course['id']);
                 $course['user_status_in_course'] = $user_status_in_course;
                 $course_list[] = $course;
             }
             $categories[$row['session_category_id']]['sessions'][$row['id']]['courses'] = $course_list;
             $categories[$row['session_category_id']]['sessions'][$row['id']]['moved_to'] = isset($row['moved_to']) ? $row['moved_to'] : null;
             $categories[$row['session_category_id']]['sessions'][$row['id']]['moved_status'] = isset($row['moved_status']) ? $row['moved_status'] : null;
         }
     }
     return $categories;
 }