|
1
|
|
|
<?php |
|
2
|
|
|
/* For licensing terms, see /license.txt */ |
|
3
|
|
|
|
|
4
|
|
|
use Chamilo\CoreBundle\Entity\SequenceResource; |
|
5
|
|
|
use Chamilo\CoreBundle\Entity\SessionRelCourse; |
|
6
|
|
|
use Chamilo\CoreBundle\Entity\Tag; |
|
7
|
|
|
use Chamilo\CoreBundle\Repository\SequenceRepository; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Class CoursesController. |
|
11
|
|
|
* |
|
12
|
|
|
* This file contains class used like controller, |
|
13
|
|
|
* it should be included inside a dispatcher file (e.g: index.php) |
|
14
|
|
|
* |
|
15
|
|
|
* @author Christian Fasanando <[email protected]> - BeezNest |
|
16
|
|
|
* |
|
17
|
|
|
* @package chamilo.auth |
|
18
|
|
|
*/ |
|
19
|
|
|
class CoursesController |
|
20
|
|
|
{ |
|
21
|
|
|
private $toolname; |
|
22
|
|
|
private $view; |
|
23
|
|
|
private $model; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Constructor. |
|
27
|
|
|
*/ |
|
28
|
|
|
public function __construct() |
|
29
|
|
|
{ |
|
30
|
|
|
$this->toolname = 'auth'; |
|
31
|
|
|
//$actived_theme_path = api_get_template(); |
|
32
|
|
|
$this->view = new View($this->toolname); |
|
33
|
|
|
$this->model = new Auth(); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* It's used for listing courses, |
|
38
|
|
|
* render to courses_list view. |
|
39
|
|
|
* |
|
40
|
|
|
* @param string $action |
|
41
|
|
|
* @param string $message confirmation message(optional) |
|
42
|
|
|
*/ |
|
43
|
|
|
public function courseList($action, $message = '') |
|
44
|
|
|
{ |
|
45
|
|
|
$data = []; |
|
46
|
|
|
$data['user_courses'] = $this->model->get_courses_of_user(api_get_user_id()); |
|
47
|
|
|
$data['user_course_categories'] = CourseManager::get_user_course_categories(api_get_user_id()); |
|
48
|
|
|
$data['courses_in_category'] = $this->model->get_courses_in_category(); |
|
49
|
|
|
$data['action'] = $action; |
|
50
|
|
|
$data['message'] = $message; |
|
51
|
|
|
|
|
52
|
|
|
// render to the view |
|
53
|
|
|
$this->view->set_data($data); |
|
54
|
|
|
$this->view->set_layout('catalog_layout'); |
|
55
|
|
|
$this->view->set_template('courses_list'); |
|
56
|
|
|
$this->view->render(); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* It's used for listing categories, render to categories_list view. |
|
61
|
|
|
*/ |
|
62
|
|
|
public function categoryList() |
|
63
|
|
|
{ |
|
64
|
|
|
api_block_anonymous_users(); |
|
65
|
|
|
$stok = Security::get_token(); |
|
66
|
|
|
$actions = Display::url( |
|
67
|
|
|
Display::return_icon('back.png', get_lang('Back'), '', '32'), |
|
68
|
|
|
api_get_path(WEB_CODE_PATH).'auth/courses.php?action=sortmycourses' |
|
69
|
|
|
); |
|
70
|
|
|
$actions = Display::toolbarAction('toolbar-forum', [$actions]); |
|
71
|
|
|
|
|
72
|
|
|
$form = new FormValidator( |
|
73
|
|
|
'create_course_category', |
|
74
|
|
|
'post', |
|
75
|
|
|
api_get_path(WEB_CODE_PATH).'auth/courses.php?action=createcoursecategory' |
|
76
|
|
|
); |
|
77
|
|
|
$form->addHidden('sec_token', $stok); |
|
78
|
|
|
$form->addText('title_course_category', get_lang('Name')); |
|
79
|
|
|
$form->addButtonSave(get_lang('AddCategory'), 'create_course_category'); |
|
80
|
|
|
|
|
81
|
|
|
$tpl = new Template(); |
|
82
|
|
|
$tpl->assign('content', $form->returnForm()); |
|
83
|
|
|
$tpl->assign('actions', $actions); |
|
84
|
|
|
$tpl->display_one_col_template(); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* It's used for listing courses with categories, |
|
89
|
|
|
* render to courses_categories view. |
|
90
|
|
|
* |
|
91
|
|
|
* @param string $action |
|
92
|
|
|
* @param string $category_code |
|
93
|
|
|
* @param string $message |
|
94
|
|
|
* @param string $error |
|
95
|
|
|
* @param string $content |
|
96
|
|
|
* @param array $limit will be used if $random_value is not set. |
|
97
|
|
|
* This array should contains 'start' and 'length' keys |
|
98
|
|
|
* |
|
99
|
|
|
* @internal param \action $string |
|
100
|
|
|
* @internal param \Category $string code (optional) |
|
101
|
|
|
*/ |
|
102
|
|
|
public function courses_categories( |
|
103
|
|
|
$action, |
|
104
|
|
|
$category_code = null, |
|
105
|
|
|
$message = '', |
|
106
|
|
|
$error = '', |
|
107
|
|
|
$content = null, |
|
108
|
|
|
$limit = [] |
|
109
|
|
|
) { |
|
110
|
|
|
$data = []; |
|
111
|
|
|
$listCategories = CoursesAndSessionsCatalog::getCourseCategoriesTree(); |
|
112
|
|
|
|
|
113
|
|
|
$data['countCoursesInCategory'] = CourseCategory::countCoursesInCategory($category_code); |
|
114
|
|
|
if ($action === 'display_random_courses') { |
|
115
|
|
|
// Random value is used instead limit filter |
|
116
|
|
|
$data['browse_courses_in_category'] = CoursesAndSessionsCatalog::getCoursesInCategory(null, 12); |
|
117
|
|
|
$data['countCoursesInCategory'] = count($data['browse_courses_in_category']); |
|
118
|
|
|
} else { |
|
119
|
|
|
if (!isset($category_code)) { |
|
120
|
|
|
$category_code = $listCategories['ALL']['code']; // by default first category |
|
121
|
|
|
} |
|
122
|
|
|
$limit = isset($limit) ? $limit : self::getLimitArray(); |
|
123
|
|
|
$listCourses = CoursesAndSessionsCatalog::getCoursesInCategory($category_code, null, $limit); |
|
124
|
|
|
|
|
125
|
|
|
$data['browse_courses_in_category'] = $listCourses; |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
$data['list_categories'] = $listCategories; |
|
129
|
|
|
$data['code'] = Security::remove_XSS($category_code); |
|
130
|
|
|
|
|
131
|
|
|
// getting all the courses to which the user is subscribed to |
|
132
|
|
|
$curr_user_id = api_get_user_id(); |
|
133
|
|
|
$user_courses = $this->model->get_courses_of_user($curr_user_id); |
|
134
|
|
|
$user_coursecodes = []; |
|
135
|
|
|
|
|
136
|
|
|
// we need only the course codes as these will be used to match against the courses of the category |
|
137
|
|
|
if ($user_courses != '') { |
|
138
|
|
|
foreach ($user_courses as $key => $value) { |
|
139
|
|
|
$user_coursecodes[] = $value['code']; |
|
140
|
|
|
} |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
if (api_is_drh()) { |
|
144
|
|
|
$courses = CourseManager::get_courses_followed_by_drh(api_get_user_id()); |
|
145
|
|
|
foreach ($courses as $course) { |
|
146
|
|
|
$user_coursecodes[] = $course['code']; |
|
147
|
|
|
} |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
$data['user_coursecodes'] = $user_coursecodes; |
|
151
|
|
|
$data['action'] = $action; |
|
152
|
|
|
$data['message'] = $message; |
|
153
|
|
|
$data['content'] = $content; |
|
154
|
|
|
$data['error'] = $error; |
|
155
|
|
|
$data['catalogShowCoursesSessions'] = 0; |
|
156
|
|
|
$showCoursesSessions = (int) api_get_setting('catalog_show_courses_sessions'); |
|
157
|
|
|
if ($showCoursesSessions > 0) { |
|
158
|
|
|
$data['catalogShowCoursesSessions'] = $showCoursesSessions; |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
// render to the view |
|
162
|
|
|
$this->view->set_data($data); |
|
163
|
|
|
$this->view->set_layout('layout'); |
|
164
|
|
|
$this->view->set_template('courses_categories'); |
|
165
|
|
|
$this->view->render(); |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
/** |
|
169
|
|
|
* @param string $search_term |
|
170
|
|
|
* @param string $message |
|
171
|
|
|
* @param string $error |
|
172
|
|
|
* @param string $content |
|
173
|
|
|
* @param array $limit |
|
174
|
|
|
* @param bool $justVisible Whether to search only in courses visibles in the catalogue |
|
175
|
|
|
*/ |
|
176
|
|
|
public function search_courses( |
|
177
|
|
|
$search_term, |
|
178
|
|
|
$message = '', |
|
179
|
|
|
$error = '', |
|
180
|
|
|
$content = null, |
|
181
|
|
|
$limit = [], |
|
182
|
|
|
$justVisible = false |
|
183
|
|
|
) { |
|
184
|
|
|
$data = []; |
|
185
|
|
|
$limit = !empty($limit) ? $limit : self::getLimitArray(); |
|
186
|
|
|
$browse_course_categories = CoursesAndSessionsCatalog::getCourseCategories(); |
|
187
|
|
|
$data['countCoursesInCategory'] = CourseCategory::countCoursesInCategory('ALL', $search_term); |
|
188
|
|
|
$data['browse_courses_in_category'] = CoursesAndSessionsCatalog::search_courses( |
|
189
|
|
|
$search_term, |
|
190
|
|
|
$limit, |
|
191
|
|
|
$justVisible |
|
192
|
|
|
); |
|
193
|
|
|
$data['browse_course_categories'] = $browse_course_categories; |
|
194
|
|
|
$data['search_term'] = Security::remove_XSS($search_term); //filter before showing in template |
|
195
|
|
|
|
|
196
|
|
|
// getting all the courses to which the user is subscribed to |
|
197
|
|
|
$curr_user_id = api_get_user_id(); |
|
198
|
|
|
$user_courses = $this->model->get_courses_of_user($curr_user_id); |
|
199
|
|
|
$user_coursecodes = []; |
|
200
|
|
|
|
|
201
|
|
|
// we need only the course codes as these will be used to match against the courses of the category |
|
202
|
|
|
if ($user_courses != '') { |
|
203
|
|
|
foreach ($user_courses as $value) { |
|
204
|
|
|
$user_coursecodes[] = $value['code']; |
|
205
|
|
|
} |
|
206
|
|
|
} |
|
207
|
|
|
|
|
208
|
|
|
$data['user_coursecodes'] = $user_coursecodes; |
|
209
|
|
|
$data['message'] = $message; |
|
210
|
|
|
$data['content'] = $content; |
|
211
|
|
|
$data['error'] = $error; |
|
212
|
|
|
$data['action'] = 'display_courses'; |
|
213
|
|
|
|
|
214
|
|
|
// render to the view |
|
215
|
|
|
$this->view->set_data($data); |
|
216
|
|
|
$this->view->set_layout('catalog_layout'); |
|
217
|
|
|
$this->view->set_template('courses_categories'); |
|
218
|
|
|
$this->view->render(); |
|
219
|
|
|
} |
|
220
|
|
|
|
|
221
|
|
|
/** |
|
222
|
|
|
* Create a category |
|
223
|
|
|
* render to listing view. |
|
224
|
|
|
* |
|
225
|
|
|
* @param string $title |
|
226
|
|
|
*/ |
|
227
|
|
|
public function addCourseCategory($title) |
|
228
|
|
|
{ |
|
229
|
|
|
$result = $this->model->store_course_category($title); |
|
230
|
|
|
if ($result) { |
|
231
|
|
|
Display::addFlash( |
|
232
|
|
|
Display::return_message(get_lang('CourseCategoryStored')) |
|
233
|
|
|
); |
|
234
|
|
|
} else { |
|
235
|
|
|
Display::addFlash( |
|
236
|
|
|
Display::return_message( |
|
237
|
|
|
get_lang('ACourseCategoryWithThisNameAlreadyExists'), |
|
238
|
|
|
'error' |
|
239
|
|
|
) |
|
240
|
|
|
); |
|
241
|
|
|
} |
|
242
|
|
|
header('Location: '.api_get_path(WEB_CODE_PATH).'auth/courses.php?action=sortmycourses'); |
|
243
|
|
|
exit; |
|
244
|
|
|
} |
|
245
|
|
|
|
|
246
|
|
|
/** |
|
247
|
|
|
* Change course category |
|
248
|
|
|
* render to listing view. |
|
249
|
|
|
* |
|
250
|
|
|
* @param string $course_code |
|
251
|
|
|
* @param int $category_id |
|
252
|
|
|
*/ |
|
253
|
|
|
public function change_course_category($course_code, $category_id) |
|
254
|
|
|
{ |
|
255
|
|
|
$courseInfo = api_get_course_info($course_code); |
|
256
|
|
|
$courseId = $courseInfo['real_id']; |
|
257
|
|
|
|
|
258
|
|
|
$result = $this->model->updateCourseCategory($courseId, $category_id); |
|
259
|
|
|
if ($result) { |
|
260
|
|
|
Display::addFlash( |
|
261
|
|
|
Display::return_message(get_lang('EditCourseCategorySucces')) |
|
262
|
|
|
); |
|
263
|
|
|
} |
|
264
|
|
|
$action = 'sortmycourses'; |
|
265
|
|
|
$this->courseList($action); |
|
266
|
|
|
} |
|
267
|
|
|
|
|
268
|
|
|
/** |
|
269
|
|
|
* Move up/down courses inside a category |
|
270
|
|
|
* render to listing view. |
|
271
|
|
|
* |
|
272
|
|
|
* @param string $move move to up or down |
|
273
|
|
|
* @param string $course_code |
|
274
|
|
|
* @param int $category_id Category id |
|
275
|
|
|
*/ |
|
276
|
|
|
public function move_course($move, $course_code, $category_id) |
|
277
|
|
|
{ |
|
278
|
|
|
$result = $this->model->move_course($move, $course_code, $category_id); |
|
279
|
|
|
if ($result) { |
|
280
|
|
|
Display::addFlash( |
|
281
|
|
|
Display::return_message(get_lang('CourseSortingDone')) |
|
282
|
|
|
); |
|
283
|
|
|
} |
|
284
|
|
|
$action = 'sortmycourses'; |
|
285
|
|
|
$this->courseList($action); |
|
286
|
|
|
} |
|
287
|
|
|
|
|
288
|
|
|
/** |
|
289
|
|
|
* Move up/down categories |
|
290
|
|
|
* render to listing view. |
|
291
|
|
|
* |
|
292
|
|
|
* @param string $move move to up or down |
|
293
|
|
|
* @param int $category_id Category id |
|
294
|
|
|
*/ |
|
295
|
|
|
public function move_category($move, $category_id) |
|
296
|
|
|
{ |
|
297
|
|
|
$result = $this->model->move_category($move, $category_id); |
|
298
|
|
|
if ($result) { |
|
299
|
|
|
Display::addFlash( |
|
300
|
|
|
Display::return_message(get_lang('CategorySortingDone')) |
|
301
|
|
|
); |
|
302
|
|
|
} |
|
303
|
|
|
$action = 'sortmycourses'; |
|
304
|
|
|
$this->courseList($action); |
|
305
|
|
|
} |
|
306
|
|
|
|
|
307
|
|
|
/** |
|
308
|
|
|
* Edit course category |
|
309
|
|
|
* render to listing view. |
|
310
|
|
|
* |
|
311
|
|
|
* @param string $title Category title |
|
312
|
|
|
* @param int $category Category id |
|
313
|
|
|
*/ |
|
314
|
|
|
public function edit_course_category($title, $category) |
|
315
|
|
|
{ |
|
316
|
|
|
$result = $this->model->store_edit_course_category($title, $category); |
|
317
|
|
|
if ($result) { |
|
318
|
|
|
Display::addFlash( |
|
319
|
|
|
Display::return_message(get_lang('CourseCategoryEditStored')) |
|
320
|
|
|
); |
|
321
|
|
|
} |
|
322
|
|
|
$action = 'sortmycourses'; |
|
323
|
|
|
$this->courseList($action); |
|
324
|
|
|
} |
|
325
|
|
|
|
|
326
|
|
|
/** |
|
327
|
|
|
* Delete a course category |
|
328
|
|
|
* render to listing view. |
|
329
|
|
|
* |
|
330
|
|
|
* @param int Category id |
|
331
|
|
|
*/ |
|
332
|
|
|
public function delete_course_category($category_id) |
|
333
|
|
|
{ |
|
334
|
|
|
$result = $this->model->delete_course_category($category_id); |
|
335
|
|
|
if ($result) { |
|
336
|
|
|
Display::addFlash( |
|
337
|
|
|
Display::return_message(get_lang('CourseCategoryDeleted')) |
|
338
|
|
|
); |
|
339
|
|
|
} |
|
340
|
|
|
$action = 'sortmycourses'; |
|
341
|
|
|
$this->courseList($action); |
|
342
|
|
|
} |
|
343
|
|
|
|
|
344
|
|
|
/** |
|
345
|
|
|
* Unsubscribe user from a course |
|
346
|
|
|
* render to listing view. |
|
347
|
|
|
* |
|
348
|
|
|
* @param string $course_code |
|
349
|
|
|
* @param string $search_term |
|
350
|
|
|
* @param string $category_code |
|
351
|
|
|
*/ |
|
352
|
|
|
public function unsubscribe_user_from_course( |
|
353
|
|
|
$course_code, |
|
354
|
|
|
$search_term = null, |
|
355
|
|
|
$category_code = null |
|
356
|
|
|
) { |
|
357
|
|
|
$result = $this->model->remove_user_from_course($course_code); |
|
358
|
|
|
$message = ''; |
|
359
|
|
|
$error = ''; |
|
360
|
|
|
|
|
361
|
|
|
if ($result) { |
|
362
|
|
|
Display::addFlash( |
|
363
|
|
|
Display::return_message(get_lang('YouAreNowUnsubscribed')) |
|
364
|
|
|
); |
|
365
|
|
|
} |
|
366
|
|
|
|
|
367
|
|
|
if (!empty($search_term)) { |
|
368
|
|
|
CoursesAndSessionsCatalog::search_courses($search_term, $message, $error); |
|
369
|
|
|
} else { |
|
370
|
|
|
$this->courses_categories( |
|
371
|
|
|
'subcribe', |
|
372
|
|
|
$category_code, |
|
373
|
|
|
$message, |
|
374
|
|
|
$error |
|
375
|
|
|
); |
|
376
|
|
|
} |
|
377
|
|
|
} |
|
378
|
|
|
|
|
379
|
|
|
/** |
|
380
|
|
|
* Get the html block for courses categories. |
|
381
|
|
|
* |
|
382
|
|
|
* @param string $code Current category code |
|
383
|
|
|
* @param bool $hiddenLinks Whether hidden links |
|
384
|
|
|
* @param array $limit |
|
385
|
|
|
* |
|
386
|
|
|
* @return string The HTML block |
|
387
|
|
|
*/ |
|
388
|
|
|
public function getCoursesCategoriesBlock( |
|
389
|
|
|
$code = null, |
|
390
|
|
|
$hiddenLinks = false, |
|
391
|
|
|
$limit = null |
|
392
|
|
|
) { |
|
393
|
|
|
$categories = CoursesAndSessionsCatalog::getCourseCategories(); |
|
394
|
|
|
$html = ''; |
|
395
|
|
|
if (!empty($categories)) { |
|
396
|
|
|
$action = 'display_courses'; |
|
397
|
|
|
foreach ($categories[0] as $category) { |
|
398
|
|
|
$categoryName = $category['name']; |
|
399
|
|
|
$categoryCode = $category['code']; |
|
400
|
|
|
$categoryCourses = $category['count_courses']; |
|
401
|
|
|
|
|
402
|
|
|
$html .= '<li>'; |
|
403
|
|
|
|
|
404
|
|
|
$categoryLink = CourseCategory::getCourseCategoryUrl( |
|
405
|
|
|
1, |
|
406
|
|
|
$limit['length'], |
|
407
|
|
|
$categoryCode, |
|
408
|
|
|
$hiddenLinks, |
|
409
|
|
|
$action |
|
410
|
|
|
); |
|
411
|
|
|
|
|
412
|
|
|
if ($code == $categoryCode) { |
|
413
|
|
|
$html .= '<strong>'; |
|
414
|
|
|
$html .= "$categoryName ($categoryCourses)"; |
|
415
|
|
|
$html .= '</strong>'; |
|
416
|
|
|
} else { |
|
417
|
|
|
if (!empty($categoryCourses)) { |
|
418
|
|
|
$html .= '<a href="'.$categoryLink.'">'; |
|
419
|
|
|
$html .= "$categoryName ($categoryCourses)"; |
|
420
|
|
|
$html .= '</a>'; |
|
421
|
|
|
} else { |
|
422
|
|
|
$html .= "$categoryName ($categoryCourses)"; |
|
423
|
|
|
} |
|
424
|
|
|
} |
|
425
|
|
|
|
|
426
|
|
|
if (!empty($categories[$categoryCode])) { |
|
427
|
|
|
$html .= '<ul class="nav nav-list">'; |
|
428
|
|
|
|
|
429
|
|
|
foreach ($categories[$categoryCode] as $subCategory1) { |
|
430
|
|
|
$subCategory1Name = $subCategory1['name']; |
|
431
|
|
|
$subCategory1Code = $subCategory1['code']; |
|
432
|
|
|
$subCategory1Courses = $subCategory1['count_courses']; |
|
433
|
|
|
$html .= '<li>'; |
|
434
|
|
|
if ($code == $subCategory1Code) { |
|
435
|
|
|
$html .= "<strong>$subCategory1Name ($subCategory1Courses)</strong>"; |
|
436
|
|
|
} else { |
|
437
|
|
|
$html .= '<a href="'.$categoryLink.'">'; |
|
438
|
|
|
$html .= "$subCategory1Name ($subCategory1Courses)"; |
|
439
|
|
|
$html .= '</a>'; |
|
440
|
|
|
} |
|
441
|
|
|
|
|
442
|
|
|
if (!empty($categories[$subCategory1Code])) { |
|
443
|
|
|
$html .= '<ul class="nav nav-list">'; |
|
444
|
|
|
|
|
445
|
|
|
foreach ($categories[$subCategory1Code] as $subCategory2) { |
|
446
|
|
|
$subCategory2Name = $subCategory2['name']; |
|
447
|
|
|
$subCategory2Code = $subCategory2['code']; |
|
448
|
|
|
$subCategory2Courses = $subCategory2['count_courses']; |
|
449
|
|
|
|
|
450
|
|
|
$html .= '<li>'; |
|
451
|
|
|
|
|
452
|
|
|
if ($code == $subCategory2Code) { |
|
453
|
|
|
$html .= "<strong>$subCategory2Name ($subCategory2Courses)</strong>"; |
|
454
|
|
|
} else { |
|
455
|
|
|
$html .= '<a href="'.$categoryLink.'">'; |
|
456
|
|
|
$html .= "$subCategory2Name ($subCategory2Courses)"; |
|
457
|
|
|
$html .= '</a>'; |
|
458
|
|
|
} |
|
459
|
|
|
|
|
460
|
|
|
if (!empty($categories[$subCategory2Code])) { |
|
461
|
|
|
$html .= '<ul class="nav nav-list">'; |
|
462
|
|
|
|
|
463
|
|
|
foreach ($categories[$subCategory2Code] as $subCategory3) { |
|
464
|
|
|
$subCategory3Name = $subCategory3['name']; |
|
465
|
|
|
$subCategory3Code = $subCategory3['code']; |
|
466
|
|
|
$subCategory3Courses = $subCategory3['count_courses']; |
|
467
|
|
|
|
|
468
|
|
|
$html .= '<li>'; |
|
469
|
|
|
|
|
470
|
|
|
if ($code == $subCategory3Code) { |
|
471
|
|
|
$html .= "<strong>$subCategory3Name ($subCategory3Courses)</strong>"; |
|
472
|
|
|
} else { |
|
473
|
|
|
$html .= '<a href="'.$categoryLink.'">'; |
|
474
|
|
|
$html .= "$subCategory3Name ($subCategory3Courses)"; |
|
475
|
|
|
$html .= '</a>'; |
|
476
|
|
|
} |
|
477
|
|
|
$html .= '</li>'; |
|
478
|
|
|
} |
|
479
|
|
|
$html .= '</ul>'; |
|
480
|
|
|
} |
|
481
|
|
|
$html .= '</li>'; |
|
482
|
|
|
} |
|
483
|
|
|
$html .= '</ul>'; |
|
484
|
|
|
} |
|
485
|
|
|
$html .= '</li>'; |
|
486
|
|
|
} |
|
487
|
|
|
$html .= '</ul>'; |
|
488
|
|
|
} |
|
489
|
|
|
$html .= '</li>'; |
|
490
|
|
|
} |
|
491
|
|
|
} |
|
492
|
|
|
|
|
493
|
|
|
return $html; |
|
494
|
|
|
} |
|
495
|
|
|
|
|
496
|
|
|
/** |
|
497
|
|
|
* Get a HTML button for subscribe to session. |
|
498
|
|
|
* |
|
499
|
|
|
* @param int $sessionId The session ID |
|
500
|
|
|
* @param string $sessionName The session name |
|
501
|
|
|
* @param bool $checkRequirements Optional. |
|
502
|
|
|
* Whether the session has requirement. Default is false |
|
503
|
|
|
* @param bool $includeText Optional. Whether show the text in button |
|
504
|
|
|
* @param bool $btnBing |
|
505
|
|
|
* |
|
506
|
|
|
* @return string The button HTML |
|
507
|
|
|
*/ |
|
508
|
|
|
public function getRegisteredInSessionButton( |
|
509
|
|
|
$sessionId, |
|
510
|
|
|
$sessionName, |
|
511
|
|
|
$checkRequirements = false, |
|
512
|
|
|
$includeText = false, |
|
513
|
|
|
$btnBing = false |
|
514
|
|
|
) { |
|
515
|
|
|
if ($btnBing) { |
|
516
|
|
|
$btnBing = 'btn-lg btn-block'; |
|
517
|
|
|
} else { |
|
518
|
|
|
$btnBing = 'btn-sm'; |
|
519
|
|
|
} |
|
520
|
|
|
if ($checkRequirements) { |
|
521
|
|
|
$url = api_get_path(WEB_AJAX_PATH); |
|
522
|
|
|
$url .= 'sequence.ajax.php?'; |
|
523
|
|
|
$url .= http_build_query([ |
|
524
|
|
|
'a' => 'get_requirements', |
|
525
|
|
|
'id' => intval($sessionId), |
|
526
|
|
|
'type' => SequenceResource::SESSION_TYPE, |
|
527
|
|
|
]); |
|
528
|
|
|
|
|
529
|
|
|
return Display::toolbarButton( |
|
530
|
|
|
get_lang('CheckRequirements'), |
|
531
|
|
|
$url, |
|
532
|
|
|
'shield', |
|
533
|
|
|
'info', |
|
534
|
|
|
[ |
|
535
|
|
|
'class' => $btnBing.' ajax', |
|
536
|
|
|
'data-title' => get_lang('CheckRequirements'), |
|
537
|
|
|
'data-size' => 'md', |
|
538
|
|
|
'title' => get_lang('CheckRequirements'), |
|
539
|
|
|
], |
|
540
|
|
|
$includeText |
|
541
|
|
|
); |
|
542
|
|
|
} |
|
543
|
|
|
|
|
544
|
|
|
$catalogSessionAutoSubscriptionAllowed = false; |
|
545
|
|
|
if (api_get_setting('catalog_allow_session_auto_subscription') === 'true') { |
|
546
|
|
|
$catalogSessionAutoSubscriptionAllowed = true; |
|
547
|
|
|
} |
|
548
|
|
|
|
|
549
|
|
|
$url = api_get_path(WEB_CODE_PATH); |
|
550
|
|
|
|
|
551
|
|
|
if ($catalogSessionAutoSubscriptionAllowed) { |
|
552
|
|
|
$url .= 'auth/courses.php?'; |
|
553
|
|
|
$url .= http_build_query([ |
|
554
|
|
|
'action' => 'subscribe_to_session', |
|
555
|
|
|
'session_id' => intval($sessionId), |
|
556
|
|
|
]); |
|
557
|
|
|
|
|
558
|
|
|
$result = Display::toolbarButton( |
|
559
|
|
|
get_lang('Subscribe'), |
|
560
|
|
|
$url, |
|
561
|
|
|
'pencil', |
|
562
|
|
|
'primary', |
|
563
|
|
|
[ |
|
564
|
|
|
'class' => $btnBing.' ajax', |
|
565
|
|
|
'data-title' => get_lang('AreYouSureToSubscribe'), |
|
566
|
|
|
'data-size' => 'md', |
|
567
|
|
|
'title' => get_lang('Subscribe'), |
|
568
|
|
|
], |
|
569
|
|
|
$includeText |
|
570
|
|
|
); |
|
571
|
|
|
} else { |
|
572
|
|
|
$url .= 'inc/email_editor.php?'; |
|
573
|
|
|
$url .= http_build_query([ |
|
574
|
|
|
'action' => 'subscribe_me_to_session', |
|
575
|
|
|
'session' => Security::remove_XSS($sessionName), |
|
576
|
|
|
]); |
|
577
|
|
|
|
|
578
|
|
|
$result = Display::toolbarButton( |
|
579
|
|
|
get_lang('SubscribeToSessionRequest'), |
|
580
|
|
|
$url, |
|
581
|
|
|
'pencil', |
|
582
|
|
|
'primary', |
|
583
|
|
|
['class' => $btnBing], |
|
584
|
|
|
$includeText |
|
585
|
|
|
); |
|
586
|
|
|
} |
|
587
|
|
|
|
|
588
|
|
|
$hook = HookResubscribe::create(); |
|
589
|
|
|
if (!empty($hook)) { |
|
590
|
|
|
$hook->setEventData([ |
|
591
|
|
|
'session_id' => intval($sessionId), |
|
592
|
|
|
]); |
|
593
|
|
|
try { |
|
594
|
|
|
$hook->notifyResubscribe(HOOK_EVENT_TYPE_PRE); |
|
595
|
|
|
} catch (Exception $exception) { |
|
596
|
|
|
$result = $exception->getMessage(); |
|
597
|
|
|
} |
|
598
|
|
|
} |
|
599
|
|
|
|
|
600
|
|
|
return $result; |
|
601
|
|
|
} |
|
602
|
|
|
|
|
603
|
|
|
/** |
|
604
|
|
|
* Generate a label if the user has been registered in session. |
|
605
|
|
|
* |
|
606
|
|
|
* @return string The label |
|
607
|
|
|
*/ |
|
608
|
|
|
public function getAlreadyRegisteredInSessionLabel() |
|
609
|
|
|
{ |
|
610
|
|
|
$icon = '<em class="fa fa-graduation-cap"></em>'; |
|
611
|
|
|
|
|
612
|
|
|
return Display::div( |
|
613
|
|
|
$icon, |
|
614
|
|
|
[ |
|
615
|
|
|
'class' => 'btn btn-default btn-sm registered', |
|
616
|
|
|
'title' => get_lang("AlreadyRegisteredToSession"), |
|
617
|
|
|
] |
|
618
|
|
|
); |
|
619
|
|
|
} |
|
620
|
|
|
|
|
621
|
|
|
/** |
|
622
|
|
|
* Get a icon for a session. |
|
623
|
|
|
* |
|
624
|
|
|
* @param string $sessionName The session name |
|
625
|
|
|
* |
|
626
|
|
|
* @return string The icon |
|
627
|
|
|
*/ |
|
628
|
|
|
public function getSessionIcon($sessionName) |
|
629
|
|
|
{ |
|
630
|
|
|
return Display::return_icon( |
|
631
|
|
|
'window_list.png', |
|
632
|
|
|
$sessionName, |
|
633
|
|
|
null, |
|
634
|
|
|
ICON_SIZE_MEDIUM |
|
635
|
|
|
); |
|
636
|
|
|
} |
|
637
|
|
|
|
|
638
|
|
|
/** |
|
639
|
|
|
* Return Session catalog rendered view. |
|
640
|
|
|
* |
|
641
|
|
|
* @param string $action |
|
642
|
|
|
* @param string $nameTools |
|
643
|
|
|
* @param array $limit |
|
644
|
|
|
*/ |
|
645
|
|
|
public function sessionList($action, $nameTools, $limit = []) |
|
646
|
|
|
{ |
|
647
|
|
|
$date = isset($_POST['date']) ? $_POST['date'] : date('Y-m-d'); |
|
648
|
|
|
$hiddenLinks = isset($_GET['hidden_links']) ? $_GET['hidden_links'] == 1 : false; |
|
649
|
|
|
$limit = isset($limit) ? $limit : self::getLimitArray(); |
|
650
|
|
|
$countSessions = SessionManager::countSessionsByEndDate($date); |
|
651
|
|
|
$sessions = CoursesAndSessionsCatalog::browseSessions($date, $limit); |
|
652
|
|
|
|
|
653
|
|
|
$pageTotal = ceil($countSessions / $limit['length']); |
|
654
|
|
|
// Do NOT show pagination if only one page or less |
|
655
|
|
|
$cataloguePagination = $pageTotal > 1 ? CourseCategory::getCatalogPagination($limit['current'], $limit['length'], $pageTotal) : ''; |
|
656
|
|
|
$sessionsBlocks = $this->getFormattedSessionsBlock($sessions); |
|
657
|
|
|
|
|
658
|
|
|
// Get session search catalogue URL |
|
659
|
|
|
$courseUrl = CourseCategory::getCourseCategoryUrl( |
|
660
|
|
|
1, |
|
661
|
|
|
$limit['length'], |
|
662
|
|
|
null, |
|
663
|
|
|
0, |
|
664
|
|
|
'subscribe' |
|
665
|
|
|
); |
|
666
|
|
|
|
|
667
|
|
|
$tpl = new Template(); |
|
668
|
|
|
$tpl->assign('show_courses', CoursesAndSessionsCatalog::showCourses()); |
|
669
|
|
|
$tpl->assign('show_sessions', CoursesAndSessionsCatalog::showSessions()); |
|
670
|
|
|
$tpl->assign('show_tutor', api_get_setting('show_session_coach') === 'true'); |
|
671
|
|
|
$tpl->assign('course_url', $courseUrl); |
|
672
|
|
|
$tpl->assign('catalog_pagination', $cataloguePagination); |
|
673
|
|
|
$tpl->assign('hidden_links', $hiddenLinks); |
|
674
|
|
|
$tpl->assign('search_token', Security::get_token()); |
|
675
|
|
|
$tpl->assign('search_date', $date); |
|
676
|
|
|
$tpl->assign('web_session_courses_ajax_url', api_get_path(WEB_AJAX_PATH).'course.ajax.php'); |
|
677
|
|
|
$tpl->assign('sessions', $sessionsBlocks); |
|
678
|
|
|
$tpl->assign('already_subscribed_label', $this->getAlreadyRegisteredInSessionLabel()); |
|
679
|
|
|
|
|
680
|
|
|
$layout = $tpl->get_template('auth/session_catalog.html.twig'); |
|
681
|
|
|
$content = $tpl->fetch($layout); |
|
682
|
|
|
$tpl->assign('content', $content); |
|
683
|
|
|
$tpl->display_one_col_template(); |
|
684
|
|
|
} |
|
685
|
|
|
|
|
686
|
|
|
/** |
|
687
|
|
|
* Show the Session Catalogue with filtered session by course tags. |
|
688
|
|
|
* |
|
689
|
|
|
* @param array $limit Limit info |
|
690
|
|
|
*/ |
|
691
|
|
|
public function sessionsListByCoursesTag(array $limit) |
|
692
|
|
|
{ |
|
693
|
|
|
$searchTag = isset($_POST['search_tag']) ? $_POST['search_tag'] : null; |
|
694
|
|
|
$searchDate = isset($_POST['date']) ? $_POST['date'] : date('Y-m-d'); |
|
695
|
|
|
$hiddenLinks = isset($_GET['hidden_links']) ? intval($_GET['hidden_links']) == 1 : false; |
|
696
|
|
|
$courseUrl = CourseCategory::getCourseCategoryUrl( |
|
697
|
|
|
1, |
|
698
|
|
|
$limit['length'], |
|
699
|
|
|
null, |
|
700
|
|
|
0, |
|
701
|
|
|
'subscribe' |
|
702
|
|
|
); |
|
703
|
|
|
|
|
704
|
|
|
$sessions = CoursesAndSessionsCatalog::browseSessionsByTags($searchTag, $limit); |
|
705
|
|
|
$sessionsBlocks = $this->getFormattedSessionsBlock($sessions); |
|
706
|
|
|
|
|
707
|
|
|
$tpl = new Template(); |
|
708
|
|
|
$tpl->assign('show_courses', CoursesAndSessionsCatalog::showCourses()); |
|
709
|
|
|
$tpl->assign('show_sessions', CoursesAndSessionsCatalog::showSessions()); |
|
710
|
|
|
$tpl->assign('show_tutor', (api_get_setting('show_session_coach') === 'true' ? true : false)); |
|
711
|
|
|
$tpl->assign('course_url', $courseUrl); |
|
712
|
|
|
$tpl->assign('already_subscribed_label', $this->getAlreadyRegisteredInSessionLabel()); |
|
713
|
|
|
$tpl->assign('hidden_links', $hiddenLinks); |
|
714
|
|
|
$tpl->assign('search_token', Security::get_token()); |
|
715
|
|
|
$tpl->assign('search_date', Security::remove_XSS($searchDate)); |
|
716
|
|
|
$tpl->assign('search_tag', Security::remove_XSS($searchTag)); |
|
717
|
|
|
$tpl->assign('sessions', $sessionsBlocks); |
|
718
|
|
|
|
|
719
|
|
|
$contentTemplate = $tpl->get_template('auth/session_catalog.tpl'); |
|
720
|
|
|
|
|
721
|
|
|
$tpl->display($contentTemplate); |
|
722
|
|
|
} |
|
723
|
|
|
|
|
724
|
|
|
/** |
|
725
|
|
|
* Show the Session Catalogue with filtered session by a query term. |
|
726
|
|
|
* |
|
727
|
|
|
* @param array $limit |
|
728
|
|
|
*/ |
|
729
|
|
|
public function sessionListBySearch(array $limit) |
|
730
|
|
|
{ |
|
731
|
|
|
$q = isset($_REQUEST['q']) ? Security::remove_XSS($_REQUEST['q']) : null; |
|
732
|
|
|
$hiddenLinks = isset($_GET['hidden_links']) ? (int) $_GET['hidden_links'] == 1 : false; |
|
733
|
|
|
$courseUrl = CourseCategory::getCourseCategoryUrl( |
|
734
|
|
|
1, |
|
735
|
|
|
$limit['length'], |
|
736
|
|
|
null, |
|
737
|
|
|
0, |
|
738
|
|
|
'subscribe' |
|
739
|
|
|
); |
|
740
|
|
|
$searchDate = isset($_POST['date']) ? $_POST['date'] : date('Y-m-d'); |
|
741
|
|
|
|
|
742
|
|
|
$sessions = CoursesAndSessionsCatalog::browseSessionsBySearch($q, $limit); |
|
743
|
|
|
$sessionsBlocks = $this->getFormattedSessionsBlock($sessions); |
|
744
|
|
|
|
|
745
|
|
|
$tpl = new Template(); |
|
746
|
|
|
$tpl->assign('show_courses', CoursesAndSessionsCatalog::showCourses()); |
|
747
|
|
|
$tpl->assign('show_sessions', CoursesAndSessionsCatalog::showSessions()); |
|
748
|
|
|
$tpl->assign('show_tutor', api_get_setting('show_session_coach') === 'true' ? true : false); |
|
749
|
|
|
$tpl->assign('course_url', $courseUrl); |
|
750
|
|
|
$tpl->assign('already_subscribed_label', $this->getAlreadyRegisteredInSessionLabel()); |
|
751
|
|
|
$tpl->assign('hidden_links', $hiddenLinks); |
|
752
|
|
|
$tpl->assign('search_token', Security::get_token()); |
|
753
|
|
|
$tpl->assign('search_date', Security::remove_XSS($searchDate)); |
|
754
|
|
|
$tpl->assign('search_tag', Security::remove_XSS($q)); |
|
755
|
|
|
$tpl->assign('sessions', $sessionsBlocks); |
|
756
|
|
|
|
|
757
|
|
|
$contentTemplate = $tpl->get_template('auth/session_catalog.tpl'); |
|
758
|
|
|
|
|
759
|
|
|
$tpl->display($contentTemplate); |
|
760
|
|
|
} |
|
761
|
|
|
|
|
762
|
|
|
/** |
|
763
|
|
|
* @return array |
|
764
|
|
|
*/ |
|
765
|
|
|
public static function getLimitArray() |
|
766
|
|
|
{ |
|
767
|
|
|
$pageCurrent = isset($_REQUEST['pageCurrent']) ? (int) $_GET['pageCurrent'] : 1; |
|
768
|
|
|
$pageLength = isset($_REQUEST['pageLength']) ? (int) $_GET['pageLength'] : CoursesAndSessionsCatalog::PAGE_LENGTH; |
|
769
|
|
|
|
|
770
|
|
|
return [ |
|
771
|
|
|
'start' => ($pageCurrent - 1) * $pageLength, |
|
772
|
|
|
'current' => $pageCurrent, |
|
773
|
|
|
'length' => $pageLength, |
|
774
|
|
|
]; |
|
775
|
|
|
} |
|
776
|
|
|
|
|
777
|
|
|
/** |
|
778
|
|
|
* Get the formatted data for sessions block to be displayed on Session Catalog page. |
|
779
|
|
|
* |
|
780
|
|
|
* @param array $sessions The session list |
|
781
|
|
|
* |
|
782
|
|
|
* @return array |
|
783
|
|
|
*/ |
|
784
|
|
|
private function getFormattedSessionsBlock(array $sessions) |
|
785
|
|
|
{ |
|
786
|
|
|
$extraFieldValue = new ExtraFieldValue('session'); |
|
787
|
|
|
$userId = api_get_user_id(); |
|
788
|
|
|
$sessionsBlocks = []; |
|
789
|
|
|
$entityManager = Database::getManager(); |
|
790
|
|
|
$sessionRelCourseRepo = $entityManager->getRepository('ChamiloCoreBundle:SessionRelCourse'); |
|
791
|
|
|
$extraFieldRepo = $entityManager->getRepository('ChamiloCoreBundle:ExtraField'); |
|
792
|
|
|
$extraFieldRelTagRepo = $entityManager->getRepository('ChamiloCoreBundle:ExtraFieldRelTag'); |
|
793
|
|
|
|
|
794
|
|
|
$tagsField = $extraFieldRepo->findOneBy([ |
|
795
|
|
|
'extraFieldType' => Chamilo\CoreBundle\Entity\ExtraField::COURSE_FIELD_TYPE, |
|
796
|
|
|
'variable' => 'tags', |
|
797
|
|
|
]); |
|
798
|
|
|
|
|
799
|
|
|
/** @var \Chamilo\CoreBundle\Entity\Session $session */ |
|
800
|
|
|
foreach ($sessions as $session) { |
|
801
|
|
|
$sessionDates = SessionManager::parseSessionDates([ |
|
802
|
|
|
'display_start_date' => $session->getDisplayStartDate(), |
|
803
|
|
|
'display_end_date' => $session->getDisplayEndDate(), |
|
804
|
|
|
'access_start_date' => $session->getAccessStartDate(), |
|
805
|
|
|
'access_end_date' => $session->getAccessEndDate(), |
|
806
|
|
|
'coach_access_start_date' => $session->getCoachAccessStartDate(), |
|
807
|
|
|
'coach_access_end_date' => $session->getCoachAccessEndDate(), |
|
808
|
|
|
]); |
|
809
|
|
|
|
|
810
|
|
|
$imageField = $extraFieldValue->get_values_by_handler_and_field_variable( |
|
811
|
|
|
$session->getId(), |
|
812
|
|
|
'image' |
|
813
|
|
|
); |
|
814
|
|
|
$sessionCourseTags = []; |
|
815
|
|
|
if (!is_null($tagsField)) { |
|
816
|
|
|
$sessionRelCourses = $sessionRelCourseRepo->findBy([ |
|
817
|
|
|
'session' => $session, |
|
818
|
|
|
]); |
|
819
|
|
|
/** @var SessionRelCourse $sessionRelCourse */ |
|
820
|
|
|
foreach ($sessionRelCourses as $sessionRelCourse) { |
|
821
|
|
|
$courseTags = $extraFieldRelTagRepo->getTags( |
|
822
|
|
|
$tagsField, |
|
823
|
|
|
$sessionRelCourse->getCourse()->getId() |
|
824
|
|
|
); |
|
825
|
|
|
/** @var Tag $tag */ |
|
826
|
|
|
foreach ($courseTags as $tag) { |
|
827
|
|
|
$sessionCourseTags[] = $tag->getTag(); |
|
828
|
|
|
} |
|
829
|
|
|
} |
|
830
|
|
|
} |
|
831
|
|
|
|
|
832
|
|
|
if (!empty($sessionCourseTags)) { |
|
833
|
|
|
$sessionCourseTags = array_unique($sessionCourseTags); |
|
834
|
|
|
} |
|
835
|
|
|
|
|
836
|
|
|
/** @var SequenceRepository $repo */ |
|
837
|
|
|
$repo = $entityManager->getRepository('ChamiloCoreBundle:SequenceResource'); |
|
838
|
|
|
$sequences = $repo->getRequirementsAndDependenciesWithinSequences( |
|
839
|
|
|
$session->getId(), |
|
840
|
|
|
SequenceResource::SESSION_TYPE |
|
841
|
|
|
); |
|
842
|
|
|
|
|
843
|
|
|
$hasRequirements = false; |
|
844
|
|
|
foreach ($sequences['sequences'] as $sequence) { |
|
845
|
|
|
if (count($sequence['requirements']) === 0) { |
|
846
|
|
|
continue; |
|
847
|
|
|
} |
|
848
|
|
|
$hasRequirements = true; |
|
849
|
|
|
break; |
|
850
|
|
|
} |
|
851
|
|
|
$cat = $session->getCategory(); |
|
852
|
|
|
if (empty($cat)) { |
|
853
|
|
|
$cat = null; |
|
854
|
|
|
$catName = ''; |
|
855
|
|
|
} else { |
|
856
|
|
|
$catName = $cat->getName(); |
|
857
|
|
|
} |
|
858
|
|
|
|
|
859
|
|
|
$generalCoach = $session->getGeneralCoach(); |
|
860
|
|
|
$coachId = $generalCoach ? $generalCoach->getId() : 0; |
|
861
|
|
|
$coachName = $generalCoach ? UserManager::formatUserFullName($session->getGeneralCoach()) : ''; |
|
862
|
|
|
|
|
863
|
|
|
$actions = null; |
|
864
|
|
|
if (api_is_platform_admin()) { |
|
865
|
|
|
$actions = api_get_path(WEB_CODE_PATH).'session/resume_session.php?id_session='.$session->getId(); |
|
866
|
|
|
} |
|
867
|
|
|
|
|
868
|
|
|
$plugin = \BuyCoursesPlugin::create(); |
|
869
|
|
|
$isThisSessionOnSale = $plugin->getBuyCoursePluginPrice($session); |
|
870
|
|
|
|
|
871
|
|
|
$sessionsBlock = [ |
|
872
|
|
|
'id' => $session->getId(), |
|
873
|
|
|
'name' => $session->getName(), |
|
874
|
|
|
'image' => isset($imageField['value']) ? $imageField['value'] : null, |
|
875
|
|
|
'nbr_courses' => $session->getNbrCourses(), |
|
876
|
|
|
'nbr_users' => $session->getNbrUsers(), |
|
877
|
|
|
'coach_id' => $coachId, |
|
878
|
|
|
'coach_url' => $generalCoach |
|
879
|
|
|
? api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=get_user_popup&user_id='.$coachId |
|
880
|
|
|
: '', |
|
881
|
|
|
'coach_name' => $coachName, |
|
882
|
|
|
'coach_avatar' => UserManager::getUserPicture( |
|
883
|
|
|
$coachId, |
|
884
|
|
|
USER_IMAGE_SIZE_SMALL |
|
885
|
|
|
), |
|
886
|
|
|
'is_subscribed' => SessionManager::isUserSubscribedAsStudent( |
|
887
|
|
|
$session->getId(), |
|
888
|
|
|
$userId |
|
889
|
|
|
), |
|
890
|
|
|
'icon' => $this->getSessionIcon($session->getName()), |
|
891
|
|
|
'date' => $sessionDates['display'], |
|
892
|
|
|
'price' => !empty($isThisSessionOnSale['html']) ? $isThisSessionOnSale['html'] : '', |
|
893
|
|
|
'subscribe_button' => isset($isThisSessionOnSale['buy_button']) ? $isThisSessionOnSale['buy_button'] : $this->getRegisteredInSessionButton( |
|
894
|
|
|
$session->getId(), |
|
895
|
|
|
$session->getName(), |
|
896
|
|
|
$hasRequirements |
|
897
|
|
|
), |
|
898
|
|
|
'show_description' => $session->getShowDescription(), |
|
899
|
|
|
'description' => $session->getDescription(), |
|
900
|
|
|
'category' => $catName, |
|
901
|
|
|
'tags' => $sessionCourseTags, |
|
902
|
|
|
'edit_actions' => $actions, |
|
903
|
|
|
'duration' => SessionManager::getDayLeftInSession( |
|
904
|
|
|
['id' => $session->getId(), 'duration' => $session->getDuration()], |
|
905
|
|
|
$userId |
|
906
|
|
|
), |
|
907
|
|
|
]; |
|
908
|
|
|
|
|
909
|
|
|
$sessionsBlock = array_merge($sessionsBlock, $sequences); |
|
910
|
|
|
$sessionsBlocks[] = $sessionsBlock; |
|
911
|
|
|
} |
|
912
|
|
|
|
|
913
|
|
|
return $sessionsBlocks; |
|
914
|
|
|
} |
|
915
|
|
|
} |
|
916
|
|
|
|