Fixing CourseManager constants

skala
Julio Montoya 13 years ago
parent 68b2263773
commit 1075ff760d
  1. 5
      index.php
  2. 4
      main/admin/course_add.php
  3. 6
      main/create_course/add_course.php
  4. 2
      main/inc/lib/add_course.lib.inc.php
  5. 56
      main/inc/lib/course.lib.php
  6. 6
      main/inc/lib/template.lib.php

@ -155,14 +155,11 @@ if (!isset($_REQUEST['include'])) {
$hot_courses = $controller->return_hot_courses();
$announcements_block = $controller->return_announcements();
}
$controller->tpl->assign('hot_courses', $hot_courses);
$controller->tpl->assign('announcements_block', $announcements_block);
$controller->tpl->assign('home_page_block', $controller->return_home_page());
$controller->tpl->assign('notice_block', $controller->return_notice());
$controller->tpl->assign('main_navigation_block', $controller->return_navigation_links());
$controller->tpl->assign('help_block', $controller->return_help());

@ -55,11 +55,11 @@ $form->applyFilter('title', 'html_filter');
$form->applyFilter('title', 'trim');
// Code
$form->add_textfield('visual_code', array(get_lang('CourseCode'), get_lang('OnlyLettersAndNumbers')) , false, array('class' => 'span3', 'maxlength' => MAX_COURSE_LENGTH_CODE));
$form->add_textfield('visual_code', array(get_lang('CourseCode'), get_lang('OnlyLettersAndNumbers')) , false, array('class' => 'span3', 'maxlength' => CourseManager::MAX_COURSE_LENGTH_CODE));
$form->applyFilter('visual_code', 'api_strtoupper');
$form->applyFilter('visual_code', 'html_filter');
$form->addRule('visual_code', get_lang('Max'), 'maxlength', MAX_COURSE_LENGTH_CODE);
$form->addRule('visual_code', get_lang('Max'), 'maxlength', CourseManager::MAX_COURSE_LENGTH_CODE);
//$form->addElement('select', 'tutor_id', get_lang('CourseTitular'), $teachers, array('style' => 'width:350px', 'class'=>'chzn-select', 'id'=>'tutor_id'));
//$form->applyFilter('tutor_id', 'html_filter');

@ -100,9 +100,9 @@ CourseManager::select_and_sort_categories($categories_select);
// Course code
$form->add_textfield('wanted_code', array(get_lang('Code'), get_lang('OnlyLettersAndNumbers')), '', array('class' => 'span3', 'maxlength' => MAX_COURSE_LENGTH_CODE));
$form->add_textfield('wanted_code', array(get_lang('Code'), get_lang('OnlyLettersAndNumbers')), '', array('class' => 'span3', 'maxlength' => CourseManager::MAX_COURSE_LENGTH_CODE));
$form->applyFilter('wanted_code', 'html_filter');
$form->addRule('wanted_code', get_lang('Max'), 'maxlength', MAX_COURSE_LENGTH_CODE);
$form->addRule('wanted_code', get_lang('Max'), 'maxlength', CourseManager::MAX_COURSE_LENGTH_CODE);
/*if ($course_validation_feature) {
$form->addRule('wanted_code', get_lang('ThisFieldIsRequired'), 'required');
@ -202,7 +202,7 @@ if ($form->validate()) {
}
if ($wanted_code == '') {
$wanted_code = generate_course_code(api_substr($title, 0, MAX_COURSE_LENGTH_CODE));
$wanted_code = generate_course_code(api_substr($title, 0, CourseManager::MAX_COURSE_LENGTH_CODE));
}
// Check whether the requested course code has already been occupied.

@ -21,7 +21,7 @@ function generate_course_code($course_title, $encoding = null) {
if (empty($encoding)) {
$encoding = api_get_system_encoding();
}
return substr(preg_replace('/[^A-Z0-9]/', '', strtoupper(api_transliterate($course_title, 'X', $encoding))), 0, MAX_COURSE_LENGTH_CODE);
return substr(preg_replace('/[^A-Z0-9]/', '', strtoupper(api_transliterate($course_title, 'X', $encoding))), 0, CourseManager::MAX_COURSE_LENGTH_CODE);
}
/**

@ -64,50 +64,20 @@
/* INIT SECTION */
/**
* Configuration files
*/
require_once api_get_path(CONFIGURATION_PATH).'add_course.conf.php';
require_once api_get_path(LIBRARY_PATH).'add_course.lib.inc.php';
define('MAX_COURSE_LENGTH_CODE', 40);
/**
* Constants definition
*/
//LOGIC: course visibility and registration settings
/*
COURSE VISIBILITY
MAPPING OLD SETTINGS TO NEW SETTINGS
-----------------------
NOT_VISIBLE_NO_SUBSCRIPTION_ALLOWED
--> COURSE_VISIBILITY_REGISTERED, SUBSCRIBE_NOT_ALLOWED
NOT_VISIBLE_SUBSCRIPTION_ALLOWED
--> COURSE_VISIBILITY_REGISTERED, SUBSCRIBE_ALLOWED
VISIBLE_SUBSCRIPTION_ALLOWED
--> COURSE_VISIBILITY_OPEN_PLATFORM, SUBSCRIBE_ALLOWED
VISIBLE_NO_SUBSCRIPTION_ALLOWED
--> COURSE_VISIBILITY_OPEN_PLATFORM, SUBSCRIBE_NOT_ALLOWED
*/
//OLD SETTINGS
define('NOT_VISIBLE_NO_SUBSCRIPTION_ALLOWED', 0);
define('NOT_VISIBLE_SUBSCRIPTION_ALLOWED', 1);
define('VISIBLE_SUBSCRIPTION_ALLOWED', 2);
define('VISIBLE_NO_SUBSCRIPTION_ALLOWED', 3);
//This constant is used to show separate user names in the course list (userportal), footer, etc
define('USER_SEPARATOR', ' |');
/**
* CourseManager Class
* @package chamilo.library
*/
class CourseManager {
CONST MAX_COURSE_LENGTH_CODE = 40;
//This constant is used to show separate user names in the course list (userportal), footer, etc
CONST USER_SEPARATOR = ' |';
var $columns = array();
/**
@ -135,7 +105,7 @@ class CourseManager {
if (empty($params['wanted_code'])) {
$params['wanted_code'] = $params['title'];
// Check whether the requested course code has already been occupied.
$params['wanted_code'] = generate_course_code(api_substr($params['title'], 0, MAX_COURSE_LENGTH_CODE));
$params['wanted_code'] = generate_course_code(api_substr($params['title'], 0, self::MAX_COURSE_LENGTH_CODE));
}
// Create the course keys
@ -1372,7 +1342,7 @@ class CourseManager {
return $teachers;
}
public static function get_teacher_list_from_course_code_to_string($course_code, $separator = USER_SEPARATOR, $add_link_to_profile = false) {
public static function get_teacher_list_from_course_code_to_string($course_code, $separator = self::USER_SEPARATOR, $add_link_to_profile = false) {
$teacher_list = self::get_teacher_list_from_course_code($course_code);
$teacher_string = '';
$list = array();
@ -1431,7 +1401,7 @@ class CourseManager {
}
}
function get_coachs_from_course_to_string($session_id = 0, $course_code = null, $separator = USER_SEPARATOR, $add_link_to_profile = false) {
function get_coachs_from_course_to_string($session_id = 0, $course_code = null, $separator = self::USER_SEPARATOR, $add_link_to_profile = false) {
$coachs_course = self::get_coachs_from_course($session_id, $course_code);
$course_coachs = array();
@ -1461,7 +1431,7 @@ class CourseManager {
$coach_list[] = $coach['complete_name'];
}
if (!empty($coach_list)) {
$tutor_data = implode(USER_SEPARATOR, $coach_list);
$tutor_data = implode(self::USER_SEPARATOR, $coach_list);
}
}
return $tutor_data;
@ -2918,7 +2888,7 @@ class CourseManager {
$course_title .= $course_info['visual_code'];
}
if (api_get_setting('display_teacher_in_courselist') == 'true') {
$params['teachers'] = CourseManager::get_teacher_list_from_course_code_to_string($course['code'], USER_SEPARATOR, true);
$params['teachers'] = CourseManager::get_teacher_list_from_course_code_to_string($course['code'], self::USER_SEPARATOR, true);
}
$course_title .= ' ';
$course_title .= Display::return_icon('klipper.png', get_lang('CourseAutoRegister'));
@ -3063,7 +3033,7 @@ class CourseManager {
$course_title .= $course_info['visual_code'];
}
if (api_get_setting('display_teacher_in_courselist') == 'true') {
$teachers = CourseManager::get_teacher_list_from_course_code_to_string($course['code'], USER_SEPARATOR, true);
$teachers = CourseManager::get_teacher_list_from_course_code_to_string($course['code'], self::USER_SEPARATOR, true);
}
$params['link'] = $course_title_url;
@ -3234,8 +3204,8 @@ class CourseManager {
if (api_get_setting('display_teacher_in_courselist') == 'true') {
if (api_get_setting('use_session_mode') == 'true' && !$nosession) {
$teacher_list = CourseManager::get_teacher_list_from_course_code_to_string($course_info['code'], USER_SEPARATOR, true);
$course_coachs = CourseManager::get_coachs_from_course_to_string($course_info['id_session'], $course['code'], USER_SEPARATOR, true);
$teacher_list = CourseManager::get_teacher_list_from_course_code_to_string($course_info['code'], self::USER_SEPARATOR, true);
$course_coachs = CourseManager::get_coachs_from_course_to_string($course_info['id_session'], $course['code'], self::USER_SEPARATOR, true);
if ($course_info['status'] == COURSEMANAGER || ($course_info['status'] == STUDENT && empty($course_info['id_session'])) || empty($course_info['status'])) {
$params['teachers'] = $teacher_list;

@ -596,10 +596,10 @@ class Template {
}
if (count($coachs_email) > 1) {
$tutor_data .= get_lang('Coachs').' : ';
$tutor_data .= array_to_string($email_link, USER_SEPARATOR);
$tutor_data .= array_to_string($email_link, CourseManager::USER_SEPARATOR);
} elseif (count($coachs_email) == 1) {
$tutor_data .= get_lang('Coach').' : ';
$tutor_data .= array_to_string($email_link, USER_SEPARATOR);
$tutor_data .= array_to_string($email_link, CourseManager::USER_SEPARATOR);
} elseif (count($coachs_email) == 0) {
$tutor_data .= '';
}
@ -625,7 +625,7 @@ class Template {
if (count($mail) > 1) {
$label = get_lang('Teachers');
}
$teacher_data .= $label.' : '.array_to_string($teachers_parsed, USER_SEPARATOR);
$teacher_data .= $label.' : '.array_to_string($teachers_parsed, CourseManager::USER_SEPARATOR);
}
$this->assign('teachers', $teacher_data);
}

Loading…
Cancel
Save