Annotation of loncom/interface/portfolio.pm, revision 1.247
1.125 albertel 1: # The LearningOnline Network
2: # portfolio browser
3: #
1.247 ! raeburn 4: # $Id: portfolio.pm,v 1.246 2013/07/02 19:04:37 raeburn Exp $
1.125 albertel 5: #
1.3 banghart 6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28:
1.1 banghart 29: package Apache::portfolio;
30: use strict;
31: use Apache::Constants qw(:common :http);
1.2 banghart 32: use Apache::loncommon;
1.1 banghart 33: use Apache::lonnet;
1.2 banghart 34: use Apache::lontexconvert;
35: use Apache::lonfeedback;
36: use Apache::lonlocal;
1.82 albertel 37: use Apache::lonnet;
1.99 raeburn 38: use Apache::longroup;
1.132 raeburn 39: use Apache::lonhtmlcommon;
1.113 albertel 40: use HTML::Entities;
1.221 raeburn 41: use LONCAPA qw(:DEFAULT :match);
1.16 banghart 42:
1.137 albertel 43: sub group_args {
44: my $output;
45: if (defined($env{'form.group'})) {
1.138 albertel 46: $output .= '&group='.$env{'form.group'};
1.137 albertel 47: if (defined($env{'form.ref'})) {
48: $output .= '&ref='.$env{'form.ref'};
49: }
50: }
51: return $output;
52: }
53:
54: sub group_form_data {
55: my $output;
56: if (defined($env{'form.group'})) {
1.138 albertel 57: $output = '<input type="hidden" name="group" value="'.$env{'form.group'}.'" />';
1.137 albertel 58: if (exists($env{'form.ref'})) {
59: $output .= '<input type="hidden" name="ref" value="'.
60: $env{'form.ref'}.'" />';
61: }
62: }
1.139 albertel 63: return $output;
1.137 albertel 64: }
65:
1.240 bisitz 66: # receives a filename and path stub from username/userfiles/portfolio/
1.16 banghart 67: # returns an anchor tag consisting encoding filename and currentpath
1.23 albertel 68: sub make_anchor {
1.149 banghart 69: my ($url, $anchor_fields, $inner_text) = @_;
70: if ($$anchor_fields{'continue'} ne 'true') {$$anchor_fields{'continue'} = 'false'};
71: my $anchor = '<a href="'.$url.'?';
72: foreach my $field_name (keys(%$anchor_fields)) {
73: $anchor .= $field_name.'='.$$anchor_fields{$field_name}.'&';
74: }
1.151 banghart 75: $anchor =~ s/&$//;
1.138 albertel 76: $anchor .= &group_args();
1.149 banghart 77: $anchor .= '">'.$inner_text.'</a>';
1.8 albertel 78: return $anchor;
1.6 banghart 79: }
1.138 albertel 80:
1.24 albertel 81: my $dirptr=16384;
1.48 banghart 82: sub display_common {
1.206 raeburn 83: my ($r,$url,$current_path,$is_empty,$dir_list,$can_upload,$group)=@_;
1.138 albertel 84: my $namespace = &get_namespace();
85: my $port_path = &get_port_path();
1.120 raeburn 86: if ($can_upload) {
1.137 albertel 87: my $groupitem = &group_form_data();
88:
1.120 raeburn 89: my $iconpath= $r->dir_config('lonIconsURL') . "/";
1.199 bisitz 90: my %lt=&Apache::lonlocal::texthash(
1.216 bisitz 91: 'upload' => 'Upload',
92: 'upload_label' => 'Upload file to current directory',
93: 'createdir' => 'Create Subdirectory',
94: 'createdir_label' => 'Create subdirectory in current directory',
95: 'parse' => 'Upload embedded images/multimedia/css/linked files if HTML file',
96: );
1.120 raeburn 97: my $escuri = &HTML::Entities::encode($r->uri,'&<>"');
1.168 albertel 98: my $help_fileupload = &Apache::loncommon::help_open_topic('Portfolio AddFiles');
99: my $help_createdir = &Apache::loncommon::help_open_topic('Portfolio CreateDirectory');
1.206 raeburn 100: my $help_portfolio = &Apache::loncommon::help_open_topic('Portfolio About', &mt('Help on the portfolio'));
1.247 ! raeburn 101: $r->print(&display_portfolio_usage($group,$help_portfolio));
1.195 raeburn 102: my $parse_check;
103: if (!&suppress_embed_prompt()) {
104: $parse_check = <<"END";
105: <br />
106: <span class="LC_nobreak">
1.216 bisitz 107: <label>
108: <input type="checkbox" name="parserflag" checked="checked" />
109: $lt{'parse'}
1.195 raeburn 110: </label>
111: </span>
112: END
113: }
1.199 bisitz 114:
115: # Upload File
116: $r->print('<div class="LC_left_float">'
117: .'<form method="post" enctype="multipart/form-data" action="'.$escuri.'">'
118: .'<fieldset>'
119: .'<legend>'.$lt{'upload_label'}.'</legend>'
120: .$groupitem
121: .'<input name="uploaddoc" type="file" />'
122: .'<input type="hidden" name="currentpath" value="'.$current_path.'" />'
123: .'<input type="hidden" name="action" value="'.$env{"form.action"}.'" />'
1.235 raeburn 124: .'<input type="hidden" name="symb" value="'.$env{"form.symb"}.'" />'
1.199 bisitz 125: .'<input type="hidden" name="fieldname" value="'.$env{"form.fieldname"}.'" />'
126: .'<input type="hidden" name="mode" value="'.$env{"form.mode"}.'" />'
127: .'<input type="submit" name="storeupl" value="'.$lt{'upload'}.'" />'
128: .$help_fileupload
129: .$parse_check
130: .'</fieldset>'
131: .'</form>'
132: .'</div>'
133: );
134: # Create Subdirectory
135: $r->print('<div class="LC_left_float">'
136: .'<form method="post" action="'.$escuri.'">'
137: .'<fieldset>'
138: .'<legend>'.$lt{'createdir_label'}.'</legend>'
1.204 raeburn 139: .'<input name="newdir" type="text" />'.$groupitem
1.199 bisitz 140: .'<input type="hidden" name="currentpath" value="'.$current_path.'" />'
141: .'<input type="hidden" name="action" value="'.$env{"form.action"}.'" />'
1.235 raeburn 142: .'<input type="hidden" name="symb" value="'.$env{"form.symb"}.'" />'
1.199 bisitz 143: .'<input type="hidden" name="fieldname" value="'.$env{"form.fieldname"}.'" />'
144: .'<input type="hidden" name="mode" value="'.$env{"form.mode"}.'" />'
145: .'<input type="submit" name="createdir" value="'.$lt{'createdir'}.'" />'
146: .$help_createdir
147: .'</fieldset>'
148: .'</form>'
149: .'</div>'
150: );
151: } # end "if can_upload"
152:
1.24 albertel 153: my @tree = split (/\//,$current_path);
1.150 banghart 154: my %anchor_fields = (
1.149 banghart 155: 'selectfile' => $port_path,
156: 'currentpath' => '/',
157: 'mode' => $env{"form.mode"},
1.235 raeburn 158: 'symb' => $env{"form.symb"},
1.149 banghart 159: 'fieldname' => $env{"form.fieldname"},
160: 'continue' => $env{"form.continue"}
161: );
1.215 bisitz 162: $r->print('<br clear="all" />');
1.149 banghart 163: $r->print('<span class="LC_current_location">'.&make_anchor($url,\%anchor_fields,$port_path).'/');
1.19 banghart 164: if (@tree > 1){
1.176 albertel 165: my $newCurrentPath = '/';
1.19 banghart 166: for (my $i = 1; $i< @tree; $i++){
167: $newCurrentPath .= $tree[$i].'/';
1.150 banghart 168: my %anchor_fields = (
1.149 banghart 169: 'selectfile' => $tree[$i],
1.176 albertel 170: 'currentpath' => $newCurrentPath,
1.149 banghart 171: 'mode' => $env{"form.mode"},
1.235 raeburn 172: 'symb' => $env{"form.symb"},
1.149 banghart 173: 'fieldname' => $env{"form.fieldname"},
174: 'continue' => $env{"form.continue"}
175: );
176: $r->print(&make_anchor($url,\%anchor_fields,$tree[$i]).'/');
1.19 banghart 177: }
178: }
1.117 albertel 179: $r->print('</span>');
1.168 albertel 180: $r->print(&Apache::loncommon::help_open_topic('Portfolio ChangeDirectory'));
1.94 raeburn 181: &Apache::lonhtmlcommon::store_recent($namespace,$current_path,$current_path);
1.235 raeburn 182: $r->print('<br /><form method="post" action="'.$url.'?mode='.$env{"form.mode"}.'&fieldname='.$env{"form.fieldname"}.'&symb='.$env{'form.symb'}.&group_args());
1.94 raeburn 183: $r->print('">'.
184: &Apache::lonhtmlcommon::select_recent($namespace,'currentpath',
1.22 albertel 185: 'this.form.submit();'));
1.21 banghart 186: $r->print("</form>");
1.48 banghart 187: }
1.137 albertel 188:
1.246 raeburn 189: sub display_portfolio_usage {
1.247 ! raeburn 190: my ($group,$helpitem) = @_;
1.206 raeburn 191: my $disk_quota = &get_quota($group);
192: my $getpropath = 1;
193: my $portfolio_root = &get_portfolio_root();
194: my ($uname,$udom) = &get_name_dom($group);
195: my $current_disk_usage =
196: &Apache::lonnet::diskusage($udom,$uname,$portfolio_root,$getpropath);
1.246 raeburn 197: return &Apache::loncommon::head_subbox(
1.247 ! raeburn 198: '<div style="float:right;padding-top:0;margin-top;0">'
! 199: .$helpitem
! 200: .'</div>'
! 201: .'<div>'
! 202: .&Apache::lonhtmlcommon::display_usage($current_disk_usage,$disk_quota)
! 203: .'</div>');
1.206 raeburn 204: }
205:
1.134 banghart 206: sub display_directory_line {
1.156 albertel 207: my ($r,$select_mode, $filename, $mtime, $size, $css_class,
1.137 albertel 208: $line, $access_controls, $curr_access, $now, $version_flag,
1.140 banghart 209: $href_location, $url, $current_path, $access_admin_text, $versions)=@_;
1.156 albertel 210:
211: my $fullpath = &prepend_group($current_path.$filename);
1.197 bisitz 212: $r->print(&Apache::loncommon::start_data_table_row());
1.153 banghart 213: $r->print($line); # contains first two cells of table
1.155 banghart 214: my $lock_info;
1.156 albertel 215: if ($version_flag) { # versioned can't be versioned, so TRUE when root file
1.213 droeschl 216: $r->print('<td><img alt="" src="'.&Apache::loncommon::icon($filename).'" class="LC_fileicon" /></td>');
1.156 albertel 217: $r->print('<td>'.$version_flag.'</td>');
1.153 banghart 218: } else { # this is a graded or handed back file
1.191 raeburn 219: my ($user,$domain) = &get_name_dom($env{'form.group'});
1.154 banghart 220: my $permissions_hash = &Apache::lonnet::get_portfile_permissions($domain,$user);
1.156 albertel 221: if (defined($$permissions_hash{$fullpath})) {
222: foreach my $array_item (@{$$permissions_hash{$fullpath}}) {
1.155 banghart 223: if (ref($array_item) eq 'ARRAY') {
1.156 albertel 224: if ($$array_item[-1] eq 'handback') {
1.155 banghart 225: $lock_info = 'Handback';
1.156 albertel 226: } elsif ($$array_item[-1] eq 'graded') {
1.155 banghart 227: $lock_info = 'Graded';
1.154 banghart 228: }
1.155 banghart 229: }
1.154 banghart 230: }
231: }
1.156 albertel 232: if ($lock_info) {
233: my %anchor_fields = ('lockinfo' => $fullpath);
1.161 banghart 234: if ($versions) { # hold the folder open
235: my ($fname,$version,$extension) = &Apache::grades::file_name_version_ext($fullpath);
236: $fname =~ s|^/||;
237: $anchor_fields{'showversions'} = $fname.'.'.$extension;
238: }
1.156 albertel 239: $lock_info = &make_anchor(undef,\%anchor_fields,$lock_info);
240: }
241: $r->print('<td colspan="2">'.$lock_info.'</td>');
1.153 banghart 242: }
243: # $r->print('<td>'.$$version_flag{$filename}.'</td><td>');
244: $r->print('<td>'.&make_anchor($href_location.$filename,undef,$filename).'</td>');
1.137 albertel 245: $r->print('<td>'.$size.'</td>');
246: $r->print('<td>'.&Apache::lonlocal::locallocaltime($mtime).'</td>');
247: if ($select_mode ne 'true') {
1.197 bisitz 248: $r->print('<td class="'.$css_class.'"> </td>'); # Display status
249: $r->print('<td><span class="LC_nobreak">'
250: .&mt($curr_access).' '
251: );
1.152 albertel 252: my %anchor_fields = (
1.150 banghart 253: 'access' => $filename,
254: 'currentpath' => $current_path
255: );
256: $r->print(&make_anchor($url, \%anchor_fields, $access_admin_text).'</span></td>');
1.197 bisitz 257: } else {
258: $r->print('<td class="'.$css_class.'"> </td>'); # Display status
1.137 albertel 259: }
1.197 bisitz 260: $r->print(&Apache::loncommon::end_data_table_row().$/);
1.134 banghart 261: }
1.137 albertel 262:
1.48 banghart 263: sub display_directory {
1.138 albertel 264: my ($r,$url,$current_path,$is_empty,$dir_list,$group,$can_upload,
1.137 albertel 265: $can_modify,$can_delete,$can_setacl)=@_;
1.48 banghart 266: my $iconpath= $r->dir_config('lonIconsURL') . "/";
1.77 banghart 267: my $select_mode;
268: my $checked_files;
1.138 albertel 269: my $port_path = &get_port_path();
1.191 raeburn 270: my ($uname,$udom) = &get_name_dom($group);
1.120 raeburn 271: my $access_admin_text = &mt('View Status');
272: if ($can_setacl) {
273: $access_admin_text = &mt('View/Change Status');
274: }
275:
1.102 raeburn 276: my $current_permissions = &Apache::lonnet::get_portfile_permissions($udom,
277: $uname);
278: my %locked_files = &Apache::lonnet::get_marked_as_readonly_hash(
279: $current_permissions,$group);
280: my %access_controls = &Apache::lonnet::get_access_controls($current_permissions,$group);
281: my $now = time;
1.170 raeburn 282: if ($env{"form.mode"} eq 'selectfile') {
1.229 raeburn 283: &select_files($r,$dir_list);
1.223 bisitz 284: $checked_files =&Apache::lonnet::files_in_path($uname,$env{'form.currentpath'});
285: $select_mode = 'true';
1.31 albertel 286: }
1.77 banghart 287: if ($select_mode eq 'true') {
1.113 albertel 288: $r->print('<form method="post" name="checkselect" action="'.$url.'">');
1.197 bisitz 289: $r->print(&Apache::loncommon::start_data_table()
290: .&Apache::loncommon::start_data_table_header_row()
291: .'<th>'.&mt('Select').'</th>'
1.223 bisitz 292: .'<th> </th>'
293: .'<th> </th>'
1.197 bisitz 294: .'<th>'.&mt('Name').'</th>'
295: .'<th>'.&mt('Size').'</th>'
296: .'<th>'.&mt('Last Modified').'</th>'
297: .'<th> </th>'
298: .&Apache::loncommon::end_data_table_header_row()
299: );
1.77 banghart 300: } else {
1.113 albertel 301: $r->print('<form method="post" action="'.$url.'">');
1.223 bisitz 302: $r->print(
303: '<p>'
304: .&Apache::loncommon::help_open_topic(
305: 'Portfolio FileList',
306: &mt('Using the portfolio file list'))
307: .'</p>'
308: );
1.197 bisitz 309: $r->print(&Apache::loncommon::start_data_table()
310: .&Apache::loncommon::start_data_table_header_row()
1.187 bisitz 311: .'<th colspan="2">'.&mt('Actions'). &Apache::loncommon::help_open_topic('Portfolio FileAction').'</th>'
1.223 bisitz 312: .'<th> </th>'
313: .'<th> </th>'
1.187 bisitz 314: .'<th>'.&mt('Name').&Apache::loncommon::help_open_topic('Portfolio OpenFile').'</th>'
315: .'<th>'.&mt('Size').'</th>'
316: .'<th>'.&mt('Last Modified').'</th>'
1.197 bisitz 317: .'<th> </th>'
1.187 bisitz 318: .'<th>'.&mt('Current Access Status').&Apache::loncommon::help_open_topic('Portfolio ShareFile').'</th>'
1.197 bisitz 319: .&Apache::loncommon::end_data_table_header_row());
1.94 raeburn 320: }
1.223 bisitz 321:
322: # Empty directory?
323: if ($is_empty && ($current_path ne '/') && $can_delete) {
324: my $cols = ($select_mode eq 'true') ? 7 : 9;
325: # Empty message
326: $r->print(
327: &Apache::loncommon::start_data_table_row()
328: .'<td colspan="'.$cols.'">'
329: .'<p class="LC_info">'
330: .&mt('This directory is empty.')
331: .'</p>'
332: .'</td>'
333: .&Apache::loncommon::end_data_table_row()
334: .&Apache::loncommon::end_data_table()
335: .'</form>'
336: );
337: # Delete button
338: $r->print(
339: '<form method="post" action="'.$url.'">'.
340: &group_form_data().
341: '<input type="hidden" name="action" value="deletedir" />'.
342: '<p>'.
343: '<input type="submit" name="deletedir" value="'.&mt("Delete Directory").'" />'.
344: '</p>'.
345: '<input type="hidden" name="selectfile" value="" />'.
346: '<input type="hidden" name="currentpath" value="'.$current_path.'" />'.
347: '</form>'
348: );
349: # Directory is empty, so nothing else to display
350: return;
351: }
352:
1.137 albertel 353: $r->print("\n".&group_form_data()."\n");
354:
1.94 raeburn 355: my $href_location="/uploaded/$udom/$uname/$port_path".$current_path;
356: my $href_edit_location="/editupload/$udom/$uname/$port_path".$current_path;
1.105 banghart 357: my @dir_lines;
358: my %versioned;
1.233 raeburn 359: if (ref($dir_list) eq 'ARRAY') {
360: foreach my $dir_line (sort
361: {
362: my ($afile)=split('&',$a,2);
363: my ($bfile)=split('&',$b,2);
364: return (lc($afile) cmp lc($bfile));
365: } (@{$dir_list})) {
366: my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$dir_line,16);
367: $filename =~ s/\s+$//;
368: my ($fname,$version,$extension) = &Apache::grades::file_name_version_ext($filename);
369: if ($version) {
370: my $fullpath = &prepend_group($current_path.$fname.'.'.$extension);
371: push(@{ $versioned{$fullpath} },
372: [$filename,$dom,$testdir,$size,$mtime,$obs,]);
373: } else {
374: push(@dir_lines, [$filename,$dom,$testdir,$size,$mtime,$obs]);
375: }
376: }
1.105 banghart 377: }
1.229 raeburn 378: my $zerobyte;
1.140 banghart 379: foreach my $dir_line (@dir_lines) {
380: my ($filename,$dom,$testdir,$size,$mtime,$obs) = @$dir_line;
1.105 banghart 381: my ($fname,$version,$extension) = &Apache::grades::file_name_version_ext($filename);
1.93 albertel 382: if (($filename ne '.') && ($filename ne '..') && ($filename !~ /\.meta$/ ) && ($filename !~ /(.*)\.(\d+)\.([^\.]*)$/)) {
1.156 albertel 383: my $version_flag;
1.131 banghart 384: my $show_versions;
1.156 albertel 385: my $fullpath = &prepend_group($current_path.$filename);
1.162 banghart 386: if ($env{'form.showversions'} =~ /$filename/) {
1.131 banghart 387: $show_versions = 'true';
388: }
1.156 albertel 389: if (exists($versioned{$fullpath})) {
1.152 albertel 390: my %anchor_fields = (
1.156 albertel 391: 'selectfile' => $fullpath,
1.150 banghart 392: 'continue' => 'false',
393: 'currentpath' => $current_path,
394: );
1.134 banghart 395: if ($show_versions) {
1.162 banghart 396: # Must preserve other possible showversion files
397: my $version_remainder = $env{'form.showversions'};
398: $version_remainder =~ s/$filename//g;
399: $anchor_fields{'showversions'} = $version_remainder;
1.156 albertel 400: $version_flag = &make_anchor('portfolio',\%anchor_fields,
1.150 banghart 401: '<img class="LC_icon" alt="'.&mt('opened folder').'" src="'.$iconpath.'folder_pointer_opened.gif" />');
1.134 banghart 402: } else {
1.162 banghart 403: # allow multiple files to show versioned
404: $anchor_fields{'showversions'} = $env{'form.showversions'}.','.$filename;
1.156 albertel 405: $version_flag = &make_anchor('portfolio',\%anchor_fields,
1.150 banghart 406: '<img class="LC_icon" alt="'.&mt('closed folder').'" src="'.$iconpath.'folder_pointer_closed.gif" />');
1.134 banghart 407: }
1.129 banghart 408: } else {
1.156 albertel 409: $version_flag = ' ';
1.129 banghart 410: }
1.23 albertel 411: if ($dirptr&$testdir) {
1.197 bisitz 412: my $colspan_folder='';
413: my $colspan_fill='';
1.77 banghart 414: if ($select_mode eq 'true'){
1.197 bisitz 415: $colspan_fill=' colspan="3"';
416: } else {
417: $colspan_folder=' colspan="2"';
418: $colspan_fill=' colspan="4"';
1.64 banghart 419: }
1.197 bisitz 420: $r->print('<tr class="LC_browser_folder">');
1.213 droeschl 421: $r->print('<td'.$colspan_folder.'><img alt="'.&mt('closed folder').'" src="'.$iconpath.'navmap.folder.closed.gif" class="LC_fileicon" /></td>'
1.197 bisitz 422: .'<td>'.&mt('Go to ...').'</td>');
1.152 albertel 423: my %anchor_fields = (
1.149 banghart 424: 'selectfile' => $filename.'/',
425: 'currentpath' => $current_path.$filename.'/',
426: 'mode' => $env{"form.mode"},
1.235 raeburn 427: 'symb' => $env{"form.symb"},
1.149 banghart 428: 'fieldname' => $env{"form.fieldname"},
429: 'continue' => $env{"form.continue"}
430: );
1.197 bisitz 431: $r->print('<td>'.$version_flag.'</td>'
432: .'<td>'.&make_anchor($url,\%anchor_fields,$filename.'/').'</td>');
433: $r->print('<td'.$colspan_fill.'> </td>');
1.47 banghart 434: $r->print('</tr>');
435: } else {
1.116 albertel 436: my $css_class = 'LC_browser_file';
437: my $line;
1.124 albertel 438: if ($select_mode eq 'true') {
1.229 raeburn 439: if ($size > 0) {
440: $line='<td><input type="checkbox" name="checkfile" value="'.$filename.'"';
441: if ($$checked_files{$filename} eq 'selected') {
442: $line.=' checked="checked" ';
443: }
444: $line.=' /></td>';
445: } else {
446: $line = '<td> </td>';
447: $zerobyte ++;
1.77 banghart 448: }
449: } else {
1.103 raeburn 450: if (exists $locked_files{$fullpath}) {
1.152 albertel 451: my %anchor_fields = (
1.156 albertel 452: 'lockinfo' => $fullpath
1.150 banghart 453: );
1.188 bisitz 454: $line.='<td colspan="2">'.&make_anchor($url,\%anchor_fields,&mt('Locked')).'</td>';
1.116 albertel 455: $css_class= 'LC_browser_file_locked';
1.77 banghart 456: } else {
1.120 raeburn 457: if (!$can_modify) {
458: $line .= '<td colspan="2">';
459: } else {
460: $line .= '<td>';
461: }
462: if ($can_delete) {
463: $line .= '<input type="checkbox" name="selectfile" value="'.$filename.'" />';
464: }
465: if ($can_modify) {
1.219 raeburn 466: my $cat='<img class="LC_icon" alt="'.&mt('Metadata').'" title="'.&mt('Metadata').'" src="'.&Apache::loncommon::lonhttpdurl('/res/adm/pages/catalog.png').'" />';
1.152 albertel 467: my %anchor_fields = (
1.150 banghart 468: 'rename' => $filename,
469: currentpath => $current_path
470: );
1.188 bisitz 471: $line .= &make_anchor($url,\%anchor_fields,&mt('Rename'));
1.159 banghart 472: $line .= '</td><td>'.&make_anchor($href_edit_location.$filename.'.meta',\%anchor_fields,$cat);
1.150 banghart 473: # '<a href="'.$href_edit_location.$filename.'.meta">'.$cat.'</a>';
1.120 raeburn 474: }
475: $line .= '</td>';
1.77 banghart 476: }
1.61 banghart 477: }
1.124 albertel 478: my $curr_access;
479: if ($select_mode ne 'true') {
480: my $pub_access = 0;
481: my $guest_access = 0;
482: my $cond_access = 0;
483: foreach my $key (sort(keys(%{$access_controls{$fullpath}}))) {
484: my ($num,$scope,$end,$start) = &unpack_acc_key($key);
485: if (($now > $start) && (!$end || $end > $now)) {
486: if ($scope eq 'public') {
487: $pub_access = 1;
488: } elsif ($scope eq 'guest') {
489: $guest_access = 1;
490: } else {
491: $cond_access = 1;
492: }
493: }
494: }
495: if (!$pub_access && !$guest_access && !$cond_access) {
496: $curr_access = &mt('Private');
497: } else {
498: my @allaccesses;
499: if ($pub_access) {
500: push(@allaccesses,&mt('Public'));
501: }
502: if ($guest_access) {
503: push(@allaccesses,&mt('Passphrase-protected'));
504: }
505: if ($cond_access) {
506: push(@allaccesses,&mt('Conditional'));
507: }
508: $curr_access = join('+ ',@allaccesses);
509: }
510: }
1.156 albertel 511: &display_directory_line($r,$select_mode, $filename, $mtime, $size, $css_class, $line,
512: \%access_controls, $curr_access,$now, $version_flag, $href_location,
1.140 banghart 513: $url, $current_path, $access_admin_text);
1.134 banghart 514: if ($show_versions) {
1.156 albertel 515: foreach my $dir_line (@{ $versioned{$fullpath} }) {
516: my ($v_filename,$dom,$testdir,$size,$mtime,$obs) =
517: @$dir_line;
1.143 banghart 518: $line = '<td colspan="2"> </td>';
1.156 albertel 519: &display_directory_line($r,$select_mode, $v_filename, $mtime, $size,
520: $css_class, $line, \%access_controls, $curr_access, $now,
521: undef, $href_location, $url, $current_path, $access_admin_text, 1);
1.140 banghart 522: }
1.134 banghart 523: }
1.47 banghart 524: }
525: }
526: }
1.77 banghart 527: if ($select_mode eq 'true') {
1.229 raeburn 528: $r->print(&Apache::loncommon::end_data_table());
529: if ($zerobyte) {
530: $r->print('<p class="LC_warning">'.&mt('[quant,_1,file] in list not selectable as file size is 0 bytes.',$zerobyte).'</p>');
531: }
532: $r->print('
1.127 albertel 533: <input type="hidden" name="continue" value="true" />
534: <input type="hidden" name="fieldname" value="'.$env{'form.fieldname'}.'" />
1.235 raeburn 535: <input type="hidden" name="symb" value="'.$env{'form.symb'}.'" />
1.127 albertel 536: <input type="hidden" name="mode" value="selectfile" />
1.198 bisitz 537: <p>
538: <input type="submit" name="submit" value="'.&mt('Select checked files, and continue selecting').'" /><br />
1.214 bisitz 539: <input type="button" name="doit" onClick="finishSelect();" value="'.&mt('Select checked files, and close window').'" />
1.198 bisitz 540: </p>
1.48 banghart 541: <input type="hidden" name="currentpath" value="'.$current_path.'" />
1.77 banghart 542: </form>');
543: } else {
1.197 bisitz 544: $r->print(&Apache::loncommon::end_data_table());
1.120 raeburn 545: if ($can_delete) {
546: $r->print('
1.199 bisitz 547: <p>
1.196 schafran 548: <input type="submit" name="doit" value="'.&mt('Delete Selected').'" />'.
1.168 albertel 549: &Apache::loncommon::help_open_topic('Portfolio DeleteFile').'
1.199 bisitz 550: </p>
1.77 banghart 551: <input type="hidden" name="action" value="delete" />
552: <input type="hidden" name="currentpath" value="'.$current_path.'" />
1.120 raeburn 553: </form>'
554: );
555: }
1.77 banghart 556: }
1.47 banghart 557: }
1.72 banghart 558:
1.24 albertel 559: sub open_form {
1.94 raeburn 560: my ($r,$url)=@_;
1.65 banghart 561: my @files=&Apache::loncommon::get_env_multiple('form.selectfile');
1.102 raeburn 562: $r->print('<form name="portform" method="post" action="'.$url.'">');
1.24 albertel 563: $r->print('<input type="hidden" name="action" value="'.
1.82 albertel 564: $env{'form.action'}.'" />');
1.24 albertel 565: $r->print('<input type="hidden" name="confirmed" value="1" />');
1.65 banghart 566: foreach (@files) {
567: $r->print('<input type="hidden" name="selectfile" value="'.
568: $_.'" />');
569: }
1.24 albertel 570: $r->print('<input type="hidden" name="currentpath" value="'.
1.82 albertel 571: $env{'form.currentpath'}.'" />');
1.24 albertel 572: }
573:
574: sub close_form {
1.137 albertel 575: my ($r,$url,$button_text)=@_;
1.108 raeburn 576: if (!defined($button_text)) {
577: $button_text = {
578: 'continue' => &mt('Continue'),
579: 'cancel' => &mt('Cancel'),
580: };
581: }
1.138 albertel 582: $r->print('<p><input type="submit" value="'.$button_text->{'continue'}.'" />');
1.137 albertel 583: $r->print(&group_form_data().'</p></form>');
1.112 albertel 584: $r->print('<form action="'.$url.'" method="post">
1.24 albertel 585: <p>
586: <input type="hidden" name="currentpath" value="'.
1.137 albertel 587: $env{'form.currentpath'}.'" />'.
588: &group_form_data());
1.108 raeburn 589: $r->print("\n".' <input type="submit" value="'.$button_text->{'cancel'}.'" />
1.94 raeburn 590: </p></form>');
1.24 albertel 591: }
592:
593: sub display_file {
1.27 albertel 594: my ($path,$filename)=@_;
1.65 banghart 595: my $display_file_text;
1.116 albertel 596: my $file_start='<span class="LC_filename">';
597: my $file_end='</span>';
1.82 albertel 598: if (!defined($path)) { $path=$env{'form.currentpath'}; }
1.65 banghart 599: if (!defined($filename)) {
1.82 albertel 600: $filename=$env{'form.selectfile'};
1.116 albertel 601: $display_file_text = $file_start.$path.$filename.$file_end;
1.65 banghart 602: } elsif (ref($filename) eq "ARRAY") {
1.116 albertel 603: foreach my $file (@$filename) {
604: $display_file_text .= $file_start.$path.$file.$file_end.'<br />';
1.65 banghart 605: }
606: } elsif (ref($filename) eq "SCALAR") {
1.116 albertel 607: $display_file_text = $file_start.$path.$$filename.$file_end;
608: } else {
609: $display_file_text = $file_start.$path.$filename.$file_end;
1.65 banghart 610: }
611: return $display_file_text;
1.24 albertel 612: }
613:
614: sub done {
1.241 bisitz 615: my ($linktext,$url)=@_;
1.243 raeburn 616: unless (defined($linktext)) {
1.241 bisitz 617: $linktext='Return to directory';
1.76 banghart 618: }
1.153 banghart 619: my %anchor_fields = (
1.161 banghart 620: 'showversions' => $env{'form.showversions'},
1.153 banghart 621: 'currentpath' => $env{'form.currentpath'},
622: 'fieldname' => $env{'form.fieldname'},
1.235 raeburn 623: 'symb' => $env{'form.symb'},
1.153 banghart 624: 'mode' => $env{'form.mode'}
625: );
1.241 bisitz 626: my $result = &Apache::lonhtmlcommon::actionbox(
627: [&make_anchor($url,\%anchor_fields,&mt($linktext))]);
1.94 raeburn 628: return $result;
1.24 albertel 629: }
630:
631: sub delete {
1.191 raeburn 632: my ($r,$url,$group)=@_;
1.55 banghart 633: my @check;
1.82 albertel 634: my $file_name = $env{'form.currentpath'}.$env{'form.selectfile'};
1.138 albertel 635: $file_name = &prepend_group($file_name);
1.65 banghart 636: my @files=&Apache::loncommon::get_env_multiple('form.selectfile');
1.191 raeburn 637: my ($uname,$udom) = &get_name_dom($group);
1.94 raeburn 638: if (&Apache::lonnet::is_locked($file_name,$udom,$uname) eq 'true') {
1.241 bisitz 639: $r->print(
640: '<p class="LC_warning">'
641: .&mt('The file is locked and cannot be deleted.')
642: .'</p>'
643: .&done(undef,$url)
644: );
1.55 banghart 645: } else {
1.66 banghart 646: if (scalar(@files)) {
1.94 raeburn 647: &open_form($r,$url);
1.188 bisitz 648: $r->print('<p>'.&mt('Delete [_1]?',&display_file(undef,\@files)).'</p>');
1.137 albertel 649: &close_form($r,$url);
1.66 banghart 650: } else {
1.237 bisitz 651: $r->print('<p class="LC_warning">'.&mt('No file was checked to delete.').'</p>');
1.137 albertel 652: $r->print(&done(undef,$url));
1.66 banghart 653: }
1.55 banghart 654: }
1.24 albertel 655: }
656:
657: sub delete_confirmed {
1.164 raeburn 658: my ($r,$url,$group)=@_;
1.65 banghart 659: my @files=&Apache::loncommon::get_env_multiple('form.selectfile');
660: my $result;
1.191 raeburn 661: my ($uname,$udom) = &get_name_dom($group);
1.138 albertel 662: my $port_path = &get_port_path();
1.164 raeburn 663: my $current_permissions = &Apache::lonnet::get_portfile_permissions($udom,
664: $uname);
1.241 bisitz 665: my @msg;
1.65 banghart 666: foreach my $delete_file (@files) {
1.241 bisitz 667: $result =
668: &Apache::lonnet::removeuserfile(
669: $uname,$udom,$port_path.
670: $env{'form.currentpath'}.
671: $delete_file);
1.65 banghart 672: if ($result ne 'ok') {
1.241 bisitz 673: push(@msg, &Apache::lonhtmlcommon::confirm_success(
674: &mt('An error occurred ([_1]) while trying to delete [_2].'
675: ,$result,&display_file(undef, $delete_file)),1));
676: } else {
677: push(@msg, &Apache::lonhtmlcommon::confirm_success(
678: &mt('File: [_1] deleted.'
679: ,&display_file(undef,$delete_file))));
1.164 raeburn 680: my $file_name = $env{'form.currentpath'}.$delete_file;
681: $file_name = &prepend_group($file_name);
682: my %access_controls =
683: &Apache::lonnet::get_access_controls($current_permissions,
684: $group,$file_name);
685: if (keys(%access_controls) > 0) {
686: my %changes;
1.166 raeburn 687: foreach my $key (keys(%{$access_controls{$file_name}})) {
1.164 raeburn 688: $changes{'delete'}{$key} = 1;
689: }
690: if (keys(%changes) > 0) {
691: my ($outcome,$deloutcome,$new_values,$translation) =
692: &Apache::lonnet::modify_access_controls($file_name,\%changes,
693: $udom,$uname);
694: if ($outcome ne 'ok') {
1.241 bisitz 695: push(@msg, &Apache::lonhtmlcommon::confirm_success(
696: &mt('An error occurred ([_1]) while '.
697: 'trying to delete access controls for the file.',$outcome),1));
1.164 raeburn 698: } else {
699: if ($deloutcome eq 'ok') {
1.241 bisitz 700: push(@msg, &mt('Access controls also deleted for the file.')); # FIXME: Does the user really need this message?
1.164 raeburn 701: } else {
1.241 bisitz 702: push(@msg, &Apache::lonhtmlcommon::confirm_success(
703: &mt('An error occurred ([_1]) while '.
704: 'trying to delete access controls for the file.'
705: ,$deloutcome),1));
1.164 raeburn 706: }
707: }
708: }
709: }
1.65 banghart 710: }
1.24 albertel 711: }
1.241 bisitz 712: $r->print(&Apache::loncommon::confirmwrapper(join('<br />',@msg)));
1.137 albertel 713: $r->print(&done(undef,$url));
1.24 albertel 714: }
715:
1.30 banghart 716: sub delete_dir {
1.137 albertel 717: my ($r,$url)=@_;
1.94 raeburn 718: &open_form($r,$url);
1.188 bisitz 719: $r->print('<p>'.&mt('Delete [_1]?',&display_file()).'</p>');
1.137 albertel 720: &close_form($r,$url);
1.30 banghart 721: }
722:
723: sub delete_dir_confirmed {
1.191 raeburn 724: my ($r,$url,$group)=@_;
1.82 albertel 725: my $directory_name = $env{'form.currentpath'};
1.81 albertel 726: $directory_name =~ s|/$||; # remove any trailing slash
1.191 raeburn 727: my ($uname,$udom) = &get_name_dom($group);
1.138 albertel 728: my $namespace = &get_namespace();
729: my $port_path = &get_port_path();
1.94 raeburn 730: my $result=&Apache::lonnet::removeuserfile($uname,$udom,$port_path.
1.30 banghart 731: $directory_name);
1.241 bisitz 732:
1.30 banghart 733: if ($result ne 'ok') {
1.241 bisitz 734: $r->print(
735: &Apache::loncommon::confirmwrapper(
736: &Apache::lonhtmlcommon::confirm_success(
737: &mt('An error occurred (dir) ([_1]) while trying to delete [_2].'
738: ,$result,$directory_name),1)));
739: $r->print(&done(undef,$url));
740: return;
1.32 banghart 741: } else {
1.41 banghart 742: # now remove from recent
1.94 raeburn 743: &Apache::lonhtmlcommon::remove_recent($namespace,[$directory_name.'/']);
1.32 banghart 744: my @dirs = split m!/!, $directory_name;
745: $directory_name='/';
746: for (my $i=1; $i < (@dirs - 1); $i ++){
747: $directory_name .= $dirs[$i].'/';
748: }
1.82 albertel 749: $env{'form.currentpath'} = $directory_name;
1.30 banghart 750: }
1.241 bisitz 751: $r->print(
752: &Apache::loncommon::confirmwrapper(
753: &Apache::lonhtmlcommon::confirm_success(
754: &mt('Directory successfully deleted'))));
1.137 albertel 755: $r->print(&done(undef,$url));
1.30 banghart 756: }
757:
1.24 albertel 758: sub rename {
1.191 raeburn 759: my ($r,$url,$group)=@_;
1.82 albertel 760: my $file_name = $env{'form.currentpath'}.$env{'form.rename'};
1.191 raeburn 761: my ($uname,$udom) = &get_name_dom($group);
1.138 albertel 762: $file_name = &prepend_group($file_name);
1.94 raeburn 763: if (&Apache::lonnet::is_locked($file_name,$udom,$uname) eq 'true') {
1.241 bisitz 764: $r->print(
765: '<p class="LC_error">'
766: .&mt('The file is locked and cannot be renamed.')
767: .'</p>'
768: );
1.137 albertel 769: $r->print(&done(undef,$url));
1.55 banghart 770: } else {
1.94 raeburn 771: &open_form($r,$url);
1.188 bisitz 772: $r->print('<p>'.&mt('Rename [_1] to [_2]?', &display_file()
1.204 raeburn 773: , '<input name="filenewname" type="text" size="50" />').'</p>');
1.137 albertel 774: &close_form($r,$url);
1.55 banghart 775: }
1.24 albertel 776: }
777:
778: sub rename_confirmed {
1.164 raeburn 779: my ($r,$url,$group)=@_;
1.82 albertel 780: my $filenewname=&Apache::lonnet::clean_filename($env{'form.filenewname'});
1.191 raeburn 781: my ($uname,$udom) = &get_name_dom($group);
1.138 albertel 782: my $port_path = &get_port_path();
1.241 bisitz 783:
784: # Display warning in case of filename cleaning has changed the filename
785: if ($filenewname ne $env{'form.filenewname'}) {
786: $r->print(
787: '<p><span class="LC_warning">'
788: .&mt('Invalid characters')
789: .'</span><br />'
790: .&mt('The new filename was changed from [_1] to [_2].'
791: ,'<span class="LC_filename">'.&display_file('',$env{'form.filenewname'}).'</span>'
792: ,'<span class="LC_filename">'.&display_file('',$filenewname).'</span>')
793: .'</p>'
794: );
795:
796: }
797:
798: # Filename empty?
1.27 albertel 799: if ($filenewname eq '') {
1.241 bisitz 800: $r->print(
801: &Apache::loncommon::confirmwrapper(
802: &Apache::lonhtmlcommon::confirm_success(
803: &mt('Error: no valid filename was provided to rename to.'),1)));
804: $r->print(&done(undef,$url));
805: return;
1.27 albertel 806: }
1.241 bisitz 807:
808: # Rename the file
1.164 raeburn 809: my $chg_access;
1.27 albertel 810: my $result=
1.94 raeburn 811: &Apache::lonnet::renameuserfile($uname,$udom,
812: $port_path.$env{'form.currentpath'}.$env{'form.selectfile'},
813: $port_path.$env{'form.currentpath'}.$filenewname);
1.164 raeburn 814: if ($result eq 'ok') {
815: $chg_access = &access_for_renamed($filenewname,$group,$udom,$uname);
816: } else {
1.241 bisitz 817: $r->print(
818: &Apache::loncommon::confirmwrapper(
819: &Apache::lonhtmlcommon::confirm_success(
820: &mt('An error occurred ([_1]) while trying to rename [_2] to [_3].'
821: ,$result,&display_file(),&display_file('',$filenewname))
822: ,1)));
823: $r->print(&done(undef,$url));
1.164 raeburn 824: return;
1.27 albertel 825: }
1.164 raeburn 826: $r->print($chg_access);
1.241 bisitz 827: $r->print(
828: &Apache::loncommon::confirmwrapper(
829: &Apache::lonhtmlcommon::confirm_success(
830: &mt('File successfully renamed'))));
1.137 albertel 831: $r->print(&done(undef,$url));
1.27 albertel 832: }
1.102 raeburn 833:
1.164 raeburn 834: sub access_for_renamed {
835: my ($filenewname,$group,$udom,$uname) = @_;
836: my $oldfile = $env{'form.currentpath'}.$env{'form.selectfile'};
837: $oldfile = &prepend_group($oldfile);
838: my $newfile = $env{'form.currentpath'}.$filenewname;
839: $newfile = &prepend_group($newfile);
840: my $current_permissions =
1.165 albertel 841: &Apache::lonnet::get_portfile_permissions($udom,$uname);
1.164 raeburn 842: my %access_controls =
1.165 albertel 843: &Apache::lonnet::get_access_controls($current_permissions,
844: $group,$oldfile);
1.164 raeburn 845: my $chg_text;
846: if (keys(%access_controls) > 0) {
847: my %change_old;
848: my %change_new;
1.165 albertel 849: foreach my $key (keys(%{$access_controls{$oldfile}})) {
1.164 raeburn 850: $change_old{'delete'}{$key} = 1;
851: $change_new{'activate'}{$key} = $access_controls{$oldfile}{$key};
852: }
853: my ($outcome,$deloutcome,$new_values,$translation) =
854: &Apache::lonnet::modify_access_controls($oldfile,\%change_old,
1.165 albertel 855: $udom,$uname);
1.164 raeburn 856: if ($outcome ne 'ok') {
1.182 albertel 857: $chg_text ='<br /><br />'.&mt("An error occurred ([_1]) while ".
1.165 albertel 858: "trying to delete access control records for the old name.",$outcome).
1.164 raeburn 859: '</span><br />';
860: } else {
861: if ($deloutcome ne 'ok') {
1.165 albertel 862: $chg_text = '<br /><br /><span class="LC_error"><br />'.
1.182 albertel 863: &mt("An error occurred ([_1]) while ".
1.165 albertel 864: "trying to delete access control records for the old name.",$deloutcome).
865: '</span><br />';
1.164 raeburn 866: }
867: }
868: ($outcome,$deloutcome,$new_values,$translation) =
869: &Apache::lonnet::modify_access_controls($newfile,\%change_new,
870: $udom,$uname);
871: if ($outcome ne 'ok') {
1.165 albertel 872: $chg_text .= '<br /><br />'.
1.182 albertel 873: &mt("An error occurred ([_1]) while ".
1.165 albertel 874: "trying to update access control records for the new name.",$outcome).
1.164 raeburn 875: '</span><br />';
876: }
877: if ($chg_text eq '') {
878: $chg_text = '<br /><br />'.&mt('Access controls updated to reflect the name change.');
879: }
880: }
881: return $chg_text;
882: }
883:
1.104 raeburn 884: sub display_access {
1.170 raeburn 885: my ($r,$url,$group,$can_setacl,$port_path,$action) = @_;
1.191 raeburn 886: my ($uname,$udom) = &get_name_dom($group);
1.104 raeburn 887: my $file_name = $env{'form.currentpath'}.$env{'form.access'};
1.138 albertel 888: $file_name = &prepend_group($file_name);
1.104 raeburn 889: my $current_permissions = &Apache::lonnet::get_portfile_permissions($udom,
890: $uname);
891: my %access_controls = &Apache::lonnet::get_access_controls($current_permissions,$group,$file_name);
1.120 raeburn 892: my $aclcount = keys(%access_controls);
1.170 raeburn 893: my ($header,$info);
894: if ($action eq 'chgaccess') {
1.241 bisitz 895: $header =
896: '<h2>'
897: .&mt('Allowing others to retrieve file: [_1]'
898: ,'<span class="LC_filename">'
899: .$port_path.$env{'form.currentpath'}.$env{'form.access'}
900: .'</span>')
901: .'</h2>';
1.170 raeburn 902: $info .= &mt('Access to this file by others can be set to be one or more of the following types: public, passphrase-protected or conditional.');
903: $info .= '<br /><ul><li>'.&mt('Public files are available to anyone without the need for login.');
904: $info .= '</li><li>'.&mt('Passphrase-protected files do not require log-in, but will require the viewer to enter the passphrase you set.');
905: $info .= '</li><li>'.&explain_conditionals();
1.174 raeburn 906: $info .= '</li></ul>'.
1.201 raeburn 907: &mt('A listing of files viewable without log-in is available at: ')."<a href=\"/adm/$udom/$uname/aboutme/portfolio\">".&Apache::lonnet::absolute_url($ENV{'SERVER_NAME'})."/adm/$udom/$uname/aboutme/portfolio</a>.<br />";
1.170 raeburn 908: if ($group eq '') {
1.210 weissno 909: $info .= &mt("For logged in users a 'Display file listing' link will also appear (when there are viewable files) on your personal information page:");
1.174 raeburn 910: } else {
911: $info .= &mt("For logged in users a 'Display file listing' link will also appear (when there are viewable files) on the course information page:");
912: }
1.201 raeburn 913: $info .= "<br /><a href=\"/adm/$udom/$uname/aboutme\">".&Apache::lonnet::absolute_url($ENV{'SERVER_NAME'})."/adm/$udom/$uname/aboutme</a><br />";
1.174 raeburn 914: if ($group ne '') {
915: $info .= &mt("Users with privileges to edit course contents may add a course information page to a course using the 'Course Info' button in DOCS").'<br />';
1.170 raeburn 916: }
917: } else {
918: $header = '<h3>'.&mt('Conditional access controls for file: [_1]',$port_path.$env{'form.currentpath'}.$env{'form.access'}).'</h3>'.
919: &explain_conditionals().'<br />';
1.142 raeburn 920: }
1.120 raeburn 921: if ($can_setacl) {
922: &open_form($r,$url);
923: $r->print($header.$info);
1.187 bisitz 924: $r->print('<br />'.&Apache::loncommon::help_open_topic('Portfolio ShareFile SetAccess', &mt('Help on setting up share access')));
925: $r->print(&Apache::loncommon::help_open_topic('Portfolio ShareFile ChangeSetting', &mt('Help on changing settings')));
926: $r->print(&Apache::loncommon::help_open_topic('Portfolio ShareFile StopAccess', &mt('Help on removing share access')));
1.170 raeburn 927: &access_setting_table($r,$url,$file_name,$access_controls{$file_name},
928: $action);
1.120 raeburn 929: my $button_text = {
1.108 raeburn 930: 'continue' => &mt('Proceed'),
1.188 bisitz 931: 'cancel' => &mt('Return to directory'),
1.108 raeburn 932: };
1.137 albertel 933: &close_form($r,$url,$button_text);
1.120 raeburn 934: } else {
935: $r->print($header);
936: if ($aclcount) {
937: $r->print($info);
938: }
1.137 albertel 939: &view_access_settings($r,$url,$access_controls{$file_name},$aclcount);
1.120 raeburn 940: }
941: }
942:
1.170 raeburn 943: sub explain_conditionals {
944: return
945: &mt('Conditional files are accessible to logged-in users with accounts in the LON-CAPA network, who satisfy the conditions you set.').'<br />'."\n".
1.221 raeburn 946: &mt('The conditions can include affiliation with a particular course or community, or a user account in a specific domain.').'<br />'."\n".
1.170 raeburn 947: &mt('Alternatively access can be granted to people with specific LON-CAPA usernames and domains.');
948: }
949:
1.120 raeburn 950: sub view_access_settings {
1.137 albertel 951: my ($r,$url,$access_controls,$aclcount) = @_;
1.120 raeburn 952: my ($showstart,$showend);
953: my %todisplay;
954: foreach my $key (sort(keys(%{$access_controls}))) {
955: my ($num,$scope,$end,$start) = &unpack_acc_key($key);
956: $todisplay{$scope}{$key} = $$access_controls{$key};
957: }
958: if ($aclcount) {
1.188 bisitz 959: $r->print('<h4>'.&mt('Current access controls defined for this file:').'</h4>');
1.120 raeburn 960: $r->print(&Apache::loncommon::start_data_table());
961: $r->print(&Apache::loncommon::start_data_table_header_row());
962: $r->print('<th>'.&mt('Access control').'</th><th>'.&mt('Dates available').
963: '</th><th>'.&mt('Additional information').'</th>');
964: $r->print(&Apache::loncommon::end_data_table_header_row());
965: my $count = 1;
966: my $chg = 'none';
967: &build_access_summary($r,$count,$chg,%todisplay);
968: $r->print(&Apache::loncommon::end_data_table());
969: } else {
1.189 raeburn 970: $r->print(&mt('No access control settings currently exist for this file.').'<br />');
1.120 raeburn 971: }
1.153 banghart 972: my %anchor_fields = (
973: 'currentpath' => $env{'form.currentpath'}
974: );
1.188 bisitz 975: $r->print('<br />'.&make_anchor($url, \%anchor_fields, &mt('Return to directory')));
1.120 raeburn 976: return;
1.104 raeburn 977: }
978:
1.120 raeburn 979: sub build_access_summary {
980: my ($r,$count,$chg,%todisplay) = @_;
981: my ($showstart,$showend);
982: my %scope_desc = (
983: public => 'Public',
984: guest => 'Passphrase-protected',
985: domains => 'Conditional: domain-based',
986: users => 'Conditional: user-based',
1.221 raeburn 987: course => 'Conditional: course/community-based',
1.120 raeburn 988: );
1.170 raeburn 989: my @allscopes = ('public','guest','domains','users','course');
1.120 raeburn 990: foreach my $scope (@allscopes) {
991: if ((!(exists($todisplay{$scope}))) || (ref($todisplay{$scope}) ne 'HASH')) {
992: next;
993: }
994: foreach my $key (sort(keys(%{$todisplay{$scope}}))) {
995: if ($count) {
996: $r->print(&Apache::loncommon::start_data_table_row());
997: }
998: my ($num,$scope,$end,$start) = &unpack_acc_key($key);
999: my $content = $todisplay{$scope}{$key};
1000: if ($chg eq 'delete') {
1001: $showstart = &mt('Deleted');
1002: $showend = $showstart;
1003: } else {
1.236 bisitz 1004: $showstart = &Apache::lonlocal::locallocaltime($start);
1.120 raeburn 1005: if ($end == 0) {
1006: $showend = &mt('No end date');
1007: } else {
1.236 bisitz 1008: $showend = &Apache::lonlocal::locallocaltime($end);
1.120 raeburn 1009: }
1010: }
1011: $r->print('<td>'.&mt($scope_desc{$scope}));
1.221 raeburn 1012: my $crstype;
1.170 raeburn 1013: if ($scope eq 'course') {
1.120 raeburn 1014: if ($chg ne 'delete') {
1015: my $cid = $content->{'domain'}.'_'.$content->{'number'};
1016: my %course_description = &Apache::lonnet::coursedescription($cid);
1017: $r->print('<br />('.$course_description{'description'}.')');
1.221 raeburn 1018: $crstype = 'Course';
1019: if ($course_description{'type'} ne '') {
1020: $crstype = $course_description{'type'};
1021: }
1.120 raeburn 1022: }
1023: }
1024: $r->print('</td><td>'.&mt('Start: ').$showstart.
1025: '<br />'.&mt('End: ').$showend.'</td><td>');
1026: if ($chg ne 'delete') {
1027: if ($scope eq 'guest') {
1028: $r->print(&mt('Passphrase').': '.$content->{'password'});
1.170 raeburn 1029: } elsif ($scope eq 'course') {
1.172 raeburn 1030: $r->print('<table width="100%"><tr>');
1.120 raeburn 1031: $r->print('<th>'.&mt('Roles').'</th><th>'.
1032: &mt('Access').'</th><th>'.
1033: &mt('Sections').'</th>');
1.170 raeburn 1034: $r->print('<th>'.&mt('Groups').'</th>');
1.120 raeburn 1035: $r->print('</tr>');
1036: foreach my $id (sort(keys(%{$content->{'roles'}}))) {
1037: $r->print('<tr>');
1038: foreach my $item ('role','access','section','group') {
1039: $r->print('<td>');
1040: if ($item eq 'role') {
1041: my $role_output;
1042: foreach my $role (@{$content->{'roles'}{$id}{$item}}) {
1043: if ($role eq 'all') {
1044: $role_output .= $role.',';
1045: } elsif ($role =~ /^cr/) {
1046: $role_output .= (split('/',$role))[3].',';
1047: } else {
1.221 raeburn 1048: $role_output .= &Apache::lonnet::plaintext($role,$crstype).',';
1.120 raeburn 1049: }
1050: }
1051: $role_output =~ s/,$//;
1052: $r->print($role_output);
1053: } else {
1054: $r->print(join(',',@{$content->{'roles'}{$id}{$item}}));
1055: }
1.170 raeburn 1056: $r->print('</td>');
1.120 raeburn 1057: }
1.170 raeburn 1058: $r->print('</tr>');
1.120 raeburn 1059: }
1.170 raeburn 1060: $r->print('</table>');
1.120 raeburn 1061: } elsif ($scope eq 'domains') {
1062: $r->print(&mt('Domains: ').join(',',@{$content->{'dom'}}));
1063: } elsif ($scope eq 'users') {
1064: my $curr_user_list = &sort_users($content->{'users'});
1065: $r->print(&mt('Users: ').$curr_user_list);
1066: } else {
1067: $r->print(' ');
1068: }
1069: } else {
1070: $r->print(' ');
1071: }
1072: $r->print('</td>');
1073: $r->print(&Apache::loncommon::end_data_table_row());
1074: $count ++;
1075: }
1076: }
1077: }
1078:
1079:
1.104 raeburn 1080: sub update_access {
1.137 albertel 1081: my ($r,$url,$group,$port_path) = @_;
1.104 raeburn 1082: my $totalprocessed = 0;
1083: my %processing;
1084: my %title = (
1.108 raeburn 1085: 'activate' => 'New control(s) added',
1086: 'delete' => 'Existing control(s) deleted',
1087: 'update' => 'Existing control(s) modified',
1.104 raeburn 1088: );
1.108 raeburn 1089: my $changes;
1.104 raeburn 1090: foreach my $chg (sort(keys(%title))) {
1091: @{$processing{$chg}} = &Apache::loncommon::get_env_multiple('form.'.$chg);
1092: $totalprocessed += @{$processing{$chg}};
1093: foreach my $num (@{$processing{$chg}}) {
1094: my $scope = $env{'form.scope_'.$num};
1095: my ($start,$end) = &get_dates_from_form($num);
1096: my $newkey = $num.':'.$scope.'_'.$end.'_'.$start;
1097: if ($chg eq 'delete') {
1098: $$changes{$chg}{$newkey} = 1;
1099: } else {
1100: $$changes{$chg}{$newkey} =
1.108 raeburn 1101: &build_access_record($num,$scope,$start,$end,$chg);
1.104 raeburn 1102: }
1103: }
1104: }
1105: my $file_name = $env{'form.currentpath'}.$env{'form.selectfile'};
1.241 bisitz 1106: $r->print('<h2>'.&mt('Allowing others to retrieve file: [_1]',
1107: '<span class="LC_filename">'.$port_path.$file_name.'</span>').'</h2>'."\n");
1.138 albertel 1108: $file_name = &prepend_group($file_name);
1.191 raeburn 1109: my ($uname,$udom) = &get_name_dom($group);
1.104 raeburn 1110: my ($errors,$outcome,$deloutcome,$new_values,$translation);
1111: if ($totalprocessed) {
1112: ($outcome,$deloutcome,$new_values,$translation) =
1.108 raeburn 1113: &Apache::lonnet::modify_access_controls($file_name,$changes,$udom,
1114: $uname);
1.104 raeburn 1115: }
1.108 raeburn 1116: my $current_permissions = &Apache::lonnet::get_portfile_permissions($udom,
1117: $uname);
1.109 albertel 1118: my %access_controls =
1119: &Apache::lonnet::get_access_controls($current_permissions,
1120: $group,$file_name);
1.104 raeburn 1121: if ($totalprocessed) {
1122: if ($outcome eq 'ok') {
1123: my $updated_controls = $access_controls{$file_name};
1124: my ($showstart,$showend);
1125: $r->print(&Apache::loncommon::start_data_table());
1.110 albertel 1126: $r->print(&Apache::loncommon::start_data_table_header_row());
1.108 raeburn 1127: $r->print('<th>'.&mt('Type of change').'</th><th>'.
1128: &mt('Access control').'</th><th>'.&mt('Dates available').
1129: '</th><th>'.&mt('Additional information').'</th>');
1.110 albertel 1130: $r->print(&Apache::loncommon::end_data_table_header_row());
1.104 raeburn 1131: foreach my $chg (sort(keys(%processing))) {
1132: if (@{$processing{$chg}} > 0) {
1133: if ($chg eq 'delete') {
1134: if (!($deloutcome eq 'ok')) {
1.116 albertel 1135: $errors .='<span class="LC_error">'.
1136: &mt('A problem occurred deleting access controls: [_1]',$deloutcome).
1137: '</span>';
1.104 raeburn 1138: next;
1139: }
1140: }
1141: my $numchgs = @{$processing{$chg}};
1142: $r->print(&Apache::loncommon::start_data_table_row());
1.108 raeburn 1143: $r->print('<td rowspan="'.$numchgs.'">'.&mt($title{$chg}).
1144: '.</td>');
1.104 raeburn 1145: my $count = 0;
1.120 raeburn 1146: my %todisplay;
1.104 raeburn 1147: foreach my $key (sort(keys(%{$$changes{$chg}}))) {
1.120 raeburn 1148: my ($num,$scope,$end,$start) = &unpack_acc_key($key);
1.104 raeburn 1149: my $newkey = $key;
1150: if ($chg eq 'activate') {
1151: $newkey =~ s/^(\d+)/$$translation{$1}/;
1152: }
1.120 raeburn 1153: $todisplay{$scope}{$newkey} = $$updated_controls{$newkey};
1.104 raeburn 1154: }
1.120 raeburn 1155: &build_access_summary($r,$count,$chg,%todisplay);
1.104 raeburn 1156: }
1157: }
1158: $r->print(&Apache::loncommon::end_data_table());
1159: } else {
1160: if ((@{$processing{'activate'}} > 0) || (@{$processing{'update'}} > 0)) {
1.116 albertel 1161: $errors .= '<span class="LC_error">'.
1.179 albertel 1162: &mt('A problem occurred saving access control settings: [_1]',$outcome).
1.116 albertel 1163: '</span>';
1.104 raeburn 1164: }
1165: }
1166: if ($errors) {
1167: $r->print($errors);
1168: }
1169: }
1.108 raeburn 1170: my $allnew = 0;
1171: my $totalnew = 0;
1172: my $status = 'new';
1173: my ($firstitem,$lastitem);
1.221 raeburn 1174: my @types = ('course','domains','users');
1175: foreach my $newitem (@types) {
1.108 raeburn 1176: $allnew += $env{'form.new'.$newitem};
1177: }
1178: if ($allnew > 0) {
1179: my $now = time;
1180: my $then = $now + (60*60*24*180); # six months approx.
1.138 albertel 1181: &open_form($r,$url);
1.221 raeburn 1182: my %showtypes = &Apache::lonlocal::texthash (
1183: course => 'course/community',
1184: domains => 'domain',
1185: users => 'user',
1186: );
1187: foreach my $newitem (@types) {
1.108 raeburn 1188: if ($env{'form.new'.$newitem} > 0) {
1.221 raeburn 1189: $r->print('<br />'.&mt('Add new [_1]-based[_2] access control for portfolio file: [_3]','<b>'.$showtypes{$newitem},'</b>','<b>'.$env{'form.currentpath'}.$env{'form.selectfile'}.'</b>').'<br /><br />');
1.108 raeburn 1190: $firstitem = $totalnew;
1191: $lastitem = $totalnew + $env{'form.new'.$newitem};
1192: $totalnew = $lastitem;
1193: my @numbers;
1194: for (my $i=$firstitem; $i<$lastitem; $i++) {
1.243 raeburn 1195: push(@numbers,$i);
1.108 raeburn 1196: }
1197: &display_access_row($r,$status,$newitem,\@numbers,
1198: $access_controls{$file_name},$now,$then);
1199: }
1200: }
1.137 albertel 1201: &close_form($r,$url);
1.108 raeburn 1202: } else {
1.153 banghart 1203: my %anchor_fields = (
1204: 'currentpath' => $env{'form.currentpath'},
1205: 'access' => $env{'form.selectfile'}
1206: );
1.241 bisitz 1207: my @actions;
1208: push(@actions, &make_anchor($url, \%anchor_fields, &mt('Display all access settings for this file')));
1.153 banghart 1209: delete $anchor_fields{'access'};
1.241 bisitz 1210: push(@actions, &make_anchor($url,\%anchor_fields,&mt('Return to directory')));
1211: $r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
1.108 raeburn 1212: }
1.104 raeburn 1213: return;
1214: }
1215:
1216: sub build_access_record {
1.108 raeburn 1217: my ($num,$scope,$start,$end,$chg) = @_;
1.109 albertel 1218: my $record = {
1219: type => $scope,
1220: time => {
1221: start => $start,
1222: end => $end
1223: },
1224: };
1225:
1226: if ($scope eq 'guest') {
1227: $record->{'password'} = $env{'form.password'};
1.170 raeburn 1228: } elsif ($scope eq 'course') {
1.109 albertel 1229: $record->{'domain'} = $env{'form.crsdom_'.$num};
1230: $record->{'number'} = $env{'form.crsnum_'.$num};
1.108 raeburn 1231: my @role_ids;
1.109 albertel 1232: my @delete_role_ids =
1233: &Apache::loncommon::get_env_multiple('form.delete_role_'.$num);
1234: my @preserves =
1235: &Apache::loncommon::get_env_multiple('form.preserve_role_'.$num);
1236: if (@delete_role_ids) {
1237: foreach my $id (@preserves) {
1238: if (grep {$_ = $id} (@delete_role_ids)) {
1239: next;
1240: }
1241: push(@role_ids,$id);
1242: }
1243: } else {
1244: push(@role_ids,@preserves);
1245: }
1246:
1247: my $next_id = $env{'form.add_role_'.$num};
1248: if ($next_id) {
1249: push(@role_ids,$next_id);
1250: }
1251:
1.108 raeburn 1252: foreach my $id (@role_ids) {
1253: my (@roles,@accesses,@sections,@groups);
1254: if (($id == $next_id) && ($chg eq 'update')) {
1.109 albertel 1255: @roles = split(/,/,$env{'form.role_'.$num.'_'.$next_id});
1.108 raeburn 1256: @accesses = split(/,/,$env{'form.access_'.$num.'_'.$next_id});
1257: @sections = split(/,/,$env{'form.section_'.$num.'_'.$next_id});
1.109 albertel 1258: @groups = split(/,/,$env{'form.group_'.$num.'_'.$next_id});
1.108 raeburn 1259: } else {
1260: @roles = &Apache::loncommon::get_env_multiple('form.role_'.$num.'_'.$id);
1261: @accesses = &Apache::loncommon::get_env_multiple('form.access_'.$num.'_'.$id);
1262: @sections = &Apache::loncommon::get_env_multiple('form.section_'.$num.'_'.$id);
1263: @groups = &Apache::loncommon::get_env_multiple('form.group_'.$num.'_'.$id);
1264: }
1.109 albertel 1265: $record->{'roles'}{$id}{'role'} = \@roles;
1266: $record->{'roles'}{$id}{'access'} = \@accesses;
1267: $record->{'roles'}{$id}{'section'} = \@sections;
1268: $record->{'roles'}{$id}{'group'} = \@groups;
1.108 raeburn 1269: }
1270: } elsif ($scope eq 'domains') {
1271: my @doms = &Apache::loncommon::get_env_multiple('form.dom_'.$num);
1.109 albertel 1272: $record->{'dom'} = \@doms;
1.108 raeburn 1273: } elsif ($scope eq 'users') {
1274: my $userlist = $env{'form.users_'.$num};
1.109 albertel 1275: $userlist =~ s/\s+//sg;
1276: my %userhash = map { ($_,1) } (split(/,/,$userlist));
1277: foreach my $user (keys(%userhash)) {
1.108 raeburn 1278: my ($uname,$udom) = split(/:/,$user);
1.109 albertel 1279: push(@{$record->{'users'}}, {
1280: 'uname' => $uname,
1281: 'udom' => $udom
1282: });
1283: }
1.108 raeburn 1284: }
1.104 raeburn 1285: return $record;
1286: }
1287:
1288: sub get_dates_from_form {
1289: my ($id) = @_;
1290: my $startdate;
1291: my $enddate;
1292: $startdate = &Apache::lonhtmlcommon::get_date_from_form('startdate_'.$id);
1293: $enddate = &Apache::lonhtmlcommon::get_date_from_form('enddate_'.$id);
1294: if ( exists ($env{'form.noend_'.$id}) ) {
1295: $enddate = 0;
1296: }
1297: return ($startdate,$enddate);
1298: }
1299:
1.108 raeburn 1300: sub sort_users {
1.109 albertel 1301: my ($users) = @_;
1302: my @curr_users = map {
1303: $_->{'uname'}.':'.$_->{'udom'}
1304: } (@{$users});
1305: my $curr_user_list = join(",\n",sort(@curr_users));
1.108 raeburn 1306: return $curr_user_list;
1307: }
1308:
1.104 raeburn 1309: sub access_setting_table {
1.170 raeburn 1310: my ($r,$url,$filename,$access_controls,$action) = @_;
1.104 raeburn 1311: my ($public,$publictext);
1.170 raeburn 1312: $publictext ='Off';
1.104 raeburn 1313: my ($guest,$guesttext);
1.170 raeburn 1314: $guesttext = 'Off';
1.104 raeburn 1315: my @courses = ();
1316: my @domains = ();
1317: my @users = ();
1318: my $now = time;
1319: my $then = $now + (60*60*24*180); # six months approx.
1.108 raeburn 1320: my ($num,$scope,$publicnum,$guestnum);
1.170 raeburn 1321: my (%acl_count,%end,%start,%conditionals);
1.104 raeburn 1322: foreach my $key (sort(keys(%{$access_controls}))) {
1.108 raeburn 1323: ($num,$scope,$end{$key},$start{$key}) = &unpack_acc_key($key);
1.104 raeburn 1324: if ($scope eq 'public') {
1325: $public = $key;
1.108 raeburn 1326: $publicnum = $num;
1327: $publictext = &acl_status($start{$key},$end{$key},$now);
1328: } elsif ($scope eq 'guest') {
1329: $guest=$key;
1330: $guestnum = $num;
1331: $guesttext = &acl_status($start{$key},$end{$key},$now);
1.170 raeburn 1332: } else {
1333: $conditionals{$scope}{$key} = $$access_controls{$key};
1334: if ($scope eq 'course') {
1335: push(@courses,$key);
1336: } elsif ($scope eq 'domains') {
1337: push(@domains,$key);
1338: } elsif ($scope eq 'users') {
1339: push(@users,$key);
1340: }
1.104 raeburn 1341: }
1.108 raeburn 1342: $acl_count{$scope} ++;
1.104 raeburn 1343: }
1.108 raeburn 1344: $r->print('<table border="0"><tr><td valign="top">');
1.170 raeburn 1345: if ($action eq 'chgaccess') {
1346: &standard_settings($r,$now,$then,$url,$filename,\%acl_count,\%start,
1347: \%end,$public,$publicnum,$publictext,$guest,$guestnum,
1348: $guesttext,$access_controls,%conditionals);
1349: } else {
1350: &condition_setting($r,$access_controls,$now,$then,\%acl_count,
1351: \@domains,\@users,\@courses);
1352: }
1353: $r->print('</td></tr></table>');
1354: }
1355:
1356: sub standard_settings {
1357: my ($r,$now,$then,$url,$filename,$acl_count,$start,$end,$public,$publicnum,
1358: $publictext,$guest,$guestnum,$guesttext,$access_controls,%conditionals)=@_;
1.187 bisitz 1359: $r->print('<h3>'.&mt('Public access: [_1]',&mt($publictext)).'</h3>');
1.104 raeburn 1360: $r->print(&Apache::loncommon::start_data_table());
1.110 albertel 1361: $r->print(&Apache::loncommon::start_data_table_header_row());
1.108 raeburn 1362: $r->print('<th>'.&mt('Action').'</th><th>'.&mt('Dates available').'</th>');
1.110 albertel 1363: $r->print(&Apache::loncommon::end_data_table_header_row());
1.104 raeburn 1364: $r->print(&Apache::loncommon::start_data_table_row());
1.108 raeburn 1365: if ($public) {
1366: $r->print('<td>'.&actionbox('old',$publicnum,'public').'</td><td>'.
1.170 raeburn 1367: &dateboxes($publicnum,$start->{$public},$end->{$public}).'</td>');
1.108 raeburn 1368: } else {
1369: $r->print('<td>'.&actionbox('new','0','public').'</td><td>'.
1370: &dateboxes('0',$now,$then).'</td>');
1371: }
1372: $r->print(&Apache::loncommon::end_data_table_row());
1373: $r->print(&Apache::loncommon::end_data_table());
1374: $r->print('</td><td width="40"> </td><td valign="top">');
1.187 bisitz 1375: $r->print('<h3>'.&mt('Passphrase-protected access: [_1]',&mt($guesttext)).'</h3>');
1.104 raeburn 1376: $r->print(&Apache::loncommon::start_data_table());
1.110 albertel 1377: $r->print(&Apache::loncommon::start_data_table_header_row());
1.108 raeburn 1378: $r->print('<th>'.&mt('Action').'</th><th>'.&mt('Dates available').
1.120 raeburn 1379: '</th><th>'. &mt('Passphrase').'</th>');
1.110 albertel 1380: $r->print(&Apache::loncommon::end_data_table_header_row());
1.108 raeburn 1381: $r->print(&Apache::loncommon::start_data_table_row());
1382: my $passwd;
1383: if ($guest) {
1.109 albertel 1384: $passwd = $$access_controls{$guest}{'password'};
1.108 raeburn 1385: $r->print('<td>'.&actionbox('old',$guestnum,'guest').'</td><td>'.
1.170 raeburn 1386: &dateboxes($guestnum,$start->{$guest},$end->{$guest}).'</td>');
1.108 raeburn 1387: } else {
1388: $r->print('<td>'.&actionbox('new','1','guest').'</td><td>'.
1389: &dateboxes('1',$now,$then).'</td>');
1.104 raeburn 1390: }
1.108 raeburn 1391: $r->print('<td><input type="text" size="15" name="password" value="'.
1392: $passwd.'" /></td>');
1.104 raeburn 1393: $r->print(&Apache::loncommon::end_data_table_row());
1394: $r->print(&Apache::loncommon::end_data_table());
1.170 raeburn 1395: $r->print('</td></tr><tr><td colspan="3"> </td></tr>'.
1396: '<tr><td colspan="3">');
1397: my $numconditionals = 0;
1398: my $conditionstext;
1399: my %cond_status;
1400: foreach my $scope ('domains','users','course') {
1401: $numconditionals += $acl_count->{$scope};
1402: if ($acl_count->{$scope} > 0) {
1403: if ($conditionstext ne 'Active') {
1404: foreach my $key (keys(%{$conditionals{$scope}})) {
1405: $conditionstext = &acl_status($start->{$key},$end->{$key},$now);
1406: if ($conditionstext eq 'Active') {
1407: last;
1408: }
1409: }
1410: }
1411: }
1412: }
1413: if ($conditionstext eq '') {
1414: $conditionstext = 'Off';
1415: }
1416: my %anchor_fields = (
1417: 'access' => $env{'form.selectfile'},
1418: 'action' => 'chgconditions',
1419: 'currentpath' => $env{'form.currentpath'},
1420: );
1.187 bisitz 1421: $r->print('<h3>'.&mt('Conditional access: [_1]',&mt($conditionstext)).'</h3>');
1.170 raeburn 1422: if ($numconditionals > 0) {
1423: my $count = 1;
1424: my $chg = 'none';
1425: $r->print(&mt('You have previously set [_1] conditional access controls.',$numconditionals).' '.&make_anchor($url,\%anchor_fields,&mt('Change Conditions')).'<br /><br />');
1426: $r->print(&Apache::loncommon::start_data_table());
1427: $r->print(&Apache::loncommon::start_data_table_header_row());
1428: $r->print('<th>'.&mt('Access control').'</th><th>'.&mt('Dates available').
1429: '</th><th>'.&mt('Additional information').'</th>');
1430: $r->print(&Apache::loncommon::end_data_table_header_row());
1431: &build_access_summary($r,$count,$chg,%conditionals);
1432: $r->print(&Apache::loncommon::end_data_table());
1433: } else {
1.217 raeburn 1434: $r->print(&make_anchor($url,\%anchor_fields,&mt('Add conditional access')).' '.&mt('based on domain, username, or course/community affiliation.'));
1.170 raeburn 1435: }
1436: }
1437:
1438: sub condition_setting {
1439: my ($r,$access_controls,$now,$then,$acl_count,$domains,$users,$courses) = @_;
1440: $r->print('<tr><td valign="top">');
1441: &access_element($r,'domains',$acl_count,$domains,$access_controls,$now,$then);
1.158 albertel 1442: $r->print('</td><td> </td><td valign="top">');
1.170 raeburn 1443: &access_element($r,'users',$acl_count,$users,$access_controls,$now,$then);
1.158 albertel 1444: $r->print('</td></tr><tr><td colspan="3"></td></tr><tr>');
1.170 raeburn 1445: if ($acl_count->{course} > 0) {
1.158 albertel 1446: $r->print('<td colspan="3" valign="top">');
1447: } else {
1448: $r->print('<td valign="top">');
1449: }
1.170 raeburn 1450: &access_element($r,'course',$acl_count,$courses,$access_controls,$now,$then);
1.158 albertel 1451: $r->print('</td>');
1.108 raeburn 1452: $r->print('</td></tr></table>');
1453: }
1454:
1455: sub acl_status {
1456: my ($start,$end,$now) = @_;
1457: if ($start > $now) {
1.170 raeburn 1458: return 'Inactive';
1.108 raeburn 1459: }
1460: if ($end && $end<$now) {
1.170 raeburn 1461: return 'Inactive';
1.108 raeburn 1462: }
1.170 raeburn 1463: return 'Active';
1.108 raeburn 1464: }
1465:
1466: sub access_element {
1467: my ($r,$type,$acl_count,$items,$access_controls,$now,$then) = @_;
1.221 raeburn 1468: my %typetext = &Apache::lonlocal::texthash(
1469: domains => 'Domain',
1470: users => 'User',
1471: course => 'Course/Community'
1472: );
1.222 raeburn 1473: $r->print('<h3>'.&mt('[_1]-based conditional access: ',$typetext{$type}));
1.108 raeburn 1474: if ($$acl_count{$type}) {
1475: $r->print($$acl_count{$type}.' ');
1476: if ($$acl_count{$type} > 1) {
1477: $r->print(&mt('conditions'));
1478: } else {
1479: $r->print(&mt('condition'));
1480: }
1481: } else {
1482: $r->print(&mt('Off'));
1483: }
1484: $r->print('</h3>');
1485: &display_access_row($r,'old',$type,$items,$access_controls,$now,$then);
1486: return;
1487: }
1488:
1489: sub display_access_row {
1490: my ($r,$status,$type,$items,$access_controls,$now,$then) = @_;
1.221 raeburn 1491: my $showtype;
1492: if ($type eq 'course') {
1493: $showtype = &mt('Courses/Communities');
1494: } elsif ($type eq 'domains') {
1495: $showtype = &mt('Domains');
1496: } elsif ($type eq 'users') {
1497: $showtype = &mt('Users');
1498: }
1.108 raeburn 1499: if (@{$items} > 0) {
1500: my @all_doms;
1501: my $colspan = 3;
1502: $r->print(&Apache::loncommon::start_data_table());
1.110 albertel 1503: $r->print(&Apache::loncommon::start_data_table_header_row());
1.221 raeburn 1504: $r->print('<th>'.&mt('Action?').'</th><th>'.$showtype.'</th><th>'.
1.108 raeburn 1505: &mt('Dates available').'</th>');
1.172 raeburn 1506: if ($type eq 'course' && $status eq 'old') {
1.221 raeburn 1507:
1508: $r->print('<th>'.&mt('Allowed course/community affiliations').
1.108 raeburn 1509: '</th>');
1510: $colspan ++;
1511: } elsif ($type eq 'domains') {
1.178 albertel 1512: @all_doms = sort(&Apache::lonnet::all_domains());
1.108 raeburn 1513: }
1.110 albertel 1514: $r->print(&Apache::loncommon::end_data_table_header_row());
1.108 raeburn 1515: foreach my $key (@{$items}) {
1.118 albertel 1516: $r->print(&Apache::loncommon::start_data_table_row());
1.170 raeburn 1517: if ($type eq 'course') {
1.118 albertel 1518: &course_row($r,$status,$type,$key,$access_controls,$now,$then);
1.108 raeburn 1519: } elsif ($type eq 'domains') {
1520: &domains_row($r,$status,$key,\@all_doms,$access_controls,$now,
1521: $then);
1522: } elsif ($type eq 'users') {
1523: &users_row($r,$status,$key,$access_controls,$now,$then);
1524: }
1.118 albertel 1525: $r->print(&Apache::loncommon::end_data_table_row());
1.108 raeburn 1526: }
1527: if ($status eq 'old') {
1.111 albertel 1528: $r->print(&Apache::loncommon::start_data_table_row());
1.108 raeburn 1529: $r->print('<td colspan="',$colspan.'">'.&additional_item($type).
1530: '</td>');
1.111 albertel 1531: $r->print(&Apache::loncommon::end_data_table_row());
1.108 raeburn 1532: }
1533: $r->print(&Apache::loncommon::end_data_table());
1534: } else {
1.221 raeburn 1535: $r->print(&mt('No [_1]-based conditions defined.',$showtype).'<br />'.
1536: &additional_item($type));
1.108 raeburn 1537: }
1538: return;
1539: }
1540:
1.110 albertel 1541: sub course_js {
1542: return qq|
1.108 raeburn 1543: <script type="text/javascript">
1.172 raeburn 1544: function setRoleOptions(num,roleid,cdom,cnum,type) {
1545: updateIndexNum = getIndexByValue('update',num);
1546: var addItem = 'add_role_'+num;
1547: var addIndexNum = getIndexByName(addItem);
1548: if (document.portform.elements[addItem].checked) {
1549: document.portform.elements[updateIndexNum].checked = true;
1550: var url = '/adm/portfolio?action=rolepicker&setroles='+num+'_'+roleid+'&cnum='+cnum+'&cdom='+cdom+'&type='+type;
1.108 raeburn 1551: var title = 'Roles_Chooser';
1552: var options = 'scrollbars=1,resizable=1,menubar=0';
1553: options += ',width=700,height=600';
1554: rolebrowser = open(url,title,options,'1');
1555: rolebrowser.focus();
1556: } else {
1.172 raeburn 1557: addArray = new Array ('role','access','section','group');
1558: for (var j=0;j<addArray.length;j++) {
1559: var itemIndex = getIndexByName(addArray[j]+'_'+num+'_'+roleid);
1560: document.portform.elements[itemIndex].value = '';
1.108 raeburn 1561: }
1562: }
1563: }
1564:
1.172 raeburn 1565: function getIndexByName(item) {
1.108 raeburn 1566: for (var i=0;i<document.portform.elements.length;i++) {
1.172 raeburn 1567: if (document.portform.elements[i].name == item) {
1.108 raeburn 1568: return i;
1569: }
1570: }
1571: return -1;
1572: }
1573:
1.172 raeburn 1574: function getIndexByValue(name,value) {
1.108 raeburn 1575: for (var i=0;i<document.portform.elements.length;i++) {
1576: if (document.portform.elements[i].name == name && document.portform.elements[i].value == value) {
1577: return i;
1578: }
1579: }
1580: return -1;
1581: }
1582:
1583: </script>
1.110 albertel 1584: |;
1585: }
1586:
1587: sub course_row {
1.118 albertel 1588: my ($r,$status,$type,$item,$access_controls,$now,$then) = @_;
1.115 raeburn 1589: my $content;
1.110 albertel 1590: my $defdom = $env{'user.domain'};
1591: if ($status eq 'old') {
1.115 raeburn 1592: $content = $$access_controls{$item};
1593: $defdom = $content->{'domain'};
1.110 albertel 1594: }
1595: my $js = &Apache::loncommon::coursebrowser_javascript($defdom)
1596: .&course_js();
1.221 raeburn 1597: my $showtype = &mt('Course/Community');
1598: my $crstype = 'Course';
1.108 raeburn 1599: my ($num,$scope,$end,$start) = &set_identifiers($status,$item,$now,$then,
1600: $type);
1.110 albertel 1601: $r->print('<td>'.$js.&actionbox($status,$num,$scope).'</td>');
1.108 raeburn 1602: if ($status eq 'old') {
1.115 raeburn 1603: my $cid = $content->{'domain'}.'_'.$content->{'number'};
1.108 raeburn 1604: my %course_description = &Apache::lonnet::coursedescription($cid);
1.221 raeburn 1605: if ($course_description{'type'} ne '') {
1606: $crstype = $course_description{'type'};
1607: }
1.115 raeburn 1608: $r->print('<td><input type="hidden" name="crsdom_'.$num.'" value="'.$content->{'domain'}.'" /><input type="hidden" name="crsnum_'.$num.'" value="'.$content->{'number'}.'" />'.$course_description{'description'}.'</td>');
1.108 raeburn 1609: } elsif ($status eq 'new') {
1.221 raeburn 1610: $r->print('<td>'.&Apache::loncommon::selectcourse_link('portform','crsnum_'.$num,'crsdom_'.$num,'description_'.$num,$num.'_1',undef,$showtype).' <input type="text" name="description_'.$num.'" size="30" /><input type="hidden" name="crsdom_'.$num.'" /><input type="hidden" name="crsnum_'.$num.'" /></td>');
1.108 raeburn 1611: }
1.172 raeburn 1612: $r->print('<td>'.&dateboxes($num,$start,$end));
1613: my $newrole_id = 1;
1.108 raeburn 1614: if ($status eq 'old') {
1.172 raeburn 1615: $r->print('</td><td>');
1.108 raeburn 1616: my $max_id = 0;
1.172 raeburn 1617: if (keys(%{$content->{'roles'}}) > 0) {
1618: $r->print('<table><tr><th>'.&mt('Action').'</th>'.
1619: '<th>'.&mt('Roles').'</th>'.
1620: '<th>'.&mt('Access').'</th>'.
1621: '<th>'.&mt('Sections').'</th>'.
1622: '<th>'.&mt('Groups').'</th></tr>');
1623: foreach my $role_id (sort(keys(%{$content->{'roles'}}))) {
1624: if ($role_id > $max_id) {
1625: $max_id = $role_id;
1626: }
1627: $max_id ++;
1.221 raeburn 1628: my $role_selects = &role_selectors($num,$role_id,$crstype,$content,'display');
1.200 bisitz 1629: $r->print('<tr><td><span class="LC_nobreak"><label><input type="checkbox" name="delete_role_'.$num.'" value="'.$role_id.'" />'.&mt('Delete').'</label></span><br /><input type="hidden" name="preserve_role_'.$num.'" value="'.$role_id.'" /></td>'.$role_selects.'</tr>');
1.172 raeburn 1630: }
1631: $r->print('</table>');
1632: }
1633: $r->print('<br />'.&mt('Add a roles-based condition').
1.214 bisitz 1634: ' <input type="checkbox" name="add_role_'.
1.172 raeburn 1635: $num.'" onClick="javascript:setRoleOptions('."'$num',
1636: '$max_id','$content->{'domain'}','$content->{'number'}',
1.221 raeburn 1637: '$showtype'".')" value="" />');
1.172 raeburn 1638: $newrole_id = $max_id;
1639: } else {
1.214 bisitz 1640: $r->print('<input type="hidden" name="add_role_'.$num.'" value="" />');
1.108 raeburn 1641: }
1.172 raeburn 1642: $r->print(&add_course_role($num,$newrole_id));
1643: $r->print('</td>');
1.108 raeburn 1644: return;
1645: }
1646:
1.172 raeburn 1647: sub add_course_role {
1648: my ($num,$max_id) = @_;
1649: my $output;
1650: $output .='<input type="hidden" name="role_'.$num.'_'.$max_id.'" />'.
1651: '<input type="hidden" name="access_'.$num.'_'.$max_id.'" />'.
1652: '<input type="hidden" name="section_'.$num.'_'.$max_id.'" />'.
1653: '<input type="hidden" name="group_'.$num.'_'.$max_id.'" />';
1654: return $output;
1655: }
1656:
1.108 raeburn 1657: sub domains_row {
1658: my ($r,$status,$item,$all_doms,$access_controls,$now,$then) = @_;
1659: my ($num,$scope,$end,$start) = &set_identifiers($status,$item,$now,$then,
1660: 'domains');
1.207 bisitz 1661: my $dom_select = '<select name="dom_'.$num.'" size="4" multiple="multiple">'.
1.108 raeburn 1662: ' <option value="">'.&mt('Please select').'</option>';
1663: if ($status eq 'old') {
1.109 albertel 1664: my $content = $$access_controls{$item};
1665: foreach my $dom (@{$all_doms}) {
1666: if ((@{$content->{'dom'}} > 0)
1667: && (grep(/^\Q$dom\E$/,@{$content->{'dom'}}))) {
1.214 bisitz 1668: $dom_select .= '<option value="'.$dom.'" selected="selected">'.
1.108 raeburn 1669: $dom.'</option>';
1670: } else {
1671: $dom_select .= '<option value="'.$dom.'">'.$dom.'</option>';
1672: }
1673: }
1674: } else {
1675: foreach my $dom (@{$all_doms}) {
1676: $dom_select .= '<option value="'.$dom.'">'.$dom.'</option>';
1677: }
1678: }
1.112 albertel 1679: $dom_select .= '</select>';
1.108 raeburn 1680: $r->print('<td>'.&actionbox($status,$num,$scope).'</td><td>'.$dom_select.
1681: '</td><td>'.&dateboxes($num,$start,$end).'</td>');
1682: }
1683:
1684: sub users_row {
1685: my ($r,$status,$item,$access_controls,$now,$then) = @_;
1686: my ($num,$scope,$end,$start) = &set_identifiers($status,$item,$now,$then,
1687: 'users');
1688: my $curr_user_list;
1689: if ($status eq 'old') {
1.109 albertel 1690: my $content = $$access_controls{$item};
1691: $curr_user_list = &sort_users($content->{'users'});
1.108 raeburn 1692: }
1693: $r->print('<td>'.&actionbox($status,$num,$scope).'</td><td>'.&mt("Format for users' username:domain information:").'<br /><tt>sparty:msu,illini:uiuc ... etc.</tt><br /><textarea name="users_'.$num.'" cols="30" rows="5">'.$curr_user_list.'</textarea></td><td>'.&dateboxes($num,$start,$end).'</td>');
1694: }
1695:
1696: sub additional_item {
1697: my ($type) = @_;
1.221 raeburn 1698: my $showtype;
1699: if ($type eq 'course') {
1700: $showtype = &mt('course/community');
1701: } elsif ($type eq 'domains') {
1702: $showtype = &mt('domains');
1703: } elsif ($type eq 'users') {
1704: $showtype = &mt('users');
1705: }
1706: my $output = &mt('Add new [_1] condition(s)?',$showtype).' '.&mt('Number to add: ').'<input type="text" name="new'.$type.'" size="3" value="0" />';
1.108 raeburn 1707: return $output;
1708: }
1709:
1710: sub actionbox {
1711: my ($status,$num,$scope) = @_;
1.200 bisitz 1712: my $output = '<span class="LC_nobreak"><label>';
1.108 raeburn 1713: if ($status eq 'new') {
1.170 raeburn 1714: my $checkstate;
1715: if ($scope eq 'domains' || $scope eq 'users' || $scope eq 'course') {
1716: $checkstate = 'checked="checked"';
1717: }
1718: $output .= '<input type="checkbox" name="activate" value="'.$num.'" '.
1719: $checkstate.' />'.
1.108 raeburn 1720: &mt('Activate');
1721: } else {
1722: $output .= '<input type="checkbox" name="delete" value="'.$num.
1.200 bisitz 1723: '" />'.&mt('Delete').'</label></span><br /><span class="LC_nobreak">'.
1.108 raeburn 1724: '<label><input type="checkbox" name="update" value="'.
1725: $num.'" />'.&mt('Update');
1726: }
1.112 albertel 1727: $output .= '</label></span><input type="hidden" name="scope_'.$num. '" value="'.$scope.'" />';
1.108 raeburn 1728: return $output;
1729: }
1730:
1731: sub dateboxes {
1732: my ($num,$start,$end) = @_;
1733: my $noend;
1734: if ($end == 0) {
1735: $noend = 'checked="checked"';
1736: }
1737: my $startdate = &Apache::lonhtmlcommon::date_setter('portform',
1738: 'startdate_'.$num,$start,undef,undef,undef,1,undef,
1739: undef,undef,1);
1740: my $enddate = &Apache::lonhtmlcommon::date_setter('portform',
1741: 'enddate_'.$num,$end,undef,undef,undef,1,undef,
1.200 bisitz 1742: undef,undef,1). ' <span class="LC_nobreak"><label>'.
1.108 raeburn 1743: '<input type="checkbox" name="noend_'.
1744: $num.'" '.$noend.' />'.&mt('No end date').
1.112 albertel 1745: '</label></span>';
1.108 raeburn 1746:
1747: my $output = &mt('Start: ').$startdate.'<br />'.&mt('End: ').$enddate;
1748: return $output;
1749: }
1750:
1751: sub unpack_acc_key {
1752: my ($acc_key) = @_;
1753: my ($num,$scope,$end,$start) = ($acc_key =~ /^([^:]+):([a-z]+)_(\d*)_?(\d*)$/);
1754: return ($num,$scope,$end,$start);
1755: }
1756:
1757: sub set_identifiers {
1758: my ($status,$item,$now,$then,$scope) = @_;
1759: if ($status eq 'old') {
1760: return(&unpack_acc_key($item));
1761: } else {
1762: return($item,$scope,$then,$now);
1763: }
1764: }
1765:
1766: sub role_selectors {
1.172 raeburn 1767: my ($num,$role_id,$type,$content,$caller) = @_;
1.108 raeburn 1768: my ($output,$cdom,$cnum,$longid);
1769: if ($caller eq 'display') {
1770: $longid = '_'.$num.'_'.$role_id;
1.172 raeburn 1771: $cdom = $$content{'domain'};
1772: $cnum = $$content{'number'};
1.108 raeburn 1773: } elsif ($caller eq 'rolepicker') {
1774: $cdom = $env{'form.cdom'};
1775: $cnum = $env{'form.cnum'};
1776: }
1.221 raeburn 1777: my $crstype = 'Course';
1778: if ($cnum =~ /^$match_community$/) {
1779: $crstype = 'Community'
1780: }
1.108 raeburn 1781: my ($sections,$groups,$allroles,$rolehash,$accesshash) =
1.221 raeburn 1782: &Apache::loncommon::get_secgrprole_info($cdom,$cnum,1,$crstype);
1.108 raeburn 1783: if (!@{$sections}) {
1784: @{$sections} = ('none');
1785: } else {
1786: unshift(@{$sections},('all','none'));
1787: }
1788: if (!@{$groups}) {
1789: @{$groups} = ('none');
1790: } else {
1791: unshift(@{$groups},('all','none'));
1792: }
1793: my @allacesses = sort(keys(%{$accesshash}));
1794: my (%sectionhash,%grouphash);
1795: foreach my $sec (@{$sections}) {
1796: $sectionhash{$sec} = $sec;
1797: }
1798: foreach my $grp (@{$groups}) {
1799: $grouphash{$grp} = $grp;
1800: }
1801: my %lookup = (
1802: 'role' => $rolehash,
1803: 'access' => $accesshash,
1804: 'section' => \%sectionhash,
1805: 'group' => \%grouphash,
1806: );
1807: my @allaccesses = sort(keys(%{$accesshash}));
1808: my %allitems = (
1809: 'role' => $allroles,
1810: 'access' => \@allaccesses,
1811: 'section' => $sections,
1.172 raeburn 1812: 'group' => $groups,
1.108 raeburn 1813: );
1814: foreach my $item ('role','access','section','group') {
1.207 bisitz 1815: $output .= '<td><select name="'.$item.$longid.'" multiple="multiple" size="4">'."\n";
1.108 raeburn 1816: foreach my $entry (@{$allitems{$item}}) {
1817: if ($caller eq 'display') {
1818: if ((@{$$content{'roles'}{$role_id}{$item}} > 0) &&
1819: (grep(/^\Q$entry\E$/,@{$$content{'roles'}{$role_id}{$item}}))) {
1.214 bisitz 1820: $output .= ' <option value="'.$entry.'" selected="selected">'.
1.108 raeburn 1821: $lookup{$item}{$entry}.'</option>';
1822: next;
1823: }
1824: }
1825: $output .= ' <option value="'.$entry.'">'.
1826: $lookup{$item}{$entry}.'</option>';
1827: }
1828: $output .= '</select>';
1829: }
1830: $output .= '</td>';
1831: return $output;
1832: }
1833:
1834: sub role_options_window {
1835: my ($r) = @_;
1836: my $type = $env{'form.type'};
1.172 raeburn 1837: my $rolenum = $env{'form.setroles'};
1838: my ($num,$role_id) = ($rolenum =~ /^([\d_]+)_(\d+)$/);
1839: my $role_elements;
1840: foreach my $item ('role','access','section','group') {
1841: $role_elements .= "'".$item.'_'.$rolenum."',";
1842: }
1843: $role_elements =~ s/,$//;
1844: my $role_selects = &role_selectors($num,$role_id,$type,undef,
1845: 'rolepicker');
1.108 raeburn 1846: $r->print(<<"END_SCRIPT");
1847: <script type="text/javascript">
1848: function setRoles() {
1.172 raeburn 1849: var role_elements = new Array($role_elements);
1850: for (var i=0; i<role_elements.length; i++) {
1.108 raeburn 1851: var copylist = '';
1852: for (var j=0; j<document.rolepicker.elements[i].length; j++) {
1853: if (document.rolepicker.elements[i].options[j].selected) {
1854: copylist = copylist + document.rolepicker.elements[i].options[j].value + ',';
1855: }
1856: }
1857: copylist = copylist.substr(0,copylist.length-1);
1.172 raeburn 1858: var openerItem = getIndexByName(role_elements[i]);
1859: opener.document.portform.elements[openerItem].value = copylist;
1.108 raeburn 1860: }
1.172 raeburn 1861: var roleAdder = getIndexByName('add_role_$num');
1862: opener.document.portform.elements[roleAdder].value = '$role_id';
1.108 raeburn 1863: self.close();
1864: }
1.172 raeburn 1865:
1866: function getIndexByName(item) {
1867: for (var i=0;i<opener.document.portform.elements.length;i++) {
1868: if (opener.document.portform.elements[i].name == item) {
1869: return i;
1870: }
1871: }
1872: return -1;
1873: }
1874:
1.108 raeburn 1875: </script>
1876: END_SCRIPT
1.220 bisitz 1877: $r->print(
1878: '<p>'
1879: .&mt('Select roles, '.lc($type).' status, section(s) and group(s) for users'
1880: .' who will be able to access the portfolio file.')
1881: .'</p>'
1882: );
1883: $r->print(
1884: '<form name="rolepicker" action="/adm/portfolio" method="post">'
1885: .'<table><tr>'
1886: .'<th>'.&mt('Roles').'</th>'
1887: .'<th>'.&mt("$type status").'</th>'
1888: .'<th>'.&mt('Sections').'</th>'
1889: .'<th>'.&mt('Groups').'</th>'
1890: .'</tr><tr>'.$role_selects.'</tr>'
1891: .'</table><br />'
1892: .'<input type="button" name="rolepickbutton" value="'.&mt('Save').'" onclick="setRoles()" />'
1893: );
1.108 raeburn 1894: return;
1.104 raeburn 1895: }
1896:
1.47 banghart 1897: sub select_files {
1.229 raeburn 1898: my ($r,$dir_list) = @_;
1.82 albertel 1899: if ($env{'form.continue'} eq 'true') {
1.60 banghart 1900: # here we update the selections for the currentpath
1901: # eventually, have to handle removing those not checked, but . . .
1.83 banghart 1902: my @items=&Apache::loncommon::get_env_multiple('form.checkfile');
1903: if (scalar(@items)){
1.229 raeburn 1904: my @ok_items;
1905: if (ref($dir_list) eq 'ARRAY') {
1906: foreach my $dir_line (@{$dir_list}) {
1907: my ($filename,undef,undef,undef,undef,undef,undef,undef,$size)=split(/\&/,$dir_line,10);
1908: if (grep(/^\Q$filename\E$/,@items)) {
1909: if ($size) {
1910: push(@ok_items,$filename);
1911: }
1912: }
1913: }
1914: }
1915: &Apache::lonnet::save_selected_files($env{'user.name'}, $env{'form.currentpath'}, @ok_items);
1.83 banghart 1916: }
1.62 banghart 1917: } else {
1918: #empty the file for a fresh start
1.83 banghart 1919: &Apache::lonnet::clear_selected_files($env{'user.name'});
1.62 banghart 1920: }
1.82 albertel 1921: my @files = &Apache::lonnet::files_not_in_path($env{'user.name'}, $env{'form.currentpath'});
1.62 banghart 1922: my $java_files = join ",", @files;
1923: if ($java_files) {
1924: $java_files.=',';
1.60 banghart 1925: }
1.63 banghart 1926: my $javascript =(<<ENDSMP);
1.113 albertel 1927: <script type="text/javascript">
1.48 banghart 1928: function finishSelect() {
1.62 banghart 1929: ENDSMP
1.63 banghart 1930: $javascript .= 'fileList = "'.$java_files.'";';
1931: $javascript .= (<<ENDSMP);
1.49 banghart 1932: for (i=0;i<document.forms.checkselect.length;i++) {
1933: if (document.forms.checkselect[i].checked){
1.54 banghart 1934: fileList = fileList + document.forms.checkselect.currentpath.value + document.forms.checkselect[i].value + "," ;
1.49 banghart 1935: }
1936: }
1.186 albertel 1937: var hwfield = opener.document.getElementsByName('$env{'form.fieldname'}');
1938: hwfield[0].value = fileList;
1.48 banghart 1939: self.close();
1940: }
1941: </script>
1942: ENDSMP
1.63 banghart 1943: $r->print($javascript);
1.198 bisitz 1944: $r->print("<h1>".&mt('Select portfolio files')."</h1>");
1.88 albertel 1945: my @otherfiles=&Apache::lonnet::files_not_in_path($env{'user.name'}, $env{'form.currentpath'});
1946: if (@otherfiles) {
1.198 bisitz 1947: $r->print(&Apache::loncommon::start_data_table()
1948: .&Apache::loncommon::start_data_table_header_row()
1949: .'<th>'.&mt('Files selected from other directories:')."</th>"
1950: .&Apache::loncommon::end_data_table_header_row()
1951: );
1.88 albertel 1952: foreach my $file (@otherfiles) {
1.198 bisitz 1953: $r->print(&Apache::loncommon::start_data_table_row()
1954: .'<td>'.$file."</td>"
1955: .&Apache::loncommon::end_data_table_row()
1956: );
1.88 albertel 1957: }
1.198 bisitz 1958: $r->print(&Apache::loncommon::end_data_table()
1959: .'<br />'
1960: );
1.60 banghart 1961: }
1.198 bisitz 1962: $r->print('<div>'
1963: .&mt('Check as many files as you wish in response to the problem:')
1964: .'</div>'
1965: );
1.47 banghart 1966: }
1.138 albertel 1967:
1.176 albertel 1968: sub upload {
1969: my ($r,$url,$group)=@_;
1.226 raeburn 1970: my $formname = 'uploaddoc';
1971: my $fname = &Apache::lonnet::clean_filename($env{'form.'.$formname.'.filename'});
1972: my ($state,$msg);
1973: if ($fname eq '') {
1.241 bisitz 1974: $r->print(
1975: &Apache::loncommon::confirmwrapper(
1976: &Apache::lonhtmlcommon::confirm_success(
1977: &mt('Invalid filename: [_1]; the name of the uploaded file did not contain any letters, '.
1.226 raeburn 1978: 'so after eliminating special characters there was nothing left.',
1.241 bisitz 1979: '<span class="LC_filename">'.$env{'form.uploaddoc.filename'}.'</span>'),1)));
1980:
1981: $r->print(&done(undef,$url));
1.226 raeburn 1982: return;
1983: }
1.195 raeburn 1984: my $disk_quota = &get_quota($group);
1985: my $portfolio_root = &get_portfolio_root();
1986: my $port_path = &get_port_path();
1987: my ($uname,$udom) = &get_name_dom($group);
1988: my $getpropath = 1;
1989: my $current_disk_usage = &Apache::lonnet::diskusage($udom,$uname,$portfolio_root,$getpropath);
1.226 raeburn 1990: ($state,$msg) =
1.195 raeburn 1991: &Apache::loncommon::check_for_upload($env{'form.currentpath'},$fname,
1.226 raeburn 1992: $group,$formname,$portfolio_root,
1.195 raeburn 1993: $port_path,$disk_quota,
1994: $current_disk_usage,$uname,$udom);
1.176 albertel 1995: if ($state eq 'will_exceed_quota'
1.227 raeburn 1996: || $state eq 'file_locked'
1997: || $state eq 'zero_bytes') {
1.241 bisitz 1998: $r->print($msg.&done(undef,$url));
1.176 albertel 1999: return;
2000: }
2001:
1.231 raeburn 2002: my (%allfiles,%codebase,$mode,$mimetype);
1.226 raeburn 2003: if ($env{'form.'.$formname.'.filename'} =~ m/(\.htm|\.html|\.shtml)$/i) {
1.193 raeburn 2004: if ($env{'form.parserflag'}) {
2005: $mode = 'parse';
2006: }
1.176 albertel 2007: }
1.226 raeburn 2008: my $context;
2009: if ($state eq 'existingfile') {
2010: $context = $state;
2011: }
1.231 raeburn 2012: my $subdir = $port_path.$env{'form.currentpath'};
2013: $subdir =~ s{(/)$}{};
1.226 raeburn 2014: my ($result,$timestamp) =
1.231 raeburn 2015: &Apache::lonnet::userfileupload($formname,$context,$subdir,
2016: $mode,\%allfiles,\%codebase,undef,undef,
2017: undef,undef,undef,undef,\$mimetype);
1.226 raeburn 2018: if ($state eq 'existingfile') {
2019: my $group_elem;
2020: my $rootdir = $r->dir_config('lonDaemons').'/tmp/overwrites';
2021: if ($group eq '') {
2022: $rootdir .= '/'.$env{'user.domain'}.'/'.$env{'user.name'};
2023: } else {
2024: $rootdir .= '/'.$env{'course.'.$env{'request.course.id'}.'.domain'}.
2025: '/'.$env{'course.'.$env{'request.course.id'}.'.num'};
2026: $group_elem = '<input type="hidden" name="group" value="'.$group.'" />';
2027: }
2028: if (($result eq $rootdir.'/'.$port_path.$env{'form.currentpath'}.$fname) && ($timestamp =~ /^\d+$/)) {
2029: my $showfname = &HTML::Entities::encode($fname,'&<>"');
2030: my %lt = &Apache::lonlocal::texthash (
2031: over => 'Overwrite existing file?',
2032: yes => 'Yes',
2033: no => 'No',
2034: undo => 'This action can not be undone.',
2035: conf => 'Are you sure you want to overwrite an existing file?',
2036: cont => 'Continue',
2037: );
1.230 raeburn 2038: my $parserflag;
2039: my $hidden = &hidden_elems();
2040: if ($mode eq 'parse') {
2041: $parserflag = '<input type="hidden" name="parserflag" value="1" />';
2042: }
1.226 raeburn 2043: $r->print(<<"END");
2044: <script type="text/javascript">
2045: // <![CDATA[
2046: function confirmOverwrite() {
1.230 raeburn 2047: var chosen;
2048: if (document.existingfile.overwrite.length) {
2049: for (var i=0; i<document.existingfile.overwrite.length; i++) {
2050: if (document.existingfile.overwrite[i].checked) {
2051: chosen = document.existingfile.overwrite[i].value;
2052: }
2053: }
2054: }
2055: if (chosen == 1) {
2056: if (confirm('$lt{'conf'}')) {
2057: document.existingfile.action.value = "process_overwrite";
2058: return true;
2059: } else {
2060: document.existingfile.action.value = "cancel_overwrite";
2061: if (document.existingfile.overwrite.length) {
2062: for (var i=0; i<document.existingfile.overwrite.length; i++) {
2063: if (document.existingfile.overwrite[i].value == "0") {
2064: document.existingfile.overwrite[i].checked = true;
2065: }
1.226 raeburn 2066: }
2067: }
1.230 raeburn 2068: return false;
1.226 raeburn 2069: }
1.230 raeburn 2070: } else {
1.226 raeburn 2071: document.existingfile.action.value = "cancel_overwrite";
1.230 raeburn 2072: return true;
1.226 raeburn 2073: }
2074: }
2075: // ]]>
2076: </script>
1.245 bisitz 2077: <p>
1.226 raeburn 2078: $msg
1.245 bisitz 2079: </p>
2080: <form method="post" action="$url" name="existingfile" onsubmit="return confirmOverwrite();">
2081: <p class="LC_nobreak">$lt{'over'}
1.230 raeburn 2082: <label><input type="radio" name="overwrite" value="1" />
1.226 raeburn 2083: $lt{'yes'}</label>
1.245 bisitz 2084: <label><input type="radio" name="overwrite" value="0" checked="checked" />$lt{'no'}</label></p>
2085: <p>
1.226 raeburn 2086: <input type="hidden" name="action" value="cancel_overwrite" />
2087: <input type="hidden" name="filename" value="$showfname" />
2088: <input type="hidden" name="timestamp" value="$timestamp" />
1.230 raeburn 2089: $hidden
2090: $parserflag
1.226 raeburn 2091: $group_elem
2092: <input type="submit" name="process" value="$lt{'cont'}" />
1.245 bisitz 2093: </p>
2094: </form>
1.226 raeburn 2095: END
2096: } else {
1.241 bisitz 2097: $r->print(
2098: &Apache::loncommon::confirmwrapper(
2099: &Apache::lonhtmlcommon::confirm_success(
2100: &mt('An error occurred ([_1]) while trying to upload [_2].'
2101: ,$result,&display_file(undef,$fname)),1)));
2102: $r->print(&done(undef,$url));
1.226 raeburn 2103: }
2104: } elsif ($result !~ m|^/uploaded/|) {
1.241 bisitz 2105: $r->print(
2106: &Apache::loncommon::confirmwrapper(
2107: &Apache::lonhtmlcommon::confirm_success(
2108: &mt('An error occurred ([_1]) while trying to upload [_2].'
2109: ,$result,&display_file(undef,$fname)),1)));
2110: $r->print(&done(undef,$url));
1.176 albertel 2111: } else {
1.231 raeburn 2112: if (!&suppress_embed_prompt()) {
2113: if ($mimetype eq 'text/html') {
2114: if (keys(%allfiles) > 0) {
2115: &print_dependency_form($r,$url,\%allfiles,\%codebase,$result);
2116: return;
2117: } else {
1.241 bisitz 2118: $r->print('<p class="LC_warning">'.&mt('No embedded items identified.').'</p>');
1.231 raeburn 2119: }
1.226 raeburn 2120: }
1.231 raeburn 2121: }
1.241 bisitz 2122: $r->print(
2123: &Apache::loncommon::confirmwrapper(
2124: &Apache::lonhtmlcommon::confirm_success(
2125: &mt('File successfully uploaded'))));
1.231 raeburn 2126: $r->print(&done(undef,$url));
1.226 raeburn 2127: }
1.231 raeburn 2128: return;
1.226 raeburn 2129: }
2130:
1.230 raeburn 2131: sub hidden_elems {
2132: my $contelem;
2133: if ($env{'form.mode'} eq 'selectfile') {
2134: $contelem = '<input type="hidden" name="continue" value="true" />';
2135: }
2136: return <<END;
2137: <input type="hidden" name="currentpath" value="$env{'form.currentpath'}" />
1.235 raeburn 2138: <input type="hidden" name="symb" value="$env{'form.symb'}" />
1.230 raeburn 2139: <input type="hidden" name="fieldname" value="$env{'form.fieldname'}" />
2140: <input type="hidden" name="mode" value="$env{'form.mode'}" />
2141: <input type="hidden" name="showversions" value="$env{'form.showversions'}" />
2142: $contelem
2143: END
2144: }
2145:
1.226 raeburn 2146: sub print_dependency_form {
1.231 raeburn 2147: my ($r,$url,$allfiles,$codebase,$result) = @_;
2148: my $container = &HTML::Entities::encode($result,'<>"&');
2149: my $state = &embedded_form_elems($container);
2150: my ($embedded,$num,$pathchg) = &Apache::loncommon::ask_for_embedded_content($url,$state,$allfiles,$codebase,
1.226 raeburn 2151: {'error_on_invalid_names' => 1,
2152: 'ignore_remote_references' => 1,});
2153: if ($embedded) {
1.231 raeburn 2154: if ($num || $pathchg) {
2155: $r->print('<h3>'.&mt("Reference Warning").'</h3>');
2156: } else {
2157: $r->print('<h3>'.&mt("Reference Information").'</h3>');
2158: }
2159: if ($num) {
1.238 raeburn 2160: $r->print('<p>'.&mt('Completed upload of the file.').' '.
2161: &mt('This file contained references to other files.').' '.
2162: &mt('You must upload the referenced files or else the uploaded file may not work properly.').
2163: '</p>'.
1.231 raeburn 2164: '<p>'.&mt("Please select the locations from which the referenced files are to be uploaded.").'</p>'.
2165: $embedded.
2166: '<p>'.&mt('or').'</p>'.&done('Return to directory',$url));
2167: } else {
2168: $r->print('<p>'.&mt("Completed upload of the file. This file contained references to other files.").'</p>'.
2169: $embedded.
2170: '<p>'.&done('Return to directory',$url).'</p>');
2171: }
1.226 raeburn 2172: } else {
2173: $r->print(&done(undef,$url));
2174: }
2175: return;
2176: }
2177:
2178: sub overwrite {
2179: my ($r,$url,$group)=@_;
2180: my $formname = 'existingfile';
2181: my $port_path = &get_port_path();
2182: my $fname = &Apache::lonnet::clean_filename($env{'form.filename'});
1.231 raeburn 2183: my (%allfiles,%codebase,$mode,$mimetype);
1.230 raeburn 2184: unless (&suppress_embed_prompt()) {
2185: if ($env{'form.parserflag'}) {
2186: if ($fname =~ /\.s?html?$/i) {
2187: $mode = 'parse';
2188: }
1.226 raeburn 2189: }
2190: }
2191: if ($fname eq '') {
1.245 bisitz 2192: $r->print(
2193: &Apache::loncommon::confirmwrapper(
2194: &Apache::lonhtmlcommon::confirm_success(
2195: &mt('Invalid filename: [_1]; the name of the uploaded file did not contain any letters, '.
1.226 raeburn 2196: 'so after eliminating special characters there was nothing left.',
1.245 bisitz 2197: '<span class="LC_filename">'.$env{'form.filename'}.'</span>'),1)));
2198: $r->print(&done(undef,$url));
1.226 raeburn 2199: return;
2200: }
2201: $env{'form.'.$formname.'.filename'} = $fname;
1.231 raeburn 2202: my $subdir = $port_path.$env{'form.currentpath'};
2203: $subdir =~ s{(/)$}{};
1.226 raeburn 2204: my $result=
1.231 raeburn 2205: &Apache::lonnet::userfileupload($formname,'overwrite',$subdir,$mode,
2206: \%allfiles,\%codebase,undef,undef,undef,
2207: undef,undef,undef,\$mimetype);
1.226 raeburn 2208: if ($result !~ m|^/uploaded/|) {
1.245 bisitz 2209: $r->print(
2210: &Apache::loncommon::confirmwrapper(
2211: &Apache::lonhtmlcommon::confirm_success(
2212: &mt('An error occurred ([_1]) while trying to overwrite [_2].'
2213: ,$result,&display_file(undef,$fname)),1)));
1.226 raeburn 2214: } else {
1.231 raeburn 2215: if ($mode eq 'parse') {
2216: if ($mimetype eq 'text/html') {
2217: if (keys(%allfiles) > 0) {
2218: &print_dependency_form($r,$url,\%allfiles,\%codebase,$result);
2219: return;
2220: } else {
1.245 bisitz 2221: $r->print(
2222: &Apache::loncommon::confirmwrapper(
2223: &Apache::lonhtmlcommon::confirm_success(
2224: &mt('Overwriting completed.'))
2225: .'<br />'.&mt('No embedded items identified.')));
1.231 raeburn 2226: }
1.195 raeburn 2227: }
1.245 bisitz 2228: } else {
2229: $r->print(
2230: &Apache::loncommon::confirmwrapper(
2231: &Apache::lonhtmlcommon::confirm_success(
2232: &mt('Overwriting completed.'))));
1.226 raeburn 2233: }
1.176 albertel 2234: }
2235:
1.230 raeburn 2236: my $group_elem;
2237: if (defined($env{'form.group'})) {
2238: $group_elem = '<input type="hidden" name="group" value="'.$env{'form.group'}.'" />';
2239: if (defined($env{'form.ref'})) {
2240: $group_elem .= '<input type="hidden" name="ref" value="'.$env{'form.ref'}.'" />'."\n";
2241: }
2242: }
2243: my $hidden = &hidden_elems();
1.245 bisitz 2244: $r->print(
2245: &Apache::lonhtmlcommon::actionbox(
2246: ['<a href="javascript:document.overwritedone.submit();">'
2247: .&mt('Return to directory')
2248: .'</a>'])
2249: .'<form name="overwritedone" method="post" action="'.$url.'">'
2250: .$hidden
2251: .$group_elem
2252: .'</form>'
2253: );
2254: return;
1.230 raeburn 2255: }
2256:
1.80 banghart 2257: sub lock_info {
1.137 albertel 2258: my ($r,$url,$group) = @_;
1.191 raeburn 2259: my ($uname,$udom) = &get_name_dom($group);
1.102 raeburn 2260: my $current_permissions = &Apache::lonnet::get_portfile_permissions($udom,
2261: $uname);
1.84 banghart 2262: my $file_name = $env{'form.lockinfo'};
1.138 albertel 2263: $file_name = &prepend_group($file_name);
1.102 raeburn 2264: if (defined($file_name) && defined($$current_permissions{$file_name})) {
2265: foreach my $array_item (@{$$current_permissions{$file_name}}) {
1.156 albertel 2266: next if (ref($array_item) ne 'ARRAY');
2267:
2268: my $filetext;
2269: if (defined($group)) {
2270: $filetext = '<strong>'.$env{'form.lockinfo'}.
2271: '</strong> (group: '.$group.')';
2272: } else {
1.241 bisitz 2273: $filetext = '<span class="LC_filename">'.$file_name.'</span>';
1.156 albertel 2274: }
2275:
2276: my $title ='<strong>'.&Apache::lonnet::gettitle($$array_item[0]).
2277: '</strong><br />';
2278: if ($$array_item[-1] eq 'graded') {
2279: $r->print(&mt('[_1] was submitted in response to problem: [_2]',
2280: $filetext,$title));
2281: } elsif ($$array_item[-1] eq 'handback') {
2282: $r->print(&mt('[_1] was handed back in response to problem: [_2]',
2283: $filetext,$title));
2284: } else {
2285: # submission style lock
2286: $r->print(&mt('[_1] was submitted in response to problem: [_2]',
2287: $filetext,$title));
2288: }
2289: my %course_description =
2290: &Apache::lonnet::coursedescription($$array_item[1]);
2291: if ( $course_description{'description'} ne '') {
1.188 bisitz 2292: $r->print(&mt('In the course:').' <strong>'.$course_description{'description'}.'</strong><br />');
1.156 albertel 2293: }
1.102 raeburn 2294: }
1.84 banghart 2295: }
1.241 bisitz 2296: $r->print(&done(undef,$url));
1.80 banghart 2297: return 'ok';
2298: }
1.138 albertel 2299:
1.25 albertel 2300: sub createdir {
1.191 raeburn 2301: my ($r,$url,$group)=@_;
1.82 albertel 2302: my $newdir=&Apache::lonnet::clean_filename($env{'form.newdir'});
1.241 bisitz 2303: # Display warning in case of directory name cleaning has changed the directory name
2304: if ($newdir ne $env{'form.newdir'}) {
2305: $r->print(
2306: '<p><span class="LC_warning">'
2307: .&mt('Invalid characters')
2308: .'</span><br />'
2309: .&mt('The new directory name was changed from [_1] to [_2].'
2310: ,'<span class="LC_filename">'.$env{'form.newdir'}.'</span>'
2311: ,'<span class="LC_filename">'.$newdir.'</span>')
2312: .'</p>'
2313: );
2314: }
2315:
2316: # Directory name empty?
1.28 albertel 2317: if ($newdir eq '') {
1.241 bisitz 2318: $r->print(
2319: &Apache::loncommon::confirmwrapper(
2320: &Apache::lonhtmlcommon::confirm_success(
2321: &mt('Error: no directory name was provided.'),1)));
2322: $r->print(&done(undef,$url));
2323: return;
1.94 raeburn 2324: }
1.241 bisitz 2325:
1.138 albertel 2326: my $portfolio_root = &get_portfolio_root();
1.233 raeburn 2327: my ($dirlistref,$listerror) = &get_dir_list($portfolio_root,undef,$group);
1.37 banghart 2328: my $found_file = 0;
1.233 raeburn 2329: if (ref($dirlistref) eq 'ARRAY') {
2330: foreach my $line (@{$dirlistref}) {
2331: my ($filename)=split(/\&/,$line,2);
2332: if ($filename eq $newdir){
2333: $found_file = 1;
2334: }
1.37 banghart 2335: }
2336: }
1.241 bisitz 2337: if ($found_file) {
2338: $r->print(
2339: &Apache::loncommon::confirmwrapper(
2340: &Apache::lonhtmlcommon::confirm_success(
2341: &mt('Unable to create a directory named [_1].'
2342: ,'<span class="LC_filename">'.$newdir.'</span>'),1)
2343: .'<br />'.&mt('A file or directory by that name already exists.')));
1.37 banghart 2344: } else {
1.191 raeburn 2345: my ($uname,$udom) = &get_name_dom($group);
1.138 albertel 2346: my $port_path = &get_port_path();
1.94 raeburn 2347: my $result=&Apache::lonnet::mkdiruserfile($uname,$udom,
2348: $port_path.$env{'form.currentpath'}.$newdir);
1.37 banghart 2349: if ($result ne 'ok') {
1.241 bisitz 2350: $r->print(
2351: &Apache::loncommon::confirmwrapper(
2352: &Apache::lonhtmlcommon::confirm_success(
2353: &mt('An error occurred ([_1]) while trying to create a new directory [_2].'
2354: ,$result,&display_file()),1)));
2355:
2356: } else {
2357: $r->print(
2358: &Apache::loncommon::confirmwrapper(
2359: &Apache::lonhtmlcommon::confirm_success(
2360: &mt('Directory successfully created'))));
1.37 banghart 2361: }
1.24 albertel 2362: }
1.137 albertel 2363: $r->print(&done(undef,$url));
1.94 raeburn 2364: }
2365:
2366: sub get_portfolio_root {
1.163 raeburn 2367: my ($udom,$uname,$group) = @_;
1.160 raeburn 2368: if (!(defined($udom)) || !(defined($uname))) {
1.191 raeburn 2369: ($uname,$udom) = &get_name_dom($group);
1.160 raeburn 2370: }
1.163 raeburn 2371: my $path = '/userfiles/portfolio';
2372: if (!defined($group)) {
2373: if (defined($env{'form.group'})) {
2374: $group = $env{'form.group'};
2375: }
1.94 raeburn 2376: }
1.163 raeburn 2377: if (defined($group)) {
2378: $path = '/userfiles/groups/'.$group.'/portfolio';
2379: }
1.191 raeburn 2380: return $path;
1.94 raeburn 2381: }
2382:
1.126 raeburn 2383: sub get_group_quota {
2384: my ($group) = @_;
2385: my $group_quota;
2386: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2387: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2388: my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum,$group);
2389: if (%curr_groups) {
2390: my %group_info = &Apache::longroup::get_group_settings(
2391: $curr_groups{$group});
2392: $group_quota = $group_info{'quota'}; #expressed in Mb
2393: if ($group_quota) {
2394: $group_quota = 1000 * $group_quota; #expressed in k
1.191 raeburn 2395: }
1.126 raeburn 2396: }
2397: return $group_quota;
1.191 raeburn 2398: }
1.126 raeburn 2399:
1.94 raeburn 2400: sub get_dir_list {
1.191 raeburn 2401: my ($portfolio_root,$path,$group) = @_;
1.176 albertel 2402: $path ||= $env{'form.currentpath'};
1.191 raeburn 2403: my ($uname,$udom) = &get_name_dom($group);
2404: my $getpropath = 1;
2405: return &Apache::lonnet::dirlist($portfolio_root.$path,$udom,$uname,$getpropath);
1.94 raeburn 2406: }
2407:
2408: sub get_name_dom {
1.191 raeburn 2409: my ($group) = @_;
1.94 raeburn 2410: my ($uname,$udom);
1.191 raeburn 2411: if (defined($group)) {
1.94 raeburn 2412: $udom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2413: $uname = $env{'course.'.$env{'request.course.id'}.'.num'};
2414: } else {
2415: $udom = $env{'user.domain'};
2416: $uname = $env{'user.name'};
2417: }
2418: return ($uname,$udom);
2419: }
2420:
1.102 raeburn 2421: sub prepend_group {
1.138 albertel 2422: my ($filename) = @_;
2423: if (defined($env{'form.group'})) {
2424: $filename = $env{'form.group'}.$filename;
1.102 raeburn 2425: }
2426: return $filename;
2427: }
2428:
1.94 raeburn 2429: sub get_namespace {
2430: my $namespace = 'portfolio';
1.138 albertel 2431: if (defined($env{'form.group'})) {
1.191 raeburn 2432: my ($uname,$udom) = &get_name_dom($env{'form.group'});
1.138 albertel 2433: $namespace .= '_'.$udom.'_'.$uname.'_'.$env{'form.group'};
1.94 raeburn 2434: }
2435: return $namespace;
2436: }
2437:
2438: sub get_port_path {
2439: my $port_path;
1.138 albertel 2440: if (defined($env{'form.group'})) {
2441: $port_path = "groups/$env{'form.group'}/portfolio";
1.94 raeburn 2442: } else {
2443: $port_path = 'portfolio';
2444: }
2445: return $port_path;
1.24 albertel 2446: }
2447:
1.120 raeburn 2448: sub missing_priv {
1.138 albertel 2449: my ($r,$url,$priv) = @_;
1.239 raeburn 2450: my %longtext =
2451: &Apache::lonlocal::texthash(
1.120 raeburn 2452: upload => 'upload files',
2453: delete => 'delete files',
2454: rename => 'rename files',
2455: setacl => 'set access controls for files',
1.239 raeburn 2456: );
1.120 raeburn 2457: my $escpath = &HTML::Entities::encode($env{'form.currentpath'},'&<>"');
2458: my $rtnlink = '<a href="'.$url;
2459: if ($url =~ /\?/) {
2460: $rtnlink .= '&';
2461: } else {
2462: $rtnlink .= '?';
2463: }
2464: $rtnlink .= 'currentpath='.$escpath;
1.188 bisitz 2465: $r->print('<h3>'.&mt('Action disallowed').'</h3>');
1.239 raeburn 2466: $r->print(&mt('You do not have sufficient privileges to [_1]',
2467: $longtext{$priv}));
1.138 albertel 2468: if (defined($env{'form.group'})) {
1.239 raeburn 2469: $r->print(' '.&mt("in the group's group portfolio."));
1.137 albertel 2470: $rtnlink .= &group_args()
1.120 raeburn 2471: } else {
1.239 raeburn 2472: $r->print(' '.&mt('in this portfolio.'));
1.120 raeburn 2473: }
1.188 bisitz 2474: $rtnlink .= '">'.&mt('Return to directory').'</a>';
1.120 raeburn 2475: $r->print('<br />'.$rtnlink);
2476: return;
2477: }
2478:
1.132 raeburn 2479: sub coursegrp_portfolio_header {
1.137 albertel 2480: my ($cdom,$cnum,$grp_desc)=@_;
1.132 raeburn 2481: my $gpterm = &Apache::loncommon::group_term();
2482: my $ucgpterm = $gpterm;
2483: $ucgpterm =~ s/^(\w)/uc($1)/e;
1.137 albertel 2484: if ($env{'form.ref'}) {
1.136 raeburn 2485: &Apache::lonhtmlcommon::add_breadcrumb
2486: ({href=>"/adm/coursegroups",
2487: text=>"Groups",
2488: title=>"Course Groups"});
2489: }
1.132 raeburn 2490: &Apache::lonhtmlcommon::add_breadcrumb
1.138 albertel 2491: ({href=>"/adm/$cdom/$cnum/$env{'form.group'}/smppg?ref=$env{'form.ref'}",
1.132 raeburn 2492: text=>"$ucgpterm: $grp_desc",
2493: title=>"Go to group's home page"},
1.137 albertel 2494: {href=>"/adm/coursegrp_portfolio?".&group_args(),
1.132 raeburn 2495: text=>"Group Portfolio",
1.136 raeburn 2496: title=>"Display group portfolio"});
1.132 raeburn 2497: my $output = &Apache::lonhtmlcommon::breadcrumbs(
2498: &mt('[_1] portfolio files - [_2]',$gpterm,$grp_desc));
2499: return $output;
2500: }
2501:
1.174 raeburn 2502: sub get_quota {
2503: my ($group) = @_;
2504: my $disk_quota;
2505: if (defined($group)) {
2506: my $grp_quota = &get_group_quota($group); # quota expressed in k
2507: if ($grp_quota ne '') {
2508: $disk_quota = $grp_quota;
2509: } else {
2510: $disk_quota = 0;
2511: }
2512: } else {
2513: $disk_quota = &Apache::loncommon::get_user_quota($env{'user.name'},
2514: $env{'user.domain'}); #expressed in Mb
2515: $disk_quota = 1000 * $disk_quota; # convert from Mb to kb
2516: }
2517: return $disk_quota;
2518: }
2519:
1.195 raeburn 2520: sub suppress_embed_prompt {
2521: my $suppress_prompt = 0;
2522: if (($env{'request.role'} =~ /^st/) && ($env{'request.course.id'} ne '')) {
2523: if ($env{'course.'.$env{'request.course.id'}.'.suppress_embed_prompt'} eq 'yes') {
2524: $suppress_prompt = 1;
2525: }
2526: }
2527: return $suppress_prompt;
2528: }
2529:
1.231 raeburn 2530: sub embedded_form_elems {
2531: my ($container) = @_;
2532: my $state = <<STATE;
2533: <input type="hidden" name="currentpath" value="$env{'form.currentpath'}" />
1.235 raeburn 2534: <input type="hidden" name="symb" value="$env{'form.symb'}" />
1.231 raeburn 2535: <input type="hidden" name="fieldname" value="$env{'form.fieldname'}" />
2536: <input type="hidden" name="mode" value="$env{'form.mode'}" />
2537: <input type="hidden" name="container" value="$container" />
2538: STATE
2539: if ($env{'form.group'} ne '') {
2540: $state .= '<input type="hidden" name="group" value="'.$env{'form.group'}.'" />'."\n";
2541: }
2542: return $state;
2543: }
1.195 raeburn 2544:
1.24 albertel 2545: sub handler {
2546: # this handles file management
2547: my $r = shift;
1.73 banghart 2548: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.108 raeburn 2549: ['selectfile','currentpath','meta','lockinfo','currentfile','action',
2550: 'fieldname','mode','rename','continue','group','access','setnum',
1.235 raeburn 2551: 'cnum','cdom','type','setroles','showversions','ref','symb']);
1.138 albertel 2552: my ($uname,$udom,$portfolio_root,$url,$caller,$title,$group,$grp_desc);
1.94 raeburn 2553: if ($r->uri =~ m|^(/adm/)([^/]+)|) {
2554: $url = $1.$2;
2555: $caller = $2;
2556: }
1.137 albertel 2557: my ($can_modify,$can_delete,$can_upload,$can_setacl);
1.94 raeburn 2558: if ($caller eq 'coursegrp_portfolio') {
2559: # Needs to be in a course
2560: if (! ($env{'request.course.fn'})) {
2561: # Not in a course
2562: $env{'user.error.msg'}=
2563: "/adm/coursegrp_portfolio:rgf:0:0:Cannot view group portfolio";
2564: return HTTP_NOT_ACCEPTABLE;
2565: }
2566: my $earlyout = 0;
1.136 raeburn 2567: my $view_permission =
2568: &Apache::lonnet::allowed('vcg',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
1.137 albertel 2569: $env{'form.group'} =~ s/\W//g;
1.138 albertel 2570: $group = $env{'form.group'};
1.191 raeburn 2571: if ($group ne '') {
2572: ($uname,$udom) = &get_name_dom($group);
1.99 raeburn 2573: my %curr_groups = &Apache::longroup::coursegroups($udom,$uname,
1.98 albertel 2574: $group);
2575: if (%curr_groups) {
1.132 raeburn 2576: my %grp_content = &Apache::longroup::get_group_settings(
2577: $curr_groups{$group});
2578: $grp_desc = &unescape($grp_content{'description'});
1.94 raeburn 2579: if (($view_permission) || (&Apache::lonnet::allowed('rgf',
2580: $env{'request.course.id'}.'/'.$group))) {
1.138 albertel 2581: $portfolio_root = &get_portfolio_root();
1.94 raeburn 2582: } else {
1.185 banghart 2583: $r->print(&mt('You do not have the privileges required to access the shared files space for this group.'));
1.94 raeburn 2584: $earlyout = 1;
2585: }
2586: } else {
1.185 banghart 2587: $r->print(&mt('Not a valid group for this course'));
1.94 raeburn 2588: $earlyout = 1;
2589: }
1.212 weissno 2590: $title = &mt('Group portfolio for [_1]', $group);
1.94 raeburn 2591: } else {
1.185 banghart 2592: $r->print(&mt('Invalid group'));
1.94 raeburn 2593: $earlyout = 1;
2594: }
2595: if ($earlyout) { return OK; }
1.126 raeburn 2596: if (&Apache::lonnet::allowed('mdg',$env{'request.course.id'})) {
1.120 raeburn 2597: $can_modify = 1;
2598: $can_delete = 1;
1.126 raeburn 2599: $can_upload = 1;
2600: $can_setacl = 1;
2601: } else {
2602: if (&Apache::lonnet::allowed('agf',$env{'request.course.id'}.'/'.$group)) {
2603: $can_setacl = 1;
2604: }
2605: if (&Apache::lonnet::allowed('ugf',$env{'request.course.id'}.'/'.$group)) {
2606: $can_upload = 1;
2607: }
2608: if (&Apache::lonnet::allowed('mgf',$env{'request.course.id'}.'/'.$group)) {
2609: $can_modify = 1;
2610: }
2611: if (&Apache::lonnet::allowed('dgf',$env{'request.course.id'}.'/'.$group)) {
2612: $can_delete = 1;
2613: }
1.120 raeburn 2614: }
1.94 raeburn 2615: } else {
2616: ($uname,$udom) = &get_name_dom();
2617: $portfolio_root = &get_portfolio_root();
1.211 schafran 2618: $title = &mt('My Space');
1.120 raeburn 2619: $can_modify = 1;
2620: $can_delete = 1;
2621: $can_upload = 1;
2622: $can_setacl = 1;
1.94 raeburn 2623: }
2624:
1.138 albertel 2625: my $port_path = &get_port_path();
1.24 albertel 2626: &Apache::loncommon::no_cache($r);
2627: &Apache::loncommon::content_type($r,'text/html');
2628: $r->send_http_header;
2629: # Give the LON-CAPA page header
1.203 raeburn 2630: my $brcrum = [{href=>"/adm/portfolio",text=>"Portfolio Manager"}];
2631:
1.82 albertel 2632: if ($env{"form.mode"} eq 'selectfile'){
1.96 albertel 2633: $r->print(&Apache::loncommon::start_page($title,undef,
1.97 albertel 2634: {'only_body' => 1}));
1.108 raeburn 2635: } elsif ($env{'form.action'} eq 'rolepicker') {
2636: $r->print(&Apache::loncommon::start_page('New role-based condition',undef,
2637: {'no_nav_bar' => 1, }));
1.205 raeburn 2638: } elsif ($caller eq 'coursegrp_portfolio') {
2639: $r->print(&Apache::loncommon::start_page($title));
1.74 banghart 2640: } else {
1.203 raeburn 2641: $r->print(&Apache::loncommon::start_page($title,undef,
2642: {'bread_crumbs' => $brcrum}));
1.205 raeburn 2643: if (!&Apache::lonnet::usertools_access($uname,$udom,'portfolio')) {
2644: $r->print('<h2>'.&mt('No user portfolio available') .'</h2>'.
2645: &mt('This is a result of one of the following:').'<ul>'.
2646: '<li>'.&mt('The administrator of this domain has disabled portfolio functionality for this specific user.').'</li>'.
2647: '<li>'.&mt('The domain has been configured to disable, by default, portfolio functionality for all users in the domain.').'</li>'.
2648: '</ul>');
2649: $r->print(&Apache::loncommon::end_page());
2650: return OK;
2651: }
1.74 banghart 2652: }
1.24 albertel 2653: $r->rflush();
1.235 raeburn 2654: # Check if access to portfolio is blocked by one or more blocking events in courses.
1.175 raeburn 2655: my ($blocked,$blocktext) =
2656: &Apache::loncommon::blocking_status('port',$uname,$udom);
2657: if ($blocked) {
1.235 raeburn 2658: my $evade_block;
2659: # If portfolio display is in a window popped up from a "Select Portfolio Files"
2660: # link in a .task resource, check if access to the task included proctor validation
2661: # of check-in to a slot limited by IP.
2662: # If so, and the slot is between its open and close dates, override the block.
2663: if ($env{'request.course.id'} && $env{'form.symb'}) {
2664: (undef,undef,my $res) = &Apache::lonnet::decode_symb($env{'form.symb'});
2665: if ($res =~ /\.task$/i) {
2666: my %history =
2667: &Apache::lonnet::restore($env{'form.symb'},$env{'request.course.id'},
2668: $env{'user.domain'},$env{'user.name'});
2669: my $version = $history{'resource.0.version'};
2670: if ($history{'resource.'.$version.'.0.checkedin'}) {
2671: if ($history{'resource.'.$version.'.0.checkedin.slot'}) {
2672: my %slot = &Apache::lonnet::get_slot($history{'resource.'.$version.'.0.checkedin.slot'});
2673: if ($slot{'ip'}) {
2674: if (&Apache::loncommon::check_ip_acc($slot{'ip'})) {
2675: my $now = time;
2676: if (($slot{'slottime'} < $now) && ($slot{'endtime'} > $now)) {
2677: $evade_block = 1;
2678: }
2679: }
2680: }
2681: }
2682: }
2683: }
2684: }
2685: unless ($evade_block) {
2686: $r->print($blocktext);
2687: $r->print(&Apache::loncommon::end_page());
2688: return OK;
2689: }
1.175 raeburn 2690: }
1.226 raeburn 2691: if (($env{'form.storeupl'}) & (!$env{'form.uploaddoc.filename'})){
1.241 bisitz 2692: $r->print(
2693: '<p><span class="LC_warning">'
2694: .&mt('No file was selected to upload.')
1.244 raeburn 2695: .'</span><br />'
1.241 bisitz 2696: .&mt('To upload a file, click [_1]Browse...[_2] and select a file, then click [_1]Upload[_2].'
2697: ,'<strong>','</strong>')
2698: .'</p>'
2699: );
1.226 raeburn 2700: }
1.82 albertel 2701: if ($env{'form.meta'}) {
1.94 raeburn 2702: &open_form($r,$url);
1.185 banghart 2703: $r->print(&mt('Edit the meta data').'<br />');
1.137 albertel 2704: &close_form($r,$url);
1.70 banghart 2705: }
1.82 albertel 2706: if ($env{'form.uploaddoc.filename'}) {
1.120 raeburn 2707: if ($can_upload) {
1.137 albertel 2708: &upload($r,$url,$group);
1.120 raeburn 2709: } else {
1.138 albertel 2710: &missing_priv($r,$url,'upload');
1.120 raeburn 2711: }
1.226 raeburn 2712: } elsif ($env{'form.action'} eq 'process_overwrite') {
2713: if ($can_upload) {
2714: &overwrite($r,$url,$group);
2715: } else {
2716: &missing_priv($r,$url,'existingfile');
2717: }
1.176 albertel 2718: } elsif ($env{'form.action'} eq 'upload_embedded') {
2719: if ($can_upload) {
1.195 raeburn 2720: my $disk_quota = &get_quota($group);
2721: my $getpropath = 1;
2722: my $current_disk_usage =
2723: &Apache::lonnet::diskusage($udom,$uname,$portfolio_root,$getpropath);
1.231 raeburn 2724: my $container = &HTML::Entities::encode($env{'form.container'},'<>&"');
2725: my $state = &embedded_form_elems($container).
2726: '<input type="hidden" name="action" value="modify_orightml" />';
2727: my ($result,$flag) =
1.195 raeburn 2728: &Apache::loncommon::upload_embedded('portfolio',$port_path,$uname,$udom,
1.231 raeburn 2729: $group,$portfolio_root,$group,$disk_quota,$current_disk_usage,$state,$url);
2730: $r->print($result.&done('Return to directory',$url));
2731: } else {
2732: &missing_priv($r,$url,'upload');
2733: }
2734: } elsif ($env{'form.action'} eq 'modify_orightml') {
2735: if ($can_upload) {
1.234 raeburn 2736: my $result =
1.242 raeburn 2737: &Apache::loncommon::modify_html_refs('portfolio',$port_path,$uname,
2738: $udom,$portfolio_root);
1.234 raeburn 2739: $r->print($result.
2740: &done('Return to directory',$url));
1.176 albertel 2741: } else {
2742: &missing_priv($r,$url,'upload');
2743: }
1.82 albertel 2744: } elsif ($env{'form.action'} eq 'delete' && $env{'form.confirmed'}) {
1.120 raeburn 2745: if ($can_delete) {
1.164 raeburn 2746: &delete_confirmed($r,$url,$group);
1.120 raeburn 2747: } else {
1.138 albertel 2748: &missing_priv($r,$url,'delete');
1.120 raeburn 2749: }
1.82 albertel 2750: } elsif ($env{'form.action'} eq 'delete') {
1.120 raeburn 2751: if ($can_delete) {
1.191 raeburn 2752: &delete($r,$url,$group);
1.120 raeburn 2753: } else {
1.138 albertel 2754: &missing_priv($r,$url,'delete');
1.120 raeburn 2755: }
1.82 albertel 2756: } elsif ($env{'form.action'} eq 'deletedir' && $env{'form.confirmed'}) {
1.120 raeburn 2757: if ($can_delete) {
1.191 raeburn 2758: &delete_dir_confirmed($r,$url,$group);
1.120 raeburn 2759: } else {
1.138 albertel 2760: &missing_priv($r,$url,'delete');
1.120 raeburn 2761: }
2762: } elsif ($env{'form.action'} eq 'deletedir') {
2763: if ($can_delete) {
1.137 albertel 2764: &delete_dir($r,$url);
1.120 raeburn 2765: } else {
1.138 albertel 2766: &missing_priv($r,$url,'delete');
1.120 raeburn 2767: }
1.82 albertel 2768: } elsif ($env{'form.action'} eq 'rename' && $env{'form.confirmed'}) {
1.120 raeburn 2769: if ($can_modify) {
1.164 raeburn 2770: &rename_confirmed($r,$url,$group);
1.120 raeburn 2771: } else {
1.138 albertel 2772: &missing_priv($r,$url,'rename');
1.120 raeburn 2773: }
1.82 albertel 2774: } elsif ($env{'form.rename'}) {
2775: $env{'form.selectfile'} = $env{'form.rename'};
2776: $env{'form.action'} = 'rename';
1.120 raeburn 2777: if ($can_modify) {
1.191 raeburn 2778: &rename($r,$url,$group);
1.120 raeburn 2779: } else {
1.138 albertel 2780: &missing_priv($r,$url,'rename');
1.120 raeburn 2781: }
1.104 raeburn 2782: } elsif ($env{'form.access'}) {
2783: $env{'form.selectfile'} = $env{'form.access'};
1.170 raeburn 2784: if (!defined($env{'form.action'})) {
2785: $env{'form.action'} = 'chgaccess';
2786: }
2787: &display_access($r,$url,$group,$can_setacl,$port_path,$env{'form.action'});
2788: } elsif (($env{'form.action'} eq 'chgaccess') ||
2789: ($env{'form.action'} eq 'chgconditions')) {
1.120 raeburn 2790: if ($can_setacl) {
1.137 albertel 2791: &update_access($r,$url,$group,$port_path);
1.120 raeburn 2792: } else {
1.138 albertel 2793: &missing_priv($r,$url,'setacl');
1.120 raeburn 2794: }
1.108 raeburn 2795: } elsif ($env{'form.action'} eq 'rolepicker') {
1.120 raeburn 2796: if ($can_setacl) {
2797: &role_options_window($r);
2798: } else {
1.138 albertel 2799: &missing_priv($r,$url,'setacl');
1.120 raeburn 2800: }
1.82 albertel 2801: } elsif ($env{'form.createdir'}) {
1.120 raeburn 2802: if ($can_upload) {
1.191 raeburn 2803: &createdir($r,$url,$group);
1.120 raeburn 2804: } else {
1.138 albertel 2805: &missing_priv($r,$url,'upload');
1.120 raeburn 2806: }
1.82 albertel 2807: } elsif ($env{'form.lockinfo'}) {
1.137 albertel 2808: &lock_info($r,$url,$group);
1.24 albertel 2809: } else {
1.226 raeburn 2810: if ($env{'form.action'} eq 'cancel_overwrite') {
2811: if ($can_upload) {
2812: my $formname = 'existingfile';
2813: my $fname = &Apache::lonnet::clean_filename($env{'form.filename'});
2814: $env{'form.'.$formname.'.filename'} = $fname;
1.231 raeburn 2815: my $subdir = $port_path.$env{'form.currentpath'};
2816: $subdir =~ s{(/)$}{};
2817: &Apache::lonnet::userfileupload($formname,'canceloverwrite',$subdir);
1.226 raeburn 2818: }
2819: }
1.24 albertel 2820: my $current_path='/';
1.82 albertel 2821: if ($env{'form.currentpath'}) {
2822: $current_path = $env{'form.currentpath'};
1.24 albertel 2823: }
1.132 raeburn 2824: if ($caller eq 'coursegrp_portfolio') {
2825: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.137 albertel 2826: $r->print(&coursegrp_portfolio_header($udom,$uname,$grp_desc));
1.132 raeburn 2827: }
1.233 raeburn 2828: my ($dirlistref,$listerror) =
2829: &get_dir_list($portfolio_root,$current_path,$group);
2830: if ($listerror eq 'no_such_dir'){
1.46 albertel 2831: # two main reasons for this:
2832: # 1) never been here, so directory structure not created
2833: # 2) back-button navigation after deleting a directory
2834: if ($current_path eq '/'){
1.100 albertel 2835: &Apache::lonnet::mkdiruserfile($uname,$udom,
1.138 albertel 2836: &get_port_path());
1.46 albertel 2837: } else {
2838: # some directory that snuck in get rid of the directory
2839: # from the recent pulldown, just in case
2840: &Apache::lonhtmlcommon::remove_recent('portfolio',
2841: [$current_path]);
2842: $current_path = '/'; # force it back to the root
2843: }
2844: # now grab the directory list again, for the first time
1.233 raeburn 2845: ($dirlistref,$listerror) =
2846: &get_dir_list($portfolio_root,$current_path,$group);
1.43 banghart 2847: }
1.46 albertel 2848: # need to know if directory is empty so it can be removed if desired
1.233 raeburn 2849: my $is_empty;
2850: if ($listerror eq 'empty') {
2851: $is_empty = 1;
2852: } elsif (ref($dirlistref) eq 'ARRAY') {
2853: if ((scalar(@{$dirlistref}) == 2) && ($dirlistref->[0] =~ /^\.+\&/)
2854: && ($dirlistref->[1] =~ /^\.+\&/)) {
2855: $is_empty = 1;
2856: }
2857: }
2858: &display_common($r,$url,$current_path,$is_empty,$dirlistref,
1.206 raeburn 2859: $can_upload,$group);
1.233 raeburn 2860: &display_directory($r,$url,$current_path,$is_empty,$dirlistref,$group,
1.137 albertel 2861: $can_upload,$can_modify,$can_delete,$can_setacl);
1.30 banghart 2862: }
1.226 raeburn 2863: $r->print(&Apache::loncommon::end_page());
1.90 albertel 2864: return OK;
1.2 banghart 2865: }
1.120 raeburn 2866:
1.1 banghart 2867: 1;
2868: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>