@ -1,4 +1,4 @@
<?php //$Id: work.lib.php 20164 2009-04-28 21:02:46 Z cvargas1 $
<?php //$Id: work.lib.php 20209 2009-04-30 00:11:19 Z cvargas1 $
/* For licensing terms, see /dokeos_license.txt */
/**
* @package dokeos.work
@ -6,7 +6,7 @@
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University - ability for course admins to specify wether uploaded documents are visible or invisible by default.
* @author Roan Embrechts, code refactoring and virtual course support
* @author Frederic Vauthier, directories management
* @version $Id: work.lib.php 20164 2009-04-28 21:02:46 Z cvargas1 $
* @version $Id: work.lib.php 20209 2009-04-30 00:11:19 Z cvargas1 $
*/
/**
* Displays action links (for admins, authorized groups members and authorized students)
@ -21,12 +21,12 @@ require_once '../inc/lib/fileDisplay.lib.php';
function display_action_links($cur_dir_path, $always_show_tool_options, $always_show_upload_form)
{
global $gradebook;
$display_output = "";
isset($_GET['origin'])?$origin = Security::remove_XSS($_GET['origin']):$origin='';
if (strlen($cur_dir_path) > 0 & & $cur_dir_path != '/') {
$parent_dir = dirname($cur_dir_path);
$display_output .= '< a href = "'.api_get_self().'?'.api_get_cidreq().'&origin='.$origin.'&curdirpath='.$parent_dir.'" > '.Display::return_icon('folder_up.gif', get_lang('Up')).' '.get_lang('Up').'< / a > ';
$display_output .= '< a href = "'.api_get_self().'?'.api_get_cidreq().'&origin='.$origin.'&gradebook='.$gradebook.'& curdirpath='.$parent_dir.'" > '.Display::return_icon('folder_up.gif', get_lang('Up')).' '.get_lang('Up').'< / a > ';
}
echo '< div class = "actions" > ';
if ($_GET['display_tool_options'] == 'true' OR $_GET['display_upload_form'] == 'true' )
@ -37,21 +37,21 @@ function display_action_links($cur_dir_path, $always_show_tool_options, $always_
}
if (! $always_show_tool_options & & api_is_allowed_to_edit()) {
// Create dir
$display_output .= '< a href = "'.api_get_self().'?'.api_get_cidreq().'&toolgroup='.$_GET['toolgroup'].'&curdirpath='.$cur_dir_path.'&createdir=1&origin='.$origin.'" > < img src = "../img/folder_new.gif" border = "0" alt = "'.get_lang('CreateDir').'" title = "'.get_lang('CreateDir').'" / > '.get_lang('CreateAssignment').' < / a > ';
$display_output .= '< a href = "'.api_get_self().'?'.api_get_cidreq().'&toolgroup='.$_GET['toolgroup'].'&curdirpath='.$cur_dir_path.'&createdir=1&origin='.$origin.'&gradebook='.$gradebook.'" > < img src = "../img/folder_new.gif" border = "0" alt = "'.get_lang('CreateDir').'" title = "'.get_lang('CreateDir').'" / > '.get_lang('CreateAssignment').' < / a > ';
// Options
$display_output .= "< a href = \"".api_get_self()."?".api_get_cidreq()."&curdirpath=".$cur_dir_path."&origin=".$origin."&display_tool_options=true&origin=".$origin."\" > ".Display::return_icon('acces_tool.gif', get_lang("EditToolOptions")).' ' . get_lang("EditToolOptions") . "< / a > ";
$display_output .= "< a href = \"".api_get_self()."?".api_get_cidreq()."&curdirpath=".$cur_dir_path."&origin=".$origin."&display_tool_options=true&origin=".$origin."&gradebook=".$gradebook." \" > ".Display::return_icon('acces_tool.gif', get_lang("EditToolOptions")).' ' . get_lang("EditToolOptions") . "< / a > ";
}
if (! $always_show_upload_form ) {
$display_output .= "< a href = \"".api_get_self()."?".api_get_cidreq()."&curdirpath=".$cur_dir_path."&display_upload_form=true&origin=".$origin."\" > ".Display::return_icon('submit_file.gif', get_lang("UploadADocument"))." ". get_lang("UploadADocument") .'< / a > ';
$display_output .= "< a href = \"".api_get_self()."?".api_get_cidreq()."&curdirpath=".$cur_dir_path."&display_upload_form=true&origin=".$origin."&gradebook=".$gradebook." \" > ".Display::return_icon('submit_file.gif', get_lang("UploadADocument"))." ". get_lang("UploadADocument") .'< / a > ';
}
if (api_is_allowed_to_edit())
{
// delete all files
$display_output .= "< a href = \"".api_get_self()."?".api_get_cidreq()."&curdirpath=".$cur_dir_path."&origin=$origin&delete=all\" " .
$display_output .= "< a href = \"".api_get_self()."?".api_get_cidreq()."&curdirpath=".$cur_dir_path."&origin=$origin&gradebook=$gradebook& delete=all\" " .
"onclick=\"javascript:if(!confirm('".addslashes(htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset))."')) return false;\">".
Display::return_icon('delete.gif', get_lang('Delete')).' '.get_lang('DeleteAllFiles')."< / a > ";
@ -64,11 +64,11 @@ function display_action_links($cur_dir_path, $always_show_tool_options, $always_
$columnStatus = mysql_fetch_array($sql_result);
if ($columnStatus['Default'] == 1) {
$display_output .= "< a href = \"".api_get_self()."?".api_get_cidreq()."&curdirpath=".$cur_dir_path."&origin=$origin&make_invisible=all\" > ".
$display_output .= "< a href = \"".api_get_self()."?".api_get_cidreq()."&curdirpath=".$cur_dir_path."&origin=$origin&gradebook=$gradebook& make_invisible=all\" > ".
Display::return_icon('invisible.gif', get_lang('Invisible')).' '.get_lang('MakeInvisible').
"< / a > \n";
} else {
$display_output .= "< a href = \"".api_get_self()."?".api_get_cidreq()."&curdirpath=".$cur_dir_path."&origin=$origin&make_visible=all\" > ".
$display_output .= "< a href = \"".api_get_self()."?".api_get_cidreq()."&curdirpath=".$cur_dir_path."&origin=$origin&gradebook=$gradebook& make_visible=all\" > ".
Display::return_icon('visible.gif', get_lang('Visible')).' '.get_lang('MakeVisible').
"< / a > \n";
}
@ -96,14 +96,14 @@ function display_action_links($cur_dir_path, $always_show_tool_options, $always_
* @param $cur_dir_path_url Current subdirectory of 'work/', url-encoded
*/
function display_tool_options($uploadvisibledisabled, $origin,$base_work_dir,$cur_dir_path,$cur_dir_path_url) {
global $charset, $group_properties;
global $charset, $group_properties,$gradebook ;
$is_allowed_to_edit = api_is_allowed_to_edit();
$work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
if (! $is_allowed_to_edit) {
return;
}
echo '< form method = "post" action = "'.api_get_self().'?origin='.$origin.'&display_tool_options=true" > ';
echo '< form method = "post" action = "'.api_get_self().'?origin='.$origin.'&gradebook='.$gradebook.'& display_tool_options=true" > ';
echo '< div class = "row" > < div class = "form_header" > '.get_lang('EditToolOptions').'< / div > < / div > ';
display_default_visibility_form($uploadvisibledisabled);
echo '< div class = "row" >
@ -161,9 +161,9 @@ function display_user_link($user_id, $name='')
$result=api_sql_query($sql,__FILE__,__LINE__);
$row=Database::fetch_array($result);
if ($name=='') {
return "< a href = \"../user/userInfo.php?cidReq=".api_get_course_id()."&origin=&uInfo=".$row['user_id']."\" > ".$row['firstname']." ".$row['lastname']."< / a > ";
return "< a href = \"../user/userInfo.php?cidReq=".api_get_course_id()."&gradebook=$gradebook& origin=&uInfo=".$row['user_id']."\" > ".$row['firstname']." ".$row['lastname']."< / a > ";
} else {
return "< a href = \"../user/userInfo.php?cidReq=".api_get_course_id()."&origin=&uInfo=".$user_id."\" > ".$name."< / a > ";
return "< a href = \"../user/userInfo.php?cidReq=".api_get_course_id()."&gradebook=$gradebook& origin=&uInfo=".$user_id."\" > ".$name."< / a > ";
}
} else {
return $name.' ('.get_lang('Anonymous').')';
@ -236,7 +236,7 @@ function create_group_date_select($prefix='')
*/
function display_student_publications_list($work_dir,$sub_course_dir,$currentCourseRepositoryWeb, $link_target_parameter, $dateFormatLong, $origin,$add_in_where_query='')
{
global $charset,$timeNoSecFormat,$dateFormatShort;
global $charset,$timeNoSecFormat,$dateFormatShort,$gradebook ;
// Database table names
$work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$iprop_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
@ -408,7 +408,7 @@ function display_student_publications_list($work_dir,$sub_course_dir,$currentCou
$homework = mysql_fetch_array($sql);
}
$form_folder = new FormValidator('edit_dir', 'post', api_get_self().'?curdirpath='.$my_sub_dir.'&origin='.$origin.'&edit_dir='.$mydir);
$form_folder = new FormValidator('edit_dir', 'post', api_get_self().'?curdirpath='.$my_sub_dir.'&origin='.$origin.'&gradebook='.$gradebook.'& edit_dir='.$mydir);
$group_name[] = FormValidator :: createElement('text','dir_name');
//$group_name[] = FormValidator :: createElement('submit','submit_edit_dir',get_lang('Ok'));
@ -614,9 +614,9 @@ function display_student_publications_list($work_dir,$sub_course_dir,$currentCou
$show_as_icon = get_work_id($mydir); //true or false
if ($show_as_icon) {
$row[] = '< a href = "'.api_get_self().'?cidReq='.api_get_course_id().'&action=downloadfolder&path=/'.$mydir.'" > < img src = "../img/zip_save.gif" style = "float:right;" alt = "'.get_lang('Save').'" title = "'.get_lang('Save').'" width = "17" height = "17" / > < / a > < a href = "'.api_get_self().'?'.api_get_cidreq().'&origin='.$origin.'&gradebook='.Security::remove_XSS($_GET['gradebook']).'&curdirpath='.$mydir.'" ' . $ class . ' > '.$dir.'< / a > '.$add_to_name.'< br > '.$cant_files.' '.$text_file.$dirtext;
$row[] = '< a href = "'.api_get_self().'?cidReq='.api_get_course_id().'&gradebook='.$gradebook.'& action=downloadfolder&path=/'.$mydir.'" > < img src = "../img/zip_save.gif" style = "float:right;" alt = "'.get_lang('Save').'" title = "'.get_lang('Save').'" width = "17" height = "17" / > < / a > < a href = "'.api_get_self().'?'.api_get_cidreq().'&origin='.$origin.'&gradebook='.Security::remove_XSS($_GET['gradebook']).'&curdirpath='.$mydir.'" ' . $ class . ' > '.$dir.'< / a > '.$add_to_name.'< br > '.$cant_files.' '.$text_file.$dirtext;
} else {
$row[] = '< a href = "'.api_get_self().'?'.api_get_cidreq().'&origin='.$origin.'&curdirpath='.$mydir.'" ' . $ class . ' > '.$dir.'< / a > '.$add_to_name.'< br > '.$cant_files.' '.$text_file.$dirtext;
$row[] = '< a href = "'.api_get_self().'?'.api_get_cidreq().'&origin='.$origin.'&gradebook='.$gradebook.'& curdirpath='.$mydir.'" ' . $ class . ' > '.$dir.'< / a > '.$add_to_name.'< br > '.$cant_files.' '.$text_file.$dirtext;
}
}
@ -634,8 +634,8 @@ function display_student_publications_list($work_dir,$sub_course_dir,$currentCou
if( $is_allowed_to_edit) {
$action .= '< a href = "'.api_get_self().'?cidReq='.api_get_course_id().
'& curdirpath='.$my_sub_dir.'& origin='.$origin.'& gradebook='.Security::remove_XSS( $_GET[' gradebook']) .'& edit_dir='.$mydir.'">< img src = "../img/edit.gif" alt = "'.get_lang('Modify').'" title = "'.get_lang('Modify').'" > < / a > ';
$action .= '< a href = "'.api_get_self().'?'.api_get_cidreq().'&origin='.$origin.'&delete_dir='.$mydir.'&delete2='.$id2.'" onclick = "javascript:if(!confirm('." ' " . addslashes ( htmlentities ( get_lang ( ' ConfirmYourChoice ' ) , ENT_QUOTES , $ charset ) ) . " ' " . ' ) ) return false ; " title = "'.get_lang('DirDelete').'" > < img src = "'.api_get_path(WEB_IMG_PATH).'delete.gif" alt = "'.get_lang('DirDelete').'" title = "'.get_lang('DirDelete').'" > < / a > ';
'& curdirpath='.$my_sub_dir.'& origin='.$origin.'& gradebook='.$gradebook.'& edit_dir='.$mydir.'">< img src = "../img/edit.gif" alt = "'.get_lang('Modify').'" title = "'.get_lang('Modify').'" > < / a > ';
$action .= '< a href = "'.api_get_self().'?'.api_get_cidreq().'&origin='.$origin.'&gradebook='.$gradebook.'& delete_dir='.$mydir.'&delete2='.$id2.'" onclick = "javascript:if(!confirm('." ' " . addslashes ( htmlentities ( get_lang ( ' ConfirmYourChoice ' ) , ENT_QUOTES , $ charset ) ) . " ' " . ' ) ) return false ; " title = "'.get_lang('DirDelete').'" > < img src = "'.api_get_path(WEB_IMG_PATH).'delete.gif" alt = "'.get_lang('DirDelete').'" title = "'.get_lang('DirDelete').'" > < / a > ';
$row[] = $action;
} else {
$row[] = "";
@ -691,20 +691,20 @@ function display_student_publications_list($work_dir,$sub_course_dir,$currentCou
if( $is_allowed_to_edit) {
$action = '';
$action .= '< a href = "'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.urlencode($my_sub_dir).'&origin='.$origin.'&edit='.$work->id.'&gradebook='.Security::remove_XSS($_GET['gradebook']).'&parent_id='.$work->parent_id.'" title = "'.get_lang('Modify').'" > < img src = "../img/edit.gif" alt = "'.get_lang('Modify').'" title = "'.get_lang('Modify').'" > < / a > ';
$action .= '< a href = "'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.urlencode($my_sub_dir).'&origin='.$origin.'&delete='.$work->id.'" onclick = "javascript:if(!confirm('." ' " . addslashes ( htmlentities ( get_lang ( ' ConfirmYourChoice ' ) , ENT_QUOTES , $ charset ) ) . " ' " . ' ) ) return false ; " title = "'.get_lang('WorkDelete').'" > < img src = "../img/delete.gif" alt = "'.get_lang('WorkDelete').'" title = "'.get_lang('WorkDelete').'" > < / a > ';
$action .= '< a href = "'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.urlencode($my_sub_dir).'&origin='.$origin.'&move='.$work->id.'" title = "'.get_lang('Move').'" > < img src = "../img/deplacer_fichier.gif" border = "0" title = "'.get_lang('Move').'" alt = "'.get_lang('Move').'" / > < / a > ';
$action .= '< a href = "'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.urlencode($my_sub_dir).'&origin='.$origin.'&gradebook='.$gradebook.'& amp;edit='.$work->id.'&gradebook='.Security::remove_XSS($_GET['gradebook']).'&parent_id='.$work->parent_id.'" title = "'.get_lang('Modify').'" > < img src = "../img/edit.gif" alt = "'.get_lang('Modify').'" title = "'.get_lang('Modify').'" > < / a > ';
$action .= '< a href = "'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.urlencode($my_sub_dir).'&origin='.$origin.'&gradebook='.$gradebook.'& amp;delete='.$work->id.'" onclick = "javascript:if(!confirm('." ' " . addslashes ( htmlentities ( get_lang ( ' ConfirmYourChoice ' ) , ENT_QUOTES , $ charset ) ) . " ' " . ' ) ) return false ; " title = "'.get_lang('WorkDelete').'" > < img src = "../img/delete.gif" alt = "'.get_lang('WorkDelete').'" title = "'.get_lang('WorkDelete').'" > < / a > ';
$action .= '< a href = "'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.urlencode($my_sub_dir).'&origin='.$origin.'&gradebook='.$gradebook.'& amp;move='.$work->id.'" title = "'.get_lang('Move').'" > < img src = "../img/deplacer_fichier.gif" border = "0" title = "'.get_lang('Move').'" alt = "'.get_lang('Move').'" / > < / a > ';
if($work->accepted == '1') {
$action .= '< a href = "'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.urlencode($my_sub_dir).'&origin='.$origin.'&make_invisible='.$work->id.'&'.$sort_params.'" title = "'.get_lang('Invisible').'" > < img src = "../img/visible.gif" alt = "'.get_lang('Invisible').'" title = "'.get_lang('Invisible').'" > < / a > ';
$action .= '< a href = "'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.urlencode($my_sub_dir).'&origin='.$origin.'&gradebook='.$gradebook.'& amp;make_invisible='.$work->id.'&'.$sort_params.'" title = "'.get_lang('Invisible').'" > < img src = "../img/visible.gif" alt = "'.get_lang('Invisible').'" title = "'.get_lang('Invisible').'" > < / a > ';
} else {
$action .= '< a href = "'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.urlencode($my_sub_dir).'&origin='.$origin.'&make_visible='.$work->id.'&'.$sort_params.'" title = "'.get_lang('Visible').'" > < img src = "../img/invisible.gif" alt = "'.get_lang('Visible').'" title = "'.get_lang('Visible').'" > < / a > ';
$action .= '< a href = "'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.urlencode($my_sub_dir).'&origin='.$origin.'&gradebook='.$gradebook.'& amp;make_visible='.$work->id.'&'.$sort_params.'" title = "'.get_lang('Visible').'" > < img src = "../img/invisible.gif" alt = "'.get_lang('Visible').'" title = "'.get_lang('Visible').'" > < / a > ';
}
$row[] = $action;
} elseif($is_author) {
$action = '';
$action .= '< a href = "'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.urlencode($my_sub_dir).'&gradebook='.Security::remove_XSS($_GET['gradebook']).'&origin='.$origin.'&edit='.$work->id.'" title = "'.get_lang('Modify').'" > < img src = "../img/edit.gif" alt = "'.get_lang('Modify').'" title = "'.get_lang('Modify').'" > < / a > ';
$action .= '< a href = "'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.urlencode($my_sub_dir).'&origin='.$origin.'&delete='.$work->id.'" onclick = "javascript:if(!confirm('." ' " . addslashes ( htmlentities ( get_lang ( ' ConfirmYourChoice ' ) , ENT_QUOTES , $ charset ) ) . " ' " . ' ) ) return false ; " title = "'.get_lang('WorkDelete').'" > < img src = "../img/delete.gif" alt = "'.get_lang('WorkDelete').'" title = "'.get_lang('WorkDelete').'" > < / a > ';
$action .= '< a href = "'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.urlencode($my_sub_dir).'&gradebook='.Security::remove_XSS($_GET['gradebook']).'&origin='.$origin.'&gradebook='.$gradebook.'& amp;edit='.$work->id.'" title = "'.get_lang('Modify').'" > < img src = "../img/edit.gif" alt = "'.get_lang('Modify').'" title = "'.get_lang('Modify').'" > < / a > ';
$action .= '< a href = "'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.urlencode($my_sub_dir).'&origin='.$origin.'&gradebook='.$gradebook.'& amp;delete='.$work->id.'" onclick = "javascript:if(!confirm('." ' " . addslashes ( htmlentities ( get_lang ( ' ConfirmYourChoice ' ) , ENT_QUOTES , $ charset ) ) . " ' " . ' ) ) return false ; " title = "'.get_lang('WorkDelete').'" > < img src = "../img/delete.gif" alt = "'.get_lang('WorkDelete').'" title = "'.get_lang('WorkDelete').'" > < / a > ';
$row[] = $action;
} else {
@ -819,8 +819,9 @@ function build_work_move_to_selector($folders,$curdirpath,$move_file,$group_dir=
$sql = "SELECT title FROM $tbl_work WHERE id ='".(int)$move_file."'";
$result = api_sql_query($sql,__FILE__,__LINE__);
$title = Database::fetch_row($result);
global $gradebook;
$form = '< form name = "move_to" action = "'.api_get_self().'" method = "POST" > '."\n";
$form = '< form name = "move_to" action = "'.api_get_self().'?gradebook='.$gradebook.' " method = "POST" > '."\n";
$form .= '< div class = "row" > < div class = "form_header" > '.get_lang('MoveFile').'< / div > < / div > ';
$form .= '< input type = "hidden" name = "move_file" value = "'.$move_file.'" / > '."\n";
$form .= '< div class = "row" >
@ -1316,7 +1317,7 @@ function to_javascript_work() {
}
}
document.form1.action = "work.php?origin='.Security::remove_XSS($_REQUEST['origin']).'";
document.form1.action = "work.php?origin='.Security::remove_XSS($_REQUEST['origin']).'&gradebook='.Security::remove_XSS($_GET['gradebook']).' ";
document.form1.submit();
}