course_edit.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <?php
  2. // $Id: course_edit.php 9246 2006-09-25 13:24:53Z bmol $
  3. /*
  4. ==============================================================================
  5. Dokeos - elearning and course management software
  6. Copyright (c) 2004 Dokeos S.A.
  7. Copyright (c) 2003 Ghent University (UGent)
  8. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  9. Copyright (c) Olivier Brouckaert
  10. Copyright (c) Bart Mollet, Hogeschool Gent
  11. For a full list of contributors, see "credits.txt".
  12. The full license can be read in "license.txt".
  13. This program is free software; you can redistribute it and/or
  14. modify it under the terms of the GNU General Public License
  15. as published by the Free Software Foundation; either version 2
  16. of the License, or (at your option) any later version.
  17. See the GNU General Public License for more details.
  18. Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  19. ==============================================================================
  20. */
  21. /**
  22. ==============================================================================
  23. * @package dokeos.admin
  24. ==============================================================================
  25. */
  26. /*
  27. ==============================================================================
  28. INIT SECTION
  29. ==============================================================================
  30. */
  31. $langFile = 'admin';
  32. $cidReset = true;
  33. include ('../inc/global.inc.php');
  34. $this_section=SECTION_PLATFORM_ADMIN;
  35. api_protect_admin_script();
  36. include (api_get_path(LIBRARY_PATH).'fileManage.lib.php');
  37. require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  38. $course_table = Database::get_main_table(MAIN_COURSE_TABLE);
  39. $course_code = isset($_GET['course_code']) ? $_GET['course_code'] : $_POST['code'];
  40. $noPHP_SELF = true;
  41. $tool_name = get_lang('ModifyCourseInfo');
  42. //$interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('PlatformAdmin'));
  43. $interbreadcrumb[] = array ("url" => "course_list.php", "name" => get_lang('AdminCourses'));
  44. /*
  45. -----------------------------------------------------------
  46. Libraries
  47. -----------------------------------------------------------
  48. */
  49. /*
  50. ==============================================================================
  51. FUNCTIONS
  52. ==============================================================================
  53. */
  54. /*
  55. ==============================================================================
  56. MAIN CODE
  57. ==============================================================================
  58. */
  59. // Get all course categories
  60. $table_course_category = Database :: get_main_table(MAIN_CATEGORY_TABLE);
  61. $sql = "SELECT code,name FROM ".$table_course_category." WHERE auth_course_child ='TRUE' ORDER BY tree_pos";
  62. $res = api_sql_query($sql, __FILE__, __LINE__);
  63. while ($cat = mysql_fetch_array($res))
  64. {
  65. $categories[$cat['code']] = '('.$cat['code'].') '.$cat['name'];
  66. }
  67. // Build the form
  68. $form = new FormValidator('update_course');
  69. $form->addElement('hidden','code',$course_code);
  70. $form->add_textfield('visual_code', get_lang('CourseCode'));
  71. $form->applyFilter('visual_code','strtoupper');
  72. $form->add_textfield('tutor_name', get_lang('CourseTitular'));
  73. $form->add_textfield( 'title', get_lang('Title'),true, array ('size' => '60'));
  74. $form->addElement('select', 'category_code', get_lang('CourseFaculty'), $categories);
  75. $form->add_textfield( 'department_name', get_lang('CourseDepartment'), false,array ('size' => '60'));
  76. $form->add_textfield( 'department_url', get_lang('CourseDepartmentURL'),false, array ('size' => '60'));
  77. $form->addElement('select_language', 'course_language', get_lang('CourseLanguage'));
  78. $form->addElement('radio', 'visibility', get_lang("CourseAccess"), get_lang('OpenToTheWorld'), COURSE_VISIBILITY_OPEN_WORLD);
  79. $form->addElement('radio', 'visibility', null, get_lang('OpenToThePlatform'), COURSE_VISIBILITY_OPEN_PLATFORM);
  80. $form->addElement('radio', 'visibility', null, get_lang('Private'), COURSE_VISIBILITY_REGISTERED);
  81. $form->addElement('radio', 'visibility', null, get_lang('CourseVisibilityClosed'), COURSE_VISIBILITY_CLOSED);
  82. $form->addElement('radio', 'subscribe', get_lang('Subscription'), get_lang('Allowed'), 1);
  83. $form->addElement('radio', 'subscribe', null, get_lang('Denied'), 0);
  84. $form->addElement('radio', 'unsubscribe', get_lang('Unsubscription'), get_lang('AllowedToUnsubscribe'), 1);
  85. $form->addElement('radio', 'unsubscribe', null, get_lang('NotAllowedToUnsubscribe'), 0);
  86. $form->addElement('text','disk_quota',get_lang('CourseQuota'));
  87. $form->addRule('disk_quota', get_lang('ThisFieldIsRequired'),'required');
  88. $form->addRule('disk_quota',get_lang('ThisFieldShouldBeNumeric'),'numeric');
  89. $form->addElement('submit', null, get_lang('Ok'));
  90. // Set some default values
  91. $sql = "SELECT * FROM $course_table WHERE code='".mysql_real_escape_string($course_code)."'";
  92. $result = api_sql_query($sql, __FILE__, __LINE__);
  93. if (mysql_num_rows($result) != 1)
  94. {
  95. header('Location: course_list.php');
  96. exit ();
  97. }
  98. $course = mysql_fetch_array($result,MYSQL_ASSOC);
  99. $course_db_name = $course['db_name'];
  100. $form->setDefaults($course);
  101. // Validate form
  102. if( $form->validate())
  103. {
  104. $course = $form->exportValues();
  105. $dbName = $_POST['dbName'];
  106. $course_code = $course['code'];
  107. $visual_code = $course['visual_code'];
  108. $tutor_name = $course['tutor_name'];
  109. $title = $course['title'];
  110. $category_code = $course['category_code'];
  111. $department_name = $course['department_name'];
  112. $department_url = $course['department_url'];
  113. $course_language = $course['course_language'];
  114. $disk_quota = $course['disk_quota'];
  115. $visibility = $course['visibility'];
  116. $subscribe = $course['subscribe'];
  117. $unsubscribe = $course['unsubscribe'];
  118. if (!stristr($department_url, 'http://'))
  119. {
  120. $department_url = 'http://'.$department_url;
  121. }
  122. $sql = "UPDATE $course_table SET course_language='".mysql_real_escape_string($course_language)."',
  123. title='".mysql_real_escape_string($title)."',
  124. category_code='".mysql_real_escape_string($category_code)."',
  125. tutor_name='".mysql_real_escape_string($tutor_name)."',
  126. visual_code='".mysql_real_escape_string($visual_code)."',
  127. department_name='".mysql_real_escape_string($department_name)."',
  128. department_url='".mysql_real_escape_string($department_url)."',
  129. disk_quota='".mysql_real_escape_string($disk_quota)."',
  130. visibility = '".mysql_real_escape_string($visibility)."',
  131. subscribe = '".mysql_real_escape_string($subscribe)."',
  132. unsubscribe='".mysql_real_escape_string($unsubscribe)."'
  133. WHERE code='".mysql_real_escape_string($course_code)."'";
  134. api_sql_query($sql, __FILE__, __LINE__);
  135. $forum_config_table = Database::get_course_table(FORUM_CONFIG_TABLE,$course_db_name);
  136. $sql = "UPDATE ".$forum_config_table." SET default_lang='".mysql_real_escape_string($course_language)."'";
  137. header('Location: course_list.php');
  138. exit ();
  139. }
  140. Display::display_header($tool_name);
  141. //api_display_tool_title($tool_name);
  142. // Display the form
  143. $form->display();
  144. /*
  145. ==============================================================================
  146. FOOTER
  147. ==============================================================================
  148. */
  149. Display :: display_footer();
  150. ?>