group_edit.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <?php
  2. /*
  3. DOKEOS - elearning and course management software
  4. For a full list of contributors, see documentation/credits.html
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  9. See "documentation/licence.html" more details.
  10. Contact:
  11. Dokeos
  12. Rue des Palais 44 Paleizenstraat
  13. B-1030 Brussels - Belgium
  14. Tel. +32 (2) 211 34 56
  15. */
  16. /**
  17. * @package dokeos.survey
  18. * @author
  19. * @version $Id: group_edit.php 10705 2007-01-12 22:40:01Z pcool $
  20. */
  21. /*
  22. ==============================================================================
  23. INIT SECTION
  24. ==============================================================================
  25. */
  26. // name of the language file that needs to be included
  27. $language_file = 'survey';
  28. // including the global dokeos file
  29. require_once ('../inc/global.inc.php');
  30. // including additional libraries
  31. /** @todo check if these are all needed */
  32. /** @todo check if the starting / is needed. api_get_path probably ends with an / */
  33. require_once (api_get_path(LIBRARY_PATH).'/fileManage.lib.php');
  34. require_once (api_get_path(CONFIGURATION_PATH) ."/add_course.conf.php");
  35. require_once (api_get_path(LIBRARY_PATH)."/add_course.lib.inc.php");
  36. require_once (api_get_path(LIBRARY_PATH)."/surveymanager.lib.php");
  37. require_once (api_get_path(LIBRARY_PATH)."/usermanager.lib.php");
  38. /** @todo replace this with the correct code */
  39. /*
  40. $status = surveymanager::get_status();
  41. api_protect_course_script();
  42. if($status==5)
  43. {
  44. api_protect_admin_script();
  45. }
  46. */
  47. /** @todo this has to be moved to a more appropriate place (after the display_header of the code)*/
  48. if (!api_is_allowed_to_edit())
  49. {
  50. Display :: display_header();
  51. Display :: display_error_message(get_lang('NotAllowedHere'));
  52. Display :: display_footer();
  53. exit;
  54. }
  55. // Database table definitions
  56. /** @todo use database constants for the survey tables */
  57. $table_group = Database :: get_course_table(TABLE_SURVEY_GROUP);
  58. $table_user = Database :: get_main_table(TABLE_MAIN_USER);
  59. $table_languages = Database::get_main_table(TABLE_MAIN_LANGUAGE);
  60. $tool_name1 = get_lang('CreateNewGroup');
  61. $tool_name = get_lang('ModifyGroupInformation');
  62. $interbreadcrumb[] = array ("url" => "survey_list.php?", "name" => get_lang('Survey'));
  63. $groupid = $_GET['groupid'];
  64. $surveyid = $_GET['surveyid'];
  65. if($_POST['action'] == 'new_group')
  66. {
  67. if(isset($_POST['back']))
  68. {
  69. $surveyid = $_REQUEST['surveyid'];
  70. header("location:create_new_group.php?surveyid=$surveyid");
  71. exit;
  72. }
  73. }
  74. if ($_POST['action'] == 'new_group')
  75. {
  76. $surveyid = $_POST['surveyid'];
  77. $groupid = $_POST['groupid'];
  78. $groupname = $_POST['groupname'];
  79. $groupname=trim($groupname);
  80. if(empty ($groupname))
  81. {
  82. $error_message = get_lang('PleaseEnterGroupName');
  83. }
  84. $introduction = $_REQUEST['content'];
  85. if(isset($_POST['next']))
  86. {
  87. $groupname=trim($groupname);
  88. if(empty ($groupname))
  89. {
  90. $error_message = get_lang('PleaseEnterGroupName');
  91. }
  92. else
  93. {
  94. SurveyManager::update_group($groupid,$surveyid,$groupname,$introduction,$curr_dbname);
  95. header("location:select_question_group.php?surveyid=$surveyid");
  96. exit;
  97. }
  98. }
  99. if(isset($_POST['saveandexit']))
  100. {
  101. $groupname=trim($groupname);
  102. if(empty ($groupname))
  103. {
  104. $error_message = get_lang('PleaseEnterGroupName');
  105. }
  106. else
  107. {
  108. SurveyManager::update_group($groupid,$surveyid,$groupname,$introduction,$curr_dbname);
  109. header("location:survey_list.php");
  110. exit;
  111. }
  112. }
  113. }
  114. Display::display_header($tool_name1);
  115. api_display_tool_title($tool_name);
  116. if( isset($error_message) )
  117. {
  118. Display::display_error_message($error_message);
  119. }
  120. ?>
  121. <?php
  122. $sql = "select * from $table_group where group_id='$groupid'";
  123. $res = api_sql_query($sql);
  124. $obj = mysql_fetch_object($res);
  125. $groupname= $obj->groupname;
  126. $introduction = $obj->introduction;
  127. ?>
  128. <form name="new_calendar_item" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
  129. <input type="hidden" name="action" value="new_group">
  130. <input type="hidden" name="surveyid" value="<?php echo $surveyid; ?>">
  131. <input type="hidden" name="groupid" value="<?php echo $groupid; ?>">
  132. <table>
  133. <tr>
  134. <td><?php echo get_lang('GroupName'); ?></td>
  135. <td><input type="text" name="groupname" size="40" value="<?php echo $groupname ?>"></td>
  136. </tr>
  137. <tr><td valign="top"><?php echo get_lang('GroupIntroduction'); ?>&nbsp;</td>
  138. <td>
  139. <?php
  140. require_once(api_get_path(LIBRARY_PATH) . "/fckeditor/fckeditor.php");
  141. $oFCKeditor = new FCKeditor('content') ;
  142. $oFCKeditor->BasePath = api_get_path(WEB_PATH) . 'main/inc/lib/fckeditor/' ;
  143. $oFCKeditor->Height = '300';
  144. $oFCKeditor->Width = '600';
  145. $oFCKeditor->Value = $introduction;
  146. $oFCKeditor->Config['CustomConfigurationsPath'] = api_get_path(REL_PATH)."main/inc/lib/fckeditor/myconfig.js";
  147. $oFCKeditor->ToolbarSet = "Survey";
  148. $sql="SELECT isocode FROM ".$table_languages." WHERE english_name='".$_SESSION["_course"]["language"]."'";
  149. $result_sql=api_sql_query($sql);
  150. $isocode_language=mysql_result($result_sql,0,0);
  151. $oFCKeditor->Config['DefaultLanguage'] = $isocode_language;
  152. $return = $oFCKeditor->CreateHtml();
  153. echo $return;
  154. ?>
  155. <br>
  156. </td>
  157. </tr>
  158. </table>
  159. <tr>
  160. <td>&nbsp;</td>
  161. <td><input type="submit" name="back" value="<?php echo get_lang('Back'); ?>"></td>
  162. <td><input type="submit" name="saveandexit" value="<?php echo get_lang('SaveAndExit'); ?>"></td>
  163. <td><input type="submit" name="next" value="<?php echo get_lang('Next'); ?>"></td>
  164. </tr>
  165. </form>
  166. <?php
  167. Display :: display_footer();
  168. ?>