Merge branch '1.9.x' into 1.10.x

1.10.x
Julio Montoya 10 years ago
commit 16a83deff8
  1. 2
      main/admin/example_class.csv
  2. 4
      main/gradebook/lib/fe/flatviewtable.class.php
  3. 6
      main/group/example.csv
  4. 7
      main/group/group.php
  5. 27
      main/group/group_overview.php
  6. 4
      main/group/import.php
  7. 175
      main/inc/lib/groupmanager.lib.php
  8. 7
      main/work/downloadfolder.inc.php

@ -1,3 +1,3 @@
name;description
name;description;
Class A4;20 students in general courses
Class B5;20 students from technical background

1 name name;description; description
2 Class A4 Class A4;20 students in general courses 20 students in general courses
3 Class B5 Class B5;20 students from technical background 20 students from technical background

@ -46,7 +46,7 @@ class FlatViewTable extends SortableTable
$addparams = null,
$mainCourseCategory = null
) {
parent :: __construct('flatviewlist', null, null, (api_is_western_name_order() xor api_sort_by_first_name()) ? 1 : 0);
parent :: __construct('flatviewlist', null, null, api_is_western_name_order() ? 1 : 0);
$this->selectcat = $selectcat;
@ -373,10 +373,12 @@ class FlatViewTable extends SortableTable
if ($is_western_name_order) {
//$users_sorting = ($this->column == 0 ? FlatViewDataGenerator :: FVDG_SORT_FIRSTNAME : FlatViewDataGenerator :: FVDG_SORT_LASTNAME);
$users_sorting = FlatViewDataGenerator :: FVDG_SORT_FIRSTNAME;
} else {
//$users_sorting = ($this->column == 0 ? FlatViewDataGenerator :: FVDG_SORT_LASTNAME : FlatViewDataGenerator :: FVDG_SORT_FIRSTNAME);
$users_sorting = FlatViewDataGenerator :: FVDG_SORT_LASTNAME;
}
if ($this->direction == 'DESC') {
$users_sorting |= FlatViewDataGenerator :: FVDG_SORT_DESC;
} else {

@ -1,5 +1,5 @@
"category";"group";"description";"announcements_state";"calendar_state";"chat_state";"doc_state";"forum_state";"work_state";"wiki_state";"max_student";"self_reg_allowed";"self_unreg_allowed";"groups_per_user";
"category";"group";"description";"announcements_state";"calendar_state";"chat_state";"doc_state";"forum_state";"work_state";"wiki_state";"max_student";"self_reg_allowed";"self_unreg_allowed";"groups_per_user";"students";"tutors"
"Category 1";"";"This is a category";"2";"2";"2";"2";"2";"2";"2";"0";"0";"0";"0";
"";"Group 1";"This is a group with no category";"2";"2";"2";"2";"2";"2";"2";"0";"0";"0"
"Category 1";"Group 2";"This is a group in a category 1";"2";"2";"2";"2";"2";"2";"2";"0";"0";"0"
"";"Group 1";"This is a group with no category";"2";"2";"2";"2";"2";"2";"2";"0";"0";"0";"";"username1,username2";"username3,username4"
"Category 1";"Group 2";"This is a group in a category 1";"2";"2";"2";"2";"2";"2";"2";"0";"0";"0";"";"username1,username2";"username3,username4"

Can't render this file because it has a wrong number of fields in line 3.

@ -167,18 +167,15 @@ if (api_is_allowed_to_edit(false, true)) {
echo '<a href="import.php?'.api_get_cidreq().'&action=import">'.
Display::return_icon('import_csv.png', get_lang('Import'), '', ICON_SIZE_MEDIUM).'</a>';
echo '<a href="group_overview.php?'.api_get_cidreq().'&action=export&type=csv">'.
echo '<a href="group_overview.php?'.api_get_cidreq().'&action=export_all&type=csv">'.
Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), '', ICON_SIZE_MEDIUM).'</a>';
echo '<a href="group_overview.php?'.api_get_cidreq().'&action=export&type=xls">'.
echo '<a href="group_overview.php?'.api_get_cidreq().'&action=export_all&type=xls">'.
Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM).'</a>';
echo '<a href="group_overview.php?'.api_get_cidreq().'&action=export_pdf">'.
Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM).'</a>';
echo '<a href="group_overview.php?'.api_get_cidreq().'&action=export_all&type=xls">'.
Display::return_icon('export_excel.png', get_lang('ExportSettingsAsXLS'), '', ICON_SIZE_MEDIUM).'</a>';
echo '<a href="group_overview.php?'.api_get_cidreq().'">'.
Display::return_icon('group_summary.png', get_lang('GroupOverview'), '', ICON_SIZE_MEDIUM).'</a>';

@ -1,5 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Main page for the group module.
* This script displays the general group settings,
@ -12,9 +13,6 @@
* @author Bart Mollet, code cleaning, use of Display-library, list of courseAdmin-tools, use of GroupManager
* @package chamilo.group
*/
/**
* INIT SECTION
*/
// Name of the language file that needs to be included
$language_file = array('group', 'admin');
@ -39,7 +37,7 @@ $keyword = isset($_GET['keyword']) ? $_GET['keyword'] : null;
if (isset($_GET['action'])) {
switch ($_GET['action']) {
case 'export_all':
$data = GroupManager::exportCategoriesAndGroupsToArray();
$data = GroupManager::exportCategoriesAndGroupsToArray(null, true);
Export::export_table_csv($data);
exit;
break;
@ -54,26 +52,9 @@ if (isset($_GET['action'])) {
break;
case 'export':
$groupId = isset($_GET['id']) ? intval($_GET['id']) : null;
$groups = GroupManager::get_group_list();
$data = array();
foreach ($groups as $index => $group) {
if (!empty($groupId)) {
if ($group['id'] != $groupId) {
continue;
}
}
$users = GroupManager::get_users($group['id']);
foreach ($users as $index => $user) {
$row = array();
$user = api_get_user_info($user);
$row[] = $group['name'];
$row[] = $user['official_code'];
$row[] = $user['lastName'];
$row[] = $user['firstName'];
$data[] = $row;
}
}
$data = GroupManager::exportCategoriesAndGroupsToArray($groupId, true);
switch ($_GET['type']) {
case 'csv':
Export::export_table_csv($data);

@ -35,7 +35,9 @@ $form->addElement('label', null, Display::url(get_lang('ExampleCSVFile'), api_ge
$form->addElement('button', 'submit', get_lang('Import'));
if ($form->validate()) {
if (isset($_FILES['file']['tmp_name']) && !empty($_FILES['file']['tmp_name'])) {
if (isset($_FILES['file']['tmp_name']) &&
!empty($_FILES['file']['tmp_name'])
) {
$groupData = Import::csv_reader($_FILES['file']['tmp_name']);
$deleteNotInArray = $form->getSubmitValue('delete_not_in_file') == 1 ? true : false;

@ -84,34 +84,31 @@ class GroupManager
*/
public static function get_group_list($category = null, $course_code = null)
{
$my_user_id = api_get_user_id();
$course_info = api_get_course_info($course_code);
$session_id = api_get_session_id();
$course_id = $course_info['real_id'];
$table_group_user = Database :: get_course_table(TABLE_GROUP_USER);
$table_group = Database :: get_course_table(TABLE_GROUP);
//condition for the session
$session_id = api_get_session_id();
$sql = "SELECT g.id,
g.name,
g.description,
g.category_id,
g.max_student maximum_number_of_members,
g.secret_directory,
g.self_registration_allowed,
g.self_unregistration_allowed,
g.session_id,
ug.user_id is_member
FROM $table_group g
LEFT JOIN $table_group_user ug
ON (
ug.group_id = g.id AND
ug.user_id = '".api_get_user_id()."' AND
ug.c_id = $course_id AND
g.c_id = $course_id
)";
g.name,
g.description,
g.category_id,
g.max_student maximum_number_of_members,
g.secret_directory,
g.self_registration_allowed,
g.self_unregistration_allowed,
g.session_id,
ug.user_id is_member
FROM $table_group g
LEFT JOIN $table_group_user ug
ON (
ug.group_id = g.id AND
ug.user_id = '".api_get_user_id()."' AND
ug.c_id = $course_id AND
g.c_id = $course_id
)";
$sql .= " WHERE 1=1 ";
@ -377,7 +374,7 @@ class GroupManager
}
/**
* deletes groups and their data.
* Deletes groups and their data.
* @author Christophe Gesche <christophe.gesche@claroline.net>
* @author Hugues Peeters <hugues.peeters@claroline.net>
* @author Bart Mollet
@ -389,11 +386,11 @@ class GroupManager
public static function delete_groups($group_ids, $course_code = null)
{
$course_info = api_get_course_info($course_code);
$course_id = $course_info['real_id'];
$course_id = $course_info['real_id'];
// Database table definitions
$group_table = Database :: get_course_table(TABLE_GROUP);
$forum_table = Database :: get_course_table(TABLE_FORUM);
$group_table = Database:: get_course_table(TABLE_GROUP);
$forum_table = Database:: get_course_table(TABLE_FORUM);
$group_ids = is_array($group_ids) ? $group_ids : array ($group_ids);
$group_ids = array_map('intval',$group_ids);
@ -413,6 +410,8 @@ class GroupManager
// Unsubscribe all users
self :: unsubscribe_all_users($group_ids);
self ::unsubscribe_all_tutors($group_ids);
$sql = "SELECT id, secret_directory, session_id FROM $group_table
WHERE c_id = $course_id AND id IN (".implode(' , ', $group_ids).")";
$db_result = Database::query($sql);
@ -1084,6 +1083,8 @@ class GroupManager
$sql = "SELECT user_id FROM $tutor_user_table
WHERE c_id = $course_id AND group_id = $group_id";
$res = Database::query($sql);
$users = array();
while ($obj = Database::fetch_object($res)) {
$users[] = api_get_user_info($obj->user_id);
}
@ -1524,10 +1525,10 @@ class GroupManager
}
/**
* Subscribe user(s) to a specified group in current course
* Subscribe user(s) to a specified group in current course (as a student)
* @param mixed $user_ids Can be an array with user-id's or a single user-id
* @param int $group_id
* @return bool TRUE if successfull
* @return bool TRUE if successful
*/
public static function subscribe_users($user_ids, $group_id)
{
@ -1567,9 +1568,11 @@ class GroupManager
foreach ($user_ids as $user_id) {
$user_id = intval($user_id);
$group_id = intval($group_id);
$sql = "INSERT INTO ".$table_group_tutor." (c_id, user_id, group_id)
VALUES ('$course_id', '".$user_id."', '".$group_id."')";
$result &= Database::query($sql);
if (self::can_user_subscribe($user_id, $group_id)) {
$sql = "INSERT INTO " . $table_group_tutor . " (c_id, user_id, group_id)
VALUES ('$course_id', '" . $user_id . "', '" . $group_id . "')";
$result &= Database::query($sql);
}
}
return $result;
}
@ -2266,7 +2269,6 @@ class GroupManager
}
/**
*
* @param array $groupData
* @param bool $deleteNotInArray
* @return array
@ -2404,6 +2406,27 @@ class GroupManager
$data['group_id'] = $groupId;
$result['updated']['group'][] = $data;
}
$students = isset($data['students']) ? explode(',', $data['students']) : null;
if (!empty($students)) {
$studentUserIdList = array();
foreach ($students as $student) {
$userInfo = api_get_user_info_from_username($student);
$studentUserIdList[] = $userInfo['user_id'];
}
self::subscribe_users($studentUserIdList, $groupId);
}
$tutors = isset($data['tutors']) ? explode(',', $data['tutors']) : null;
if (!empty($tutors)) {
$tutorIdList = array();
foreach ($tutors as $tutor) {
$userInfo = api_get_user_info_from_username($tutor);
$tutorIdList[] = $userInfo['user_id'];
}
self::subscribe_tutors($tutorIdList, $groupId);
}
$elementsFound['groups'][] = $groupId;
}
}
@ -2434,9 +2457,11 @@ class GroupManager
/**
* Export all categories/group from a course to an array.
* This function works only in a context of a course.
* @param int $groupId
* @param bool $loadUsers
* @return array
*/
public static function exportCategoriesAndGroupsToArray()
public static function exportCategoriesAndGroupsToArray($groupId = null, $loadUsers = false)
{
$data = array();
$data[] = array(
@ -2456,25 +2481,35 @@ class GroupManager
'groups_per_user'
);
$categories = GroupManager::get_categories();
$count = 1;
foreach ($categories as $categoryInfo) {
$data[] = array(
$categoryInfo['title'],
null,
$categoryInfo['description'],
$categoryInfo['announcements_state'],
$categoryInfo['calendar_state'],
$categoryInfo['chat_state'],
$categoryInfo['doc_state'],
$categoryInfo['forum_state'],
$categoryInfo['work_state'],
$categoryInfo['wiki_state'],
$categoryInfo['max_student'],
$categoryInfo['self_reg_allowed'],
$categoryInfo['self_unreg_allowed'],
$categoryInfo['groups_per_user']
);
if ($loadUsers) {
$data[0][] = 'students';
$data[0][] = 'tutors';
}
if ($loadUsers == false) {
$categories = GroupManager::get_categories();
foreach ($categories as $categoryInfo) {
$data[$count] = array(
$categoryInfo['title'],
null,
$categoryInfo['description'],
$categoryInfo['announcements_state'],
$categoryInfo['calendar_state'],
$categoryInfo['chat_state'],
$categoryInfo['doc_state'],
$categoryInfo['forum_state'],
$categoryInfo['work_state'],
$categoryInfo['wiki_state'],
$categoryInfo['max_student'],
$categoryInfo['self_reg_allowed'],
$categoryInfo['self_unreg_allowed'],
$categoryInfo['groups_per_user']
);
$count++;
}
}
$groups = GroupManager::get_group_list();
@ -2487,7 +2522,31 @@ class GroupManager
$categoryTitle = $categoryInfo['title'];
}
$data[] = array(
$users = GroupManager::getStudents($groupInfo['id']);
$userList = array();
foreach ($users as $user) {
$user = api_get_user_info($user['user_id']);
$userList[] = $user['username'];
}
$tutors = GroupManager::getTutors($groupInfo['id']);
$tutorList = array();
foreach ($tutors as $user) {
$user = api_get_user_info($user['user_id']);
$tutorList[] = $user['username'];
}
$userListToString = null;
if (!empty($userList)) {
$userListToString = implode(',', $userList);
}
$tutorListToString = null;
if (!empty($tutorList)) {
$tutorListToString = implode(',', $tutorList);
}
$data[$count] = array(
$categoryTitle,
$groupSettings['name'],
$groupSettings['description'],
@ -2501,8 +2560,22 @@ class GroupManager
$groupSettings['maximum_number_of_students'],
$groupSettings['self_registration_allowed'],
$groupSettings['self_unregistration_allowed'],
null
);
if ($loadUsers) {
$data[$count][] = $userListToString;
$data[$count][] = $tutorListToString;
}
if (!empty($groupId)) {
if ($groupId == $groupInfo['id']) {
break;
}
}
$count++;
}
return $data;
}

@ -178,11 +178,12 @@ while ($not_deleted_file = Database::fetch_assoc($query)) {
}
if (!empty($files)) {
//logging
event_download(basename($work_data['title']).'.zip (folder)');
$fileName = replace_dangerous_char($work_data['title']);
// Logging
event_download($fileName .'.zip (folder)');
//start download of created file
$name = basename($work_data['title']).'.zip';
$name = $fileName .'.zip';
if (Security::check_abs_path($temp_zip_file, api_get_path(SYS_ARCHIVE_PATH))) {
DocumentManager::file_send_for_download($temp_zip_file, true, $name);
@unlink($temp_zip_file);

Loading…
Cancel
Save