Source for file infocours.php
Documentation is available at infocours.php
// $Id: infocours.php 14956 2008-04-20 14:21:32Z yannoo $
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004 Dokeos S.A.
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) Hugues Peeters
Copyright (c) Roan Embrechts (Vrije Universiteit Brussel)
Copyright (c) Olivier Brouckaert
Copyright (c) Bart Mollet, Hogeschool Gent
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
==============================================================================
==============================================================================
* Code to display the course settings form (for the course admin)
* and activate the changes.
* See ./inc/conf/course_info.conf.php for settings
* @todo: Move $canBeEmpty from course_info.conf.php to config-settings
* @todo: Take those config settings into account in this script
* @author Patrick Cool <patrick.cool@UGent.be>
* @author Roan Embrechts, refactoring
* and improved course visibility|subscribe|unsubscribe options
* @package dokeos.course_info
==============================================================================
==============================================================================
==============================================================================
// name of the language file that needs to be included
$language_file = array ('create_course', 'course_info');
include ('../inc/global.inc.php');
-----------------------------------------------------------
-----------------------------------------------------------
require_once (api_get_path(LIBRARY_PATH). 'course.lib.php');
require_once (api_get_path(INCLUDE_PATH). "conf/course_info.conf.php");
require_once (api_get_path(INCLUDE_PATH). "lib/debug.lib.inc.php");
require_once (api_get_path(LIBRARY_PATH). 'formvalidator/FormValidator.class.php');
-----------------------------------------------------------
-----------------------------------------------------------
define("MODULE_HELP_NAME", "Settings");
define("COURSE_CHANGE_PROPERTIES", "COURSE_CHANGE_PROPERTIES");
$currentCourseID = $_course['sysCode'];
$currentCourseRepository = $_course["path"];
$is_allowedToEdit = $is_courseAdmin || $is_platformAdmin;
==============================================================================
==============================================================================
return $GLOBALS["course_info_is_editable"];
$course_code = $_course["sysCode"];
==============================================================================
==============================================================================
// Get all course categories
$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";
$s_select_course_tutor_name= "SELECT tutor_name FROM $tbl_course WHERE code='$course_code'";
$q_tutor= api_sql_query($s_select_course_tutor_name, __FILE__ , __LINE__ );
$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. "'";
$q_result_titulars= api_sql_query($s_sql_course_titular, __FILE__ , __LINE__ );
$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";
$a_profs[0] = '-- '. get_lang('NoManager'). ' --';
$s_username= $a_titulars["username"];
$s_lastname= $a_titulars["lastname"];
$s_firstname= $a_titulars["firstname"];
if($s_firstname. ' '. $s_lastname== $s_tutor){
$s_selected_tutor= $s_firstname. ' '. $s_lastname;
$s_disabled_select_titular= "";
$s_disabled_select_titular= "disabled=disabled";
$a_profs[$s_firstname. ' '. $s_lastname]= "$s_lastname $s_firstname ($s_username)";
$categories[$cat['code']] = '('. $cat['code']. ') '. $cat['name'];
$linebreak = '<div class="row"><div class="label"></div><div class="formw" style="border-bottom:1px dashed"></div></div>';
$visual_code= $form->addElement('text','visual_code', get_lang('Code'));
$form->applyFilter('visual_code', 'strtoupper');
//$form->add_textfield('tutor_name', get_lang('Professors'), true, array ('size' => '60'));
$prof = &$form->addElement('select', 'tutor_name', get_lang('Professors'), $a_profs);
$prof -> setSelected($s_selected_tutor);
$form->add_textfield('title', get_lang('Title'), true, array ('size' => '60'));
$form->addElement('select', 'category_code', get_lang('Fac'), $categories);
$form->add_textfield('department_name', get_lang('Department'), false, array ('size' => '60'));
$form->add_textfield('department_url', get_lang('DepartmentUrl'), false, array ('size' => '60'));
$form->addRule('tutor_name', get_lang('ThisFieldIsRequired'), 'required');
$form->addElement('select_language', 'course_language', get_lang('Ln'));
$form->addElement('static', null, null, get_lang("TipLang"));
$form -> addElement('html',$linebreak);
$form -> addElement('html',$linebreak);
$form->addElement('radio', 'subscribe', get_lang('Subscription'), get_lang('Allowed'), 1);
$form->addElement('radio', 'subscribe', null, get_lang('Denied'), 0);
$form -> addElement('html',$linebreak);
$form->addElement('radio', 'unsubscribe', get_lang('Unsubscription'), get_lang('AllowedToUnsubscribe'), 1);
$form->addElement('radio', 'unsubscribe', null, get_lang('NotAllowedToUnsubscribe'), 0);
$form -> addElement('html',$linebreak);
$form->addElement('radio', 'email_alert_manager_on_new_doc', get_lang('WorkEmailAlert'), get_lang('WorkEmailAlertActivate'), 1);
$form->addElement('radio', 'email_alert_manager_on_new_doc', null, get_lang('WorkEmailAlertDeactivate'), 0);
$form -> addElement('html',$linebreak);
$form->addElement('radio', 'email_alert_on_new_doc_dropbox', get_lang('DropboxEmailAlert'), get_lang('DropboxEmailAlertActivate'), 1);
$form->addElement('radio', 'email_alert_on_new_doc_dropbox', null, get_lang('DropboxEmailAlertDeactivate'), 0);
$form -> addElement('html',$linebreak);
$form->addElement('radio', 'email_alert_manager_on_new_quiz', get_lang('QuizEmailAlert'), get_lang('QuizEmailAlertActivate'), 1);
$form->addElement('radio', 'email_alert_manager_on_new_quiz', null, get_lang('QuizEmailAlertDeactivate'), 0);
$form -> addElement('html',$linebreak);
$form->addElement('radio', 'allow_user_edit_agenda', get_lang('AllowUserEditAgenda'), get_lang('AllowUserEditAgendaActivate'), 1);
$form->addElement('radio', 'allow_user_edit_agenda', null, get_lang('AllowUserEditAgendaDeactivate'), 0);
$form -> addElement('html',$linebreak);
$form->addElement('radio', 'allow_user_edit_announcement', get_lang('AllowUserEditAnnouncement'), get_lang('AllowUserEditAnnouncementActivate'), 1);
$form->addElement('radio', 'allow_user_edit_announcement', null, get_lang('AllowUserEditAnnouncementDeactivate'), 0);
$form -> addElement('html',$linebreak);
$form->addElement('radio', 'allow_user_image_forum', get_lang('AllowUserImageForum'), get_lang('AllowUserImageForumActivate'), 1);
$form->addElement('radio', 'allow_user_image_forum', null, get_lang('AllowUserImageForumDeactivate'), 0);
$form -> addElement('html',$linebreak);
$form->addElement('radio', 'allow_learning_path_theme', get_lang('AllowLearningPathTheme'), get_lang('AllowLearningPathThemeAllow'), 1);
$form->addElement('radio', 'allow_learning_path_theme', null, get_lang('AllowLearningPathThemeDisallow'), 0);
$form -> addElement('html',$linebreak);
$form->addElement('select_theme', 'course_theme', get_lang('Theme'));
$form->applyFilter('course_theme', 'trim');
$form -> addElement('html',$linebreak);
$form->addElement('static', null, null, get_lang("ConfTip"));
$form->add_textfield('course_registration_password', get_lang('CourseRegistrationPassword'), false, array ('size' => '60'));
$form->addElement('submit', null, get_lang('Ok'));
// is it allowed to edit the course settings?
$disabled_output = "disabled";
// get all the course information
// Set the default values of the form
$values['title'] = $_course['name'];
$values['visual_code'] = $_course['official_code'];
$values['category_code'] = $_course['categoryCode'];
//$values['tutor_name'] = $_course['titular'];
$values['course_language'] = $_course['language'];
$values['department_name'] = $_course['extLink']['name'];
$values['department_url'] = $_course['extLink']['url'];
$values['visibility'] = $_course['visibility'];
$values['subscribe'] = $course_access_settings['subscribe'];
$values['unsubscribe'] = $course_access_settings['unsubscribe'];
$values['course_registration_password'] = $all_course_information['registration_code'];
// get send_mail_setting (work)from table
// get send_mail_setting (dropbox) from table
// get send_mail_setting (work)from table
// get allow_user_edit_agenda from table
// get allow_user_edit_announcement from table
// get allow_user_image_forum from table
// get course_theme from table
// get allow_learning_path_theme from table
$form->setDefaults($values);
$update_values = $form->exportValues();
foreach ($update_values as $index => $value)
$sql = "UPDATE $table_course SET title = '". $update_values['title']. "',
visual_code = '". $update_values['visual_code']. "',
course_language = '". $update_values['course_language']. "',
category_code = '". $update_values['category_code']. "',
department_name = '". $update_values['department_name']. "',
department_url = '". $update_values['department_url']. "',
visibility = '". $update_values['visibility']. "',
subscribe = '". $update_values['subscribe']. "',
unsubscribe = '". $update_values['unsubscribe']. "',
tutor_name = '". $update_values['tutor_name']. "',
registration_code = '". $update_values['course_registration_password']. "'
WHERE code = '". $course_code. "'";
//update course_settings table - this assumes those records exist, otherwise triggers an error
if($update_values['email_alert_manager_on_new_doc'] != $values['email_alert_manager_on_new_doc']){
$sql = "UPDATE $table_course_setting SET value = ".(int) $update_values['email_alert_manager_on_new_doc']. " WHERE variable = 'email_alert_manager_on_new_doc' ";
if($update_values['email_alert_on_new_doc_dropbox'] != $values['email_alert_on_new_doc_dropbox']){
$sql = "UPDATE $table_course_setting SET value = ".(int) $update_values['email_alert_on_new_doc_dropbox']. " WHERE variable = 'email_alert_on_new_doc_dropbox' ";
if($update_values['email_alert_manager_on_new_quiz'] != $values['email_alert_manager_on_new_quiz']){
$sql = "UPDATE $table_course_setting SET value = ".(int) $update_values['email_alert_manager_on_new_quiz']. " WHERE variable = 'email_alert_manager_on_new_quiz' ";
if($update_values['allow_user_edit_agenda'] != $values['allow_user_edit_agenda']){
$sql = "UPDATE $table_course_setting SET value = ".(int) $update_values['allow_user_edit_agenda']. " WHERE variable = 'allow_user_edit_agenda' ";
if($update_values['allow_user_edit_announcement'] != $values['allow_user_edit_announcement']){
$sql = "UPDATE $table_course_setting SET value = ".(int) $update_values['allow_user_edit_announcement']. " WHERE variable = 'allow_user_edit_announcement' ";
if($update_values['allow_user_image_forum'] != $values['allow_user_image_forum']){
$sql = "UPDATE $table_course_setting SET value = ".(int) $update_values['allow_user_image_forum']. " WHERE variable = 'allow_user_image_forum' ";
if($update_values['course_theme'] != $values['course_theme']){
$sql = "UPDATE $table_course_setting SET value = '". $update_values['course_theme']. "' WHERE variable = 'course_theme' ";
if($update_values['allow_learningpath_theme'] != $values['allow_learning_path_theme']){
$sql = "UPDATE $table_course_setting SET value = ".(int) $update_values['allow_learning_path_theme']. " WHERE variable = 'allow_learning_path_theme' ";
include ('../inc/local.inc.php');
header('Location: infocours.php?action=show_message&cidReq='. $course_code);
-----------------------------------------------------------
-----------------------------------------------------------
//api_display_tool_title($nameTools);
if (isset ($_GET['action']) && $_GET['action'] == 'show_message')
if ($showDiskQuota && $currentCourseDiskQuota != "")
<td> <?php echo get_lang("DiskQuota"); ?> :</td>
<td> <?php echo $currentCourseDiskQuota; ?> <?php echo $byteUnits[0] ?></td>
if ($showLastEdit && $currentCourseLastEdit != "" && $currentCourseLastEdit != "0000-00-00 00:00:00")
<td> <?php echo get_lang('LastEdit'); ?> :</td>
if ($showLastVisit && $currentCourseLastVisit != "" && $currentCourseLastVisit != "0000-00-00 00:00:00")
<td> <?php echo get_lang('LastVisit'); ?> :</td>
if ($showCreationDate && $currentCourseCreationDate != "" && $currentCourseCreationDate != "0000-00-00 00:00:00")
<td> <?php echo get_lang('CreationDate'); ?> :</td>
if ($showExpirationDate && $currentCourseExpirationDate != "" && $currentCourseExpirationDate != "0000-00-00 00:00:00")
<td> <?php echo get_lang('ExpirationDate'); ?> :</td>
echo "<br />". get_lang('OrInTime'). " : ";
$nbJour = (strtotime($currentCourseExpirationDate) - time()) / (60 * 60 * 24);
$nbAnnees = round($nbJour / 365);
$nbJour = round($nbJour - $nbAnnees * 365);
if ($canReportExpirationDate)
echo " -> <a href=\"". $urlScriptToReportExpirationDate. "\">". get_lang('PostPone'). "</a>";
==============================================================================
==============================================================================
|