Merge with 1.10.x

ofaj
jmontoyaa 8 years ago
commit c9531cd398
  1. 44
      main/admin/course_user_import.php
  2. 4
      main/inc/lib/formvalidator/FormValidator.class.php
  3. 29
      main/inc/lib/groupmanager.lib.php
  4. 5
      main/install/configuration.dist.php

@ -72,9 +72,17 @@ function save_data($users_courses)
$course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$csv_data = array();
$inserted_in_course = array();
$courseListCache = [];
$courseListById = [];
foreach ($users_courses as $user_course) {
$csv_data[$user_course['UserName']][$user_course['CourseCode']] = $user_course['Status'];
if (!in_array($user_course['CourseCode'], array_keys($courseListCache))) {
$courseInfo = api_get_course_info($user_course['CourseCode']);
$courseListCache[$user_course['CourseCode']] = $courseInfo;
} else {
$courseInfo = $courseListCache[$user_course['CourseCode']];
}
$courseListById[$courseInfo['real_id']] = $courseInfo;
$csv_data[$user_course['UserName']][$courseInfo['real_id']] = $user_course['Status'];
}
foreach ($csv_data as $username => $csv_subscriptions) {
@ -96,33 +104,24 @@ function save_data($users_courses)
if ($_POST['subscribe']) {
foreach ($to_subscribe as $courseId) {
$courseInfo = api_get_course_info_by_id($courseId);
$course_code = $courseInfo['code'];
$courseInfo = $courseListById[$courseId];
$courseCode = $courseInfo['code'];
if (CourseManager :: course_exists($course_code)) {
CourseManager::subscribe_user(
$user_id,
$course_code,
$csv_subscriptions[$course_code]
$courseCode,
$csv_subscriptions[$courseId]
);
$course_info = CourseManager::get_course_information($course_code);
$inserted_in_course[$course_code] = $course_info['title'];
$inserted_in_course[$course_info['code']] = $course_info['title'];
}
$inserted_in_course[$courseInfo['code']] = $courseInfo['title'];
}
}
if ($_POST['unsubscribe']) {
foreach ($to_unsubscribe as $courseId) {
$courseInfo = api_get_course_info_by_id($courseId);
$course_code = $courseInfo['code'];
if (CourseManager :: course_exists($course_code)) {
CourseManager::unsubscribe_user($user_id, $course_code);
$course_info = CourseManager::get_course_information($course_code);
CourseManager::unsubscribe_user($user_id, $course_code);
$inserted_in_course[$course_info['code']] = $course_info['title'];
}
$courseInfo = $courseListById[$courseId];
$courseCode = $courseInfo['code'];
CourseManager::unsubscribe_user($user_id, $courseCode);
}
}
}
@ -189,10 +188,11 @@ if ($form->validate()) {
$warn = get_lang('ErrorsWhenImportingFile');
}
Display::addFlash(Display::return_message($warn));
Security::clear_token();
$tok = Security::get_token();
Display::addFlash(Display::return_message($warn));
header('Location: user_list.php?sec_token='.$tok);
header('Location: '.api_get_self());
exit();
}
}

@ -1333,14 +1333,14 @@ EOT;
var uploadButton = $('<button/>')
.addClass('btn btn-primary')
.prop('disabled', true)
.text('".get_lang('Loading')."')
.text('".addslashes(get_lang('Loading'))."')
.on('click', function () {
var \$this = $(this),
data = \$this.data();
\$this
.off('click')
.text('".get_lang('Cancel')."')
.text('".addslashes(get_lang('Cancel'))."')
.on('click', function () {
\$this.remove();
data.abort();

@ -401,12 +401,13 @@ class GroupManager
self::unsubscribe_all_users($group_ids);
self::unsubscribe_all_tutors($group_ids);
$sql = "SELECT id, secret_directory, session_id
$sql = "SELECT id, iid, secret_directory, session_id
FROM $group_table
WHERE c_id = $course_id AND id IN (".implode(' , ', $group_ids).")";
$db_result = Database::query($sql);
while ($group = Database::fetch_object($db_result)) {
$groupId = $group->iid;
// move group-documents to garbage
$source_directory = api_get_path(SYS_COURSE_PATH).$course_info['path']."/document".$group->secret_directory;
// File to renamed
@ -426,22 +427,22 @@ class GroupManager
}
}
}
}
$sql = "DELETE FROM ".$forum_table."
WHERE c_id = $course_id AND forum_of_group IN ('".implode("' , '", $group_ids)."')";
Database::query($sql);
$sql = "DELETE FROM $forum_table
WHERE c_id = $course_id AND forum_of_group = $groupId ";
Database::query($sql);
// Delete item properties of this group.
$itemPropertyTable = Database::get_course_table(TABLE_ITEM_PROPERTY);
$sql = "DELETE FROM ".$itemPropertyTable."
WHERE c_id = $course_id AND to_group_id IN ('".implode("' , '", $group_ids)."')";
Database::query($sql);
// Delete item properties of this group.
$itemPropertyTable = Database::get_course_table(TABLE_ITEM_PROPERTY);
$sql = "DELETE FROM $itemPropertyTable
WHERE c_id = $course_id AND to_group_id = $groupId ";
Database::query($sql);
// delete the groups
$sql = "DELETE FROM ".$group_table."
WHERE c_id = $course_id AND id IN ('".implode("' , '", $group_ids)."')";
Database::query($sql);
// delete the groups
$sql = "DELETE FROM $group_table
WHERE c_id = $course_id AND iid = $groupId ";
Database::query($sql);
}
return true;
}

@ -242,5 +242,8 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE;
//$_configuration['packager'] = 'chamilo';
// If true exercises added in LP can be modified.
//$_configuration['force_edit_exercise_in_lp'] = false;
// to reflect their packaging method. The default value is 'chamilo'. This will
// be reflected on the https://version.chamilo.org/stats page in the future.
//$_configuration['packager'] = 'chamilo';
// List of driver to plugin in ckeditor
//$_configuration['editor_driver_list'] = ['PersonalDriver', 'CourseDriver'];
//$_configuration['editor_driver_list'] = ['PersonalDriver', 'CourseDriver'];

Loading…
Cancel
Save