students can upload files to his shared folder

skala
Juan Carlos Raña 15 years ago
parent 55a2122e3b
commit 5159f5e1e8
  1. 15
      main/document/document.inc.php
  2. 43
      main/document/document.php
  3. 45
      main/document/upload.php

@ -546,4 +546,19 @@ function create_dir_form()
return $new_folder_text; return $new_folder_text;
} }
/**
* get if the user is in his shared folder
* @return return bool Return true when user is in his shared folder
*/
function is_my_shared_folder($user_id, $path)
{
if('/shared_folder/sf_user_'.$user_id==Security::remove_XSS($path))
{
return true;
}
return false;
}
?> ?>

@ -140,6 +140,9 @@ $dbl_click_id = 0; // used to avoid double-click
$is_allowed_to_edit = api_is_allowed_to_edit(null,true); $is_allowed_to_edit = api_is_allowed_to_edit(null,true);
$group_member_with_upload_rights = false; $group_member_with_upload_rights = false;
//if the group id is set, we show them group documents //if the group id is set, we show them group documents
if(isset($_SESSION['_gid']) && $_SESSION['_gid']!='') if(isset($_SESSION['_gid']) && $_SESSION['_gid']!='')
{ {
@ -240,6 +243,21 @@ if (!(DocumentManager::is_visible($curdirpath, $_course)||$is_allowed_to_edit)){
$course_quota = DocumentManager::get_course_quota(); $course_quota = DocumentManager::get_course_quota();
$current_session_id = api_get_session_id(); $current_session_id = api_get_session_id();
/*
-----------------------------------------------------------
Create the current user shared folder if no exist
-----------------------------------------------------------
*/
if (!file_exists($base_work_dir.'/shared_folder/sf_user_'.api_get_user_id()))
{
$usf_dir_title=api_get_person_name($_user['firstName'], $_user['lastName']);
$usf_dir_name='/shared_folder/sf_user_'.api_get_user_id();
$to_group_id=0;
create_unexisting_directory($_course,$_user['user_id'],$to_group_id,$to_user_id,$base_work_dir,$usf_dir_name,$usf_dir_title);
}
/* /*
============================================================================== ==============================================================================
MAIN SECTION MAIN SECTION
@ -760,6 +778,7 @@ if(isset($docs_and_folders) && is_array($docs_and_folders))
//data for checkbox //data for checkbox
if (($is_allowed_to_edit || $group_member_with_upload_rights) AND count($docs_and_folders)>1) { if (($is_allowed_to_edit || $group_member_with_upload_rights) AND count($docs_and_folders)>1) {
$row[] = $id['path']; $row[] = $id['path'];
} }
// Show the Owner of the file only in groups // Show the Owner of the file only in groups
@ -824,22 +843,28 @@ else
$column_show=array(); $column_show=array();
if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_folder($_user['user_id'],$curdirpath))// TODO:check enable more options for shared folders
if ($is_allowed_to_edit || $group_member_with_upload_rights)
{ {
/* CREATE NEW DOCUMENT OR NEW DIRECTORY / GO TO UPLOAD / DOWNLOAD ZIPPED FOLDER */ /* CREATE NEW DOCUMENT OR NEW DIRECTORY / GO TO UPLOAD / DOWNLOAD ZIPPED FOLDER */
?> ?>
<!-- create new document or directory --> <!-- create new document or directory -->
<a href="create_document.php?<?php echo api_get_cidreq();?>&dir=<?php echo $curdirpathurl.$req_gid; ?>"><img src="../img/filenew.gif" border="0" alt="" title="<?php echo get_lang('CreateDoc'); ?>" /></a> <?php if (!is_my_shared_folder($_user['user_id'],$curdirpath))
<a href="create_document.php?<?php echo api_get_cidreq();?>&dir=<?php echo $curdirpathurl.$req_gid; ?>"><?php echo get_lang("CreateDoc"); ?></a>&nbsp;&nbsp; {?>
<a href="create_document.php?<?php echo api_get_cidreq();?>&dir=<?php echo $curdirpathurl.$req_gid; ?>"><img src="../img/filenew.gif" border="0" alt="" title="<?php echo get_lang('CreateDoc'); ?>" /></a>
<a href="create_document.php?<?php echo api_get_cidreq();?>&dir=<?php echo $curdirpathurl.$req_gid; ?>"><?php echo get_lang("CreateDoc"); ?></a>&nbsp;&nbsp;
<?php }?>
<!-- file upload link --> <!-- file upload link -->
<a href="upload.php?<?php echo api_get_cidreq();?>&path=<?php echo $curdirpathurl.$req_gid; ?>"><img src="../img/submit_file.gif" border="0" title="<?php echo get_lang('UplUploadDocument'); ?>" alt="" /></a>
<a href="upload.php?<?php echo api_get_cidreq();?>&path=<?php echo $curdirpathurl.$req_gid; ?>"><?php echo get_lang('UplUploadDocument'); ?></a>&nbsp; <a href="upload.php?<?php echo api_get_cidreq();?>&curdirpath=<?php echo $curdirpathurl.$req_gid; ?>"><img src="../img/submit_file.gif" border="0" title="<?php echo get_lang('UplUploadDocument'); ?>" alt="" /></a>
<a href="upload.php?<?php echo api_get_cidreq();?>&curdirpath=<?php echo $curdirpathurl.$req_gid; ?>"><?php echo get_lang('UplUploadDocument'); ?></a>&nbsp;
<!-- create directory --> <!-- create directory -->
<a href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq();?>&curdirpath=<?php echo $curdirpathurl.$req_gid; ?>&amp;createdir=1"><img src="../img/folder_new.gif" border="0" title="<?php echo get_lang('CreateDir'); ?>" alt ="" /></a> <?php if (!is_my_shared_folder($_user['user_id'],$curdirpath))
<a href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq();?>&curdirpath=<?php echo $curdirpathurl.$req_gid; ?>&amp;createdir=1"><?php echo get_lang("CreateDir"); ?></a>&nbsp; {?>
<a href="quota.php?<?php echo api_get_cidreq();?>"><?php Display::display_icon('statistics.gif', get_lang("ShowCourseQuotaUse")); ?><?php echo get_lang("ShowCourseQuotaUse"); ?></a> <a href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq();?>&curdirpath=<?php echo $curdirpathurl.$req_gid; ?>&amp;createdir=1"><img src="../img/folder_new.gif" border="0" title="<?php echo get_lang('CreateDir'); ?>" alt ="" /></a>
<a href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq();?>&curdirpath=<?php echo $curdirpathurl.$req_gid; ?>&amp;createdir=1"><?php echo get_lang("CreateDir"); ?></a>&nbsp;
<a href="quota.php?<?php echo api_get_cidreq();?>"><?php Display::display_icon('statistics.gif', get_lang("ShowCourseQuotaUse")); ?><?php echo get_lang("ShowCourseQuotaUse"); ?></a>
<?php <?php
}
} }
if ($docs_and_folders!=null) { if ($docs_and_folders!=null) {
global $total_size; global $total_size;

@ -185,6 +185,27 @@ $sys_course_path = api_get_path(SYS_COURSE_PATH);
$base_work_dir = $sys_course_path.$courseDir; $base_work_dir = $sys_course_path.$courseDir;
$noPHP_SELF=true; $noPHP_SELF=true;
//what's the current path?
if(isset($_GET['curdirpath']) && $_GET['curdirpath']!='')
{
$path = $_GET['curdirpath'];
}
elseif (isset($_POST['curdirpath']))
{
$path = $_POST['curdirpath'];
}
else
{
$path = '/';
}
//check the path: if the path is not found (no document id), set the path to /
if(!DocumentManager::get_document_id($_course,$path))
{
$path = '/';
}
//this needs cleaning! //this needs cleaning!
if(isset($_SESSION['_gid']) && $_SESSION['_gid']!='') //if the group id is set, check if the user has the right to be here if(isset($_SESSION['_gid']) && $_SESSION['_gid']!='') //if the group id is set, check if the user has the right to be here
{ {
@ -205,7 +226,7 @@ if(isset($_SESSION['_gid']) && $_SESSION['_gid']!='') //if the group id is set,
api_not_allowed(true); api_not_allowed(true);
} }
} }
elseif($is_allowed_to_edit) //admin for "regular" upload, no group documents elseif($is_allowed_to_edit || is_my_shared_folder($_user['user_id'], $path)) //admin for "regular" upload, no group documents. And check if is my shared folder
{ {
$to_group_id = 0; $to_group_id = 0;
$req_gid = ''; $req_gid = '';
@ -215,25 +236,7 @@ else //no course admin and no group member...
api_not_allowed(true); api_not_allowed(true);
} }
//what's the current path?
if(isset($_GET['path']) && $_GET['path']!='')
{
$path = $_GET['path'];
}
elseif (isset($_POST['curdirpath']))
{
$path = $_POST['curdirpath'];
}
else
{
$path = '/';
}
//check the path: if the path is not found (no document id), set the path to /
if(!DocumentManager::get_document_id($_course,$path))
{
$path = '/';
}
//group docs can only be uploaded in the group directory //group docs can only be uploaded in the group directory
if($to_group_id!=0 && $path=='/') if($to_group_id!=0 && $path=='/')
{ {
@ -517,7 +520,7 @@ echo '<div class="actions">';
echo '<a href="document.php?curdirpath='.$path.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview')).get_lang('BackTo').' '.get_lang('DocumentsOverview').'</a>'; echo '<a href="document.php?curdirpath='.$path.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview')).get_lang('BackTo').' '.get_lang('DocumentsOverview').'</a>';
// link to create a folder // link to create a folder
if(!isset($_GET['createdir'])) if(!isset($_GET['createdir']) && !is_my_shared_folder($_user['user_id'], $path))
{ {
echo '<a href="'.api_get_self().'?path='.$path.'&amp;createdir=1">'.Display::return_icon('folder_new.gif', get_lang('CreateDir')).get_lang('CreateDir').'</a>'; echo '<a href="'.api_get_self().'?path='.$path.'&amp;createdir=1">'.Display::return_icon('folder_new.gif', get_lang('CreateDir')).get_lang('CreateDir').'</a>';
} }
@ -525,7 +528,9 @@ echo '</div>';
//form to select directory //form to select directory
$folders = DocumentManager::get_all_document_folders($_course,$to_group_id,$is_allowed_to_edit); $folders = DocumentManager::get_all_document_folders($_course,$to_group_id,$is_allowed_to_edit);
echo(build_directory_selector($folders,$path,$group_properties['directory'])); echo(build_directory_selector($folders,$path,$group_properties['directory']));
?> ?>
<!-- start upload form --> <!-- start upload form -->

Loading…
Cancel
Save