Minor - format code

pull/2487/head
jmontoyaa 9 years ago
parent 392fa1b023
commit cbf58e8b2a
  1. 17
      main/inc/lib/sessionmanager.lib.php
  2. 79
      main/inc/lib/userportal.lib.php

@ -96,8 +96,8 @@ class SessionManager
* @param string $displayEndDate (YYYY-MM-DD hh:mm:ss)
* @param string $coachStartDate (YYYY-MM-DD hh:mm:ss)
* @param string $coachEndDate (YYYY-MM-DD hh:mm:ss)
* @param mixed $coachId If integer, this is the session coach id, if string, the coach ID will be looked for from the user table
* @param integer $sessionCategoryId ID of the session category in which this session is registered
* @param mixed $coachId If integer, this is the session coach id, if string, the coach ID will be looked for from the user table
* @param integer $visibility Visibility after end date (0 = read-only, 1 = invisible, 2 = accessible)
* @param bool $fixSessionNameIfExists
* @param string $duration
@ -293,7 +293,7 @@ class SessionManager
*
* @return bool
*/
public static function session_name_exists($name)
public static function sessionNameExists($name)
{
$name = Database::escape_string($name);
$sql = "SELECT COUNT(*) as count FROM ".Database::get_main_table(TABLE_MAIN_SESSION)."
@ -345,8 +345,8 @@ class SessionManager
$where_condition = str_replace('category_name', 'sc.name', $where_condition);
$where_condition = str_replace(
array("AND session_active = '1' )", " AND ( session_active = '1' )"),
array(') GROUP BY s.name HAVING session_active = 1 ', " GROUP BY s.name HAVING session_active = 1 ")
, $where_condition
array(') GROUP BY s.name HAVING session_active = 1 ', " GROUP BY s.name HAVING session_active = 1 "),
$where_condition
);
$where_condition = str_replace(
array("AND session_active = '0' )", " AND ( session_active = '0' )"),
@ -387,7 +387,6 @@ class SessionManager
$where $where_condition ) as session_table";
if (api_is_multiple_url_enabled()) {
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
$where .= " AND ar.access_url_id = $access_url_id ";
@ -1365,16 +1364,16 @@ class SessionManager
/**
* Creates a new course code based in given code
*
* @param string $session_name
* @param string $session_name
* <code>
* $wanted_code = 'curse' if there are in the DB codes like curse1 curse2 the function will return: course3
* if the course code doest not exist in the DB the same course code will be returned
* </code>
* @return string wanted unused code
* @return string wanted unused code
*/
public static function generateNextSessionName($session_name)
{
$session_name_ok = !self::session_name_exists($session_name);
$session_name_ok = !self::sessionNameExists($session_name);
if (!$session_name_ok) {
$table = Database::get_main_table(TABLE_MAIN_SESSION);
$session_name = Database::escape_string($session_name);
@ -1385,7 +1384,7 @@ class SessionManager
$row = Database::fetch_array($result);
$count = $row['count'] + 1;
$session_name = $session_name.'_'.$count;
$result = self::session_name_exists($session_name);
$result = self::sessionNameExists($session_name);
if (!$result) {
return $session_name;
}

@ -495,10 +495,11 @@ class IndexManager
}
// Removed: AND cours.visibility='".COURSE_VISIBILITY_OPEN_WORLD."'
$sql_result_courses = Database::query($sql);
while ($course_result = Database::fetch_array($sql_result_courses)) {
$queryResult = Database::query($sql);
while ($course_result = Database::fetch_array($queryResult)) {
$course_list[] = $course_result;
}
$numRows = Database::num_rows($queryResult);
// $setting_show_also_closed_courses
if ($user_identified) {
@ -520,8 +521,10 @@ class IndexManager
t1.parent_id,
t1.children_count,COUNT(DISTINCT t3.code) AS nbCourse
FROM $main_category_table t1
LEFT JOIN $main_category_table t2 ON t1.code=t2.parent_id
LEFT JOIN $main_course_table t3 ON (t3.category_code = t1.code $platform_visible_courses)
LEFT JOIN $main_category_table t2
ON t1.code=t2.parent_id
LEFT JOIN $main_course_table t3
ON (t3.category_code = t1.code $platform_visible_courses)
WHERE t1.parent_id ".(empty($category) ? "IS NULL" : "='$category'")."
GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count
ORDER BY t1.tree_pos, t1.name";
@ -602,10 +605,10 @@ class IndexManager
while ($categoryName = Database::fetch_array($resCats)) {
$result .= '<h3>'.$categoryName['name']."</h3>\n";
}
$numrows = Database::num_rows($sql_result_courses);
$courses_list_string = '';
$courses_shown = 0;
if ($numrows > 0) {
if ($numRows > 0) {
$courses_list_string .= Display::page_header(get_lang('CourseList'));
$courses_list_string .= "<ul>";
if (api_get_user_id()) {
@ -671,9 +674,6 @@ class IndexManager
if (api_get_setting('display_coursecode_in_courselist') == 'true') {
$course_details[] = $course['visual_code'];
}
// if (api_get_setting('display_coursecode_in_courselist') == 'true' && api_get_setting('display_teacher_in_courselist') == 'true') {
// $courses_list_string .= ' - ';
// }
if (api_get_setting('display_teacher_in_courselist') === 'true') {
if (!empty($course['tutor_name'])) {
$course_details[] = $course['tutor_name'];
@ -917,7 +917,6 @@ class IndexManager
}
$userGroup = new UserGroup();
$profile_content = '<ul class="nav nav-pills nav-stacked">';
// @todo Add a platform setting to add the user image.
@ -925,7 +924,9 @@ class IndexManager
// New messages.
$number_of_new_messages = MessageManager::getCountNewMessages();
// New contact invitations.
$number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id(api_get_user_id());
$number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id(
api_get_user_id()
);
// New group invitations sent by a moderator.
$group_pending_invitations = $userGroup->get_groups_by_user(
@ -934,7 +935,6 @@ class IndexManager
false
);
$group_pending_invitations = count($group_pending_invitations);
$total_invitations = $number_of_new_messages_of_friend + $group_pending_invitations;
$cant_msg = Display::badge($number_of_new_messages);
@ -964,7 +964,6 @@ class IndexManager
if (api_get_setting('allow_my_files') === 'false') {
$myFiles = '';
}
$profile_content .= $myFiles;
}
}
@ -1009,7 +1008,6 @@ class IndexManager
public function return_navigation_links()
{
$html = '';
// Deleting the myprofile link.
if (api_get_setting('allow_social_tool') == 'true') {
unset($this->tpl->menu_navigation['myprofile']);
@ -1046,7 +1044,6 @@ class IndexManager
$html = '';
$show_create_link = false;
$show_course_link = false;
if (api_is_allowed_to_create_course()) {
$show_create_link = true;
}
@ -1077,11 +1074,16 @@ class IndexManager
}
}
//Sort courses
// Sort courses
$url = api_get_path(WEB_CODE_PATH).'auth/courses.php?action=sortmycourses';
$img_order = Display::return_icon('order-course.png', get_lang('SortMyCourses'));
$my_account_content .= '<li class="order-course">'.Display::url($img_order.get_lang('SortMyCourses'), $url,
array('class' => 'sort course')).'</li>';
$my_account_content .= '<li class="order-course">'.
Display::url(
$img_order.get_lang('SortMyCourses'),
$url,
array('class' => 'sort course')
).
'</li>';
// Session history
if (isset($_GET['history']) && intval($_GET['history']) == 1) {
@ -1205,13 +1207,18 @@ class IndexManager
$specialCourses[$key]['student_info']['certificate'] = null;
if (isset($category[0])) {
if ($category[0]->is_certificate_available($user_id)) {
$specialCourses[$key]['student_info']['certificate'] = Display::label(get_lang('Yes'), 'success');
$specialCourses[$key]['student_info']['certificate'] = Display::label(
get_lang('Yes'),
'success'
);
} else {
$specialCourses[$key]['student_info']['certificate'] = Display::label(get_lang('No'), 'danger');
$specialCourses[$key]['student_info']['certificate'] = Display::label(
get_lang('No'),
'danger'
);
}
}
}
}
}
@ -1262,17 +1269,17 @@ class IndexManager
}
}
}
}
}
}
foreach ($courses['not_category'] as $key => $courseNotInCatInfo) {
if ($studentInfoProgress) {
$progress = Tracking::get_avg_student_progress(
$user_id,
$courseNotInCatInfo['course_code']
);
$courses['not_category'][$key]['student_info']['progress'] = ($progress === false)? null : $progress;
$courses['not_category'][$key]['student_info']['progress'] = $progress === false ? null : $progress;
}
if ($studentInfoScore) {
@ -1303,15 +1310,23 @@ class IndexManager
$courses['not_category'][$key]['student_info']['certificate'] = get_lang('No');
}
} else {
if ($category[0]->is_certificate_available($user_id)) {
$courses['not_category'][$key]['student_info']['certificate'] = Display::label(get_lang('Yes'), 'success');
if ($category[0]->is_certificate_available(
$user_id
)
) {
$courses['not_category'][$key]['student_info']['certificate'] = Display::label(
get_lang('Yes'),
'success'
);
} else {
$courses['not_category'][$key]['student_info']['certificate'] = Display::label(get_lang('No'), 'danger');
$courses['not_category'][$key]['student_info']['certificate'] = Display::label(
get_lang('No'),
'danger'
);
}
}
}
}
}
}
@ -1354,7 +1369,6 @@ class IndexManager
// Declared listSession variable
$listSession = [];
$session_now = time();
if (is_array($session_categories)) {
foreach ($session_categories as $session_category) {
@ -1479,7 +1493,6 @@ class IndexManager
}
}
}
$html_courses_session[] = $course_session;
}
}
@ -1775,10 +1788,10 @@ class IndexManager
$load_history = (isset($_GET['history']) && intval($_GET['history']) == 1) ? true : false;
if ($load_history) {
//Load sessions in category in *history*
// Load sessions in category in *history*
$session_categories = UserManager::get_sessions_by_category($user_id, true);
} else {
//Load sessions in category
// Load sessions in category
$session_categories = UserManager::get_sessions_by_category($user_id, false);
}
@ -2079,7 +2092,6 @@ class IndexManager
private static function getHtmlForSession($id, $title, $categorySessionId, $courseInfo)
{
$html = '';
if ($categorySessionId == 0) {
$class1 = 'session-view-lvl-2'; // session
$class2 = 'session-view-lvl-4'; // got to course in session link
@ -2157,7 +2169,8 @@ class IndexManager
}
/**
* Get the session coach name, duration or dates when $_configuration['show_simple_session_info'] is enabled
* Get the session coach name, duration or dates
* when $_configuration['show_simple_session_info'] is enabled
* @param string $coachName
* @param string $dates
* @param string|null $duration Optional

Loading…
Cancel
Save