Minor - format code.

1.9.x
Julio Montoya 11 years ago
parent 55aac07fbf
commit 41c69f7a8b
  1. 12
      main/inc/lib/main_api.lib.php
  2. 11
      main/inc/lib/sessionmanager.lib.php
  3. 188
      main/inc/lib/userportal.lib.php

@ -2054,7 +2054,9 @@ function api_get_session_visibility(
$visibility = $original_visibility = $row['visibility'];
// I don't care the session visibility.
if ($row['date_start'] == '0000-00-00' && $row['date_end'] == '0000-00-00') {
if ($row['date_start'] == '0000-00-00' &&
$row['date_end'] == '0000-00-00'
) {
// Session duration per student.
if (SessionManager::durationPerUserIsEnabled()) {
@ -2109,7 +2111,6 @@ function api_get_session_visibility(
}
}
// If the end date was set.
if (!empty($row['date_end']) && $row['date_end'] != '0000-00-00') {
// End date finish at midnight.
@ -2170,6 +2171,7 @@ function api_get_session_visibility(
$visibility = SESSION_INVISIBLE;
}
}
return $visibility;
}
@ -2231,7 +2233,6 @@ function api_get_session_condition($session_id, $and = true, $with_base_content
*/
function api_get_coachs_from_course($session_id=0,$course_code='')
{
if (!empty($session_id)) {
$session_id = intval($session_id);
} else {
@ -2244,8 +2245,8 @@ function api_get_coachs_from_course($session_id=0,$course_code='')
$course_code = api_get_course_id();
}
$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
$tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_user = Database:: get_main_table(TABLE_MAIN_USER);
$tbl_session_course_user = Database:: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$coaches = array();
$sql = "SELECT u.user_id,u.lastname,u.firstname,u.username
@ -2405,6 +2406,7 @@ function api_is_platform_admin_by_id($user_id = null, $url = null) {
$is_on_url = Database::num_rows($res) === 1;
return $is_on_url;
}
/**
* Returns the user's numeric status ID from the users table
* @param int User ID. If none provided, will use current user

@ -2720,8 +2720,11 @@ class SessionManager
* @param string $course_name
* @return array list of courses
*/
public static function get_course_list_by_session_id($session_id, $course_name = '', $orderBy = null)
{
public static function get_course_list_by_session_id(
$session_id,
$course_name = '',
$orderBy = null
) {
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
@ -2749,8 +2752,8 @@ class SessionManager
$sql .= Database::escape_string($orderBy);
$result = Database::query($sql);
$num_rows = Database::num_rows($result);
$result = Database::query($sql);
$num_rows = Database::num_rows($result);
$courses = array();
if ($num_rows > 0) {
while ($row = Database::fetch_array($result,'ASSOC')) {

@ -630,10 +630,10 @@ class IndexManager
/**
* retrieves all the courses that the user has already subscribed to
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
* @param int $user_id: the id of the user
* @return array an array containing all the information of the courses of the given user
*/
*/
function get_courses_of_user($user_id) {
$table_course = Database::get_main_table(TABLE_MAIN_COURSE);
$table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
@ -780,6 +780,7 @@ class IndexManager
function return_reservation_block() {
$html = '';
$booking_content = null;
if (api_get_setting('allow_reservation') == 'true' && api_is_allowed_to_create_course()) {
$booking_content .='<ul class="nav nav-list">';
$booking_content .='<a href="main/reservation/reservation.php">'.get_lang('ManageReservations').'</a><br />';
@ -943,9 +944,10 @@ class IndexManager
}
/**
* The most important function here, prints the session and course list (user_portal.php)
*
* */
* Prints the session and course list (user_portal.php)
* @param int $user_id
* @return string
*/
public function return_courses_and_sessions($user_id)
{
global $_configuration;
@ -988,7 +990,9 @@ class IndexManager
$session_category_id = $session_category['session_category']['id'];
// Sessions and courses that are not in a session category
if ($session_category_id == 0) {
if ($session_category_id == 0 &&
isset($session_category['sessions'])
) {
// Independent sessions
foreach ($session_category['sessions'] as $session) {
@ -1102,81 +1106,122 @@ class IndexManager
// All sessions included in
$count_courses_session = 0;
$html_sessions = '';
foreach ($session_category['sessions'] as $session) {
$session_id = $session['session_id'];
// Don't show empty sessions.
if (count($session['courses']) < 1) {
continue;
}
$date_session_start = $session['date_start'];
$date_session_end = $session['date_end'];
$days_access_before_beginning = $session['nb_days_access_before_beginning'];
$days_access_after_end = $session['nb_days_access_after_end'];
if (isset($session_category['sessions'])) {
foreach ($session_category['sessions'] as $session) {
$session_id = $session['session_id'];
$session_now = time();
$html_courses_session = '';
$count = 0;
foreach ($session['courses'] as $course) {
$is_coach_course = api_is_coach($session_id, $course['code']);
$dif_time_after = 0;
$allowed_time = 0;
if ($is_coach_course) {
// 24 hours = 86400
if ($date_session_start != '0000-00-00') {
$allowed_time = api_strtotime($date_session_start.' 00:00:00') - ($days_access_before_beginning*86400);
}
if ($date_session_end != '0000-00-00') {
$endSessionToTms = api_strtotime($date_session_end.' 23:59:59');
if ($session_now > $endSessionToTms) {
$dif_time_after = $session_now - $endSessionToTms;
$dif_time_after = round($dif_time_after / 86400);
// Don't show empty sessions.
if (count($session['courses']) < 1) {
continue;
}
$date_session_start = $session['date_start'];
$date_session_end = $session['date_end'];
$days_access_before_beginning = $session['nb_days_access_before_beginning'];
$days_access_after_end = $session['nb_days_access_after_end'];
$session_now = time();
$html_courses_session = '';
$count = 0;
foreach ($session['courses'] as $course) {
$is_coach_course = api_is_coach(
$session_id,
$course['code']
);
$dif_time_after = 0;
$allowed_time = 0;
if ($is_coach_course) {
// 24 hours = 86400
if ($date_session_start != '0000-00-00') {
$allowed_time = api_strtotime($date_session_start . ' 00:00:00') - ($days_access_before_beginning * 86400);
}
if ($date_session_end != '0000-00-00') {
$endSessionToTms = api_strtotime($date_session_end . ' 23:59:59');
if ($session_now > $endSessionToTms) {
$dif_time_after = $session_now - $endSessionToTms;
$dif_time_after = round(
$dif_time_after / 86400
);
}
}
} else {
$allowed_time = api_strtotime(
$date_session_start . ' 00:00:00'
);
}
} else {
$allowed_time = api_strtotime($date_session_start.' 00:00:00');
}
if ($session_now > $allowed_time && $days_access_after_end > $dif_time_after - 1) {
if (api_get_setting('hide_courses_in_sessions') == 'false') {
$c = CourseManager :: get_logged_user_course_html($course, $session_id, 'session_course_item');
$html_courses_session .= $c[1];
if ($session_now > $allowed_time && $days_access_after_end > $dif_time_after - 1) {
if (api_get_setting('hide_courses_in_sessions') == 'false') {
$c = CourseManager:: get_logged_user_course_html(
$course,
$session_id,
'session_course_item'
);
$html_courses_session .= $c[1];
}
$count_courses_session++;
$count++;
}
$count_courses_session++;
$count++;
}
}
$params = array();
$params = array();
if ($count > 0) {
$session_box = Display :: get_session_title_box($session_id);
$params['icon'] = Display::return_icon('window_list.png', $session_box['title'], array('width' => '48px', 'align' => 'absmiddle', 'id' => 'session_img_'.$session_id)) . ' ';
if ($count > 0) {
$session_box = Display:: get_session_title_box(
$session_id
);
$params['icon'] = Display::return_icon(
'window_list.png',
$session_box['title'],
array(
'width' => '48px',
'align' => 'absmiddle',
'id' => 'session_img_' . $session_id
)
) . ' ';
if (api_is_drh()) {
$session_link = $session_box['title'];
$params['link'] = null;
} else {
$session_link = Display::tag(
'a',
$session_box['title'],
array(
'href' => api_get_path(WEB_CODE_PATH) . 'session/index.php?session_id=' . $session_id
)
);
$params['link'] = api_get_path(WEB_CODE_PATH) . 'session/index.php?session_id=' . $session_id;
}
if (api_is_drh()) {
$session_link = $session_box['title'];
$params['link'] = null;
} else {
$session_link = Display::tag('a', $session_box['title'], array('href'=>api_get_path(WEB_CODE_PATH).'session/index.php?session_id='.$session_id));
$params['link'] = api_get_path(WEB_CODE_PATH).'session/index.php?session_id='.$session_id;
}
$params['title'] = $session_link;
$params['subtitle'] = (!empty($session_box['coach']) ? $session_box['coach'] . ' | ' : '') . $session_box['dates'];
if (api_is_platform_admin()) {
$params['right_actions'] = '<a href="' . api_get_path(WEB_CODE_PATH) . 'admin/resume_session.php?id_session=' . $session_id . '">' .
Display::return_icon(
'edit.png',
get_lang('Edit'),
array('align' => 'absmiddle'),
ICON_SIZE_SMALL
) . '</a>';
}
$params['title'] = $session_link;
$params['subtitle'] = (!empty($session_box['coach']) ? $session_box['coach'].' | ' : '').$session_box['dates'];
$parentInfo = CourseManager::course_item_html(
$params,
true
);
if (api_is_platform_admin()) {
$params['right_actions'] = '<a href="'.api_get_path(WEB_CODE_PATH).'admin/resume_session.php?id_session='.$session_id.'">'.Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL).'</a>';
}
if (isset($_configuration['show_simple_session_info']) && $_configuration['show_simple_session_info']) {
$params['title'] = $session_box['title'];
$parentInfo = CourseManager::course_item_html_no_icon(
$params
);
}
$parentInfo = CourseManager::course_item_html($params, true);
if (isset($_configuration['show_simple_session_info']) && $_configuration['show_simple_session_info']) {
$params['title'] = $session_box['title'];
$parentInfo = CourseManager::course_item_html_no_icon($params);
$html_sessions .= $parentInfo . $html_courses_session;
}
$html_sessions .= $parentInfo.$html_courses_session;
}
}
@ -1225,7 +1270,7 @@ class IndexManager
/**
* Shows a welcome message when the user doesn't have any content in the course list
*/
function return_welcome_to_course_block()
public function return_welcome_to_course_block()
{
$count_courses = CourseManager::count_courses();
$tpl = $this->tpl->get_template('layout/welcome_to_course.tpl');
@ -1242,7 +1287,10 @@ class IndexManager
return $this->tpl->fetch($tpl);
}
function return_hot_courses()
/**
* @return array
*/
public function return_hot_courses()
{
return CourseManager::return_hot_courses();
}

Loading…
Cancel
Save