|
1
|
|
|
<?php |
|
2
|
|
|
/* For licensing terms, see /license.txt */ |
|
3
|
|
|
|
|
4
|
|
|
namespace Chamilo\CoreBundle\Menu; |
|
5
|
|
|
|
|
6
|
|
|
use Knp\Menu\FactoryInterface; |
|
7
|
|
|
use Symfony\Component\DependencyInjection\ContainerAware; |
|
8
|
|
|
use Symfony\Component\DependencyInjection\ContainerAwareInterface; |
|
9
|
|
|
use Symfony\Component\DependencyInjection\ContainerAwareTrait; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Class LeftMenuBuilder |
|
13
|
|
|
* @package Chamilo\CoreBundle\Menu |
|
14
|
|
|
*/ |
|
15
|
|
|
class LeftMenuBuilder implements ContainerAwareInterface |
|
16
|
|
|
{ |
|
17
|
|
|
use ContainerAwareTrait; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Course menu |
|
21
|
|
|
* |
|
22
|
|
|
* @param FactoryInterface $factory |
|
23
|
|
|
* @param array $options |
|
24
|
|
|
* @return \Knp\Menu\ItemInterface |
|
25
|
|
|
*/ |
|
26
|
|
|
public function courseMenu(FactoryInterface $factory, array $options) |
|
27
|
|
|
{ |
|
28
|
|
|
$checker = $this->container->get('security.authorization_checker'); |
|
29
|
|
|
$menu = $factory->createItem('root'); |
|
30
|
|
|
$translator = $this->container->get('translator'); |
|
31
|
|
|
$settingsManager = $this->container->get('chamilo.settings.manager'); |
|
32
|
|
|
|
|
33
|
|
|
if ($checker->isGranted('IS_AUTHENTICATED_FULLY')) { |
|
34
|
|
|
$menu->setChildrenAttribute('class', 'nav nav-pills nav-stacked'); |
|
35
|
|
|
$menu->addChild( |
|
36
|
|
|
$translator->trans('MyCourses'), |
|
37
|
|
|
[ |
|
38
|
|
|
'route' => 'userportal', |
|
39
|
|
|
'routeParameters' => ['type' => 'courses'], |
|
40
|
|
|
] |
|
41
|
|
|
); |
|
42
|
|
|
|
|
43
|
|
|
if (api_is_allowed_to_create_course()) { |
|
44
|
|
|
$lang = $translator->trans('CreateCourse'); |
|
45
|
|
|
if ($settingsManager->getSetting( |
|
46
|
|
|
'course.course_validation' |
|
47
|
|
|
) == 'true' |
|
48
|
|
|
) { |
|
49
|
|
|
$lang = $translator->trans('CreateCourseRequest'); |
|
50
|
|
|
} |
|
51
|
|
|
$menu->addChild( |
|
52
|
|
|
$lang, |
|
53
|
|
|
['route' => 'add_course'] |
|
54
|
|
|
); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
$link = $this->container->get('router')->generate('web.main'); |
|
58
|
|
|
|
|
59
|
|
|
$menu->addChild( |
|
60
|
|
|
$translator->trans('ManageCourses'), |
|
61
|
|
|
[ |
|
62
|
|
|
'uri' => $link.'auth/courses.php?action=sortmycourses', |
|
63
|
|
|
] |
|
64
|
|
|
); |
|
65
|
|
|
|
|
66
|
|
|
$browse = $settingsManager->getSetting( |
|
67
|
|
|
'display.allow_students_to_browse_courses' |
|
68
|
|
|
); |
|
69
|
|
|
|
|
70
|
|
|
if ($browse == 'true') { |
|
71
|
|
|
if ($checker->isGranted('ROLE_STUDENT') && !api_is_drh( |
|
72
|
|
|
) && !api_is_session_admin() |
|
73
|
|
|
) { |
|
74
|
|
|
$menu->addChild( |
|
75
|
|
|
$translator->trans('CourseCatalog'), |
|
76
|
|
|
[ |
|
77
|
|
|
'uri' => $link.'auth/courses.php', |
|
78
|
|
|
] |
|
79
|
|
|
); |
|
80
|
|
|
} else { |
|
81
|
|
|
$menu->addChild( |
|
82
|
|
|
$translator->trans('Dashboard'), |
|
83
|
|
|
[ |
|
84
|
|
|
'uri' => $link.'dashboard/index.php', |
|
85
|
|
|
] |
|
86
|
|
|
); |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** @var \Knp\Menu\MenuItem $menu */ |
|
91
|
|
|
$menu->addChild( |
|
92
|
|
|
$translator->trans('History'), |
|
93
|
|
|
[ |
|
94
|
|
|
'route' => 'userportal', |
|
95
|
|
|
'routeParameters' => [ |
|
96
|
|
|
'type' => 'sessions', |
|
97
|
|
|
'filter' => 'history', |
|
98
|
|
|
], |
|
99
|
|
|
] |
|
100
|
|
|
); |
|
101
|
|
|
|
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
return $menu; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* Course menu |
|
109
|
|
|
* |
|
110
|
|
|
* @param FactoryInterface $factory |
|
111
|
|
|
* @param array $options |
|
112
|
|
|
* @return \Knp\Menu\ItemInterface |
|
113
|
|
|
*/ |
|
114
|
|
|
public function sessionMenu(FactoryInterface $factory, array $options) |
|
115
|
|
|
{ |
|
116
|
|
|
$checker = $this->container->get('security.authorization_checker'); |
|
117
|
|
|
$menu = $factory->createItem('root'); |
|
118
|
|
|
$translator = $this->container->get('translator'); |
|
119
|
|
|
$settingsManager = $this->container->get('chamilo.settings.manager'); |
|
120
|
|
|
|
|
121
|
|
|
if ($checker->isGranted('IS_AUTHENTICATED_FULLY')) { |
|
122
|
|
|
$menu->setChildrenAttribute('class', 'nav nav-pills nav-stacked'); |
|
123
|
|
|
|
|
124
|
|
|
$menu->addChild( |
|
125
|
|
|
$translator->trans('MySessions'), |
|
126
|
|
|
[ |
|
127
|
|
|
'route' => 'userportal', |
|
128
|
|
|
'routeParameters' => ['type' => 'sessions'], |
|
129
|
|
|
] |
|
130
|
|
|
); |
|
131
|
|
|
|
|
132
|
|
|
if ($checker->isGranted('ROLE_ADMIN')) { |
|
133
|
|
|
$menu->addChild( |
|
134
|
|
|
$translator->trans('AddSession'), |
|
135
|
|
|
[ |
|
136
|
|
|
'route' => 'main', |
|
137
|
|
|
'routeParameters' => ['name' => 'session/session_add.php'], |
|
138
|
|
|
] |
|
139
|
|
|
); |
|
140
|
|
|
} |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
return $menu; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
/** |
|
147
|
|
|
* @param FactoryInterface $factory |
|
148
|
|
|
* @param array $options |
|
149
|
|
|
* @return ItemInterface |
|
150
|
|
|
*/ |
|
151
|
|
|
public function profileMenu(FactoryInterface $factory, array $options) |
|
152
|
|
|
{ |
|
153
|
|
|
$menu = $factory->createItem('root'); |
|
154
|
|
|
$security = $this->container->get('security.authorization_checker'); |
|
155
|
|
|
$translator = $this->container->get('translator'); |
|
156
|
|
|
|
|
157
|
|
|
if ($security->isGranted('IS_AUTHENTICATED_FULLY')) { |
|
158
|
|
|
$menu->setChildrenAttribute('class', 'nav nav-pills nav-stacked'); |
|
159
|
|
|
|
|
160
|
|
|
$menu->addChild( |
|
161
|
|
|
$translator->trans('Inbox'), |
|
162
|
|
|
array( |
|
163
|
|
|
'route' => 'main', |
|
164
|
|
|
'routeParameters' => array( |
|
165
|
|
|
'name' => 'messages/inbox.php', |
|
166
|
|
|
), |
|
167
|
|
|
) |
|
168
|
|
|
); |
|
169
|
|
|
|
|
170
|
|
|
$menu->addChild( |
|
171
|
|
|
$translator->trans('Compose'), |
|
172
|
|
|
array( |
|
173
|
|
|
'route' => 'main', |
|
174
|
|
|
'routeParameters' => array( |
|
175
|
|
|
'name' => 'messages/new_message.php', |
|
176
|
|
|
), |
|
177
|
|
|
) |
|
178
|
|
|
); |
|
179
|
|
|
|
|
180
|
|
|
$menu->addChild( |
|
181
|
|
|
$translator->trans('PendingInvitations'), |
|
182
|
|
|
array( |
|
183
|
|
|
'route' => 'main', |
|
184
|
|
|
'routeParameters' => array( |
|
185
|
|
|
'name' => 'social/invitations.php', |
|
186
|
|
|
), |
|
187
|
|
|
) |
|
188
|
|
|
); |
|
189
|
|
|
|
|
190
|
|
|
$menu->addChild( |
|
191
|
|
|
$translator->trans('MyFiles'), |
|
192
|
|
|
array( |
|
193
|
|
|
'route' => 'main', |
|
194
|
|
|
'routeParameters' => array( |
|
195
|
|
|
'name' => 'social/myfiles.php', |
|
196
|
|
|
), |
|
197
|
|
|
) |
|
198
|
|
|
); |
|
199
|
|
|
|
|
200
|
|
|
$menu->addChild( |
|
201
|
|
|
$translator->trans('EditProfile'), |
|
202
|
|
|
array( |
|
203
|
|
|
'route' => 'main', |
|
204
|
|
|
'routeParameters' => array( |
|
205
|
|
|
'name' => 'messages/inbox.php', |
|
206
|
|
|
), |
|
207
|
|
|
) |
|
208
|
|
|
); |
|
209
|
|
|
|
|
210
|
|
|
$menu->addChild( |
|
211
|
|
|
$translator->trans('Inbox'), |
|
212
|
|
|
array( |
|
213
|
|
|
'route' => 'main', |
|
214
|
|
|
'routeParameters' => array( |
|
215
|
|
|
'name' => 'messages/inbox.php', |
|
216
|
|
|
), |
|
217
|
|
|
) |
|
218
|
|
|
); |
|
219
|
|
|
} |
|
220
|
|
|
|
|
221
|
|
|
return $menu; |
|
222
|
|
|
} |
|
223
|
|
|
|
|
224
|
|
|
/** |
|
225
|
|
|
* @todo add validations |
|
226
|
|
|
* @param FactoryInterface $factory |
|
227
|
|
|
* @param array $options |
|
228
|
|
|
* @return ItemInterface |
|
229
|
|
|
*/ |
|
230
|
|
|
public function socialMenu(FactoryInterface $factory, array $options) |
|
231
|
|
|
{ |
|
232
|
|
|
$menu = $factory->createItem('root'); |
|
233
|
|
|
$security = $this->container->get('security.authorization_checker'); |
|
234
|
|
|
$translator = $this->container->get('translator'); |
|
235
|
|
|
|
|
236
|
|
|
if ($security->isGranted('IS_AUTHENTICATED_FULLY')) { |
|
237
|
|
|
$menu->setChildrenAttribute('class', 'nav nav-pills nav-stacked'); |
|
238
|
|
|
|
|
239
|
|
|
$menu->addChild( |
|
240
|
|
|
$translator->trans('Home'), |
|
241
|
|
|
array( |
|
242
|
|
|
'route' => 'main', |
|
243
|
|
|
'routeParameters' => array( |
|
244
|
|
|
'name' => 'social/home.php', |
|
245
|
|
|
), |
|
246
|
|
|
) |
|
247
|
|
|
); |
|
248
|
|
|
|
|
249
|
|
|
$menu->addChild( |
|
250
|
|
|
$translator->trans('Messages'), |
|
251
|
|
|
array( |
|
252
|
|
|
'route' => 'main', |
|
253
|
|
|
'routeParameters' => array( |
|
254
|
|
|
'name' => 'messages/inbox.php', |
|
255
|
|
|
), |
|
256
|
|
|
) |
|
257
|
|
|
); |
|
258
|
|
|
|
|
259
|
|
|
$menu->addChild( |
|
260
|
|
|
$translator->trans('Invitations'), |
|
261
|
|
|
array( |
|
262
|
|
|
'route' => 'main', |
|
263
|
|
|
'routeParameters' => array( |
|
264
|
|
|
'name' => 'social/invitations.php', |
|
265
|
|
|
), |
|
266
|
|
|
) |
|
267
|
|
|
); |
|
268
|
|
|
|
|
269
|
|
|
$menu->addChild( |
|
270
|
|
|
$translator->trans('ViewMySharedProfile'), |
|
271
|
|
|
array( |
|
272
|
|
|
'route' => 'main', |
|
273
|
|
|
'routeParameters' => array( |
|
274
|
|
|
'name' => 'social/profile.php', |
|
275
|
|
|
), |
|
276
|
|
|
) |
|
277
|
|
|
); |
|
278
|
|
|
|
|
279
|
|
|
$menu->addChild( |
|
280
|
|
|
$translator->trans('Friends'), |
|
281
|
|
|
array( |
|
282
|
|
|
'route' => 'main', |
|
283
|
|
|
'routeParameters' => array( |
|
284
|
|
|
'name' => 'social/friends.php', |
|
285
|
|
|
), |
|
286
|
|
|
) |
|
287
|
|
|
); |
|
288
|
|
|
|
|
289
|
|
|
$menu->addChild( |
|
290
|
|
|
$translator->trans('SocialGroups'), |
|
291
|
|
|
array( |
|
292
|
|
|
'route' => 'main', |
|
293
|
|
|
'routeParameters' => array( |
|
294
|
|
|
'name' => 'social/groups.php', |
|
295
|
|
|
), |
|
296
|
|
|
) |
|
297
|
|
|
); |
|
298
|
|
|
|
|
299
|
|
|
$menu->addChild( |
|
300
|
|
|
$translator->trans('Search'), |
|
301
|
|
|
array( |
|
302
|
|
|
'route' => 'main', |
|
303
|
|
|
'routeParameters' => array( |
|
304
|
|
|
'name' => 'social/search.php', |
|
305
|
|
|
), |
|
306
|
|
|
) |
|
307
|
|
|
); |
|
308
|
|
|
|
|
309
|
|
|
$menu->addChild( |
|
310
|
|
|
$translator->trans('MyFiles'), |
|
311
|
|
|
array( |
|
312
|
|
|
'route' => 'main', |
|
313
|
|
|
'routeParameters' => array( |
|
314
|
|
|
'name' => 'social/myfiles.php', |
|
315
|
|
|
), |
|
316
|
|
|
) |
|
317
|
|
|
); |
|
318
|
|
|
} |
|
319
|
|
|
|
|
320
|
|
|
return $menu; |
|
321
|
|
|
} |
|
322
|
|
|
|
|
323
|
|
|
/** |
|
324
|
|
|
* Skills menu |
|
325
|
|
|
* @param FactoryInterface $factory |
|
326
|
|
|
* @param array $options |
|
327
|
|
|
* @return \Knp\Menu\ItemInterface |
|
328
|
|
|
*/ |
|
329
|
|
|
public function skillsMenu(FactoryInterface $factory, array $options) |
|
330
|
|
|
{ |
|
331
|
|
|
$checker = $this->container->get('security.authorization_checker'); |
|
332
|
|
|
$translator = $this->container->get('translator'); |
|
333
|
|
|
$settingsManager = $this->container->get('chamilo.settings.manager'); |
|
334
|
|
|
//$allow = $settingsManager->getSetting('hide_my_certificate_link'); |
|
335
|
|
|
$allow = api_get_configuration_value('hide_my_certificate_link'); |
|
336
|
|
|
|
|
337
|
|
|
$menu = $factory->createItem('root'); |
|
338
|
|
|
if ($checker->isGranted('IS_AUTHENTICATED_FULLY')) { |
|
339
|
|
|
$menu->setChildrenAttribute('class', 'nav nav-pills nav-stacked'); |
|
340
|
|
|
|
|
341
|
|
|
if ($allow == false) { |
|
342
|
|
|
$menu->addChild( |
|
343
|
|
|
$translator->trans('MyCertificates'), |
|
344
|
|
|
[ |
|
345
|
|
|
'route' => 'main', |
|
346
|
|
|
'routeParameters' => ['name' => 'gradebook/my_certificates.php'], |
|
347
|
|
|
] |
|
348
|
|
|
); |
|
349
|
|
|
} |
|
350
|
|
|
|
|
351
|
|
|
if ($settingsManager->getSetting( |
|
352
|
|
|
'allow_public_certificates' |
|
353
|
|
|
) === 'true' |
|
354
|
|
|
) { |
|
355
|
|
|
$menu->addChild( |
|
356
|
|
|
$translator->trans('Search'), |
|
357
|
|
|
[ |
|
358
|
|
|
'route' => 'main', |
|
359
|
|
|
'routeParameters' => ['name' => 'gradebook/search.php'], |
|
360
|
|
|
] |
|
361
|
|
|
); |
|
362
|
|
|
} |
|
363
|
|
|
|
|
364
|
|
|
if ($settingsManager->getSetting('allow_skills_tool') === 'true') { |
|
365
|
|
|
$menu->addChild( |
|
366
|
|
|
$translator->trans('MySkills'), |
|
367
|
|
|
[ |
|
368
|
|
|
'route' => 'main', |
|
369
|
|
|
'routeParameters' => ['name' => 'social/my_skills_report.php'], |
|
370
|
|
|
] |
|
371
|
|
|
); |
|
372
|
|
|
|
|
373
|
|
|
if ($checker->isGranted('ROLE_TEACHER')) { |
|
374
|
|
|
$menu->addChild( |
|
375
|
|
|
$translator->trans('ManageSkills'), |
|
376
|
|
|
[ |
|
377
|
|
|
'route' => 'main', |
|
378
|
|
|
'routeParameters' => ['name' => 'admin/skills_wheel.php'], |
|
379
|
|
|
] |
|
380
|
|
|
); |
|
381
|
|
|
} |
|
382
|
|
|
} |
|
383
|
|
|
} |
|
384
|
|
|
|
|
385
|
|
|
return $menu; |
|
386
|
|
|
} |
|
387
|
|
|
} |
|
388
|
|
|
|