index.php 12 KB

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