Minor - format code.

pull/2487/head
jmontoyaa 9 years ago
parent 4a8471b4a8
commit 00e4940863
  1. 14
      index.php
  2. 48
      main/inc/lib/course.lib.php
  3. 54
      main/inc/lib/display.lib.php

@ -38,7 +38,10 @@ if (!empty($_GET['logout'])) {
/** /**
* Registers in the track_e_default table (view in important activities in admin * Registers in the track_e_default table (view in important activities in admin
* interface) a possible attempted break in, sending auth data through get. * interface) a possible attempted break in, sending auth data through get.
* @todo This piece of code should probably move to local.inc.php where the actual login / logout procedure is handled. The real use of this code block should be seriously considered as well. This form should just use a security token and get done with it. * @todo This piece of code should probably move to local.inc.php where the
* actual login / logout procedure is handled.
* The real use of this code block should be seriously considered as well.
* This form should just use a security token and get done with it.
*/ */
if (isset($_GET['submitAuth']) && $_GET['submitAuth'] == 1) { if (isset($_GET['submitAuth']) && $_GET['submitAuth'] == 1) {
$i = api_get_anonymous_id(); $i = api_get_anonymous_id();
@ -68,12 +71,13 @@ if (!api_get_user_id() && CustomPages::enabled()) {
} }
/** /**
* @todo This piece of code should probably move to local.inc.php where the actual login procedure is handled. * @todo This piece of code should probably move to local.inc.php where the
* @todo Check if this code is used. I think this code is never executed because after clicking the submit button * actual login procedure is handled.
* the code does the stuff in local.inc.php and then redirects to index.php or user_portal.php depending * @todo Check if this code is used. I think this code is never executed because
* after clicking the submit button the code does the stuff
* in local.inc.php and then redirects to index.php or user_portal.php depending
* on api_get_setting('page_after_login'). * on api_get_setting('page_after_login').
*/ */
if (!empty($_POST['submitAuth'])) { if (!empty($_POST['submitAuth'])) {
// The user has been already authenticated, we are now to find the last login of the user. // The user has been already authenticated, we are now to find the last login of the user.
if (isset($_user['user_id'])) { if (isset($_user['user_id'])) {

@ -4868,8 +4868,8 @@ class CourseManager
} }
if ($access_link && in_array('enter', if ($access_link && in_array('enter',$access_link) ||
$access_link) || $course_info['visibility'] == COURSE_VISIBILITY_OPEN_WORLD $course_info['visibility'] == COURSE_VISIBILITY_OPEN_WORLD
) { ) {
$my_course['go_to_course_button'] = Display::url( $my_course['go_to_course_button'] = Display::url(
get_lang('GoToCourse').' '. get_lang('GoToCourse').' '.
@ -4918,9 +4918,6 @@ class CourseManager
//Description //Description
$my_course['description_button'] = ''; $my_course['description_button'] = '';
/* if ($course_info['visibility'] == COURSE_VISIBILITY_OPEN_WORLD || in_array($course_info['real_id'],
$my_course_code_list)
) { */
$my_course['description_button'] = Display::url( $my_course['description_button'] = Display::url(
Display::returnFontAwesomeIcon('info-circle'), Display::returnFontAwesomeIcon('info-circle'),
api_get_path(WEB_AJAX_PATH).'course_home.ajax.php?a=show_course_information&code='.$course_info['code'], api_get_path(WEB_AJAX_PATH).'course_home.ajax.php?a=show_course_information&code='.$course_info['code'],
@ -4931,8 +4928,6 @@ class CourseManager
'aria-label' => get_lang('Description') 'aria-label' => get_lang('Description')
] ]
); );
//}
/* get_lang('Description') */
$my_course['teachers'] = self::getTeachersFromCourse($course_info['real_id'], true); $my_course['teachers'] = self::getTeachersFromCourse($course_info['real_id'], true);
$point_info = self::get_course_ranking($course_info['real_id'], 0); $point_info = self::get_course_ranking($course_info['real_id'], 0);
@ -5085,7 +5080,8 @@ class CourseManager
$visibilityCondition = self::getCourseVisibilitySQLCondition('c', true); $visibilityCondition = self::getCourseVisibilitySQLCondition('c', true);
if (!empty($accessUrlId) && $accessUrlId == intval($accessUrlId)) { if (!empty($accessUrlId) && $accessUrlId == intval($accessUrlId)) {
$sql = "SELECT count(c.id) FROM $tableCourse c, $tableCourseRelAccessUrl u $sql = "SELECT count(c.id)
FROM $tableCourse c, $tableCourseRelAccessUrl u
WHERE WHERE
c.id = u.c_id AND c.id = u.c_id AND
u.access_url_id = $accessUrlId AND u.access_url_id = $accessUrlId AND
@ -5163,8 +5159,11 @@ class CourseManager
$options[] = 'enter'; $options[] = 'enter';
} }
if ($course['visibility'] != COURSE_VISIBILITY_HIDDEN && empty($course['registration_code']) && $course['unsubscribe'] == UNSUBSCRIBE_ALLOWED && api_user_is_login($uid) && (in_array($course['real_id'], if ($course['visibility'] != COURSE_VISIBILITY_HIDDEN &&
$user_courses)) empty($course['registration_code']) &&
$course['unsubscribe'] == UNSUBSCRIBE_ALLOWED &&
api_user_is_login($uid) &&
in_array($course['real_id'], $user_courses)
) { ) {
$options[] = 'unsubscribe'; $options[] = 'unsubscribe';
} }
@ -5416,7 +5415,12 @@ class CourseManager
// Create // Create
Database::insert( Database::insert(
$courseSettingTable, $courseSettingTable,
['title' => $variable, 'value' => $value, 'c_id' => $courseId, 'variable' => $variable] [
'title' => $variable,
'value' => $value,
'c_id' => $courseId,
'variable' => $variable,
]
); );
} }
return true; return true;
@ -5444,9 +5448,10 @@ class CourseManager
* Get information from the track_e_course_access table * Get information from the track_e_course_access table
* @param int $sessionId * @param int $sessionId
* @param int $userId * @param int $userId
* @param int $limit
* @return array * @return array
*/ */
public static function getCourseAccessPerSessionAndUser($sessionId, $userId, $limit = null) public static function getCourseAccessPerSessionAndUser($sessionId, $userId, $limit = 0)
{ {
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
@ -5882,13 +5887,15 @@ class CourseManager
" WHERE access_start_date = '$startDate' AND access_end_date = '$endDate')" : null; " WHERE access_start_date = '$startDate' AND access_end_date = '$endDate')" : null;
$visibility = ($includeClosed ? '' : 'visibility NOT IN (0, 4) AND '); $visibility = ($includeClosed ? '' : 'visibility NOT IN (0, 4) AND ');
$query = "SELECT id, code, title $sql = "SELECT id, code, title
FROM " . Database::get_main_table(TABLE_MAIN_COURSE)." FROM ".Database::get_main_table(TABLE_MAIN_COURSE)."
WHERE $visibility code NOT IN ( WHERE $visibility code NOT IN (
SELECT DISTINCT course_code FROM ".Database::get_main_table(TABLE_MAIN_SESSION_COURSE).$dateConditional.") SELECT DISTINCT course_code
FROM ".Database::get_main_table(TABLE_MAIN_SESSION_COURSE).$dateConditional."
)
ORDER BY id"; ORDER BY id";
$result = Database::query($query); $result = Database::query($sql);
$courses = array(); $courses = array();
while ($row = Database::fetch_array($result)) { while ($row = Database::fetch_array($result)) {
$courses[] = $row; $courses[] = $row;
@ -5940,7 +5947,6 @@ class CourseManager
} }
$result = Database::query($sql); $result = Database::query($sql);
while ($row = Database::fetch_assoc($result)) { while ($row = Database::fetch_assoc($result)) {
$coursesList[] = $row; $coursesList[] = $row;
} }
@ -6246,8 +6252,11 @@ class CourseManager
* @param string $tableUserFieldValues The user extra field value table name * @param string $tableUserFieldValues The user extra field value table name
* @return int The number of users with this extra field with a specific value * @return int The number of users with this extra field with a specific value
*/ */
public static function getCountRegisteredUsersWithCourseExtraField($name, $tableExtraFields = '', $tableUserFieldValues = '') public static function getCountRegisteredUsersWithCourseExtraField(
{ $name,
$tableExtraFields = '',
$tableUserFieldValues = ''
) {
if (empty($tableExtraFields)) { if (empty($tableExtraFields)) {
$tableExtraFields = Database::get_main_table(TABLE_EXTRA_FIELD); $tableExtraFields = Database::get_main_table(TABLE_EXTRA_FIELD);
} }
@ -6256,7 +6265,6 @@ class CourseManager
} }
$registered_users_with_extra_field = 0; $registered_users_with_extra_field = 0;
if (!empty($name) && $name != '-') { if (!empty($name) && $name != '-') {
$extraFieldType = EntityExtraField::COURSE_FIELD_TYPE; $extraFieldType = EntityExtraField::COURSE_FIELD_TYPE;
$name = Database::escape_string($name); $name = Database::escape_string($name);

@ -1273,9 +1273,7 @@ class Display
// Creating the jqgrid element. // Creating the jqgrid element.
$json .= '$("#'.$div_id.'").jqGrid({'; $json .= '$("#'.$div_id.'").jqGrid({';
//$json .= $beforeSelectRow; //$json .= $beforeSelectRow;
$json .= $json_encode; $json .= $json_encode;
$json .= '});'; $json .= '});';
// Grouping headers option // Grouping headers option
@ -1575,50 +1573,8 @@ class Display
} }
$active = true; $active = true;
} else { } else {
/*$start = $stop = false;
$start_buffer = $stop_buffer = '';
if ($session_info['access_start_date'] === '0000-00-00 00:00:00' || empty($session_info['access_start_date'])) {
$session_info['access_start_date'] = '';
} else {
$start = true;
$start_buffer = $session_info['access_start_date'];
$session_info['access_start_date'] = $session_info['access_start_date'];
}
if ($session_info['access_end_date'] === '0000-00-00 00:00:00' || empty($session_info['access_end_date'])) {
$session_info['access_end_date'] = '';
} else {
$stop = true;
$stop_buffer = $session_info['access_end_date'];
$session_info['access_end_date'] = $session_info['access_end_date'];
}
if ($start && $stop) {
$session['dates'] = sprintf(
get_lang('FromDateXToDateY'),
api_format_date($start_buffer),
api_format_date($stop_buffer)
);
} else {
$start_buffer = $stop_buffer = null;
if (!empty($session_info['access_start_date'])) {
$start_buffer = sprintf(
get_lang('FromDateX'),
api_format_date(api_get_local_time($session_info['access_start_date']))
);
}
if (!empty($session_info['access_end_date'])) {
$stop_buffer = sprintf(
get_lang('UntilDateX'),
api_format_date(api_get_local_time($session_info['access_end_date']))
);
}*/
$dates = SessionManager::parseSessionDates($session_info, true); $dates = SessionManager::parseSessionDates($session_info, true);
//$session['dates'] = $start_buffer . ' ' . $stop_buffer.'- julio '.$dates['access'];
$session['dates'] = $dates['access']; $session['dates'] = $dates['access'];
if (api_get_setting('show_session_coach') === 'true') { if (api_get_setting('show_session_coach') === 'true') {
$session['coach'] = api_get_person_name( $session['coach'] = api_get_person_name(
$session_info['firstname'], $session_info['firstname'],
@ -2124,6 +2080,7 @@ class Display
return $html; return $html;
} }
/** /**
* *
* @param int $itemId * @param int $itemId
@ -2149,7 +2106,7 @@ class Display
$fixedValue = null, $fixedValue = null,
$linkAttributes = [] $linkAttributes = []
) { ) {
$defaultClass = "before"; $defaultClass = 'before';
$class = $defaultClass; $class = $defaultClass;
foreach ($conditions as $condition) { foreach ($conditions as $condition) {
$array = isset($condition['items']) ? $condition['items'] : array(); $array = isset($condition['items']) ? $condition['items'] : array();
@ -2178,13 +2135,13 @@ class Display
} }
} }
if ($isCurrent) { if ($isCurrent) {
$class = "before current"; $class = 'before current';
} }
if ($isMedia && $isCurrent) { if ($isMedia && $isCurrent) {
$class = "before current"; $class = 'before current';
} }
if (empty($link)) { if (empty($link)) {
$link_to_show = "#"; $link_to_show = '#';
} else { } else {
$link_to_show = $link.($nextValue + $localCounter); $link_to_show = $link.($nextValue + $localCounter);
} }
@ -2392,7 +2349,6 @@ class Display
if (!$colsWidth) { if (!$colsWidth) {
$width = 12 / $col; $width = 12 / $col;
array_walk($content, function() use ($width, &$colsWidth) { array_walk($content, function() use ($width, &$colsWidth) {
$colsWidth[] = $width; $colsWidth[] = $width;
}); });

Loading…
Cancel
Save