@ -1,16 +1,9 @@
<?php // $Id: course_edit.php 20441 2009-05-10 07:39:15Z ivantcholakov $
/* For licensing terms, see /dokeos_license.txt */
/**
==============================================================================
* @package dokeos.admin
==============================================================================
* @package chamilo.admin
*/
/*
==============================================================================
INIT SECTION
==============================================================================
*/
/* Initialization section */
// name of the language file that needs to be included
$language_file = 'admin';
$cidReset = true;
@ -31,22 +24,8 @@ $interbreadcrumb[] = array ("url" => "course_list.php", "name" => get_lang('Admi
define('USER_FIELD_TYPE_CHECKBOX', 10);
/*
-----------------------------------------------------------
Libraries
-----------------------------------------------------------
*/
/*
==============================================================================
FUNCTIONS
==============================================================================
*/
/*
==============================================================================
MAIN CODE
==============================================================================
*/
/* Libraries */
/* MAIN CODE */
// Get all course categories
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
@ -54,8 +33,7 @@ $table_user = Database :: get_main_table(TABLE_MAIN_USER);
//Get the course infos
$sql = "SELECT * FROM $course_table WHERE code='".Database::escape_string($course_code)."'";
$result = Database::query($sql);
if (Database::num_rows($result) != 1)
{
if (Database::num_rows($result) != 1) {
header('Location: course_list.php');
exit ();
}
@ -67,8 +45,7 @@ $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname' : ' O
$sql = "SELECT user.user_id,lastname,firstname FROM $table_user as user,$table_course_user as course_user WHERE course_user.status='1' AND course_user.user_id=user.user_id AND course_user.course_code='".$course_code."'".$order_clause;
$res = Database::query($sql);
$course_teachers = array();
while($obj = Database::fetch_object($res))
{
while ($obj = Database::fetch_object($res)) {
$course_teachers[$obj->user_id] = api_get_person_name($obj->firstname, $obj->lastname);
}
@ -78,8 +55,7 @@ $res = Database::query($sql);
$teachers = array();
$platform_teachers[0] = '-- '.get_lang('NoManager').' --';
while($obj = Database::fetch_object($res))
{
while ($obj = Database::fetch_object($res)) {
if (!array_key_exists($obj->user_id,$course_teachers)) {
$teachers[$obj->user_id] = api_get_person_name($obj->firstname, $obj->lastname);
}
@ -196,8 +172,7 @@ $course_db_name = $course['db_name'];
$course['title'] = api_html_entity_decode($course['title'], ENT_QUOTES, $charset);
$form->setDefaults($course);
// Validate form
if( $form->validate())
{
if ($form->validate()) {
$course = $form->getSubmitValues();
$dbName = $_POST['dbName'];
$course_code = $course['code'];
@ -242,8 +217,7 @@ if( $form->validate())
$visibility = $course['visibility'];
$subscribe = $course['subscribe'];
$unsubscribe = $course['unsubscribe'];
if (!stristr($department_url, 'http://'))
{
if (!stristr($department_url, 'http://')) {
$department_url = 'http://'.$department_url;
}
$sql = "UPDATE $course_table SET course_language='".Database::escape_string($course_language)."',
@ -284,8 +258,7 @@ if( $form->validate())
if (Database::num_rows($result) == 1) {
$sql = 'UPDATE '.$course_user_table.' SET status = "1" WHERE course_code = "'.$course_code.'" AND user_id = "'.$key.'" ';
}
else{
} else {
$sql = "INSERT INTO ".$course_user_table . " SET
course_code = '".Database::escape_string($course_code). "',
user_id = '".$key . "',
@ -296,9 +269,7 @@ if( $form->validate())
user_course_cat='0'";
}
Database::query($sql);
}
}
$sql = "INSERT IGNORE INTO ".$course_user_table . " SET
@ -340,14 +311,14 @@ function moveItem(origin , destination){
function sortOptions(options) {
newOptions = new Array();
for (i = 0 ; i< options.length ; i + + )
for (i = 0 ; i< options.length ; i + + ) {
newOptions[i] = options[i];
}
newOptions = newOptions.sort(mysort);
options.length = 0;
for(i = 0 ; i < newOptions.length ; i + + )
for (i = 0 ; i < newOptions.length ; i + + ) {
options[i] = newOptions[i];
}
}
function mysort(a, b) {
@ -362,18 +333,14 @@ function mysort(a, b){
function valide() {
var options = document.getElementById('course_teachers').options;
for (i = 0 ; i< options.length ; i + + )
for (i = 0 ; i< options.length ; i + + ) {
options[i].selected = true;
}
document.update_course.submit();
}
< / script > ";
//api_display_tool_title($tool_name);
// Display the form
$form->display();
/*
==============================================================================
FOOTER
==============================================================================
*/
/* FOOTER */
Display :: display_footer();
?>