Replaced Database::get_course_info() with api_get_course_info(),

Database :: get_user_personal_table() replaced with Database :: get_main_table(),
Database::get_course_list() moved to CourseManager,
Removing Database::get_last_insert_id() using Database::insert_id()
Moving Database::get_course_by_category() to CourseManager,
skala
Julio Montoya 12 years ago
parent e48d57eb22
commit d9d92e9f4d
  1. 2
      main/admin/calendar.lib.php
  2. 13
      main/admin/special_exports.php
  3. 6
      main/calendar/agenda.inc.php
  4. 2
      main/calendar/agenda.lib.php
  5. 14
      main/calendar/myagenda.inc.php
  6. 34
      main/calendar/myagenda.php
  7. 2
      main/coursecopy/classes/CourseBuilder.class.php
  8. 2
      main/coursecopy/classes/CourseRestorer.class.php
  9. 2
      main/coursecopy/classes/DummyCourseCreator.class.php
  10. 2
      main/dropbox/dropbox_init.inc.php
  11. 2
      main/exercice/question.class.php
  12. 2
      main/gradebook/exercise_jump.php
  13. 2
      main/gradebook/index.php
  14. 4
      main/gradebook/lib/fe/displaygradebook.php
  15. 4
      main/gradebook/lib/fe/gradebooktable.class.php
  16. 2
      main/inc/lib/attendance.lib.php
  17. 16
      main/inc/lib/auth.lib.php
  18. 46
      main/inc/lib/course.lib.php
  19. 2
      main/inc/lib/course_request.lib.php
  20. 1
      main/inc/lib/tracking.lib.php
  21. 10
      main/inc/lib/usermanager.lib.php
  22. 3
      main/install/1.10.0/update-db-1.9.0-1.10.0.inc.php
  23. 2
      main/newscorm/aicc.class.php
  24. 4
      main/newscorm/resourcelinker.inc.php
  25. 2
      main/newscorm/scorm.class.php
  26. 4
      src/ChamiloLMS/Controller/LearnpathController.php
  27. 3
      src/ChamiloLMS/Controller/UserPortalController.php

@ -1637,9 +1637,7 @@ function get_agendaitems($month, $year)
//databases of the courses
$TABLEAGENDA = Database :: get_main_table(TABLE_MAIN_SYSTEM_CALENDAR);
//$TABLE_ITEMPROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY);
//$group_memberships = GroupManager :: get_group_ids(Database::get_current_course_database(), $_user['user_id']);
// if the user is administrator of that course we show all the agenda items
//if (api_is_allowed_to_edit())
//{

@ -68,7 +68,7 @@ if ((isset ($_POST['action']) && $_POST['action'] == 'course_select_form') || (i
$Resource = $_POST['resource'];
foreach ($Resource as $Code_course => $Sessions) {
$_course = Database::get_course_info($Code_course);
$_course = api_get_course_info($Code_course);
$tbl_document = Database::get_course_table(TABLE_DOCUMENT);
$tbl_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
$course_id = $_course['real_id'];
@ -103,10 +103,11 @@ if ((isset ($_POST['action']) && $_POST['action'] == 'course_select_form') || (i
AND props.to_group_id= $to_group_id AND docs.c_id = $course_id AND props.c_id = $course_id";
$query_session_doc = Database::query($sql_session_doc);
while ($rows_course_session_file = Database::fetch_assoc($query_session_doc)) {
$zip_folder->add($FileZip['PATH_COURSE'].$_course['directory'].'/document'.$rows_course_session_file['path'],
PCLZIP_OPT_ADD_PATH, $_course['directory']."/".$ListSession[$session_id],
PCLZIP_OPT_REMOVE_PATH, $FileZip['PATH_COURSE'].$_course['directory'].'/document'.$FileZip['PATH_REMOVE']
);
$zip_folder->add(
$FileZip['PATH_COURSE'].$_course['directory'].'/document'.$rows_course_session_file['path'],
PCLZIP_OPT_ADD_PATH, $_course['directory']."/".$ListSession[$session_id],
PCLZIP_OPT_REMOVE_PATH, $FileZip['PATH_COURSE'].$_course['directory'].'/document'.$FileZip['PATH_REMOVE']
);
}
}
}
@ -209,7 +210,7 @@ function fullexportspecial(){
$code_course = '';
$list_course = array();
$zip_folder = new PclZip($FileZip['TEMP_FILE_ZIP']);
$list_course = Database::get_course_list();
$list_course = CourseManager::get_course_list();
$tbl_document = Database::get_course_table(TABLE_DOCUMENT);
$tbl_property = Database::get_course_table(TABLE_ITEM_PROPERTY);

@ -34,7 +34,7 @@ $(function() {
} else {
url = String(window.location)+temp;
window.location.replace(url);
}
}
});
});
</script>';
@ -289,7 +289,7 @@ function get_calendar_items($select_month, $select_year, $select_day = false)
//Check my personal calendar items
if (api_get_setting('allow_personal_agenda') == 'true' && empty($_SESSION['user']) && empty($_SESSION['group'])) {
$tbl_personal_agenda = Database :: get_user_personal_table(TABLE_PERSONAL_AGENDA);
$tbl_personal_agenda = Database :: get_main_table(TABLE_PERSONAL_AGENDA);
// 1. creating the SQL statement for getting the personal agenda items in MONTH view
$sql = "SELECT id, title, text as content , date as start_date, enddate as end_date, parent_event_id FROM ".$tbl_personal_agenda."
WHERE user='".api_get_user_id()."' ".$show_all_current_personal;
@ -1120,7 +1120,7 @@ function construct_to_select_form($group_list = null, $user_list = null, $filter
}
$result .= "</optgroup>";
}
// adding the individual users to the select form
if (!empty($user_list)) {
$result .= '<optgroup label="'.get_lang('FilterByUser').'">';

@ -14,7 +14,7 @@ class Agenda
{
//Table definitions
$this->tbl_global_agenda = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR);
$this->tbl_personal_agenda = Database::get_user_personal_table(TABLE_PERSONAL_AGENDA);
$this->tbl_personal_agenda = Database::get_main_table(TABLE_PERSONAL_AGENDA);
$this->tbl_course_agenda = Database::get_course_table(TABLE_AGENDA);
//Setting the course object if we are in a course

@ -327,7 +327,7 @@ function display_myminimonthcalendar($agendaitems, $month, $year, $monthName) {
function show_new_personal_item_form($id = "") {
global $year, $MonthsLong;
$tbl_personal_agenda = Database :: get_user_personal_table(TABLE_PERSONAL_AGENDA);
$tbl_personal_agenda = Database :: get_main_table(TABLE_PERSONAL_AGENDA);
// we construct the default time and date data (used if we are not editing a personal agenda item)
//$today = getdate();
@ -517,7 +517,7 @@ function show_new_personal_item_form($id = "") {
*/
function store_personal_item($day, $month, $year, $hour, $minute, $title, $content, $id = "") {
$tbl_personal_agenda = Database :: get_user_personal_table(TABLE_PERSONAL_AGENDA);
$tbl_personal_agenda = Database :: get_main_table(TABLE_PERSONAL_AGENDA);
//constructing the date
$date = $year."-".$month."-".$day." ".$hour.":".$minute.":00";
@ -598,7 +598,7 @@ function get_courses_of_user() {
* This function retrieves all the personal agenda items and add them to the agenda items found by the other functions.
*/
function get_personal_agenda_items($user_id, $agendaitems, $day = "", $month = "", $year = "", $week = "", $type) {
$tbl_personal_agenda = Database :: get_user_personal_table(TABLE_PERSONAL_AGENDA);
$tbl_personal_agenda = Database :: get_main_table(TABLE_PERSONAL_AGENDA);
$user_id = intval($user_id);
// 1. creating the SQL statement for getting the personal agenda items in MONTH view
@ -700,7 +700,7 @@ function get_personal_agenda_items($user_id, $agendaitems, $day = "", $month = "
* @return array The results of the database query, or null if not found
*/
function get_personal_agenda_item($id) {
$tbl_personal_agenda = Database :: get_user_personal_table(TABLE_PERSONAL_AGENDA);
$tbl_personal_agenda = Database :: get_main_table(TABLE_PERSONAL_AGENDA);
$id = Database::escape_string($id);
// make sure events of the personal agenda can only be seen by the user himself
$user = api_get_user_id();
@ -720,7 +720,7 @@ function get_personal_agenda_item($id) {
function show_personal_agenda() {
global $MonthsLong, $charset;
$tbl_personal_agenda = Database :: get_user_personal_table(TABLE_PERSONAL_AGENDA);
$tbl_personal_agenda = Database :: get_main_table(TABLE_PERSONAL_AGENDA);
// The SQL statement that retrieves all the personal agenda items of this user
$sql = "SELECT * FROM ".$tbl_personal_agenda." WHERE user='".api_get_user_id()."' ORDER BY date DESC";
@ -824,7 +824,7 @@ function show_personal_agenda() {
function show_simple_personal_agenda($user_id) {
global $MonthsLong, $charset;
$tbl_personal_agenda = Database :: get_user_personal_table(TABLE_PERSONAL_AGENDA);
$tbl_personal_agenda = Database :: get_main_table(TABLE_PERSONAL_AGENDA);
// The SQL statement that retrieves all the personal agenda items of this user
$sql = "SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$user_id."' ORDER BY date DESC";
@ -885,7 +885,7 @@ function show_simple_personal_agenda($user_id) {
* does not belong to him/her
*/
function delete_personal_agenda($id) {
$tbl_personal_agenda = Database :: get_user_personal_table(TABLE_PERSONAL_AGENDA);
$tbl_personal_agenda = Database :: get_main_table(TABLE_PERSONAL_AGENDA);
if ($id != strval(intval($id))) {
return false; //potential SQL injection

@ -31,11 +31,11 @@ if (!empty ($course_path)) {
$htmlHeadXtra[] = to_javascript();
$htmlHeadXtra[] = "<script src=\"tbl_change.js\" type=\"text/javascript\" language=\"javascript\"></script>";
$htmlHeadXtra[] = "<script>
$(function() {
$(\".dialog\").dialog(\"destroy\");
$(function() {
$(\".dialog\").dialog(\"destroy\");
$(\".dialog\").dialog({
autoOpen: false,
show: \"blind\",
show: \"blind\",
resizable: false,
height:300,
width:550,
@ -62,7 +62,7 @@ $TABLECOURS = Database :: get_main_table(TABLE_MAIN_COURSE);
$TABLECOURSUSER = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$TABLEAGENDA = Database :: get_course_table(TABLE_AGENDA);
$TABLE_ITEMPROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY);
$tbl_personal_agenda= Database :: get_user_personal_table(TABLE_PERSONAL_AGENDA);
$tbl_personal_agenda= Database :: get_main_table(TABLE_PERSONAL_AGENDA);
// the variables for the days and the months
// Defining the shorts for the days
@ -141,7 +141,7 @@ if (isset($_user['user_id'])) {
// getting all the courses that this user is subscribed to
//$courses_dbs = get_all_courses_of_user();
$my_course_list = CourseManager::get_courses_list_by_user_id(api_get_user_id(), true);
if (!is_array($my_course_list)) {
// this is for the special case if the user has no courses (otherwise you get an error)
$my_course_list = array();
@ -178,13 +178,13 @@ if (isset($_user['user_id'])) {
}
echo "</div>";
$agendaitems = get_myagendaitems(api_get_user_id(), $my_course_list, $month, $year);
$agendaitems = get_myagendaitems(api_get_user_id(), $my_course_list, $month, $year);
$agendaitems = get_global_agenda_items($agendaitems, $day, $month, $year, $week, "month_view");
if (api_get_setting('allow_personal_agenda') == 'true') {
$agendaitems = get_personal_agenda_items(api_get_user_id(), $agendaitems, $day, $month, $year, $week, "month_view");
}
if ($process != 'month_view') {
echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
echo "<tr>";
@ -196,26 +196,26 @@ if (isset($_user['user_id'])) {
// OlivierB : the image has a white background, which causes trouble if the portal has another background color. Image should be transparent. ----> echo "<td width=\"20\" background=\"../img/verticalruler.gif\">&nbsp;</td>";
echo "<td width=\"8\">&nbsp;</td>";
// the main area: day, week, month view
echo "<td valign=\"top\">";
echo "<td valign=\"top\">";
}
switch ($process) {
case 'month_view' :
case 'month_view' :
display_mymonthcalendar(api_get_user_id(), $agendaitems, $month, $year, array(), $monthName);
break;
case 'week_view' :
$agendaitems = get_week_agendaitems($my_course_list, $month, $year, $week);
$agendaitems = get_global_agenda_items($agendaitems, $day, $month, $year, $week, "week_view");
$agendaitems = get_week_agendaitems($my_course_list, $month, $year, $week);
$agendaitems = get_global_agenda_items($agendaitems, $day, $month, $year, $week, "week_view");
if (api_get_setting("allow_personal_agenda") == "true") {
$agendaitems = get_personal_agenda_items(api_get_user_id(), $agendaitems, $day, $month, $year, $week, "week_view");
}
display_weekcalendar($agendaitems, $month, $year, array(), $monthName);
break;
case 'day_view' :
$agendaitems = get_day_agendaitems($my_course_list, $month, $year, $day);
$agendaitems = get_global_agenda_items($agendaitems, $day, $month, $year, $week, "day_view");
$agendaitems = get_day_agendaitems($my_course_list, $month, $year, $day);
$agendaitems = get_global_agenda_items($agendaitems, $day, $month, $year, $week, "day_view");
if (api_get_setting('allow_personal_agenda') == 'true') {
$agendaitems = get_personal_agenda_items(api_get_user_id(), $agendaitems, $day, $month, $year, $week, "day_view");
$agendaitems = get_personal_agenda_items(api_get_user_id(), $agendaitems, $day, $month, $year, $week, "day_view");
}
display_daycalendar($agendaitems, $day, $month, $year, array(), $monthName);
break;
@ -250,4 +250,4 @@ if (isset($_user['user_id'])) {
if ($process != 'month_view') {
echo '</td></tr></table>';
}
Display :: display_footer();
Display :: display_footer();

@ -925,7 +925,7 @@ class CourseBuilder
function build_session_course(){
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$list_course = Database::get_course_list();
$list_course = CourseManager::get_course_list();
$list = array();
foreach($list_course as $_course) {
$this->course = new Course();

@ -2447,7 +2447,7 @@ class CourseRestorer
$glossary->description
)."', display_order='".self::DBUTF8escapestring($glossary->display_order)."' $condition_session ";
Database::query($sql);
$my_id = Database::get_last_insert_id();
$my_id = Database::insert_id();
api_item_property_update(
$this->destination_course_info,
TOOL_GLOSSARY,

@ -48,7 +48,7 @@ class DummyCourseCreator
$this->default_property['start_visible'] = '0000-00-00 00:00:00';
$this->default_property['end_visible'] = '0000-00-00 00:00:00';
$course = Database::get_course_info($course_code);
$course = api_get_course_info($course_code);
$this->course = new Course();
$tmp_path = api_get_path(SYS_COURSE_PATH).$course['directory'].'/document/tmp_'.uniqid('');
@mkdir($tmp_path, api_get_permissions_for_new_directories(), true);

@ -64,7 +64,7 @@ require_once api_get_path(SYS_CODE_PATH).'document/document.inc.php'; // we use
$user_id = api_get_user_id();
$course_code = api_get_course_id();
$courseId = api_get_course_int_id();
$course_info = Database::get_course_info($course_code);
$course_info = api_get_course_info($course_code);
$session_id = api_get_session_id();
if (empty($session_id)) {

@ -1840,7 +1840,7 @@ abstract class Question
VALUES ($course_id, '".Database::escape_string($question_name)."', '$max_score', $max_position, $type, $level)";
Database::query($sql);
// Get the question ID
$question_id = Database::get_last_insert_id();
$question_id = Database::insert_id();
// Get the max question_order
$sql = "SELECT max(question_order) as max_order FROM $tbl_quiz_rel_question

@ -18,7 +18,7 @@ api_block_anonymous_users();
$this_section=SECTION_COURSES;
$course_code = api_get_course_id();
$course_info = Database::get_course_info($course_code);
$course_info = api_get_course_info($course_code);
$course_title = $course_info['title'];
$course_code = $return_result['code'];
$gradebook = Security::remove_XSS($_GET['gradebook']);

@ -731,7 +731,7 @@ $no_qualification = false;
if ($category != '0') {
$cat = new Category();
$category_id = intval($_GET['selectcat']);
$course_id = Database::get_course_by_category($category_id);
$course_id = CourseManager::get_course_by_category($category_id);
$show_message = $cat->show_message_resource_delete($course_id);
if ($show_message == '') {

@ -189,7 +189,7 @@ class DisplayGradebook
// Student
$status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id());
$objcat = new Category();
$course_id = Database::get_course_by_category($selectcat);
$course_id = CourseManager::get_course_by_category($selectcat);
$message_resource=$objcat->show_message_resource_delete($course_id);
if (!$is_course_admin && $status<>1 && $selectcat<>0) {
@ -361,7 +361,7 @@ class DisplayGradebook
//student
$status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id());
$objcat = new Category();
$course_id = Database::get_course_by_category($selectcat);
$course_id = CourseManager::get_course_by_category($selectcat);
$message_resource = $objcat->show_message_resource_delete($course_id);
$grade_model_id = $catobj->get_grade_model_id();

@ -520,7 +520,7 @@ class GradebookTable extends SortableTable {
// evaluation
case 'E' :
$cat = new Category();
$course_id = Database::get_course_by_category($_GET['selectcat']);
$course_id = CourseManager::get_course_by_category($_GET['selectcat']);
$show_message = $cat->show_message_resource_delete($course_id);
@ -557,7 +557,7 @@ class GradebookTable extends SortableTable {
// link
case 'L' :
$cat = new Category();
$course_id = Database::get_course_by_category($_GET['selectcat']);
$course_id = CourseManager::get_course_by_category($_GET['selectcat']);
$show_message = $cat->show_message_resource_delete($course_id);
$url = $item->get_link();

@ -1223,7 +1223,7 @@ class Attendance
date_time = '".Database::escape_string($this->date_time)."',
attendance_id = '$attendance_id'";
Database::query($sql);
$cal_id = Database::get_last_insert_id();
$cal_id = Database::insert_id();
$affected_rows = Database::affected_rows();
}

@ -96,7 +96,7 @@ class AuthLib {
*/
public function get_user_course_categories() {
$user_id = api_get_user_id();
$table_category = Database::get_user_personal_table(TABLE_USER_COURSE_CATEGORY);
$table_category = Database::get_main_table(TABLE_USER_COURSE_CATEGORY);
$sql = "SELECT * FROM " . $table_category . " WHERE user_id=$user_id ORDER BY sort ASC";
$result = Database::query($sql);
$output = array();
@ -118,7 +118,7 @@ class AuthLib {
// table definitions
$TABLECOURS = Database::get_main_table(TABLE_MAIN_COURSE);
$TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$TABLE_USER_COURSE_CATEGORY = Database::get_user_personal_table(TABLE_USER_COURSE_CATEGORY);
$TABLE_USER_COURSE_CATEGORY = Database::get_main_table(TABLE_USER_COURSE_CATEGORY);
$TABLE_COURSE_FIELD = Database :: get_main_table(TABLE_MAIN_COURSE_FIELD);
$TABLE_COURSE_FIELD_VALUE = Database :: get_main_table(TABLE_MAIN_COURSE_FIELD_VALUES);
@ -248,7 +248,7 @@ class AuthLib {
public function move_category($direction, $category2move) {
// the database definition of the table that stores the user defined course categories
$table_user_defined_category = Database::get_user_personal_table(TABLE_USER_COURSE_CATEGORY);
$table_user_defined_category = Database::get_main_table(TABLE_USER_COURSE_CATEGORY);
$current_user_id = api_get_user_id();
$user_coursecategories = $this->get_user_course_categories();
@ -287,7 +287,7 @@ class AuthLib {
*/
public function get_user_course_categories_info() {
$current_user_id = api_get_user_id();
$table_category = Database::get_user_personal_table(TABLE_USER_COURSE_CATEGORY);
$table_category = Database::get_main_table(TABLE_USER_COURSE_CATEGORY);
$sql = "SELECT * FROM " . $table_category . " WHERE user_id='" . $current_user_id . "' ORDER BY sort ASC";
$result = Database::query($sql);
while ($row = Database::fetch_array($result)) {
@ -307,7 +307,7 @@ class AuthLib {
$title = Database::escape_string($title);
$category_id = intval($category_id);
$result = false;
$tucc = Database::get_user_personal_table(TABLE_USER_COURSE_CATEGORY);
$tucc = Database::get_main_table(TABLE_USER_COURSE_CATEGORY);
$sql_update = "UPDATE $tucc SET title='" . api_htmlentities($title, ENT_QUOTES, api_get_system_encoding()) . "' WHERE id='" . $category_id . "'";
Database::query($sql_update);
if (Database::affected_rows()) {
@ -323,7 +323,7 @@ class AuthLib {
*/
public function delete_course_category($category_id) {
$current_user_id = api_get_user_id();
$tucc = Database::get_user_personal_table(TABLE_USER_COURSE_CATEGORY);
$tucc = Database::get_main_table(TABLE_USER_COURSE_CATEGORY);
$TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$category_id = intval($category_id);
$result = false;
@ -373,7 +373,7 @@ class AuthLib {
*/
public function store_course_category($category_title) {
$tucc = Database::get_user_personal_table(TABLE_USER_COURSE_CATEGORY);
$tucc = Database::get_main_table(TABLE_USER_COURSE_CATEGORY);
// protect data
$current_user_id = api_get_user_id();
@ -691,4 +691,4 @@ class AuthLib {
return array('message' => $message, 'content' => $content);
}
}
}
}

@ -1474,7 +1474,7 @@ class CourseManager
* @return array List of groups info
*/
public static function get_group_list_of_course($course_code, $session_id = 0, $in_get_empty_group = 0) {
$course_info = Database::get_course_info($course_code);
$course_info = api_get_course_info($course_code);
$course_id = $course_info['real_id'];
$group_list = array();
$session_id != 0 ? $session_condition = ' WHERE g.session_id IN(1,'.intval($session_id).')' : $session_condition = ' WHERE g.session_id = 0';
@ -1937,7 +1937,7 @@ class CourseManager
$codes = array();
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$tbl_user_course_category = Database::get_user_personal_table(TABLE_USER_COURSE_CATEGORY);
$tbl_user_course_category = Database::get_main_table(TABLE_USER_COURSE_CATEGORY);
$special_course_list = self::get_special_course_list();
@ -2731,7 +2731,7 @@ class CourseManager
}
public static function displayPersonalCourseCategories($user_id, $filter, $load_dirs, $getCount, $start = null, $maxPerPage = null) {
$tableUserCourseCategory = Database::get_user_personal_table(TABLE_USER_COURSE_CATEGORY);
$tableUserCourseCategory = Database::get_main_table(TABLE_USER_COURSE_CATEGORY);
// Table definitions
$TABLECOURS = Database :: get_main_table(TABLE_MAIN_COURSE);
@ -3061,7 +3061,7 @@ class CourseManager
$html = null;
// Step 1: We get all the categories of the user
$tucc = Database::get_user_personal_table(TABLE_USER_COURSE_CATEGORY);
$tucc = Database::get_main_table(TABLE_USER_COURSE_CATEGORY);
$sql = "SELECT id, title FROM $tucc WHERE user_id='".$user_id."' ORDER BY sort ASC";
$result = Database::query($sql);
while ($row = Database::fetch_array($result)) {
@ -3226,7 +3226,7 @@ class CourseManager
function get_user_course_categories() {
global $_user;
$output = array();
$table_category = Database::get_user_personal_table(TABLE_USER_COURSE_CATEGORY);
$table_category = Database::get_main_table(TABLE_USER_COURSE_CATEGORY);
$sql = "SELECT * FROM ".$table_category." WHERE user_id='".Database::escape_string($_user['user_id'])."'";
$result = Database::query($sql);
while ($row = Database::fetch_array($result)) {
@ -4733,9 +4733,8 @@ class CourseManager
unsubscribe = '".intval($unsubscribe) . "',
visual_code = '".Database :: escape_string($visual_code) . "'";
Database::query($sql);
//error_log($sql);
$course_id = Database::get_last_insert_id();
$course_id = Database::insert_id();
if ($course_id) {
@ -4854,5 +4853,36 @@ class CourseManager
}
}
/**
* @return a list (array) of all courses.
* This function was originally in the Database class
*/
public static function get_course_list()
{
$table = Database::get_main_table(TABLE_MAIN_COURSE);
return Database::store_result(Database::query("SELECT *, id as real_id FROM $table"));
}
/**
* Returns course code from a given gradebook category's id
* @param int Category ID
* @return string Course code
*/
public static function get_course_by_category($category_id)
{
$category_id = intval($category_id);
$info = Database::fetch_array(
Database::query(
'SELECT course_code FROM '.Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY).' WHERE id='.$category_id
),
'ASSOC'
);
return $info ? $info['course_code'] : false;
}
} //end class CourseManager

@ -107,7 +107,7 @@ class CourseRequestManager {
if (!$result_sql) {
return false;
}
$last_insert_id = Database::get_last_insert_id();
$last_insert_id = Database::insert_id();
// E-mail notifications.

@ -226,7 +226,6 @@ class Tracking
$sql = 'SELECT login_date FROM '.$tbl_track_login.'
WHERE login_user_id = '.intval($student_id).'
ORDER BY login_date DESC LIMIT 0,1';
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
if ($last_login_date = Database::result($rs, 0, 0)) {

@ -499,7 +499,7 @@ class UserManager
}
// Delete the personal course categories
$course_cat_table = Database::get_user_personal_table(TABLE_USER_COURSE_CATEGORY);
$course_cat_table = Database::get_main_table(TABLE_USER_COURSE_CATEGORY);
$sql = "DELETE FROM $course_cat_table WHERE user_id = '".$user_id."'";
Database::query($sql);
@ -512,7 +512,7 @@ class UserManager
Database::query($sql);
// Delete the personal agenda-items from this user
$agenda_table = Database :: get_user_personal_table(TABLE_PERSONAL_AGENDA);
$agenda_table = Database :: get_main_table(TABLE_PERSONAL_AGENDA);
$sql = "DELETE FROM $agenda_table WHERE user = '".$user_id."'";
Database::query($sql);
@ -2600,7 +2600,7 @@ class UserManager
}
//Courses in which we are subscribed out of any session
$tbl_user_course_category = Database :: get_user_personal_table(TABLE_USER_COURSE_CATEGORY);
$tbl_user_course_category = Database :: get_main_table(TABLE_USER_COURSE_CATEGORY);
$personal_course_list_sql = "SELECT course.code,
course_rel_user.status course_rel_status,
@ -3339,7 +3339,7 @@ class UserManager
//the tag doesn't exist
$sql = "INSERT INTO $table_user_tag (tag, field_id,count) VALUES ('$tag','$field_id', count + 1)";
$result = Database::query($sql);
$last_insert_id = Database::get_last_insert_id();
$last_insert_id = Database::insert_id();
} else {
//the tag exists we update it
$sql = "UPDATE $table_user_tag SET count = count + 1 WHERE id = $tag_id";
@ -3565,7 +3565,7 @@ class UserManager
$tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
$tbl_course_field = Database :: get_main_table(TABLE_MAIN_COURSE_FIELD);
$tbl_course_field_value = Database :: get_main_table(TABLE_MAIN_COURSE_FIELD_VALUES);
$tbl_user_course_category = Database :: get_user_personal_table(TABLE_USER_COURSE_CATEGORY);
$tbl_user_course_category = Database :: get_main_table(TABLE_USER_COURSE_CATEGORY);
//we filter the courses from the URL
$join_access_url=$where_access_url='';

@ -130,7 +130,6 @@ $update = function($_configuration, $mainConnection, $dryRun, $output, $app) {
//Database::query($sql);
$mainConnection->executeQuery($sql);
$id = $mainConnection->lastInsertId('id');
//$id = Database::get_last_insert_id();
$oldGroups[$group['id']] = $id;
}
}
@ -212,4 +211,4 @@ $update = function($_configuration, $mainConnection, $dryRun, $output, $app) {
if (!$dryRun) {
$mainConnection->commit();
}
};
};

@ -793,7 +793,7 @@ class aicc extends learnpath
require_once 'learnpath_functions.inc.php';
$course_id = api_get_course_int_id();
$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
$_course = Database::get_course_info(api_get_course_id());
$_course = api_get_course_info(api_get_course_id());
$sql = "SELECT * FROM $tbl_lp WHERE c_id = ".$course_id." id=".$lp_id;
$result = Database::query($sql);

@ -2086,8 +2086,6 @@ function showorhide_addresourcelink($type, $id)
*/
function rl_get_html_resource_link($course_code, $type, $id, $style = '', $new_window = true)
{
$_course = Database::get_course_info($course_code);
$course_id = api_get_course_int_id();
// Styling the link of the added resource
@ -2334,7 +2332,7 @@ function rl_get_resource_link_for_learnpath($course_id, $learnpath_id, $id_in_pa
*/
function rl_get_resource_name($course_code, $learnpath_id, $id_in_path)
{
$_course = Database::get_course_info($course_code);
$_course = api_get_course_info($course_code);
$course_id = $_course['real_id'];
$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);

@ -898,7 +898,7 @@ class scorm extends learnpath
require_once 'learnpath_functions.inc.php';
$course_id = api_get_course_int_id();
$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
$_course = Database::get_course_info(api_get_course_id());
$_course = api_get_course_info(api_get_course_id());
$sql = "SELECT * FROM $tbl_lp WHERE c_id = ".$course_id." AND id=".$lp_id;
$result = Database::query($sql);

@ -54,7 +54,7 @@ class LearnpathController
$app['breadcrumb'] = $breadcrumb;
//Find session
// Find session.
$sessionId = api_get_session_id();
$session = null;
if (!empty($sessionId)) {
@ -213,4 +213,4 @@ class LearnpathController
return new Response($response, 200, array());
}
}
}

@ -29,10 +29,9 @@ class UserPortalController extends CommonController
//@todo Use filters like "after/before|finish" to manage user access
api_block_anonymous_users();
//Abort request because the user is not allowed here - @todo use filters
if ($app['allowed'] == false) {
return $app->abort(403);
return $app->abort(403, 'Not allowed');
}
// Check if a user is enrolled only in one course for going directly to the course after the login.

Loading…
Cancel
Save