index.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  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(LIBRARY_PATH).'course.lib.php';
  21. require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
  22. //require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
  23. // current section
  24. $this_section = SECTION_COURSES;
  25. // protect a course script
  26. api_protect_course_script(true);
  27. // defining constants
  28. define('ADD_THEMATIC_PLAN', 6);
  29. // get actions
  30. $actions = array('thematic_details', 'thematic_list', 'thematic_add', 'thematic_edit', 'thematic_copy', 'thematic_delete', 'moveup', 'movedown',
  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. $htmlHeadXtra[] = api_get_jquery_ui_js();
  65. $htmlHeadXtra[] = '<script language="javascript">
  66. function datetime_by_attendance(selected_value) {
  67. $.ajax({
  68. contentType: "application/x-www-form-urlencoded",
  69. beforeSend: function(objeto) {},
  70. type: "POST",
  71. url: "'.api_get_path(WEB_AJAX_PATH).'thematic.ajax.php?a=get_datetime_by_attendance",
  72. data: "attendance_id="+selected_value+"&thematic_advance_id='.$thematic_id.'",
  73. success: function(datos) {
  74. $("#div_datetime_attendance").html(datos);
  75. }
  76. });
  77. }
  78. $(document).ready(function() {
  79. $(".thematic_advance_actions, .thematic_tools ").hide();
  80. $(".thematic_content").mouseover(function() {
  81. var id = parseInt(this.id.split("_")[3]);
  82. $("#thematic_id_content_"+id ).show();
  83. });
  84. $(".thematic_content").mouseleave(function() {
  85. var id = parseInt(this.id.split("_")[3]);
  86. $("#thematic_id_content_"+id ).hide();
  87. });
  88. $(".thematic_advance_content").mouseover(function() {
  89. var id = parseInt(this.id.split("_")[4]);
  90. $("#thematic_advance_tools_"+id ).show();
  91. });
  92. $(".thematic_advance_content").mouseleave(function() {
  93. var id = parseInt(this.id.split("_")[4]);
  94. $("#thematic_advance_tools_"+id ).hide();
  95. });
  96. //Second col
  97. $(".thematic_plan_opener").live("click", function() {
  98. var url = this.href;
  99. var dialog = $("#dialog");
  100. if ($("#dialog").length == 0) {
  101. dialog = $(\'<div id="dialog" style="display:hidden"></div> \').appendTo(\'body\');
  102. }
  103. // load remote content
  104. dialog.load(
  105. url,
  106. {},
  107. function(responseText, textStatus, XMLHttpRequest) {
  108. dialog.dialog({
  109. width: 720,
  110. height: 550,
  111. modal: true,
  112. buttons: {
  113. '.addslashes(get_lang('Save')).' : function() {
  114. var serialize_form_content = $("#thematic_plan_add").serialize();
  115. //Getting FCK content
  116. var oEditor = FCKeditorAPI.GetInstance("description[1]");
  117. content_1= oEditor.GetXHTML(true) ;
  118. var oEditor = FCKeditorAPI.GetInstance("description[2]");
  119. content_2= oEditor.GetXHTML(true) ;
  120. var oEditor = FCKeditorAPI.GetInstance("description[3]");
  121. content_3= oEditor.GetXHTML(true) ;
  122. var oEditor = FCKeditorAPI.GetInstance("description[4]");
  123. content_4= oEditor.GetXHTML(true) ;
  124. var oEditor = FCKeditorAPI.GetInstance("description[5]");
  125. content_5= oEditor.GetXHTML(true) ;
  126. var oEditor = FCKeditorAPI.GetInstance("description[6]");
  127. content_6= oEditor.GetXHTML(true) ;
  128. $.ajax({
  129. type: "POST",
  130. url: "'.api_get_path(WEB_AJAX_PATH).'thematic.ajax.php?a=save_thematic_plan",
  131. 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,
  132. success: function(data) {
  133. var thematic_id = $("input[name=\"thematic_id\"]").val();
  134. $("#thematic_plan_"+thematic_id).html(data);
  135. }
  136. });
  137. dialog.dialog("close");
  138. }
  139. }
  140. });
  141. }
  142. );
  143. //prevent the browser to follow the link
  144. return false;
  145. });
  146. // Third col
  147. $(".thematic_advanced_opener, .thematic_advanced_add_opener").live("click", function() {
  148. var url = this.href;
  149. var my_class = this.className;
  150. var dialog = $("#dialog");
  151. if ($("#dialog").length == 0) {
  152. dialog = $(\'<div id="dialog" style="display:hidden"></div> \').appendTo(\'body\');
  153. }
  154. // load remote content
  155. dialog.load(
  156. url,
  157. {},
  158. function(responseText, textStatus, XMLHttpRequest) {
  159. dialog.dialog({
  160. width: 720,
  161. height: 550,
  162. modal: true,
  163. buttons: {
  164. '.addslashes(get_lang('Save')).' : function() {
  165. var serialize_form_content = $("#thematic_advance").serialize();
  166. //Getting FCK content
  167. var oEditor = FCKeditorAPI.GetInstance("content");
  168. content = oEditor.GetXHTML(true) ;
  169. $.ajax({
  170. type: "POST",
  171. url: "'.api_get_path(WEB_AJAX_PATH).'thematic.ajax.php?a=save_thematic_advance",
  172. data: "real_content=" + content + "&" +serialize_form_content,
  173. success: function(data) {
  174. var thematic_advance_id = $("input[name=\"thematic_advance_id\"]").val();
  175. $("#thematic_advance_"+thematic_advance_id).html(data);
  176. //Only refresh if the parent is to add
  177. if (my_class == "thematic_advanced_add_opener") {
  178. location.reload(true);
  179. }
  180. }
  181. });
  182. dialog.dialog("close");
  183. }
  184. }
  185. });
  186. }
  187. );
  188. //prevent the browser to follow the link
  189. return false;
  190. });
  191. });
  192. function update_done_thematic_advance(selected_value) {
  193. $.ajax({
  194. contentType: "application/x-www-form-urlencoded",
  195. beforeSend: function(objeto) {},
  196. type: "GET",
  197. url: "'.api_get_path(WEB_AJAX_PATH).'thematic.ajax.php?a=update_done_thematic_advance",
  198. data: "thematic_advance_id="+selected_value,
  199. success: function(data) {
  200. $("#div_result").html(data);
  201. }
  202. });
  203. // clean all radios
  204. for (var i=0; i< $(".done_thematic").length;i++) {
  205. var id_radio_thematic = $(".done_thematic").get(i).id;
  206. $("#td_"+id_radio_thematic).css({"background-color":"#FFF"});
  207. }
  208. // set background to previous radios
  209. for (var i=0; i < $(".done_thematic").length;i++) {
  210. var id_radio_thematic = $(".done_thematic").get(i).id;
  211. $("#td_"+id_radio_thematic).css({"background-color":"#E5EDF9"});
  212. if ($(".done_thematic").get(i).value == selected_value) {
  213. break;
  214. }
  215. }
  216. }
  217. function check_per_attendance(obj) {
  218. if (obj.checked) {
  219. document.getElementById(\'div_datetime_by_attendance\').style.display=\'block\';
  220. document.getElementById(\'div_custom_datetime\').style.display=\'none\';
  221. } else {
  222. document.getElementById(\'div_datetime_by_attendance\').style.display=\'none\';
  223. document.getElementById(\'div_custom_datetime\').style.display=\'block\';
  224. }
  225. }
  226. function check_per_custom_date(obj) {
  227. if (obj.checked) {
  228. document.getElementById(\'div_custom_datetime\').style.display=\'block\';
  229. document.getElementById(\'div_datetime_by_attendance\').style.display=\'none\';
  230. } else {
  231. document.getElementById(\'div_custom_datetime\').style.display=\'none\';
  232. document.getElementById(\'div_datetime_by_attendance\').style.display=\'block\';
  233. }
  234. }
  235. </script>';
  236. if ($action == 'thematic_list') {
  237. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('ThematicControl'));
  238. }
  239. if ($action == 'thematic_add') {
  240. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  241. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('NewThematicSection'));
  242. }
  243. if ($action == 'thematic_edit') {
  244. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  245. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('EditThematicSection'));
  246. }
  247. if ($action == 'thematic_details') {
  248. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('ThematicControl'));
  249. }
  250. if ($action == 'thematic_plan_list' || $action == 'thematic_plan_delete') {
  251. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  252. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('ThematicPlan').' ('.$thematic_data['title'].') ');
  253. }
  254. if ($action == 'thematic_plan_add' || $action == 'thematic_plan_edit') {
  255. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  256. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action=thematic_plan_list&thematic_id='.$thematic_id, 'name' => get_lang('ThematicPlan').' ('.$thematic_data['title'].')');
  257. if ($description_type >= ADD_THEMATIC_PLAN) {
  258. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('NewBloc'));
  259. } else {
  260. $interbreadcrumb[] = array ('url' => '#', 'name' => $default_thematic_plan_title[$description_type]);
  261. }
  262. }
  263. if ($action == 'thematic_advance_list' || $action == 'thematic_advance_delete') {
  264. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  265. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('ThematicAdvance').' ('.$thematic_data['title'].')');
  266. }
  267. if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') {
  268. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  269. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action=thematic_advance_list&thematic_id='.$thematic_id, 'name' => get_lang('ThematicAdvance').' ('.$thematic_data['title'].')');
  270. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('NewThematicAdvance'));
  271. }
  272. // Distpacher actions to controller
  273. switch ($action) {
  274. case 'thematic_add' :
  275. case 'thematic_edit' :
  276. case 'thematic_delete' :
  277. case 'thematic_delete_select' :
  278. case 'thematic_copy' :
  279. case 'moveup' :
  280. case 'movedown' :
  281. if (!api_is_allowed_to_edit(null,true)) {
  282. api_not_allowed();
  283. }
  284. case 'thematic_list' :
  285. case 'thematic_details' :
  286. $thematic_controller->thematic($action);
  287. break;
  288. case 'thematic_plan_add' :
  289. case 'thematic_plan_edit' :
  290. case 'thematic_plan_delete' :
  291. if (!api_is_allowed_to_edit(null,true)) {
  292. api_not_allowed();
  293. }
  294. case 'thematic_plan_list' :
  295. $thematic_controller->thematic_plan($action);
  296. break;
  297. case 'thematic_advance_add' :
  298. case 'thematic_advance_edit' :
  299. case 'thematic_advance_delete' :
  300. if (!api_is_allowed_to_edit(null,true)) {
  301. api_not_allowed();
  302. }
  303. case 'thematic_advance_list' :
  304. $thematic_controller->thematic_advance($action);
  305. break;
  306. }