1.9.x
Cesar Perales 11 years ago
commit cb31585cc7
  1. 91
      main/admin/add_courses_to_usergroup.php
  2. 38
      main/admin/user_import.php
  3. 9
      main/admin/user_list.php
  4. 24
      main/coursecopy/classes/CourseRestorer.class.php
  5. 1
      main/exercice/answer.class.php
  6. 4
      main/gradebook/lib/gradebook_functions.inc.php
  7. 9
      main/group/group.php
  8. 24
      main/group/group_creation.php
  9. 52
      main/inc/lib/course.lib.php
  10. 2
      main/inc/lib/course_category.lib.php
  11. 246
      main/inc/lib/groupmanager.lib.php
  12. 2
      main/inc/lib/internationalization.lib.php
  13. 1
      main/inc/lib/main_api.lib.php
  14. 4
      main/inc/lib/tracking.lib.php
  15. 43
      main/inc/lib/usermanager.lib.php
  16. 2
      main/inc/lib/zombie/zombie_manager.class.php
  17. 27
      main/newscorm/lp_upload.php
  18. 44
      main/newscorm/openoffice_document.class.php
  19. 78
      main/newscorm/openoffice_presentation.class.php
  20. 2
      main/template/default/layout/topbar.tpl
  21. 98
      main/upload/upload_ppt.php
  22. 34
      main/work/work.lib.php

@ -82,28 +82,27 @@ $errorMsg = '';
$sessions=array();
$usergroup = new UserGroup();
$id = intval($_GET['id']);
if($_POST['form_sent']) {
$form_sent = $_POST['form_sent'];
$elements_posted = $_POST['elements_in_name'];
if ($_POST['form_sent']) {
$form_sent = $_POST['form_sent'];
$elements_posted = $_POST['elements_in_name'];
if (!is_array($elements_posted)) {
$elements_posted=array();
}
if ($form_sent == 1) {
$usergroup->subscribe_courses_to_usergroup($id, $elements_posted);
header('Location: usergroups.php');
exit;
exit;
}
}
$data = $usergroup->get($id);
$course_list_in = $usergroup->get_courses_by_usergroup($id);
$course_list = CourseManager::get_courses_list(0,0,'title');
$data = $usergroup->get($id);
$course_list_in = $usergroup->get_courses_by_usergroup($id);
$course_list = CourseManager::get_courses_list(0, 0, 'title', 'asc', -1, null, api_get_current_access_url_id());
//api_display_tool_title($tool_name.' ('.$session_info['name'].')');
$elements_not_in = $elements_in= array();
if (!empty($course_list)) {
foreach($course_list as $item) {
if (in_array($item['id'], $course_list_in)) {
foreach ($course_list as $item) {
if (in_array($item['id'], $course_list_in)) {
$elements_in[$item['id']] = $item['title']." (".$item['visual_code'].")";
} else {
$elements_not_in[$item['id']] = $item['title']." (".$item['visual_code'].")";
@ -114,8 +113,9 @@ $ajax_search = $add_type == 'unique' ? true : false;
//checking for extra field with filter on
function search($needle,$type) {
global $tbl_user,$elements_in;
function search($needle,$type)
{
global $elements_in;
$xajax_response = new XajaxResponse();
$return = '';
if (!empty($needle) && !empty($type)) {
@ -135,8 +135,7 @@ function search($needle,$type) {
' LIMIT 11';*/
} else {
$list = CourseManager::get_courses_list(0, 0, 2, 'ASC', -1, $needle);
}
$i=0;
}
if ($type=='single') {
/*
while ($user = Database :: fetch_array($rs)) {
@ -151,42 +150,45 @@ function search($needle,$type) {
$xajax_response -> addAssign('ajax_list_users_single','innerHTML',api_utf8_encode($return));*/
} else {
$return .= '<select id="elements_not_in" name="elements_not_in_name[]" multiple="multiple" size="15" style="width:360px;">';
foreach ($list as $row ) {
if (!in_array($row['id'], array_keys($elements_in))) {
foreach ($list as $row) {
if (!in_array($row['id'], array_keys($elements_in))) {
$return .= '<option value="'.$row['id'].'">'.$row['title'].' ('.$row['visual_code'].')</option>';
}
}
$return .= '</select>';
$xajax_response -> addAssign('ajax_list_multiple','innerHTML',api_utf8_encode($return));
$xajax_response->addAssign('ajax_list_multiple', 'innerHTML', api_utf8_encode($return));
}
}
return $xajax_response;
}
$xajax -> processRequests();
$xajax->processRequests();
Display::display_header($tool_name);
if ($add_type == 'multiple') {
$link_add_type_unique = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.Security::remove_XSS($_GET['add']).'&add_type=unique">'.Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'</a>';
$link_add_type_unique = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.Security::remove_XSS($_GET['add']).'&add_type=unique">'.
Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'</a>';
$link_add_type_multiple = Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple');
} else {
$link_add_type_unique = Display::return_icon('single.gif').get_lang('SessionAddTypeUnique');
$link_add_type_multiple = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.Security::remove_XSS($_GET['add']).'&add_type=multiple">'.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>';
$link_add_type_multiple = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.Security::remove_XSS($_GET['add']).'&add_type=multiple">'.
Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>';
}
echo '<div class="actions">';
echo '<a href="usergroups.php">'.Display::return_icon('back.png',get_lang('Back'), array(), ICON_SIZE_MEDIUM).'</a>';
echo '<a href="usergroups.php">'.Display::return_icon('back.png',get_lang('Back'), array(), ICON_SIZE_MEDIUM).'</a>';
echo '</div>';
?>
<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?id=<?php echo $id; if(!empty($_GET['add'])) echo '&add=true' ; ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>>
<?php echo '<legend>'.$data['name'].': '.$tool_name.'</legend>';
<?php echo '<legend>'.$data['name'].': '.$tool_name.'</legend>';
if ($add_type=='multiple') {
if (is_array($extra_field_list)) {
if (is_array($new_field_list) && count($new_field_list)>0 ) {
if (is_array($new_field_list) && count($new_field_list) > 0) {
echo '<h3>'.get_lang('FilterUsers').'</h3>';
foreach ($new_field_list as $new_field) {
echo $new_field['name'];
@ -210,10 +212,10 @@ if ($add_type=='multiple') {
}
}
}
echo Display::input('hidden','id',$id);
echo Display::input('hidden','form_sent','1');
echo Display::input('hidden','add_type',null);
if(!empty($errorMsg)) {
echo Display::input('hidden', 'id', $id);
echo Display::input('hidden', 'form_sent', '1');
echo Display::input('hidden', 'add_type', null);
if (!empty($errorMsg)) {
Display::display_normal_message($errorMsg); //main API
}
?>
@ -230,12 +232,12 @@ if(!empty($errorMsg)) {
<tr>
<td align="center">
<?php echo get_lang('FirstLetterCourseTitle'); ?> :
<select name="firstLetterUser" onchange = "xajax_search(this.value,'multiple')" >
<option value = "%">--</option>
<?php
echo Display :: get_alphabet_options();
?>
</select>
<select name="firstLetterUser" onchange = "xajax_search(this.value,'multiple')" >
<option value = "%">--</option>
<?php
echo Display :: get_alphabet_options();
?>
</select>
</td>
<td align="center">&nbsp;</td>
</tr>
@ -243,16 +245,16 @@ if(!empty($errorMsg)) {
<tr>
<td align="center">
<div id="content_source">
<?php
if (!($add_type=='multiple')) {
<?php
if (!($add_type=='multiple')) {
?>
<input type="text" id="user_to_add" onkeyup="xajax_search_users(this.value,'single')" />
<div id="ajax_list_users_single"></div>
<?php
} else {
} else {
?>
<div id="ajax_list_multiple">
<?php echo Display::select('elements_not_in_name',$elements_not_in, '',array('style'=>'width:360px', 'multiple'=>'multiple','id'=>'elements_not_in','size'=>'15px'),false); ?>
<?php echo Display::select('elements_not_in_name', $elements_not_in, '', array('style'=>'width:360px', 'multiple'=>'multiple','id'=>'elements_not_in','size'=>'15px'),false); ?>
</div>
<?php
}
@ -294,8 +296,7 @@ if(!empty($errorMsg)) {
</form>
<script type="text/javascript">
<!--
function moveItem(origin , destination){
function moveItem(origin , destination) {
for(var i = 0 ; i<origin.options.length ; i++) {
if(origin.options[i].selected) {
@ -339,9 +340,7 @@ function valide(){
document.forms.formulaire.submit();
}
function loadUsersInSelect(select){
function loadUsersInSelect(select) {
var xhr_object = null;
if(window.XMLHttpRequest) // Firefox
@ -351,12 +350,9 @@ function loadUsersInSelect(select){
else // XMLHttpRequest non supporté par le navigateur
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
//xhr_object.open("GET", "loadUsersInSelect.ajax.php?id_session=<?php echo $id_session ?>&letter="+select.options[select.selectedIndex].text, false);
xhr_object.open("POST", "loadUsersInSelect.ajax.php");
xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
nosessionUsers = makepost(document.getElementById('elements_not_in'));
sessionUsers = makepost(document.getElementById('elements_in'));
nosessionClasses = makepost(document.getElementById('origin_classes'));
@ -366,7 +362,6 @@ function loadUsersInSelect(select){
xhr_object.onreadystatechange = function() {
if(xhr_object.readyState == 4) {
document.getElementById('content_source').innerHTML = result = xhr_object.responseText;
//alert(xhr_object.responseText);
}
}
}
@ -376,10 +371,8 @@ function makepost(select){
var ret = "";
for (i = 0 ; i<options.length ; i++)
ret = ret + options[i].value +'::'+options[i].text+";;";
return ret;
}
-->
</script>
<?php
Display::display_footer();

@ -114,26 +114,45 @@ function complete_missing_data($user) {
* @return void
* @uses global variable $inserted_in_course, which returns the list of courses the user was inserted in
*/
function save_data($users) {
function save_data($users)
{
global $inserted_in_course;
// Not all scripts declare the $inserted_in_course array (although they should).
if (!isset($inserted_in_course)) {
$inserted_in_course = array();
}
require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
$send_mail = $_POST['sendMail'] ? 1 : 0;
$send_mail = $_POST['sendMail'] ? true : false;
if (is_array($users)) {
foreach ($users as $user) {
$user = complete_missing_data($user);
$user['Status'] = api_status_key($user['Status']);
$user_id = UserManager :: create_user($user['FirstName'], $user['LastName'], $user['Status'], $user['Email'], $user['UserName'], $user['Password'], $user['OfficialCode'], $user['language'], $user['PhoneNumber'], '', $user['AuthSource'], null, 1, 0, null, null, $send_mail);
$user_id = UserManager :: create_user(
$user['FirstName'],
$user['LastName'],
$user['Status'],
$user['Email'],
$user['UserName'],
$user['Password'],
$user['OfficialCode'],
$user['language'],
$user['PhoneNumber'],
'',
$user['AuthSource'],
null,
1,
0,
null,
null,
$send_mail
);
if (!is_array($user['Courses']) && !empty($user['Courses'])) {
$user['Courses'] = array($user['Courses']);
}
if (is_array($user['Courses'])) {
foreach ($user['Courses'] as $index => $course) {
if (CourseManager :: course_exists($course)) {
CourseManager :: subscribe_user($user_id, $course,$user['Status']);
foreach ($user['Courses'] as $course) {
if (CourseManager::course_exists($course)) {
CourseManager::subscribe_user($user_id, $course, $user['Status']);
$course_info = CourseManager::get_course_information($course);
$inserted_in_course[$course] = $course_info['title'];
}
@ -144,13 +163,14 @@ function save_data($users) {
if ($vcourse['code'] == $course) {
// Ignore, this has already been inserted.
} else {
CourseManager :: subscribe_user($user_id, $vcourse['code'],$user['Status']);
CourseManager :: subscribe_user($user_id, $vcourse['code'], $user['Status']);
$inserted_in_course[$vcourse['code']] = $vcourse['title'];
}
}
}
}
}
if (!empty($user['ClassName'])) {
$class_id = ClassManager :: get_class_id($user['ClassName']);
ClassManager :: add_user($user_id, $class_id);
@ -160,11 +180,11 @@ function save_data($users) {
global $extra_fields;
// We are sure that the extra field exists.
foreach($extra_fields as $extras) {
foreach ($extra_fields as $extras) {
if (isset($user[$extras[1]])) {
$key = $extras[1];
$value = $user[$extras[1]];
UserManager::update_extra_field_value($user_id, $key,$value);
UserManager::update_extra_field_value($user_id, $key, $value);
}
}
}

@ -897,8 +897,13 @@ $table->set_column_filter(7, 'status_filter');
$table->set_column_filter(8, 'active_filter');
$table->set_column_filter(10, 'modify_filter');
if (api_is_platform_admin())
$table->set_form_actions(array ('delete' => get_lang('DeleteFromPlatform')));
// Only show empty actions bar if delete users has been blocked
if (api_is_platform_admin() && !(isset($_configuration['deny_delete_users']) && $_configuration['deny_delete_users'])) {
$table->set_form_actions(array ('delete' => get_lang('DeleteFromPlatform')));
} else {
$table->set_form_actions(array ('none' => get_lang('NoActionAvailable')));
}
$table_result = $table->return_table();

@ -2026,10 +2026,12 @@ class CourseRestorer
// check resources inside html from fckeditor tool and copy correct urls into recipient course
$obj->params['description'] = DocumentManager::replace_urls_inside_content_html_from_copy_course($obj->params['description'], $this->course->code, $this->course->destination_path, $this->course->backup_path, $this->course->info['path']);
$id_work = $obj->params['id'];
$obj->params['id'] = null;
$obj->params['c_id'] = $this->destination_course_id;
$last_id = Database::insert($table_work, $obj->params);
// re-create dir
// @todo check security against injection of dir in crafted course backup here!
$path = $obj->params['url'];
@ -2041,6 +2043,28 @@ class CourseRestorer
}
if (is_numeric($last_id)) {
$sql = 'SELECT *
FROM '.$table_work_assignment.'
WHERE c_id = '.$this->course_origin_id.' AND
publication_id = '.$id_work;
$result = Database::query($sql);
$cant = Database::num_rows($result);
if ($cant > 0) {
$row = Database::fetch_assoc($result);
$expires_date = $row['expires_on'];
$end_date = $row['ends_on'];
$add_to_calendar = $row['add_to_calendar'];
$enable_calification = $row['enable_calification'];
$sql_add_homework = "INSERT INTO $table_work_assignment SET
c_id = $this->destination_course_id ,
expires_on = '$expires_date',
ends_on = '$end_date',
add_to_calendar = '$add_to_calendar',
enable_qualification = '$enable_calification',
publication_id = '$last_id'";
Database::query($sql_add_homework);
}
api_item_property_update($this->destination_course_info, 'work', $last_id,"DirectoryCreated", api_get_user_id());
}
}

@ -545,6 +545,7 @@ class Answer
$this->cancel();
}
/**
* Duplicates answers by copying them into another question
*

@ -361,8 +361,10 @@ function is_resource_in_course_gradebook($course_code, $resource_type, $resource
{
$l = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
$course_code = Database::escape_string($course_code);
$sql = "SELECT * FROM $l l WHERE course_code = '$course_code' AND type = " . (int) $resource_type . " and ref_id = " . (int) $resource_id;
$sql = "SELECT * FROM $l l
WHERE course_code = '$course_code' AND type = ".(int)$resource_type . " AND ref_id = " . (int)$resource_id;
$res = Database::query($sql);
if (Database::num_rows($res) < 1) {
return false;
}

@ -19,6 +19,9 @@
$language_file = 'group';
require_once '../inc/global.inc.php';
$is_allowed_in_course = api_is_allowed_to_edit(false, true);
$this_section = SECTION_COURSES;
$current_course_tool = TOOL_GROUP;
@ -27,12 +30,12 @@ api_protect_course_script(true);
$htmlHeadXtra[] = '<script>
$(document).ready( function() {
for (i=0;i<$(".actions").length;i++) {
for (i=0; i<$(".actions").length; i++) {
if ($(".actions:eq("+i+")").html()=="<table border=\"0\"></table>" || $(".actions:eq("+i+")").html()=="" || $(".actions:eq("+i+")").html()==null) {
$(".actions:eq("+i+")").hide();
}
}
} );
});
</script>';
$nameTools = get_lang('GroupManagement');
$course_id = api_get_course_int_id();
@ -45,7 +48,7 @@ if (api_get_setting('allow_group_categories') == 'false') {
$num = Database::num_rows($res);
if ($num == 0) {
$sql = "INSERT INTO ".$cat_table." ( c_id, id , title , description , forum_state, wiki_state, max_student, self_reg_allowed, self_unreg_allowed, groups_per_user, display_order)
VALUES ($course_id, '2', '".lang2db(get_lang('DefaultGroupCategory'))."', '', '1', '1', '8', '0', '0', '0', '0');";
VALUES ($course_id, '2', '".Database::escape_string(get_lang('DefaultGroupCategory'))."', '', '1', '1', '8', '0', '0', '0', '0');";
Database::query($sql);
}
}

@ -92,7 +92,6 @@ elseif (isset($_POST['number_of_groups'])) {
if ($number_of_groups > 1) {
?>
<script type="text/javascript">
<!--
var number_of_groups = <?php echo $number_of_groups; ?>;
function switch_state(key) {
for( i=1; i<number_of_groups; i++) {
@ -124,7 +123,6 @@ elseif (isset($_POST['number_of_groups'])) {
element.value = ref.value;
}
}
-->
</script>
<?php
}
@ -136,7 +134,7 @@ elseif (isset($_POST['number_of_groups'])) {
$cat_options[$category['id']] = $category['title'];
}
}
$form = new FormValidator('create_groups_step2');
$form = new FormValidator('create_groups_step2', 'POST', api_get_self().'?'.api_get_cidreq());
// Modify the default templates
$renderer = $form->defaultRenderer();
@ -216,7 +214,7 @@ EOT;
$categories = GroupManager :: get_categories();
//echo '<blockquote>';
if (count($categories) > 1 || isset ($categories[0]) && $categories[0]['id'] != GroupManager::VIRTUAL_COURSE_CATEGORY) {
$create_groups_form = new FormValidator('create_groups');
$create_groups_form = new FormValidator('create_groups', 'post', api_get_self().'?'.api_get_cidreq());
$create_groups_form->addElement('header', '', $nameTools);
$group_el = array ();
$group_el[] = $create_groups_form->createElement('static', null, null, get_lang('Create'));
@ -231,24 +229,6 @@ EOT;
} else {
echo get_lang('NoCategoriesDefined');
}
//echo '</blockquote>';
/*
* Show form to generate groups from virtual courses
*/
$virtual_courses = CourseManager :: get_virtual_courses_linked_to_real_course($_course['sysCode']);
if (count($virtual_courses) > 0) {
echo '<b>'.get_lang('CreateGroupsFromVirtualCourses').'</b>';
echo '<blockquote>';
echo get_lang('CreateGroupsFromVirtualCoursesInfo');
$create_virtual_groups_form = new FormValidator('create_virtual_groups');
$create_virtual_groups_form->addElement('hidden', 'action');
$create_virtual_groups_form->addElement('submit', 'submit', get_lang('Ok'));
$create_virtual_groups_form->setDefaults(array('action' => 'create_virtual_groups'));
$create_virtual_groups_form->display();
echo '</blockquote>';
}
/*
* Show form to generate subgroups
*/

@ -130,10 +130,25 @@ class CourseManager
* @param string The direction of the order (ASC or DESC). Optional, defaults to ASC.
* @param string The visibility of the course, or all by default.
* @param string If defined, only return results for which the course *title* begins with this string
* @return array
*/
public static function get_courses_list($from = 0, $howmany = 0, $orderby = 1, $orderdirection = 'ASC', $visibility = -1, $startwith = '') {
public static function get_courses_list(
$from = 0,
$howmany = 0,
$orderby = 1,
$orderdirection = 'ASC',
$visibility = -1,
$startwith = '',
$urlId = null
) {
$sql = "SELECT course.* FROM ".Database::get_main_table(TABLE_MAIN_COURSE)." course ";
if (!empty($urlId)) {
$table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$sql .= " INNER JOIN $table url ON (url.course_code = course.code) ";
}
$sql = "SELECT * FROM ".Database::get_main_table(TABLE_MAIN_COURSE)." ";
if (!empty($startwith)) {
$sql .= "WHERE title LIKE '".Database::escape_string($startwith)."%' ";
if ($visibility !== -1 && $visibility == strval(intval($visibility))) {
@ -145,6 +160,12 @@ class CourseManager
$sql .= " AND visibility = $visibility ";
}
}
if (!empty($urlId)) {
$urlId = intval($urlId);
$sql .= " AND access_url_id= $urlId";
}
if (!empty($orderby)) {
$sql .= " ORDER BY ".Database::escape_string($orderby)." ";
} else {
@ -222,7 +243,7 @@ class CourseManager
/**
* Unsubscribe one or more users from a course
*
* @param int user_id or an array with user ids
* @param mixed user_id or an array with user ids
* @param string course code
* @param int session id
* @assert ('', '') === false
@ -230,13 +251,13 @@ class CourseManager
*/
public static function unsubscribe_user($user_id, $course_code, $session_id = 0)
{
if (!is_array($user_id)) {
$user_id = array($user_id);
}
if (count($user_id) == 0) {
return;
}
$table_user = Database::get_main_table(TABLE_MAIN_USER);
if (!empty($session_id)) {
@ -270,8 +291,8 @@ class CourseManager
Database::query("DELETE FROM ".Database::get_course_table(TABLE_GROUP_TUTOR)." WHERE c_id = $course_id AND user_id IN (".$user_ids.")");
// Erase user student publications (works) in the course - by André Boivin
//@todo field student_publication.author should be the user id
/*
$sqlu = "SELECT * FROM $table_user WHERE user_id IN (".$user_ids.")";
$resu = Database::query($sqlu);
$username = Database::fetch_array($resu,'ASSOC');
@ -279,9 +300,26 @@ class CourseManager
$userlastname = $username['lastname'];
$publication_name = $userfirstname.' '.$userlastname ;
$table_course_user_publication = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
$table_course_user_publication = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
$sql = "DELETE FROM $table_course_user_publication WHERE c_id = $course_id AND author = '".Database::escape_string($publication_name)."'";
Database::query($sql);
Database::query($sql);*/
foreach ($user_ids as $userId) {
// Getting all work from user
$workList = getWorkPerUser($userId);
if (!empty($workList)) {
foreach ($workList as $work) {
$work = $work['work'];
// Getting user results
if (!empty($work->user_results)) {
foreach ($work->user_results as $workSent) {
deleteWorkItem($workSent['id'], $course_info);
}
}
}
}
}
// Unsubscribe user from all blogs in the course.
Database::query("DELETE FROM ".Database::get_course_table(TABLE_BLOGS_REL_USER)." WHERE c_id = $course_id AND user_id IN (".$user_ids.")");

@ -110,7 +110,7 @@ function addNode($code, $name, $canHaveCourses, $parent_id)
$row = Database::fetch_array($result);
$tree_pos = $row['maxTreePos'] + 1;
$sql = "INSERT INTO $tbl_category(name,code,parent_id,tree_pos,children_count,auth_course_child)
$sql = "INSERT INTO $tbl_category(name, code, parent_id, tree_pos, children_count, auth_course_child)
VALUES('$name','$code'," .(empty($parent_id) ? "NULL" : "'$parent_id'") . ",'$tree_pos','0','$canHaveCourses')";
Database::query($sql);
$categoryId = Database::insert_id();

@ -185,7 +185,7 @@ class GroupManager
*/
public static function create_group($name, $category_id, $tutor, $places)
{
global $_course;
$_course = api_get_course_info();
$table_group = Database :: get_course_table(TABLE_GROUP);
$session_id = api_get_session_id();
@ -204,7 +204,7 @@ class GroupManager
}
}
$sql = "INSERT INTO ".$table_group." SET
$sql = "INSERT INTO ".$table_group." SET
c_id = $course_id ,
category_id='".Database::escape_string($category_id)."',
max_student = '".$places."',
@ -412,7 +412,7 @@ class GroupManager
if (file_exists($source_directory)) {
if (api_get_setting('permanently_remove_deleted_files') == 'true') {
// Delete
my_delete($source_directory);
my_delete($source_directory);
} else {
// Rename
rename($source_directory, $destination_dir);
@ -1017,11 +1017,11 @@ class GroupManager
}
/**
* Returns users belonging to any of the group
*
* @param array $groups list of group ids
* @return array list of user ids
*/
* Returns users belonging to any of the group
*
* @param array $groups list of group ids
* @return array list of user ids
*/
public static function get_groups_users($groups = array())
{
$result = array();
@ -1151,7 +1151,6 @@ class GroupManager
if (self :: can_user_subscribe($user_id, $group_id)) {
self :: subscribe_users($user_id, $group_id);
$group_available_place[$group_id]--;
//$userToken[$user_id]--;
unset($userToken[$user_id]);
$changed = true;
break;
@ -1239,10 +1238,11 @@ class GroupManager
public static function is_self_registration_allowed($user_id, $group_id)
{
$course_id = api_get_course_int_id();
if (!$user_id > 0)
if (!$user_id > 0) {
return false;
}
$table_group = Database :: get_course_table(TABLE_GROUP);
$group_id= intval($group_id);
$group_id = intval($group_id);
if (isset($group_id)) {
$sql = "SELECT self_registration_allowed FROM $table_group WHERE c_id = $course_id AND id = $group_id";
$db_result = Database::query($sql);
@ -1261,13 +1261,17 @@ class GroupManager
*/
public static function is_self_unregistration_allowed($user_id, $group_id)
{
if (!$user_id > 0)
if (!$user_id > 0) {
return false;
}
$table_group = Database :: get_course_table(TABLE_GROUP);
$group_id = Database::escape_string($group_id);
$course_id = api_get_course_int_id();
$db_result = Database::query('SELECT self_unregistration_allowed FROM '.$table_group.' WHERE c_id = '.$course_id.' AND id = '.$group_id);
$db_result = Database::query(
'SELECT self_unregistration_allowed FROM '.$table_group.' WHERE c_id = '.$course_id.' AND id = '.$group_id
);
$db_object = Database::fetch_object($db_result);
return $db_object->self_unregistration_allowed == 1 && self :: can_user_unsubscribe($user_id, $group_id);
}
@ -1279,13 +1283,16 @@ class GroupManager
*/
public static function is_subscribed($user_id, $group_id)
{
if(empty($user_id) or empty($group_id)){return false;}
if (empty($user_id) or empty($group_id)) {
return false;
}
$table_group_user = Database :: get_course_table(TABLE_GROUP_USER);
$group_id = Database::escape_string($group_id);
$user_id = Database::escape_string($user_id);
$course_id = api_get_course_int_id();
$sql = 'SELECT 1 FROM '.$table_group_user.' WHERE c_id = '.$course_id.' AND group_id = '.$group_id.' AND user_id = '.$user_id;
$db_result = Database::query($sql);
return Database::num_rows($db_result) > 0;
}
@ -1297,10 +1304,7 @@ class GroupManager
*/
public static function can_user_subscribe($user_id, $group_id)
{
global $_course;
$course_code = $_course['sysCode'];
$category = self :: get_category_from_group($group_id);
$result = CourseManager :: is_user_subscribed_in_real_or_linked_course($user_id, $course_code);
$result = !self :: is_subscribed($user_id, $group_id);
$result &= (self :: number_of_students($group_id) < self :: maximum_number_of_students($group_id));
if ($category['groups_per_user'] == self::GROUP_PER_MEMBER_NO_LIMIT) {
@ -1308,6 +1312,7 @@ class GroupManager
}
$result &= (self :: user_in_number_of_groups($user_id, $category['id']) < $category['groups_per_user']);
$result &= !self :: is_tutor_of_group($user_id, $group_id);
return $result;
}
@ -1370,7 +1375,8 @@ class GroupManager
{
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
$table_group_tutor = Database :: get_course_table(TABLE_GROUP_TUTOR);
$order_clause = api_sort_by_first_name() ? ' ORDER BY u.firstname, u.lastname' : ' ORDER BY u.lastname, u.firstname';
$order_clause = api_sort_by_first_name(
) ? ' ORDER BY u.firstname, u.lastname' : ' ORDER BY u.lastname, u.firstname';
$group_id = Database::escape_string($group_id);
$course_id = api_get_course_int_id();
@ -1399,11 +1405,11 @@ class GroupManager
* Subscribe user(s) to a specified group in current course
* @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 successful
* @return bool TRUE if successfull
*/
public static function subscribe_users($user_ids, $group_id)
{
$user_ids = is_array($user_ids) ? $user_ids : array ($user_ids);
$user_ids = is_array($user_ids) ? $user_ids : array($user_ids);
$result = true;
$course_id = api_get_course_int_id();
$table_group_user = Database :: get_course_table(TABLE_GROUP_USER);
@ -1425,11 +1431,11 @@ class GroupManager
* @param int $group_id
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @see subscribe_users. This function is almost an exact copy of that function.
* @return bool TRUE if successful
* @return bool TRUE if successfull
*/
public static function subscribe_tutors($user_ids, $group_id)
{
$user_ids = is_array($user_ids) ? $user_ids : array ($user_ids);
$user_ids = is_array($user_ids) ? $user_ids : array($user_ids);
$result = true;
$course_id = api_get_course_int_id();
$table_group_tutor = Database :: get_course_table(TABLE_GROUP_TUTOR);
@ -1448,7 +1454,7 @@ class GroupManager
* Unsubscribe user(s) from a specified group in current course
* @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 successful
* @return bool TRUE if successfull
*/
public static function unsubscribe_users($user_ids, $group_id)
{
@ -1464,23 +1470,23 @@ class GroupManager
/**
* Unsubscribe all users from one or more groups
* @param mixed $group_id Can be an array with group-id's or a single group-id
* @return bool TRUE if successful
* @return bool TRUE if successfull
*/
public static function unsubscribe_all_users($group_ids)
{
$course_id = api_get_course_int_id();
$group_ids = is_array($group_ids) ? $group_ids : array ($group_ids);
$group_ids = is_array($group_ids) ? $group_ids : array($group_ids);
$group_ids = array_map('intval', $group_ids);
if( count($group_ids) > 0) {
if(api_is_course_coach()) {
for($i=0 ; $i<count($group_ids) ; $i++) {
if(!api_is_element_in_the_session(TOOL_GROUP,$group_ids[$i])) {
array_splice($group_ids,$i,1);
if (count($group_ids) > 0) {
if (api_is_course_coach()) {
for ($i = 0; $i < count($group_ids); $i++) {
if (!api_is_element_in_the_session(TOOL_GROUP, $group_ids[$i])) {
array_splice($group_ids, $i, 1);
$i--;
}
}
if(count($group_ids)==0) {
if (count($group_ids) == 0) {
return false;
}
}
@ -1502,8 +1508,8 @@ class GroupManager
public static function unsubscribe_all_tutors($group_ids)
{
$course_id = api_get_course_int_id();
$group_ids = is_array($group_ids) ? $group_ids : array ($group_ids);
if( count($group_ids) > 0) {
$group_ids = is_array($group_ids) ? $group_ids : array($group_ids);
if (count($group_ids) > 0) {
$table_group_tutor = Database :: get_course_table(TABLE_GROUP_TUTOR);
$sql = 'DELETE FROM '.$table_group_tutor.' WHERE group_id IN ('.implode(',', $group_ids).') AND c_id = '.$course_id;
$result = Database::query($sql);
@ -1520,7 +1526,7 @@ class GroupManager
* @todo use the function user_has_access that includes this function
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
*/
public static function is_tutor_of_group($user_id,$group_id)
public static function is_tutor_of_group($user_id, $group_id)
{
$table_group_tutor = Database :: get_course_table(TABLE_GROUP_TUTOR);
$user_id = Database::escape_string($user_id);
@ -1529,7 +1535,7 @@ class GroupManager
$sql = "SELECT * FROM ".$table_group_tutor." WHERE c_id = $course_id AND user_id='".$user_id."' AND group_id='".$group_id."'";
$result = Database::query($sql);
if (Database::num_rows($result)>0) {
if (Database::num_rows($result) > 0) {
return true;
} else {
return false;
@ -1544,11 +1550,11 @@ class GroupManager
* @param $group_id the id of the group
* @return boolean true/false
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
*/
*/
public static function is_user_in_group($user_id, $group_id)
{
$member = self :: is_subscribed($user_id,$group_id);
$tutor = self :: is_tutor_of_group($user_id,$group_id);
$member = self :: is_subscribed($user_id, $group_id);
$tutor = self :: is_tutor_of_group($user_id, $group_id);
if ($member OR $tutor) {
return true;
} else {
@ -1564,16 +1570,15 @@ class GroupManager
*/
public static function get_all_tutors()
{
global $_course;
$course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$user_table = Database :: get_main_table(TABLE_MAIN_USER);
$sql = "SELECT user.user_id AS user_id, user.lastname AS lastname, user.firstname AS firstname
FROM ".$user_table." user, ".$course_user_table." cu
WHERE cu.user_id=user.user_id
AND cu.tutor_id='1'
AND cu.course_code='".$_course['sysCode']."'";
FROM ".$user_table." user, ".$course_user_table." cu
WHERE cu.user_id=user.user_id
AND cu.tutor_id='1'
AND cu.c_id='".api_get_course_int_id()."'";
$resultTutor = Database::query($sql);
$tutors = array ();
$tutors = array();
while ($tutor = Database::fetch_array($resultTutor)) {
$tutors[] = $tutor;
}
@ -1587,15 +1592,16 @@ class GroupManager
* @return bool TRUE if given user is a tutor in the current course.
* @deprecated this function uses the old tutor implementation
*/
public static function is_tutor($user_id) {
global $_course;
$course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$user_id = Database::escape_string($user_id);
public static function is_tutor($user_id)
{
$course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$user_id = Database::escape_string($user_id);
$sql = "SELECT tutor_id FROM ".$course_user_table."
WHERE user_id='".$user_id."' AND course_code='".$_course['code']."'"."AND tutor_id=1";
WHERE user_id = '".$user_id."' AND c_id ='".api_get_course_int_id()."'"."AND tutor_id=1";
$db_result = Database::query($sql);
$result = (Database::num_rows($db_result) > 0);
return $result;
}
@ -1607,55 +1613,59 @@ class GroupManager
* @param integer $user_id: the ID of the user you want to know all its
* group memberships
*/
public static function get_group_ids ($course_id, $user_id) {
public static function get_group_ids($course_id, $user_id)
{
$groups = array();
$tbl_group = Database::get_course_table(TABLE_GROUP_USER);
$tbl_group_tutor = Database::get_course_table(TABLE_GROUP_TUTOR);
$user_id = intval($user_id);
$course_id = intval($course_id);
$tbl_group = Database::get_course_table(TABLE_GROUP_USER);
$tbl_group_tutor = Database::get_course_table(TABLE_GROUP_TUTOR);
$user_id = intval($user_id);
$course_id = intval($course_id);
$sql = "SELECT group_id FROM $tbl_group WHERE c_id = $course_id AND user_id = '$user_id'";
$groupres = Database::query($sql);
if ($groupres) {
while ($myrow= Database::fetch_array($groupres))
$groups[]=$myrow['group_id'];
while ($myrow = Database::fetch_array($groupres)) {
$groups[] = $myrow['group_id'];
}
}
//Also loading if i'm the tutor
$sql = "SELECT group_id FROM $tbl_group_tutor WHERE c_id = $course_id AND user_id = '$user_id'";
$groupres = Database::query($sql);
if ($groupres) {
while ($myrow= Database::fetch_array($groupres)) {
$groups[]=$myrow['group_id'];
while ($myrow = Database::fetch_array($groupres)) {
$groups[] = $myrow['group_id'];
}
}
if (!empty($groups)) {
array_filter($groups);
array_filter($groups);
}
return $groups;
}
/*
Group functions - these take virtual/linked courses into account when necessary
*/
/**
* Get a combined list of all users of the real course $course_code
* and all users in virtual courses linked to this course $course_code
* Filter user list: remove duplicate users; plus
* remove users that
* - are already in the current group $group_id;
* - do not have student status in these courses;
* - are not appointed as tutor (group assistent) for this group;
* - have already reached their maximum # of groups in this course.
*
* Originally to get the correct list of users a big SQL statement was used,
* but this has become more complicated now there is not just one real course but many virtual courses.
* Still, that could have worked as well.
*
* @version 1.1.3
* @author Roan Embrechts
*/
* Get a combined list of all users of the real course $course_code
* and all users in virtual courses linked to this course $course_code
* Filter user list: remove duplicate users; plus
* remove users that
* - are already in the current group $group_id;
* - do not have student status in these courses;
* - are not appointed as tutor (group assistent) for this group;
* - have already reached their maximum # of groups in this course.
*
* Originally to get the correct list of users a big SQL statement was used,
* but this has become more complicated now there is not just one real course but many virtual courses.
* Still, that could have worked as well.
*
* @version 1.1.3
* @author Roan Embrechts
*/
public static function get_complete_list_of_users_that_can_be_added_to_group ($course_code, $group_id) {
global $_course, $_user;
$category = self :: get_category_from_group($group_id, $course_code);
@ -1711,28 +1721,30 @@ class GroupManager
return $complete_user_list;
}
/**
* Filter out duplicates in a multidimensional array
* by comparing field $compare_field.
*
* @param $user_array_in list of users (must be sorted).
* @param string $compare_field, the field to be compared
*/
public static function filter_duplicates ($user_array_in, $compare_field) {
* Filter out duplicates in a multidimensional array
* by comparing field $compare_field.
*
* @param $user_array_in list of users (must be sorted).
* @param string $compare_field, the field to be compared
*/
public static function filter_duplicates($user_array_in, $compare_field)
{
$total_number = count($user_array_in);
$user_array_out[0] = $user_array_in[0];
$count_out = 0;
for ($count_in = 1; $count_in < $total_number; $count_in ++) {
for ($count_in = 1; $count_in < $total_number; $count_in++) {
if ($user_array_in[$count_in][$compare_field] != $user_array_out[$count_out][$compare_field]) {
$count_out ++;
$count_out++;
$user_array_out[$count_out] = $user_array_in[$count_in];
}
}
return $user_array_out;
}
/**
* Filters from the array $user_array_in the users already in the group $group_id.
*/
public static function filter_users_already_in_group ($user_array_in, $group_id) {
* Filters from the array $user_array_in the users already in the group $group_id.
*/
public static function filter_users_already_in_group($user_array_in, $group_id)
{
foreach ($user_array_in as $this_user) {
if (!self :: is_subscribed($this_user['user_id'], $group_id)) {
$user_array_out[] = $this_user;
@ -1742,11 +1754,12 @@ class GroupManager
}
/**
* Remove all users that are not students and all users who have tutor status
* from the list.
*/
public static function filter_only_students($user_array_in) {
$user_array_out = array ();
* Remove all users that are not students and all users who have tutor status
* from the list.
*/
public static function filter_only_students($user_array_in)
{
$user_array_out = array();
foreach ($user_array_in as $this_user) {
//if ($this_user['status_rel'] == STUDENT && $this_user['tutor_id'] == 0) {
if (api_get_session_id()) {
@ -1771,7 +1784,9 @@ class GroupManager
* @return bool True if the given user has access to the given tool in the
* given course.
*/
public static function user_has_access($user_id, $group_id, $tool) {
public static function user_has_access($user_id, $group_id, $tool)
{
// Admin have access everywhere
if (api_is_platform_admin()) {
return true;
@ -1808,7 +1823,7 @@ class GroupManager
return false;
}
$user_is_in_group = self::is_user_in_group($user_id, $group_id);
$user_is_in_group = self :: is_user_in_group($user_id, $group_id);
// Check group properties
$group_info = self :: get_group_properties($group_id);
@ -1834,11 +1849,11 @@ class GroupManager
return false;
} elseif ($group_info[$state_key] == self::TOOL_PUBLIC) {
return true;
} elseif (api_is_allowed_to_edit(false,true)) {
} elseif (api_is_allowed_to_edit(false, true)) {
return true;
} elseif($group_info['tutor_id'] == $user_id) { //this tutor implementation was dropped
} elseif ($group_info['tutor_id'] == $user_id) { //this tutor implementation was dropped
return true;
} elseif($group_info[$state_key] == self::TOOL_PRIVATE && !$user_is_in_group) {
} elseif ($group_info[$state_key] == self::TOOL_PRIVATE && !$user_is_in_group) {
return false;
} else {
return $user_is_in_group;
@ -1850,17 +1865,17 @@ class GroupManager
*/
public static function get_user_group_name($user_id)
{
$table_group_user = Database::get_course_table(TABLE_GROUP_USER);
$table_group = Database::get_course_table(TABLE_GROUP);
$user_id = intval($user_id);
$course_id = api_get_course_int_id();
$table_group_user = Database::get_course_table(TABLE_GROUP_USER);
$table_group = Database::get_course_table(TABLE_GROUP);
$user_id = intval($user_id);
$course_id = api_get_course_int_id();
$sql_groups = "SELECT name FROM $table_group g INNER JOIN $table_group_user gu
ON (gu.group_id=g.id)
WHERE gu.c_id= $course_id AND
WHERE gu.c_id= $course_id AND
g.c_id= $course_id AND
gu.user_id = $user_id";
$res = Database::query($sql_groups);
$groups=array();
$groups = array();
while ($group = Database::fetch_array($res)) {
$groups[] .= $group['name'];
}
@ -1882,31 +1897,28 @@ class GroupManager
$group_ids = array_map('intval', $group_ids);
if (api_is_course_coach()) {
for ($i=0 ; $i<count($group_ids) ; $i++) {
if (!api_is_element_in_the_session(TOOL_GROUP,$group_ids[$i])) {
for ($i = 0; $i < count($group_ids); $i++) {
if (!api_is_element_in_the_session(TOOL_GROUP, $group_ids[$i])) {
array_splice($group_ids, $i, 1);
$i--;
}
}
if (count($group_ids)==0) {
if (count($group_ids) == 0) {
return false;
}
}
global $_course;
$_course = api_get_course_info();
$session_id = api_get_session_id();
$course_id = api_get_course_int_id();
$category = self::get_category_from_group($group_ids[0]);
$category = self :: get_category_from_group($group_ids[0]);
$groups_per_user = $category['groups_per_user'];
$group_table = Database :: get_course_table(TABLE_GROUP);
$group_user_table = Database :: get_course_table(TABLE_GROUP_USER);
$session_id = api_get_session_id();
$complete_user_list = CourseManager :: get_real_and_linked_user_list($_course['sysCode'], true, $session_id);
$number_groups_per_user = ($groups_per_user == self::GROUP_PER_MEMBER_NO_LIMIT ? self::INFINITE : $groups_per_user);
$course_id = api_get_course_int_id();
/*
* Retrieve all the groups where enrollment is still allowed
* (reverse) ordered by the number of place available
@ -1928,7 +1940,7 @@ class GroupManager
} else {
$places = self::MEMBER_PER_GROUP_NO_LIMIT;
}
$group_available_place[$group['gid']] = $group['nbPlaces'];
$group_available_place[$group['gid']] = $places;
}
/*
@ -1980,7 +1992,7 @@ class GroupManager
$row = array();
// Checkbox
if (api_is_allowed_to_edit(false,true) && count($group_list) > 1) {
if (api_is_allowed_to_edit(false, true) && count($group_list) > 1) {
$row[] = $this_group['id'];
}
@ -1994,7 +2006,7 @@ class GroupManager
self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_ANNOUNCEMENT) ||
self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_WORK) ||
self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_WIKI))
&& !(api_is_course_coach() && intval($this_group['session_id']) != $session_id)
&& !(api_is_course_coach() && intval($this_group['session_id']) != $session_id)
) {
$group_name = '<a href="group_space.php?cidReq='.api_get_course_id().'&amp;origin='.$orig.'&amp;gidReq='.$this_group['id'].'">'.

@ -1111,10 +1111,12 @@ function api_is_western_name_order($format = null, $language = null) {
}
$language_is_supported = api_is_language_supported($language);
if (!$language_is_supported || empty($language)) {
$language = api_get_interface_language(false, true);
}
if (!isset($order[$format][$language])) {
$test_name = api_get_person_name('%f', '%l', '%t', $format, $language);
$order[$format][$language] = stripos($test_name, '%f') <= stripos($test_name, '%l');
}

@ -89,6 +89,7 @@ define('TOOL_LINK', 'link');
define('TOOL_COURSE_DESCRIPTION', 'course_description');
define('TOOL_SEARCH', 'search');
define('TOOL_LEARNPATH', 'learnpath');
define('TOOL_AGENDA', 'agenda');
define('TOOL_ANNOUNCEMENT', 'announcement');
define('TOOL_FORUM', 'forum');
define('TOOL_FORUM_CATEGORY','forum_category');

@ -3574,7 +3574,7 @@ class TrackingCourseLog
if (!empty($_GET['user_keyword'])) {
$keyword = trim(Database::escape_string($_GET['user_keyword']));
$condition_user .= " AND (user.firstname LIKE '%".$keyword."%' OR user.lastname LIKE '%".$keyword."%' OR user.username LIKE '%".$keyword."%' OR user.email LIKE '%".$keyword."%' ) ";
$condition_user .= " AND (user.firstname LIKE '%".$keyword."%' OR user.lastname LIKE '%".$keyword."%' OR user.username LIKE '%".$keyword."%' OR user.email LIKE '%".$keyword."%' ) ";
}
if (api_is_multiple_url_enabled()) {
@ -3638,7 +3638,7 @@ class TrackingCourseLog
$user['official_code'] = $user['col0'];
$user['lastname'] = $user['col1'];
$user['firstname'] = $user['col2'];
$user['username'] = $user['col3'];
$user['username'] = $user['col3'];
$user['time'] = api_time_to_hms(Tracking::get_time_spent_on_the_course($user['user_id'], $course_code, $session_id));
$avg_student_score = Tracking::get_avg_student_score($user['user_id'], $course_code, array(), $session_id);

@ -63,8 +63,25 @@ class UserManager
* @assert ('Sam','Gamegie',5,'sam@example.com','jo','jo') > 1
* @assert ('Pippin','Took',null,null,'jo','jo') === false
*/
public static function create_user($firstName, $lastName, $status, $email, $loginName, $password, $official_code = '', $language = '', $phone = '', $picture_uri = '', $auth_source = PLATFORM_AUTH_SOURCE, $expiration_date = '0000-00-00 00:00:00', $active = 1, $hr_dept_id = 0, $extra = null, $encrypt_method = '', $send_mail = false)
{
public static function create_user(
$firstName,
$lastName,
$status,
$email,
$loginName,
$password,
$official_code = '',
$language = '',
$phone = '',
$picture_uri = '',
$auth_source = PLATFORM_AUTH_SOURCE,
$expiration_date = '0000-00-00 00:00:00',
$active = 1,
$hr_dept_id = 0,
$extra = null,
$encrypt_method = '',
$send_mail = false
) {
global $_user, $_configuration;
$original_password = $password;
$access_url_id = 1;
@ -163,7 +180,6 @@ class UserManager
if (!empty($email) && $send_mail) {
$recipient_name = api_get_person_name($firstName, $lastName, null, PERSON_NAME_EMAIL_ADDRESS);
$emailsubject = '['.api_get_setting('siteName').'] '.get_lang('YourReg').' '.api_get_setting('siteName');
$sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
$email_admin = api_get_setting('emailAdministrator');
@ -185,17 +201,12 @@ class UserManager
$values["prior_lang"] = null;
EventsDispatcher::events('user_registration', $values);
} else {
@api_mail_html($recipient_name, $email, $emailsubject, $emailbody, $sender_name, $email_admin);
api_mail_html($recipient_name, $email, $emailsubject, $emailbody, $sender_name, $email_admin);
}
/* ENDS MANAGE EVENT WITH MAIL */
}
// Add event to system log
$user_id_manager = api_get_user_id();
event_system(LOG_USER_CREATE, LOG_USER_ID, $return);
} else {
$return = false;
return api_set_failure('error inserting in Database');
}
@ -224,7 +235,7 @@ class UserManager
public static function can_delete_user($user_id)
{
global $_configuration;
if (isset($_configuration['delete_users']) && $_configuration['delete_users'] == false) {
if (isset($_configuration['deny_delete_users']) && $_configuration['deny_delete_users'] == true) {
return false;
}
$table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
@ -250,7 +261,7 @@ class UserManager
* super-admins. Other roles should only be able to disable a user,
* which removes access to the platform but doesn't delete anything.
* @param int The ID of th user to be deleted
* @return boolean true if user is succesfully deleted, false otherwise
* @return boolean true if user is successfully deleted, false otherwise
* @assert (null) === false
* @assert ('abc') === false
*/
@ -2136,7 +2147,7 @@ class UserManager
// Checking session visibility
$visibility = api_get_session_visibility($session_id, null, $ignore_visibility_for_admins);
switch ($visibility) {
case SESSION_VISIBLE_READ_ONLY:
case SESSION_VISIBLE:
@ -2144,7 +2155,7 @@ class UserManager
break;
case SESSION_INVISIBLE:
continue(2);
}
}
$categories[$row['session_category_id']]['sessions'][$row['id']]['session_name'] = $row['name'];
$categories[$row['session_category_id']]['sessions'][$row['id']]['session_id'] = $row['id'];
@ -2153,12 +2164,12 @@ class UserManager
$categories[$row['session_category_id']]['sessions'][$row['id']]['nb_days_access_before_beginning'] = $row['nb_days_access_before_beginning'];
$categories[$row['session_category_id']]['sessions'][$row['id']]['nb_days_access_after_end'] = $row['nb_days_access_after_end'];
$categories[$row['session_category_id']]['sessions'][$row['id']]['courses'] = UserManager::get_courses_list_by_session($user_id, $row['id']);
}
}
return $categories;
}
/**

@ -60,7 +60,7 @@ class ZombieManager
) AND
access.login_date <= '$ceiling' AND
user.user_id = access.login_user_id AND
url.login_user_id = user.user_id AND url.access_url_id=$current_url_id";
url.user_id = user.user_id AND url.access_url_id=$current_url_id";
} else {
$sql .= " FROM $user_table as user, $login_table as access
WHERE

@ -20,7 +20,6 @@ if (empty($_POST['current_dir'])) {
}
$uncompress = 1;
//error_log('New LP - lp_upload.php', 0);
/*
* Check the request method in place of a variable from POST
* because if the file size exceed the maximum file upload
@ -30,7 +29,7 @@ $uncompress = 1;
$user_file = Request::is_post() ? Request::file('user_file') : array();
$user_file = $user_file ? $user_file : array();
$is_error = isset($user_file['error']) ? $user_file['error'] : false;
if( Request::is_post() && $is_error){
if (Request::is_post() && $is_error) {
return api_failure::set_failure('upload_file_too_big');
unset($_FILEs['user_file']);
} else if ($_SERVER['REQUEST_METHOD'] == 'POST' && count($_FILES) > 0 && !empty($_FILES['user_file']['name'])) {
@ -55,11 +54,11 @@ if( Request::is_post() && $is_error){
$proximity = 'local';
if (!empty($_REQUEST['content_proximity'])) {
$proximity = Database::escape_string($_REQUEST['content_proximity']);
$proximity = Database::escape_string($_REQUEST['content_proximity']);
}
$maker = 'Scorm';
if (!empty($_REQUEST['content_maker'])) {
$maker = Database::escape_string($_REQUEST['content_maker']);
$maker = Database::escape_string($_REQUEST['content_maker']);
}
switch ($type) {
@ -108,7 +107,7 @@ if( Request::is_post() && $is_error){
default:
return api_failure::set_failure('not_a_learning_path');
}
} elseif($_SERVER['REQUEST_METHOD'] == 'POST') {
} elseif ($_SERVER['REQUEST_METHOD'] == 'POST') {
// end if is_uploaded_file
// If file name given to get in claroline/upload/, try importing this way.
@ -142,7 +141,7 @@ if( Request::is_post() && $is_error){
require_once 'scorm.class.php';
$oScorm = new scorm();
$manifest = $oScorm->import_local_package($s, $current_dir);
if ($manifest === false ) { //if ap i_set_failure
if ($manifest === false) { //if ap i_set_failure
return api_failure::set_failure(api_failure::get_last_failure());
}
if (!empty($manifest)) {
@ -151,9 +150,13 @@ if( Request::is_post() && $is_error){
}
$proximity = '';
if (!empty($_REQUEST['content_proximity'])) { $proximity = Database::escape_string($_REQUEST['content_proximity']); }
if (!empty($_REQUEST['content_proximity'])) {
$proximity = Database::escape_string($_REQUEST['content_proximity']);
}
$maker = '';
if (!empty($_REQUEST['content_maker'])) {$maker = Database::escape_string($_REQUEST['content_maker']); }
if (!empty($_REQUEST['content_maker'])) {
$maker = Database::escape_string($_REQUEST['content_maker']);
}
$oScorm->set_proximity($proximity);
$oScorm->set_maker($maker);
$oScorm->set_jslib('scorm_api.php');
@ -167,9 +170,13 @@ if( Request::is_post() && $is_error){
$oAICC->import_aicc(api_get_course_id());
}
$proximity = '';
if (!empty($_REQUEST['content_proximity'])) { $proximity = Database::escape_string($_REQUEST['content_proximity']); }
if (!empty($_REQUEST['content_proximity'])) {
$proximity = Database::escape_string($_REQUEST['content_proximity']);
}
$maker = '';
if (!empty($_REQUEST['content_maker'])) { $maker = Database::escape_string($_REQUEST['content_maker']); }
if (!empty($_REQUEST['content_maker'])) {
$maker = Database::escape_string($_REQUEST['content_maker']);
}
$oAICC->set_proximity($proximity);
$oAICC->set_maker($maker);
$oAICC->set_jslib('aicc_api.php');

@ -7,13 +7,15 @@
* to help in the conversion of Office documents to learning paths
* @package chamilo.learnpath
* @author Eric Marguin <eric.marguin@dokeos.com>
* @author Julio Montoya
* @license GNU/GPL
*/
/**
* Defines the "OpenofficeDocument" child of class "learnpath"
*/
abstract class OpenofficeDocument extends learnpath {
abstract class OpenofficeDocument extends learnpath
{
public $first_item = 0;
public $original_charset = 'utf-8';
@ -25,31 +27,36 @@ abstract class OpenofficeDocument extends learnpath {
* @param integer Learnpath ID in DB
* @param integer User ID
*/
public function __construct($course_code = null, $resource_id = null, $user_id = null) {
public function __construct($course_code = null, $resource_id = null, $user_id = null)
{
if ($this->debug > 0) {
error_log('In OpenofficeDocument::OpenofficeDocument()', 0);
}
if (!empty($course_code) && !empty($resource_id) && !empty($user_id)) {
parent::__construct($course_code, $resource_id, $user_id);
} else {
// Do nothing but still build the presentation object.
}
}
public function convert_document($file, $action_after_conversion = 'make_lp') {
global $_course, $_user, $_configuration;
$this->file_name = pathinfo($file['name'], PATHINFO_FILENAME);
/**
* @param string $file
* @param string $action_after_conversion
* @return bool|int
*/
public function convert_document($file, $action_after_conversion = 'make_lp')
{
global $_course;
$this->file_name = pathinfo($file['name'], PATHINFO_FILENAME);
// Create the directory
$result = $this->generate_lp_folder($_course, $this->file_name);
$result = $this->generate_lp_folder($_course, $this->file_name);
// Create the directory
$this->base_work_dir = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
///learning_path/ppt_dirname directory
$this->created_dir = substr($result['dir'], 0, strlen($result['dir']) -1);
$this->created_dir = substr($result['dir'], 0, strlen($result['dir']) -1);
$this->file_path = $this->created_dir.'/'.replace_dangerous_char($file['name'], 'strict');
//var_dump($this->file_name, $this->file_path, $this->base_work_dir, $this->created_dir);
/*
* Original code
global $_course, $_user, $_configuration;
@ -69,9 +76,9 @@ abstract class OpenofficeDocument extends learnpath {
$this->base_work_dir = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
$this->created_dir = create_unexisting_directory($_course, $_user['user_id'], api_get_session_id(), 0, 0, $this->base_work_dir, $dir_name);
var_dump($this->file_name, $this->file_path, $this->base_work_dir, $this->created_dir);
*/
$ppt2lp_host = api_get_setting('service_ppt2lp', 'host');
@ -96,7 +103,7 @@ abstract class OpenofficeDocument extends learnpath {
$cmd .= ' -p ' . api_get_setting('service_ppt2lp', 'port');
// Call to the function implemented by child.
$cmd .= $this->add_command_parameters();
// To allow openoffice to manipulate docs.
// To allow openoffice to manipulate docs.
@chmod($this->base_work_dir, 0777);
@chmod($this->base_work_dir.$this->created_dir, 0777);
@chmod($this->base_work_dir.$this->file_path, 0777);
@ -107,7 +114,7 @@ abstract class OpenofficeDocument extends learnpath {
$files = array();
$return = 0;
$shell = exec($cmd, $files, $return);
if ($return != 0) { // If the java application returns an error code.
switch ($return) {
// Can't connect to openoffice.
@ -141,7 +148,7 @@ abstract class OpenofficeDocument extends learnpath {
// files info
$files = $result['files'];
}
if (!empty($files)) {
// Create lp
$this->lp_id = learnpath::add_lp($_course['id'], $this->file_name, '', 'guess', 'manual');
@ -165,7 +172,8 @@ abstract class OpenofficeDocument extends learnpath {
* @param array current ppt file
* @return array images files
*/
private function _get_remote_ppt2lp_files($file) {
private function _get_remote_ppt2lp_files($file)
{
require_once api_get_path(LIBRARY_PATH) . 'nusoap/nusoap.php';
// host
$ppt2lp_host = api_get_setting('service_ppt2lp', 'host');

@ -20,17 +20,19 @@ if (api_get_setting('search_enabled') == 'true') {
require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
}
class OpenofficePresentation extends OpenofficeDocument {
class OpenofficePresentation extends OpenofficeDocument
{
public $take_slide_name;
public function __construct($take_slide_name = false, $course_code = null, $resource_id = null, $user_id = null) {
public function __construct($take_slide_name = false, $course_code = null, $resource_id = null, $user_id = null)
{
$this->take_slide_name = $take_slide_name;
parent::__construct($course_code, $resource_id, $user_id);
}
public function make_lp($files = array()) {
public function make_lp($files = array())
{
global $_course;
$previous = 0;
$i = 0;
@ -39,8 +41,10 @@ class OpenofficePresentation extends OpenofficeDocument {
return false;
foreach ($files as $file) {
list($slide_name, $file_name, $slide_body) = explode('||', $file); // '||' is used as separator between fields: slide name (with accents) || file name (without accents) || all slide text (to be indexed).
/* '||' is used as separator between fields:
slide name (with accents) || file name (without accents) || all slide text (to be indexed).
*/
list($slide_name, $file_name, $slide_body) = explode('||', $file);
// Filename is utf8 encoded, but when we decode, some chars are not translated (like quote &rsquo;).
// so we remove these chars by translating it in htmlentities and the reconvert it in want charset.
@ -58,8 +62,26 @@ class OpenofficePresentation extends OpenofficeDocument {
$i++;
// Add the png to documents.
$document_id = add_document($_course, $this->created_dir.'/'.urlencode($file_name), 'file', filesize($this->base_work_dir.$this->created_dir.'/'.$file_name), $slide_name);
api_item_property_update($_course, TOOL_DOCUMENT, $document_id, 'DocumentAdded', api_get_user_id(), 0, 0, null, null, api_get_session_id());
$document_id = add_document(
$_course,
$this->created_dir.'/'.urlencode($file_name),
'file',
filesize($this->base_work_dir.$this->created_dir.'/'.$file_name),
$slide_name
);
api_item_property_update(
$_course,
TOOL_DOCUMENT,
$document_id,
'DocumentAdded',
api_get_user_id(),
0,
0,
null,
null,
api_get_session_id()
);
// Generating the thumbnail.
$image = $this->base_work_dir.$this->created_dir .'/'. $file_name;
@ -67,21 +89,28 @@ class OpenofficePresentation extends OpenofficeDocument {
$pattern = '/(\w+)\.png$/';
$replacement = '${1}_thumb.png';
$thumb_name = preg_replace($pattern, $replacement, $file_name);
// Calculate thumbnail size.
$image_size = api_getimagesize($image);
$width = $image_size['width'];
$height = $image_size['height'];
$thumb_width = 300;
$thumb_height = floor($height * ($thumb_width / $width));
$my_new_image = new Image($image);
$my_new_image->resize($thumb_width, $thumb_height);
$my_new_image->send_image($this->base_work_dir.$this->created_dir .'/'. $thumb_name, -1, 'png');
// Adding the thumbnail to documents.
$document_id_thumb = add_document($_course, $this->created_dir.'/'.urlencode($thumb_name), 'file', filesize($this->base_work_dir.$this->created_dir.'/'.$thumb_name), $slide_name);
$document_id_thumb = add_document(
$_course,
$this->created_dir.'/'.urlencode($thumb_name),
'file',
filesize($this->base_work_dir.$this->created_dir.'/'.$thumb_name),
$slide_name
);
api_item_property_update($_course, TOOL_THUMBNAIL, $document_id_thumb, 'DocumentAdded', api_get_user_id(), 0, 0);
// Create an html file.
@ -100,7 +129,14 @@ class OpenofficePresentation extends OpenofficeDocument {
</html>'); // This indentation is to make the generated html files to look well.
fclose($fp);
$document_id = add_document($_course,$this->created_dir.'/'.urlencode($html_file), 'file', filesize($this->base_work_dir.$this->created_dir.'/'.$html_file), $slide_name);
$document_id = add_document(
$_course,
$this->created_dir.'/'.urlencode($html_file),
'file',
filesize($this->base_work_dir.$this->created_dir.'/'.$html_file),
$slide_name
);
if ($document_id) {
// Put the document in item_property update.
@ -114,7 +150,7 @@ class OpenofficePresentation extends OpenofficeDocument {
// Code for text indexing.
if (api_get_setting('search_enabled') == 'true') {
if (isset($_POST['index_document']) && $_POST['index_document']) {
if (isset($_POST['index_document']) && $_POST['index_document']) {
$di = new ChamiloIndexer();
isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : $lang = 'english';
$di->connectDb(NULL, NULL, $lang);
@ -165,18 +201,22 @@ class OpenofficePresentation extends OpenofficeDocument {
}
}
function add_command_parameters() {
if (empty($this->slide_width) || empty($this->slide_height))
function add_command_parameters()
{
if (empty($this->slide_width) || empty($this->slide_height)) {
list($this->slide_width, $this->slide_height) = explode('x', api_get_setting('service_ppt2lp', 'size'));
}
return ' -w '.$this->slide_width.' -h '.$this->slide_height.' -d oogie "'.$this->base_work_dir.'/'.$this->file_path.'" "'.$this->base_work_dir.$this->created_dir.'.html"';
}
function set_slide_size($width, $height) {
function set_slide_size($width, $height)
{
$this->slide_width = $width;
$this->slide_height = $height;
}
function add_docs_to_visio($files = array()) {
function add_docs_to_visio($files = array())
{
global $_course;
foreach ($files as $file) {
list($slide_name,$file_name) = explode('||',$file); // '||' is used as separator between slide name (with accents) and file name (without accents).

@ -77,7 +77,7 @@
<li><a href="{{ _p.web_main }}social/invitations.php">{{ "PendingInvitations"|get_lang }}</a></li> -->
</ul>
</li>
<li><a href="{{ _p.web }}index.php?logout=logout">{{ "Logout"|get_lang }}</a></li>
<li><a href="{{ _p.web }}index.php?logout=logout&uid={{_u.user_id}}">{{ "Logout"|get_lang }}</a></li>
</ul>
</div> <!-- /nav collapse -->
{% endif %}

@ -11,7 +11,7 @@
*/
//the document file is loaded because most of the upload vocab relates to the document tool
$language_file[] = "document";
$language_file[] = "document";
$language_file[] = "learnpath";
$language_file[] = "scormdocument";
@ -26,39 +26,41 @@ $htmlHeadXtra[] = '<script type="text/javascript">
var myUpload = new upload(0);
</script>';
if (isset($_POST['convert'])){
$cwdir = getcwd();
if(isset($_FILES['user_file'])) {
$allowed_extensions = array('odp','sxi','ppt','pps','sxd','pptx');
if(in_array(strtolower(pathinfo($_FILES['user_file']['name'],PATHINFO_EXTENSION)),$allowed_extensions)) {
require('../newscorm/lp_upload.php');
if(isset($o_ppt) && $first_item_id != 0){
if (api_get_setting('search_enabled')=='true') {
require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php');
if (isset($_POST['convert'])) {
$cwdir = getcwd();
if (isset($_FILES['user_file'])) {
$allowed_extensions = array('odp', 'sxi', 'ppt', 'pps', 'sxd', 'pptx');
if (in_array(strtolower(pathinfo($_FILES['user_file']['name'], PATHINFO_EXTENSION)), $allowed_extensions)) {
require_once api_get_path(SYS_CODE_PATH).'newscorm/lp_upload.php';
if (isset($o_ppt) && $first_item_id != 0) {
if (api_get_setting('search_enabled')=='true') {
require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
$specific_fields = get_specific_field_list();
foreach ($specific_fields as $specific_field) {
$values = explode(',', trim($_POST[$specific_field['code']]));
if ( !empty($values) ) {
foreach ($values as $value) {
$value = trim($value);
if ( !empty($value) ) {
add_specific_field_value($specific_field['id'], api_get_course_id(), TOOL_LEARNPATH, $o_ppt->lp_id, $value);
}
}
}
}
$values = explode(',', trim($_POST[$specific_field['code']]));
if (!empty($values)) {
foreach ($values as $value) {
$value = trim($value);
if (!empty($value)) {
add_specific_field_value($specific_field['id'], api_get_course_id(), TOOL_LEARNPATH, $o_ppt->lp_id, $value);
}
}
}
}
}
header('Location: ../newscorm/lp_controller.php?'.api_get_cidreq().'&lp_id='.$o_ppt->lp_id.'&action=view_item&id='.$first_item_id);
} else {
if(!empty($o_ppt->error))
$errorMessage = $o_ppt->error;
else
$errorMessage = get_lang('OogieUnknownError');
}
} else {
$errorMessage = get_lang('OogieBadExtension');
}
}
header('Location: ../newscorm/lp_controller.php?'.api_get_cidreq().'&lp_id='.$o_ppt->lp_id.'&action=view_item&id='.$first_item_id);
exit;
} else {
if (!empty($o_ppt->error)) {
$errorMessage = $o_ppt->error;
} else {
$errorMessage = get_lang('OogieUnknownError');
}
}
} else {
$errorMessage = get_lang('OogieBadExtension');
}
}
}
event_access_tool(TOOL_UPLOAD);
@ -66,8 +68,8 @@ event_access_tool(TOOL_UPLOAD);
// check access permissions (edit permission is needed to add a document or a LP)
$is_allowed_to_edit = api_is_allowed_to_edit();
if(!$is_allowed_to_edit){
api_not_allowed(true);
if (!$is_allowed_to_edit) {
api_not_allowed(true);
}
$interbreadcrumb[]= array ("url"=>"../newscorm/lp_controller.php?action=list", "name"=> get_lang("Doc"));
@ -76,38 +78,34 @@ $nameTools = get_lang("OogieConversionPowerPoint");
Display :: display_header($nameTools);
$message = get_lang("WelcomeOogieConverter");
if (!empty($errorMessage)) {
if (!empty($errorMessage)) {
echo Display::return_message($errorMessage, 'warning', false);
}
$div_upload_limit = get_lang('UploadMaxSize').' : '.ini_get('post_max_size');
$form = new FormValidator('upload_ppt', 'POST', '', '');
$form->addElement('header', get_lang("WelcomeOogieSubtitle"));
$form->addElement('html', Display::return_message($message, 'info', false));
// build the form
$div_upload_limit = get_lang('UploadMaxSize').' : '.ini_get('post_max_size');
$form->addElement ('file', 'user_file', array('<img src="../img/powerpoint_big.gif" />', $div_upload_limit));
$form->addElement ('checkbox', 'take_slide_name','', get_lang('TakeSlideName'));
if (api_get_setting('search_enabled')=='true') {
$form->addElement('file', 'user_file', array('<img src="../img/powerpoint_big.gif" />', $div_upload_limit));
$form->addElement('checkbox', 'take_slide_name', '', get_lang('TakeSlideName'));
if (api_get_setting('search_enabled') == 'true') {
require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php');
$specific_fields = get_specific_field_list();
$form->addElement ('checkbox', 'index_document','', get_lang('SearchFeatureDoIndexDocument'));
$form->addElement ('select_language', 'language', get_lang('SearchFeatureDocumentLanguage'));
$form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument'));
$form->addElement('select_language', 'language', get_lang('SearchFeatureDocumentLanguage'));
foreach ($specific_fields as $specific_field) {
$form->addElement ('text', $specific_field['code'], $specific_field['name'].' : ');
$form->addElement('text', $specific_field['code'], $specific_field['name'].' : ');
}
}
$form->addElement ('style_submit_button', 'convert', get_lang('ConvertToLP'));
$form->addElement ('hidden', 'ppt2lp', 'true');
$form->addElement('style_submit_button', 'convert', get_lang('ConvertToLP'));
$form->addElement('hidden', 'ppt2lp', 'true');
$form->add_real_progress_bar(md5(rand(0,10000)), 'user_file', 1, true);
$form->add_real_progress_bar(md5(rand(0, 10000)), 'user_file', 1, true);
$defaults = array('take_slide_name'=>'checked="checked"','index_document'=>'checked="checked"');
$form->setDefaults($defaults);
// display the form
$form->display();
Display::display_footer();
Display::display_footer();

@ -287,16 +287,20 @@ function getWorkList($id, $my_folder_data, $add_in_where_query)
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id);
$group_id = api_get_group_id();
$link_info = is_resource_in_course_gradebook(api_get_course_id(), 3 , $id, api_get_session_id());
$work_in_gradebook_link_id = $link_info['id'];
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
if ($work_in_gradebook_link_id) {
if ($is_allowed_to_edit)
if (intval($my_folder_data['qualification']) == 0) {
Display::display_warning_message(get_lang('MaxWeightNeedToBeProvided'));
$linkInfo = is_resource_in_course_gradebook(api_get_course_id(), 3 , $id, api_get_session_id());
if ($linkInfo) {
$workInGradeBookLinkId = $linkInfo['id'];
if ($workInGradeBookLinkId) {
if ($is_allowed_to_edit) {
if (intval($my_folder_data['qualification']) == 0) {
Display::display_warning_message(get_lang('MaxWeightNeedToBeProvided'));
}
}
}
}
$contains_file_query = '';
@ -304,15 +308,16 @@ function getWorkList($id, $my_folder_data, $add_in_where_query)
// Get list from database
if ($is_allowed_to_edit) {
$active_condition = ' active IN (0, 1)';
$sql_get_publications_list = "SELECT * FROM $work_table
$sql = "SELECT * FROM $work_table
WHERE c_id = $course_id $add_in_where_query $condition_session AND $active_condition AND (parent_id = 0) $contains_file_query ";
if (!empty($group_id)) {
$sql_get_publications_list .= " AND post_group_id = '".$group_id."' ";
$sql .= " AND post_group_id = '".$group_id."' ";
}
$sql_get_publications_list .= " ORDER BY sent_date DESC";
$sql .= " ORDER BY sent_date DESC";
} else {
if (!empty($group_id)) {
$group_query = " WHERE c_id = $course_id AND post_group_id = '".$group_id."' "; // set to select only messages posted by the user's group
// set to select only messages posted by the user's group
$group_query = " WHERE c_id = $course_id AND post_group_id = '".$group_id."' ";
$subdirs_query = "AND parent_id = 0";
} else {
$group_query = " WHERE c_id = $course_id AND post_group_id = '0' ";
@ -320,12 +325,14 @@ function getWorkList($id, $my_folder_data, $add_in_where_query)
}
//@todo how we can active or not an assignment?
$active_condition = ' AND active IN (1,0)';
$sql_get_publications_list = "SELECT * FROM $work_table $group_query $subdirs_query $add_in_where_query $active_condition $condition_session ORDER BY title";
$sql = "SELECT * FROM $work_table
$group_query $subdirs_query $add_in_where_query $active_condition $condition_session
ORDER BY title";
}
$work_parents = array();
$sql_result = Database::query($sql_get_publications_list);
$sql_result = Database::query($sql);
if (Database::num_rows($sql_result)) {
while ($work = Database::fetch_object($sql_result)) {
if ($work->parent_id == 0) {
@ -333,6 +340,7 @@ function getWorkList($id, $my_folder_data, $add_in_where_query)
}
}
}
return $work_parents;
}

Loading…
Cancel
Save