index.php 12 KB

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