index.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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', 'pedaSuggest', '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).'thematic.lib.php';
  18. require_once api_get_path(LIBRARY_PATH).'app_view.php';
  19. require_once 'thematic_controller.php';
  20. //require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
  21. // current section
  22. $this_section = SECTION_COURSES;
  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_plan_list', 'thematic_plan_add', 'thematic_plan_edit', 'thematic_plan_delete',
  30. 'thematic_advance_list', 'thematic_advance_add', 'thematic_advance_edit', 'thematic_advance_delete');
  31. $action = 'thematic_details';
  32. if (isset($_GET['action']) && in_array($_GET['action'],$actions)) {
  33. $action = $_GET['action'];
  34. }
  35. if (isset($_POST['action']) && $_POST['action'] == 'thematic_delete_select') {
  36. $action = 'thematic_delete_select';
  37. }
  38. if (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'true') {
  39. $action = 'thematic_details';
  40. }
  41. if ($action == 'thematic_details' || $action == 'thematic_list') {
  42. $_SESSION['thematic_control'] = $action;
  43. }
  44. // get thematic id
  45. if (isset($_GET['thematic_id'])) {
  46. $thematic_id = intval($_GET['thematic_id']);
  47. }
  48. // get thematic plan description type
  49. if (isset($_GET['description_type'])) {
  50. $description_type = intval($_GET['description_type']);
  51. }
  52. // instance thematic object for using like library here
  53. $thematic = new Thematic();
  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. $("#add_plan").live("click", function() {
  67. var serialize_form_content = $("#thematic_plan_add").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. }
  90. });
  91. //prevent the browser to follow the link
  92. return false;
  93. });
  94. // Third col
  95. $("#update_button, #add_button").click(function() {
  96. var url = this.href;
  97. var my_id = this.id;
  98. var serialize_form_content = $("#thematic_advance").serialize();
  99. //Getting FCK content
  100. var oEditor = FCKeditorAPI.GetInstance("content");
  101. content = oEditor.GetXHTML(true) ;
  102. $.ajax({
  103. type: "POST",
  104. url: "'.api_get_path(WEB_AJAX_PATH).'thematic.ajax.php?a=save_thematic_advance",
  105. data: "real_content=" + content + "&" +serialize_form_content,
  106. success: function(data) {
  107. var thematic_advance_id = $("input[name=\"thematic_advance_id\"]").val();
  108. $("#thematic_advance_"+thematic_advance_id).html(data);
  109. $("#thematic_advance").html("<div class=\"confirmation-message\">'.addslashes(get_lang('Saved')).'</div>");
  110. //Only refresh if the parent is to add
  111. if (my_id == "add_button") {
  112. location.reload(true);
  113. }
  114. }
  115. });
  116. //prevent the browser to follow the link
  117. return false;
  118. });
  119. });
  120. </script>';
  121. $htmlHeadXtra[] = '<script type="text/javascript">
  122. function datetime_by_attendance(selected_value) {
  123. $.ajax({
  124. contentType: "application/x-www-form-urlencoded",
  125. beforeSend: function(objeto) {},
  126. type: "POST",
  127. url: "'.api_get_path(WEB_AJAX_PATH).'thematic.ajax.php?a=get_datetime_by_attendance",
  128. data: "attendance_id="+selected_value+"&thematic_advance_id='.$thematic_id.'",
  129. success: function(datos) {
  130. $("#div_datetime_attendance").html(datos);
  131. $("#start_date_select_calendar").val($("#start_date_select_calendar option:first").val());
  132. // $("#duration_in_hours_element").focus();
  133. }
  134. });
  135. }
  136. $(document).ready(function() {
  137. $(".thematic_advance_actions, .thematic_tools ").hide();
  138. $(".thematic_content").mouseover(function() {
  139. var id = parseInt(this.id.split("_")[3]);
  140. $("#thematic_id_content_"+id ).show();
  141. });
  142. $(".thematic_content").mouseleave(function() {
  143. var id = parseInt(this.id.split("_")[3]);
  144. $("#thematic_id_content_"+id ).hide();
  145. });
  146. $(".thematic_advance_content").mouseover(function() {
  147. var id = parseInt(this.id.split("_")[4]);
  148. $("#thematic_advance_tools_"+id ).show();
  149. });
  150. $(".thematic_advance_content").mouseleave(function() {
  151. var id = parseInt(this.id.split("_")[4]);
  152. $("#thematic_advance_tools_"+id ).hide();
  153. });
  154. });
  155. function update_done_thematic_advance(selected_value) {
  156. $.ajax({
  157. contentType: "application/x-www-form-urlencoded",
  158. beforeSend: function(objeto) {},
  159. type: "GET",
  160. url: "'.api_get_path(WEB_AJAX_PATH).'thematic.ajax.php?a=update_done_thematic_advance",
  161. data: "thematic_advance_id="+selected_value,
  162. success: function(data) {
  163. $("#div_result").html(data);
  164. }
  165. });
  166. // clean all radios
  167. for (var i=0; i< $(".done_thematic").length;i++) {
  168. var id_radio_thematic = $(".done_thematic").get(i).id;
  169. $("#td_"+id_radio_thematic).css({"background-color":"#FFF"});
  170. }
  171. // set background to previous radios
  172. for (var i=0; i < $(".done_thematic").length;i++) {
  173. var id_radio_thematic = $(".done_thematic").get(i).id;
  174. $("#td_"+id_radio_thematic).css({"background-color":"#E5EDF9"});
  175. if ($(".done_thematic").get(i).value == selected_value) {
  176. break;
  177. }
  178. }
  179. }
  180. function check_per_attendance(obj) {
  181. if (obj.checked) {
  182. document.getElementById(\'div_datetime_by_attendance\').style.display=\'block\';
  183. document.getElementById(\'div_custom_datetime\').style.display=\'none\';
  184. } else {
  185. document.getElementById(\'div_datetime_by_attendance\').style.display=\'none\';
  186. document.getElementById(\'div_custom_datetime\').style.display=\'block\';
  187. }
  188. }
  189. function check_per_custom_date(obj) {
  190. if (obj.checked) {
  191. document.getElementById(\'div_custom_datetime\').style.display=\'block\';
  192. document.getElementById(\'div_datetime_by_attendance\').style.display=\'none\';
  193. } else {
  194. document.getElementById(\'div_custom_datetime\').style.display=\'none\';
  195. document.getElementById(\'div_datetime_by_attendance\').style.display=\'block\';
  196. }
  197. }
  198. </script>';
  199. if ($action == 'thematic_list') {
  200. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('ThematicControl'));
  201. }
  202. if ($action == 'thematic_add') {
  203. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  204. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('NewThematicSection'));
  205. }
  206. if ($action == 'thematic_edit') {
  207. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  208. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('EditThematicSection'));
  209. }
  210. if ($action == 'thematic_details') {
  211. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('ThematicControl'));
  212. }
  213. if ($action == 'thematic_plan_list' || $action == 'thematic_plan_delete') {
  214. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  215. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('ThematicPlan').' ('.$thematic_data['title'].') ');
  216. }
  217. if ($action == 'thematic_plan_add' || $action == 'thematic_plan_edit') {
  218. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  219. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action=thematic_plan_list&thematic_id='.$thematic_id, 'name' => get_lang('ThematicPlan').' ('.$thematic_data['title'].')');
  220. if ($description_type >= ADD_THEMATIC_PLAN) {
  221. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('NewBloc'));
  222. } else {
  223. $interbreadcrumb[] = array ('url' => '#', 'name' => $default_thematic_plan_title[$description_type]);
  224. }
  225. }
  226. if ($action == 'thematic_advance_list' || $action == 'thematic_advance_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('ThematicAdvance').' ('.$thematic_data['title'].')');
  229. }
  230. if ($action == 'thematic_advance_add' || $action == 'thematic_advance_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_advance_list&thematic_id='.$thematic_id, 'name' => get_lang('ThematicAdvance').' ('.$thematic_data['title'].')');
  233. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('NewThematicAdvance'));
  234. }
  235. // Distpacher actions to controller
  236. switch ($action) {
  237. case 'thematic_add' :
  238. case 'thematic_edit' :
  239. case 'thematic_delete' :
  240. case 'thematic_delete_select' :
  241. case 'thematic_copy' :
  242. case 'moveup' :
  243. case 'movedown' :
  244. if (!api_is_allowed_to_edit(null,true)) {
  245. api_not_allowed();
  246. }
  247. case 'thematic_list' :
  248. case 'thematic_details' :
  249. $thematic_controller->thematic($action);
  250. break;
  251. case 'thematic_plan_add' :
  252. case 'thematic_plan_edit' :
  253. case 'thematic_plan_delete' :
  254. if (!api_is_allowed_to_edit(null,true)) {
  255. api_not_allowed();
  256. }
  257. case 'thematic_plan_list' :
  258. $thematic_controller->thematic_plan($action);
  259. break;
  260. case 'thematic_advance_add' :
  261. case 'thematic_advance_edit' :
  262. case 'thematic_advance_delete' :
  263. if (!api_is_allowed_to_edit(null,true)) {
  264. api_not_allowed();
  265. }
  266. case 'thematic_advance_list' :
  267. $thematic_controller->thematic_advance($action);
  268. break;
  269. }