index.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Template (front controller in MVC pattern) used for distpaching to the controllers depend on the current action
  5. * @author Christian Fasanando <christian1827@gmail.com>
  6. * @author Julio Montoya <gugli100@gmail.com> Bugfixes session support
  7. * @package chamilo.course_progress
  8. */
  9. /**
  10. * Code
  11. */
  12. // name of the language file that needs to be included
  13. $language_file = array ('course_description', 'userInfo', 'admin');
  14. // including files
  15. require_once '../inc/global.inc.php';
  16. require_once api_get_path(LIBRARY_PATH).'app_view.php';
  17. require_once 'thematic_controller.php';
  18. // current section
  19. $this_section = SECTION_COURSES;
  20. $current_course_tool = TOOL_COURSE_PROGRESS;
  21. // protect a course script
  22. api_protect_course_script(true);
  23. // defining constants
  24. define('ADD_THEMATIC_PLAN', 6);
  25. // get actions
  26. $actions = array('thematic_details', 'thematic_list', 'thematic_add', 'thematic_edit', 'thematic_copy', 'thematic_delete', 'moveup', 'movedown',
  27. 'thematic_import_select', 'thematic_import', 'thematic_export', 'thematic_export_pdf',
  28. 'thematic_plan_list', 'thematic_plan_add', 'thematic_plan_edit', 'thematic_plan_delete',
  29. 'thematic_advance_list', 'thematic_advance_add', 'thematic_advance_edit', 'thematic_advance_delete');
  30. $action = 'thematic_details';
  31. if (isset($_GET['action']) && in_array($_GET['action'],$actions)) {
  32. $action = $_GET['action'];
  33. }
  34. if (isset($_POST['action']) && $_POST['action'] == 'thematic_delete_select') {
  35. $action = 'thematic_delete_select';
  36. }
  37. if (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'true') {
  38. $action = 'thematic_details';
  39. }
  40. if ($action == 'thematic_details' || $action == 'thematic_list') {
  41. $_SESSION['thematic_control'] = $action;
  42. }
  43. // get thematic id
  44. if (isset($_GET['thematic_id'])) {
  45. $thematic_id = intval($_GET['thematic_id']);
  46. }
  47. // get thematic plan description type
  48. if (isset($_GET['description_type'])) {
  49. $description_type = intval($_GET['description_type']);
  50. }
  51. $courseInfo = api_get_course_info();
  52. // instance thematic object for using like library here
  53. $thematic = new Thematic($courseInfo);
  54. // thematic controller object
  55. $thematic_controller = new ThematicController();
  56. if (!empty($thematic_id)) {
  57. // thematic data by id
  58. $thematic_data = $thematic->get_thematic_list($thematic_id);
  59. }
  60. // get default thematic plan title
  61. $default_thematic_plan_title = $thematic->get_default_thematic_plan_title();
  62. // Only when I see the 3 columns. Avoids double or triple click binding for onclick event
  63. $htmlHeadXtra[] = '<script type="text/javascript">
  64. $(document).ready(function() {
  65. //Second col
  66. /*
  67. $("#thematic_plan_add").live("submit", function() {
  68. var serialize_form_content = $(this).serialize();
  69. //Getting FCK content
  70. var oEditor = FCKeditorAPI.GetInstance("description[1]");
  71. content_1= oEditor.GetXHTML(true) ;
  72. var oEditor = FCKeditorAPI.GetInstance("description[2]");
  73. content_2= oEditor.GetXHTML(true) ;
  74. var oEditor = FCKeditorAPI.GetInstance("description[3]");
  75. content_3= oEditor.GetXHTML(true) ;
  76. var oEditor = FCKeditorAPI.GetInstance("description[4]");
  77. content_4= oEditor.GetXHTML(true) ;
  78. var oEditor = FCKeditorAPI.GetInstance("description[5]");
  79. content_5= oEditor.GetXHTML(true) ;
  80. var oEditor = FCKeditorAPI.GetInstance("description[6]");
  81. content_6= oEditor.GetXHTML(true) ;
  82. $.ajax({
  83. type: "POST",
  84. url: "'.api_get_path(WEB_AJAX_PATH).'thematic.ajax.php?a=save_thematic_plan",
  85. data: "desc[1]="+content_1+"&"+"desc[2]="+content_2+"&"+"desc[3]="+content_3+"&"+"desc[4]="+content_4+"&"+"desc[5]="+content_5+"&"+"desc[6]="+content_6+"&"+serialize_form_content,
  86. success: function(data) {
  87. var thematic_id = $("input[name=\"thematic_id\"]").val();
  88. $("#thematic_plan_"+thematic_id).html(data);
  89. $("#thematic_plan_add").html("<div class=\"confirmation-message\">'.addslashes(get_lang('Saved')).'</div>");
  90. //location.reload(true);
  91. }
  92. });
  93. //prevent the browser to follow the link
  94. return false;
  95. });*/
  96. // Third col
  97. /*
  98. $("#thematic_advance").live("submit", function() {
  99. var url = this.href;
  100. var my_id = this.id;
  101. var serialize_form_content = $(this).serialize();
  102. //Getting FCK content
  103. var oEditor = FCKeditorAPI.GetInstance("content");
  104. content = oEditor.GetXHTML(true) ;
  105. $.ajax({
  106. type: "POST",
  107. url: "'.api_get_path(WEB_AJAX_PATH).'thematic.ajax.php?a=save_thematic_advance",
  108. data: "real_content=" + content + "&" +serialize_form_content,
  109. success: function(data) {
  110. var thematic_advance_id = $("input[name=\"thematic_advance_id\"]").val();
  111. $("#thematic_advance_"+thematic_advance_id).html(data);
  112. $("#thematic_advance").html("<div class=\"confirmation-message\">'.addslashes(get_lang('Saved')).'</div>");
  113. //Only refresh if the parent is to add
  114. if (my_id == "add_button") {
  115. //location.reload(true);
  116. }
  117. }
  118. });
  119. //prevent the browser to follow the link
  120. return false;
  121. });*/
  122. $(".thematic_advance_actions, .thematic_tools ").hide();
  123. $(".thematic_content").mouseover(function() {
  124. var id = parseInt(this.id.split("_")[3]);
  125. $("#thematic_id_content_"+id ).show();
  126. });
  127. $(".thematic_content").mouseleave(function() {
  128. var id = parseInt(this.id.split("_")[3]);
  129. $("#thematic_id_content_"+id ).hide();
  130. });
  131. $(".thematic_advance_content").mouseover(function() {
  132. var id = parseInt(this.id.split("_")[4]);
  133. $("#thematic_advance_tools_"+id ).show();
  134. });
  135. $(".thematic_advance_content").mouseleave(function() {
  136. var id = parseInt(this.id.split("_")[4]);
  137. $("#thematic_advance_tools_"+id ).hide();
  138. });
  139. /*
  140. $("#custom_date").live("click", function() {
  141. $("#div_custom_datetime").css("display", "none");
  142. $("#div_datetime_by_attendance").hide();
  143. });
  144. $("#from_attendance").live("click", function() {
  145. $("#div_custom_datetime").css("display", "block");
  146. $("#div_custom_datetime").show();
  147. $("#div_datetime_by_attendance").show();
  148. });*/
  149. });
  150. </script>';
  151. $htmlHeadXtra[] = '<script type="text/javascript">
  152. function datetime_by_attendance(attendance_id, thematic_advance_id) {
  153. $.ajax({
  154. contentType: "application/x-www-form-urlencoded",
  155. beforeSend: function(objeto) {},
  156. type: "GET",
  157. url: "'.api_get_path(WEB_AJAX_PATH).'thematic.ajax.php?a=get_datetime_by_attendance",
  158. data: "attendance_id="+attendance_id+"&thematic_advance_id="+thematic_advance_id,
  159. success: function(data) {
  160. $("#div_datetime_attendance").html(data);
  161. if (thematic_advance_id == 0) {
  162. $("#start_date_select_calendar").val($("#start_date_select_calendar option:first").val());
  163. }
  164. }
  165. });
  166. }
  167. function update_done_thematic_advance(selected_value) {
  168. $.ajax({
  169. contentType: "application/x-www-form-urlencoded",
  170. beforeSend: function(objeto) {},
  171. type: "GET",
  172. url: "'.api_get_path(WEB_AJAX_PATH).'thematic.ajax.php?a=update_done_thematic_advance",
  173. data: "thematic_advance_id="+selected_value,
  174. success: function(data) {
  175. $("#div_result").html(data);
  176. }
  177. });
  178. // clean all radios
  179. for (var i=0; i< $(".done_thematic").length;i++) {
  180. var id_radio_thematic = $(".done_thematic").get(i).id;
  181. $("#td_"+id_radio_thematic).css({"background-color":"#FFF"});
  182. }
  183. // set background to previous radios
  184. for (var i=0; i < $(".done_thematic").length;i++) {
  185. var id_radio_thematic = $(".done_thematic").get(i).id;
  186. $("#td_"+id_radio_thematic).css({"background-color":"#E5EDF9"});
  187. if ($(".done_thematic").get(i).value == selected_value) {
  188. break;
  189. }
  190. }
  191. }
  192. function check_per_attendance(obj) {
  193. if (obj.checked) {
  194. $("#div_datetime_by_attendance").show();
  195. $("#div_custom_datetime").hide();
  196. } else {
  197. $("#div_datetime_by_attendance").hide();
  198. $("#div_custom_datetime").show();
  199. }
  200. }
  201. function check_per_custom_date(obj) {
  202. if (obj.checked) {
  203. $("#div_custom_datetime").show();
  204. $("#div_datetime_by_attendance").hide();
  205. } else {
  206. $("#div_custom_datetime").hide();
  207. $("#div_datetime_by_attendance").show();
  208. }
  209. }
  210. </script>';
  211. if ($action == 'thematic_list') {
  212. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('ThematicControl'));
  213. }
  214. if ($action == 'thematic_add') {
  215. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  216. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('NewThematicSection'));
  217. }
  218. if ($action == 'thematic_edit') {
  219. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  220. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('EditThematicSection'));
  221. }
  222. if ($action == 'thematic_details') {
  223. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('ThematicControl'));
  224. }
  225. if ($action == 'thematic_plan_list' || $action == 'thematic_plan_delete') {
  226. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  227. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('ThematicPlan').' ('.$thematic_data['title'].') ');
  228. }
  229. if ($action == 'thematic_plan_add' || $action == 'thematic_plan_edit') {
  230. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  231. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action=thematic_plan_list&thematic_id='.$thematic_id, 'name' => get_lang('ThematicPlan').' ('.$thematic_data['title'].')');
  232. if ($description_type >= ADD_THEMATIC_PLAN) {
  233. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('NewBloc'));
  234. } else {
  235. $interbreadcrumb[] = array ('url' => '#', 'name' => $default_thematic_plan_title[$description_type]);
  236. }
  237. }
  238. if ($action == 'thematic_advance_list' || $action == 'thematic_advance_delete') {
  239. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  240. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('ThematicAdvance').' ('.$thematic_data['title'].')');
  241. }
  242. if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') {
  243. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  244. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action=thematic_advance_list&thematic_id='.$thematic_id, 'name' => get_lang('ThematicAdvance').' ('.$thematic_data['title'].')');
  245. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('NewThematicAdvance'));
  246. }
  247. // Distpacher actions to controller
  248. switch ($action) {
  249. case 'thematic_add' :
  250. case 'thematic_edit' :
  251. case 'thematic_delete' :
  252. case 'thematic_delete_select' :
  253. case 'thematic_copy' :
  254. case 'thematic_import_select' :
  255. case 'thematic_import' :
  256. case 'moveup' :
  257. case 'movedown' :
  258. if (!api_is_allowed_to_edit(null,true)) {
  259. api_not_allowed();
  260. }
  261. case 'thematic_list' :
  262. case 'thematic_export' :
  263. case 'thematic_export_pdf' :
  264. case 'thematic_details' :
  265. $thematic_controller->thematic($action);
  266. break;
  267. case 'thematic_plan_add' :
  268. case 'thematic_plan_edit' :
  269. case 'thematic_plan_delete' :
  270. if (!api_is_allowed_to_edit(null,true)) {
  271. api_not_allowed();
  272. }
  273. case 'thematic_plan_list' :
  274. $thematic_controller->thematic_plan($action);
  275. break;
  276. case 'thematic_advance_add' :
  277. case 'thematic_advance_edit' :
  278. case 'thematic_advance_delete' :
  279. if (!api_is_allowed_to_edit(null,true)) {
  280. api_not_allowed();
  281. }
  282. case 'thematic_advance_list' :
  283. $thematic_controller->thematic_advance($action);
  284. break;
  285. }