dokeos-course_info
[ class tree: dokeos-course_info ] [ index: dokeos-course_info ] [ all elements ]

Source for file infocours.php

Documentation is available at infocours.php

  1. <?php
  2. // $Id: infocours.php 14956 2008-04-20 14:21:32Z yannoo $
  3. /*
  4. ==============================================================================
  5.     Dokeos - elearning and course management software
  6.  
  7.     Copyright (c) 2004 Dokeos S.A.
  8.     Copyright (c) 2003 Ghent University (UGent)
  9.     Copyright (c) 2001 Universite catholique de Louvain (UCL)
  10.     Copyright (c) Hugues Peeters
  11.     Copyright (c) Roan Embrechts (Vrije Universiteit Brussel)
  12.     Copyright (c) Olivier Brouckaert
  13.     Copyright (c) Bart Mollet, Hogeschool Gent
  14.  
  15.     For a full list of contributors, see "credits.txt".
  16.     The full license can be read in "license.txt".
  17.  
  18.     This program is free software; you can redistribute it and/or
  19.     modify it under the terms of the GNU General Public License
  20.     as published by the Free Software Foundation; either version 2
  21.     of the License, or (at your option) any later version.
  22.  
  23.     See the GNU General Public License for more details.
  24.  
  25.     Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  26. ==============================================================================
  27. */
  28. /**
  29. ==============================================================================
  30. *    Code to display the course settings form (for the course admin)
  31. *    and activate the changes.
  32. *
  33. *    See ./inc/conf/course_info.conf.php for settings
  34. @todo: Move $canBeEmpty from course_info.conf.php to config-settings
  35. @todo: Take those config settings into account in this script
  36. @author Patrick Cool <patrick.cool@UGent.be>
  37. @author Roan Embrechts, refactoring
  38. *  and improved course visibility|subscribe|unsubscribe options
  39. @package dokeos.course_info
  40. ==============================================================================
  41. */
  42. /*
  43. ==============================================================================
  44.        INIT SECTION
  45. ==============================================================================
  46. */
  47. // name of the language file that needs to be included
  48. $language_file array ('create_course''course_info');
  49. include ('../inc/global.inc.php');
  50. $this_section SECTION_COURSES;
  51.  
  52. $nameTools get_lang("ModifInfo");
  53.  
  54. /*
  55. -----------------------------------------------------------
  56.     Libraries
  57. -----------------------------------------------------------
  58. */
  59. require_once (api_get_path(LIBRARY_PATH).'course.lib.php');
  60. require_once (api_get_path(INCLUDE_PATH)."conf/course_info.conf.php");
  61. require_once (api_get_path(INCLUDE_PATH)."lib/debug.lib.inc.php");
  62. require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  63. /*
  64. -----------------------------------------------------------
  65.     Constants and variables
  66. -----------------------------------------------------------
  67. */
  68. define("MODULE_HELP_NAME""Settings");
  69. define("COURSE_CHANGE_PROPERTIES""COURSE_CHANGE_PROPERTIES");
  70. $TABLECOURSE                 Database :: get_main_table(TABLE_MAIN_COURSE);
  71. $TABLEFACULTY                 Database :: get_main_table(TABLE_MAIN_CATEGORY);
  72. $TABLECOURSEHOME             Database :: get_course_table(TABLE_TOOL_LIST);
  73. $TABLELANGUAGES             Database :: get_main_table(TABLE_MAIN_LANGUAGE);
  74. $TABLEBBCONFIG                 Database :: get_course_table(TOOL_FORUM_CONFIG_TABLE);
  75. $currentCourseID             $_course['sysCode'];
  76. $currentCourseRepository     $_course["path"];
  77. $is_allowedToEdit             $is_courseAdmin || $is_platformAdmin;
  78. $course_setting_table         Database::get_course_table(TABLE_COURSE_SETTING);
  79. /*
  80. ==============================================================================
  81.         LOGIC FUNCTIONS
  82. ==============================================================================
  83. */
  84. {
  85.     return $GLOBALS["course_info_is_editable"];
  86. }
  87. $course_code $_course["sysCode"];
  88. $course_access_settings CourseManager :: get_access_settings($course_code);
  89.  
  90. /*
  91. ==============================================================================
  92.         MAIN CODE
  93. ==============================================================================
  94. */
  95.  
  96. if (!$is_allowedToEdit)
  97. {
  98.     api_not_allowed(true);
  99. }
  100.  
  101. $table_course_category Database :: get_main_table(TABLE_MAIN_CATEGORY);
  102. $tbl_course_user Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  103.  
  104. // Get all course categories
  105. $sql "SELECT code,name FROM ".$table_course_category." WHERE auth_course_child ='TRUE'  OR code = '".mysql_real_escape_string($_course['categoryCode'])."'  ORDER BY tree_pos";
  106. $res api_sql_query($sql__FILE____LINE__);
  107.  
  108. $s_select_course_tutor_name="SELECT tutor_name FROM $tbl_course WHERE code='$course_code'";
  109. $q_tutor=api_sql_query($s_select_course_tutor_name__FILE____LINE__);
  110. $s_tutor=mysql_result($q_tutor,0,"tutor_name");
  111.  
  112. $s_sql_course_titular="SELECT DISTINCT username, lastname, firstname FROM $tbl_user as user, $tbl_course_user as course_rel_user WHERE (course_rel_user.status='1') AND user.user_id=course_rel_user.user_id AND course_code='".$course_code."'";
  113. $q_result_titulars=api_sql_query($s_sql_course_titular__FILE____LINE__);
  114.  
  115. if(mysql_num_rows($q_result_titulars)==0){
  116.     $sql="SELECT username, lastname, firstname FROM $tbl_user as user, $tbl_admin as admin WHERE admin.user_id=user.user_id ORDER BY lastname ASC";
  117.     $q_result_titulars=api_sql_query($sql__FILE____LINE__);
  118. }
  119.  
  120. $a_profs[0'-- '.get_lang('NoManager').' --';
  121. while($a_titulars=mysql_fetch_array($q_result_titulars)){
  122.         $s_username=$a_titulars["username"];
  123.         $s_lastname=$a_titulars["lastname"];
  124.         $s_firstname=$a_titulars["firstname"];
  125.  
  126.         if($s_firstname.' '.$s_lastname==$s_tutor){
  127.             $s_selected_tutor=$s_firstname.' '.$s_lastname;
  128.         }
  129.         $s_disabled_select_titular="";
  130.         if(!$is_courseAdmin){
  131.             $s_disabled_select_titular="disabled=disabled";
  132.         }
  133.         $a_profs[$s_firstname.' '.$s_lastname]="$s_lastname $s_firstname ($s_username)";
  134. }
  135.  
  136. while ($cat mysql_fetch_array($res))
  137. {
  138.     $categories[$cat['code']] '('.$cat['code'].') '.$cat['name'];
  139.     ksort($categories);
  140. }
  141.  
  142.  
  143. $linebreak '<div class="row"><div class="label"></div><div class="formw" style="border-bottom:1px dashed"></div></div>';
  144.  
  145. // Build the form
  146. $form new FormValidator('update_course');
  147. $visual_code=$form->addElement('text','visual_code'get_lang('Code'));
  148.     $visual_code->freeze();
  149. $form->applyFilter('visual_code''strtoupper');
  150. //$form->add_textfield('tutor_name', get_lang('Professors'), true, array ('size' => '60'));
  151. $prof &$form->addElement('select''tutor_name'get_lang('Professors')$a_profs);
  152. $prof -> setSelected($s_selected_tutor);
  153. $form->add_textfield('title'get_lang('Title')truearray ('size' => '60'));
  154. $form->addElement('select''category_code'get_lang('Fac')$categories);
  155. $form->add_textfield('department_name'get_lang('Department')falsearray ('size' => '60'));
  156. $form->add_textfield('department_url'get_lang('DepartmentUrl')falsearray ('size' => '60'));
  157. $form->addRule('tutor_name'get_lang('ThisFieldIsRequired')'required');
  158. $form->addElement('select_language''course_language'get_lang('Ln'));
  159. $form->addElement('static'nullnullget_lang("TipLang"));
  160. $form -> addElement('html',$linebreak);
  161.  
  162. $form->addElement('radio''visibility'get_lang("CourseAccess")get_lang('OpenToTheWorld')COURSE_VISIBILITY_OPEN_WORLD);
  163. $form->addElement('radio''visibility'nullget_lang('OpenToThePlatform')COURSE_VISIBILITY_OPEN_PLATFORM);
  164. $form->addElement('radio''visibility'nullget_lang('Private')COURSE_VISIBILITY_REGISTERED);
  165. $form->addElement('radio''visibility'nullget_lang('CourseVisibilityClosed')COURSE_VISIBILITY_CLOSED);
  166. $form -> addElement('html',$linebreak);
  167.  
  168. $form->addElement('radio''subscribe'get_lang('Subscription')get_lang('Allowed')1);
  169. $form->addElement('radio''subscribe'nullget_lang('Denied')0);
  170. $form -> addElement('html',$linebreak);
  171.  
  172. $form->addElement('radio''unsubscribe'get_lang('Unsubscription')get_lang('AllowedToUnsubscribe')1);
  173. $form->addElement('radio''unsubscribe'nullget_lang('NotAllowedToUnsubscribe')0);
  174. $form -> addElement('html',$linebreak);
  175.  
  176. $form->addElement('radio''email_alert_manager_on_new_doc'get_lang('WorkEmailAlert')get_lang('WorkEmailAlertActivate')1);
  177. $form->addElement('radio''email_alert_manager_on_new_doc'nullget_lang('WorkEmailAlertDeactivate')0);
  178. $form -> addElement('html',$linebreak);
  179.  
  180. $form->addElement('radio''email_alert_on_new_doc_dropbox'get_lang('DropboxEmailAlert')get_lang('DropboxEmailAlertActivate')1);
  181. $form->addElement('radio''email_alert_on_new_doc_dropbox'nullget_lang('DropboxEmailAlertDeactivate')0);
  182. $form -> addElement('html',$linebreak);
  183.  
  184. $form->addElement('radio''email_alert_manager_on_new_quiz'get_lang('QuizEmailAlert')get_lang('QuizEmailAlertActivate')1);
  185. $form->addElement('radio''email_alert_manager_on_new_quiz'nullget_lang('QuizEmailAlertDeactivate')0);
  186. $form -> addElement('html',$linebreak);
  187.  
  188. $form->addElement('radio''allow_user_edit_agenda'get_lang('AllowUserEditAgenda')get_lang('AllowUserEditAgendaActivate')1);
  189. $form->addElement('radio''allow_user_edit_agenda'nullget_lang('AllowUserEditAgendaDeactivate')0);
  190. $form -> addElement('html',$linebreak);
  191.  
  192. $form->addElement('radio''allow_user_edit_announcement'get_lang('AllowUserEditAnnouncement')get_lang('AllowUserEditAnnouncementActivate')1);
  193. $form->addElement('radio''allow_user_edit_announcement'nullget_lang('AllowUserEditAnnouncementDeactivate')0);
  194. $form -> addElement('html',$linebreak);
  195.  
  196. $form->addElement('radio''allow_user_image_forum'get_lang('AllowUserImageForum')get_lang('AllowUserImageForumActivate')1);
  197. $form->addElement('radio''allow_user_image_forum'nullget_lang('AllowUserImageForumDeactivate')0);
  198. $form -> addElement('html',$linebreak);
  199.  
  200.  
  201.  
  202. // Course theme picker
  203. if (api_get_setting('allow_course_theme'== 'true')
  204. {    
  205.     //Allow Learning path 
  206.     $form->addElement('radio''allow_learning_path_theme'get_lang('AllowLearningPathTheme')get_lang('AllowLearningPathThemeAllow')1);
  207.     $form->addElement('radio''allow_learning_path_theme'nullget_lang('AllowLearningPathThemeDisallow')0);
  208.     $form -> addElement('html',$linebreak);
  209.     
  210.     
  211.     $form->addElement('select_theme''course_theme'get_lang('Theme'));
  212.     $form->applyFilter('course_theme''trim');
  213.     $form -> addElement('html',$linebreak);
  214. }
  215.  
  216.  
  217. $form->addElement('static'nullnullget_lang("ConfTip"));
  218. $form->add_textfield('course_registration_password'get_lang('CourseRegistrationPassword')falsearray ('size' => '60'));
  219.     {
  220.     $form->addElement('submit'nullget_lang('Ok'));
  221.     }
  222. else
  223. {
  224.     // is it allowed to edit the course settings?
  225.     if (!is_settings_editable())
  226.         $disabled_output "disabled";
  227.     $form->freeze();
  228.     }
  229.  
  230. // get all the course information
  231. $all_course_information =  CourseManager::get_course_information($_course['sysCode']);
  232.  
  233.  
  234. // Set the default values of the form
  235.  
  236. $values['title'$_course['name'];
  237. $values['visual_code'$_course['official_code'];
  238. $values['category_code'$_course['categoryCode'];
  239. //$values['tutor_name'] = $_course['titular'];
  240. $values['course_language'$_course['language'];
  241. $values['department_name'$_course['extLink']['name'];
  242. $values['department_url'$_course['extLink']['url'];
  243. $values['visibility'$_course['visibility'];
  244. $values['subscribe'$course_access_settings['subscribe'];
  245. $values['unsubscribe'$course_access_settings['unsubscribe'];
  246. $values['course_registration_password'=  $all_course_information['registration_code'];
  247. // get send_mail_setting (work)from table
  248. $values['email_alert_manager_on_new_doc'api_get_course_setting('email_alert_manager_on_new_doc');
  249. // get send_mail_setting (dropbox) from table
  250. $values['email_alert_on_new_doc_dropbox'api_get_course_setting('email_alert_on_new_doc_dropbox');
  251. // get send_mail_setting (work)from table
  252. $values['email_alert_manager_on_new_quiz'api_get_course_setting('email_alert_manager_on_new_quiz');
  253. // get allow_user_edit_agenda from table
  254. $values['allow_user_edit_agenda'api_get_course_setting('allow_user_edit_agenda');
  255. // get allow_user_edit_announcement from table
  256. $values['allow_user_edit_announcement'api_get_course_setting('allow_user_edit_announcement');
  257. // get allow_user_image_forum from table
  258. $values['allow_user_image_forum'api_get_course_setting('allow_user_image_forum');
  259. // get course_theme from table
  260. $values['course_theme'api_get_course_setting('course_theme');
  261. // get allow_learning_path_theme from table
  262. $values['allow_learning_path_theme'api_get_course_setting('allow_learning_path_theme');
  263.  
  264.  
  265. $form->setDefaults($values);
  266. // Validate form
  267. if ($form->validate(&& is_settings_editable())
  268.     {
  269.     $update_values $form->exportValues();
  270.     foreach ($update_values as $index => $value)
  271.         {
  272.         $update_values[$indexmysql_real_escape_string($value);
  273.         }
  274.     $table_course Database :: get_main_table(TABLE_MAIN_COURSE);
  275.     $sql "UPDATE $table_course SET title             = '".$update_values['title']."',
  276.                                          visual_code     = '".$update_values['visual_code']."',
  277.                                          course_language = '".$update_values['course_language']."',
  278.                                          category_code  = '".$update_values['category_code']."',
  279.                                          department_name  = '".$update_values['department_name']."',
  280.                                          department_url  = '".$update_values['department_url']."',
  281.                                          visibility  = '".$update_values['visibility']."',
  282.                                          subscribe  = '".$update_values['subscribe']."',
  283.                                          unsubscribe  = '".$update_values['unsubscribe']."',
  284.                                          tutor_name     = '".$update_values['tutor_name']."',
  285.                                          registration_code = '".$update_values['course_registration_password']."'
  286.                                     WHERE code = '".$course_code."'";
  287.     api_sql_query($sql__FILE____LINE__);
  288.  
  289.     //update course_settings table - this assumes those records exist, otherwise triggers an error
  290.     $table_course_setting Database::get_course_table(TABLE_COURSE_SETTING);
  291.     if($update_values['email_alert_manager_on_new_doc'!= $values['email_alert_manager_on_new_doc']){
  292.         $sql "UPDATE $table_course_setting SET value = ".(int)$update_values['email_alert_manager_on_new_doc']." WHERE variable = 'email_alert_manager_on_new_doc' ";
  293.         api_sql_query($sql,__FILE__,__LINE__);
  294.     }
  295.     if($update_values['email_alert_on_new_doc_dropbox'!= $values['email_alert_on_new_doc_dropbox']){
  296.         $sql "UPDATE $table_course_setting SET value = ".(int)$update_values['email_alert_on_new_doc_dropbox']." WHERE variable = 'email_alert_on_new_doc_dropbox' ";
  297.         api_sql_query($sql,__FILE__,__LINE__);
  298.     }
  299.     if($update_values['email_alert_manager_on_new_quiz'!= $values['email_alert_manager_on_new_quiz']){
  300.         $sql "UPDATE $table_course_setting SET value = ".(int)$update_values['email_alert_manager_on_new_quiz']." WHERE variable = 'email_alert_manager_on_new_quiz' ";
  301.         api_sql_query($sql,__FILE__,__LINE__);
  302.     }
  303.     if($update_values['allow_user_edit_agenda'!= $values['allow_user_edit_agenda']){
  304.         $sql "UPDATE $table_course_setting SET value = ".(int)$update_values['allow_user_edit_agenda']." WHERE variable = 'allow_user_edit_agenda' ";
  305.         api_sql_query($sql,__FILE__,__LINE__);
  306.     }
  307.     if($update_values['allow_user_edit_announcement'!= $values['allow_user_edit_announcement']){
  308.         $sql "UPDATE $table_course_setting SET value = ".(int)$update_values['allow_user_edit_announcement']." WHERE variable = 'allow_user_edit_announcement' ";
  309.         api_sql_query($sql,__FILE__,__LINE__);
  310.     }    
  311.     if($update_values['allow_user_image_forum'!= $values['allow_user_image_forum']){
  312.         $sql "UPDATE $table_course_setting SET value = ".(int)$update_values['allow_user_image_forum']." WHERE variable = 'allow_user_image_forum' ";
  313.         api_sql_query($sql,__FILE__,__LINE__);
  314.     }
  315.     if($update_values['course_theme'!= $values['course_theme']){
  316.         $sql "UPDATE $table_course_setting SET value = '".$update_values['course_theme']."' WHERE variable = 'course_theme' ";
  317.         api_sql_query($sql,__FILE__,__LINE__)
  318.     }
  319.     if($update_values['allow_learningpath_theme'!= $values['allow_learning_path_theme']){
  320.         $sql "UPDATE $table_course_setting SET value = ".(int)$update_values['allow_learning_path_theme']." WHERE variable = 'allow_learning_path_theme' ";
  321.         api_sql_query($sql,__FILE__,__LINE__);
  322.     }
  323.     
  324.  
  325.     $cidReset true;
  326.     $cidReq $course_code;
  327.     include ('../inc/local.inc.php');
  328.     header('Location: infocours.php?action=show_message&amp;cidReq='.$course_code);
  329.     exit;
  330. }
  331. /*
  332. -----------------------------------------------------------
  333.     Header
  334. -----------------------------------------------------------
  335. */
  336.  
  337.  
  338. //api_display_tool_title($nameTools);
  339. if (isset ($_GET['action']&& $_GET['action'== 'show_message')
  340.     {
  341.     Display :: display_normal_message(get_lang('ModifDone'));
  342.     }
  343. // Display the form
  344. $form->display();
  345.     if ($showDiskQuota && $currentCourseDiskQuota != "")
  346.     {
  347. ?>
  348. <table>
  349.     <tr>
  350.     <td><?php echo get_lang("DiskQuota")?>&nbsp;:</td>
  351.     <td><?php echo $currentCourseDiskQuota?> <?php echo $byteUnits[0?></td>
  352.     </tr>
  353.     <?php
  354.  
  355.     }
  356.     if ($showLastEdit && $currentCourseLastEdit != "" && $currentCourseLastEdit != "0000-00-00 00:00:00")
  357.     {
  358. ?>
  359.     <tr>
  360.     <td><?php echo get_lang('LastEdit')?>&nbsp;:</td>
  361.     <td><?php echo format_locale_date($dateTimeFormatLong,strtotime($currentCourseLastEdit))?></td>
  362.     </tr>
  363.     <?php
  364.  
  365.     }
  366.     if ($showLastVisit && $currentCourseLastVisit != "" && $currentCourseLastVisit != "0000-00-00 00:00:00")
  367.     {
  368. ?>
  369.     <tr>
  370.     <td><?php echo get_lang('LastVisit')?>&nbsp;:</td>
  371.     <td><?php echo format_locale_date($dateTimeFormatLong,strtotime($currentCourseLastVisit))?></td>
  372.     </tr>
  373.     <?php
  374.  
  375.     }
  376.     if ($showCreationDate && $currentCourseCreationDate != "" && $currentCourseCreationDate != "0000-00-00 00:00:00")
  377.     {
  378. ?>
  379.     <tr>
  380.     <td><?php echo get_lang('CreationDate')?>&nbsp;:</td>
  381.     <td><?php echo format_locale_date($dateTimeFormatLong,strtotime($currentCourseCreationDate))?></td>
  382.     </tr>
  383.     <?php
  384.  
  385.     }
  386.     if ($showExpirationDate && $currentCourseExpirationDate != "" && $currentCourseExpirationDate != "0000-00-00 00:00:00")
  387.     {
  388. ?>
  389.     <tr>
  390.     <td><?php echo get_lang('ExpirationDate')?>&nbsp;:</td>
  391.     <td>
  392.     <?php
  393.  
  394.         echo format_locale_date($dateTimeFormatLongstrtotime($currentCourseExpirationDate));
  395.         echo "<br />".get_lang('OrInTime')." : ";
  396.         $nbJour (strtotime($currentCourseExpirationDatetime()) (60 60 24);
  397.         $nbAnnees round($nbJour 365);
  398.         $nbJour round($nbJour $nbAnnees 365);
  399.         switch ($nbAnnees)
  400.         {
  401.             case "1" :
  402.                 echo $nbAnnees" an ";
  403.                 break;
  404.             case "0" :
  405.                 break;
  406.             default :
  407.                 echo $nbAnnees" ans ";
  408.         };
  409.         switch ($nbJour)
  410.         {
  411.             case "1" :
  412.                 echo $nbJour" jour ";
  413.                 break;
  414.             case "0" :
  415.                 break;
  416.             default :
  417.                 echo $nbJour" jours ";
  418.         }
  419.         if ($canReportExpirationDate)
  420.         {
  421.             echo " -&gt; <a href=\"".$urlScriptToReportExpirationDate."\">".get_lang('PostPone')."</a>";
  422.         }
  423. ?>
  424. </td>
  425. </tr>
  426. </table>
  427. <?php
  428.  
  429.     }
  430.  
  431. /*
  432. ==============================================================================
  433.         FOOTER
  434. ==============================================================================
  435. */
  436. ?>

Documentation generated on Thu, 12 Jun 2008 13:51:44 -0500 by phpDocumentor 1.4.1