index.php 12 KB

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