index.php 12 KB

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