--- loncom/interface/portfolio.pm 2006/06/26 22:23:27 1.121 +++ loncom/interface/portfolio.pm 2014/12/07 19:45:19 1.255 @@ -1,3 +1,8 @@ +# The LearningOnline Network +# portfolio browser +# +# $Id: portfolio.pm,v 1.255 2014/12/07 19:45:19 raeburn Exp $ +# # Copyright Michigan State University Board of Trustees # # This file is part of the LearningOnline Network with CAPA (LON-CAPA). @@ -31,115 +36,242 @@ use Apache::lonfeedback; use Apache::lonlocal; use Apache::lonnet; use Apache::longroup; +use Apache::lonhtmlcommon; use HTML::Entities; -use LONCAPA; +use LONCAPA qw(:DEFAULT :match); -# receives a file name and path stub from username/userfiles/portfolio/ +sub group_args { + my $output; + if (defined($env{'form.group'})) { + $output .= '&group='.$env{'form.group'}; + if (defined($env{'form.ref'})) { + $output .= '&ref='.$env{'form.ref'}; + } + } + return $output; +} + +sub group_form_data { + my $output; + if (defined($env{'form.group'})) { + $output = ''; + if (exists($env{'form.ref'})) { + $output .= ''; + } + } + return $output; +} + +# receives a filename and path stub from username/userfiles/portfolio/ # returns an anchor tag consisting encoding filename and currentpath sub make_anchor { - my ($url, $filename, $current_path, $current_mode, $field_name, - $continue_select,$group) = @_; - if ($continue_select ne 'true') {$continue_select = 'false'}; - my $anchor = ''.$filename.''; + my ($url, $anchor_fields, $inner_text) = @_; + if ($$anchor_fields{'continue'} ne 'true') {$$anchor_fields{'continue'} = 'false'}; + my $anchor = ''.$inner_text.''; return $anchor; } + my $dirptr=16384; sub display_common { - my ($r,$url,$current_path,$is_empty,$dir_list,$group,$can_upload)=@_; - my $namespace = &get_namespace($group); - my $port_path = &get_port_path($group); + my ($r,$url,$current_path,$is_empty,$dir_list,$can_upload,$group)=@_; + my $namespace = &get_namespace(); + my $port_path = &get_port_path(); if ($can_upload) { - my $groupitem; - if (defined($group)) { - $groupitem = ''; - } + my $groupitem = &group_form_data(); + my $iconpath= $r->dir_config('lonIconsURL') . "/"; - my %text=&Apache::lonlocal::texthash( - 'upload' => 'Upload', - 'upload_label' => - 'Upload file to current directory:', - 'createdir' => 'Create Subdirectory', - 'createdir_label' => - 'Create subdirectory in current directory:'); + my %lt=&Apache::lonlocal::texthash( + 'upload' => 'Upload', + 'upload_label' => 'Upload file to current directory', + 'createdir' => 'Create Subdirectory', + 'createdir_label' => 'Create subdirectory in current directory', + 'parse' => 'Upload embedded images/multimedia/css/linked files if HTML file', + ); my $escuri = &HTML::Entities::encode($r->uri,'&<>"'); - $r->print(<<"TABLE"); -
- $text{'upload_label'} - | -- - | -
- $text{'createdir_label'} - | -- - | -
'); - if (defined($group)) { - $r->print("\n".''); - } - $r->print('
'); + $r->print(&group_form_data().''); $r->print(''); - if (defined($group)) { - $r->print("\n".''); - } + $env{'form.currentpath'}.'" />'. + &group_form_data()); $r->print("\n".'
' + .&mt('The file is locked and cannot be deleted.') + .'
' + .&done(undef,$url) + ); } else { if (scalar(@files)) { &open_form($r,$url); - $r->print(''.&mt('Delete').' '.&display_file(undef,\@files).'?
'); - &close_form($r,$url,$group); + $r->print(''.&mt('Delete [_1]?',&display_file(undef,\@files)).'
'); + &close_form($r,$url); } else { - $r->print("No file was checked to delete.'.&mt('No file was checked to delete.').'
'); + $r->print(&done(undef,$url)); } } } @@ -421,24 +659,65 @@ sub delete_confirmed { my @files=&Apache::loncommon::get_env_multiple('form.selectfile'); my $result; my ($uname,$udom) = &get_name_dom($group); - my $port_path = &get_port_path($group); + my $port_path = &get_port_path(); + my $current_permissions = &Apache::lonnet::get_portfile_permissions($udom, + $uname); + my @msg; foreach my $delete_file (@files) { - $result=&Apache::lonnet::removeuserfile($uname,$udom,$port_path. - $env{'form.currentpath'}. - $delete_file); + $result = + &Apache::lonnet::removeuserfile( + $uname,$udom,$port_path. + $env{'form.currentpath'}. + $delete_file); if ($result ne 'ok') { - $r->print(' An error occured ('.$result. - ') while trying to delete '.&display_file(undef, $delete_file).''.&mt('Delete').' '.&display_file().'?
'); - &close_form($r,$url,$group); + $r->print(''.&mt('Delete [_1]?',&display_file()).'
'); + &close_form($r,$url); } sub delete_dir_confirmed { @@ -446,43 +725,53 @@ sub delete_dir_confirmed { my $directory_name = $env{'form.currentpath'}; $directory_name =~ s|/$||; # remove any trailing slash my ($uname,$udom) = &get_name_dom($group); - my $namespace = &get_namespace($group); - my $port_path = &get_port_path($group); + my $namespace = &get_namespace(); + my $port_path = &get_port_path(); my $result=&Apache::lonnet::removeuserfile($uname,$udom,$port_path. $directory_name); - + if ($result ne 'ok') { - $r->print(' An error occured (dir) ('.$result. - ') while trying to delete '.$directory_name.'' + .&mt('The file is locked and cannot be renamed.') + .'
' + ); + $r->print(&done(undef,$url)); } else { &open_form($r,$url); - $r->print(''.&mt('Rename').' '.&display_file().' to - ?
'); - &close_form($r,$url,$group); + $r->print(''.&mt('Rename [_1] to [_2]?', &display_file() + , '').'
'); + &close_form($r,$url); } } @@ -490,64 +779,178 @@ sub rename_confirmed { my ($r,$url,$group)=@_; my $filenewname=&Apache::lonnet::clean_filename($env{'form.filenewname'}); my ($uname,$udom) = &get_name_dom($group); - my $port_path = &get_port_path($group); + my $port_path = &get_port_path(); + + # Display warning in case of filename cleaning has changed the filename + if ($filenewname ne $env{'form.filenewname'}) { + $r->print( + ''
+ .&mt('Invalid characters')
+ .'
'
+ .&mt('The new filename was changed from [_1] to [_2].'
+ ,''.&display_file('',$env{'form.filenewname'}).''
+ ,''.&display_file('',$filenewname).'')
+ .'
'.&mt('Roles').' | '. &mt('Access').' | '. &mt('Sections').' | '); - if ($scope eq 'course') { - $r->print(''.&mt('Groups').' | '); - } else { - $r->print(''.&mt('Teams').' | '); - } + $r->print(''.&mt('Groups').' | '); $r->print('
---|---|---|---|---|---|
'); if ($item eq 'role') { - my $ucscope = $scope; - $ucscope =~ s/^(\w)/uc($1)/e; my $role_output; foreach my $role (@{$content->{'roles'}{$id}{$item}}) { if ($role eq 'all') { @@ -648,7 +1048,7 @@ sub build_access_summary { } elsif ($role =~ /^cr/) { $role_output .= (split('/',$role))[3].','; } else { - $role_output .= &Apache::lonnet::plaintext($role,$ucscope).','; + $role_output .= &Apache::lonnet::plaintext($role,$crstype).','; } } $role_output =~ s/,$//; @@ -656,16 +1056,19 @@ sub build_access_summary { } else { $r->print(join(',',@{$content->{'roles'}{$id}{$item}})); } - $r->print(' |
' + .&mt('Add new [_1]'.$showtypes{$newitem}.'-based[_2] access control for portfolio file: [_3]', + '','', + '' + .$env{'form.currentpath'}.$env{'form.selectfile'}.'') + .'
'); + $firstitem = $totalnew; + $lastitem = $totalnew + $env{'form.new'.$newitem}; + $totalnew = $lastitem; + my @numbers; + for (my $i=$firstitem; $i<$lastitem; $i++) { + push(@numbers,$i); } + &display_access_row($r,$status,$newitem,\@numbers, + $access_controls{$file_name},$now,$then); } - &close_form($r,$url,$group); + &close_form($r,$url); } else { - my $group_arg; - if ($group) { - $group_arg = '&group='.$group; - } - $r->print('');
- $r->print(''.&mt('Public access:').' '.$publictext.''); + if ($action eq 'chgaccess') { + &standard_settings($r,$now,$then,$url,$filename,\%acl_count,\%start, + \%end,$public,$publicnum,$publictext,$guest,$guestnum, + $guesttext,$access_controls,%conditionals); + } else { + &condition_setting($r,$access_controls,$now,$then,\%acl_count, + \@domains,\@users,\@courses,\@ips); + } + $r->print(' |
' + .&mt('No '.$infotype.'-based conditions defined') + .'
' + .&additional_item($type) + ); } return; } @@ -1074,34 +1573,38 @@ sub display_access_row { sub course_js { return qq| |; } @@ -1124,59 +1628,78 @@ sub course_row { } my $js = &Apache::loncommon::coursebrowser_javascript($defdom) .&course_js(); - my $crsgrptext = 'Groups'; - if ($type eq 'group') { - $crsgrptext = 'Teams'; - } - my $uctype = $type; - $uctype =~ s/^(\w)/uc($1)/e; + my $showtype = &mt('Course/Community'); + my $crstype = 'Course'; my ($num,$scope,$end,$start) = &set_identifiers($status,$item,$now,$then, $type); $r->print(''.&mt('Action').' | '.&mt('Roles').' | '. - &mt('Access').' | '.&mt('Sections').' | '. - &mt($crsgrptext).' | '.&dateboxes($num,$start,$end)); + my $newrole_id = 1; if ($status eq 'old') { + $r->print(' | '); my $max_id = 0; - foreach my $role_id (sort(keys(%{$content->{'roles'}}))) { - if ($role_id > $max_id) { - $max_id = $role_id; - } - $max_id ++; - my $role_selects = &role_selectors($num,$role_id,$status,$type,$content,'display'); - $r->print(' |
---|---|---|---|---|
'.&mt('Action').' | '. + ''.&mt('Roles').' | '. + ''.&mt('Access').' | '. + ''.&mt('Sections').' | '. + ''.&mt('Groups').' |
---|---|---|---|---|