index.php 12 KB

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