Minor - Replaced tabspaces with blankspaces

1.9.x
Imanol Losada 11 years ago
parent 6f0062ffd2
commit 49206761c2
  1. 52
      main/auth/inscription.php
  2. 1070
      main/dropbox/dropbox_functions.inc.php
  3. 6
      main/inc/ajax/user_manager.ajax.php
  4. 268
      main/inc/lib/add_course.lib.inc.php
  5. 328
      main/inc/lib/database.lib.php
  6. 34
      main/inc/lib/mail.lib.inc.php
  7. 460
      main/inc/lib/main_api.lib.php
  8. 3540
      main/mySpace/myspace.lib.php
  9. 18
      main/user/user_add.php
  10. 1482
      main/work/work.lib.php

@ -2,8 +2,8 @@
/* For licensing terms, see /license.txt */
/**
* This script displays a form for registering new users.
* @package chamilo.auth
* This script displays a form for registering new users.
* @package chamilo.auth
*/
use \ChamiloSession as Session;
@ -51,11 +51,11 @@ if (!empty($course_code_redirect)) {
if ($user_already_registered_show_terms == false) {
if (api_is_western_name_order()) {
// FIRST NAME and LAST NAME
// FIRST NAME and LAST NAME
$form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40));
$form->addElement('text', 'lastname', get_lang('LastName'), array('size' => 40));
} else {
// LAST NAME and FIRST NAME
// LAST NAME and FIRST NAME
$form->addElement('text', 'lastname', get_lang('LastName'), array('size' => 40));
$form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40));
}
@ -63,7 +63,7 @@ if ($user_already_registered_show_terms == false) {
$form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
// EMAIL
// EMAIL
$form->addElement('text', 'email', get_lang('Email'), array('size' => 40));
if (api_get_setting('registration', 'email') == 'true') {
$form->addRule('email', get_lang('ThisFieldIsRequired'), 'required');
@ -83,14 +83,14 @@ if ($user_already_registered_show_terms == false) {
$form->addElement('text', 'openid', get_lang('OpenIDURL'), array('size' => 40));
}
// Enabled by Ivan Tcholakov, 06-APR-2009. CONFVAL_ASK_FOR_OFFICIAL_CODE = false by default.
// OFFICIAL CODE
// OFFICIAL CODE
if (CONFVAL_ASK_FOR_OFFICIAL_CODE) {
$form->addElement('text', 'official_code', get_lang('OfficialCode'), array('size' => 40));
if (api_get_setting('registration', 'officialcode') == 'true')
$form->addRule('official_code', get_lang('ThisFieldIsRequired'), 'required');
}
// USERNAME
// USERNAME
if (api_get_setting('login_is_email') != 'true') {
$form->addElement('text', 'username', get_lang('UserName'), array('id' => 'username', 'size' => USERNAME_MAX_LENGTH));
$form->applyFilter('username','trim');
@ -100,7 +100,7 @@ if ($user_already_registered_show_terms == false) {
$form->addRule('username', get_lang('UserTaken'), 'username_available');
}
// PASSWORD
// PASSWORD
$form->addElement('password', 'pass1', get_lang('Pass'), array('id' => 'pass1', 'size' => 20, 'autocomplete' => 'off'));
if (isset($_configuration['allow_strength_pass_checker']) && $_configuration['allow_strength_pass_checker']) {
@ -115,7 +115,7 @@ if ($user_already_registered_show_terms == false) {
if (CHECK_PASS_EASY_TO_FIND)
$form->addRule('password1', get_lang('PassTooEasy').': '.api_generate_password(), 'callback', 'api_check_password');
// PHONE
// PHONE
$form->addElement('text', 'phone', get_lang('Phone'), array('size' => 20));
if (api_get_setting('registration', 'phone') == 'true')
$form->addRule('phone', get_lang('ThisFieldIsRequired'), 'required');
@ -127,11 +127,11 @@ if ($user_already_registered_show_terms == false) {
$form->addRule('picture', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
}*/
// LANGUAGE
// LANGUAGE
if (api_get_setting('registration', 'language') == 'true') {
$form->addElement('select_language', 'language', get_lang('Language'));
}
// STUDENT/TEACHER
// STUDENT/TEACHER
if (api_get_setting('allow_registration_as_teacher') != 'false') {
$form->addElement('radio', 'status', get_lang('Profile'), get_lang('RegStudent'), STUDENT);
$form->addElement('radio', 'status', null, get_lang('RegAdmin'), COURSEMANAGER);
@ -165,7 +165,7 @@ if ($user_already_registered_show_terms == false) {
$form->addRule('captcha', get_lang('TheTextYouEnteredDoesNotMatchThePicture'), 'CAPTCHA', $captcha_question);
}
// EXTENDED FIELDS
// EXTENDED FIELDS
if (api_get_setting('extended_profile') == 'true' && api_get_setting('extendedprofile_registration', 'mycomptetences') == 'true') {
$form->add_html_editor('competences', get_lang('MyCompetences'), false, false, array('ToolbarSet' => 'register', 'Width' => '100%', 'Height' => '130'));
}
@ -485,26 +485,26 @@ if ($form->validate()) {
Database::query($sql);
// 2. Send mail to all platform admin
$emailsubject = get_lang('ApprovalForNewAccount',null,$values['language']).': '.$values['username'];
$emailbody = get_lang('ApprovalForNewAccount',null,$values['language'])."\n";
$emailbody .= get_lang('UserName',null,$values['language']).': '.$values['username']."\n";
$emailsubject = get_lang('ApprovalForNewAccount',null,$values['language']).': '.$values['username'];
$emailbody = get_lang('ApprovalForNewAccount',null,$values['language'])."\n";
$emailbody .= get_lang('UserName',null,$values['language']).': '.$values['username']."\n";
if (api_is_western_name_order()) {
$emailbody .= get_lang('FirstName',null,$values['language']).': '.$values['firstname']."\n";
$emailbody .= get_lang('LastName',null,$values['language']).': '.$values['lastname']."\n";
$emailbody .= get_lang('FirstName',null,$values['language']).': '.$values['firstname']."\n";
$emailbody .= get_lang('LastName',null,$values['language']).': '.$values['lastname']."\n";
} else {
$emailbody .= get_lang('LastName',null,$values['language']).': '.$values['lastname']."\n";
$emailbody .= get_lang('FirstName',null,$values['language']).': '.$values['firstname']."\n";
$emailbody .= get_lang('LastName',null,$values['language']).': '.$values['lastname']."\n";
$emailbody .= get_lang('FirstName',null,$values['language']).': '.$values['firstname']."\n";
}
$emailbody .= get_lang('Email',null,$values['language']).': '.$values['email']."\n";
$emailbody .= get_lang('Status',null,$values['language']).': '.$values['status']."\n\n";
$emailbody .= get_lang('Email',null,$values['language']).': '.$values['email']."\n";
$emailbody .= get_lang('Status',null,$values['language']).': '.$values['status']."\n\n";
$url_edit = Display::url(
api_get_path(WEB_CODE_PATH).'admin/user_edit.php?user_id='.$user_id,
api_get_path(WEB_CODE_PATH).'admin/user_edit.php?user_id='.$user_id
);
$emailbody .= get_lang('ManageUser',null,$values['language']).": $url_edit";
$emailbody .= get_lang('ManageUser',null,$values['language']).": $url_edit";
$admins = UserManager::get_all_administrators();
foreach ($admins as $admin_info) {
@ -551,10 +551,10 @@ if ($form->validate()) {
/* SESSION REGISTERING */
/* @todo move this in a function */
$_user['firstName'] = stripslashes($values['firstname']);
$_user['lastName'] = stripslashes($values['lastname']);
$_user['mail'] = $values['email'];
$_user['language'] = $values['language'];
$_user['user_id'] = $user_id;
$_user['lastName'] = stripslashes($values['lastname']);
$_user['mail'] = $values['email'];
$_user['language'] = $values['language'];
$_user['user_id'] = $user_id;
$is_allowedCreateCourse = $values['status'] == 1;
$usersCanCreateCourse = (api_get_setting('allow_users_to_create_courses') == 'true');

File diff suppressed because it is too large Load Diff

@ -41,7 +41,7 @@ switch ($action) {
}
}
break;
case 'search_tags':
case 'search_tags':
if (api_is_anonymous()) {
echo '';
} else {
@ -50,7 +50,7 @@ switch ($action) {
}
}
break;
case 'generate_api_key':
case 'generate_api_key':
if (api_is_anonymous()) {
echo '';
} else {
@ -69,7 +69,7 @@ switch ($action) {
<?php
}
break;
case 'active_user':
case 'active_user':
if (api_is_platform_admin() && api_global_admin_can_edit_admin($_GET['user_id'])) {
$user_id = intval($_GET['user_id']);

@ -334,12 +334,12 @@ function create_course_tables($course_db_name = null) {
$use_one_db = true;
if ($use_one_db) {
$course_db_name = DB_COURSE_PREFIX;
$course_db_name = DB_COURSE_PREFIX;
} else {
if (!$_configuration['single_database']) {
Database::query("CREATE DATABASE IF NOT EXISTS " . $course_db_name . "" . $charset_clause);
}
$course_db_name = $_configuration['table_prefix'].$course_db_name.$_configuration['db_glue'];
if (!$_configuration['single_database']) {
Database::query("CREATE DATABASE IF NOT EXISTS " . $course_db_name . "" . $charset_clause);
}
$course_db_name = $_configuration['table_prefix'].$course_db_name.$_configuration['db_glue'];
}
//@todo define the backticks inside those table names directly (instead of adding them afterwards)
@ -399,8 +399,8 @@ function create_course_tables($course_db_name = null) {
$TABLEQUIZQUESTIONLIST = $course_db_name . 'quiz_question';
$TABLEQUIZANSWERSLIST = $course_db_name . 'quiz_answer';
$TABLEQUIZQUESTIONOPTION = $course_db_name . 'quiz_question_option';
$table_quiz_question_category = $course_db_name . 'quiz_question_category';
$table_quiz_question_rel_category = $course_db_name . 'quiz_question_rel_category';
$table_quiz_question_category = $course_db_name . 'quiz_question_category';
$table_quiz_question_rel_category = $course_db_name . 'quiz_question_rel_category';
// Dropbox
$TABLETOOLDROPBOXPOST = $course_db_name . 'dropbox_post';
@ -477,7 +477,7 @@ function create_course_tables($course_db_name = null) {
$add_to_all_tables = ' c_id INT NOT NULL, ';
/* Announcement tool */
/* Announcement tool */
$sql = "
CREATE TABLE `".$TABLETOOLANNOUNCEMENTS . "` (
@ -498,7 +498,7 @@ function create_course_tables($course_db_name = null) {
// Announcement Attachment
$sql = "CREATE TABLE `".$TABLETOOLANNOUNCEMENTSATTACHMENT."` (
$add_to_all_tables
$add_to_all_tables
id int NOT NULL auto_increment,
path varchar(255) NOT NULL,
comment text,
@ -553,12 +553,12 @@ function create_course_tables($course_db_name = null) {
)" . $charset_clause;
Database::query($sql);
/* Forum tool */
/* Forum tool */
// Forum Category
$sql = "
CREATE TABLE `".$TABLETOOLFORUMCATEGORY . "` (
$add_to_all_tables
$add_to_all_tables
cat_id int NOT NULL auto_increment,
cat_title varchar(255) NOT NULL default '',
cat_comment text,
@ -669,7 +669,7 @@ function create_course_tables($course_db_name = null) {
// Forum Attachment
$sql = "CREATE TABLE `".$TABLETOOLFORUMATTACHMENT."` (
$add_to_all_tables
$add_to_all_tables
id int NOT NULL auto_increment,
path varchar(255) NOT NULL,
comment text,
@ -682,7 +682,7 @@ function create_course_tables($course_db_name = null) {
// Forum notification
$sql = "CREATE TABLE `".$TABLETOOLFORUMNOTIFICATION."` (
$add_to_all_tables
$add_to_all_tables
id int NOT NULL auto_increment,
user_id int,
forum_id int,
@ -696,7 +696,7 @@ function create_course_tables($course_db_name = null) {
// Forum thread qualify :Add table forum_thread_qualify
$sql = "CREATE TABLE `".$TABLETOOLFORUMQUALIFY."` (
$add_to_all_tables
$add_to_all_tables
id int unsigned AUTO_INCREMENT,
user_id int unsigned NOT NULL,
thread_id int NOT NULL,
@ -713,7 +713,7 @@ function create_course_tables($course_db_name = null) {
//Forum thread qualify: Add table forum_thread_qualify_historical
$sql = "CREATE TABLE `".$TABLETOOLFORUMQUALIFYLOG."` (
$add_to_all_tables
$add_to_all_tables
id int unsigned AUTO_INCREMENT,
user_id int unsigned NOT NULL,
thread_id int NOT NULL,
@ -832,25 +832,25 @@ function create_course_tables($course_db_name = null) {
$sql = "CREATE TABLE `".$table_quiz_question_category . "` (
$add_to_all_tables
id int NOT NULL AUTO_INCREMENT,
title varchar(255) NOT NULL,
description text NOT NULL,
PRIMARY KEY (c_id,id)
)" . $charset_clause;
$add_to_all_tables
id int NOT NULL AUTO_INCREMENT,
title varchar(255) NOT NULL,
description text NOT NULL,
PRIMARY KEY (c_id,id)
)" . $charset_clause;
Database::query($sql);
$sql = "CREATE TABLE `".$table_quiz_question_rel_category . "` (
$add_to_all_tables
question_id int NOT NULL,
category_id int NOT NULL,
PRIMARY KEY (c_id,question_id)
$sql = "CREATE TABLE `".$table_quiz_question_rel_category . "` (
$add_to_all_tables
question_id int NOT NULL,
category_id int NOT NULL,
PRIMARY KEY (c_id,question_id)
)" . $charset_clause;
Database::query($sql);
/* Course description */
/* Course description */
$sql = "
CREATE TABLE `".$TABLETOOLCOURSEDESC . "` (
@ -890,7 +890,7 @@ function create_course_tables($course_db_name = null) {
$sql = "ALTER TABLE `".$tbl_course_homepage . "` ADD INDEX ( session_id ) ";
Database::query($sql);
/* Agenda tool */
/* Agenda tool */
$sql = "
CREATE TABLE `".$TABLETOOLAGENDA . "` (
@ -933,7 +933,7 @@ function create_course_tables($course_db_name = null) {
// Agenda Attachment
$sql = "CREATE TABLE `".$TABLETOOLAGENDAATTACHMENT."` (
$add_to_all_tables
$add_to_all_tables
id int NOT NULL auto_increment,
path varchar(255) NOT NULL,
comment text,
@ -950,7 +950,7 @@ function create_course_tables($course_db_name = null) {
$sql = "
CREATE TABLE `".$TABLETOOLDOCUMENT . "` (
$add_to_all_tables
$add_to_all_tables
id int unsigned NOT NULL auto_increment,
path varchar(255) NOT NULL default '',
comment text,
@ -988,8 +988,8 @@ function create_course_tables($course_db_name = null) {
weight float(6,2) UNSIGNED NOT NULL default 0,
session_id INT UNSIGNED NOT NULL default 0,
user_id INTEGER NOT NULL,
allow_text_assignment INTEGER NOT NULL DEFAULT 0,
contains_file INTEGER NOT NULL DEFAULT 0,
allow_text_assignment INTEGER NOT NULL DEFAULT 0,
contains_file INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (c_id, id)
)" . $charset_clause;
Database::query($sql);
@ -1051,7 +1051,7 @@ function create_course_tables($course_db_name = null) {
/* Wiki */
$sql = "CREATE TABLE `".$TABLETOOLWIKI . "` (
$add_to_all_tables
$add_to_all_tables
id int NOT NULL auto_increment,
page_id int NOT NULL default 0,
reflink varchar(255) NOT NULL default 'index',
@ -1087,7 +1087,7 @@ function create_course_tables($course_db_name = null) {
Database::query($sql);
$sql = "CREATE TABLE `".$TABLEWIKICONF . "` (
$add_to_all_tables
$add_to_all_tables
page_id int NOT NULL default 0,
task text NOT NULL,
feedback1 text NOT NULL,
@ -1108,7 +1108,7 @@ function create_course_tables($course_db_name = null) {
Database::query($sql);
$sql = "CREATE TABLE `".$TABLEWIKIDISCUSS . "` (
$add_to_all_tables
$add_to_all_tables
id int NOT NULL auto_increment,
publication_id int NOT NULL default 0,
userc_id int NOT NULL default 0,
@ -1120,7 +1120,7 @@ function create_course_tables($course_db_name = null) {
Database::query($sql);
$sql = "CREATE TABLE `".$TABLEWIKIMAILCUE . "` (
$add_to_all_tables
$add_to_all_tables
id int NOT NULL,
user_id int NOT NULL,
type text NOT NULL,
@ -1137,7 +1137,7 @@ function create_course_tables($course_db_name = null) {
$sql = "
CREATE TABLE `".$TABLETOOLONLINECONNECTED . "` (
$add_to_all_tables
$add_to_all_tables
user_id int unsigned NOT NULL,
last_connection datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (c_id, user_id)
@ -1174,7 +1174,7 @@ function create_course_tables($course_db_name = null) {
*/
Database::query("CREATE TABLE `".$TABLEGROUPS . "` (
$add_to_all_tables
$add_to_all_tables
id int unsigned NOT NULL auto_increment,
name varchar(100) default NULL,
category_id int unsigned NOT NULL default 0,
@ -1197,7 +1197,7 @@ function create_course_tables($course_db_name = null) {
Database::query("ALTER TABLE `".$TABLEGROUPS . "` ADD INDEX ( session_id )");
Database::query("CREATE TABLE `".$TABLEGROUPCATEGORIES . "` (
$add_to_all_tables
$add_to_all_tables
id int unsigned NOT NULL auto_increment,
title varchar(255) NOT NULL default '',
description text NOT NULL,
@ -1217,7 +1217,7 @@ function create_course_tables($course_db_name = null) {
)" . $charset_clause);
Database::query("CREATE TABLE `".$TABLEGROUPUSER . "` (
$add_to_all_tables
$add_to_all_tables
id int unsigned NOT NULL auto_increment,
user_id int unsigned NOT NULL,
group_id int unsigned NOT NULL default 0,
@ -1227,7 +1227,7 @@ function create_course_tables($course_db_name = null) {
)" . $charset_clause);
Database::query("CREATE TABLE `".$TABLEGROUPTUTOR . "` (
$add_to_all_tables
$add_to_all_tables
id int NOT NULL auto_increment,
user_id int NOT NULL,
group_id int NOT NULL default 0,
@ -1235,7 +1235,7 @@ function create_course_tables($course_db_name = null) {
)" . $charset_clause);
Database::query("CREATE TABLE `".$TABLEITEMPROPERTY . "` (
$add_to_all_tables
$add_to_all_tables
id int NOT NULL auto_increment,
tool varchar(100) NOT NULL default '',
insert_user_id int unsigned NOT NULL default '0',
@ -1310,7 +1310,7 @@ function create_course_tables($course_db_name = null) {
)" . $charset_clause);
$sql = "CREATE TABLE `".$TABLETOOLDROPBOXCATEGORY."` (
$add_to_all_tables
$add_to_all_tables
cat_id int NOT NULL auto_increment,
cat_name text NOT NULL,
received tinyint unsigned NOT NULL default 0,
@ -1325,7 +1325,7 @@ function create_course_tables($course_db_name = null) {
Database::query($sql);
$sql = "CREATE TABLE `".$TABLETOOLDROPBOXFEEDBACK."` (
$add_to_all_tables
$add_to_all_tables
feedback_id int NOT NULL auto_increment,
file_id int NOT NULL default 0,
author_user_id int NOT NULL default 0,
@ -1342,8 +1342,8 @@ function create_course_tables($course_db_name = null) {
*/
$sql = "CREATE TABLE IF NOT EXISTS `$TABLELP` (
$add_to_all_tables
" .
$add_to_all_tables
" .
"id int unsigned auto_increment," . // unique ID, generated by MySQL
"lp_type int unsigned not null," . // lp_types can be found in the main database's lp_type table
"name varchar(255) not null," . // name is the text name of the learning path (e.g. Word 2000)
@ -1364,22 +1364,22 @@ function create_course_tables($course_db_name = null) {
"preview_image varchar(255) not null default '', " . // stores the theme of the LP
"author varchar(255) not null default '', " . // stores the theme of the LP
"session_id int unsigned not null default 0, " . // the session_id
"prerequisite int unsigned not null default 0," . // pre requisite for next lp
"hide_toc_frame tinyint NOT NULL DEFAULT 0, ".
"seriousgame_mode tinyint NOT NULL DEFAULT 0, ".
"prerequisite int unsigned not null default 0," . // pre requisite for next lp
"hide_toc_frame tinyint NOT NULL DEFAULT 0, ".
"seriousgame_mode tinyint NOT NULL DEFAULT 0, ".
"use_max_score int unsigned not null default 1, " .
"autolunch int unsigned not null default 0, " . // auto lunch LP
"created_on DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', " .
"modified_on DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', " .
"publicated_on DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', " .
"expired_on DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (c_id, id)
"created_on DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', " .
"modified_on DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', " .
"publicated_on DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', " .
"expired_on DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (c_id, id)
)" . $charset_clause;
Database::query($sql);
$sql = "CREATE TABLE IF NOT EXISTS `$TABLELPVIEW` (
$add_to_all_tables" .
$add_to_all_tables" .
"id int unsigned auto_increment," . // unique ID from MySQL
"lp_id int unsigned not null," . // learnpath ID from 'lp'
"user_id int unsigned not null," . // user ID from main.user
@ -1388,7 +1388,7 @@ function create_course_tables($course_db_name = null) {
"progress int unsigned default 0," .
"session_id int not null default 0,
PRIMARY KEY (c_id, id)
)" . $charset_clause; // lp's progress for this user
)" . $charset_clause; // lp's progress for this user
Database::query($sql);
@ -1402,8 +1402,8 @@ function create_course_tables($course_db_name = null) {
Database::query($sql);
$sql = "CREATE TABLE IF NOT EXISTS `$TABLELPITEM` (
$add_to_all_tables
" .
$add_to_all_tables
" .
"id int unsigned auto_increment," . // unique ID from MySQL
"lp_id int unsigned not null," . // lp_id from 'lp'
"item_type char(32) not null default 'dokeos_document'," . // can be dokeos_document, dokeos_chapter or scorm_asset, scorm_sco, scorm_chapter
@ -1427,7 +1427,7 @@ function create_course_tables($course_db_name = null) {
"audio VARCHAR(250),
PRIMARY KEY (c_id, id)
)" . $charset_clause; // contains the audio file that goes with the learning path step
)" . $charset_clause; // contains the audio file that goes with the learning path step
Database::query($sql);
@ -1438,8 +1438,8 @@ function create_course_tables($course_db_name = null) {
Database::query($sql);
$sql = "CREATE TABLE IF NOT EXISTS `$TABLELPITEMVIEW` (
$add_to_all_tables
" .
$add_to_all_tables
" .
"id bigint unsigned auto_increment," . // unique ID
"lp_item_id int unsigned not null," . // item ID (MySQL id)
"lp_view_id int unsigned not null," . // learning path view id (attempt)
@ -1448,7 +1448,7 @@ function create_course_tables($course_db_name = null) {
"total_time int unsigned not null default 0," . // after how many seconds did he close it?
"score float unsigned not null default 0," . // score returned by SCORM or other techs
"status char(32) not null default 'not attempted'," . // status for this item (SCORM)
"suspend_data longtext null default ''," .
"suspend_data longtext null default ''," .
"lesson_location text null default ''," .
"core_exit varchar(32) not null default 'none'," .
"max_score varchar(8) default '',
@ -1468,7 +1468,7 @@ function create_course_tables($course_db_name = null) {
$sql = "CREATE TABLE IF NOT EXISTS `$TABLELPIVINTERACTION`(
$add_to_all_tables" .
$add_to_all_tables" .
"id bigint unsigned auto_increment," .
"order_id int unsigned not null default 0,". // internal order (0->...) given by Dokeos
"lp_iv_id bigint unsigned not null," . // identifier of the related sco_view
@ -1480,7 +1480,7 @@ function create_course_tables($course_db_name = null) {
"student_response text not null default ''," . // student response (format depends on type)
"result varchar(255) not null default ''," . // textual result
"latency varchar(16) not null default ''," . // time necessary for completion of the interaction
"PRIMARY KEY (c_id, id)".
"PRIMARY KEY (c_id, id)".
")" . $charset_clause;
Database::query($sql);
@ -1489,7 +1489,7 @@ function create_course_tables($course_db_name = null) {
Database::query($sql);
$sql = "CREATE TABLE IF NOT EXISTS `$TABLELPIVOBJECTIVE`(
$add_to_all_tables" .
$add_to_all_tables" .
"id bigint unsigned auto_increment," .
"lp_iv_id bigint unsigned not null," . // identifier of the related sco_view
"order_id int unsigned not null default 0,". // internal order (0->...) given by Dokeos
@ -1498,7 +1498,7 @@ function create_course_tables($course_db_name = null) {
"score_max float unsigned not null default 0," . // max score
"score_min float unsigned not null default 0," . // min score
"status char(32) not null default 'not attempted', " . //status, just as sco status
"PRIMARY KEY (c_id, id) ".
"PRIMARY KEY (c_id, id) ".
")" . $charset_clause;
Database::query($sql);
@ -1527,7 +1527,7 @@ function create_course_tables($course_db_name = null) {
$sql = "
CREATE TABLE `" . $tbl_blogs_comments . "` (
$add_to_all_tables
$add_to_all_tables
comment_id int NOT NULL AUTO_INCREMENT ,
title varchar( 250 ) NOT NULL default '',
comment longtext NOT NULL ,
@ -1544,7 +1544,7 @@ function create_course_tables($course_db_name = null) {
$sql = "
CREATE TABLE `" . $tbl_blogs_posts . "` (
$add_to_all_tables
$add_to_all_tables
post_id int NOT NULL AUTO_INCREMENT ,
title varchar( 250 ) NOT NULL default '',
full_text longtext NOT NULL ,
@ -1558,7 +1558,7 @@ function create_course_tables($course_db_name = null) {
$sql = "
CREATE TABLE `" . $tbl_blogs_rating . "` (
$add_to_all_tables
$add_to_all_tables
rating_id int NOT NULL AUTO_INCREMENT ,
blog_id int NOT NULL default 0,
rating_type enum( 'post', 'comment' ) NOT NULL default 'post',
@ -1572,7 +1572,7 @@ function create_course_tables($course_db_name = null) {
$sql = "
CREATE TABLE `" . $tbl_blogs_rel_user . "` (
$add_to_all_tables
$add_to_all_tables
blog_id int NOT NULL default 0,
user_id int NOT NULL default 0,
PRIMARY KEY ( c_id, blog_id , user_id )
@ -1582,7 +1582,7 @@ function create_course_tables($course_db_name = null) {
$sql = "
CREATE TABLE `" . $tbl_blogs_tasks . "` (
$add_to_all_tables
$add_to_all_tables
task_id int NOT NULL AUTO_INCREMENT ,
blog_id int NOT NULL default 0,
title varchar( 250 ) NOT NULL default '',
@ -1596,7 +1596,7 @@ function create_course_tables($course_db_name = null) {
$sql = "
CREATE TABLE `" . $tbl_blogs_tasks_rel_user . "` (
$add_to_all_tables
$add_to_all_tables
blog_id int NOT NULL default 0,
user_id int NOT NULL default 0,
task_id int NOT NULL default 0,
@ -1607,7 +1607,7 @@ function create_course_tables($course_db_name = null) {
Database::query($sql);
$sql ="CREATE TABLE `" .$tbl_blogs_attachment."` (
$add_to_all_tables
$add_to_all_tables
id int unsigned NOT NULL auto_increment,
path varchar(255) NOT NULL COMMENT 'the real filename',
comment text,
@ -1623,7 +1623,7 @@ function create_course_tables($course_db_name = null) {
$sql = "
CREATE TABLE `" . $tbl_permission_group . "` (
$add_to_all_tables
$add_to_all_tables
id int NOT NULL AUTO_INCREMENT ,
group_id int NOT NULL default 0,
tool varchar( 250 ) NOT NULL default '',
@ -1635,7 +1635,7 @@ function create_course_tables($course_db_name = null) {
$sql = "
CREATE TABLE `" . $tbl_permission_user . "` (
$add_to_all_tables
$add_to_all_tables
id int NOT NULL AUTO_INCREMENT ,
user_id int NOT NULL default 0,
tool varchar( 250 ) NOT NULL default '',
@ -1647,7 +1647,7 @@ function create_course_tables($course_db_name = null) {
$sql = "
CREATE TABLE `" . $tbl_permission_task . "` (
$add_to_all_tables
$add_to_all_tables
id int NOT NULL AUTO_INCREMENT,
task_id int NOT NULL default 0,
tool varchar( 250 ) NOT NULL default '',
@ -1659,7 +1659,7 @@ function create_course_tables($course_db_name = null) {
$sql = "
CREATE TABLE `" . $tbl_role . "` (
$add_to_all_tables
$add_to_all_tables
role_id int NOT NULL AUTO_INCREMENT,
role_name varchar( 250 ) NOT NULL default '',
role_comment text,
@ -1671,7 +1671,7 @@ function create_course_tables($course_db_name = null) {
$sql = "
CREATE TABLE `" . $tbl_role_group . "` (
$add_to_all_tables
$add_to_all_tables
id int NOT NULL AUTO_INCREMENT,
role_id int NOT NULL default 0,
scope varchar( 20 ) NOT NULL default 'course',
@ -1683,7 +1683,7 @@ function create_course_tables($course_db_name = null) {
$sql = "
CREATE TABLE `" . $tbl_role_permissions . "` (
$add_to_all_tables
$add_to_all_tables
id int NOT NULL AUTO_INCREMENT,
role_id int NOT NULL default 0,
tool varchar( 250 ) NOT NULL default '',
@ -1696,7 +1696,7 @@ function create_course_tables($course_db_name = null) {
$sql = "
CREATE TABLE `" . $tbl_role_user . "` (
$add_to_all_tables
$add_to_all_tables
role_id int NOT NULL default 0,
scope varchar( 20 ) NOT NULL default 'course',
user_id int NOT NULL default 0,
@ -1730,7 +1730,7 @@ function create_course_tables($course_db_name = null) {
*/
$sql = "CREATE TABLE `".$TABLESURVEY."` (
$add_to_all_tables
$add_to_all_tables
survey_id int unsigned NOT NULL auto_increment,
code varchar(20) default NULL,
title text default NULL,
@ -1767,7 +1767,7 @@ function create_course_tables($course_db_name = null) {
Database::query($sql);
$sql = "CREATE TABLE `".$TABLESURVEYINVITATION."` (
$add_to_all_tables
$add_to_all_tables
survey_invitation_id int unsigned NOT NULL auto_increment,
survey_code varchar(20) NOT NULL,
user varchar(250) NOT NULL,
@ -1781,7 +1781,7 @@ function create_course_tables($course_db_name = null) {
$result = Database::query($sql);
$sql = "CREATE TABLE `".$TABLESURVEYQUESTION."` (
$add_to_all_tables
$add_to_all_tables
question_id int unsigned NOT NULL auto_increment,
survey_id int unsigned NOT NULL,
survey_question text NOT NULL,
@ -1799,7 +1799,7 @@ function create_course_tables($course_db_name = null) {
$result = Database::query($sql);
$sql ="CREATE TABLE `".$TABLESURVEYQUESTIONOPTION."` (
$add_to_all_tables
$add_to_all_tables
question_option_id int unsigned NOT NULL auto_increment,
question_id int unsigned NOT NULL,
survey_id int unsigned NOT NULL,
@ -1812,7 +1812,7 @@ function create_course_tables($course_db_name = null) {
$result = Database::query($sql);
$sql = "CREATE TABLE `".$TABLESURVEYANSWER."` (
$add_to_all_tables
$add_to_all_tables
answer_id int unsigned NOT NULL auto_increment,
survey_id int unsigned NOT NULL,
question_id int unsigned NOT NULL,
@ -1824,7 +1824,7 @@ function create_course_tables($course_db_name = null) {
$result = Database::query($sql);
$sql = "CREATE TABLE `".$TABLESURVEYGROUP."` (
$add_to_all_tables
$add_to_all_tables
id int unsigned NOT NULL auto_increment,
name varchar(20) NOT NULL,
description varchar(255) NOT NULL,
@ -1835,7 +1835,7 @@ function create_course_tables($course_db_name = null) {
// Table glosary
$sql = "CREATE TABLE `".$TBL_GLOSSARY."` (
$add_to_all_tables
$add_to_all_tables
glossary_id int unsigned NOT NULL auto_increment,
name varchar(255) NOT NULL,
description text not null,
@ -1850,7 +1850,7 @@ function create_course_tables($course_db_name = null) {
// Table notebook
$sql = "CREATE TABLE `".$TBL_NOTEBOOK."` (
$add_to_all_tables
$add_to_all_tables
notebook_id int unsigned NOT NULL auto_increment,
user_id int unsigned NOT NULL,
course varchar(40) not null,
@ -1869,7 +1869,7 @@ function create_course_tables($course_db_name = null) {
// Attendance table
$sql = "
CREATE TABLE `".$TBL_ATTENDANCE."` (
$add_to_all_tables
$add_to_all_tables
id int NOT NULL auto_increment,
name text NOT NULL,
description TEXT NULL,
@ -1892,7 +1892,7 @@ function create_course_tables($course_db_name = null) {
// Attendance sheet table
$sql = "
CREATE TABLE `".$TBL_ATTENDANCE_SHEET."` (
$add_to_all_tables
$add_to_all_tables
user_id int NOT NULL,
attendance_calendar_id int NOT NULL,
presence tinyint NOT NULL DEFAULT 0,
@ -1906,7 +1906,7 @@ function create_course_tables($course_db_name = null) {
// Attendance calendar table
$sql = "
CREATE TABLE `".$TBL_ATTENDANCE_CALENDAR."` (
$add_to_all_tables
$add_to_all_tables
id int NOT NULL auto_increment,
attendance_id int NOT NULL ,
date_time datetime NOT NULL default '0000-00-00 00:00:00',
@ -1924,7 +1924,7 @@ function create_course_tables($course_db_name = null) {
// Attendance result table
$sql = "
CREATE TABLE `".$TBL_ATTENDANCE_RESULT."` (
$add_to_all_tables
$add_to_all_tables
id int NOT NULL auto_increment,
user_id int NOT NULL,
attendance_id int NOT NULL,
@ -1941,7 +1941,7 @@ function create_course_tables($course_db_name = null) {
// attendance sheet log table
$sql = "CREATE TABLE `".$TBL_ATTENDANCE_SHEET_LOG."` (
$add_to_all_tables
$add_to_all_tables
id int NOT NULL auto_increment,
attendance_id int NOT NULL DEFAULT 0,
lastedit_date datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@ -1955,7 +1955,7 @@ function create_course_tables($course_db_name = null) {
// Thematic table
$sql = "CREATE TABLE `".$TBL_THEMATIC."` (
$add_to_all_tables
$add_to_all_tables
id int NOT NULL auto_increment,
title varchar(255) NOT NULL,
content text NULL,
@ -1971,7 +1971,7 @@ function create_course_tables($course_db_name = null) {
// thematic plan table
$sql = "CREATE TABLE `".$TBL_THEMATIC_PLAN."` (
$add_to_all_tables
$add_to_all_tables
id int NOT NULL auto_increment,
thematic_id int NOT NULL,
title varchar(255) NOT NULL,
@ -1987,7 +1987,7 @@ function create_course_tables($course_db_name = null) {
// thematic advance table
$sql = "
CREATE TABLE `".$TBL_THEMATIC_ADVANCE."` (
$add_to_all_tables
$add_to_all_tables
id int NOT NULL auto_increment,
thematic_id int NOT NULL,
attendance_id int NOT NULL DEFAULT 0,
@ -2078,10 +2078,10 @@ function sort_pictures($files, $type) {
/**
* Fills the course repository with some example content.
* @param string Course directory name (without prefix/suffix). eg "ABC"
* @param bool Whether we want to fill it with example content or not
* @return array The (structured) list of files created
* @version 1.2
* @param string Course directory name (without prefix/suffix). eg "ABC"
* @param bool Whether we want to fill it with example content or not
* @return array The (structured) list of files created
* @version 1.2
* @deprecated this function has been merged into the fill_db_course
* @assert (null, null) === false
*/
@ -2290,31 +2290,31 @@ function fill_db_course($course_id, $course_repository, $language, $fill_with_ex
$course_id = intval($course_id);
if (empty($course_id)) {
return false;
return false;
}
$now = api_get_utc_datetime(time());
$tbl_course_homepage = Database::get_course_table(TABLE_TOOL_LIST);
$TABLEINTROS = Database::get_course_table(TABLE_TOOL_INTRO);
$TABLEGROUPCATEGORIES = Database::get_course_table(TABLE_GROUP_CATEGORY);
$TABLEITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
$TABLETOOLAGENDA = Database::get_course_table(TABLE_AGENDA);
$tbl_course_homepage = Database::get_course_table(TABLE_TOOL_LIST);
$TABLEINTROS = Database::get_course_table(TABLE_TOOL_INTRO);
$TABLEGROUPCATEGORIES = Database::get_course_table(TABLE_GROUP_CATEGORY);
$TABLEITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
$TABLETOOLAGENDA = Database::get_course_table(TABLE_AGENDA);
$TABLETOOLANNOUNCEMENTS = Database::get_course_table(TABLE_ANNOUNCEMENT);
$TABLETOOLDOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
$TABLETOOLLINK = Database::get_course_table(TABLE_LINK);
$TABLEQUIZ = Database::get_course_table(TABLE_QUIZ_TEST);
$TABLEQUIZQUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$TABLEQUIZQUESTIONLIST = Database::get_course_table(TABLE_QUIZ_QUESTION);
$TABLEQUIZANSWERSLIST = Database::get_course_table(TABLE_QUIZ_ANSWER);
$TABLESETTING = Database::get_course_table(TABLE_COURSE_SETTING);
$TABLEFORUMCATEGORIES = Database::get_course_table(TABLE_FORUM_CATEGORY);
$TABLEFORUMS = Database::get_course_table(TABLE_FORUM);
$TABLEFORUMTHREADS = Database::get_course_table(TABLE_FORUM_THREAD);
$TABLEFORUMPOSTS = Database::get_course_table(TABLE_FORUM_POST);
$TABLEGRADEBOOK = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$TABLEGRADEBOOKLINK = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
$TABLEGRADEBOOKCERT = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
$TABLETOOLDOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
$TABLETOOLLINK = Database::get_course_table(TABLE_LINK);
$TABLEQUIZ = Database::get_course_table(TABLE_QUIZ_TEST);
$TABLEQUIZQUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$TABLEQUIZQUESTIONLIST = Database::get_course_table(TABLE_QUIZ_QUESTION);
$TABLEQUIZANSWERSLIST = Database::get_course_table(TABLE_QUIZ_ANSWER);
$TABLESETTING = Database::get_course_table(TABLE_COURSE_SETTING);
$TABLEFORUMCATEGORIES = Database::get_course_table(TABLE_FORUM_CATEGORY);
$TABLEFORUMS = Database::get_course_table(TABLE_FORUM);
$TABLEFORUMTHREADS = Database::get_course_table(TABLE_FORUM_THREAD);
$TABLEFORUMPOSTS = Database::get_course_table(TABLE_FORUM_POST);
$TABLEGRADEBOOK = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$TABLEGRADEBOOKLINK = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
$TABLEGRADEBOOKCERT = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
include api_get_path(SYS_CODE_PATH).'lang/english/create_course.inc.php';
$file_to_include = api_get_path(SYS_CODE_PATH).'lang/'.$language.'/create_course.inc.php';
@ -2400,7 +2400,7 @@ function fill_db_course($course_id, $course_repository, $language, $fill_with_ex
/* Group tool */
Database::query("INSERT INTO $TABLEGROUPCATEGORIES (c_id, id , title , description , max_student , self_reg_allowed , self_unreg_allowed , groups_per_user , display_order )
VALUES ($course_id, '2', '".lang2db(get_lang('DefaultGroupCategory')) . "', '', '8', '0', '0', '0', '0');");
VALUES ($course_id, '2', '".lang2db(get_lang('DefaultGroupCategory')) . "', '', '8', '0', '0', '0', '0');");
/* Example Material */
global $language_interface;
@ -2595,7 +2595,7 @@ function fill_db_course($course_id, $course_repository, $language, $fill_with_ex
// We need to add the item properties too!
$insert_id = Database :: insert_id();
$sql = "INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility)
VALUES ($course_id, '" . TOOL_LINK . "',1,NOW(),NOW(),$insert_id,'LinkAdded',1,0,NULL,1)";
VALUES ($course_id, '" . TOOL_LINK . "',1,NOW(),NOW(),$insert_id,'LinkAdded',1,0,NULL,1)";
Database::query($sql);
$add_wikipedia_link_sql = "INSERT INTO $TABLETOOLLINK (c_id, url, title, description, category_id, display_order, on_homepage, target)
@ -2610,13 +2610,13 @@ function fill_db_course($course_id, $course_repository, $language, $fill_with_ex
/* Annoucement tool */
$sql = "INSERT INTO $TABLETOOLANNOUNCEMENTS (c_id, title,content,end_date,display_order,email_sent)
VALUES ($course_id, '".lang2db(get_lang('AnnouncementExampleTitle')) . "', '".lang2db(get_lang('AnnouncementEx')) . "', NOW(), '1','0')";
VALUES ($course_id, '".lang2db(get_lang('AnnouncementExampleTitle')) . "', '".lang2db(get_lang('AnnouncementEx')) . "', NOW(), '1','0')";
Database::query($sql);
// We need to add the item properties too!
$insert_id = Database :: insert_id();
$sql = "INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility)
VALUES ($course_id, '" . TOOL_ANNOUNCEMENT . "',1,NOW(),NOW(),$insert_id,'AnnouncementAdded',1,0,NULL,1)";
VALUES ($course_id, '" . TOOL_ANNOUNCEMENT . "',1,NOW(),NOW(),$insert_id,'AnnouncementAdded',1,0,NULL,1)";
Database::query($sql);
/* Introduction text */
@ -2647,7 +2647,7 @@ function fill_db_course($course_id, $course_repository, $language, $fill_with_ex
' "'.$html.'", "1", "0", "0", "1", "0")');
$exercise_id = Database :: insert_id();
Database::query("INSERT INTO $TABLEQUIZQUESTIONLIST (c_id, id, question, description, ponderation, position, type, picture, level)
VALUES ( '.$course_id.', '1', '".lang2db(get_lang('SocraticIrony')) . "', '".lang2db(get_lang('ManyAnswers')) . "', '10', '1', '2','',1)");
VALUES ( '.$course_id.', '1', '".lang2db(get_lang('SocraticIrony')) . "', '".lang2db(get_lang('ManyAnswers')) . "', '10', '1', '2','',1)");
Database::query("INSERT INTO $TABLEQUIZQUESTION (c_id, question_id, exercice_id, question_order) VALUES ('.$course_id.', 1,1,1)");
/* Forum tool */
@ -2655,19 +2655,19 @@ function fill_db_course($course_id, $course_repository, $language, $fill_with_ex
Database::query("INSERT INTO $TABLEFORUMCATEGORIES VALUES ($course_id, 1,'".lang2db(get_lang('ExampleForumCategory'))."', '', 1, 0, 0)");
$insert_id = Database :: insert_id();
Database::query("INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility)
VALUES ($course_id, 'forum_category',1,NOW(),NOW(),$insert_id,'ForumCategoryAdded',1,0,NULL,1)");
VALUES ($course_id, 'forum_category',1,NOW(),NOW(),$insert_id,'ForumCategoryAdded',1,0,NULL,1)");
Database::query("INSERT INTO $TABLEFORUMS (c_id, forum_title, forum_comment, forum_threads,forum_posts,forum_last_post,forum_category, allow_anonymous, allow_edit,allow_attachments, allow_new_threads,default_view,forum_of_group,forum_group_public_private, forum_order,locked,session_id )
VALUES ($course_id, '".lang2db(get_lang('ExampleForum'))."', '', 0, 0, 0, 1, 0, 1, '0', 1, 'flat','0', 'public', 1, 0,0)");
VALUES ($course_id, '".lang2db(get_lang('ExampleForum'))."', '', 0, 0, 0, 1, 0, 1, '0', 1, 'flat','0', 'public', 1, 0,0)");
$insert_id = Database :: insert_id();
Database::query("INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility)
VALUES ($course_id, '".TOOL_FORUM."', 1,NOW(),NOW(),$insert_id,'ForumAdded',1,0,NULL,1)");
VALUES ($course_id, '".TOOL_FORUM."', 1,NOW(),NOW(),$insert_id,'ForumAdded',1,0,NULL,1)");
Database::query("INSERT INTO $TABLEFORUMTHREADS (c_id, thread_id, thread_title, forum_id, thread_replies, thread_poster_id, thread_poster_name, thread_views, thread_last_post, thread_date, locked, thread_qualify_max, session_id)
VALUES ($course_id, 1, '".lang2db(get_lang('ExampleThread'))."', 1, 0, 1, '', 0, 1, NOW(), 0, 10, 0)");
VALUES ($course_id, 1, '".lang2db(get_lang('ExampleThread'))."', 1, 0, 1, '', 0, 1, NOW(), 0, 10, 0)");
$insert_id = Database :: insert_id();
Database::query("INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility)
VALUES ($course_id, 'forum_thread',1,NOW(),NOW(),$insert_id,'ForumThreadAdded',1,0,NULL,1)");
VALUES ($course_id, 'forum_thread',1,NOW(),NOW(),$insert_id,'ForumThreadAdded',1,0,NULL,1)");
Database::query("INSERT INTO $TABLEFORUMPOSTS VALUES ($course_id, 1, '".lang2db(get_lang('ExampleThread'))."', '".lang2db(get_lang('ExampleThreadContent'))."', 1, 1, 1, '', NOW(), 0, 0, 1)");
@ -2754,8 +2754,8 @@ function register_course($params)
$teachers = isset($params['teachers']) ? $params['teachers'] : null;
$status = isset($params['status']) ? $params['status'] : null;
$TABLECOURSE = Database :: get_main_table(TABLE_MAIN_COURSE);
$TABLECOURSUSER = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$TABLECOURSE = Database :: get_main_table(TABLE_MAIN_COURSE);
$TABLECOURSUSER = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$ok_to_register_course = true;
@ -2828,7 +2828,7 @@ function register_course($params)
unsubscribe = '".intval($unsubscribe) . "',
visual_code = '".Database :: escape_string($visual_code) . "'";
Database::query($sql);
$course_id = Database::insert_id();
$course_id = Database::insert_id();
if ($course_id) {
$sort = api_max_sort_value('0', api_get_user_id());

@ -34,7 +34,7 @@ class Database {
*/
/**
* Returns the name of the main database.
* Returns the name of the main database.
*/
public static function get_main_database() {
global $_configuration;
@ -42,7 +42,7 @@ class Database {
}
/**
* Returns the name of the statistics database.
* Returns the name of the statistics database.
* @todo use main_database
*/
public static function get_statistic_database() {
@ -51,7 +51,7 @@ class Database {
}
/**
* Returns the name of the database where all the personal stuff of the user is stored
* Returns the name of the database where all the personal stuff of the user is stored
* @todo use main_database
*/
public static function get_user_personal_database() {
@ -60,7 +60,7 @@ class Database {
}
/**
* Returns the name of the current course database.
* Returns the name of the current course database.
* @return mixed Glued database name of false if undefined
*/
public static function get_current_course_database() {
@ -72,7 +72,7 @@ class Database {
}
/**
* Returns the glued name of the current course database.
* Returns the glued name of the current course database.
* @return mixed Glued database name of false if undefined
*/
public static function get_current_course_glued_database() {
@ -84,11 +84,11 @@ class Database {
}
/**
* The glue is the string needed between database and table.
* The trick is: in multiple databases, this is a period (with backticks).
* In single database, this can be e.g. an underscore so we just fake
* there are multiple databases and the code can be written independent
* of the single / multiple database setting.
* The glue is the string needed between database and table.
* The trick is: in multiple databases, this is a period (with backticks).
* In single database, this can be e.g. an underscore so we just fake
* there are multiple databases and the code can be written independent
* of the single / multiple database setting.
*/
public static function get_database_glue() {
global $_configuration;
@ -96,11 +96,11 @@ class Database {
}
/**
* Returns the database prefix.
* All created COURSE databases are prefixed with this string.
* Returns the database prefix.
* All created COURSE databases are prefixed with this string.
*
* TIP: This can be convenient if you have multiple system installations
* on the same physical server.
* TIP: This can be convenient if you have multiple system installations
* on the same physical server.
*/
public static function get_database_name_prefix() {
global $_configuration;
@ -108,10 +108,10 @@ class Database {
}
/**
* Returns the course table prefix for single database.
* Not certain exactly when this is used.
* Do research.
* It's used in local.inc.php.
* Returns the course table prefix for single database.
* Not certain exactly when this is used.
* Do research.
* It's used in local.inc.php.
*/
public static function get_course_table_prefix() {
global $_configuration;
@ -169,7 +169,7 @@ class Database {
echo "<h3>Dev Message: get_course_table() doesn't have a 2nd parameter</h3>";
//exit;
}
return self::format_table_name(self::get_main_database(), DB_COURSE_PREFIX.$short_table_name);
return self::format_table_name(self::get_main_database(), DB_COURSE_PREFIX.$short_table_name);
//return self::format_glued_course_table_name(self::fix_database_parameter($database_name), $short_table_name);
}
@ -207,8 +207,8 @@ class Database {
*/
/**
* @return a list (array) of all courses.
* @todo shouldn't this be in the course.lib.php script?
* @return a list (array) of all courses.
* @todo shouldn't this be in the course.lib.php script?
*/
public static function get_course_list() {
$table = self::get_main_table(TABLE_MAIN_COURSE);
@ -216,10 +216,10 @@ class Database {
}
/**
* Returns an array with all database fields for the specified course.
* Returns an array with all database fields for the specified course.
*
* @param string The real (system) course code (main course table ID)
* @todo shouldn't this be in the course.lib.php script?
* @param string The real (system) course code (main course table ID)
* @todo shouldn't this be in the course.lib.php script?
*/
public static function get_course_info($course_code) {
$course_code = self::escape_string($course_code);
@ -263,19 +263,19 @@ class Database {
}
/**
* This method creates an abstraction layer between database field names
* and field names expected in code.
* This method creates an abstraction layer between database field names
* and field names expected in code.
*
* This approach helps when changing database names.
* It's also useful now to get rid of the 'franglais'.
* This approach helps when changing database names.
* It's also useful now to get rid of the 'franglais'.
*
* @todo add more array entries to abstract course info from field names
* @author Roan Embrechts
* @todo add more array entries to abstract course info from field names
* @author Roan Embrechts
*
* @todo What's the use of this method. I think this is better removed.
* There should be consistency in the variable names and the
* @todo What's the use of this method. I think this is better removed.
* There should be consistency in the variable names and the
* use throughout the scripts
* for the database name we should consistently use or db_name
* for the database name we should consistently use or db_name
* or database (db_name probably being the better one)
*/
public static function generate_abstract_course_field_names($result_array) {
@ -316,25 +316,25 @@ class Database {
}
/**
* This method creates an abstraction layer between database field names
* and field names expected in code.
* This method creates an abstraction layer between database field names
* and field names expected in code.
*
* This helps when changing database names.
* It's also useful now to get rid of the 'franglais'.
* This helps when changing database names.
* It's also useful now to get rid of the 'franglais'.
*
* @todo add more array entries to abstract user info from field names
* @author Roan Embrechts
* @author Patrick Cool
* @todo add more array entries to abstract user info from field names
* @author Roan Embrechts
* @author Patrick Cool
*
* @todo what's the use of this function. I think this is better removed.
* There should be consistency in the variable names and the use throughout the scripts
* @todo what's the use of this function. I think this is better removed.
* There should be consistency in the variable names and the use throughout the scripts
*/
public static function generate_abstract_user_field_names($result_array) {
$result_array['firstName'] = $result_array['firstname'];
$result_array['lastName'] = $result_array['lastname'];
$result_array['mail'] = $result_array['email'];
#$result_array['picture_uri'] = $result_array['picture_uri'];
#$result_array ['user_id'] = $result_array['user_id'];
$result_array['firstName'] = $result_array['firstname'];
$result_array['lastName'] = $result_array['lastname'];
$result_array['mail'] = $result_array['email'];
#$result_array['picture_uri'] = $result_array['picture_uri'];
#$result_array ['user_id'] = $result_array['user_id'];
return $result_array;
}
@ -355,8 +355,8 @@ class Database {
/**
* Returns the number of affected rows in the last database operation.
* @param resource $connection (optional) The database server connection, for detailed description see the method query().
* @return int Returns the number of affected rows on success, and -1 if the last query failed.
* @param resource $connection (optional) The database server connection, for detailed description see the method query().
* @return int Returns the number of affected rows on success, and -1 if the last query failed.
*/
public static function affected_rows($connection = null) {
return self::use_default_connection($connection) ? mysql_affected_rows() : mysql_affected_rows($connection);
@ -364,8 +364,8 @@ class Database {
/**
* Closes non-persistent database connection.
* @param resource $connection (optional) The database server connection, for detailed description see the method query().
* @return bool Returns TRUE on success or FALSE on failure.
* @param resource $connection (optional) The database server connection, for detailed description see the method query().
* @return bool Returns TRUE on success or FALSE on failure.
*/
public static function close($connection = null) {
return self::use_default_connection($connection) ? mysql_close() : mysql_close($connection);
@ -373,8 +373,8 @@ class Database {
/**
* Opens a connection to a database server.
* @param array $parameters (optional) An array that contains the necessary parameters for accessing the server.
* @return resource/boolean Returns a database connection on success or FALSE on failure.
* @param array $parameters (optional) An array that contains the necessary parameters for accessing the server.
* @return resource/boolean Returns a database connection on success or FALSE on failure.
* Note: Currently the array could contain MySQL-specific parameters:
* $parameters['server'], $parameters['username'], $parameters['password'],
* $parameters['new_link'], $parameters['client_flags'], $parameters['persistent'].
@ -417,7 +417,7 @@ class Database {
/**
* Returns error number from the last operation done on the database server.
* @param resource $connection (optional) The database server connection,
* @param resource $connection (optional) The database server connection,
* for detailed description see the method query().
* @return int Returns the error number from the last database (operation, or 0 (zero) if no error occurred.
*/
@ -427,7 +427,7 @@ class Database {
/**
* Returns error text from the last operation done on the database server.
* @param resource $connection (optional) The database server connection, for detailed description see the method query().
* @param resource $connection (optional) The database server connection, for detailed description see the method query().
* @return string Returns the error text from the last database operation, or '' (empty string) if no error occurred.
*/
public static function error($connection = null) {
@ -447,9 +447,9 @@ class Database {
/**
* Escapes a string to insert into the database as text
* @param string The string to escape
* @param resource $connection (optional) The database server connection, for detailed description see the method query().
* @return string The escaped string
* @param string The string to escape
* @param resource $connection (optional) The database server connection, for detailed description see the method query().
* @return string The escaped string
* @author Yannick Warnier <yannick.warnier@dokeos.com>
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
*/
@ -465,21 +465,21 @@ class Database {
/**
* Gets the array from a SQL result (as returned by Database::query) - help achieving database independence
* @param resource The result from a call to sql_query (e.g. Database::query)
* @param string Optional: "ASSOC","NUM" or "BOTH", as the constant used in mysql_fetch_array.
* @return array Array of results as returned by php
* @param resource The result from a call to sql_query (e.g. Database::query)
* @param string Optional: "ASSOC","NUM" or "BOTH", as the constant used in mysql_fetch_array.
* @return array Array of results as returned by php
* @author Yannick Warnier <yannick.warnier@beeznest.com>
*/
public static function fetch_array($result, $option = 'BOTH') {
if ($result === false) { return array(); }
if ($result === false) { return array(); }
return $option == 'ASSOC' ? mysql_fetch_array($result, MYSQL_ASSOC) : ($option == 'NUM' ? mysql_fetch_array($result, MYSQL_NUM) : mysql_fetch_array($result));
}
/**
* Gets an associative array from a SQL result (as returned by Database::query).
* This method is equivalent to calling Database::fetch_array() with 'ASSOC' value for the optional second parameter.
* @param resource $result The result from a call to sql_query (e.g. Database::query).
* @return array Returns an associative array that corresponds to the fetched row and moves the internal data pointer ahead.
* @param resource $result The result from a call to sql_query (e.g. Database::query).
* @return array Returns an associative array that corresponds to the fetched row and moves the internal data pointer ahead.
*/
public static function fetch_assoc($result) {
return mysql_fetch_assoc($result);
@ -487,11 +487,11 @@ class Database {
/**
* Gets the next row of the result of the SQL query (as returned by Database::query) in an object form
* @param resource The result from a call to sql_query (e.g. Database::query)
* @param string Optional class name to instanciate
* @param array Optional array of parameters
* @return object Object of class StdClass or the required class, containing the query result row
* @author Yannick Warnier <yannick.warnier@dokeos.com>
* @param resource The result from a call to sql_query (e.g. Database::query)
* @param string Optional class name to instanciate
* @param array Optional array of parameters
* @return object Object of class StdClass or the required class, containing the query result row
* @author Yannick Warnier <yannick.warnier@dokeos.com>
*/
public static function fetch_object($result, $class = null, $params = null) {
return !empty($class) ? (is_array($params) ? mysql_fetch_object($result, $class, $params) : mysql_fetch_object($result, $class)) : mysql_fetch_object($result);
@ -499,8 +499,8 @@ class Database {
/**
* Gets the array from a SQL result (as returned by Database::query) - help achieving database independence
* @param resource The result from a call to sql_query (see Database::query()).
* @return array Array of results as returned by php (mysql_fetch_row)
* @param resource The result from a call to sql_query (see Database::query()).
* @return array Array of results as returned by php (mysql_fetch_row)
*/
public static function fetch_row($result) {
return mysql_fetch_row($result);
@ -508,7 +508,7 @@ class Database {
/**
* Frees all the memory associated with the provided result identifier.
* @return bool Returns TRUE on success or FALSE on failure.
* @return bool Returns TRUE on success or FALSE on failure.
* Notes: Use this method if you are concerned about how much memory is being used for queries that return large result sets.
* Anyway, all associated result memory is automatically freed at the end of the script's execution.
*/
@ -518,7 +518,7 @@ class Database {
/**
* Returns the database client library version.
* @return strung Returns a string that represents the client library version.
* @return strung Returns a string that represents the client library version.
*/
public static function get_client_info() {
return mysql_get_client_info();
@ -527,9 +527,9 @@ class Database {
/**
* Returns a list of databases created on the server. The list may contain all of the
* available database names or filtered database names by using a pattern.
* @param string $pattern (optional) A pattern for filtering database names as if it was needed for the SQL's LIKE clause, for example 'chamilo_%'.
* @param resource $connection (optional) The database server connection, for detailed description see the method query().
* @return array Returns in an array the retrieved list of database names.
* @param string $pattern (optional) A pattern for filtering database names as if it was needed for the SQL's LIKE clause, for example 'chamilo_%'.
* @param resource $connection (optional) The database server connection, for detailed description see the method query().
* @return array Returns in an array the retrieved list of database names.
*/
public static function get_databases($pattern = '', $connection = null) {
$result = array();
@ -543,13 +543,13 @@ class Database {
/**
* Returns a list of the fields that a given table contains. The list may contain all of the available field names or filtered field names by using a pattern.
* By using a special option, this method is able to return an indexed list of fields' properties, where field names are keys.
* @param string $table This is the examined table.
* @param string $pattern (optional) A pattern for filtering field names as if it was needed for the SQL's LIKE clause, for example 'column_%'.
* @param string $database (optional) The name of the targeted database. If it is omited, the current database is assumed, see Database::select_db().
* @param bool $including_properties (optional) When this option is true, the returned result has the followong format:
* array(field_name_1 => array(0 => property_1, 1 => property_2, ...), fieald_name_2 => array(0 => property_1, ...), ...)
* @param resource $connection (optional) The database server connection, for detailed description see the method query().
* @return array Returns in an array the retrieved list of field names.
* @param string $table This is the examined table.
* @param string $pattern (optional) A pattern for filtering field names as if it was needed for the SQL's LIKE clause, for example 'column_%'.
* @param string $database (optional) The name of the targeted database. If it is omited, the current database is assumed, see Database::select_db().
* @param bool $including_properties (optional) When this option is true, the returned result has the followong format:
* array(field_name_1 => array(0 => property_1, 1 => property_2, ...), fieald_name_2 => array(0 => property_1, ...), ...)
* @param resource $connection (optional) The database server connection, for detailed description see the method query().
* @return array Returns in an array the retrieved list of field names.
*/
public static function get_fields($table, $pattern = '', $database = '', $including_properties = false, $connection = null) {
$result = array();
@ -577,8 +577,8 @@ class Database {
/**
* Returns information about the type of the current connection and the server host name.
* @param resource $connection (optional) The database server connection, for detailed description see the method query().
* @return string/boolean Returns string data on success or FALSE on failure.
* @param resource $connection (optional) The database server connection, for detailed description see the method query().
* @return string/boolean Returns string data on success or FALSE on failure.
*/
public static function get_host_info($connection = null) {
return self::use_default_connection($connection) ? mysql_get_host_info() : mysql_get_host_info($connection);
@ -586,8 +586,8 @@ class Database {
/**
* Retrieves database client/server protocol version.
* @param resource $connection (optional) The database server connection, for detailed description see the method query().
* @return int/boolean Returns the protocol version on success or FALSE on failure.
* @param resource $connection (optional) The database server connection, for detailed description see the method query().
* @return int/boolean Returns the protocol version on success or FALSE on failure.
*/
public static function get_proto_info($connection = null) {
return self::use_default_connection($connection) ? mysql_get_proto_info() : mysql_get_proto_info($connection);
@ -595,8 +595,8 @@ class Database {
/**
* Retrieves the database server version.
* @param resource $connection (optional) The database server connection, for detailed description see the method query().
* @return string/boolean Returns the MySQL server version on success or FALSE on failure.
* @param resource $connection (optional) The database server connection, for detailed description see the method query().
* @return string/boolean Returns the MySQL server version on success or FALSE on failure.
*/
public static function get_server_info($connection = null) {
return self::use_default_connection($connection) ? mysql_get_server_info() : mysql_get_server_info($connection);
@ -605,10 +605,10 @@ class Database {
/**
* Returns a list of tables within a database. The list may contain all of the
* available table names or filtered table names by using a pattern.
* @param string $database (optional) The name of the examined database. If it is omited, the current database is assumed, see Database::select_db().
* @param string $pattern (optional) A pattern for filtering table names as if it was needed for the SQL's LIKE clause, for example 'access_%'.
* @param resource $connection (optional) The database server connection, for detailed description see the method query().
* @return array Returns in an array the retrieved list of table names.
* @param string $database (optional) The name of the examined database. If it is omited, the current database is assumed, see Database::select_db().
* @param string $pattern (optional) A pattern for filtering table names as if it was needed for the SQL's LIKE clause, for example 'access_%'.
* @param resource $connection (optional) The database server connection, for detailed description see the method query().
* @return array Returns in an array the retrieved list of table names.
*/
public static function get_tables($database = '', $pattern = '', $connection = null) {
$result = array();
@ -629,8 +629,8 @@ class Database {
/**
* Gets the ID of the last item inserted into the database
* This should be updated to use ADODB at some point
* @param resource $connection (optional) The database server connection, for detailed description see the method query().
* @return int The last ID as returned by the DB function
* @param resource $connection (optional) The database server connection, for detailed description see the method query().
* @return int The last ID as returned by the DB function
*/
public static function insert_id($connection = null) {
return self::use_default_connection($connection) ? mysql_insert_id() : mysql_insert_id($connection);
@ -638,8 +638,8 @@ class Database {
/**
* Gets the number of rows from the last query result - help achieving database independence
* @param resource The result
* @return integer The number of rows contained in this result
* @param resource The result
* @return integer The number of rows contained in this result
* @author Yannick Warnier <yannick.warnier@dokeos.com>
**/
public static function num_rows($result) {
@ -649,10 +649,10 @@ class Database {
/**
* Acts as the relative *_result() function of most DB drivers and fetches a
* specific line and a field
* @param resource The database resource to get data from
* @param integer The row number
* @param string Optional field name or number
* @return mixed One cell of the result, or FALSE on error
* @param resource The database resource to get data from
* @param integer The row number
* @param string Optional field name or number
* @return mixed One cell of the result, or FALSE on error
*/
public static function result($resource, $row, $field = '') {
return self::num_rows($resource) > 0 ? (!empty($field) ? mysql_result($resource, $row, $field) : mysql_result($resource, $row)) : null;
@ -663,14 +663,14 @@ class Database {
* Documentation has been added by Arthur Portugal
* Some adaptations have been implemented by Ivan Tcholakov, 2009, 2010
* @author Olivier Brouckaert
* @param string $query The SQL query
* @param resource $connection (optional) The database server (MySQL) connection.
* If it is not specified, the connection opened by mysql_connect() is assumed.
* If no connection is found, the server will try to create one as if mysql_connect() was called with no arguments.
* If no connection is found or established, an E_WARNING level error is generated.
* @param string $file (optional) On error it shows the file in which the error has been trigerred (use the "magic" constant __FILE__ as input parameter)
* @param string $line (optional) On error it shows the line in which the error has been trigerred (use the "magic" constant __LINE__ as input parameter)
* @return resource The returned result from the query
* @param string $query The SQL query
* @param resource $connection (optional) The database server (MySQL) connection.
* If it is not specified, the connection opened by mysql_connect() is assumed.
* If no connection is found, the server will try to create one as if mysql_connect() was called with no arguments.
* If no connection is found or established, an E_WARNING level error is generated.
* @param string $file (optional) On error it shows the file in which the error has been trigerred (use the "magic" constant __FILE__ as input parameter)
* @param string $line (optional) On error it shows the line in which the error has been trigerred (use the "magic" constant __LINE__ as input parameter)
* @return resource The returned result from the query
* Note: The parameter $connection could be skipped. Here are examples of this method usage:
* Database::query($query);
* $result = Database::query($query);
@ -695,8 +695,8 @@ class Database {
//Check if the table contains a c_ (means a course id)
if (api_get_setting('server_type')==='test' && strpos($query, 'c_')) {
//Check if the table contains inner joins
if (
//Check if the table contains inner joins
if (
strpos($query, 'assoc_handle') === false &&
strpos($query, 'olpc_peru_filter') === false &&
strpos($query, 'allow_public_certificates') === false &&
@ -716,20 +716,20 @@ class Database {
strpos($query, 'chamilo_electric_blue') === false &&
strpos($query, 'wcag_anysurfer_public_pages') === false &&
strpos($query, 'specific_field') === false &&
strpos($query, 'down_doc_path') === false &&
strpos($query, 'INNER JOIN') === false &&
strpos($query, 'inner join') === false &&
strpos($query, 'left join') === false &&
strpos($query, 'LEFT JOIN') === false &&
strpos($query, 'insert') === false &&
strpos($query, 'INSERT') === false &&
strpos($query, 'ALTER') === false &&
strpos($query, 'alter') === false &&
strpos($query, 'c_id') === false &&
strpos($query, 'create table') === false &&
strpos($query, 'CREATE TABLE') === false &&
strpos($query, 'AUTO_INCREMENT') === false
) {
strpos($query, 'down_doc_path') === false &&
strpos($query, 'INNER JOIN') === false &&
strpos($query, 'inner join') === false &&
strpos($query, 'left join') === false &&
strpos($query, 'LEFT JOIN') === false &&
strpos($query, 'insert') === false &&
strpos($query, 'INSERT') === false &&
strpos($query, 'ALTER') === false &&
strpos($query, 'alter') === false &&
strpos($query, 'c_id') === false &&
strpos($query, 'create table') === false &&
strpos($query, 'CREATE TABLE') === false &&
strpos($query, 'AUTO_INCREMENT') === false
) {
//@todo remove this
echo '<pre>';
$message = '<h4>Dev message: please add the c_id field in this query or report this error in support.chamilo.org </h4>';
@ -737,7 +737,7 @@ class Database {
echo $message;
echo '</pre>';
//error_log($message);
}
}
}
if (!($result = $use_default_connection ? mysql_query($query) : mysql_query($query, $connection))) {
@ -816,9 +816,9 @@ class Database {
/**
* Selects a database.
* @param string $database_name The name of the database that is to be selected.
* @param resource $connection (optional) The database server connection, for detailed description see the method query().
* @return bool Returns TRUE on success or FALSE on failure.
* @param string $database_name The name of the database that is to be selected.
* @param resource $connection (optional) The database server connection, for detailed description see the method query().
* @return bool Returns TRUE on success or FALSE on failure.
*/
public static function select_db($database_name, $connection = null) {
return self::use_default_connection($connection) ? mysql_select_db($database_name) : mysql_select_db($database_name, $connection);
@ -848,8 +848,8 @@ class Database {
/**
* Checks whether a given encoding is supported by the database server.
* @param string $encoding The encoding (a system conventional id, for example 'UTF-8') to be checked.
* @return bool Returns a boolean value as a check-result.
* @param string $encoding The encoding (a system conventional id, for example 'UTF-8') to be checked.
* @return bool Returns a boolean value as a check-result.
* @author Ivan Tcholakov
*/
public static function is_encoding_supported($encoding) {
@ -869,9 +869,9 @@ class Database {
* Constructs a SQL clause about default character set and default collation for newly created databases and tables.
* Example: Database::make_charset_clause('UTF-8', 'bulgarian') returns
* DEFAULT CHARACTER SET `utf8` DEFAULT COLLATE `utf8_general_ci`
* @param string $encoding (optional) The default database/table encoding (a system conventional id) to be used.
* @param string $language (optional) Language (a system conventional id) used for choosing language sensitive collation (if it is possible).
* @return string Returns the constructed SQL clause or empty string if $encoding is not correct or is not supported.
* @param string $encoding (optional) The default database/table encoding (a system conventional id) to be used.
* @param string $language (optional) Language (a system conventional id) used for choosing language sensitive collation (if it is possible).
* @return string Returns the constructed SQL clause or empty string if $encoding is not correct or is not supported.
* @author Ivan Tcholakov
*/
public static function make_charset_clause($encoding = null, $language = null) {
@ -896,8 +896,8 @@ class Database {
/**
* Converts an encoding identificator to MySQL-specific encoding identifictor,
* i.e. 'UTF-8' --> 'utf8'.
* @param string $encoding The conventional encoding identificator.
* @return string Returns the corresponding MySQL-specific encoding identificator if any, otherwise returns NULL.
* @param string $encoding The conventional encoding identificator.
* @return string Returns the corresponding MySQL-specific encoding identificator if any, otherwise returns NULL.
* @author Ivan Tcholakov
*/
public static function to_db_encoding($encoding) {
@ -918,8 +918,8 @@ class Database {
/**
* Converts a MySQL-specific encoding identifictor to conventional encoding identificator,
* i.e. 'utf8' --> 'UTF-8'.
* @param string $encoding The MySQL-specific encoding identificator.
* @return string Returns the corresponding conventional encoding identificator if any, otherwise returns NULL.
* @param string $encoding The MySQL-specific encoding identificator.
* @return string Returns the corresponding conventional encoding identificator if any, otherwise returns NULL.
* @author Ivan Tcholakov
*/
public static function from_db_encoding($db_encoding) {
@ -939,9 +939,9 @@ class Database {
/**
* Chooses the default MySQL-specific collation from given encoding and language.
* @param string $encoding A conventional encoding id, i.e. 'UTF-8'
* @param string $language (optional) A conventional for the system language id, i.e. 'bulgarian'. If it is empty, the chosen collation is the default server value corresponding to the given encoding.
* @return string Returns a suitable default collation, for example 'utf8_general_ci', or NULL if collation was not found.
* @param string $encoding A conventional encoding id, i.e. 'UTF-8'
* @param string $language (optional) A conventional for the system language id, i.e. 'bulgarian'. If it is empty, the chosen collation is the default server value corresponding to the given encoding.
* @return string Returns a suitable default collation, for example 'utf8_general_ci', or NULL if collation was not found.
* @author Ivan Tcholakov
*/
public static function to_db_collation($encoding, $language = null) {
@ -978,18 +978,18 @@ class Database {
*/
/**
* Glues a course database.
* glue format from local.inc.php.
* Glues a course database.
* glue format from local.inc.php.
*/
private static function glue_course_database_name($database_name) {
return self::get_course_table_prefix().$database_name.self::get_database_glue();
}
/**
* @param string $database_name, can be empty to use current course db
* @param string $database_name, can be empty to use current course db
*
* @return the glued parameter if it is not empty,
* or the current course database (glued) if the parameter is empty.
* @return the glued parameter if it is not empty,
* or the current course database (glued) if the parameter is empty.
*/
private static function fix_database_parameter($database_name) {
if (empty($database_name)) {
@ -1000,18 +1000,18 @@ class Database {
}
/**
* Structures a course database and table name to ready them
* for querying. The course database parameter is considered glued:
* e.g. COURSE001`.`
* Structures a course database and table name to ready them
* for querying. The course database parameter is considered glued:
* e.g. COURSE001`.`
*/
private static function format_glued_course_table_name($database_name_with_glue, $table) {
return '`'.$database_name_with_glue.$table.'`';
}
/**
* Structures a database and table name to ready them
* for querying. The database parameter is considered not glued,
* just plain e.g. COURSE001
* Structures a database and table name to ready them
* for querying. The database parameter is considered not glued,
* just plain e.g. COURSE001
*/
private static function format_table_name($database, $table) {
global $_configuration;
@ -1028,9 +1028,9 @@ class Database {
* checking whether the input parameter $connection actually has been provided.
* If the input parameter connection is not a resource or if it is not FALSE (in case of error)
* then the default opened connection should be used by the called method.
* @param resource/boolean $connection The checked parameter $connection.
* @return boolean TRUE means that calling method should use the default connection.
* FALSE means that (valid) parameter $connection has been provided and it should be used.
* @param resource/boolean $connection The checked parameter $connection.
* @return boolean TRUE means that calling method should use the default connection.
* FALSE means that (valid) parameter $connection has been provided and it should be used.
*/
private static function use_default_connection($connection) {
return !is_resource($connection) && $connection !== false;
@ -1039,8 +1039,8 @@ class Database {
/**
* This private method tackles the XSS injections. It is similar to Security::remove_XSS() and works always,
* including the time of initialization when the class Security has not been loaded yet.
* @param string The input variable to be filtered from XSS, in this class it is expected to be a string.
* @return string Returns the filtered string as a result.
* @param string The input variable to be filtered from XSS, in this class it is expected to be a string.
* @return string Returns the filtered string as a result.
*/
private static function remove_XSS(& $var) {
return class_exists('Security') ? Security::remove_XSS($var) : @htmlspecialchars($var, ENT_QUOTES, api_get_system_encoding());
@ -1099,9 +1099,9 @@ class Database {
/**
* Constructs a MySQL-specific collation and checks whether it is supported by the database server.
* @param string $db_encoding A MySQL-specific encoding id, i.e. 'utf8'
* @param string $language A MySQL-compatible language id, i.e. 'bulgarian'
* @return string Returns a suitable default collation, for example 'utf8_general_ci', or NULL if collation was not found.
* @param string $db_encoding A MySQL-specific encoding id, i.e. 'utf8'
* @param string $language A MySQL-compatible language id, i.e. 'bulgarian'
* @return string Returns a suitable default collation, for example 'utf8_general_ci', or NULL if collation was not found.
* @author Ivan Tcholakov
*/
private static function check_db_collation($db_encoding, $language) {
@ -1147,7 +1147,7 @@ class Database {
$sql = 'INSERT INTO '.$table_name.' ('.implode(',',$params).') VALUES ('.implode(',',$values).')';
self::query($sql);
if ($show_query) {
var_dump($sql);
var_dump($sql);
}
return self::insert_id();
}
@ -1320,9 +1320,9 @@ class Database {
/**
* Experimental useful database update
* @param string table name use Database::get_main_table
* @param array array with values to updates, keys are the fields in the database: Example: $params['name'] = 'Julio'; $params['lastname'] = 'Montoya';
* @param array where conditions i.e array('id = ?' =>'4')
* @param string table name use Database::get_main_table
* @param array array with values to updates, keys are the fields in the database: Example: $params['name'] = 'Julio'; $params['lastname'] = 'Montoya';
* @param array where conditions i.e array('id = ?' =>'4')
* @todo lot of stuff to do here
*/
public static function update($table_name, $attributes, $where_conditions = array(), $show_query = false) {

@ -22,8 +22,8 @@ require_once api_get_path(LIBRARY_PATH).'phpmailer/class.phpmailer.php';
*
* @author Bert Vanderkimpen ICT&O UGent
*
* @param recipient_name name of recipient
* @param recipient_email email of recipient
* @param recipient_name name of recipient
* @param recipient_email email of recipient
* @param message email body
* @param subject email subject
* @return returns true if mail was sent
@ -32,7 +32,7 @@ require_once api_get_path(LIBRARY_PATH).'phpmailer/class.phpmailer.php';
*/
function api_mail($recipient_name, $recipient_email, $subject, $message, $sender_name = '',
$sender_email = '', $extra_headers = '', $additional_parameters = array()) {
api_mail_html($recipient_name, $recipient_email, $subject, $message, $sender_name,
api_mail_html($recipient_name, $recipient_email, $subject, $message, $sender_name,
$sender_email, $extra_headers, null, null, $additional_parameters);
}
@ -113,14 +113,14 @@ function api_mail_html($recipient_name, $recipient_email, $subject, $message, $s
// Send embedded image.
if ($embedded_image) {
// Get all images html inside content.
// Get all images html inside content.
preg_match_all("/<img\s+.*?src=[\"\']?([^\"\' >]*)[\"\']?[^>]*>/i", $message, $m);
// Prepare new tag images.
$new_images_html = array();
$i = 1;
if (!empty($m[1])) {
foreach ($m[1] as $image_path) {
$real_path = realpath($image_path);
foreach ($m[1] as $image_path) {
$real_path = realpath($image_path);
$filename = basename($image_path);
$image_cid = $filename.'_'.$i;
$encoding = 'base64';
@ -128,17 +128,17 @@ function api_mail_html($recipient_name, $recipient_email, $subject, $message, $s
$mail->AddEmbeddedImage($real_path, $image_cid, $filename, $encoding, $image_type);
$new_images_html[] = '<img src="cid:'.$image_cid.'" />';
$i++;
}
}
// Replace origin image for new embedded image html.
$x = 0;
if (!empty($m[0])) {
foreach ($m[0] as $orig_img) {
$message = str_replace($orig_img, $new_images_html[$x], $message);
$x++;
}
}
}
}
// Replace origin image for new embedded image html.
$x = 0;
if (!empty($m[0])) {
foreach ($m[0] as $orig_img) {
$message = str_replace($orig_img, $new_images_html[$x], $message);
$x++;
}
}
}
$message = str_replace(array("\n\r", "\n", "\r"), '<br />', $message);
$mail->Body = '<html><head></head><body>'.$message.'</body></html>';

@ -153,24 +153,24 @@ define('LOG_COURSE_DELETE', 'course_deleted');
define('LOG_COURSE_CREATE', 'course_created');
// @todo replace 'soc_gr' with social_group
define('LOG_GROUP_PORTAL_CREATED', 'soc_gr_created');
define('LOG_GROUP_PORTAL_UPDATED', 'soc_gr_updated');
define('LOG_GROUP_PORTAL_DELETED', 'soc_gr_deleted');
define('LOG_GROUP_PORTAL_USER_DELETE_ALL', 'soc_gr_delete_users');
define('LOG_GROUP_PORTAL_CREATED', 'soc_gr_created');
define('LOG_GROUP_PORTAL_UPDATED', 'soc_gr_updated');
define('LOG_GROUP_PORTAL_DELETED', 'soc_gr_deleted');
define('LOG_GROUP_PORTAL_USER_DELETE_ALL', 'soc_gr_delete_users');
define('LOG_GROUP_PORTAL_ID', 'soc_gr_portal_id');
define('LOG_GROUP_PORTAL_REL_USER_ARRAY', 'soc_gr_user_array');
define('LOG_GROUP_PORTAL_ID', 'soc_gr_portal_id');
define('LOG_GROUP_PORTAL_REL_USER_ARRAY', 'soc_gr_user_array');
define('LOG_GROUP_PORTAL_USER_SUBSCRIBED', 'soc_gr_u_subs');
define('LOG_GROUP_PORTAL_USER_UNSUBSCRIBED', 'soc_gr_u_unsubs');
define('LOG_GROUP_PORTAL_USER_UPDATE_ROLE', 'soc_gr_update_role');
define('LOG_GROUP_PORTAL_USER_SUBSCRIBED', 'soc_gr_u_subs');
define('LOG_GROUP_PORTAL_USER_UNSUBSCRIBED', 'soc_gr_u_unsubs');
define('LOG_GROUP_PORTAL_USER_UPDATE_ROLE', 'soc_gr_update_role');
define('LOG_USER_DELETE', 'user_deleted');
define('LOG_USER_CREATE', 'user_created');
define('LOG_USER_ENABLE', 'user_enable');
define('LOG_USER_DISABLE', 'user_disable');
define('LOG_USER_FIELD_CREATE', 'user_field_created');
define('LOG_USER_FIELD_DELETE', 'user_field_deleted');
define('LOG_USER_FIELD_CREATE', 'user_field_created');
define('LOG_USER_FIELD_DELETE', 'user_field_deleted');
define('LOG_SESSION_CREATE', 'session_created');
define('LOG_SESSION_DELETE', 'session_deleted');
define('LOG_SESSION_CATEGORY_CREATE', 'session_cat_created'); //changed in 1.9.8
@ -200,7 +200,7 @@ define('LOG_COURSE_CODE', 'course_code');
define('LOG_COURSE_ID', 'course_id');
define('LOG_USER_ID', 'user_id');
define('LOG_USER_OBJECT', 'user_object');
define('LOG_USER_FIELD_VARIABLE', 'user_field_variable');
define('LOG_USER_FIELD_VARIABLE', 'user_field_variable');
define('LOG_SESSION_ID', 'session_id');
define('LOG_SESSION_CATEGORY_ID', 'session_category_id');
define('LOG_CONFIGURATION_SETTINGS_CATEGORY', 'settings_category');
@ -288,33 +288,33 @@ define('COURSE_RELATION_TYPE_RRHH', 1);
define('SESSION_RELATION_TYPE_RRHH', 1);
//User image sizes
define('USER_IMAGE_SIZE_ORIGINAL', 1);
define('USER_IMAGE_SIZE_BIG', 2);
define('USER_IMAGE_SIZE_MEDIUM', 3);
define('USER_IMAGE_SIZE_ORIGINAL', 1);
define('USER_IMAGE_SIZE_BIG', 2);
define('USER_IMAGE_SIZE_MEDIUM', 3);
define('USER_IMAGE_SIZE_SMALL', 4);
// Relation type between users
define('USER_UNKNOW', 0);
define('USER_RELATION_TYPE_UNKNOW', 1);
define('USER_RELATION_TYPE_PARENT', 2); // should be deprecated is useless
define('USER_RELATION_TYPE_FRIEND', 3);
define('USER_RELATION_TYPE_GOODFRIEND', 4); // should be deprecated is useless
define('USER_RELATION_TYPE_ENEMY', 5); // should be deprecated is useless
define('USER_RELATION_TYPE_DELETED', 6);
define('USER_RELATION_TYPE_RRHH', 7);
define('USER_UNKNOW', 0);
define('USER_RELATION_TYPE_UNKNOW', 1);
define('USER_RELATION_TYPE_PARENT', 2); // should be deprecated is useless
define('USER_RELATION_TYPE_FRIEND', 3);
define('USER_RELATION_TYPE_GOODFRIEND', 4); // should be deprecated is useless
define('USER_RELATION_TYPE_ENEMY', 5); // should be deprecated is useless
define('USER_RELATION_TYPE_DELETED', 6);
define('USER_RELATION_TYPE_RRHH', 7);
//Gradebook link constants
//Please do not change existing values, they are used in the database !
define('LINK_EXERCISE', 1);
define('LINK_DROPBOX', 2);
define('LINK_STUDENTPUBLICATION', 3);
define('LINK_EXERCISE', 1);
define('LINK_DROPBOX', 2);
define('LINK_STUDENTPUBLICATION', 3);
define('LINK_LEARNPATH', 4);
define('LINK_FORUM_THREAD', 5);
define('LINK_FORUM_THREAD', 5);
//define('LINK_WORK',6);
define('LINK_ATTENDANCE', 7);
define('LINK_SURVEY', 8);
define('LINK_HOTPOTATOES', 9);
define('LINK_ATTENDANCE', 7);
define('LINK_SURVEY', 8);
define('LINK_HOTPOTATOES', 9);
//From display.lib.php
@ -896,37 +896,37 @@ function api_protect_course_script($print_headers = false, $allow_session_admins
return true;
}
if (api_is_platform_admin($allow_session_admins)) {
return true;
return true;
}
$course_info = api_get_course_info();
if (isset($course_info) && isset($course_info['visibility'])) {
switch ($course_info['visibility']) {
default:
case COURSE_VISIBILITY_CLOSED: //Completely closed: the course is only accessible to the teachers. - 0
if (api_get_user_id() && !api_is_anonymous() && $is_allowed_in_course) {
$is_visible = true;
}
break;
case COURSE_VISIBILITY_REGISTERED: //Private - access authorized to course members only - 1
if (api_get_user_id() && !api_is_anonymous() && $is_allowed_in_course) {
$is_visible = true;
}
break;
case COURSE_VISIBILITY_OPEN_PLATFORM: // Open - access allowed for users registered on the platform - 2
if (api_get_user_id() && !api_is_anonymous()) {
$is_visible = true;
}
break;
case COURSE_VISIBILITY_OPEN_WORLD: //Open - access allowed for the whole world - 3
$is_visible = true;
break;
switch ($course_info['visibility']) {
default:
case COURSE_VISIBILITY_CLOSED: //Completely closed: the course is only accessible to the teachers. - 0
if (api_get_user_id() && !api_is_anonymous() && $is_allowed_in_course) {
$is_visible = true;
}
break;
case COURSE_VISIBILITY_REGISTERED: //Private - access authorized to course members only - 1
if (api_get_user_id() && !api_is_anonymous() && $is_allowed_in_course) {
$is_visible = true;
}
break;
case COURSE_VISIBILITY_OPEN_PLATFORM: // Open - access allowed for users registered on the platform - 2
if (api_get_user_id() && !api_is_anonymous()) {
$is_visible = true;
}
break;
case COURSE_VISIBILITY_OPEN_WORLD: //Open - access allowed for the whole world - 3
$is_visible = true;
break;
case COURSE_VISIBILITY_HIDDEN: //Completely closed: the course is only accessible to the teachers. - 0
if (api_is_platform_admin()) {
$is_visible = true;
}
break;
}
}
//If password is set and user is not registered to the course then the course is not visible
if ($is_allowed_in_course == false & isset($course_info['registration_code']) && !empty($course_info['registration_code'])) {
$is_visible = false;
@ -1116,15 +1116,15 @@ function _api_format_user($user, $add_password = false)
$result['complete_name_with_username'] = $result['complete_name'];
if (!empty($user['username'])) {
$result['complete_name_with_username'] = $result['complete_name'].' ('.$user['username'].')';
$result['complete_name_with_username'] = $result['complete_name'].' ('.$user['username'].')';
}
$result['firstname'] = $firstname;
$result['lastname'] = $lastname;
$result['firstname'] = $firstname;
$result['lastname'] = $lastname;
// Kept for historical reasons
$result['firstName'] = $firstname;
$result['lastName'] = $lastname;
$result['firstName'] = $firstname;
$result['lastName'] = $lastname;
$attributes = array(
'phone',
@ -1180,36 +1180,36 @@ function _api_format_user($user, $add_password = false)
// Getting user avatar.
$picture_filename = trim($result['picture_uri']);
$avatar = api_get_path(WEB_CODE_PATH).'img/unknown.jpg';
$avatar_small = api_get_path(WEB_CODE_PATH).'img/unknown_22.jpg';
$picture_filename = trim($result['picture_uri']);
$avatar = api_get_path(WEB_CODE_PATH).'img/unknown.jpg';
$avatar_small = api_get_path(WEB_CODE_PATH).'img/unknown_22.jpg';
$avatar_sys_path = api_get_path(SYS_CODE_PATH).'img/unknown.jpg';
$dir = 'upload/users/'.$user_id.'/';
$dir = 'upload/users/'.$user_id.'/';
//if (!empty($picture_filename) && api_is_anonymous() ) { //Why you have to be anonymous?
//if (!empty($picture_filename) && api_is_anonymous() ) { //Why you have to be anonymous?
if (!empty($picture_filename)) {
if (api_get_setting('split_users_upload_directory') === 'true') {
$dir = 'upload/users/'.substr((string)$user_id, 0, 1).'/'.$user_id.'/';
}
}
$image_sys_path = api_get_path(SYS_CODE_PATH).$dir.$picture_filename;
if (file_exists($image_sys_path) && !is_dir($image_sys_path)) {
$avatar = api_get_path(WEB_CODE_PATH).$dir.$picture_filename;
$avatar_small = api_get_path(WEB_CODE_PATH).$dir.'small_'.$picture_filename;
if (api_get_setting('split_users_upload_directory') === 'true') {
$dir = 'upload/users/'.substr((string)$user_id, 0, 1).'/'.$user_id.'/';
}
}
$image_sys_path = api_get_path(SYS_CODE_PATH).$dir.$picture_filename;
if (file_exists($image_sys_path) && !is_dir($image_sys_path)) {
$avatar = api_get_path(WEB_CODE_PATH).$dir.$picture_filename;
$avatar_small = api_get_path(WEB_CODE_PATH).$dir.'small_'.$picture_filename;
$avatar_sys_path = api_get_path(SYS_CODE_PATH).$dir.$picture_filename;
}
}
$result['avatar'] = $avatar;
$result['avatar_sys_path'] = $avatar_sys_path;
$result['avatar_small'] = $avatar_small;
if (isset($user['user_is_online'])) {
$result['user_is_online'] = $user['user_is_online'] == true ? 1 : 0;
}
if (isset($user['user_is_online'])) {
$result['user_is_online'] = $user['user_is_online'] == true ? 1 : 0;
}
if (isset($user['user_is_online_in_chat'])) {
$result['user_is_online_in_chat'] = intval($user['user_is_online_in_chat']);
}
$result['user_is_online_in_chat'] = intval($user['user_is_online_in_chat']);
}
if ($add_password) {
$result['password'] = $user['password'];
@ -1236,10 +1236,10 @@ function api_get_user_info($user_id = '', $check_if_user_is_online = false, $sho
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
$result_array = Database::fetch_array($result);
if ($check_if_user_is_online) {
if ($check_if_user_is_online) {
$use_status_in_platform = user_is_online($user_id);
$result_array['user_is_online'] = $use_status_in_platform;
$result_array['user_is_online'] = $use_status_in_platform;
$user_online_in_chat = 0;
if ($use_status_in_platform) {
@ -1249,7 +1249,7 @@ function api_get_user_info($user_id = '', $check_if_user_is_online = false, $sho
}
}
$result_array['user_is_online_in_chat'] = $user_online_in_chat;
}
}
$user = _api_format_user($result_array, $show_password);
return $user;
}
@ -1343,7 +1343,7 @@ function api_get_course_path($course_code = null)
function api_get_course_setting($setting_name, $course_code = null)
{
$course_info = api_get_course_info($course_code);
$table = Database::get_course_table(TABLE_COURSE_SETTING);
$table = Database::get_course_table(TABLE_COURSE_SETTING);
$setting_name = Database::escape_string($setting_name);
if (!empty($course_info['real_id']) && !empty($setting_name)) {
$sql = "SELECT value FROM $table
@ -2449,21 +2449,21 @@ function api_is_course_tutor() {
}
function api_get_user_platform_status($user_id = false) {
$status = array();
$status = array();
$user_id = intval($user_id);
if (empty($user_id)) {
$user_id = api_get_user_id();
$user_id = api_get_user_id();
}
if (empty($user_id)) {
return false;
}
$group_id = api_get_group_id();
$course_id = api_get_course_int_id();
$course_code= api_get_course_id();
$session_id = api_get_session_id();
if (empty($user_id)) {
return false;
}
$group_id = api_get_group_id();
$course_id = api_get_course_int_id();
$course_code= api_get_course_id();
$session_id = api_get_session_id();
//Group (in course)
//Group (in course)
if ($group_id && $course_id) {
$group_status = array();
$is_subscribed = GroupManager::is_subscribed($user_id, $group_id);
@ -2479,8 +2479,8 @@ function api_get_user_platform_status($user_id = false) {
$status['group'] = $group_status;
}
//Session
if ($session_id && $course_id) {
//Session
if ($session_id && $course_id) {
$session_status = array('id' => $session_id, 'course_id' => $course_id);
$session_user_status = SessionManager::get_user_status_in_course_session($user_id, $course_code, $session_id);
switch ($session_user_status) {
@ -2495,12 +2495,12 @@ function api_get_user_platform_status($user_id = false) {
if ($is_general_coach) {
$session_status['status'] = 'general_coach';
}
$status['session'] = $session_status;
$status['session'] = $session_status;
} elseif($course_id) {
//Course
$course_status = array();
if ($course_id) {
} elseif($course_id) {
//Course
$course_status = array();
if ($course_id) {
$user_course_status = CourseManager::get_user_in_course_status($user_id, $course_code);
if ($user_course_status) {
@ -2519,8 +2519,8 @@ function api_get_user_platform_status($user_id = false) {
break;
}
}
}
$status['course'] = $course_status;
}
$status['course'] = $course_status;
}
return $status;
@ -2534,7 +2534,7 @@ function api_get_user_platform_status($user_id = false) {
*/
function api_is_course_session_coach($user_id, $course_code, $session_id)
{
$session_table = Database::get_main_table(TABLE_MAIN_SESSION);
$session_table = Database::get_main_table(TABLE_MAIN_SESSION);
$session_rel_course_rel_user_table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$user_id = intval($user_id);
@ -2542,9 +2542,9 @@ function api_is_course_session_coach($user_id, $course_code, $session_id)
$course_code = Database::escape_string($course_code);
$sql = "SELECT DISTINCT id
FROM $session_table INNER JOIN $session_rel_course_rel_user_table session_rc_ru
ON session.id = session_rc_ru.id_session
WHERE session_rc_ru.id_user = '".$user_id."' AND
FROM $session_table INNER JOIN $session_rel_course_rel_user_table session_rc_ru
ON session.id = session_rc_ru.id_session
WHERE session_rc_ru.id_user = '".$user_id."' AND
session_rc_ru.course_code = '$course_code' AND
session_rc_ru.status = 2 AND
session_rc_ru.id_session = '$session_id'";
@ -2577,34 +2577,34 @@ function api_is_coach($session_id = 0, $course_code = null, $check_student_view
} else {
$course_code = api_get_course_id();
}
$session_table = Database::get_main_table(TABLE_MAIN_SESSION);
$session_table = Database::get_main_table(TABLE_MAIN_SESSION);
$session_rel_course_rel_user_table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$sessionIsCoach = null;
if (!empty($course_code)) {
$sql = "SELECT DISTINCT id, name, date_start, date_end
FROM $session_table INNER JOIN $session_rel_course_rel_user_table session_rc_ru
ON session_rc_ru.id_user = '".api_get_user_id()."'
WHERE session_rc_ru.course_code = '$course_code' AND
if (!empty($course_code)) {
$sql = "SELECT DISTINCT id, name, date_start, date_end
FROM $session_table INNER JOIN $session_rel_course_rel_user_table session_rc_ru
ON session_rc_ru.id_user = '".api_get_user_id()."'
WHERE session_rc_ru.course_code = '$course_code' AND
session_rc_ru.status = 2 AND
session_rc_ru.id_session = '$session_id'";
$result = Database::query($sql);
$sessionIsCoach = Database::store_result($result);
}
if (!empty($session_id)) {
$sql = "SELECT DISTINCT id, name, date_start, date_end
FROM $session_table
WHERE session.id_coach = '".api_get_user_id()."' AND id = '$session_id'
ORDER BY date_start, date_end, name";
$result = Database::query($sql);
if (!empty($sessionIsCoach)) {
$sessionIsCoach = array_merge($sessionIsCoach , Database::store_result($result));
} else {
$sessionIsCoach = Database::store_result($result);
}
}
$result = Database::query($sql);
$sessionIsCoach = Database::store_result($result);
}
if (!empty($session_id)) {
$sql = "SELECT DISTINCT id, name, date_start, date_end
FROM $session_table
WHERE session.id_coach = '".api_get_user_id()."' AND id = '$session_id'
ORDER BY date_start, date_end, name";
$result = Database::query($sql);
if (!empty($sessionIsCoach)) {
$sessionIsCoach = array_merge($sessionIsCoach , Database::store_result($result));
} else {
$sessionIsCoach = Database::store_result($result);
}
}
return (count($sessionIsCoach) > 0);
}
@ -2852,9 +2852,9 @@ function api_display_debug_info($debug_info) {
function api_is_allowed_to_edit($tutor = false, $coach = false, $session_coach = false, $check_student_view = true)
{
$my_session_id = api_get_session_id();
$is_allowed_coach_to_edit = api_is_coach(null, null, $check_student_view);
$session_visibility = api_get_session_visibility($my_session_id);
$my_session_id = api_get_session_id();
$is_allowed_coach_to_edit = api_is_coach(null, null, $check_student_view);
$session_visibility = api_get_session_visibility($my_session_id);
// Admins can edit anything.
if (api_is_platform_admin(false)) {
@ -3307,13 +3307,13 @@ function api_get_item_visibility($_course, $tool, $id, $session = 0)
$id = intval($id);
$session = (int) $session;
$TABLE_ITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
$course_id = intval($_course['real_id']);
$course_id = intval($_course['real_id']);
$sql = "SELECT visibility FROM $TABLE_ITEMPROPERTY
WHERE c_id = $course_id AND
tool = '$tool' AND
ref = $id AND
(id_session = $session OR id_session = 0)
ORDER BY id_session DESC, lastedit_date DESC
WHERE c_id = $course_id AND
tool = '$tool' AND
ref = $id AND
(id_session = $session OR id_session = 0)
ORDER BY id_session DESC, lastedit_date DESC
LIMIT 1";
$res = Database::query($sql);
@ -3447,19 +3447,19 @@ function api_item_property_update(
if (!empty($session_id)) {
// Check whether session id already exist into itemp_properties for updating visibility or add it.
$sql = "SELECT id_session FROM $TABLE_ITEMPROPERTY
WHERE
c_id = $course_id AND
tool = '$tool' AND
ref='$item_id' AND
id_session = '$session_id'";
WHERE
c_id = $course_id AND
tool = '$tool' AND
ref='$item_id' AND
id_session = '$session_id'";
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
$sql = "UPDATE $TABLE_ITEMPROPERTY
SET lastedit_type = '".str_replace('_', '', ucwords($tool))."Deleted',
lastedit_date = '$time',
lastedit_user_id = '$user_id',
visibility = '$visibility',
id_session = '$session_id' $set_type
SET lastedit_type = '".str_replace('_', '', ucwords($tool))."Deleted',
lastedit_date = '$time',
lastedit_user_id = '$user_id',
visibility = '$visibility',
id_session = '$session_id' $set_type
WHERE $filter";
} else {
$sql = "INSERT INTO $TABLE_ITEMPROPERTY (c_id, tool, ref, insert_date, insert_user_id, lastedit_date, lastedit_type, lastedit_user_id,$to_field, visibility, start_visible, end_visible, id_session)
@ -3577,7 +3577,7 @@ function api_get_item_property_by_tool($tool, $course_code, $session_id = null)
$item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
$session_id = intval($session_id);
$session_condition = ' AND id_session = '.$session_id;
$course_id = $course_info['real_id'];
$course_id = $course_info['real_id'];
$sql = "SELECT * FROM $item_property_table
WHERE c_id = $course_id AND tool = '$tool' $session_condition ";
@ -3644,7 +3644,7 @@ function api_get_item_property_id($course_code, $tool, $ref) {
// Definition of tables.
$TABLE_ITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
$course_id = $course_info['real_id'];
$course_id = $course_info['real_id'];
$sql = "SELECT id FROM $TABLE_ITEMPROPERTY
WHERE c_id = $course_id AND tool = '$tool' AND ref = '$ref'";
$rs = Database::query($sql);
@ -3700,7 +3700,7 @@ function api_get_track_item_property_history($tool, $ref)
/**
* Gets item property data from tool of a course id
* @param int course id
* @param int course id
* @param string tool name, linked to 'rubrique' of the course tool_list (Warning: language sensitive !!)
* @param int id of the item itself, linked to key of every tool ('id', ...), "*" = all items of the tool
* @param int $session_id
@ -3715,18 +3715,18 @@ function api_get_item_property_info($course_id, $tool, $ref, $session_id = 0)
$tool = Database::escape_string($tool);
$ref = intval($ref);
$course_id = $course_info['real_id'];
$course_id = $course_info['real_id'];
$session_id = intval($session_id);
// Definition of tables.
$table = Database::get_course_table(TABLE_ITEM_PROPERTY);
$sql = "SELECT * FROM $table
WHERE
c_id = $course_id AND
tool = '$tool' AND
ref = $ref AND
id_session = $session_id ";
$sql = "SELECT * FROM $table
WHERE
c_id = $course_id AND
tool = '$tool' AND
ref = $ref AND
id_session = $session_id ";
$rs = Database::query($sql);
$row = array();
@ -3763,7 +3763,7 @@ function api_get_languages_combo($name = 'language', $chozen=true) {
}
$languages = $language_list['name'];
$folder = $language_list['folder'];
$folder = $language_list['folder'];
$ret .= '<select name="'.$name.'" id="language_chosen" '.($chozen?'class="chzn-select"':'').' >';
foreach ($languages as $key => $value) {
@ -3803,7 +3803,7 @@ function api_display_language_form($hide_if_no_choice = false) {
$original_languages = $language_list['name'];
$folder = $language_list['folder']; // This line is probably no longer needed.
$html = '
$html = '
<script type="text/javascript">
<!--
function jumpMenu(targ,selObj,restore){ // v3.0
@ -4283,14 +4283,14 @@ if (!function_exists('sys_get_temp_dir')) {
* @author Aidan Lister <aidan@php.net>
* @version 1.0.3
* @param string $dirname Directory to delete
* @param bool Deletes only the content or not
* @param bool Deletes only the content or not
* @return bool Returns TRUE on success, FALSE on failure
* @link http://aidanlister.com/2004/04/recursively-deleting-a-folder-in-php/
* @author Yannick Warnier, adaptation for the Chamilo LMS, April, 2008
* @author Ivan Tcholakov, a sanity check about Directory class creation has been added, September, 2009
*/
function rmdirr($dirname, $delete_only_content_in_folder = false) {
$res = true;
$res = true;
// A sanity check.
if (!file_exists($dirname)) {
@ -4328,10 +4328,10 @@ function rmdirr($dirname, $delete_only_content_in_folder = false) {
}
if ($delete_only_content_in_folder == false) {
$res = rmdir($dirname);
if ($res === false) {
error_log(__FILE__.' line '.__LINE__.': '.((bool)ini_get('track_errors') ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0);
}
$res = rmdir($dirname);
if ($res === false) {
error_log(__FILE__.' line '.__LINE__.': '.((bool)ini_get('track_errors') ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0);
}
}
return $res;
}
@ -4355,7 +4355,7 @@ function copyr($source, $dest, $exclude = array(), $copied_files = array()) {
}
return true;
} elseif (!is_dir($source)) {
//then source is not a dir nor a file, return
//then source is not a dir nor a file, return
return false;
}
@ -4400,7 +4400,7 @@ function copy_folder_course_session($pathname, $base_path_document, $session_id,
return false;
}
$course_id = $course_info['real_id'];
$course_id = $course_info['real_id'];
$folders = explode(DIRECTORY_SEPARATOR,str_replace($base_path_document.DIRECTORY_SEPARATOR,'',$pathname));
@ -4428,13 +4428,13 @@ function copy_folder_course_session($pathname, $base_path_document, $session_id,
// Insert new folder with destination session_id.
$sql = "INSERT INTO ".$table." SET
c_id = $course_id,
path = '$path',
comment = '".Database::escape_string($document->comment)."',
title = '".Database::escape_string(basename($new_pathname))."' ,
filetype='folder',
size= '0',
session_id = '$session_id'";
c_id = $course_id,
path = '$path',
comment = '".Database::escape_string($document->comment)."',
title = '".Database::escape_string(basename($new_pathname))."' ,
filetype='folder',
size= '0',
session_id = '$session_id'";
Database::query($sql);
$document_id = Database::insert_id();
api_item_property_update($course_info,TOOL_DOCUMENT,$document_id,'FolderCreated',api_get_user_id(),0,0,null,null,$session_id);
@ -4658,44 +4658,44 @@ function api_get_status_langvars() {
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
*/
function api_get_settings_options($var) {
$table_settings_options = Database :: get_main_table(TABLE_MAIN_SETTINGS_OPTIONS);
$table_settings_options = Database :: get_main_table(TABLE_MAIN_SETTINGS_OPTIONS);
$var = Database::escape_string($var);
$sql = "SELECT * FROM $table_settings_options WHERE variable = '$var' ORDER BY id";
$result = Database::query($sql);
$sql = "SELECT * FROM $table_settings_options WHERE variable = '$var' ORDER BY id";
$result = Database::query($sql);
$settings_options_array = array();
while ($row = Database::fetch_array($result, 'ASSOC')) {
//$temp_array = array ('value' => $row['value'], 'display_text' => $row['display_text']);
$settings_options_array[] = $row;
}
return $settings_options_array;
while ($row = Database::fetch_array($result, 'ASSOC')) {
//$temp_array = array ('value' => $row['value'], 'display_text' => $row['display_text']);
$settings_options_array[] = $row;
}
return $settings_options_array;
}
function api_set_setting_option($params) {
$table = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS);
if (empty($params['id'])) {
Database::insert($table, $params);
} else {
Database::update($table, $params, array('id = ? '=> $params['id']));
}
$table = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS);
if (empty($params['id'])) {
Database::insert($table, $params);
} else {
Database::update($table, $params, array('id = ? '=> $params['id']));
}
}
function api_set_setting_simple($params) {
$table = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
$table = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
$url_id = api_get_current_access_url_id();
if (empty($params['id'])) {
if (empty($params['id'])) {
$params['access_url'] = $url_id;
Database::insert($table, $params);
} else {
Database::update($table, $params, array('id = ? '=> array($params['id'])));
}
Database::insert($table, $params);
} else {
Database::update($table, $params, array('id = ? '=> array($params['id'])));
}
}
function api_delete_setting_option($id) {
$table = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS);
if (!empty($id)) {
Database::delete($table, array('id = ? '=> $id));
}
$table = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS);
if (!empty($id)) {
Database::delete($table, array('id = ? '=> $id));
}
}
/**
@ -6195,9 +6195,9 @@ function api_check_browscap() {
$setting = ini_get('browscap');
if ($setting) {
$browser = get_browser($_SERVER['HTTP_USER_AGENT'], true);
if (strpos($setting, 'browscap.ini') && !empty($browser)) {
return true;
}
if (strpos($setting, 'browscap.ini') && !empty($browser)) {
return true;
}
}
return false;
}
@ -6232,9 +6232,9 @@ function api_get_jquery_js() {
*/
function api_get_jquery_ui_js($include_jqgrid = false) {
$libraries = array('jquery-ui');
if ($include_jqgrid) {
$libraries[]='jqgrid';
}
if ($include_jqgrid) {
$libraries[]='jqgrid';
}
return api_get_jquery_libraries_js($libraries);
}
@ -6307,8 +6307,8 @@ function api_get_jquery_libraries_js($libraries) {
}
if (in_array('bxslider',$libraries)) {
$js .= api_get_js('bxslider/jquery.bxSlider.min.js');
$js .= api_get_css($js_path.'bxslider/bx_styles/bx_styles.css');
$js .= api_get_js('bxslider/jquery.bxSlider.min.js');
$js .= api_get_css($js_path.'bxslider/bx_styles/bx_styles.css');
}
// jquery datepicker
@ -6341,10 +6341,10 @@ function api_get_jquery_libraries_js($libraries) {
* Returns the course's URL
*
* This function relies on api_get_course_info()
* @param string The course code - optional (takes it from session if not given)
* @param int The session id - optional (takes it from session if not given)
* @return mixed The URL of the course or null if something does not work
* @author Julio Montoya <gugli100@gmail.com>
* @param string The course code - optional (takes it from session if not given)
* @param int The session id - optional (takes it from session if not given)
* @return mixed The URL of the course or null if something does not work
* @author Julio Montoya <gugli100@gmail.com>
*/
function api_get_course_url($course_code = null, $session_id = null)
{
@ -6373,7 +6373,7 @@ function api_get_course_url($course_code = null, $session_id = null)
/**
*
* Check if the current portal has the $_configuration['multiple_access_urls'] parameter on
* @return bool true if multi site is enabled
* @return bool true if multi site is enabled
*
* */
function api_get_multiple_access_url() {
@ -6399,29 +6399,29 @@ function api_get_unique_id() {
}
function api_get_home_path() {
$home = 'home/';
if (api_get_multiple_access_url()) {
$access_url_id = api_get_current_access_url_id();
$url_info = api_get_access_url($access_url_id);
$url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $url_info['url']));
$clean_url = replace_dangerous_char($url);
$clean_url = str_replace('/', '-', $clean_url);
$clean_url .= '/';
// if $clean_url == "localhost/" means that the multiple URL was not well configured we don't rename the $home variable
if ($clean_url != 'localhost/')
$home = 'home/'.$clean_url;
}
return $home;
$home = 'home/';
if (api_get_multiple_access_url()) {
$access_url_id = api_get_current_access_url_id();
$url_info = api_get_access_url($access_url_id);
$url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $url_info['url']));
$clean_url = replace_dangerous_char($url);
$clean_url = str_replace('/', '-', $clean_url);
$clean_url .= '/';
// if $clean_url == "localhost/" means that the multiple URL was not well configured we don't rename the $home variable
if ($clean_url != 'localhost/')
$home = 'home/'.$clean_url;
}
return $home;
}
function api_get_course_table_condition($and = true) {
$course_id = api_get_course_int_id();
$condition = '';
$condition_add = $and ? " AND " : " WHERE ";
if (!empty($course_id)) {
$condition = " $condition_add c_id = $course_id";
}
return $condition;
$course_id = api_get_course_int_id();
$condition = '';
$condition_add = $and ? " AND " : " WHERE ";
if (!empty($course_id)) {
$condition = " $condition_add c_id = $course_id";
}
return $condition;
}
/**

File diff suppressed because it is too large Load Diff

@ -1,13 +1,13 @@
<?php
/* For licensing terms, see /license.txt*/
/**
* @package chamilo.user
* @package chamilo.user
*/
/**
* Code
*/
/* INIT */
/* INIT */
// name of the language file that needs to be included
$language_file="registration";
@ -25,7 +25,7 @@ $tbl_courseUser = "course_rel_user";
/* DATA CHECKING */
/* DATA CHECKING */
if($register) {
/*
@ -94,9 +94,9 @@ if($register) {
break;
}
} // end while $result
} // end if num rows
} // end if datachecked
} // end while $result
} // end if num rows
} // end if datachecked
@ -220,10 +220,10 @@ if($register) {
unset($lastname_form, $firstname_form, $username_form, $password_form, $email_form, $admin_form, $tutor_form);
} // end if ($platformRegSucceed)
} // end if ($platformRegSucceed)
//else
//{
// $message = get_lang('UserAlreadyRegistered');
// $message = get_lang('UserAlreadyRegistered');
//}
} // end if register request
@ -335,7 +335,7 @@ if ($_cid) // if we're inside a course, then it's a course registration
</tr>
<?php
} // end if $_cid - for the case we're not in a course registration
} // end if $_cid - for the case we're not in a course registration
// but a platform registration
else
{

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save