| Total Complexity | 179 |
| Total Lines | 1148 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like PageController often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use PageController, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 25 | class PageController |
||
| 26 | { |
||
| 27 | public $maxPerPage = 5; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Returns an online help block read from the home/home_menu_[lang].html |
||
| 31 | * file. |
||
| 32 | * |
||
| 33 | * @return string HTML block |
||
| 34 | */ |
||
| 35 | public function returnHelp() |
||
| 36 | { |
||
| 37 | $home = api_get_home_path(); |
||
| 38 | $user_selected_language = api_get_language_isocode(); |
||
| 39 | $sys_path = api_get_path(SYS_PATH); |
||
| 40 | $platformLanguage = api_get_setting('language.platform_language'); |
||
| 41 | |||
| 42 | if (!isset($user_selected_language)) { |
||
| 43 | $user_selected_language = $platformLanguage; |
||
| 44 | } |
||
| 45 | $home_menu = @(string) file_get_contents($sys_path.$home.'home_menu_'.$user_selected_language.'.html'); |
||
| 46 | if (!empty($home_menu)) { |
||
| 47 | $home_menu_content = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu))); |
||
| 48 | $this->show_right_block( |
||
| 49 | get_lang('MenuGeneral'), |
||
| 50 | null, |
||
| 51 | 'help_block', |
||
| 52 | ['content' => $home_menu_content] |
||
| 53 | ); |
||
| 54 | } |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Returns an HTML block with links to the skills tools. |
||
| 59 | * |
||
| 60 | * @return string HTML <div> block |
||
| 61 | */ |
||
| 62 | public function returnSkillsLinks() |
||
| 63 | { |
||
| 64 | if (api_get_setting('skill.allow_skills_tool') == 'true') { |
||
| 65 | $content = []; |
||
| 66 | $content[] = [ |
||
| 67 | 'title' => get_lang('MySkills'), |
||
| 68 | 'href' => api_get_path(WEB_CODE_PATH).'social/skills_wheel.php', |
||
| 69 | ]; |
||
| 70 | |||
| 71 | if (api_get_setting('skill.allow_hr_skills_management') == 'true' |
||
| 72 | || api_is_platform_admin()) { |
||
| 73 | $content[] = [ |
||
| 74 | 'title' => get_lang('ManageSkills'), |
||
| 75 | 'href' => api_get_path(WEB_CODE_PATH).'admin/skills_wheel.php', |
||
| 76 | ]; |
||
| 77 | } |
||
| 78 | $this->show_right_block(get_lang("Skills"), $content, 'skill_block'); |
||
| 79 | } |
||
| 80 | } |
||
| 81 | |||
| 82 | /** |
||
| 83 | * Returns an HTML block with the notice, as found in the |
||
| 84 | * home/home_notice_[lang].html file. |
||
| 85 | * |
||
| 86 | * @return string HTML <div> block |
||
| 87 | */ |
||
| 88 | public function returnNotice() |
||
| 89 | { |
||
| 90 | $sys_path = api_get_path(SYS_PATH); |
||
| 91 | $user_selected_language = api_get_language_isocode(); |
||
| 92 | $home = api_get_home_path(); |
||
| 93 | |||
| 94 | // Notice |
||
| 95 | $home_notice = @(string) file_get_contents($sys_path.$home.'home_notice_'.$user_selected_language.'.html'); |
||
| 96 | if (empty($home_notice)) { |
||
| 97 | $home_notice = @(string) file_get_contents($sys_path.$home.'home_notice.html'); |
||
| 98 | } |
||
| 99 | |||
| 100 | if (!empty($home_notice)) { |
||
| 101 | $home_notice = api_to_system_encoding($home_notice, api_detect_encoding(strip_tags($home_notice))); |
||
| 102 | $home_notice = Display::div($home_notice, ['class' => 'homepage_notice']); |
||
| 103 | |||
| 104 | $this->show_right_block(get_lang('Notice'), null, 'notice_block', ['content' => $home_notice]); |
||
| 105 | } |
||
| 106 | } |
||
| 107 | |||
| 108 | /** |
||
| 109 | * Returns the received content packaged in <div> block, with the title as |
||
| 110 | * <h4>. |
||
| 111 | * |
||
| 112 | * @param string Title to include as h4 |
||
| 113 | * @param string Longer content to show (usually a <ul> list) |
||
| 114 | * @param string ID to be added to the HTML attributes for the block |
||
| 115 | * @param array Array of attributes to add to the HTML block |
||
| 116 | * |
||
| 117 | * @return string HTML <div> block |
||
| 118 | * |
||
| 119 | * @todo use the menu builder |
||
| 120 | */ |
||
| 121 | public function show_right_block($title, $content, $id, $params = null) |
||
| 131 | ]; |
||
| 132 | |||
| 133 | //$app['template']->assign($id, $block_menu); |
||
| 134 | } |
||
| 135 | |||
| 136 | /** |
||
| 137 | * Returns a content search form in an HTML <div>, pointing at the |
||
| 138 | * main/search/ directory. If search_enabled is not set, then it returns |
||
| 139 | * an empty string. |
||
| 140 | * |
||
| 141 | * @return string HTML <div> block showing the search form, or an empty string if search not enabled |
||
| 142 | */ |
||
| 143 | public function return_search_block() |
||
| 158 | } |
||
| 159 | |||
| 160 | /** |
||
| 161 | * Return the homepage, including announcements. |
||
| 162 | * |
||
| 163 | * @return string The portal's homepage as an HTML string |
||
| 164 | */ |
||
| 165 | public function returnHomePage() |
||
| 166 | { |
||
| 167 | // Including the page for the news |
||
| 168 | $html = null; |
||
| 169 | $home = api_get_path(SYS_DATA_PATH).api_get_home_path(); |
||
|
|
|||
| 170 | $home_top_temp = null; |
||
| 171 | |||
| 172 | if (!empty($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/', $_GET['include'])) { |
||
| 173 | $open = @(string) file_get_contents(api_get_path(SYS_PATH).$home.$_GET['include']); |
||
| 174 | $html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open))); |
||
| 175 | } else { |
||
| 176 | $user_selected_language = api_get_user_language(); |
||
| 177 | |||
| 178 | if (!file_exists($home.'home_news_'.$user_selected_language.'.html')) { |
||
| 179 | if (file_exists($home.'home_top.html')) { |
||
| 180 | $home_top_temp = file($home.'home_top.html'); |
||
| 181 | } else { |
||
| 182 | //$home_top_temp = file('home/'.'home_top.html'); |
||
| 183 | } |
||
| 184 | if (!empty($home_top_temp)) { |
||
| 185 | $home_top_temp = implode('', $home_top_temp); |
||
| 186 | } |
||
| 187 | } else { |
||
| 188 | if (file_exists($home.'home_top_'.$user_selected_language.'.html')) { |
||
| 189 | $home_top_temp = file_get_contents($home.'home_top_'.$user_selected_language.'.html'); |
||
| 190 | } else { |
||
| 191 | $home_top_temp = file_get_contents($home.'home_top.html'); |
||
| 192 | } |
||
| 193 | } |
||
| 194 | |||
| 195 | if (empty($home_top_temp) && api_is_platform_admin()) { |
||
| 196 | $home_top_temp = get_lang('PortalHomepageDefaultIntroduction'); |
||
| 197 | } |
||
| 198 | $open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp); |
||
| 199 | if (!empty($open)) { |
||
| 200 | $html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open))); |
||
| 201 | } |
||
| 202 | } |
||
| 203 | |||
| 204 | return $html; |
||
| 205 | } |
||
| 206 | |||
| 207 | /** |
||
| 208 | * Returns an HTML block with classes (if show_groups_to_users is true). |
||
| 209 | * |
||
| 210 | * @return string A list of links to users classes tools, or an empty string if show_groups_to_users is disabled |
||
| 211 | */ |
||
| 212 | public function return_classes_block() |
||
| 242 | } |
||
| 243 | |||
| 244 | /** |
||
| 245 | * Prepares a block with all the pending exercises in all courses. |
||
| 246 | * |
||
| 247 | * @param array Array of courses (arrays) of the user |
||
| 248 | */ |
||
| 249 | public function return_exercise_block($personal_course_list, $tpl) |
||
| 250 | { |
||
| 251 | $exercise_list = []; |
||
| 252 | if (!empty($personal_course_list)) { |
||
| 253 | foreach ($personal_course_list as $course_item) { |
||
| 254 | $course_code = $course_item['c']; |
||
| 255 | $session_id = $course_item['id_session']; |
||
| 256 | |||
| 257 | $exercises = ExerciseLib::get_exercises_to_be_taken($course_code, $session_id); |
||
| 258 | |||
| 259 | foreach ($exercises as $exercise_item) { |
||
| 260 | $exercise_item['course_code'] = $course_code; |
||
| 261 | $exercise_item['session_id'] = $session_id; |
||
| 262 | $exercise_item['tms'] = api_strtotime($exercise_item['end_time'], 'UTC'); |
||
| 263 | |||
| 264 | $exercise_list[] = $exercise_item; |
||
| 265 | } |
||
| 266 | } |
||
| 267 | if (!empty($exercise_list)) { |
||
| 268 | $exercise_list = ArrayClass::msort($exercise_list, 'tms'); |
||
| 269 | $my_exercise = $exercise_list[0]; |
||
| 270 | $url = Display::url( |
||
| 271 | $my_exercise['title'], |
||
| 272 | api_get_path( |
||
| 273 | WEB_CODE_PATH |
||
| 274 | ).'exercise/overview.php?exerciseId='.$my_exercise['id'].'&cidReq='.$my_exercise['course_code'].'&id_session='.$my_exercise['session_id'] |
||
| 275 | ); |
||
| 276 | $tpl->assign('exercise_url', $url); |
||
| 277 | $tpl->assign( |
||
| 278 | 'exercise_end_date', |
||
| 279 | api_convert_and_format_date($my_exercise['end_time'], DATE_FORMAT_SHORT) |
||
| 280 | ); |
||
| 281 | } |
||
| 282 | } |
||
| 283 | } |
||
| 284 | |||
| 285 | /** |
||
| 286 | * Display list of courses in a category. |
||
| 287 | * (for anonymous users). |
||
| 288 | * |
||
| 289 | * @version 1.1 |
||
| 290 | * |
||
| 291 | * @author Patrick Cool <[email protected]>, Ghent University - refactoring and code cleaning |
||
| 292 | * @author Julio Montoya <[email protected]>, Beeznest template modifs |
||
| 293 | */ |
||
| 294 | public function return_courses_in_categories() |
||
| 295 | { |
||
| 296 | $result = ''; |
||
| 297 | $stok = Security::get_token(); |
||
| 298 | |||
| 299 | // Initialization. |
||
| 300 | $user_identified = (api_get_user_id() > 0 && !api_is_anonymous()); |
||
| 301 | $web_course_path = api_get_path(WEB_COURSE_PATH); |
||
| 302 | $category = Database::escape_string($_GET['category']); |
||
| 303 | $setting_show_also_closed_courses = api_get_setting('show_closed_courses') == 'true'; |
||
| 304 | |||
| 305 | // Database table definitions. |
||
| 306 | $main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE); |
||
| 307 | $main_category_table = Database :: get_main_table(TABLE_MAIN_CATEGORY); |
||
| 308 | |||
| 309 | // Get list of courses in category $category. |
||
| 310 | $sql_get_course_list = "SELECT * FROM $main_course_table cours |
||
| 311 | WHERE category_code = '".Database::escape_string($_GET['category'])."' |
||
| 312 | ORDER BY title, UPPER(visual_code)"; |
||
| 313 | |||
| 314 | // Showing only the courses of the current access_url_id. |
||
| 315 | if (api_is_multiple_url_enabled()) { |
||
| 316 | $url_access_id = api_get_current_access_url_id(); |
||
| 317 | if ($url_access_id != -1) { |
||
| 318 | $tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); |
||
| 319 | $sql_get_course_list = "SELECT * FROM $main_course_table as course INNER JOIN $tbl_url_rel_course as url_rel_course |
||
| 320 | ON (url_rel_course.c_id = course.id) |
||
| 321 | WHERE access_url_id = $url_access_id AND category_code = '".Database::escape_string( |
||
| 322 | $_GET['category'] |
||
| 323 | )."' ORDER BY title, UPPER(visual_code)"; |
||
| 324 | } |
||
| 325 | } |
||
| 326 | |||
| 327 | // Removed: AND cours.visibility='".COURSE_VISIBILITY_OPEN_WORLD."' |
||
| 328 | $sql_result_courses = Database::query($sql_get_course_list); |
||
| 329 | |||
| 330 | while ($course_result = Database::fetch_array($sql_result_courses)) { |
||
| 331 | $course_list[] = $course_result; |
||
| 332 | } |
||
| 333 | |||
| 334 | $platform_visible_courses = ''; |
||
| 335 | // $setting_show_also_closed_courses |
||
| 336 | if ($user_identified) { |
||
| 337 | if ($setting_show_also_closed_courses) { |
||
| 338 | $platform_visible_courses = ''; |
||
| 339 | } else { |
||
| 340 | $platform_visible_courses = " AND (t3.visibility='".COURSE_VISIBILITY_OPEN_WORLD."' OR t3.visibility='".COURSE_VISIBILITY_OPEN_PLATFORM."' )"; |
||
| 341 | } |
||
| 342 | } else { |
||
| 343 | if ($setting_show_also_closed_courses) { |
||
| 344 | $platform_visible_courses = ''; |
||
| 345 | } else { |
||
| 346 | $platform_visible_courses = " AND (t3.visibility='".COURSE_VISIBILITY_OPEN_WORLD."' )"; |
||
| 347 | } |
||
| 348 | } |
||
| 349 | $sqlGetSubCatList = " |
||
| 350 | SELECT t1.name,t1.code,t1.parent_id,t1.children_count,COUNT(DISTINCT t3.code) AS nbCourse |
||
| 351 | FROM $main_category_table t1 |
||
| 352 | LEFT JOIN $main_category_table t2 ON t1.code=t2.parent_id |
||
| 353 | LEFT JOIN $main_course_table t3 ON (t3.category_code=t1.code $platform_visible_courses) |
||
| 354 | WHERE t1.parent_id ".(empty($category) ? "IS NULL" : "='$category'")." |
||
| 355 | GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count ORDER BY t1.tree_pos, t1.name"; |
||
| 356 | |||
| 357 | // Showing only the category of courses of the current access_url_id |
||
| 358 | if (api_is_multiple_url_enabled()) { |
||
| 359 | $url_access_id = api_get_current_access_url_id(); |
||
| 360 | if ($url_access_id != -1) { |
||
| 361 | $tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); |
||
| 362 | $sqlGetSubCatList = " |
||
| 363 | SELECT t1.name,t1.code,t1.parent_id,t1.children_count,COUNT(DISTINCT t3.code) AS nbCourse |
||
| 364 | FROM $main_category_table t1 |
||
| 365 | LEFT JOIN $main_category_table t2 ON t1.code=t2.parent_id |
||
| 366 | LEFT JOIN $main_course_table t3 ON (t3.category_code=t1.code $platform_visible_courses) |
||
| 367 | INNER JOIN $tbl_url_rel_course as url_rel_course |
||
| 368 | ON (url_rel_course.c_id = t3.id) |
||
| 369 | WHERE access_url_id = $url_access_id AND t1.parent_id ".(empty($category) ? "IS NULL" : "='$category'")." |
||
| 370 | GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count ORDER BY t1.tree_pos, t1.name"; |
||
| 371 | } |
||
| 372 | } |
||
| 373 | |||
| 374 | $resCats = Database::query($sqlGetSubCatList); |
||
| 375 | $thereIsSubCat = false; |
||
| 376 | if (Database::num_rows($resCats) > 0) { |
||
| 377 | $htmlListCat = Display::page_header(get_lang('CatList')); |
||
| 378 | $htmlListCat .= '<ul>'; |
||
| 379 | while ($catLine = Database::fetch_array($resCats)) { |
||
| 380 | if ($catLine['code'] != $category) { |
||
| 381 | $category_has_open_courses = $this->category_has_open_courses($catLine['code']); |
||
| 382 | if ($category_has_open_courses) { |
||
| 383 | // The category contains courses accessible to anonymous visitors. |
||
| 384 | $htmlListCat .= '<li>'; |
||
| 385 | $htmlListCat .= '<a href="'.api_get_self( |
||
| 386 | ).'?category='.$catLine['code'].'">'.$catLine['name'].'</a>'; |
||
| 387 | if (api_get_setting('show_number_of_courses') == 'true') { |
||
| 388 | $htmlListCat .= ' ('.$catLine['nbCourse'].' '.get_lang('Courses').')'; |
||
| 389 | } |
||
| 390 | $htmlListCat .= "</li>"; |
||
| 391 | $thereIsSubCat = true; |
||
| 392 | } elseif ($catLine['children_count'] > 0) { |
||
| 393 | // The category has children, subcategories. |
||
| 394 | $htmlListCat .= '<li>'; |
||
| 395 | $htmlListCat .= '<a href="'.api_get_self( |
||
| 396 | ).'?category='.$catLine['code'].'">'.$catLine['name'].'</a>'; |
||
| 397 | $htmlListCat .= "</li>"; |
||
| 398 | $thereIsSubCat = true; |
||
| 399 | } elseif (api_get_setting('show_empty_course_categories') == 'true') { |
||
| 400 | /* End changed code to eliminate the (0 courses) after empty categories. */ |
||
| 401 | $htmlListCat .= '<li>'; |
||
| 402 | $htmlListCat .= $catLine['name']; |
||
| 403 | $htmlListCat .= "</li>"; |
||
| 404 | $thereIsSubCat = true; |
||
| 405 | } // Else don't set thereIsSubCat to true to avoid printing things if not requested. |
||
| 406 | } else { |
||
| 407 | $htmlTitre = '<p>'; |
||
| 408 | if (api_get_setting('show_back_link_on_top_of_tree') == 'true') { |
||
| 409 | $htmlTitre .= '<a href="'.api_get_self().'"><< '.get_lang('BackToHomePage').'</a>'; |
||
| 410 | } |
||
| 411 | if (!is_null($catLine['parent_id']) || |
||
| 412 | (api_get_setting('show_back_link_on_top_of_tree') != 'true' && |
||
| 413 | !is_null($catLine['code'])) |
||
| 414 | ) { |
||
| 415 | $htmlTitre .= '<a href="'.api_get_self( |
||
| 416 | ).'?category='.$catLine['parent_id'].'"><< '.get_lang('Up').'</a>'; |
||
| 417 | } |
||
| 418 | $htmlTitre .= "</p>"; |
||
| 419 | if ($category != "" && !is_null($catLine['code'])) { |
||
| 420 | $htmlTitre .= '<h3>'.$catLine['name']."</h3>"; |
||
| 421 | } else { |
||
| 422 | $htmlTitre .= '<h3>'.get_lang('Categories')."</h3>"; |
||
| 423 | } |
||
| 424 | } |
||
| 425 | } |
||
| 426 | $htmlListCat .= "</ul>"; |
||
| 427 | } |
||
| 428 | $result .= $htmlTitre; |
||
| 429 | if ($thereIsSubCat) { |
||
| 430 | $result .= $htmlListCat; |
||
| 431 | } |
||
| 432 | while ($categoryName = Database::fetch_array($resCats)) { |
||
| 433 | $result .= '<h3>'.$categoryName['name']."</h3>\n"; |
||
| 434 | } |
||
| 435 | $numrows = Database::num_rows($sql_result_courses); |
||
| 436 | $courses_list_string = ''; |
||
| 437 | $courses_shown = 0; |
||
| 438 | if ($numrows > 0) { |
||
| 439 | $courses_list_string .= Display::page_header(get_lang('CourseList')); |
||
| 440 | $courses_list_string .= "<ul>"; |
||
| 441 | |||
| 442 | if (api_get_user_id()) { |
||
| 443 | $courses_of_user = $this->get_courses_of_user(api_get_user_id()); |
||
| 444 | } |
||
| 445 | |||
| 446 | foreach ($course_list as $course) { |
||
| 447 | // $setting_show_also_closed_courses |
||
| 448 | if (!$setting_show_also_closed_courses) { |
||
| 449 | // If we do not show the closed courses |
||
| 450 | // we only show the courses that are open to the world (to everybody) |
||
| 451 | // and the courses that are open to the platform (if the current user is a registered user. |
||
| 452 | if (($user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) || ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD)) { |
||
| 453 | $courses_shown++; |
||
| 454 | $courses_list_string .= "<li>\n"; |
||
| 455 | $courses_list_string .= '<a href="'.$web_course_path.$course['directory'].'/">'.$course['title'].'</a><br />'; |
||
| 456 | $course_details = []; |
||
| 457 | if (api_get_setting('course.display_coursecode_in_courselist') == |
||
| 458 | 'true') { |
||
| 459 | $course_details[] = $course['visual_code']; |
||
| 460 | } |
||
| 461 | if (api_get_setting('course.display_teacher_in_courselist') == |
||
| 462 | 'true') { |
||
| 463 | $course_details[] = $course['tutor_name']; |
||
| 464 | } |
||
| 465 | if (api_get_setting('display.show_different_course_language') == |
||
| 466 | 'true' && $course['course_language'] != api_get_setting( |
||
| 467 | 'language.platform_language' |
||
| 468 | ) |
||
| 469 | ) { |
||
| 470 | $course_details[] = $course['course_language']; |
||
| 471 | } |
||
| 472 | $courses_list_string .= implode(' - ', $course_details); |
||
| 473 | $courses_list_string .= "</li>\n"; |
||
| 474 | } |
||
| 475 | } else { |
||
| 476 | // We DO show the closed courses. |
||
| 477 | // The course is accessible if (link to the course homepage): |
||
| 478 | // 1. the course is open to the world (doesn't matter if the user is logged in or not): $course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD); |
||
| 479 | // 2. the user is logged in and the course is open to the world or open to the platform: ($user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM); |
||
| 480 | // 3. the user is logged in and the user is subscribed to the course and the course visibility is not COURSE_VISIBILITY_CLOSED; |
||
| 481 | // 4. the user is logged in and the user is course admin of te course (regardless of the course visibility setting); |
||
| 482 | // 5. the user is the platform admin api_is_platform_admin(). |
||
| 483 | // |
||
| 484 | $courses_shown++; |
||
| 485 | $courses_list_string .= "<li>\n"; |
||
| 486 | if ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD |
||
| 487 | || ($user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) |
||
| 488 | || ($user_identified && key_exists( |
||
| 489 | $course['code'], |
||
| 490 | $courses_of_user |
||
| 491 | ) && $course['visibility'] != COURSE_VISIBILITY_CLOSED) |
||
| 492 | || $courses_of_user[$course['code']]['status'] == '1' |
||
| 493 | || api_is_platform_admin() |
||
| 494 | ) { |
||
| 495 | $courses_list_string .= '<a href="'.$web_course_path.$course['directory'].'/">'; |
||
| 496 | } |
||
| 497 | $courses_list_string .= $course['title']; |
||
| 498 | if ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD |
||
| 499 | || ($user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) |
||
| 500 | || ($user_identified && key_exists( |
||
| 501 | $course['code'], |
||
| 502 | $courses_of_user |
||
| 503 | ) && $course['visibility'] != COURSE_VISIBILITY_CLOSED) |
||
| 504 | || $courses_of_user[$course['code']]['status'] == '1' |
||
| 505 | || api_is_platform_admin() |
||
| 506 | ) { |
||
| 507 | $courses_list_string .= '</a><br />'; |
||
| 508 | } |
||
| 509 | $course_details = []; |
||
| 510 | if (api_get_setting('course.display_coursecode_in_courselist') == 'true') { |
||
| 511 | $course_details[] = $course['visual_code']; |
||
| 512 | } |
||
| 513 | if (api_get_setting('course.display_teacher_in_courselist') == 'true') { |
||
| 514 | $course_details[] = $course['tutor_name']; |
||
| 515 | } |
||
| 516 | if (api_get_setting( |
||
| 517 | 'display.show_different_course_language' |
||
| 518 | ) == 'true' && $course['course_language'] != api_get_setting( |
||
| 519 | 'language.platform_language' |
||
| 520 | ) |
||
| 521 | ) { |
||
| 522 | $course_details[] = $course['course_language']; |
||
| 523 | } |
||
| 524 | if (api_get_setting( |
||
| 525 | 'show_different_course_language' |
||
| 526 | ) == 'true' && $course['course_language'] != api_get_setting( |
||
| 527 | 'language.platform_language' |
||
| 528 | ) |
||
| 529 | ) { |
||
| 530 | $course_details[] = $course['course_language']; |
||
| 531 | } |
||
| 532 | |||
| 533 | $courses_list_string .= implode(' - ', $course_details); |
||
| 534 | // We display a subscription link if: |
||
| 535 | // 1. it is allowed to register for the course and if the course is not already in the courselist of the user and if the user is identiefied |
||
| 536 | // 2. |
||
| 537 | if ($user_identified && !array_key_exists($course['code'], $courses_of_user)) { |
||
| 538 | if ($course['subscribe'] == '1') { |
||
| 539 | $courses_list_string .= '<form action="main/auth/courses.php?action=subscribe&category='.Security::remove_XSS( |
||
| 540 | $_GET['category'] |
||
| 541 | ).'" method="post">'; |
||
| 542 | $courses_list_string .= '<input type="hidden" name="sec_token" value="'.$stok.'">'; |
||
| 543 | $courses_list_string .= '<input type="hidden" name="subscribe" value="'.$course['code'].'" />'; |
||
| 544 | $courses_list_string .= '<input type="image" name="unsub" src="'.api_get_path(WEB_IMG_PATH).'enroll.gif" alt="'.get_lang('Subscribe').'" />'.get_lang('Subscribe').' |
||
| 545 | </form>'; |
||
| 546 | } else { |
||
| 547 | $courses_list_string .= '<br />'.get_lang('SubscribingNotAllowed'); |
||
| 548 | } |
||
| 549 | } |
||
| 550 | $courses_list_string .= "</li>"; |
||
| 551 | } //end else |
||
| 552 | } // end foreach |
||
| 553 | $courses_list_string .= "</ul>"; |
||
| 554 | } |
||
| 555 | if ($courses_shown > 0) { |
||
| 556 | // Only display the list of courses and categories if there was more than |
||
| 557 | // 0 courses visible to the world (we're in the anonymous list here). |
||
| 558 | $result .= $courses_list_string; |
||
| 559 | } |
||
| 560 | if ($category != '') { |
||
| 561 | $result .= '<p><a href="'.api_get_self().'"> '.Display :: return_icon('back.png', get_lang('BackToHomePage')).get_lang('BackToHomePage').'</a></p>'; |
||
| 562 | } |
||
| 563 | |||
| 564 | return $result; |
||
| 565 | } |
||
| 566 | |||
| 567 | /** |
||
| 568 | * @param int $user_id |
||
| 569 | * @param string $filter |
||
| 570 | * @param int $page |
||
| 571 | * |
||
| 572 | * @return bool |
||
| 573 | */ |
||
| 574 | public function returnMyCourseCategories($user_id, $filter, $page) |
||
| 575 | { |
||
| 576 | if (empty($user_id)) { |
||
| 577 | return false; |
||
| 578 | } |
||
| 579 | $loadDirs = api_get_setting('document.show_documents_preview') == 'true' ? true : false; |
||
| 580 | $start = ($page - 1) * $this->maxPerPage; |
||
| 581 | |||
| 582 | $nbResults = (int) CourseManager::displayPersonalCourseCategories($user_id, $filter, $loadDirs, true); |
||
| 583 | |||
| 584 | $html = CourseManager::displayPersonalCourseCategories( |
||
| 585 | $user_id, |
||
| 586 | $filter, |
||
| 587 | $loadDirs, |
||
| 588 | false, |
||
| 589 | $start, |
||
| 590 | $this->maxPerPage |
||
| 591 | ); |
||
| 592 | |||
| 593 | $adapter = new FixedAdapter($nbResults, []); |
||
| 594 | $pagerfanta = new Pagerfanta($adapter); |
||
| 595 | $pagerfanta->setMaxPerPage($this->maxPerPage); // 10 by default |
||
| 596 | $pagerfanta->setCurrentPage($page); // 1 by default |
||
| 597 | |||
| 598 | $this->app['pagerfanta.view.router.name'] = 'userportal'; |
||
| 599 | $this->app['pagerfanta.view.router.params'] = [ |
||
| 600 | 'filter' => $filter, |
||
| 601 | 'type' => 'courses', |
||
| 602 | 'page' => $page, |
||
| 603 | ]; |
||
| 604 | $this->app['template']->assign('pagination', $pagerfanta); |
||
| 605 | |||
| 606 | return $html; |
||
| 607 | } |
||
| 608 | |||
| 609 | public function returnSpecialCourses($user_id, $filter, $page) |
||
| 610 | { |
||
| 611 | if (empty($user_id)) { |
||
| 612 | return false; |
||
| 613 | } |
||
| 614 | |||
| 615 | $loadDirs = api_get_setting('document.show_documents_preview') == 'true' ? true : false; |
||
| 616 | $start = ($page - 1) * $this->maxPerPage; |
||
| 617 | |||
| 618 | $nbResults = CourseManager::displaySpecialCourses($user_id, $filter, $loadDirs, true); |
||
| 619 | |||
| 620 | $html = CourseManager::displaySpecialCourses($user_id, $filter, $loadDirs, false, $start, $this->maxPerPage); |
||
| 621 | if (!empty($html)) { |
||
| 622 | $adapter = new FixedAdapter($nbResults, []); |
||
| 623 | $pagerfanta = new Pagerfanta($adapter); |
||
| 624 | $pagerfanta->setMaxPerPage($this->maxPerPage); // 10 by default |
||
| 625 | $pagerfanta->setCurrentPage($page); // 1 by default |
||
| 626 | $this->app['pagerfanta.view.router.name'] = 'userportal'; |
||
| 627 | $this->app['pagerfanta.view.router.params'] = [ |
||
| 628 | 'filter' => $filter, |
||
| 629 | 'type' => 'courses', |
||
| 630 | 'page' => $page, |
||
| 631 | ]; |
||
| 632 | $this->app['template']->assign('pagination', $pagerfanta); |
||
| 633 | } |
||
| 634 | |||
| 635 | return $html; |
||
| 636 | } |
||
| 637 | |||
| 638 | /** |
||
| 639 | * The most important function here, prints the session and course list (user_portal.php). |
||
| 640 | * |
||
| 641 | * @param int $user_id |
||
| 642 | * @param string $filter |
||
| 643 | * @param int $page |
||
| 644 | * |
||
| 645 | * @return string HTML list of sessions and courses |
||
| 646 | */ |
||
| 647 | public function returnCourses($user_id, $filter, $page) |
||
| 705 | } |
||
| 706 | |||
| 707 | public function returnSessionsCategories($user_id, $filter, $page) |
||
| 708 | { |
||
| 709 | if (empty($user_id)) { |
||
| 710 | return false; |
||
| 711 | } |
||
| 712 | |||
| 713 | $load_history = (isset($filter) && $filter == 'history') ? true : false; |
||
| 714 | |||
| 715 | $start = ($page - 1) * $this->maxPerPage; |
||
| 716 | |||
| 717 | $nbResults = UserManager::getCategories($user_id, false, true, true); |
||
| 718 | $session_categories = UserManager::getCategories( |
||
| 719 | $user_id, |
||
| 720 | false, |
||
| 721 | false, |
||
| 722 | true, |
||
| 723 | $start, |
||
| 724 | $this->maxPerPage |
||
| 725 | ); |
||
| 726 | |||
| 727 | $html = null; |
||
| 728 | //Showing history title |
||
| 729 | if ($load_history) { |
||
| 730 | $html .= Display::page_subheader(get_lang('HistoryTrainingSession')); |
||
| 731 | if (empty($session_categories)) { |
||
| 732 | $html .= get_lang('YouDoNotHaveAnySessionInItsHistory'); |
||
| 733 | } |
||
| 734 | } |
||
| 735 | |||
| 736 | $load_directories_preview = api_get_setting('document.show_documents_preview') == 'true' ? true : false; |
||
| 737 | $sessions_with_category = $html; |
||
| 738 | |||
| 739 | if (isset($session_categories) && !empty($session_categories)) { |
||
| 740 | foreach ($session_categories as $session_category) { |
||
| 741 | $session_category_id = $session_category['session_category']['id']; |
||
| 742 | |||
| 743 | // All sessions included in |
||
| 744 | $count_courses_session = 0; |
||
| 745 | $html_sessions = ''; |
||
| 746 | foreach ($session_category['sessions'] as $session) { |
||
| 747 | $session_id = $session['session_id']; |
||
| 748 | |||
| 749 | // Don't show empty sessions. |
||
| 750 | if (count($session['courses']) < 1) { |
||
| 751 | continue; |
||
| 752 | } |
||
| 753 | |||
| 754 | $html_courses_session = ''; |
||
| 755 | $count = 0; |
||
| 756 | foreach ($session['courses'] as $course) { |
||
| 757 | if (api_get_setting('session.hide_courses_in_sessions') == 'false') { |
||
| 758 | $html_courses_session .= CourseManager::get_logged_user_course_html($course, $session_id); |
||
| 759 | } |
||
| 760 | $count_courses_session++; |
||
| 761 | $count++; |
||
| 762 | } |
||
| 763 | |||
| 764 | $params = []; |
||
| 765 | if ($count > 0) { |
||
| 766 | $params['icon'] = Display::return_icon( |
||
| 767 | 'window_list.png', |
||
| 768 | $session['session_name'], |
||
| 769 | ['id' => 'session_img_'.$session_id], |
||
| 770 | ICON_SIZE_LARGE |
||
| 771 | ); |
||
| 772 | |||
| 773 | //Default session name |
||
| 774 | $session_link = $session['session_name']; |
||
| 775 | $params['link'] = null; |
||
| 776 | |||
| 777 | if (api_get_setting('session.session_page_enabled') == 'true' && !api_is_drh()) { |
||
| 778 | //session name with link |
||
| 779 | $session_link = Display::tag( |
||
| 780 | 'a', |
||
| 781 | $session['session_name'], |
||
| 782 | ['href' => api_get_path(WEB_CODE_PATH).'session/index.php?session_id='.$session_id] |
||
| 783 | ); |
||
| 784 | $params['link'] = api_get_path(WEB_CODE_PATH).'session/index.php?session_id='.$session_id; |
||
| 785 | } |
||
| 786 | |||
| 787 | $params['title'] = $session_link; |
||
| 788 | |||
| 789 | $moved_status = \SessionManager::getSessionChangeUserReason( |
||
| 790 | isset($session['moved_status']) ? $session['moved_status'] : '' |
||
| 791 | ); |
||
| 792 | $moved_status = isset($moved_status) && !empty($moved_status) ? ' ('.$moved_status.')' : null; |
||
| 793 | |||
| 794 | $params['subtitle'] = isset($session['coach_info']) ? $session['coach_info']['complete_name'] : null.$moved_status; |
||
| 795 | $params['dates'] = \SessionManager::parseSessionDates( |
||
| 796 | $session |
||
| 797 | ); |
||
| 798 | |||
| 799 | if (api_is_platform_admin()) { |
||
| 800 | $params['right_actions'] = '<a href="'.api_get_path(WEB_CODE_PATH).'session/resume_session.php?id_session='.$session_id.'">'.Display::return_icon( |
||
| 801 | 'edit.png', |
||
| 802 | get_lang('Edit'), |
||
| 803 | ['align' => 'absmiddle'], |
||
| 804 | ICON_SIZE_SMALL |
||
| 805 | ).'</a>'; |
||
| 806 | } |
||
| 807 | $html_sessions .= CourseManager::course_item_html($params, true).$html_courses_session; |
||
| 808 | } |
||
| 809 | } |
||
| 810 | |||
| 811 | if ($count_courses_session > 0) { |
||
| 812 | $params = []; |
||
| 813 | $params['icon'] = Display::return_icon( |
||
| 814 | 'folder_blue.png', |
||
| 815 | $session_category['session_category']['name'], |
||
| 816 | [], |
||
| 817 | ICON_SIZE_LARGE |
||
| 818 | ); |
||
| 819 | |||
| 820 | if (api_is_platform_admin()) { |
||
| 821 | $params['right_actions'] = '<a href="'.api_get_path( |
||
| 822 | WEB_CODE_PATH |
||
| 823 | ).'admin/session_category_edit.php?&id='.$session_category['session_category']['id'].'">'.Display::return_icon( |
||
| 824 | 'edit.png', |
||
| 825 | get_lang('Edit'), |
||
| 826 | [], |
||
| 827 | ICON_SIZE_SMALL |
||
| 828 | ).'</a>'; |
||
| 829 | } |
||
| 830 | |||
| 831 | $params['title'] = $session_category['session_category']['name']; |
||
| 832 | |||
| 833 | if (api_is_platform_admin()) { |
||
| 834 | $params['link'] = api_get_path( |
||
| 835 | WEB_CODE_PATH |
||
| 836 | ).'admin/session_category_edit.php?&id='.$session_category['session_category']['id']; |
||
| 837 | } |
||
| 838 | |||
| 839 | $session_category_start_date = $session_category['session_category']['date_start']; |
||
| 840 | $session_category_end_date = $session_category['session_category']['date_end']; |
||
| 841 | |||
| 842 | if (!empty($session_category_start_date) && $session_category_start_date != '0000-00-00' && !empty($session_category_end_date) && $session_category_end_date != '0000-00-00') { |
||
| 843 | $params['subtitle'] = sprintf( |
||
| 844 | get_lang('FromDateXToDateY'), |
||
| 845 | $session_category['session_category']['date_start'], |
||
| 846 | $session_category['session_category']['date_end'] |
||
| 847 | ); |
||
| 848 | } else { |
||
| 849 | if (!empty($session_category_start_date) && $session_category_start_date != '0000-00-00') { |
||
| 850 | $params['subtitle'] = get_lang('From').' '.$session_category_start_date; |
||
| 851 | } |
||
| 852 | if (!empty($session_category_end_date) && $session_category_end_date != '0000-00-00') { |
||
| 853 | $params['subtitle'] = get_lang('Until').' '.$session_category_end_date; |
||
| 854 | } |
||
| 855 | } |
||
| 856 | $sessions_with_category .= CourseManager::course_item_parent( |
||
| 857 | CourseManager::course_item_html($params, true), |
||
| 858 | $html_sessions |
||
| 859 | ); |
||
| 860 | } |
||
| 861 | } |
||
| 862 | |||
| 863 | //Pagination |
||
| 864 | $adapter = new FixedAdapter($nbResults, []); |
||
| 865 | $pagerfanta = new Pagerfanta($adapter); |
||
| 866 | $pagerfanta->setMaxPerPage($this->maxPerPage); // 10 by default |
||
| 867 | $pagerfanta->setCurrentPage($page); // 1 by default |
||
| 868 | |||
| 869 | $this->app['pagerfanta.view.router.name'] = 'userportal'; |
||
| 870 | $this->app['pagerfanta.view.router.params'] = [ |
||
| 871 | 'filter' => $filter, |
||
| 872 | 'type' => 'sessioncategories', |
||
| 873 | 'page' => $page, |
||
| 874 | ]; |
||
| 875 | $this->app['template']->assign('pagination', $pagerfanta); |
||
| 876 | } |
||
| 877 | |||
| 878 | return $sessions_with_category; |
||
| 879 | } |
||
| 880 | |||
| 881 | /** |
||
| 882 | * @param int $user_id |
||
| 883 | * @param string $filter current|history |
||
| 884 | * @param int $page |
||
| 885 | * |
||
| 886 | * @return bool|null|string |
||
| 887 | */ |
||
| 888 | public function returnSessions($user_id, $filter, $page) |
||
| 889 | { |
||
| 890 | if (empty($user_id)) { |
||
| 891 | return false; |
||
| 892 | } |
||
| 893 | |||
| 894 | $loadHistory = (isset($filter) && $filter == 'history') ? true : false; |
||
| 895 | |||
| 896 | /*$app['session_menu'] = function ($app) use ($loadHistory) { |
||
| 897 | $menu = $app['knp_menu.factory']->createItem( |
||
| 898 | 'root', |
||
| 899 | array( |
||
| 900 | 'childrenAttributes' => array( |
||
| 901 | 'class' => 'nav nav-tabs', |
||
| 902 | 'currentClass' => 'active' |
||
| 903 | ) |
||
| 904 | ) |
||
| 905 | ); |
||
| 906 | |||
| 907 | $current = $menu->addChild( |
||
| 908 | get_lang('Current'), |
||
| 909 | array( |
||
| 910 | 'route' => 'userportal', |
||
| 911 | 'routeParameters' => array( |
||
| 912 | 'filter' => 'current', |
||
| 913 | 'type' => 'sessions' |
||
| 914 | ) |
||
| 915 | ) |
||
| 916 | ); |
||
| 917 | $history = $menu->addChild( |
||
| 918 | get_lang('HistoryTrainingSession'), |
||
| 919 | array( |
||
| 920 | 'route' => 'userportal', |
||
| 921 | 'routeParameters' => array( |
||
| 922 | 'filter' => 'history', |
||
| 923 | 'type' => 'sessions' |
||
| 924 | ) |
||
| 925 | ) |
||
| 926 | ); |
||
| 927 | //@todo use URIVoter |
||
| 928 | if ($loadHistory) { |
||
| 929 | $history->setCurrent(true); |
||
| 930 | } else { |
||
| 931 | $current->setCurrent(true); |
||
| 932 | } |
||
| 933 | |||
| 934 | return $menu; |
||
| 935 | };*/ |
||
| 936 | |||
| 937 | //@todo move this in template |
||
| 938 | //$app['knp_menu.menus'] = array('actions_menu' => 'session_menu'); |
||
| 939 | |||
| 940 | $start = ($page - 1) * $this->maxPerPage; |
||
| 941 | |||
| 942 | if ($loadHistory) { |
||
| 943 | // Load sessions in category in *history*. |
||
| 944 | $nbResults = (int) UserManager::get_sessions_by_category( |
||
| 945 | $user_id, |
||
| 946 | true, |
||
| 947 | true, |
||
| 948 | true, |
||
| 949 | null, |
||
| 950 | null, |
||
| 951 | 'no_category' |
||
| 952 | ); |
||
| 953 | |||
| 954 | $session_categories = UserManager::get_sessions_by_category( |
||
| 955 | $user_id, |
||
| 956 | true, |
||
| 957 | false, |
||
| 958 | true, |
||
| 959 | $start, |
||
| 960 | $this->maxPerPage, |
||
| 961 | 'no_category' |
||
| 962 | ); |
||
| 963 | } else { |
||
| 964 | // Load sessions in category. |
||
| 965 | $nbResults = (int) UserManager::get_sessions_by_category( |
||
| 966 | $user_id, |
||
| 967 | false, |
||
| 968 | true, |
||
| 969 | false, |
||
| 970 | null, |
||
| 971 | null, |
||
| 972 | 'no_category' |
||
| 973 | ); |
||
| 974 | |||
| 975 | $session_categories = UserManager::get_sessions_by_category( |
||
| 976 | $user_id, |
||
| 977 | false, |
||
| 978 | false, |
||
| 979 | false, |
||
| 980 | $start, |
||
| 981 | $this->maxPerPage, |
||
| 982 | 'no_category' |
||
| 983 | ); |
||
| 984 | } |
||
| 985 | |||
| 986 | $html = null; |
||
| 987 | |||
| 988 | // Showing history title |
||
| 989 | if ($loadHistory) { |
||
| 990 | // $html .= Display::page_subheader(get_lang('HistoryTrainingSession')); |
||
| 991 | if (empty($session_categories)) { |
||
| 992 | $html .= get_lang('YouDoNotHaveAnySessionInItsHistory'); |
||
| 993 | } |
||
| 994 | } |
||
| 995 | |||
| 996 | $load_directories_preview = api_get_setting('document.show_documents_preview') === 'true' ? true : false; |
||
| 997 | $sessions_with_no_category = $html; |
||
| 998 | |||
| 999 | if (isset($session_categories) && !empty($session_categories)) { |
||
| 1000 | foreach ($session_categories as $session_category) { |
||
| 1001 | $session_category_id = $session_category['session_category']['id']; |
||
| 1002 | |||
| 1003 | // Sessions does not belong to a session category |
||
| 1004 | if ($session_category_id == 0) { |
||
| 1005 | // Independent sessions |
||
| 1006 | if (isset($session_category['sessions'])) { |
||
| 1007 | foreach ($session_category['sessions'] as $session) { |
||
| 1008 | $session_id = $session['session_id']; |
||
| 1009 | |||
| 1010 | // Don't show empty sessions. |
||
| 1011 | if (count($session['courses']) < 1) { |
||
| 1012 | continue; |
||
| 1013 | } |
||
| 1014 | |||
| 1015 | // Courses inside the current session. |
||
| 1016 | $date_session_start = $session['access_start_date']; |
||
| 1017 | $date_session_end = $session['access_end_date']; |
||
| 1018 | $coachAccessStartDate = $session['coach_access_start_date']; |
||
| 1019 | $coachAccessEndDate = $session['coach_access_end_date']; |
||
| 1020 | |||
| 1021 | $session_now = time(); |
||
| 1022 | $count_courses_session = 0; |
||
| 1023 | $count_courses_session = 0; |
||
| 1024 | |||
| 1025 | // Loop course content |
||
| 1026 | $html_courses_session = []; |
||
| 1027 | $atLeastOneCourseIsVisible = false; |
||
| 1028 | |||
| 1029 | foreach ($session['courses'] as $course) { |
||
| 1030 | $is_coach_course = api_is_coach($session_id, $course['real_id']); |
||
| 1031 | $allowed_time = 0; |
||
| 1032 | |||
| 1033 | // Read only and accessible |
||
| 1034 | if (api_get_setting('session.hide_courses_in_sessions') == 'false') { |
||
| 1035 | $courseUserHtml = CourseManager::get_logged_user_course_html( |
||
| 1036 | $course, |
||
| 1037 | $session_id, |
||
| 1038 | $load_directories_preview |
||
| 1039 | ); |
||
| 1040 | |||
| 1041 | if (isset($courseUserHtml[1])) { |
||
| 1042 | $course_session = $courseUserHtml[1]; |
||
| 1043 | $course_session['skill'] = isset($courseUserHtml['skill']) ? $courseUserHtml['skill'] : ''; |
||
| 1044 | $html_courses_session[] = $course_session; |
||
| 1045 | } |
||
| 1046 | } |
||
| 1047 | $count_courses_session++; |
||
| 1048 | } |
||
| 1049 | |||
| 1050 | if ($count_courses_session > 0) { |
||
| 1051 | $params = []; |
||
| 1052 | |||
| 1053 | $params['icon'] = Display::return_icon( |
||
| 1054 | 'window_list.png', |
||
| 1055 | $session['session_name'], |
||
| 1056 | ['id' => 'session_img_'.$session_id], |
||
| 1057 | ICON_SIZE_LARGE |
||
| 1058 | ); |
||
| 1059 | $params['is_session'] = true; |
||
| 1060 | //Default session name |
||
| 1061 | $session_link = $session['session_name']; |
||
| 1062 | $params['link'] = null; |
||
| 1063 | |||
| 1064 | if (api_get_setting('session.session_page_enabled') == 'true' && !api_is_drh()) { |
||
| 1065 | //session name with link |
||
| 1066 | $session_link = Display::tag( |
||
| 1067 | 'a', |
||
| 1068 | $session['session_name'], |
||
| 1069 | [ |
||
| 1070 | 'href' => api_get_path(WEB_CODE_PATH).'session/index.php?session_id='.$session_id, |
||
| 1071 | ] |
||
| 1072 | ); |
||
| 1073 | $params['link'] = api_get_path(WEB_CODE_PATH).'session/index.php?session_id='.$session_id; |
||
| 1074 | } |
||
| 1075 | |||
| 1076 | $params['title'] = $session_link; |
||
| 1077 | |||
| 1078 | $moved_status = \SessionManager::getSessionChangeUserReason( |
||
| 1079 | $session['moved_status'] ?? '' |
||
| 1080 | ); |
||
| 1081 | $moved_status = isset($moved_status) && !empty($moved_status) ? ' ('.$moved_status.')' : null; |
||
| 1082 | |||
| 1083 | $params['subtitle'] = isset($session['coach_info']) ? $session['coach_info']['complete_name'] : null.$moved_status; |
||
| 1084 | //$params['dates'] = $session['date_message']; |
||
| 1085 | |||
| 1086 | $params['dates'] = \SessionManager::parseSessionDates($session); |
||
| 1087 | $params['right_actions'] = ''; |
||
| 1088 | if (api_is_platform_admin()) { |
||
| 1089 | $params['right_actions'] .= |
||
| 1090 | Display::url( |
||
| 1091 | Display::return_icon( |
||
| 1092 | 'edit.png', |
||
| 1093 | get_lang('Edit'), |
||
| 1094 | ['align' => 'absmiddle'], |
||
| 1095 | ICON_SIZE_SMALL |
||
| 1096 | ), |
||
| 1097 | api_get_path(WEB_CODE_PATH).'session/resume_session.php?id_session='.$session_id |
||
| 1098 | ); |
||
| 1099 | } |
||
| 1100 | |||
| 1101 | if (api_get_setting('session.hide_courses_in_sessions') == 'false') { |
||
| 1102 | // $params['extra'] .= $html_courses_session; |
||
| 1103 | } |
||
| 1104 | $courseDataToString = CourseManager::parseCourseListData($html_courses_session); |
||
| 1105 | $sessions_with_no_category .= CourseManager::course_item_parent( |
||
| 1106 | CourseManager::course_item_html($params, true), |
||
| 1107 | $courseDataToString |
||
| 1108 | ); |
||
| 1109 | } |
||
| 1110 | } |
||
| 1111 | } |
||
| 1112 | } |
||
| 1113 | } |
||
| 1114 | |||
| 1115 | /*$adapter = new FixedAdapter($nbResults, array()); |
||
| 1116 | $pagerfanta = new Pagerfanta($adapter); |
||
| 1117 | $pagerfanta->setMaxPerPage($this->maxPerPage); // 10 by default |
||
| 1118 | $pagerfanta->setCurrentPage($page); // 1 by default |
||
| 1119 | |||
| 1120 | $this->app['pagerfanta.view.router.name'] = 'userportal'; |
||
| 1121 | $this->app['pagerfanta.view.router.params'] = array( |
||
| 1122 | 'filter' => $filter, |
||
| 1123 | 'type' => 'sessions', |
||
| 1124 | 'page' => $page |
||
| 1125 | ); |
||
| 1126 | $this->app['template']->assign('pagination', $pagerfanta);*/ |
||
| 1127 | } |
||
| 1128 | |||
| 1129 | return $sessions_with_no_category; |
||
| 1130 | } |
||
| 1131 | |||
| 1132 | /** |
||
| 1133 | * Shows a welcome message when the user doesn't have any content in |
||
| 1134 | * the course list. |
||
| 1135 | * |
||
| 1136 | * @param object A Template object used to declare variables usable in the given template |
||
| 1137 | */ |
||
| 1138 | public function return_welcome_to_course_block($tpl) |
||
| 1154 | } |
||
| 1155 | |||
| 1156 | /** |
||
| 1157 | * @param array |
||
| 1158 | */ |
||
| 1159 | public function returnNavigationLinks($items) |
||
| 1160 | { |
||
| 1161 | // Main navigation section. |
||
| 1176 |