diff --git a/main/course_home/course_home.php b/main/course_home/course_home.php index ddc088d763..61f7730379 100644 --- a/main/course_home/course_home.php +++ b/main/course_home/course_home.php @@ -267,3 +267,5 @@ $tpl->assign('actions', $actions); $tpl->assign('message', $show_message); $tpl->assign('content', $content); $tpl->display_one_col_template(); + +Session::erase('_gid'); diff --git a/main/document/create_document.php b/main/document/create_document.php index 447705ff84..5671a0f191 100644 --- a/main/document/create_document.php +++ b/main/document/create_document.php @@ -305,10 +305,10 @@ if (isset ($group_properties)) { } // Create a new form -$form = new FormValidator('create_document','post',api_get_self().'?dir='.Security::remove_XSS(urlencode($dir)).'&selectcat='.Security::remove_XSS($_GET['selectcat']), null, array('class' =>'form-vertical' )); +$form = new FormValidator('create_document','post',api_get_self().'?'.api_get_cidreq().'&dir='.Security::remove_XSS(urlencode($dir)).'&selectcat='.Security::remove_XSS($_GET['selectcat']), null, array('class' =>'form-vertical' )); // form title -$form->addElement('header', '', $nameTools); +$form->addElement('header', $nameTools); if ($is_certificate_mode) {//added condition for certicate in gradebook $form->addElement('hidden','certificate','true',array('id'=>'certificate')); @@ -492,7 +492,7 @@ if ($form->validate()) { $content = Security::remove_XSS($values['content'], COURSEMANAGERLOWSECURITY); if (strpos($content, '/css/frames.css') === false) { - $content = str_replace('', ' ', $content); + $content = str_replace('', '', $content); } if ($fp = @fopen($filepath.$filename.'.'.$extension, 'w')) { $content = str_replace(api_get_path(WEB_COURSE_PATH), $_configuration['url_append'].'/courses/', $content); @@ -555,8 +555,8 @@ if ($form->validate()) { } $certificate_condition = '&certificate=true'; } - header('Location: document.php?id='.$folder_id.$selectcat.$certificate_condition); - exit (); + header('Location: document.php?'.api_get_cidreq().'&id='.$folder_id.$selectcat.$certificate_condition); + exit(); } else { Display :: display_header($nameTools, 'Doc'); Display :: display_error_message(get_lang('Impossible')); diff --git a/main/document/document.php b/main/document/document.php index e0931aad8c..052e171761 100644 --- a/main/document/document.php +++ b/main/document/document.php @@ -106,7 +106,6 @@ if (api_get_session_id() != 0) { $group_member_with_upload_rights = $group_member_with_upload_rights && api_is_allowed_to_session_edit(false, true); } - //Setting group variables if (api_get_group_id()) { // Get group info @@ -118,20 +117,17 @@ if (api_get_group_id()) { if ($group_properties['doc_state'] == 2) { // Documents are private if ($is_allowed_to_edit || GroupManager :: is_user_in_group(api_get_user_id(), api_get_group_id())) { - // Only courseadmin or group members (members + tutors) allowed - $req_gid = '&gidReq=' . api_get_group_id(); + // Only courseadmin or group members (members + tutors) allowed $interbreadcrumb[] = array('url' => '../group/group.php', 'name' => get_lang('Groups')); $interbreadcrumb[] = array('url' => '../group/group_space.php?gidReq=' . api_get_group_id(), 'name' => get_lang('GroupSpace') . ' ' . $group_properties['name']); //they are allowed to upload $group_member_with_upload_rights = true; } else { - $to_group_id = 0; - $req_gid = ''; + $to_group_id = 0; } } elseif ($group_properties['doc_state'] == 1) { // Documents are public - $to_group_id = api_get_group_id(); - $req_gid = '&gidReq=' . api_get_group_id(); + $to_group_id = api_get_group_id(); $interbreadcrumb[] = array('url' => '../group/group.php', 'name' => get_lang('Groups')); $interbreadcrumb[] = array('url' => '../group/group_space.php?gidReq=' . api_get_group_id(), 'name' => get_lang('GroupSpace') . ' ' . $group_properties['name']); //allowed to upload? @@ -140,14 +136,12 @@ if (api_get_group_id()) { $group_member_with_upload_rights = true; } } else { // Documents not active for this group - $to_group_id = 0; - $req_gid = ''; + $to_group_id = 0; } $_SESSION['group_member_with_upload_rights'] = $group_member_with_upload_rights; } else { $_SESSION['group_member_with_upload_rights'] = false; - $to_group_id = 0; - $req_gid = ''; + $to_group_id = 0; } //Actions @@ -928,7 +922,7 @@ if ($curdirpath != '/' && $curdirpath != $group_properties['directory'] && !$is_ if ($is_certificate_mode && $curdirpath != '/certificates') { ?> - + - + - +   - + - + - + - + - + - + '; + echo ''; echo Display::display_icon('upload_certificate.png', get_lang('UploadCertificate'), '', ICON_SIZE_MEDIUM) . ''; } else { - echo ''; + echo ''; echo Display::display_icon('upload_file.png', get_lang('UplUploadDocument'), '', ICON_SIZE_MEDIUM) . ''; } // Create directory if (!$is_certificate_mode) { ?> - + $category) { if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath') { Display::display_footer(); } +Session::erase('_gid'); \ No newline at end of file diff --git a/main/inc/ajax/document.ajax.php b/main/inc/ajax/document.ajax.php index e6b48d1aaa..b41413bb13 100644 --- a/main/inc/ajax/document.ajax.php +++ b/main/inc/ajax/document.ajax.php @@ -10,11 +10,9 @@ require_once api_get_path(LIBRARY_PATH).'document.lib.php'; $action = $_REQUEST['a']; switch($action) { case 'upload_file': - api_protect_course_script(true); - + api_protect_course_script(true); //User access same as upload.php - $is_allowed_to_edit = api_is_allowed_to_edit(null, true); - + $is_allowed_to_edit = api_is_allowed_to_edit(null, true); // This needs cleaning! if (api_get_group_id()) { if ($is_allowed_to_edit || GroupManager::is_user_in_group(api_get_user_id(), api_get_group_id())) { // Only courseadmin or group members allowed diff --git a/main/inc/global.inc.php b/main/inc/global.inc.php index 7d72428fc3..a2c0fd991d 100644 --- a/main/inc/global.inc.php +++ b/main/inc/global.inc.php @@ -617,4 +617,4 @@ $default_quota = api_get_setting('default_document_quotum'); if (empty($default_quota)) { $default_quota = 100000000; } -define('DEFAULT_DOCUMENT_QUOTA', $default_quota); +define('DEFAULT_DOCUMENT_QUOTA', $default_quota); \ No newline at end of file diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index f6138f061a..8f127e1274 100755 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -2227,8 +2227,7 @@ class DocumentManager { $base_work_dir = $sys_course_path.$course_dir; if (isset($files['file'])) { - $upload_ok = process_uploaded_file($files['file'], $show_output); - + $upload_ok = process_uploaded_file($files['file'], $show_output); if ($upload_ok) { // File got on the server without problems, now process it $new_path = handle_uploaded_document($course_info, $files['file'], $base_work_dir, $path, api_get_user_id(), api_get_group_id(), null, $unzip, $if_exists, $show_output); diff --git a/main/inc/local.inc.php b/main/inc/local.inc.php index f70f3d65ed..6ff6b8d291 100644 --- a/main/inc/local.inc.php +++ b/main/inc/local.inc.php @@ -634,7 +634,7 @@ if (isset($uidReset) && $uidReset) { // session data refresh requested if (isset($cidReset) && $cidReset) { // Course session data refresh requested or empty data - if ($cidReq) { + if ($cidReq) { $_course = api_get_course_info($cidReq); if (!empty($_course)) { @@ -665,7 +665,7 @@ if (isset($cidReset) && $cidReset) { } if (!empty($_GET['gidReq'])) { - $_SESSION['_gid'] = intval($_GET['gidReq']); + $_SESSION['_gid'] = intval($_GET['gidReq']); } else { Session::erase('_gid'); } @@ -730,6 +730,8 @@ if (isset($cidReset) && $cidReset) { $_cid = $_SESSION['_cid' ]; $_course = $_SESSION['_course']; + + // these lines are usefull for tracking. Indeed we can have lost the id_session and not the cid. // Moreover, if we want to track a course with another session it can be usefull @@ -741,8 +743,18 @@ if (isset($cidReset) && $cidReset) { $_SESSION['id_session'] = intval($_GET['id_session']); } + if (!empty($_REQUEST['gidReq'])) { - $_SESSION['_gid'] = intval($_REQUEST['gidReq']); + $_SESSION['_gid'] = intval($_REQUEST['gidReq']); + + $group_table = Database::get_course_table(TABLE_GROUP); + $sql = "SELECT * FROM $group_table WHERE c_id = ".$_course['real_id']." AND id = '$gidReq'"; + $result = Database::query($sql); + if (Database::num_rows($result) > 0) { // This group has recorded status related to this course + $gpData = Database::fetch_array($result); + $_gid = $gpData ['id']; + Session::write('_gid', $_gid); + } } if (!isset($_SESSION['login_as'])) { @@ -807,10 +819,12 @@ if (isset($cidReset) && $cidReset) { } // if the requested group is different from the group in session -$gid = isset($_SESSION['_gid']) ? $_SESSION['_gid'] : ''; +/* +$gid = isset($_SESSION['_gid']) ? $_SESSION['_gid'] : 0; if (isset($gidReq) && $gidReq != $gid) { $gidReset = true; -} +}*/ + /* COURSE / USER REL. INIT */ @@ -1043,7 +1057,9 @@ if ((isset($uidReset) && $uidReset) || (isset($cidReset) && $cidReset)) { } /* GROUP INIT */ -if ((isset($gidReset) && $gidReset) || (isset($cidReset) && $cidReset)) { // session data refresh requested +/* +if ((isset($gidReset) && $gidReset) || (isset($cidReset) && $cidReset)) { + // session data refresh requested if ($gidReq && $_cid && !empty($_course['real_id'])) { // have keys to search data $group_table = Database::get_course_table(TABLE_GROUP); $sql = "SELECT * FROM $group_table WHERE c_id = ".$_course['real_id']." AND id = '$gidReq'"; @@ -1063,7 +1079,7 @@ if ((isset($gidReset) && $gidReset) || (isset($cidReset) && $cidReset)) { // ses } else { //if no previous value, assign caracteristic undefined value $_gid = -1; } - +*/ //set variable according to student_view_enabled choices if (api_get_setting('student_view_enabled') == "true") {