Skip to content

Commit be7459d

Browse files
committed
Merge pull request #304 from FraGoTe/7161
7161
2 parents d011ec4 + 78d68af commit be7459d

File tree

4 files changed

+85
-87
lines changed

4 files changed

+85
-87
lines changed

main/course_progress/index.php

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -296,40 +296,40 @@ function check_per_custom_date(obj) {
296296

297297
// Distpacher actions to controller
298298
switch ($action) {
299-
case 'thematic_add' :
300-
case 'thematic_edit' :
301-
case 'thematic_delete' :
302-
case 'thematic_delete_select' :
303-
case 'thematic_copy' :
304-
case 'thematic_import_select' :
305-
case 'thematic_import' :
306-
case 'moveup' :
307-
case 'movedown' :
299+
case 'thematic_add':
300+
case 'thematic_edit':
301+
case 'thematic_delete':
302+
case 'thematic_delete_select':
303+
case 'thematic_copy':
304+
case 'thematic_import_select':
305+
case 'thematic_import':
306+
case 'moveup':
307+
case 'movedown':
308308
if (!api_is_allowed_to_edit(null,true)) {
309-
api_not_allowed();
309+
api_not_allowed();
310310
}
311-
case 'thematic_list' :
312-
case 'thematic_export' :
313-
case 'thematic_export_pdf' :
314-
case 'thematic_details' :
311+
case 'thematic_list':
312+
case 'thematic_export':
313+
case 'thematic_export_pdf':
314+
case 'thematic_details':
315315
$thematic_controller->thematic($action);
316-
break;
317-
case 'thematic_plan_add' :
318-
case 'thematic_plan_edit' :
319-
case 'thematic_plan_delete' :
316+
break;
317+
case 'thematic_plan_add':
318+
case 'thematic_plan_edit':
319+
case 'thematic_plan_delete':
320320
if (!api_is_allowed_to_edit(null,true)) {
321321
api_not_allowed();
322322
}
323-
case 'thematic_plan_list' :
323+
case 'thematic_plan_list':
324324
$thematic_controller->thematic_plan($action);
325-
break;
326-
case 'thematic_advance_add' :
327-
case 'thematic_advance_edit' :
328-
case 'thematic_advance_delete' :
325+
break;
326+
case 'thematic_advance_add':
327+
case 'thematic_advance_edit':
328+
case 'thematic_advance_delete':
329329
if (!api_is_allowed_to_edit(null,true)) {
330330
api_not_allowed();
331331
}
332-
case 'thematic_advance_list' :
332+
case 'thematic_advance_list':
333333
$thematic_controller->thematic_advance($action);
334-
break;
334+
break;
335335
}

main/course_progress/thematic.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@
163163

164164
$edit_link = '';
165165
if (api_is_allowed_to_edit(null, true)) {
166-
$edit_link = '<a class="thickbox" href="index.php?'.api_get_cidreq().'&action=thematic_advance_edit&thematic_id='.$thematic['id'].'&thematic_advance_id='.$thematic_advance['id'].'" >'.Display::return_icon('edit.png',get_lang('EditThematicAdvance'),array(),ICON_SIZE_SMALL).'</a>';
166+
$edit_link = '<a class="thickbox" href="index.php?'.api_get_cidreq().'&action=thematic_advance_edit&thematic_id='.$thematic['id'].'&thematic_advance_id='.$thematic_advance['id'].'&display=no_header" >'.Display::return_icon('edit.png',get_lang('EditThematicAdvance'),array(),ICON_SIZE_SMALL).'</a>';
167167
$edit_link .= '<a onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToDelete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_advance_delete&thematic_id='.$thematic['id'].'&thematic_advance_id='.$thematic_advance['id'].'">'.
168168
Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a></center>';
169169

main/course_progress/thematic_controller.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ public function thematic($action) {
4040

4141
$check = Security::check_token('request');
4242
$thematic_id = isset($_REQUEST['thematic_id']) ? intval($_REQUEST['thematic_id']) : null;
43-
43+
$displayHeader = (!empty($_REQUEST['display']) && $_REQUEST['display'] === 'no_header') ? false : true;
44+
4445
if ($check) {
4546
switch ($action) {
4647
case 'thematic_add':
@@ -248,9 +249,11 @@ public function thematic($action) {
248249
$data['default_thematic_plan_title'] = $thematic->get_default_thematic_plan_title();
249250

250251
$data['action'] = $action;
252+
$layoutName = $displayHeader ? 'layout' : 'layout_no_header';
253+
251254
// render to the view
252255
$this->view->set_data($data);
253-
$this->view->set_layout('layout');
256+
$this->view->set_layout($layoutName);
254257
$this->view->set_template('thematic');
255258
$this->view->render();
256259
}
@@ -357,15 +360,17 @@ public function thematic_advance($action) {
357360
$thematic = new Thematic();
358361
$attendance = new Attendance();
359362
$data = array();
360-
363+
364+
$displayHeader = (!empty($_REQUEST['display']) && $_REQUEST['display'] === 'no_header') ? false : true;
365+
361366
// get data for attendance input select
362367
$attendance_list = $attendance->get_attendances_list();
363368
$attendance_select = array();
364369
$attendance_select[0] = get_lang('SelectAnAttendance');
365370
foreach ($attendance_list as $attendance_id => $attendance_data) {
366371
$attendance_select[$attendance_id] = $attendance_data['name'];
367372
}
368-
373+
369374
$thematic_id = intval($_REQUEST['thematic_id']);
370375
$thematic_advance_id = intval($_REQUEST['thematic_advance_id']);
371376

@@ -459,10 +464,11 @@ public function thematic_advance($action) {
459464
$data['attendance_select'] = $attendance_select;
460465
$data['thematic_advance_data'] = $thematic_advance_data;
461466
$data['calendar_select'] = $calendar_select;
462-
467+
$layoutName = $displayHeader ? 'layout' : 'layout_no_header';
468+
463469
// render to the view
464470
$this->view->set_data($data);
465-
$this->view->set_layout('layout');
471+
$this->view->set_layout($layoutName);
466472
$this->view->set_template('thematic_advance');
467473
$this->view->render();
468474
}

main/inc/lib/thematic.lib.php

Lines changed: 47 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -541,70 +541,62 @@ public function get_thematic_plan_div($data) {
541541
return $final_return;
542542
}
543543

544-
/**
544+
/**
545545
* get thematic advance list
546-
* @param int Thematic advance id (optional), get data by thematic advance list
547-
* @param string Course code (optional)
548-
* @return array data
546+
* @param int $thematic_advance_id Thematic advance id (optional), get data by thematic advance list
547+
* @param string $course_code Course code (optional)
548+
* @param bool $force_session_id Force to have a session id
549+
* @return array $data
549550
*/
550-
public function get_thematic_advance_list($thematic_advance_id = null, $course_code = null, $force_session_id = false) { // set current course
551-
$course_info = api_get_course_info($course_code);
552-
553-
$tbl_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE);
554-
$tbl_thematic = Database::get_course_table(TABLE_THEMATIC);
551+
public function get_thematic_advance_list($thematic_advance_id = null, $course_code = null, $force_session_id = false) { // set current course
552+
$course_info = api_get_course_info($course_code);
553+
$tbl_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE);
554+
$tbl_thematic = Database::get_course_table(TABLE_THEMATIC);
555555

556-
$data = array();
557-
558-
$condition = '';
559-
if (isset($thematic_advance_id)) {
560-
$thematic_advance_id = intval($thematic_advance_id);
561-
$condition = " AND a.id = $thematic_advance_id ";
562-
}
563-
564-
$course_id = $course_info['real_id'];
556+
$data = array();
565557

558+
$condition = '';
559+
if (isset($thematic_advance_id)) {
560+
$thematic_advance_id = intval($thematic_advance_id);
561+
$condition = " AND a.id = $thematic_advance_id ";
562+
}
566563

567-
/*if ($force_session_id) {
568-
$sql = "SELECT a.* FROM $tbl_thematic_advance a INNER JOIN $tbl_thematic t ON t.id = a.thematic_id WHERE 1 $condition AND t.session_id = ".api_get_session_id()." ORDER BY start_date ";
569-
} else {
570-
$sql = "SELECT * FROM $tbl_thematic_advance a WHERE 1 $condition ORDER BY start_date ";
571-
}*/
564+
$course_id = $course_info['real_id'];
572565

573-
$sql = "SELECT * FROM $tbl_thematic_advance a WHERE c_id = $course_id $condition ORDER BY start_date ";
566+
$sql = "SELECT * FROM $tbl_thematic_advance a WHERE c_id = $course_id $condition ORDER BY start_date ";
574567

575-
$elements = array();
576-
if ($force_session_id) {
577-
$list = api_get_item_property_by_tool('thematic_advance', $course_info['code'], api_get_session_id());
578-
foreach($list as $value) {
579-
$elements[$value['ref']]= $value;
580-
}
581-
}
568+
$elements = array();
569+
if ($force_session_id) {
570+
$list = api_get_item_property_by_tool('thematic_advance', $course_info['code'], api_get_session_id());
571+
foreach($list as $value) {
572+
$elements[$value['ref']]= $value;
573+
}
574+
}
582575

583-
$res = Database::query($sql);
584-
if (Database::num_rows($res) > 0) {
585-
if (!empty($thematic_advance_id)) {
586-
$data = Database::fetch_array($res);
587-
} else {
588-
// group all data group by thematic id
589-
$tmp = array();
590-
while ($row = Database::fetch_array($res, 'ASSOC')) {
591-
592-
$tmp[] = $row['thematic_id'];
593-
if (in_array($row['thematic_id'], $tmp)) {
594-
if ($force_session_id) {
595-
if (in_array($row['id'], array_keys($elements))) {
596-
$row['session_id'] = $elements[$row['id']]['id_session'];
597-
$data[$row['thematic_id']][$row['id']] = $row;
598-
}
599-
} else {
600-
$data[$row['thematic_id']][$row['id']] = $row;
601-
}
602-
}
576+
$res = Database::query($sql);
577+
if (Database::num_rows($res) > 0) {
578+
if (!empty($thematic_advance_id)) {
579+
$data = Database::fetch_array($res);
580+
} else {
581+
// group all data group by thematic id
582+
$tmp = array();
583+
while ($row = Database::fetch_array($res, 'ASSOC')) {
584+
$tmp[] = $row['thematic_id'];
585+
if (in_array($row['thematic_id'], $tmp)) {
586+
if ($force_session_id) {
587+
if (in_array($row['id'], array_keys($elements))) {
588+
$row['session_id'] = $elements[$row['id']]['id_session'];
589+
$data[$row['thematic_id']][$row['id']] = $row;
590+
}
591+
} else {
592+
$data[$row['thematic_id']][$row['id']] = $row;
593+
}
594+
}
603595

604-
}
605-
}
606-
}
607-
return $data;
596+
}
597+
}
598+
}
599+
return $data;
608600
}
609601

610602
/**

0 commit comments

Comments
 (0)