userportal.lib.php 75 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Class IndexManager
  5. */
  6. class IndexManager
  7. {
  8. const VIEW_BY_DEFAULT = 0;
  9. const VIEW_BY_SESSION = 1;
  10. // An instance of the template engine
  11. public $tpl = false;
  12. public $name = '';
  13. public $home = '';
  14. public $default_home = 'home/';
  15. /**
  16. * Construct
  17. * @param string $title
  18. */
  19. public function __construct($title)
  20. {
  21. $this->tpl = new Template($title);
  22. $this->home = api_get_home_path();
  23. $this->user_id = api_get_user_id();
  24. $this->load_directories_preview = false;
  25. if (api_get_setting('show_documents_preview') == 'true') {
  26. $this->load_directories_preview = true;
  27. }
  28. }
  29. /**
  30. * @param bool $setLoginForm
  31. */
  32. function set_login_form($setLoginForm = true)
  33. {
  34. global $loginFailed;
  35. $this->tpl->setLoginForm($setLoginForm);
  36. }
  37. function return_exercise_block($personal_course_list)
  38. {
  39. $exercise_list = array();
  40. if (!empty($personal_course_list)) {
  41. foreach($personal_course_list as $course_item) {
  42. $course_code = $course_item['c'];
  43. $session_id = $course_item['id_session'];
  44. $exercises = ExerciseLib::get_exercises_to_be_taken(
  45. $course_code,
  46. $session_id
  47. );
  48. foreach($exercises as $exercise_item) {
  49. $exercise_item['course_code'] = $course_code;
  50. $exercise_item['session_id'] = $session_id;
  51. $exercise_item['tms'] = api_strtotime($exercise_item['end_time'], 'UTC');
  52. $exercise_list[] = $exercise_item;
  53. }
  54. }
  55. if (!empty($exercise_list)) {
  56. $exercise_list = msort($exercise_list, 'tms');
  57. $my_exercise = $exercise_list[0];
  58. $url = Display::url($my_exercise['title'], api_get_path(WEB_CODE_PATH).'exercice/overview.php?exerciseId='.$my_exercise['id'].'&cidReq='.$my_exercise['course_code'].'&id_session='.$my_exercise['session_id']);
  59. $this->tpl->assign('exercise_url', $url);
  60. $this->tpl->assign('exercise_end_date', api_convert_and_format_date($my_exercise['end_time'], DATE_FORMAT_SHORT));
  61. }
  62. }
  63. }
  64. function return_announcements($show_slide = true)
  65. {
  66. //// Display System announcements
  67. $hideAnnouncements = api_get_setting('hide_global_announcements_when_not_connected');
  68. if ($hideAnnouncements == 'true' && empty($userId)) {
  69. return null;
  70. }
  71. $announcement = isset($_GET['announcement']) ? $_GET['announcement'] : null;
  72. $announcement = intval($announcement);
  73. if (!api_is_anonymous() && $this->user_id) {
  74. $visibility = api_is_allowed_to_create_course() ? SystemAnnouncementManager::VISIBLE_TEACHER : SystemAnnouncementManager::VISIBLE_STUDENT;
  75. if ($show_slide) {
  76. $announcements = SystemAnnouncementManager:: display_announcements_slider(
  77. $visibility,
  78. $announcement
  79. );
  80. } else {
  81. $announcements = SystemAnnouncementManager:: display_all_announcements(
  82. $visibility,
  83. $announcement
  84. );
  85. }
  86. } else {
  87. if ($show_slide) {
  88. $announcements = SystemAnnouncementManager:: display_announcements_slider(
  89. SystemAnnouncementManager::VISIBLE_GUEST,
  90. $announcement
  91. );
  92. } else {
  93. $announcements = SystemAnnouncementManager:: display_all_announcements(
  94. SystemAnnouncementManager::VISIBLE_GUEST,
  95. $announcement
  96. );
  97. }
  98. }
  99. return $announcements;
  100. }
  101. /**
  102. * Alias for the online_logout() function
  103. * @param bool $redirect Whether to ask online_logout to redirect to index.php or not
  104. */
  105. function logout($redirect = true)
  106. {
  107. online_logout($this->user_id, true);
  108. }
  109. /**
  110. * This function checks if there are courses that are open to the world in the platform course categories (=faculties)
  111. *
  112. * @param string $category
  113. * @return boolean
  114. */
  115. function category_has_open_courses($category)
  116. {
  117. $setting_show_also_closed_courses = api_get_setting('show_closed_courses') == 'true';
  118. $main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
  119. $category = Database::escape_string($category);
  120. $sql_query = "SELECT * FROM $main_course_table WHERE category_code='$category'";
  121. $sql_result = Database::query($sql_query);
  122. while ($course = Database::fetch_array($sql_result)) {
  123. if (!$setting_show_also_closed_courses) {
  124. if ((api_get_user_id() > 0 && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) || ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD)) {
  125. return true; //at least one open course
  126. }
  127. } else {
  128. if (isset($course['visibility'])) {
  129. return true; // At least one course (it does not matter weither it's open or not because $setting_show_also_closed_courses = true).
  130. }
  131. }
  132. }
  133. return false;
  134. }
  135. function return_teacher_link()
  136. {
  137. $html = '';
  138. $show_menu = false;
  139. if (!empty($this->user_id)) {
  140. // tabs that are deactivated are added here
  141. $show_menu = false;
  142. $show_create_link = false;
  143. $show_course_link = false;
  144. if (api_is_platform_admin() || api_is_course_admin() || api_is_allowed_to_create_course()) {
  145. $show_menu = true;
  146. $show_course_link = true;
  147. $show_create_link = true;
  148. } else {
  149. if (api_get_setting('allow_students_to_browse_courses') == 'true') {
  150. $show_menu = true;
  151. $show_course_link = true;
  152. }
  153. }
  154. if ($show_menu && ($show_create_link || $show_course_link )) {
  155. $show_menu = true;
  156. } else {
  157. $show_menu = false;
  158. }
  159. }
  160. // My Account section
  161. if ($show_menu) {
  162. $html .= '<ul class="nav nav-pills nav-stacked">';
  163. if ($show_create_link) {
  164. $html .= '<li class="add-course"><a href="' . api_get_path(WEB_CODE_PATH) . 'create_course/add_course.php">'.Display::return_icon('new-course.png', get_lang('CourseCreate')).(api_get_setting('course_validation') == 'true' ? get_lang('CreateCourseRequest') : get_lang('CourseCreate')).'</a></li>';
  165. }
  166. if ($show_course_link) {
  167. if (!api_is_drh() && !api_is_session_admin()) {
  168. $html .= '<li class="list-course"><a href="'. api_get_path(WEB_CODE_PATH) . 'auth/courses.php">'. Display::return_icon('catalog-course.png', get_lang('CourseCatalog')) .get_lang('CourseCatalog').'</a></li>';
  169. } else {
  170. $html .= '<li><a href="' . api_get_path(WEB_CODE_PATH) . 'dashboard/index.php">'.get_lang('Dashboard').'</a></li>';
  171. }
  172. }
  173. $html .= '</ul>';
  174. }
  175. if (!empty($html)) {
  176. $html = self::show_right_block(get_lang('Courses'), $html, 'teacher_block', null, 'teachers', 'teachersCollapse');
  177. }
  178. return $html;
  179. }
  180. /**
  181. * Includes a created page
  182. * @return string
  183. */
  184. public function return_home_page()
  185. {
  186. $userId = api_get_user_id();
  187. // Including the page for the news
  188. $html = '';
  189. if (!empty($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/', $_GET['include'])) {
  190. $open = @(string)file_get_contents(api_get_path(SYS_PATH).$this->home.$_GET['include']);
  191. $html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
  192. } else {
  193. // Hiding home top when user not connected.
  194. $hideTop = api_get_setting('hide_home_top_when_connected');
  195. if ($hideTop == 'true' && !empty($userId)) {
  196. return $html;
  197. }
  198. if (!empty($_SESSION['user_language_choice'])) {
  199. $user_selected_language = $_SESSION['user_language_choice'];
  200. } elseif (!empty($_SESSION['_user']['language'])) {
  201. $user_selected_language = $_SESSION['_user']['language'];
  202. } else {
  203. $user_selected_language = api_get_setting('platformLanguage');
  204. }
  205. // Try language specific home
  206. if (file_exists($this->home.'home_top_'.$user_selected_language.'.html')) {
  207. $home_top_temp = file_get_contents($this->home.'home_top_'.$user_selected_language.'.html');
  208. }
  209. // Try default language home
  210. if (empty($home_top_temp)) {
  211. if (file_exists($this->home.'home_top.html')) {
  212. $home_top_temp = file_get_contents($this->home.'home_top.html');
  213. } else {
  214. if (file_exists($this->default_home.'home_top.html')) {
  215. $home_top_temp = file_get_contents($this->default_home . 'home_top.html');
  216. }
  217. }
  218. }
  219. if (trim($home_top_temp) == '' && api_is_platform_admin()) {
  220. $home_top_temp = '<div class="welcome-mascot">' . get_lang('PortalHomepageDefaultIntroduction') . '</div>';
  221. } else {
  222. $home_top_temp = '<div class="welcome-home-top-temp">' . $home_top_temp . '</div>';
  223. }
  224. $open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp);
  225. $html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
  226. }
  227. return $html;
  228. }
  229. function return_notice()
  230. {
  231. $sys_path = api_get_path(SYS_PATH);
  232. $user_selected_language = api_get_interface_language();
  233. $html = '';
  234. // Notice
  235. $home_notice = @(string)file_get_contents($sys_path.$this->home.'home_notice_'.$user_selected_language.'.html');
  236. if (empty($home_notice)) {
  237. $home_notice = @(string)file_get_contents($sys_path.$this->home.'home_notice.html');
  238. }
  239. if (!empty($home_notice)) {
  240. $home_notice = api_to_system_encoding($home_notice, api_detect_encoding(strip_tags($home_notice)));
  241. //$home_notice = Display::div($home_notice, array('class' => 'homepage_notice'));
  242. $html = self::show_right_block(get_lang('Notice'), $home_notice, 'notice_block', null, 'notices', 'noticesCollapse');
  243. }
  244. return $html;
  245. }
  246. function return_help()
  247. {
  248. $user_selected_language = api_get_interface_language();
  249. $sys_path = api_get_path(SYS_PATH);
  250. $platformLanguage = api_get_setting('platformLanguage');
  251. // Help section.
  252. /* Hide right menu "general" and other parts on anonymous right menu. */
  253. if (!isset($user_selected_language)) {
  254. $user_selected_language = $platformLanguage;
  255. }
  256. $html = null;
  257. $home_menu = @(string)file_get_contents($sys_path.$this->home.'home_menu_'.$user_selected_language.'.html');
  258. if (!empty($home_menu)) {
  259. $home_menu_content = '<ul class="nav nav-pills nav-stacked">';
  260. $home_menu_content .= api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
  261. $home_menu_content .= '</ul>';
  262. $html .= self::show_right_block(get_lang('MenuGeneral'), $home_menu_content, 'help_block', null, 'helps', 'helpsCollapse');
  263. }
  264. return $html;
  265. }
  266. function return_skills_links()
  267. {
  268. $content = '';
  269. $content .= '<ul class="nav nav-pills nav-stacked">';
  270. /**
  271. * Generate the block for show a panel with links to My Certificates and Certificates Search pages
  272. * @return string The HTML code for the panel
  273. */
  274. $certificatesItem = null;
  275. if (!api_is_anonymous()) {
  276. $certificatesItem = Display::tag(
  277. 'li',
  278. Display::url(Display::return_icon('graduation.png',get_lang('MyCertificates'),null,ICON_SIZE_SMALL).
  279. get_lang('MyCertificates'),
  280. api_get_path(WEB_CODE_PATH) . "gradebook/my_certificates.php"
  281. )
  282. );
  283. }
  284. $searchItem = null;
  285. if (api_get_setting('allow_public_certificates') == 'true') {
  286. $searchItem = Display::tag(
  287. 'li',
  288. Display::url(Display::return_icon('search_graduation.png',get_lang('Search'),null,ICON_SIZE_SMALL).
  289. get_lang('Search'),
  290. api_get_path(WEB_CODE_PATH) . "gradebook/search.php"
  291. )
  292. );
  293. }
  294. if (empty($certificatesItem) && empty($searchItem)) {
  295. return null;
  296. }else{
  297. $content.= $certificatesItem;
  298. $content.= $searchItem;
  299. }
  300. if (api_get_setting('allow_skills_tool') == 'true') {
  301. $content .= Display::tag('li', Display::url(Display::return_icon('skill-badges.png',get_lang('MySkills'),null,ICON_SIZE_SMALL).get_lang('MySkills'), api_get_path(WEB_CODE_PATH).'social/my_skills_report.php'));
  302. $allowSkillsManagement = api_get_setting('allow_hr_skills_management') == 'true';
  303. if (($allowSkillsManagement && api_is_drh()) || api_is_platform_admin()) {
  304. $content .= Display::tag('li',
  305. Display::url(Display::return_icon('edit-skill.png', get_lang('MySkills'), null,
  306. ICON_SIZE_SMALL) . get_lang('ManageSkills'),
  307. api_get_path(WEB_CODE_PATH) . 'admin/skills_wheel.php'));
  308. }
  309. }
  310. $content .= '</ul>';
  311. $html = self::show_right_block(
  312. get_lang("Skills"),
  313. $content,
  314. 'skill_block',
  315. null,
  316. 'skills',
  317. 'skillsCollapse'
  318. );
  319. return $html;
  320. }
  321. /**
  322. * Reacts on a failed login:
  323. * Displays an explanation with a link to the registration form.
  324. *
  325. * @version 1.0.1
  326. */
  327. function handle_login_failed()
  328. {
  329. return $this->tpl->handleLoginFailed();
  330. }
  331. /**
  332. * Display list of courses in a category.
  333. * (for anonymous users)
  334. *
  335. * @version 1.1
  336. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University - refactoring and code cleaning
  337. * @author Julio Montoya <gugli100@gmail.com>, Beeznest template modifs
  338. */
  339. function return_courses_in_categories()
  340. {
  341. $result = '';
  342. $stok = Security::get_token();
  343. // Initialization.
  344. $user_identified = (api_get_user_id() > 0 && !api_is_anonymous());
  345. $web_course_path = api_get_path(WEB_COURSE_PATH);
  346. $category = Database::escape_string($_GET['category']);
  347. $setting_show_also_closed_courses = api_get_setting('show_closed_courses') == 'true';
  348. // Database table definitions.
  349. $main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
  350. $main_category_table = Database :: get_main_table(TABLE_MAIN_CATEGORY);
  351. // Get list of courses in category $category.
  352. $sql_get_course_list = "SELECT * FROM $main_course_table cours
  353. WHERE category_code = '".Database::escape_string($_GET['category'])."'
  354. ORDER BY title, UPPER(visual_code)";
  355. // Showing only the courses of the current access_url_id.
  356. if (api_is_multiple_url_enabled()) {
  357. $url_access_id = api_get_current_access_url_id();
  358. if ($url_access_id != -1) {
  359. $tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
  360. $sql_get_course_list = "SELECT * FROM $main_course_table as course
  361. INNER JOIN $tbl_url_rel_course as url_rel_course
  362. ON (url_rel_course.c_id = course.id)
  363. WHERE
  364. access_url_id = $url_access_id AND
  365. category_code = '".Database::escape_string($_GET['category'])."'
  366. ORDER BY title, UPPER(visual_code)";
  367. }
  368. }
  369. // Removed: AND cours.visibility='".COURSE_VISIBILITY_OPEN_WORLD."'
  370. $sql_result_courses = Database::query($sql_get_course_list);
  371. while ($course_result = Database::fetch_array($sql_result_courses)) {
  372. $course_list[] = $course_result;
  373. }
  374. // $setting_show_also_closed_courses
  375. if ($user_identified) {
  376. if ($setting_show_also_closed_courses) {
  377. $platform_visible_courses = '';
  378. } else {
  379. $platform_visible_courses = " AND (t3.visibility='".COURSE_VISIBILITY_OPEN_WORLD."' OR t3.visibility='".COURSE_VISIBILITY_OPEN_PLATFORM."' )";
  380. }
  381. } else {
  382. if ($setting_show_also_closed_courses) {
  383. $platform_visible_courses = '';
  384. } else {
  385. $platform_visible_courses = " AND (t3.visibility='".COURSE_VISIBILITY_OPEN_WORLD."' )";
  386. }
  387. }
  388. $sqlGetSubCatList = "
  389. SELECT t1.name,
  390. t1.code,
  391. t1.parent_id,
  392. t1.children_count,COUNT(DISTINCT t3.code) AS nbCourse
  393. FROM $main_category_table t1
  394. LEFT JOIN $main_category_table t2 ON t1.code=t2.parent_id
  395. LEFT JOIN $main_course_table t3 ON (t3.category_code = t1.code $platform_visible_courses)
  396. WHERE t1.parent_id ". (empty ($category) ? "IS NULL" : "='$category'")."
  397. GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count ORDER BY t1.tree_pos, t1.name";
  398. // Showing only the category of courses of the current access_url_id
  399. if (api_is_multiple_url_enabled()) {
  400. $courseCategoryCondition = null;
  401. if (isMultipleUrlSupport()) {
  402. $table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY);
  403. $courseCategoryCondition = " INNER JOIN $table a ON (t1.id = a.course_category_id)";
  404. }
  405. $url_access_id = api_get_current_access_url_id();
  406. if ($url_access_id != -1) {
  407. $tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
  408. $sqlGetSubCatList = "
  409. SELECT t1.name,
  410. t1.code,
  411. t1.parent_id,
  412. t1.children_count,
  413. COUNT(DISTINCT t3.code) AS nbCourse
  414. FROM $main_category_table t1
  415. $courseCategoryCondition
  416. LEFT JOIN $main_category_table t2 ON t1.code = t2.parent_id
  417. LEFT JOIN $main_course_table t3 ON (t3.category_code = t1.code $platform_visible_courses)
  418. INNER JOIN $tbl_url_rel_course as url_rel_course
  419. ON (url_rel_course.c_id = t3.id)
  420. WHERE
  421. url_rel_course.access_url_id = $url_access_id AND
  422. t1.parent_id ".(empty($category) ? "IS NULL" : "='$category'")."
  423. GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count
  424. ORDER BY t1.tree_pos, t1.name";
  425. }
  426. }
  427. $resCats = Database::query($sqlGetSubCatList);
  428. $thereIsSubCat = false;
  429. if (Database::num_rows($resCats) > 0) {
  430. $htmlListCat = Display::page_header(get_lang('CatList'));
  431. $htmlListCat .= '<ul>';
  432. $htmlTitre = '';
  433. while ($catLine = Database::fetch_array($resCats)) {
  434. $category_has_open_courses = self::category_has_open_courses($catLine['code']);
  435. if ($category_has_open_courses) {
  436. // The category contains courses accessible to anonymous visitors.
  437. $htmlListCat .= '<li>';
  438. $htmlListCat .= '<a href="'.api_get_self().'?category='.$catLine['code'].'">'.$catLine['name'].'</a>';
  439. if (api_get_setting('show_number_of_courses') == 'true') {
  440. $htmlListCat .= ' ('.$catLine['nbCourse'].' '.get_lang('Courses').')';
  441. }
  442. $htmlListCat .= "</li>";
  443. $thereIsSubCat = true;
  444. } elseif ($catLine['children_count'] > 0) {
  445. // The category has children, subcategories.
  446. $htmlListCat .= '<li>';
  447. $htmlListCat .= '<a href="'.api_get_self().'?category='.$catLine['code'].'">'.$catLine['name'].'</a>';
  448. $htmlListCat .= "</li>";
  449. $thereIsSubCat = true;
  450. } elseif (api_get_setting('show_empty_course_categories') == 'true') {
  451. /* End changed code to eliminate the (0 courses) after empty categories. */
  452. $htmlListCat .= '<li>';
  453. $htmlListCat .= $catLine['name'];
  454. $htmlListCat .= "</li>";
  455. $thereIsSubCat = true;
  456. } // Else don't set thereIsSubCat to true to avoid printing things if not requested.
  457. // TODO: deprecate this useless feature - this includes removing system variable
  458. if (empty($htmlTitre)) {
  459. $htmlTitre = '<p>';
  460. if (api_get_setting('show_back_link_on_top_of_tree') == 'true') {
  461. $htmlTitre .= '<a href="'.api_get_self().'">&lt;&lt; '.get_lang('BackToHomePage').'</a>';
  462. }
  463. $htmlTitre .= "</p>";
  464. }
  465. }
  466. $htmlListCat .= "</ul>";
  467. }
  468. $result .= $htmlTitre;
  469. if ($thereIsSubCat) {
  470. $result .= $htmlListCat;
  471. }
  472. while ($categoryName = Database::fetch_array($resCats)) {
  473. $result .= '<h3>' . $categoryName['name'] . "</h3>\n";
  474. }
  475. $numrows = Database::num_rows($sql_result_courses);
  476. $courses_list_string = '';
  477. $courses_shown = 0;
  478. if ($numrows > 0) {
  479. $courses_list_string .= Display::page_header(get_lang('CourseList'));
  480. $courses_list_string .= "<ul>";
  481. if (api_get_user_id()) {
  482. $courses_of_user = self::get_courses_of_user(api_get_user_id());
  483. }
  484. foreach ($course_list as $course) {
  485. // $setting_show_also_closed_courses
  486. if ($course['visibility'] == COURSE_VISIBILITY_HIDDEN) { continue; }
  487. if (!$setting_show_also_closed_courses) {
  488. // If we do not show the closed courses
  489. // we only show the courses that are open to the world (to everybody)
  490. // and the courses that are open to the platform (if the current user is a registered user.
  491. if (($user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) || ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD)) {
  492. $courses_shown++;
  493. $courses_list_string .= "<li>";
  494. $courses_list_string .= '<a href="'.$web_course_path.$course['directory'].'/">'.$course['title'].'</a><br />';
  495. $course_details = array();
  496. if (api_get_setting('display_coursecode_in_courselist') == 'true') {
  497. $course_details[] = $course['visual_code'];
  498. }
  499. if (api_get_setting('display_teacher_in_courselist') == 'true') {
  500. $course_details[] = CourseManager::get_teacher_list_from_course_code_to_string($course['code']);
  501. }
  502. if (api_get_setting('show_different_course_language') == 'true' && $course['course_language'] != api_get_setting('platformLanguage')) {
  503. $course_details[] = $course['course_language'];
  504. }
  505. $courses_list_string .= implode(' - ', $course_details);
  506. $courses_list_string .= "</li>";
  507. }
  508. } else {
  509. // We DO show the closed courses.
  510. // The course is accessible if (link to the course homepage):
  511. // 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);
  512. // 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);
  513. // 3. the user is logged in and the user is subscribed to the course and the course visibility is not COURSE_VISIBILITY_CLOSED;
  514. // 4. the user is logged in and the user is course admin of te course (regardless of the course visibility setting);
  515. // 5. the user is the platform admin api_is_platform_admin().
  516. $courses_shown++;
  517. $courses_list_string .= "<li>";
  518. if ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD
  519. || ($user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM)
  520. || ($user_identified && array_key_exists($course['code'], $courses_of_user)
  521. && $course['visibility'] != COURSE_VISIBILITY_CLOSED)
  522. || $courses_of_user[$course['code']]['status'] == '1'
  523. || api_is_platform_admin()) {
  524. $courses_list_string .= '<a href="'.$web_course_path.$course['directory'].'/">';
  525. }
  526. $courses_list_string .= $course['title'];
  527. if ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD
  528. || ($user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM)
  529. || ($user_identified && array_key_exists($course['code'], $courses_of_user)
  530. && $course['visibility'] != COURSE_VISIBILITY_CLOSED)
  531. || $courses_of_user[$course['code']]['status'] == '1'
  532. || api_is_platform_admin()) {
  533. $courses_list_string .= '</a><br />';
  534. }
  535. $course_details = array();
  536. if (api_get_setting('display_coursecode_in_courselist') == 'true') {
  537. $course_details[] = $course['visual_code'];
  538. }
  539. // if (api_get_setting('display_coursecode_in_courselist') == 'true' && api_get_setting('display_teacher_in_courselist') == 'true') {
  540. // $courses_list_string .= ' - ';
  541. // }
  542. if (api_get_setting('display_teacher_in_courselist') == 'true') {
  543. if (!empty($course['tutor_name'])) {
  544. $course_details[] = $course['tutor_name'];
  545. }
  546. }
  547. if (api_get_setting('show_different_course_language') == 'true' && $course['course_language'] != api_get_setting('platformLanguage')) {
  548. $course_details[] = $course['course_language'];
  549. }
  550. $courses_list_string .= implode(' - ', $course_details);
  551. // We display a subscription link if:
  552. // 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
  553. // 2.
  554. if ($user_identified && !array_key_exists($course['code'], $courses_of_user)) {
  555. if ($course['subscribe'] == '1') {
  556. $courses_list_string .= '&nbsp;<a class="btn btn-primary" href="main/auth/courses.php?action=subscribe_course&sec_token='.$stok.'&subscribe_course='.$course['code'].'&category_code='.Security::remove_XSS($_GET['category']).'">'.get_lang('Subscribe').'</a><br />';
  557. } else {
  558. $courses_list_string .= '<br />'.get_lang('SubscribingNotAllowed');
  559. }
  560. }
  561. $courses_list_string .= "</li>";
  562. } //end else
  563. } // end foreach
  564. $courses_list_string .= "</ul>";
  565. }
  566. if ($courses_shown > 0) {
  567. // Only display the list of courses and categories if there was more than
  568. // 0 courses visible to the world (we're in the anonymous list here).
  569. $result .= $courses_list_string;
  570. }
  571. if ($category != '') {
  572. $result .= '<p><a href="'.api_get_self().'"> ' .
  573. Display :: return_icon('back.png', get_lang('BackToHomePage')).
  574. get_lang('BackToHomePage') . '</a></p>';
  575. }
  576. return $result;
  577. }
  578. /**
  579. * retrieves all the courses that the user has already subscribed to
  580. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
  581. * @param int $user_id: the id of the user
  582. * @return array an array containing all the information of the courses of the given user
  583. */
  584. public function get_courses_of_user($user_id)
  585. {
  586. $table_course = Database::get_main_table(TABLE_MAIN_COURSE);
  587. $table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
  588. // Secondly we select the courses that are in a category (user_course_cat <> 0)
  589. // and sort these according to the sort of the category
  590. $user_id = intval($user_id);
  591. $sql_select_courses = "SELECT
  592. course.code k,
  593. course.visual_code vc,
  594. course.subscribe subscr,
  595. course.unsubscribe unsubscr,
  596. course.title i,
  597. course.tutor_name t,
  598. course.directory dir,
  599. course_rel_user.status status,
  600. course_rel_user.sort sort,
  601. course_rel_user.user_course_cat user_course_cat
  602. FROM
  603. $table_course course,
  604. $table_course_user course_rel_user
  605. WHERE
  606. course.id = course_rel_user.c_id AND
  607. course_rel_user.user_id = '".$user_id."' AND
  608. course_rel_user.relation_type <> ".COURSE_RELATION_TYPE_RRHH."
  609. ORDER BY course_rel_user.sort ASC";
  610. $result = Database::query($sql_select_courses);
  611. $courses = array();
  612. while ($row = Database::fetch_array($result)) {
  613. // We only need the database name of the course.
  614. $courses[$row['k']] = array(
  615. 'code' => $row['k'],
  616. 'visual_code' => $row['vc'],
  617. 'title' => $row['i'],
  618. 'directory' => $row['dir'],
  619. 'status' => $row['status'],
  620. 'tutor' => $row['t'],
  621. 'subscribe' => $row['subscr'],
  622. 'unsubscribe' => $row['unsubscr'],
  623. 'sort' => $row['sort'],
  624. 'user_course_category' => $row['user_course_cat']
  625. );
  626. }
  627. return $courses;
  628. }
  629. /**
  630. * @todo use the template system
  631. */
  632. function show_right_block($title, $content, $id = null, $params = null, $idAccordion = null, $idCollpase = null)
  633. {
  634. if (!empty($idAccordion)) {
  635. $html = null;
  636. $html .= '<div class="panel-group" id="'.$idAccordion.'" role="tablist" aria-multiselectable="true">' . PHP_EOL;
  637. $html .= '<div class="panel panel-default" id="'.$id.'">' . PHP_EOL;
  638. $html .= '<div class="panel-heading" role="tab"><h4 class="panel-title">' . PHP_EOL;
  639. $html .= '<a role="button" data-toggle="collapse" data-parent="#'.$idAccordion.'" href="#'.$idCollpase.'" aria-expanded="true" aria-controls="'.$idCollpase.'">'.$title.'</a>' . PHP_EOL;
  640. $html .= '</h4></div>' . PHP_EOL;
  641. $html .= '<div id="'.$idCollpase.'" class="panel-collapse collapse in" role="tabpanel">' . PHP_EOL;
  642. $html .= '<div class="panel-body">'.$content.'</div>' . PHP_EOL;
  643. $html .= '</div></div></div>' . PHP_EOL;
  644. } else {
  645. if (!empty($id)) {
  646. $params['id'] = $id;
  647. }
  648. $params['class'] = 'panel panel-default';
  649. $html = null;
  650. if (!empty($title)) {
  651. $html .= '<div class="panel-heading">'.$title.'</div>' . PHP_EOL;
  652. }
  653. $html.= '<div class="panel-body">'.$content.'</div>' . PHP_EOL;
  654. $html = Display::div($html, $params);
  655. }
  656. return $html;
  657. }
  658. /**
  659. * Adds a form to let users login
  660. * @version 1.1
  661. */
  662. public function display_login_form()
  663. {
  664. return $this->tpl->displayLoginForm();
  665. }
  666. /**
  667. * @todo use FormValidator
  668. * @return string
  669. */
  670. public function return_search_block()
  671. {
  672. $html = '';
  673. if (api_get_setting('search_enabled') == 'true') {
  674. $search_btn = get_lang('Search');
  675. $search_content = '<form action="main/search/" method="post">
  676. <div class="form-group">
  677. <input type="text" id="query" class="form-control" name="query" value="" />
  678. <button class="btn btn-default" type="submit" name="submit" value="'.$search_btn.'" />'.$search_btn.' </button>
  679. </div></form>';
  680. $html .= self::show_right_block(get_lang('Search'), $search_content, 'search_block');
  681. }
  682. return $html;
  683. }
  684. /**
  685. * @return string
  686. */
  687. public function return_classes_block()
  688. {
  689. $html = '';
  690. if (api_get_setting('show_groups_to_users') == 'true') {
  691. $usergroup = new UserGroup();
  692. $usergroup_list = $usergroup->get_usergroup_by_user(api_get_user_id());
  693. $classes = '';
  694. if (!empty($usergroup_list)) {
  695. foreach($usergroup_list as $group_id) {
  696. $data = $usergroup->get($group_id);
  697. $data['name'] = Display::url($data['name'], api_get_path(WEB_CODE_PATH).'user/classes.php?id='.$data['id']);
  698. $classes .= Display::tag('li', $data['name']);
  699. }
  700. }
  701. if (api_is_platform_admin()) {
  702. $classes .= Display::tag(
  703. 'li',
  704. Display::url(get_lang('AddClasses') ,api_get_path(WEB_CODE_PATH).'admin/usergroups.php?action=add')
  705. );
  706. }
  707. if (!empty($classes)) {
  708. $classes = Display::tag('ul', $classes, array('class'=>'nav nav-pills nav-stacked'));
  709. $html .= self::show_right_block(get_lang('Classes'), $classes, 'classes_block');
  710. }
  711. }
  712. return $html;
  713. }
  714. /**
  715. * @return null|string
  716. */
  717. public function return_user_image_block()
  718. {
  719. $html = null;
  720. if (!api_is_anonymous()) {
  721. $userPicture = UserManager::getUserPicture(api_get_user_id());
  722. $content = null;
  723. if (api_get_setting('allow_social_tool') == 'true') {
  724. $content .= '<a style="text-align:center" href="' . api_get_path(WEB_PATH) . 'main/social/home.php">
  725. <img class="img-circle" src="' . $userPicture . '" ></a>';
  726. } else {
  727. $content .= '<a style="text-align:center" href="' . api_get_path(WEB_PATH) . 'main/auth/profile.php">
  728. <img class="img-circle" title="' . get_lang('EditProfile') . '" src="' . $userPicture. '" ></a>';
  729. }
  730. $html = self::show_right_block(
  731. null,
  732. $content,
  733. 'user_image_block',
  734. array('style' => 'text-align:center;')
  735. );
  736. }
  737. return $html;
  738. }
  739. /**
  740. * @return null|string|void
  741. */
  742. public function return_profile_block()
  743. {
  744. global $_configuration;
  745. $user_id = api_get_user_id();
  746. if (empty($user_id)) {
  747. return;
  748. }
  749. $userGroup = new UserGroup();
  750. $profile_content = '<ul class="nav nav-pills nav-stacked">';
  751. // @todo Add a platform setting to add the user image.
  752. if (api_get_setting('allow_message_tool') == 'true') {
  753. // New messages.
  754. $number_of_new_messages = MessageManager::get_new_messages();
  755. // New contact invitations.
  756. $number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id(api_get_user_id());
  757. // New group invitations sent by a moderator.
  758. $group_pending_invitations = $userGroup->get_groups_by_user(
  759. api_get_user_id(),
  760. GROUP_USER_PERMISSION_PENDING_INVITATION,
  761. false
  762. );
  763. $group_pending_invitations = count($group_pending_invitations);
  764. $total_invitations = $number_of_new_messages_of_friend + $group_pending_invitations;
  765. $cant_msg = Display::badge($number_of_new_messages);
  766. $link = '';
  767. if (api_get_setting('allow_social_tool') == 'true') {
  768. $link = '?f=social';
  769. }
  770. $profile_content .= '<li class="inbox-message-social"><a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php'.$link.'">'.Display::return_icon('inbox.png',get_lang('Inbox'),null,ICON_SIZE_SMALL).get_lang('Inbox').$cant_msg.' </a></li>';
  771. $profile_content .= '<li class="new-message-social"><a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php'.$link.'">'.Display::return_icon('new-message.png',get_lang('Compose'),null,ICON_SIZE_SMALL).get_lang('Compose').' </a></li>';
  772. if (api_get_setting('allow_social_tool') == 'true') {
  773. $total_invitations = Display::badge($total_invitations);
  774. $profile_content .= '<li class="invitations-social"><a href="'.api_get_path(WEB_PATH).'main/social/invitations.php">'.Display::return_icon('invitations.png',get_lang('PendingInvitations'),null,ICON_SIZE_SMALL).get_lang('PendingInvitations').$total_invitations.'</a></li>';
  775. }
  776. if (isset($_configuration['allow_my_files_link_in_homepage']) && $_configuration['allow_my_files_link_in_homepage']) {
  777. $profile_content .= '<li class="myfiles-social"><a href="'.api_get_path(WEB_PATH).'main/social/myfiles.php">'.get_lang('MyFiles').'</a></li>';
  778. }
  779. }
  780. $editProfileUrl = Display::getProfileEditionLink($user_id);
  781. $profile_content .= '<li class="profile-social"><a href="' . $editProfileUrl . '">'.Display::return_icon('edit-profile.png',get_lang('EditProfile'),null,ICON_SIZE_SMALL).get_lang('EditProfile').'</a></li>';
  782. $profile_content .= '</ul>';
  783. $html = self::show_right_block(
  784. get_lang('Profile'),
  785. $profile_content,
  786. 'profile_block',
  787. null,
  788. 'profile',
  789. 'profileCollapse'
  790. );
  791. return $html;
  792. }
  793. public function return_navigation_links()
  794. {
  795. $html = '';
  796. // Deleting the myprofile link.
  797. if (api_get_setting('allow_social_tool') == 'true') {
  798. unset($this->tpl->menu_navigation['myprofile']);
  799. }
  800. // Main navigation section.
  801. // Tabs that are deactivated are added here.
  802. if (!empty($this->tpl->menu_navigation)) {
  803. $content = '<ul class="nav nav-pills nav-stacked">';
  804. foreach ($this->tpl->menu_navigation as $section => $navigation_info) {
  805. $current = $section == $GLOBALS['this_section'] ? ' id="current"' : '';
  806. $content .= '<li'.$current.'>';
  807. $content .= '<a href="'.$navigation_info['url'].'" target="_self">'.$navigation_info['title'].'</a>';
  808. $content .= '</li>';
  809. }
  810. $content .= '</ul>';
  811. $html = self::show_right_block(get_lang('MainNavigation'), $content, 'navigation_link_block');
  812. }
  813. return $html;
  814. }
  815. /**
  816. * @return null|string
  817. */
  818. public function return_course_block()
  819. {
  820. $html = '';
  821. $show_create_link = false;
  822. $show_course_link = false;
  823. if ((api_get_setting('allow_users_to_create_courses') == 'false' &&
  824. !api_is_platform_admin()) || api_is_student()
  825. ) {
  826. $display_add_course_link = false;
  827. } else {
  828. $display_add_course_link = true;
  829. }
  830. if ($display_add_course_link) {
  831. $show_create_link = true;
  832. }
  833. if (api_is_platform_admin() || api_is_course_admin() || api_is_allowed_to_create_course()) {
  834. $show_course_link = true;
  835. } else {
  836. if (api_get_setting('allow_students_to_browse_courses') == 'true') {
  837. $show_course_link = true;
  838. }
  839. }
  840. // My account section
  841. $my_account_content = '<ul class="nav nav-pills nav-stacked">';
  842. if ($show_create_link) {
  843. $my_account_content .= '<li class="add-course"><a href="main/create_course/add_course.php">';
  844. if (api_get_setting('course_validation') == 'true' && !api_is_platform_admin()) {
  845. $my_account_content .= Display::return_icon('new-course.png',get_lang('CourseCreateRequest'),null,ICON_SIZE_SMALL);
  846. $my_account_content .= get_lang('CreateCourseRequest');
  847. } else {
  848. $my_account_content .= Display::return_icon('new-course.png',get_lang('CourseCreate'),null,ICON_SIZE_SMALL);
  849. $my_account_content .= get_lang('CourseCreate');
  850. }
  851. $my_account_content .= '</a></li>';
  852. if (SessionManager::allowToManageSessions()) {
  853. $my_account_content .= '<li class="add-course"><a href="main/session/session_add.php">';
  854. $my_account_content .= Display::return_icon('session.png',get_lang('AddSession'),null,ICON_SIZE_SMALL);
  855. $my_account_content .= get_lang('AddSession');
  856. $my_account_content .= '</a></li>';
  857. }
  858. }
  859. //Sort courses
  860. $url = api_get_path(WEB_CODE_PATH).'auth/courses.php?action=sortmycourses';
  861. $img_order= Display::return_icon('order-course.png',get_lang('SortMyCourses'),null,ICON_SIZE_SMALL);
  862. $my_account_content .= '<li class="order-course">'.Display::url($img_order.get_lang('SortMyCourses'), $url, array('class' => 'sort course')).'</li>';
  863. // Session history
  864. if (isset($_GET['history']) && intval($_GET['history']) == 1) {
  865. $my_account_content .= '<li class="history-course"><a href="user_portal.php">'.Display::return_icon('history-course.png',get_lang('DisplayTrainingList'),null,ICON_SIZE_SMALL).get_lang('DisplayTrainingList').'</a></li>';
  866. } else {
  867. $my_account_content .= '<li class="history-course"><a href="user_portal.php?history=1" >'.Display::return_icon('history-course.png',get_lang('HistoryTrainingSessions'),null,ICON_SIZE_SMALL).get_lang('HistoryTrainingSessions').'</a></li>';
  868. }
  869. // Course catalog
  870. if ($show_course_link) {
  871. if (!api_is_drh()) {
  872. $my_account_content .= '<li class="list-course"><a href="main/auth/courses.php" >'.Display::return_icon('catalog-course.png',get_lang('CourseCatalog'),null,ICON_SIZE_SMALL).get_lang('CourseCatalog').'</a></li>';
  873. } else {
  874. $my_account_content .= '<li><a href="main/dashboard/index.php">'.get_lang('Dashboard').'</a></li>';
  875. }
  876. }
  877. $my_account_content .= '</ul>';
  878. if (!empty($my_account_content)) {
  879. $html = self::show_right_block(
  880. get_lang('Courses'),
  881. $my_account_content,
  882. 'course_block',
  883. null,
  884. 'course',
  885. 'courseCollapse'
  886. );
  887. }
  888. return $html;
  889. }
  890. /**
  891. * Prints the session and course list (user_portal.php)
  892. * @param int $user_id
  893. * @return string
  894. */
  895. public function returnCoursesAndSessions($user_id)
  896. {
  897. global $_configuration;
  898. $gamificationModeIsActive = api_get_setting('gamification_mode');
  899. $load_history = (isset($_GET['history']) && intval($_GET['history']) == 1) ? true : false;
  900. if ($load_history) {
  901. // Load sessions in category in *history*
  902. $session_categories = UserManager::get_sessions_by_category($user_id, true);
  903. } else {
  904. // Load sessions in category
  905. $session_categories = UserManager::get_sessions_by_category($user_id, false);
  906. }
  907. $html = '';
  908. // Showing history title
  909. if ($load_history) {
  910. $html .= Display::page_subheader(get_lang('HistoryTrainingSession'));
  911. if (empty($session_categories)) {
  912. $html .= get_lang('YouDoNotHaveAnySessionInItsHistory');
  913. }
  914. }
  915. $courses_html = '';
  916. $special_courses = '';
  917. $sessionCount = 0;
  918. $courseCount = 0;
  919. // If we're not in the history view...
  920. if (!isset($_GET['history'])) {
  921. // Display special courses.
  922. $specialCourses = CourseManager::display_special_courses(
  923. $user_id,
  924. $this->load_directories_preview
  925. );
  926. $special_courses = $specialCourses['html'];
  927. // Display courses.
  928. $courses = CourseManager::display_courses(
  929. $user_id,
  930. $this->load_directories_preview
  931. );
  932. $courses_html .= $courses['html'];
  933. $courseCount = $specialCourses['course_count'] + $courses['course_count'];
  934. }
  935. $sessions_with_category = '';
  936. $sessions_with_no_category = '';
  937. if (is_array($session_categories)) {
  938. foreach ($session_categories as $session_category) {
  939. $session_category_id = $session_category['session_category']['id'];
  940. // Sessions and courses that are not in a session category
  941. if (
  942. empty($session_category_id) &&
  943. isset($session_category['sessions'])
  944. ) {
  945. // Independent sessions
  946. foreach ($session_category['sessions'] as $session) {
  947. $session_id = $session['session_id'];
  948. // Don't show empty sessions.
  949. if (count($session['courses']) < 1) {
  950. continue;
  951. }
  952. // Courses inside the current session.
  953. $date_session_start = $session['access_start_date'];
  954. $date_session_end = $session['access_end_date'];
  955. $coachAccessStartDate = $session['coach_access_start_date'];
  956. $coachAccessEndDate = $session['coach_access_end_date'];
  957. $session_now = time();
  958. $count_courses_session = 0;
  959. // Loop course content
  960. $html_courses_session = [];
  961. $atLeastOneCourseIsVisible = false;
  962. foreach ($session['courses'] as $course) {
  963. $is_coach_course = api_is_coach($session_id, $course['real_id']);
  964. $allowed_time = 0;
  965. $dif_time_after = 0;
  966. if (!empty($date_session_start) &&
  967. $date_session_start != '0000-00-00 00:00:00'
  968. ) {
  969. if ($is_coach_course) {
  970. $allowed_time = api_strtotime($coachAccessStartDate);
  971. } else {
  972. $allowed_time = api_strtotime($date_session_start);
  973. }
  974. if (!isset($_GET['history'])) {
  975. if (!empty($date_session_end) &&
  976. $date_session_end != '0000-00-00 00:00:00'
  977. ) {
  978. $endSessionToTms = api_strtotime($date_session_end);
  979. if ($session_now > $endSessionToTms) {
  980. $dif_time_after = $session_now - $endSessionToTms;
  981. $dif_time_after = round($dif_time_after / 86400);
  982. }
  983. }
  984. }
  985. }
  986. if (
  987. $session_now > $allowed_time
  988. //($coachAccessEndDate > $dif_time_after - 1)
  989. ) {
  990. // Read only and accessible.
  991. $atLeastOneCourseIsVisible = true;
  992. if (api_get_setting('hide_courses_in_sessions') == 'false') {
  993. $c = CourseManager::get_logged_user_course_html(
  994. $course,
  995. $session_id,
  996. 'session_course_item',
  997. true,
  998. $this->load_directories_preview
  999. );
  1000. if (isset($c[1])) {
  1001. $html_courses_session[] = $c['1'];
  1002. }
  1003. }
  1004. $count_courses_session++;
  1005. }
  1006. }
  1007. // No courses to show.
  1008. if ($atLeastOneCourseIsVisible == false) {
  1009. if (empty($html_courses_session)) {
  1010. continue;
  1011. }
  1012. }
  1013. if ($count_courses_session > 0) {
  1014. $params = array(
  1015. 'id' => $session_id
  1016. );
  1017. $session_box = Display::get_session_title_box($session_id);
  1018. $extra_info = !empty($session_box['coach']) ? $session_box['coach'] : null;
  1019. $extra_info .= !empty($session_box['coach'])
  1020. ? ' - ' . $session_box['dates']
  1021. : $session_box['dates'];
  1022. $extra_info .= isset($session_box['duration'])
  1023. ? ' ' . $session_box['duration']
  1024. : null;
  1025. $params['extra_fields'] = $session_box['extra_fields'];
  1026. $params['show_link_to_session'] = api_is_drh() ? false : true;
  1027. $params['title'] = $session_box['title'];
  1028. $params['subtitle'] = $extra_info;
  1029. $params['show_actions'] = api_is_platform_admin() ? true : false;
  1030. if (api_get_setting('hide_courses_in_sessions') == 'false') {
  1031. // $params['extra'] .= $html_courses_session;
  1032. }
  1033. $params['description'] = $session_box['description'];
  1034. $params['show_description'] = $session_box['show_description'];
  1035. $params['courses'] = $html_courses_session;
  1036. $params['show_simple_session_info'] = false;
  1037. if (
  1038. isset($_configuration['show_simple_session_info']) &&
  1039. $_configuration['show_simple_session_info']
  1040. ) {
  1041. $params['show_simple_session_info'] = true;
  1042. }
  1043. if ($gamificationModeIsActive) {
  1044. $params['stars'] = GamificationUtils::getSessionStars($params['id'], $this->user_id);
  1045. $params['progress'] = GamificationUtils::getSessionProgress($params['id'], $this->user_id);
  1046. $params['points'] = GamificationUtils::getSessionPoints($params['id'], $this->user_id);
  1047. }
  1048. $this->tpl->assign('session', $params);
  1049. $this->tpl->assign('gamification_mode', $gamificationModeIsActive);
  1050. $sessions_with_no_category .= $this->tpl->fetch(
  1051. "{$this->tpl->templateFolder}/user_portal/session.tpl"
  1052. );
  1053. $sessionCount++;
  1054. }
  1055. }
  1056. } else {
  1057. // All sessions included in
  1058. $count_courses_session = 0;
  1059. $html_sessions = '';
  1060. if (isset($session_category['sessions'])) {
  1061. foreach ($session_category['sessions'] as $session) {
  1062. $session_id = $session['session_id'];
  1063. // Don't show empty sessions.
  1064. if (count($session['courses']) < 1) {
  1065. continue;
  1066. }
  1067. $date_session_start = $session['access_start_date'];
  1068. $date_session_end = $session['access_end_date'];
  1069. $coachAccessStartDate = $session['coach_access_start_date'];
  1070. $coachAccessEndDate = $session['coach_access_end_date'];
  1071. $session_now = time();
  1072. $html_courses_session = [];
  1073. $count = 0;
  1074. foreach ($session['courses'] as $course) {
  1075. $is_coach_course = api_is_coach(
  1076. $session_id,
  1077. $course['real_id']
  1078. );
  1079. $dif_time_after = 0;
  1080. $allowed_time = 0;
  1081. if ($is_coach_course) {
  1082. // 24 hours = 86400
  1083. if ($date_session_start != '0000-00-00 00:00:00') {
  1084. $allowed_time = api_strtotime($coachAccessStartDate);
  1085. }
  1086. if (!isset($_GET['history'])) {
  1087. if ($date_session_end != '0000-00-00 00:00:00') {
  1088. $endSessionToTms = api_strtotime(
  1089. $date_session_end
  1090. );
  1091. if ($session_now > $endSessionToTms) {
  1092. $dif_time_after = $session_now - $endSessionToTms;
  1093. $dif_time_after = round(
  1094. $dif_time_after / 86400
  1095. );
  1096. }
  1097. }
  1098. }
  1099. } else {
  1100. $allowed_time = api_strtotime(
  1101. $date_session_start
  1102. );
  1103. }
  1104. if (
  1105. $session_now > $allowed_time //&&
  1106. //$coachAccessEndDate > $dif_time_after - 1
  1107. ) {
  1108. if (api_get_setting('hide_courses_in_sessions') == 'false') {
  1109. $c = CourseManager:: get_logged_user_course_html(
  1110. $course,
  1111. $session_id,
  1112. 'session_course_item'
  1113. );
  1114. $html_courses_session[] = $c[1];
  1115. }
  1116. $count_courses_session++;
  1117. $count++;
  1118. }
  1119. }
  1120. $sessionParams = array();
  1121. //Category
  1122. if ($count > 0) {
  1123. $session_box = Display:: get_session_title_box($session_id);
  1124. $sessionParams['id'] = $session_id;
  1125. $sessionParams['show_link_to_session'] = !api_is_drh();
  1126. $sessionParams['title'] = $session_box['title'];
  1127. $sessionParams['subtitle'] = (!empty($session_box['coach'])
  1128. ? $session_box['coach'] . ' | '
  1129. : '') . $session_box['dates'];
  1130. $sessionParams['show_actions'] = api_is_platform_admin();
  1131. $sessionParams['courses'] = $html_courses_session;
  1132. $sessionParams['show_simple_session_info'] = false;
  1133. if (
  1134. isset($_configuration['show_simple_session_info']) &&
  1135. $_configuration['show_simple_session_info']
  1136. ) {
  1137. $sessionParams['show_simple_session_info'] = true;
  1138. }
  1139. $this->tpl->assign('session', $sessionParams);
  1140. $html_sessions .= $this->tpl->fetch(
  1141. "{$this->tpl->templateFolder}/user_portal/session.tpl"
  1142. );
  1143. $sessionCount++;
  1144. }
  1145. }
  1146. }
  1147. if ($count_courses_session > 0) {
  1148. $categoryParams = array(
  1149. 'id' => $session_category['session_category']['id'],
  1150. 'title' => $session_category['session_category']['name'],
  1151. 'show_actions' => api_is_platform_admin(),
  1152. 'subtitle' => null,
  1153. 'sessions' => $html_sessions
  1154. );
  1155. $session_category_start_date = $session_category['session_category']['date_start'];
  1156. $session_category_end_date = $session_category['session_category']['date_end'];
  1157. if (
  1158. !empty($session_category_start_date) &&
  1159. $session_category_start_date != '0000-00-00' &&
  1160. !empty($session_category_end_date) &&
  1161. $session_category_end_date != '0000-00-00'
  1162. ) {
  1163. $categoryParams['subtitle'] = sprintf(
  1164. get_lang('FromDateXToDateY'),
  1165. $session_category['session_category']['date_start'],
  1166. $session_category['session_category']['date_end']
  1167. );
  1168. } else {
  1169. if (
  1170. !empty($session_category_start_date) &&
  1171. $session_category_start_date != '0000-00-00'
  1172. ) {
  1173. $categoryParams['subtitle'] = get_lang('From') . ' ' . $session_category_start_date;
  1174. }
  1175. if (
  1176. !empty($session_category_end_date) &&
  1177. $session_category_end_date != '0000-00-00'
  1178. ) {
  1179. $categoryParams['subtitle'] = get_lang('Until') . ' ' . $session_category_end_date;
  1180. }
  1181. }
  1182. $this->tpl->assign('session_category', $categoryParams);
  1183. $sessions_with_category .= $this->tpl->fetch(
  1184. "{$this->tpl->templateFolder}/user_portal/session_category.tpl"
  1185. );
  1186. }
  1187. }
  1188. }
  1189. }
  1190. return [
  1191. 'html' => $sessions_with_category.$sessions_with_no_category.$courses_html.$special_courses,
  1192. 'session_count' => $sessionCount,
  1193. 'course_count' => $courseCount
  1194. ];
  1195. }
  1196. /**
  1197. * Shows a welcome message when the user doesn't have any content in the course list
  1198. */
  1199. public function return_welcome_to_course_block()
  1200. {
  1201. $count_courses = CourseManager::count_courses();
  1202. $tpl = $this->tpl->get_template('layout/welcome_to_course.tpl');
  1203. $course_catalog_url = api_get_path(WEB_CODE_PATH).'auth/courses.php';
  1204. $course_list_url = api_get_path(WEB_PATH).'user_portal.php';
  1205. $this->tpl->assign('course_catalog_url', $course_catalog_url);
  1206. $this->tpl->assign('course_list_url', $course_list_url);
  1207. $this->tpl->assign('course_catalog_link', Display::url(get_lang('Here'), $course_catalog_url));
  1208. $this->tpl->assign('course_list_link', Display::url(get_lang('Here'), $course_list_url));
  1209. $this->tpl->assign('count_courses', $count_courses);
  1210. return $this->tpl->fetch($tpl);
  1211. }
  1212. /**
  1213. * @return array
  1214. */
  1215. public function return_hot_courses()
  1216. {
  1217. return CourseManager::return_hot_courses(30, 6);
  1218. }
  1219. /**
  1220. * UserPortal view for session, return the HTLK of the course list
  1221. * @param $user_id
  1222. * @return string
  1223. */
  1224. public function returnCoursesAndSessionsViewBySession($user_id)
  1225. {
  1226. $sessionCount = 0;
  1227. $courseCount = 0;
  1228. $load_history = (isset($_GET['history']) && intval($_GET['history']) == 1) ? true : false;
  1229. if ($load_history) {
  1230. //Load sessions in category in *history*
  1231. $session_categories = UserManager::get_sessions_by_category($user_id, true);
  1232. } else {
  1233. //Load sessions in category
  1234. $session_categories = UserManager::get_sessions_by_category($user_id, false);
  1235. }
  1236. $html = '';
  1237. //Showing history title
  1238. if ($load_history) {
  1239. $html .= Display::page_subheader(get_lang('HistoryTrainingSession'));
  1240. if (empty($session_categories)) {
  1241. $html .= get_lang('YouDoNotHaveAnySessionInItsHistory');
  1242. }
  1243. }
  1244. $specialCourses = '';
  1245. $loadDirs = $this->load_directories_preview;
  1246. // If we're not in the history view...
  1247. $listCoursesInfo = array();
  1248. if (!isset($_GET['history'])) {
  1249. // Display special courses
  1250. $specialCoursesResult = CourseManager::display_special_courses(
  1251. $user_id,
  1252. $loadDirs
  1253. );
  1254. $specialCourses = $specialCoursesResult['html'];
  1255. // Display courses
  1256. // [code=>xxx, real_id=>000]
  1257. $listCourses = CourseManager::get_courses_list_by_user_id($user_id, false);
  1258. foreach ($listCourses as $i => $listCourseCodeId) {
  1259. list($userCategoryId, $userCatTitle) = CourseManager::getUserCourseCategoryForCourse(
  1260. $user_id,
  1261. $listCourseCodeId['real_id']
  1262. );
  1263. $listCourse = api_get_course_info_by_id($listCourseCodeId['real_id']);
  1264. $listCoursesInfo[] = array(
  1265. 'course' => $listCourse,
  1266. 'code' => $listCourseCodeId['code'],
  1267. 'id' => $listCourseCodeId['real_id'],
  1268. 'title' => $listCourse['title'],
  1269. 'userCatId' => $userCategoryId,
  1270. 'userCatTitle' => $userCatTitle
  1271. );
  1272. $courseCount++;
  1273. }
  1274. usort($listCoursesInfo, 'self::compareByCourse');
  1275. }
  1276. if (is_array($session_categories)) {
  1277. // all courses that are in a session
  1278. $listCoursesInSession = SessionManager::getNamedSessionCourseForCoach($user_id);
  1279. }
  1280. // we got all courses
  1281. // for each user category, sorted alphabetically, display courses
  1282. $listUserCategories = CourseManager::get_user_course_categories($user_id);
  1283. $listCoursesAlreadyDisplayed = array();
  1284. uasort($listUserCategories, "self::compareListUserCategory");
  1285. $listUserCategories[0] = '';
  1286. $html = '<div class="session-view-block">';
  1287. foreach ($listUserCategories as $userCategoryId => $userCatTitle) {
  1288. // add user category
  1289. $userCategoryHtml = '';
  1290. if ($userCategoryId != 0) {
  1291. $userCategoryHtml = '<div class="session-view-well ">';
  1292. }
  1293. $userCategoryHtml .= self::getHtmlForUserCategory($userCategoryId, $userCatTitle);
  1294. // look for course in this userCat in session courses : $listCoursesInSession
  1295. $htmlCategory = '';
  1296. if (isset($listCoursesInSession[$userCategoryId])) {
  1297. // list of courses in this user cat
  1298. foreach ($listCoursesInSession[$userCategoryId]['courseInUserCatList'] as $i => $listCourse) {
  1299. // add course
  1300. $listCoursesAlreadyDisplayed[$listCourse['courseId']] = 1;
  1301. if ($userCategoryId == 0) {
  1302. $htmlCategory .= '<div class="session-view-well session-view-row well" >';
  1303. } else {
  1304. $htmlCategory .= '<div class="session-view-row" >';
  1305. }
  1306. $coursesInfo = $listCourse['course'];
  1307. $htmlCategory .= self::getHtmlForCourse(
  1308. $coursesInfo,
  1309. $userCategoryId,
  1310. 1,
  1311. $loadDirs
  1312. );
  1313. // list of session category
  1314. $htmlSessionCategory = '<div class="session-view-row" style="display:none;" id="courseblock-'.$coursesInfo['real_id'].'">';
  1315. foreach ($listCourse['sessionCatList'] as $j => $listCategorySession) {
  1316. // add session category
  1317. $htmlSessionCategory .= self::getHtmlSessionCategory(
  1318. $listCategorySession['catSessionId'],
  1319. $listCategorySession['catSessionName']
  1320. );
  1321. // list of session
  1322. $htmlSession = ''; // start
  1323. foreach ($listCategorySession['sessionList'] as $k => $listSession) {
  1324. // add session
  1325. $htmlSession .= '<div class="session-view-row">';
  1326. $htmlSession .= self::getHtmlForSession(
  1327. $listSession['sessionId'],
  1328. $listSession['sessionName'],
  1329. $listCategorySession['catSessionId'],
  1330. $coursesInfo
  1331. );
  1332. $htmlSession .= '</div>';
  1333. $sessionCount++;
  1334. }
  1335. $htmlSession .= ''; // end session block
  1336. $htmlSessionCategory .= $htmlSession;
  1337. }
  1338. $htmlSessionCategory .= '</div>'; // end session cat block
  1339. $htmlCategory .= $htmlSessionCategory .'</div>' ;
  1340. $htmlCategory .= ''; // end course block
  1341. }
  1342. $userCategoryHtml .= $htmlCategory;
  1343. }
  1344. // look for courses in this userCat in not in session courses : $listCoursesInfo
  1345. // if course not already added
  1346. $htmlCategory = '';
  1347. foreach ($listCoursesInfo as $i => $listCourse) {
  1348. if ($listCourse['userCatId'] == $userCategoryId && !isset($listCoursesAlreadyDisplayed[$listCourse['id']])) {
  1349. if ($userCategoryId != 0) {
  1350. $htmlCategory .= '<div class="session-view-row" >';
  1351. } else {
  1352. $htmlCategory .= '<div class="session-view-well well">';
  1353. }
  1354. $htmlCategory .= self::getHtmlForCourse(
  1355. $listCourse['course'],
  1356. $userCategoryId,
  1357. 0,
  1358. $loadDirs
  1359. );
  1360. $htmlCategory .= '</div>';
  1361. }
  1362. }
  1363. $htmlCategory .= '';
  1364. $userCategoryHtml .= $htmlCategory; // end user cat block
  1365. if ($userCategoryId != 0) {
  1366. $userCategoryHtml .= '</div>';
  1367. }
  1368. $html .= $userCategoryHtml; //
  1369. }
  1370. $html .= '</div>';
  1371. return [
  1372. 'html' => $html.$specialCourses,
  1373. 'session_count' => $sessionCount,
  1374. 'course_count' => $courseCount
  1375. ];
  1376. }
  1377. /**
  1378. * Return HTML code for personal user course category
  1379. * @param $id
  1380. * @param $title
  1381. * @return string
  1382. */
  1383. private static function getHtmlForUserCategory($id, $title)
  1384. {
  1385. if ($id == 0) {
  1386. return '';
  1387. }
  1388. $icon = Display::return_icon(
  1389. 'folder_yellow.png',
  1390. $title,
  1391. array('class' => 'sessionView'),
  1392. ICON_SIZE_LARGE
  1393. );
  1394. return "<div class='session-view-user-category'>$icon<span>$title</span></div>";
  1395. }
  1396. /**
  1397. * return HTML code for course display in session view
  1398. * @param array $courseInfo
  1399. * @param $userCategoryId
  1400. * @param bool $displayButton
  1401. * @param $loadDirs
  1402. * @return string
  1403. */
  1404. private static function getHtmlForCourse(
  1405. $courseInfo,
  1406. $userCategoryId,
  1407. $displayButton = false,
  1408. $loadDirs
  1409. ) {
  1410. if (empty($courseInfo)) {
  1411. return '';
  1412. }
  1413. $id = $courseInfo['real_id'];
  1414. $title = $courseInfo['title'];
  1415. $code = $courseInfo['code'];
  1416. $class = 'session-view-lvl-6';
  1417. if ($userCategoryId != 0 && !$displayButton) {
  1418. $class = 'session-view-lvl-7';
  1419. }
  1420. $class2 = 'session-view-lvl-6';
  1421. if ($displayButton || $userCategoryId != 0) {
  1422. $class2 = 'session-view-lvl-7';
  1423. }
  1424. $button = '';
  1425. if ($displayButton) {
  1426. $button = '<input id="session-view-button-'.intval($id).'" class="session-view-button btn btn-default" type="button" onclick="hideUnhide(\'courseblock-'.intval($id).'\', \'session-view-button-'.intval($id).'\', \'+\', \'-\')" value="+" />';
  1427. }
  1428. $icon = Display::return_icon(
  1429. 'blackboard.png',
  1430. $title,
  1431. array('class' => 'sessionView'),
  1432. ICON_SIZE_LARGE
  1433. );
  1434. $courseLink = $courseInfo['course_public_url'].'?id_session=0';
  1435. // get html course params
  1436. // ['right_actions'] ['teachers'] ['notifications']
  1437. $tabParams = CourseManager::getCourseParamsForDisplay($id, $loadDirs);
  1438. // teacher list
  1439. if (!empty($tabParams['teachers'])) {
  1440. $teachers = '<p class="'.$class2.' view-by-session-teachers">'.$tabParams['teachers'].'</p>';
  1441. }
  1442. // notification
  1443. if (!empty($tabParams['right_actions'])) {
  1444. $rightActions = '<div class="view-by-session-right-actions">'.$tabParams['right_actions'].'</div>';
  1445. }
  1446. return "<div>
  1447. $button
  1448. <span class='$class'>$icon
  1449. <a class='sessionView' href='$courseLink'>$title</a>
  1450. </span>".$tabParams['notifications']."$rightActions
  1451. </div>
  1452. $teachers";
  1453. }
  1454. /**
  1455. * return HTML code for session category
  1456. * @param $id
  1457. * @param $title
  1458. * @return string
  1459. */
  1460. private static function getHtmlSessionCategory($id, $title)
  1461. {
  1462. if ($id == 0) {
  1463. return '';
  1464. }
  1465. $icon = Display::return_icon(
  1466. 'folder_blue.png',
  1467. $title,
  1468. array('class' => 'sessionView'),
  1469. ICON_SIZE_LARGE
  1470. );
  1471. return "<div class='session-view-session-category'>
  1472. <span class='session-view-lvl-2'>
  1473. $icon
  1474. <span>$title</span>
  1475. </span>
  1476. </div>";
  1477. }
  1478. /**
  1479. * return HTML code for session
  1480. * @param int $id session id
  1481. * @param string $title session title
  1482. * @param int $categorySessionId
  1483. * @param array $courseInfo
  1484. *
  1485. * @return string
  1486. */
  1487. private static function getHtmlForSession($id, $title, $categorySessionId, $courseInfo)
  1488. {
  1489. $html = '';
  1490. if ($categorySessionId == 0) {
  1491. $class1 = 'session-view-lvl-2'; // session
  1492. $class2 = 'session-view-lvl-4'; // got to course in session link
  1493. } else {
  1494. $class1 = 'session-view-lvl-3'; // session
  1495. $class2 = 'session-view-lvl-5'; // got to course in session link
  1496. }
  1497. $icon = Display::return_icon(
  1498. 'blackboard_blue.png',
  1499. $title,
  1500. array('class' => 'sessionView'),
  1501. ICON_SIZE_LARGE
  1502. );
  1503. $courseLink = $courseInfo['course_public_url'].'?id_session='.intval($id);
  1504. $html .= "<span class='$class1 session-view-session'>$icon$title</span>";
  1505. $html .= '<div class="'.$class2.' session-view-session-go-to-course-in-session">
  1506. <a class="" href="'.$courseLink.'">'.get_lang('GoToCourseInsideSession').'</a></div>';
  1507. return '<div>'.$html.'</div>';
  1508. }
  1509. /**
  1510. * @param $listA
  1511. * @param $listB
  1512. * @return int
  1513. */
  1514. private static function compareByCourse($listA, $listB)
  1515. {
  1516. if ($listA['userCatTitle'] == $listB['userCatTitle']) {
  1517. if ($listA['title'] == $listB['title']) {
  1518. return 0;
  1519. } else if($listA['title'] > $listB['title']) {
  1520. return 1;
  1521. } else {
  1522. return -1;
  1523. }
  1524. } else if ($listA['userCatTitle'] > $listB['userCatTitle']) {
  1525. return 1;
  1526. } else {
  1527. return -1;
  1528. }
  1529. }
  1530. /**
  1531. * @param $listA
  1532. * @param $listB
  1533. * @return int
  1534. */
  1535. public static function compareListUserCategory($listA, $listB)
  1536. {
  1537. if ($listA['title'] == $listB['title']) {
  1538. return 0;
  1539. } else if($listA['title'] > $listB['title']) {
  1540. return 1;
  1541. } else {
  1542. return -1;
  1543. }
  1544. }
  1545. /**
  1546. * @param $view
  1547. * @param $userId
  1548. */
  1549. public static function setDefaultMyCourseView($view, $userId)
  1550. {
  1551. setcookie('defaultMyCourseView'.$userId, $view);
  1552. }
  1553. }