Browse Source

Merge pull request #304 from FraGoTe/7161

7161
Yannick Warnier 10 years ago
parent
commit
be7459d7bd

+ 25 - 25
main/course_progress/index.php

@@ -296,40 +296,40 @@ if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') {
 
 // Distpacher actions to controller
 switch ($action) {
-	case 'thematic_add'				:
-	case 'thematic_edit'			:
-	case 'thematic_delete'			:
-	case 'thematic_delete_select'	:
-    case 'thematic_copy'            :
-    case 'thematic_import_select'   :
-    case 'thematic_import'          :
-	case 'moveup'					:
-	case 'movedown'					:
+    case 'thematic_add':
+    case 'thematic_edit':
+    case 'thematic_delete':
+    case 'thematic_delete_select':
+    case 'thematic_copy':
+    case 'thematic_import_select':
+    case 'thematic_import':
+    case 'moveup':
+    case 'movedown':
         if (!api_is_allowed_to_edit(null,true)) {
-        	api_not_allowed();
+                api_not_allowed();
         }
-	case 'thematic_list'			:
-    case 'thematic_export'          :
-    case 'thematic_export_pdf'      :
-    case 'thematic_details'         :
+    case 'thematic_list':
+    case 'thematic_export':
+    case 'thematic_export_pdf':
+    case 'thematic_details':
         $thematic_controller->thematic($action);
-		break;
-	case 'thematic_plan_add'		:
-	case 'thematic_plan_edit'		:
-	case 'thematic_plan_delete'		:
+        break;
+    case 'thematic_plan_add':
+    case 'thematic_plan_edit':
+    case 'thematic_plan_delete':
         if (!api_is_allowed_to_edit(null,true)) {
             api_not_allowed();
         }
-    case 'thematic_plan_list'       :
+    case 'thematic_plan_list':
         $thematic_controller->thematic_plan($action);
-        break;
-	case 'thematic_advance_add'		:
-	case 'thematic_advance_edit'	:
-	case 'thematic_advance_delete'	:
+    break;
+    case 'thematic_advance_add':
+    case 'thematic_advance_edit':
+    case 'thematic_advance_delete':
         if (!api_is_allowed_to_edit(null,true)) {
             api_not_allowed();
         }
-    case 'thematic_advance_list'    :
+    case 'thematic_advance_list':
         $thematic_controller->thematic_advance($action);
-        break;
+    break;
 }

+ 1 - 1
main/course_progress/thematic.php

@@ -163,7 +163,7 @@ if ($action == 'thematic_list') {
 					
 					$edit_link = '';
 					if (api_is_allowed_to_edit(null, true)) {
-						$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>';
+						$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>';
 						$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'].'">'.
                                         Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a></center>';
 						

+ 12 - 6
main/course_progress/thematic_controller.php

@@ -40,7 +40,8 @@ class ThematicController {
 
         $check = Security::check_token('request');
         $thematic_id = isset($_REQUEST['thematic_id']) ? intval($_REQUEST['thematic_id']) : null;
-
+        $displayHeader = (!empty($_REQUEST['display']) && $_REQUEST['display'] === 'no_header') ? false : true;
+ 
         if ($check) {
             switch ($action) {
                 case 'thematic_add':
@@ -248,9 +249,11 @@ class ThematicController {
         $data['default_thematic_plan_title'] = $thematic->get_default_thematic_plan_title();
 
         $data['action'] = $action;
+        $layoutName = $displayHeader ? 'layout' : 'layout_no_header';
+       
         // render to the view
         $this->view->set_data($data);
-        $this->view->set_layout('layout');
+        $this->view->set_layout($layoutName);
         $this->view->set_template('thematic');
         $this->view->render();
     }
@@ -357,7 +360,9 @@ class ThematicController {
         $thematic = new Thematic();
         $attendance = new Attendance();
         $data = array();
-
+        
+        $displayHeader = (!empty($_REQUEST['display']) && $_REQUEST['display'] === 'no_header') ? false : true;
+  
         // get data for attendance input select		
         $attendance_list = $attendance->get_attendances_list();
         $attendance_select = array();
@@ -365,7 +370,7 @@ class ThematicController {
         foreach ($attendance_list as $attendance_id => $attendance_data) {
             $attendance_select[$attendance_id] = $attendance_data['name'];
         }
-
+       
         $thematic_id = intval($_REQUEST['thematic_id']);
         $thematic_advance_id = intval($_REQUEST['thematic_advance_id']);
 
@@ -459,10 +464,11 @@ class ThematicController {
         $data['attendance_select'] = $attendance_select;
         $data['thematic_advance_data'] = $thematic_advance_data;
         $data['calendar_select'] = $calendar_select;
-
+        $layoutName = $displayHeader ? 'layout' : 'layout_no_header';
+        
         // render to the view
         $this->view->set_data($data);
-        $this->view->set_layout('layout');
+        $this->view->set_layout($layoutName);
         $this->view->set_template('thematic_advance');
         $this->view->render();
     }

+ 47 - 55
main/inc/lib/thematic.lib.php

@@ -541,70 +541,62 @@ class Thematic
 		return $final_return;
 	}
 
-	 /**
+	/**
 	 * get thematic advance list
-	 * @param	int		Thematic advance id (optional), get data by thematic advance list
-	 * @param	string	Course code (optional)
-	 * @return	array	data
+	 * @param int $thematic_advance_id Thematic advance id (optional), get data by thematic advance list
+	 * @param string $course_code Course code (optional)
+         * @param bool $force_session_id Force to have a session id
+	 * @return array $data
 	 */
-	 public function get_thematic_advance_list($thematic_advance_id = null, $course_code = null, $force_session_id = false) {	 	// set current course
-	    $course_info = api_get_course_info($course_code);
-
-        $tbl_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE);
-        $tbl_thematic = Database::get_course_table(TABLE_THEMATIC);
+        public function get_thematic_advance_list($thematic_advance_id = null, $course_code = null, $force_session_id = false) { // set current course
+            $course_info = api_get_course_info($course_code);
+            $tbl_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE);
+            $tbl_thematic = Database::get_course_table(TABLE_THEMATIC);
 
-        $data = array();
-
-	 	$condition = '';
-	 	if (isset($thematic_advance_id)) {
-	 		$thematic_advance_id = intval($thematic_advance_id);
-	 		$condition = " AND a.id = $thematic_advance_id ";
-	 	}
-
-        $course_id = $course_info['real_id'];
+            $data = array();
 
+            $condition = '';
+            if (isset($thematic_advance_id)) {
+                $thematic_advance_id = intval($thematic_advance_id);
+                $condition = " AND a.id = $thematic_advance_id ";
+            }
 
-	 	/*if ($force_session_id) {
-            $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 ";
-	 	} else {
-		    $sql = "SELECT * FROM $tbl_thematic_advance a WHERE 1 $condition  ORDER BY start_date ";
-	 	}*/
+            $course_id = $course_info['real_id'];
 
-	 	$sql = "SELECT * FROM $tbl_thematic_advance a WHERE  c_id = $course_id $condition  ORDER BY start_date ";
+            $sql = "SELECT * FROM $tbl_thematic_advance a WHERE  c_id = $course_id $condition  ORDER BY start_date ";
 
-        $elements =  array();
-	 	if ($force_session_id) {
-    	 	$list = api_get_item_property_by_tool('thematic_advance', $course_info['code'], api_get_session_id());
-    	 	foreach($list as $value) {
-    	 	    $elements[$value['ref']]= $value;
-    	 	}
-	 	}
+            $elements = array();
+            if ($force_session_id) {
+                $list = api_get_item_property_by_tool('thematic_advance', $course_info['code'], api_get_session_id());
+                foreach($list as $value) {
+                    $elements[$value['ref']]= $value;
+                }
+            }
 
-        $res = Database::query($sql);
-		if (Database::num_rows($res) > 0) {
-			if (!empty($thematic_advance_id)) {
-				$data = Database::fetch_array($res);
-			} else {
-				// group all data group by thematic id
-				$tmp = array();
-				while ($row = Database::fetch_array($res, 'ASSOC')) {
-
-					$tmp[] = $row['thematic_id'];
-					if (in_array($row['thematic_id'], $tmp)) {
-					    if ($force_session_id) {
-					        if (in_array($row['id'], array_keys($elements))) {
-					            $row['session_id'] = $elements[$row['id']]['id_session'];
-						        $data[$row['thematic_id']][$row['id']] = $row;
-					        }
-					    } else {
-					        $data[$row['thematic_id']][$row['id']] = $row;
-					    }
-					}
+            $res = Database::query($sql);
+            if (Database::num_rows($res) > 0) {
+                if (!empty($thematic_advance_id)) {
+                    $data = Database::fetch_array($res);
+                } else {
+                    // group all data group by thematic id
+                    $tmp = array();
+                    while ($row = Database::fetch_array($res, 'ASSOC')) {
+                        $tmp[] = $row['thematic_id'];
+                        if (in_array($row['thematic_id'], $tmp)) {
+                            if ($force_session_id) {
+                                if (in_array($row['id'], array_keys($elements))) {
+                                    $row['session_id'] = $elements[$row['id']]['id_session'];
+                                    $data[$row['thematic_id']][$row['id']] = $row;
+                                }
+                            } else {
+                                $data[$row['thematic_id']][$row['id']] = $row;
+                            }
+                        }
 
-				}
-			}
-		}
-		return $data;
+                    }
+                }
+            }
+            return $data;
 	 }
 
 	/**