Annotation of loncom/interface/londocs.pm, revision 1.137
1.1 www 1: # The LearningOnline Network
1.2 www 2: # Documents
1.1 www 3: #
1.137 ! albertel 4: # $Id: londocs.pm,v 1.136 2004/08/03 20:44:33 albertel Exp $
1.1 www 5: #
1.3 www 6: # Copyright Michigan State University Board of Trustees
1.1 www 7: #
1.3 www 8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
1.1 www 9: #
1.3 www 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.
1.1 www 14: #
1.3 www 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.2 www 29: package Apache::londocs;
1.1 www 30:
31: use strict;
1.28 www 32: use Apache::Constants qw(:common :http);
1.4 www 33: use Apache::lonnet;
34: use Apache::loncommon;
1.7 www 35: use Apache::lonratedt;
36: use Apache::lonratsrv;
1.15 www 37: use Apache::lonxml;
1.74 www 38: use Apache::loncreatecourse;
1.38 www 39: use HTML::Entities;
1.27 www 40: use GDBM_File;
1.81 www 41: use Apache::lonlocal;
1.7 www 42:
1.8 www 43: my $iconpath;
1.7 www 44:
1.27 www 45: my %hash;
46:
47: my $hashtied;
1.29 www 48: my %alreadyseen=();
1.27 www 49:
1.40 www 50: my $hadchanges;
51:
1.47 www 52: # Available help topics
53:
54: my %help=();
55:
1.7 www 56: # Mapread read maps into lonratedt::global arrays
1.10 www 57: # @order and @resources, determines status
1.7 www 58: # sets @order - pointer to resources in right order
59: # sets @resources - array with the resources with correct idx
60: #
61:
62: sub mapread {
63: my ($coursenum,$coursedom,$map)=@_;
64: return
65: &Apache::lonratedt::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
66: $map);
67: }
68:
69: sub storemap {
70: my ($coursenum,$coursedom,$map)=@_;
1.104 albertel 71: my ($outtext,$errtext)=
1.7 www 72: &Apache::lonratedt::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
1.15 www 73: $map,1);
1.104 albertel 74: if ($errtext) { return ($errtext,2); }
75:
76: $hadchanges=1;
77: return ($errtext,0);
1.7 www 78: }
79:
1.74 www 80: # ----------------------------------------- Return hash with valid author names
81:
82: sub authorhosts {
83: my %outhash=();
84: my $home=0;
85: my $other=0;
86: foreach (keys %ENV) {
87: if ($_=~/^user\.role\.(au|ca)\.(.+)$/) {
88: my $role=$1;
89: my $realm=$2;
90: my ($start,$end)=split(/\./,$ENV{$_});
91: if (($start) && ($start>time)) { next; }
92: if (($end) && (time>$end)) { next; }
93: my $ca; my $cd;
94: if ($1 eq 'au') {
95: $ca=$ENV{'user.name'};
96: $cd=$ENV{'user.domain'};
97: } else {
98: ($cd,$ca)=($realm=~/^\/(\w+)\/(\w+)$/);
99: }
1.107 albertel 100: my $allowed=0;
101: my $myhome=&Apache::lonnet::homeserver($ca,$cd);
102: my @ids=&Apache::lonnet::current_machine_ids();
103: foreach my $id (@ids) { if ($id eq $myhome) { $allowed=1; } }
104: if ($allowed) {
1.74 www 105: $home++;
106: $outhash{'home_'.$ca.'@'.$cd}=1;
107: } else {
1.107 albertel 108: $outhash{'otherhome_'.$ca.'@'.$cd}=$myhome;
1.74 www 109: $other++;
110: }
111: }
112: }
113: return ($home,$other,%outhash);
114: }
115: # ------------------------------------------------------ Generate "dump" button
116:
117: sub dumpbutton {
118: my ($home,$other,%outhash)=&authorhosts();
119: if ($home+$other==0) { return ''; }
120: my $output='</td><td bgcolor="#DDDDCC">';
121: if ($home) {
122: return '</td><td bgcolor="#DDDDCC">'.
1.81 www 123: '<input type="submit" name="dumpcourse" value="'.
1.130 www 124: &mt('Dump Course DOCS to Construction Space').'" />'.
125: &Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs');
1.74 www 126: } else {
127: return'</td><td bgcolor="#DDDDCC">'.
1.81 www 128: &mt('Dump Course DOCS to Construction Space: available on other servers');
1.74 www 129: }
130: }
131:
132: # -------------------------------------------------------- Actually dump course
133:
134: sub dumpcourse {
1.75 www 135: my $r=shift;
136: $r->print('<html><head><title>Dump DOCS</title></head>'.
1.76 www 137: &Apache::loncommon::bodytag('Dump Course DOCS to Construction Space').
138: '<form name="dumpdoc" method="post">');
1.74 www 139: my ($home,$other,%outhash)=&authorhosts();
1.75 www 140: unless ($home) { return ''; }
1.76 www 141: my $origcrsid=$ENV{'request.course.id'};
142: my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
143: if (($ENV{'form.authorspace'}) && ($ENV{'form.authorfolder'}=~/\w/)) {
144: # Do the dumping
1.75 www 145: unless ($outhash{'home_'.$ENV{'form.authorspace'}}) { return ''; }
146: my ($ca,$cd)=split(/\@/,$ENV{'form.authorspace'});
1.87 www 147: $r->print('<h3>'.&mt('Copying Files').'</h3>');
1.76 www 148: my $title=$ENV{'form.authorfolder'};
1.79 www 149: $title=~s/[^\w\/]+/\_/g;
150: my %replacehash=();
151: foreach (keys %ENV) {
152: if ($_=~/^form\.namefor\_(.+)/) {
153: $replacehash{$1}=$ENV{$_};
154: }
155: }
156: my $crs='/uploaded/'.$ENV{'request.course.id'}.'/';
157: $crs=~s/\_/\//g;
158: foreach (keys %replacehash) {
159: my $newfilename=$title.'/'.$replacehash{$_};
1.132 www 160: $newfilename=~s/[^\w\/\.\/]+/\_/g;
1.79 www 161: my @dirs=split(/\//,$newfilename);
162: my $path='/home/'.$ca.'/public_html';
163: my $makepath=$path;
164: my $fail=0;
165: for (my $i=0;$i<$#dirs;$i++) {
166: $makepath.='/'.$dirs[$i];
167: unless (-e $makepath) {
168: unless(mkdir($makepath,0777)) { $fail=1; }
169: }
170: }
171: $r->print('<br /><tt>'.$_.'</tt> => <tt>'.$newfilename.'</tt>: ');
172: if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
173: if ($_=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
174: print $fh &Apache::loncreatecourse::rewritefile(
175: &Apache::loncreatecourse::readfile($ENV{'request.course.id'},$_),
176: (%replacehash,$crs => '')
177: );
178: } else {
179: print $fh
180: &Apache::loncreatecourse::readfile($ENV{'request.course.id'},$_);
181: }
182: $fh->close();
183: } else {
184: $fail=1;
185: }
186: if ($fail) {
187: $r->print('<font color="red">fail</font>');
188: } else {
189: $r->print('<font color="green">ok</font>');
190: }
191: }
1.76 www 192: } else {
193: # Input form
194: unless ($home==1) {
195: $r->print(
1.81 www 196: '<h3>'.&mt('Select the Construction Space').'</h3><select name="authorspace">');
1.76 www 197: }
198: foreach (sort keys %outhash) {
199: if ($_=~/^home_(.+)$/) {
200: if ($home==1) {
201: $r->print(
202: '<input type="hidden" name="authorspace" value="'.$1.'" />');
203: } else {
1.133 www 204: $r->print('<option value="'.$1.'">'.$1.' - '.
205: &Apache::loncommon::plainname(split(/\@/,$1)).'</option>');
1.76 www 206: }
207: }
208: }
209: unless ($home==1) {
210: $r->print('</select>');
211: }
212: my $title=$origcrsdata{'description'};
213: $title=~s/\s+/\_/gs;
214: $title=~s/\W//gs;
1.81 www 215: $r->print('<h3>'.&mt('Folder in Construction Space').'</h3><input type="text" size="50" name="authorfolder" value="'.$title.'" /><br />');
1.76 www 216: &tiehash();
1.81 www 217: $r->print('<h3>'.&mt('Filenames in Construction Space').'</h3><table border="2"><tr><th>'.&mt('Internal Filename').'</th><th>'.&mt('Title').'</th><th>'.&mt('Save as ...').'</th></tr>');
1.76 www 218: foreach (&Apache::loncreatecourse::crsdirlist($origcrsid,'userfiles')) {
1.78 www 219: $r->print('<tr><td>'.$_.'</td>');
220: my ($ext)=($_=~/\.(\w+)$/);
221: my $title=$hash{'title_'.$hash{
222: 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$_}};
223: $r->print('<td>'.($title?$title:' ').'</td>');
224: unless ($title) {
225: $title=$_;
226: }
227: $title=~s/\.(\w+)$//;
1.132 www 228: $title=~s/[^\w\/]+/\_/gs;
1.78 www 229: $title.='.'.$ext;
1.79 www 230: $r->print("\n<td><input type='text' size='60' name='namefor_".$_."' value='".$title."' /></td></tr>\n");
1.76 www 231: }
1.78 www 232: $r->print("</table>\n");
1.76 www 233: &untiehash();
234: $r->print(
1.81 www 235: '<p><input type="submit" name="dumpcourse" value="'.&mt('Dump Course DOCS').'" /></p></form>');
1.75 www 236: }
1.74 www 237: }
1.76 www 238:
1.74 www 239:
1.73 bowersj2 240: # Imports the given (name, url) resources into the course
241: # coursenum, coursedom, and folder must precede the list
242: sub group_import {
243: my $coursenum = shift;
244: my $coursedom = shift;
245: my $folder = shift;
246: while (@_) {
247: my $name = shift;
248: my $url = shift;
249: if ($url) {
250: my $idx = $#Apache::lonratedt::resources + 1;
251: $Apache::lonratedt::order[$#Apache::lonratedt::order+1]=$idx;
252: my $ext = 'false';
253: if ($url=~/^http:\/\//) { $ext = 'true'; }
254: $url =~ s/:/\:/g;
255: $name =~ s/:/\:/g;
256: $Apache::lonratedt::resources[$idx] =
257: join ':', ($name, $url, $ext, 'normal', 'res');
258: }
259: }
1.104 albertel 260: return &storemap($coursenum, $coursedom, $folder.'.sequence');
1.73 bowersj2 261: }
262:
1.114 albertel 263: sub breadcrumbs {
264: my ($where)=@_;
265: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.116 albertel 266: my (@folders)=split('&',$ENV{'form.folderpath'});
267: my $folderpath;
268: while (@folders) {
269: my $folder=shift(@folders);
270: my $foldername=shift(@folders);
271: if ($folderpath) {$folderpath.='&';}
272: $folderpath.=$folder.'&'.$foldername;
273: my $url='/adm/coursedocs?folderpath='.
274: &Apache::lonnet::escape($folderpath);
1.114 albertel 275: &Apache::lonhtmlcommon::add_breadcrumb(
276: {'href'=>$url,
277: 'title'=>&Apache::lonnet::unescape($foldername),
1.117 albertel 278: 'text'=>'<font size="+1">'.
279: &Apache::lonnet::unescape($foldername).'</font>'
280: });
1.114 albertel 281:
282:
283: }
1.137 ! albertel 284: return &Apache::lonhtmlcommon::breadcrumbs(undef,undef,undef,undef,undef,
! 285: 0,'nohelp');
1.114 albertel 286: }
287:
1.7 www 288: sub editor {
289: my ($r,$coursenum,$coursedom,$folder,$allowed)=@_;
1.114 albertel 290:
291: $r->print(&breadcrumbs($folder));
1.10 www 292: my $errtext='';
293: my $fatal=0;
294: ($errtext,$fatal)=
1.7 www 295: &mapread($coursenum,$coursedom,$folder.'.sequence');
1.17 www 296: if ($#Apache::lonratedt::order<1) {
297: $Apache::lonratedt::order[0]=1;
298: $Apache::lonratedt::resources[1]='';
299: }
1.7 www 300: if ($fatal) {
301: $r->print('<p><font color="red">'.$errtext.'</font></p>');
302: } else {
303: # ------------------------------------------------------------ Process commands
1.121 www 304:
1.16 www 305: # ---------------- if they are for this folder and user allowed to make changes
306: if (($allowed) && ($ENV{'form.folder'} eq $folder)) {
1.123 www 307: # set parameters and change order
1.121 www 308: if (defined($ENV{'form.setparms'})) {
309: my $idx=$ENV{'form.setparms'};
1.123 www 310: # set parameters
1.121 www 311: if ($ENV{'form.randpick_'.$idx}) {
1.122 www 312: &Apache::lonratedt::storeparameter($idx,'parameter_randompick',$ENV{'form.randpick_'.$idx},'int_pos');
1.121 www 313: } else {
1.122 www 314: &Apache::lonratedt::delparameter($idx,'parameter_randompick');
1.121 www 315: }
316: if ($ENV{'form.hidprs_'.$idx}) {
1.122 www 317: &Apache::lonratedt::storeparameter($idx,'parameter_hiddenresource','yes','string_yesno');
1.121 www 318: } else {
1.122 www 319: &Apache::lonratedt::delparameter($idx,'parameter_hiddenresource');
1.121 www 320: }
321: if ($ENV{'form.encprs_'.$idx}) {
1.122 www 322: &Apache::lonratedt::storeparameter($idx,'parameter_encrypturl','yes','string_yesno');
1.121 www 323: } else {
1.122 www 324: &Apache::lonratedt::delparameter($idx,'parameter_encrypturl');
1.121 www 325: }
326:
1.123 www 327: if ($ENV{'form.newpos'}) {
328: # change order
329:
330: my $newpos=$ENV{'form.newpos'}-1;
1.124 www 331: my $currentpos=$ENV{'form.currentpos'}-1;
1.125 www 332: my $i;
333: my @neworder=();
334: if ($newpos>$currentpos) {
335: # moving stuff up
336: for ($i=0;$i<$currentpos;$i++) {
337: $neworder[$i]=$Apache::lonratedt::order[$i];
338: }
339: for ($i=$currentpos;$i<$newpos;$i++) {
340: $neworder[$i]=$Apache::lonratedt::order[$i+1];
341: }
342: $neworder[$newpos]=$Apache::lonratedt::order[$currentpos];
343: for ($i=$newpos+1;$i<=$#Apache::lonratedt::order;$i++) {
344: $neworder[$i]=$Apache::lonratedt::order[$i];
345: }
346: } else {
347: # moving stuff down
348: for ($i=0;$i<$newpos;$i++) {
349: $neworder[$i]=$Apache::lonratedt::order[$i];
350: }
351: $neworder[$newpos]=$Apache::lonratedt::order[$currentpos];
352: for ($i=$newpos+1;$i<$currentpos+1;$i++) {
353: $neworder[$i]=$Apache::lonratedt::order[$i-1];
354: }
355: for ($i=$currentpos+1;$i<=$#Apache::lonratedt::order;$i++) {
356: $neworder[$i]=$Apache::lonratedt::order[$i];
357: }
358: }
359: @Apache::lonratedt::order=@neworder;
1.124 www 360: }
361: # store the changed version
1.123 www 362:
1.124 www 363: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.sequence');
364: if ($fatal) {
365: $r->print('<p><font color="red">'.$errtext.'</font></p>');
366: return;
1.123 www 367: }
1.124 www 368:
369: }
1.123 www 370:
1.10 www 371: # upload a file, if present
372: if (($ENV{'form.uploaddoc.filename'}) &&
373: ($ENV{'form.cmd'}=~/^upload_(\w+)/)) {
1.112 raeburn 374: if ( ($folder=~/^$1/) || ($1 eq 'default') ) {
1.10 www 375: # this is for a course, not a user, so set coursedoc flag
376: # probably the only place in the system where this should be "1"
1.126 albertel 377: my $url=&Apache::lonnet::userfileupload('uploaddoc',1,'docs');
1.10 www 378: my $ext='false';
379: if ($url=~/^http\:\/\//) { $ext='true'; }
380: $url=~s/\:/\:/g;
381: my $comment=$ENV{'form.comment'};
382: $comment=~s/\</\<\;/g;
383: $comment=~s/\>/\>\;/g;
384: $comment=~s/\:/\:/g;
1.17 www 385: if ($folder=~/^supplemental/) {
386: $comment=time.'___&&&___'.$ENV{'user.name'}.'___&&&___'.
387: $ENV{'user.domain'}.'___&&&___'.$comment;
388: }
1.10 www 389: my $newidx=$#Apache::lonratedt::resources+1;
390: $Apache::lonratedt::resources[$newidx]=
391: $comment.':'.$url.':'.$ext.':normal:res';
392: $Apache::lonratedt::order[$#Apache::lonratedt::order+1]=
393: $newidx;
1.104 albertel 394:
395: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.sequence');
396: if ($fatal) {
397: $r->print('<p><font color="red">'.$errtext.'</font></p>');
398: return;
399: }
1.10 www 400: }
401: }
1.8 www 402: if ($ENV{'form.cmd'}) {
1.10 www 403: my ($cmd,$idx)=split(/\_/,$ENV{'form.cmd'});
404: if ($cmd eq 'del') {
1.128 albertel 405: my (undef,$url)=split(':',$Apache::lonratedt::resources[$Apache::lonratedt::order[$idx]]);
406: if ($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) {
407: &Apache::lonnet::removeuploadedurl($url);
408: }
1.10 www 409: for (my $i=$idx;$i<$#Apache::lonratedt::order;$i++) {
410: $Apache::lonratedt::order[$i]=
411: $Apache::lonratedt::order[$i+1];
412: }
413: $#Apache::lonratedt::order--;
414: } elsif ($cmd eq 'up') {
1.38 www 415: if (($idx) && (defined($Apache::lonratedt::order[$idx-1]))) {
1.10 www 416: my $i=$Apache::lonratedt::order[$idx-1];
417: $Apache::lonratedt::order[$idx-1]=
418: $Apache::lonratedt::order[$idx];
419: $Apache::lonratedt::order[$idx]=$i;
1.38 www 420: }
1.10 www 421: } elsif ($cmd eq 'down') {
1.38 www 422: if (defined($Apache::lonratedt::order[$idx+1])) {
1.10 www 423: my $i=$Apache::lonratedt::order[$idx+1];
424: $Apache::lonratedt::order[$idx+1]=
425: $Apache::lonratedt::order[$idx];
426: $Apache::lonratedt::order[$idx]=$i;
1.38 www 427: }
1.36 www 428: } elsif ($cmd eq 'rename') {
429: my ($rtitle,@rrest)=split(/\:/,
430: $Apache::lonratedt::resources[
431: $Apache::lonratedt::order[$idx]]);
1.38 www 432: my $comment=
433: &HTML::Entities::decode($ENV{'form.title'});
1.36 www 434: $comment=~s/\</\<\;/g;
435: $comment=~s/\>/\>\;/g;
436: $comment=~s/\:/\:/g;
437: $Apache::lonratedt::resources[
438: $Apache::lonratedt::order[$idx]]=
439: $comment.':'.join(':',@rrest);
440:
1.10 www 441: }
442: # Store the changed version
1.104 albertel 443: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
444: $folder.'.sequence');
445: if ($fatal) {
446: $r->print('<p><font color="red">'.$errtext.'</font></p>');
447: return;
448: }
1.8 www 449: }
1.11 www 450: # Group import/search
451: if ($ENV{'form.importdetail'}) {
1.73 bowersj2 452: my @imports;
453: foreach (split(/\&/,$ENV{'form.importdetail'})) {
454: if (defined($_)) {
455: my ($name,$url)=split(/\=/,$_);
456: $name=&Apache::lonnet::unescape($name);
457: $url=&Apache::lonnet::unescape($url);
458: push @imports, $name, $url;
459: }
460: }
1.11 www 461: # Store the changed version
1.104 albertel 462: ($errtext,$fatal)=group_import($coursenum, $coursedom, $folder,
463: @imports);
464: if ($fatal) {
465: $r->print('<p><font color="red">'.$errtext.'</font></p>');
466: return;
467: }
1.11 www 468: }
1.53 www 469: # Loading a complete map
470: if (($ENV{'form.importmap'}) && ($ENV{'form.loadmap'})) {
1.104 albertel 471: foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$ENV{'form.importmap'}))) {
1.53 www 472: my $idx=$#Apache::lonratedt::resources;
473: $idx++;
474: $Apache::lonratedt::resources[$idx]=$_;
475: $Apache::lonratedt::order
1.104 albertel 476: [$#Apache::lonratedt::order+1]=$idx;
477: }
1.53 www 478:
479: # Store the changed version
1.104 albertel 480: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
481: $folder.'.sequence');
482: if ($fatal) {
483: $r->print('<p><font color="red">'.$errtext.'</font></p>');
484: return;
485: }
1.53 www 486: }
1.16 www 487: }
488: # ---------------------------------------------------------------- End commands
1.7 www 489: # ---------------------------------------------------------------- Print screen
1.10 www 490: my $idx=0;
491: $r->print('<table>');
492: foreach (@Apache::lonratedt::order) {
493: my ($name,$url)=split(/\:/,$Apache::lonratedt::resources[$_]);
494: unless ($name) { $name=(split(/\//,$url))[-1]; }
1.106 www 495: unless ($name) { next; }
1.112 raeburn 496: $r->print(&entryline($idx,$name,$url,$folder,$allowed,$_,$coursenum));
1.10 www 497: $idx++;
498: }
1.131 www 499: unless ($idx) {
500: $r->print('<tr><td>'.&mt('Currently no documents.').'</td></tr>');
501: }
1.10 www 502: $r->print('</table>');
1.7 www 503: }
504: }
1.1 www 505:
1.8 www 506: # --------------------------------------------------------------- An entry line
507:
508: sub entryline {
1.112 raeburn 509: my ($index,$title,$url,$folder,$allowed,$residx,$coursenum)=@_;
1.38 www 510: $title=~s/\&colon\;/\:/g;
511: $title=&HTML::Entities::encode(&HTML::Entities::decode(
1.109 albertel 512: &Apache::lonnet::unescape($title)),'"<>&\'');
1.38 www 513: my $renametitle=$title;
514: my $foldertitle=$title;
1.122 www 515: my $orderidx=$Apache::lonratedt::order[$index];
1.109 albertel 516: if ($title=~ /^(\d+)___&&&___(\w+)___&&&___(\w+)___&&&___(.*)$/ ) {
517: $foldertitle=&Apache::lontexconvert::msgtexconverted($4);
518: $renametitle=$4;
519: $title='<i>'.&Apache::lonlocal::locallocaltime($1).'</i> '.
520: &Apache::loncommon::plainname($2,$3).': <br />'.
521: $foldertitle;
522: }
1.38 www 523: $renametitle=~s/\"\;/\\\"/g;
1.8 www 524: my $line='<tr>';
525: # Edit commands
1.120 www 526: my $folderpath;
527: if ($ENV{'form.folderpath'}) {
528: $folderpath=&Apache::lonnet::escape($ENV{'form.folderpath'});
529: # $htmlfoldername=&HTML::Entities::encode($ENV{'form.foldername'},'<>&"');
530: }
1.109 albertel 531: if ($allowed) {
1.123 www 532: my $incindex=$index+1;
533: my $selectbox='';
534: if ($folder!~/^supplemental/) {
535: $selectbox=
1.124 www 536: '<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
1.123 www 537: '<select name="newpos" onChange="this.form.submit()">';
538: for (my $i=1;$i<=$#Apache::lonratedt::order+1;$i++) {
539: if ($i==$incindex) {
540: $selectbox.='<option value="" selected="1">('.$i.')</option>';
541: } else {
542: $selectbox.='<option value="'.$i.'">'.$i.'</option>';
543: }
544: }
545: $selectbox.='</select>';
546: }
1.119 www 547: my %lt=&Apache::lonlocal::texthash(
548: 'up' => 'Move Up',
1.109 albertel 549: 'dw' => 'Move Down',
550: 'rm' => 'Remove',
551: 'rn' => 'Rename');
552: $line.=(<<END);
1.121 www 553: <form name="entry_$index" action="/adm/coursedocs" method="post">
554: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.122 www 555: <input type="hidden" name="setparms" value="$orderidx" />
1.54 www 556: <td><table border='0' cellspacing='2' cellpadding='0'>
557: <tr><td bgcolor="#DDDDDD">
1.115 albertel 558: <a href='/adm/coursedocs?cmd=up_$index&folderpath=$folderpath'>
1.90 www 559: <img src="${iconpath}move_up.gif" alt='$lt{'up'}' border='0' /></a></td></tr>
1.54 www 560: <tr><td bgcolor="#DDDDDD">
1.115 albertel 561: <a href='/adm/coursedocs?cmd=down_$index&folderpath=$folderpath'>
1.90 www 562: <img src="${iconpath}move_down.gif" alt='$lt{'dw'}' border='0' /></a></td></tr>
1.123 www 563: </table></td>
564: <td>$selectbox
565: </td><td bgcolor="#DDDDDD">
1.115 albertel 566: <a href='javascript:removeres("$folderpath","$index","$renametitle");'>
1.90 www 567: <font size="-2" color="#990000">$lt{'rm'}</font></a>
1.115 albertel 568: <a href='javascript:changename("$folderpath","$index","$renametitle");'>
1.90 www 569: <font size="-2" color="#009900">$lt{'rn'}</font></a></td>
1.8 www 570: END
571: }
1.16 www 572: # Figure out what kind of a resource this is
573: my ($extension)=($url=~/\.(\w+)$/);
574: my $uploaded=($url=~/^\/*uploaded\//);
1.97 albertel 575: my $icon=&Apache::loncommon::icon($url);
1.17 www 576: my $isfolder=0;
1.114 albertel 577: my $folderarg;
1.16 www 578: if ($uploaded) {
1.135 albertel 579: if ($extension eq 'sequence') {
580: $icon=$iconpath.'/folder_closed.gif';
581: $url=~/$coursenum\/([\/\w]+)\.sequence$/;
582: $url='/adm/coursedocs?';
583: $folderarg=$1;
584: $isfolder=1;
585: } else {
586: &Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
587: }
1.16 www 588: }
1.18 www 589: $url=~s/^http\&colon\;\/\//\/adm\/wrapper\/ext\//;
1.113 albertel 590: if ((!$isfolder) && ($residx) && ($folder!~/supplemental/)) {
591: my $symb=&Apache::lonnet::symbclean(
1.50 www 592: &Apache::lonnet::declutter('uploaded/'.
593: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}.'/'.
594: $ENV{'course.'.$ENV{'request.course.id'}.'.num'}.'/'.$folder.
595: '.sequence').
596: '___'.$residx.'___'.
1.113 albertel 597: &Apache::lonnet::declutter($url));
598: (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
599: $url=&Apache::lonnet::clutter($url);
1.127 albertel 600: if ($url=~/^\/*uploaded\//) {
601: $url=~/\.(\w+)$/;
602: my $embstyle=&Apache::loncommon::fileembstyle($1);
603: if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
604: $url='/adm/wrapper'.$url;
605: } elsif ($embstyle eq 'ssi') {
606: #do nothing with these
607: } elsif ($url!~/\.(sequence|page)$/) {
608: $url='/adm/coursedocs/showdoc'.$url;
609: }
610: }
1.113 albertel 611: $url.=(($url=~/\?/)?'&':'?').'symb='.&Apache::lonnet::escape($symb);
1.50 www 612: }
1.120 www 613: my $parameterset=' ';
1.114 albertel 614: if ($isfolder) {
615: my $foldername=&Apache::lonnet::escape($foldertitle);
616: my $folderpath=$ENV{'form.folderpath'};
617: if ($folderpath) { $folderpath.='&' };
618: $folderpath.=$folderarg.'&'.$foldername;
619: $url.='folderpath='.&Apache::lonnet::escape($folderpath);
1.120 www 620: $parameterset=&mt('Randomly Pick: ').
1.122 www 621: '<input type="text" size="4" name="randpick_'.$orderidx.'" value="'.
622: (&Apache::lonratedt::getparameter($orderidx,'parameter_randompick'))[0].'" />';
1.114 albertel 623: }
1.113 albertel 624: $line.='<td bgcolor="#FFFFBB"><a href="'.$url.'"><img src="'.$icon.
625: '" border="0"></a></td>'.
1.119 www 626: "<td bgcolor='#FFFFBB'><a href='$url'>$title</a></td>";
1.120 www 627: if (($allowed) && ($folder!~/^supplemental/)) {
628: my %lt=&Apache::lonlocal::texthash(
629: 'hd' => 'Hidden',
630: 'ec' => 'URL hidden',
631: 'sp' => 'Store Parameters');
1.122 www 632: my $enctext=
633: ((&Apache::lonratedt::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="1"':'');
634: my $hidtext=
635: ((&Apache::lonratedt::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="1"':'');
1.120 www 636: $line.=(<<ENDPARMS);
637: <td bgcolor="#BBBBFF"><font size='-2'>
1.122 www 638: <input type="checkbox" name="hidprs_$orderidx" $hidtext/> $lt{'hd'}</td>
1.120 www 639: <td bgcolor="#BBBBFF"><font size='-2'>
1.122 www 640: <input type="checkbox" name="encprs_$orderidx" $enctext/> $lt{'ec'}</td>
1.120 www 641: <td bgcolor="#BBBBFF"><font size="-2">$parameterset</font></td>
642: <td bgcolor="#BBBBFF"><font size='-2'>
1.121 www 643: <input type="submit" value="$lt{'sp'}" />
1.120 www 644: </font></td>
645: ENDPARMS
1.119 www 646: }
1.120 www 647: $line.="</form></tr>";
1.8 www 648: return $line;
649: }
650:
1.27 www 651: # ---------------------------------------------------------------- tie the hash
652:
653: sub tiehash {
1.136 albertel 654: my ($mode)=@_;
1.27 www 655: $hashtied=0;
656: if ($ENV{'request.course.fn'}) {
1.136 albertel 657: if ($mode eq 'write') {
658: if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db",
659: &GDBM_WRCREAT(),0640)) {
660: $hashtied=2;
661: }
662: } else {
663: if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db",
664: &GDBM_READER(),0640)) {
1.27 www 665: $hashtied=1;
1.136 albertel 666: }
667: }
1.27 www 668: }
669: }
670:
671: sub untiehash {
672: if ($hashtied) { untie %hash; }
673: $hashtied=0;
674: }
675:
1.29 www 676: # --------------------------------------------------------------- check on this
677:
678: sub checkonthis {
679: my ($r,$url,$level,$title)=@_;
680: $alreadyseen{$url}=1;
681: $r->rflush();
1.41 www 682: if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
1.108 albertel 683: $r->print("\n<br />");
1.29 www 684: for (my $i=0;$i<=$level*5;$i++) {
685: $r->print(' ');
686: }
687: $r->print('<a href="'.$url.'" target="cat">'.
688: ($title?$title:$url).'</a> ');
689: if ($url=~/^\/res\//) {
690: my $result=&Apache::lonnet::repcopy(
691: &Apache::lonnet::filelocation('',$url));
692: if ($result==OK) {
1.87 www 693: $r->print('<font color="green">'.&mt('ok').'</font>');
1.29 www 694: $r->rflush();
1.34 www 695: &Apache::lonnet::countacc($url);
696: $url=~/\.(\w+)$/;
697: if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
698: $r->print('<br />');
699: $r->rflush();
700: for (my $i=0;$i<=$level*5;$i++) {
701: $r->print(' ');
702: }
1.84 www 703: $r->print('- '.&mt('Rendering').': ');
1.69 albertel 704: my $oldpath=$ENV{'request.filename'};
705: $ENV{'request.filename'}=&Apache::lonnet::filelocation('',$url);
1.34 www 706: &Apache::lonxml::xmlparse($r,'web',
707: &Apache::lonnet::getfile(
1.35 albertel 708: &Apache::lonnet::filelocation('',$url)));
1.94 www 709: undef($Apache::lonhomework::parsing_a_problem);
1.69 albertel 710: $ENV{'request.filename'}=$oldpath;
1.34 www 711: if (($Apache::lonxml::errorcount) ||
712: ($Apache::lonxml::warningcount)) {
713: if ($Apache::lonxml::errorcount) {
1.98 www 714: $r->print('<img src="/adm/lonMisc/bomb.gif" /><font color="red"><b>'.
1.87 www 715: $Apache::lonxml::errorcount.' '.
716: &mt('error(s)').'</b></font> ');
1.34 www 717: }
718: if ($Apache::lonxml::warningcount) {
719: $r->print('<font color="blue">'.
1.84 www 720: $Apache::lonxml::warningcount.' '.
721: &mt('warning(s)').'</font>');
1.34 www 722: }
723: } else {
1.87 www 724: $r->print('<font color="green">'.&mt('ok').'</font>');
1.34 www 725: }
726: $r->rflush();
727: }
1.29 www 728: my $dependencies=
729: &Apache::lonnet::metadata($url,'dependencies');
730: foreach (split(/\,/,$dependencies)) {
731: if (($_=~/^\/res\//) && (!$alreadyseen{$_})) {
732: &checkonthis($r,$_,$level+1);
733: }
734: }
735: } elsif ($result==HTTP_SERVICE_UNAVAILABLE) {
1.84 www 736: $r->print('<font color="red"><b>'.&mt('connection down').'</b></font>');
1.29 www 737: } elsif ($result==HTTP_NOT_FOUND) {
1.100 www 738: unless ($url=~/\$/) {
739: $r->print('<font color="red"><b>'.&mt('not found').'</b></font>');
740: } else {
741: $r->print('<font color="yellow"><b>'.&mt('unable to verify variable URL').'</b></font>');
742: }
1.29 www 743: } else {
1.84 www 744: $r->print('<font color="red"><b>'.&mt('access denied').'</b></font>');
1.29 www 745: }
746: }
747: }
748: }
749:
1.1 www 750:
1.75 www 751: #
752: # -------------------------------------------------------------- Verify Content
753: #
754: sub verifycontent {
755: my $r=shift;
1.26 www 756: my $loaderror=&Apache::lonnet::overloaderror($r);
757: if ($loaderror) { return $loaderror; }
758:
759: $r->print('<html><head><title>Verify Content</title></head>'.
760: &Apache::loncommon::bodytag('Verify Course Documents'));
1.27 www 761: $hashtied=0;
1.30 www 762: undef %alreadyseen;
763: %alreadyseen=();
1.27 www 764: &tiehash();
765: foreach (keys %hash) {
1.28 www 766: if (($_=~/^src\_(.+)$/) && (!$alreadyseen{$hash{$_}})) {
1.29 www 767: &checkonthis($r,$hash{$_},0,$hash{'title_'.$1});
1.27 www 768: }
769: }
770: &untiehash();
1.108 albertel 771: $r->print('<h1>'.&mt('Done').'.</h1>'.'<a href="/adm/coursedocs">'.
772: &mt('Return to DOCS').'</a>');
1.75 www 773: }
774:
775: # -------------------------------------------------------------- Check Versions
776:
777: sub checkversions {
778: my $r=shift;
1.89 www 779: $r->print('<html><head><title>Check Versions</title></head>'.
1.26 www 780: &Apache::loncommon::bodytag('Check Course Document Versions'));
1.89 www 781: my $header='';
782: my $startsel='';
783: my $monthsel='';
784: my $weeksel='';
785: my $daysel='';
786: my $allsel='';
787: my %changes=();
788: my $starttime=0;
1.91 www 789: my $haschanged=0;
1.92 www 790: my %setversions=&Apache::lonnet::dump('resourceversions',
791: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
792: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
793:
794: $hashtied=0;
795: &tiehash();
796: my %newsetversions=();
1.91 www 797: if ($ENV{'form.setmostrecent'}) {
798: $haschanged=1;
1.92 www 799: foreach (keys %hash) {
800: if ($_=~/^ids\_(\/res\/.+)$/) {
1.93 www 801: $newsetversions{$1}='mostrecent';
1.92 www 802: }
803: }
1.91 www 804: } elsif ($ENV{'form.setcurrent'}) {
805: $haschanged=1;
1.92 www 806: foreach (keys %hash) {
807: if ($_=~/^ids\_(\/res\/.+)$/) {
1.93 www 808: my $getvers=&Apache::lonnet::getversion($1);
809: if ($getvers>0) {
810: $newsetversions{$1}=$getvers;
811: }
1.92 www 812: }
813: }
1.91 www 814: } elsif ($ENV{'form.setversions'}) {
815: $haschanged=1;
1.92 www 816: foreach (keys %ENV) {
817: if ($_=~/^form\.set_version_(.+)$/) {
818: my $src=$1;
819: if (($ENV{$_}) && ($ENV{$_} ne $setversions{$src})) {
820: $newsetversions{$src}=$ENV{$_};
821: }
822: }
823: }
1.91 www 824: }
825: if ($haschanged) {
1.92 www 826: if (&Apache::lonnet::put('resourceversions',\%newsetversions,
827: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
828: $ENV{'course.'.$ENV{'request.course.id'}.'.num'}) eq 'ok') {
829: $r->print('<h1>'.&mt('Your Version Settings have been Stored').'</h1>');
830: } else {
831: $r->print('<h1><font color="red">'.&mt('An Error Occured while Attempting to Store your Version Settings').'</font></h1>');
832: }
1.136 albertel 833: &mark_hash_old();
1.91 www 834: }
1.136 albertel 835: &changewarning($r,'');
1.89 www 836: if ($ENV{'form.timerange'} eq 'all') {
837: # show all documents
838: $header=&mt('All Documents in Course');
1.91 www 839: $allsel=1;
1.90 www 840: foreach (keys %hash) {
841: if ($_=~/^ids\_(\/res\/.+)$/) {
842: my $src=$1;
843: $changes{$src}=1;
844: }
845: }
1.89 www 846: } else {
847: # show documents which changed
848: %changes=&Apache::lonnet::dump
849: ('versionupdate',$ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
1.30 www 850: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1.89 www 851: my $firstkey=(keys %changes)[0];
852: unless ($firstkey=~/^error\:/) {
853: unless ($ENV{'form.timerange'}) {
854: $ENV{'form.timerange'}=604800;
855: }
856: my $seltext=&mt('during the last').' '.$ENV{'form.timerange'}.' '
857: .&mt('seconds');
858: if ($ENV{'form.timerange'}==-1) {
859: $seltext='since start of course';
860: $startsel='selected';
861: $ENV{'form.timerange'}=time;
862: }
863: $starttime=time-$ENV{'form.timerange'};
864: if ($ENV{'form.timerange'}==2592000) {
865: $seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
866: $monthsel='selected';
867: } elsif ($ENV{'form.timerange'}==604800) {
868: $seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
869: $weeksel='selected';
870: } elsif ($ENV{'form.timerange'}==86400) {
871: $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
872: $daysel='selected';
873: }
874: $header=&mt('Content changed').' '.$seltext;
875: } else {
876: $header=&mt('No content modifications yet.');
877: }
878: }
1.92 www 879: %setversions=&Apache::lonnet::dump('resourceversions',
880: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
881: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1.89 www 882: my %lt=&Apache::lonlocal::texthash
1.88 www 883: ('st' => 'Version changes since start of Course',
884: 'lm' => 'Version changes since last Month',
885: 'lw' => 'Version changes since last Week',
886: 'sy' => 'Version changes since Yesterday',
1.91 www 887: 'al' => 'All Resources (possibly large output)',
1.88 www 888: 'sd' => 'Display',
1.84 www 889: 'fi' => 'File',
890: 'md' => 'Modification Date',
1.87 www 891: 'mr' => 'Most recently published Version',
892: 've' => 'Version used in Course',
1.91 www 893: 'vu' => 'Set Version to be used in Course',
894: 'sv' => 'Set Versions to be used in Course according to Selections below',
895: 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
896: 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
1.84 www 897: 'di' => 'Differences');
1.89 www 898: $r->print(<<ENDHEADERS);
1.31 www 899: <form action="/adm/coursedocs" method="post">
1.91 www 900: <input type="hidden" name="versions" value="1" />
901: <input type="submit" name="setmostrecent" value="$lt{'sm'}" />
902: <input type="submit" name="setcurrent" value="$lt{'sc'}" /><hr />
1.31 www 903: <select name="timerange">
1.88 www 904: <option value='all' $allsel>$lt{'al'}</option>
1.84 www 905: <option value="-1" $startsel>$lt{'st'}</option>
906: <option value="2592000" $monthsel>$lt{'lm'}</option>
907: <option value="604800" $weeksel>$lt{'lw'}</option>
908: <option value="86400" $daysel>$lt{'sy'}</option>
1.31 www 909: </select>
1.91 www 910: <input type="submit" name="display" value="$lt{'sd'}" />
1.89 www 911: <h3>$header</h3>
1.91 www 912: <input type="submit" name="setversions" value="$lt{'sv'}" />
1.103 matthew 913: <table border="0">
1.31 www 914: ENDHEADERS
1.91 www 915: foreach (sort keys %changes) {
1.89 www 916: if ($changes{$_}>$starttime) {
917: my ($root,$extension)=($_=~/^(.*)\.(\w+)$/);
918: my $currentversion=&Apache::lonnet::getversion($_);
1.93 www 919: if ($currentversion<0) {
920: $currentversion=&mt('Could not be determined.');
921: }
1.89 www 922: my $linkurl=&Apache::lonnet::clutter($_);
923: $r->print(
1.103 matthew 924: '<tr><td colspan="5"><br /><br /><font size="+1"><b>'.
1.91 www 925: &Apache::lonnet::gettitle($linkurl).
1.103 matthew 926: '</b></font></td></tr>'.
927: '<tr><td> </td>'.
928: '<td colspan="4">'.
929: '<a href="'.$linkurl.'" target="cat">'.$linkurl.
930: '</a></td></tr>'.
931: '<tr><td></td>'.
932: '<td title="'.$lt{'md'}.'">'.
1.102 matthew 933: &Apache::lonlocal::locallocaltime(
934: &Apache::lonnet::metadata($root.'.'.$extension,
935: 'lastrevisiondate')
936: ).
1.103 matthew 937: '</td>'.
938: '<td title="'.$lt{'mr'}.'"><nobr>Most Recent: '.
939: '<font size="+1">'.$currentversion.'</font>'.
940: '</nobr></td>'.
941: '<td title="'.$lt{'ve'}.'"><nobr>In Course: '.
942: '<font size="+1">');
1.87 www 943: # Used in course
1.89 www 944: my $usedversion=$hash{'version_'.$linkurl};
1.93 www 945: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1.89 www 946: $r->print($usedversion);
947: } else {
948: $r->print($currentversion);
949: }
1.103 matthew 950: $r->print('</font></nobr></td><td title="'.$lt{'vu'}.'">'.
951: '<nobr>Use: ');
1.87 www 952: # Set version
1.92 www 953: $r->print(&Apache::loncommon::select_form($setversions{$linkurl},
1.89 www 954: 'set_version_'.$linkurl,
1.136 albertel 955: ('select_form_order' =>
956: ['',1..$currentversion,'mostrecent'],
957: '' => '',
1.93 www 958: 'mostrecent' => 'most recent',
1.89 www 959: map {$_,$_} (1..$currentversion))));
1.103 matthew 960: $r->print('</nobr></td></tr><tr><td></td>');
1.89 www 961: my $lastold=1;
962: for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
963: my $url=$root.'.'.$prevvers.'.'.$extension;
964: if (&Apache::lonnet::metadata($url,'lastrevisiondate')<
965: $starttime) {
966: $lastold=$prevvers;
967: }
968: }
1.103 matthew 969: #
970: # Code to figure out how many version entries should go in
971: # each of the four columns
972: my $entries_per_col = 0;
973: my $num_entries = ($currentversion-$lastold);
974: if ($num_entries % 4 == 0) {
975: $entries_per_col = $num_entries/4;
976: } else {
977: $entries_per_col = $num_entries/4 + 1;
978: }
979: my $entries_count = 0;
980: $r->print('<td valign="top"><font size="-2">');
981: my $cols_output = 1;
1.32 www 982: for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
1.89 www 983: my $url=$root.'.'.$prevvers.'.'.$extension;
1.103 matthew 984: $r->print('<nobr><a href="'.&Apache::lonnet::clutter($url).
1.91 www 985: '">'.&mt('Version').' '.$prevvers.'</a> ('.
1.103 matthew 986: &Apache::lonlocal::locallocaltime(
987: &Apache::lonnet::metadata($url,
988: 'lastrevisiondate')
989: ).
1.91 www 990: ')');
1.89 www 991: if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
1.33 www 992: $r->print(' <a href="/adm/diff?filename='.
1.89 www 993: &Apache::lonnet::clutter($root.'.'.$extension).
994: '&versionone='.$prevvers.
995: '">'.&mt('Diffs').'</a>');
996: }
1.103 matthew 997: $r->print('</nobr><br />');
998: if (++$entries_count % $entries_per_col == 0) {
999: $r->print('</font></td>');
1000: if ($cols_output != 4) {
1001: $r->print('<td valign="top"><font size="-2">');
1002: $cols_output++;
1003: }
1004: }
1.89 www 1005: }
1.103 matthew 1006: while($cols_output++ < 4) {
1007: $r->print('</font></td><td><font>')
1008: }
1009: $r->print('</font></td></tr>'."\n");
1.89 www 1010: }
1011: }
1.92 www 1012: $r->print('</table></form>');
1.89 www 1013: $r->print('<h1>'.&mt('Done').'.</h1>');
1014:
1015: &untiehash();
1.75 www 1016: }
1017:
1.136 albertel 1018: sub mark_hash_old {
1019: my $retie_hash=0;
1020: if ($hashtied) {
1021: $retie_hash=1;
1022: &untiehash();
1023: }
1024: &tiehash('write');
1025: $hash{'old'}=1;
1026: &untiehash();
1027: if ($retie_hash) { &tiehash(); }
1028: }
1029:
1030: sub is_hash_old {
1031: my $untie_hash=0;
1032: if (!$hashtied) {
1033: $untie_hash=1;
1034: &tiehash();
1035: }
1036: my $return=$hash{'old'};
1037: if ($untie_hash) { &untiehash(); }
1038: return $return;
1039: }
1040:
1.91 www 1041: sub changewarning {
1042: my ($r,$postexec)=@_;
1.136 albertel 1043: if (!&is_hash_old()) { return; }
1.91 www 1044: $r->print(
1045: '<script>function reinit(tf) { tf.submit();'.$postexec.' }</script>'.
1046: '<form method="post" action="/adm/roles" target="loncapaclient">'.
1.117 albertel 1047: '<input type="hidden" name="orgurl" value="/adm/coursedocs?folderpath='.
1048: &Apache::lonnet::escape($ENV{'form.folderpath'}).
1049: '" /><input type="hidden" name="selectrole" value="1" /><h3><font color="red">'.
1.91 www 1050: &mt('Changes will become active for your current session after').
1051: ' <input type="hidden" name="'.
1052: $ENV{'request.role'}.'" value="1" /><input type="button" value="'.
1053: &mt('re-initializing course').'" onClick="reinit(this.form)"/>'.&mt(', or the next time you log in.').
1054: $help{'Caching'}.'</font></h3></form>');
1055: }
1056:
1.75 www 1057: # ================================================================ Main Handler
1058: sub handler {
1059: my $r = shift;
1.82 www 1060: &Apache::loncommon::content_type($r,'text/html');
1.75 www 1061: $r->send_http_header;
1062: return OK if $r->header_only;
1063:
1064: # --------------------------------------------- Initialize help topics for this
1065: foreach ('Adding_Course_Doc','Main_Course_Documents',
1066: 'Adding_External_Resource','Navigate_Content',
1067: 'Adding_Folders','Docs_Overview', 'Load_Map',
1068: 'Supplemental', 'Score_Upload_Form',
1.130 www 1069: 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
1070: 'Check_Resource_Versions','Verify_Content') {
1.75 www 1071: $help{$_}=&Apache::loncommon::help_open_topic('Docs_'.$_);
1072: }
1073: # Composite help files
1074: $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
1075: 'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
1076: $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
1077: 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
1.86 albertel 1078: $help{'Simple Problem'} = &Apache::loncommon::help_open_topic(
1079: 'Option_Response_Simple');
1.75 www 1080: $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
1081: 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
1082: $help{'My Personal Info'} = &Apache::loncommon::help_open_topic(
1083: 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
1084: $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
1085:
1086: if ($ENV{'form.verify'}) {
1087: &verifycontent($r);
1088: } elsif ($ENV{'form.versions'}) {
1089: &checkversions($r);
1090: } elsif ($ENV{'form.dumpcourse'}) {
1091: &dumpcourse($r);
1.26 www 1092: } else {
1.7 www 1093: # is this a standard course?
1094:
1095: my $standard=($ENV{'request.course.uri'}=~/^\/uploaded\//);
1.15 www 1096: my $forcestandard;
1097: my $forcesupplement;
1098: my $script='';
1099: my $allowed;
1100: my $events='';
1.19 www 1101: my $showdoc=0;
1.15 www 1102: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.114 albertel 1103: ['folderpath']);
1104: if ($ENV{'form.folderpath'}) {
1105: my (@folderpath)=split('&',$ENV{'form.folderpath'});
1106: $ENV{'form.foldername'}=&Apache::lonnet::unescape(pop(@folderpath));
1107: $ENV{'form.folder'}=pop(@folderpath);
1.116 albertel 1108: }
1.21 www 1109: if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
1.127 albertel 1110: $showdoc='/'.$1;
1.21 www 1111: }
1112: unless ($showdoc) { # got called from remote
1.15 www 1113: $forcestandard=($ENV{'form.folder'}=~/^default_/);
1114: $forcesupplement=($ENV{'form.folder'}=~/^supplemental_/);
1.7 www 1115:
1.4 www 1116: # does this user have privileges to post, etc?
1.77 www 1117: $allowed=&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'});
1.15 www 1118: if ($allowed) {
1119: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
1120: $script=&Apache::lonratedt::editscript('simple');
1121: }
1122: } else { # got called in sequence from course
1123: $allowed=0;
1.49 www 1124: $script='</script>'.&Apache::lonmenu::registerurl(1,undef).'<script>';
1125: $events='onLoad="'.&Apache::lonmenu::loadevents.
1126: '" onUnload="'.&Apache::lonmenu::unloadevents.'"';
1.3 www 1127: }
1.4 www 1128:
1129: # get course data
1130: my $coursenum=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
1131: my $coursedom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
1132:
1.14 www 1133: # get personal data
1134:
1135: my $uname=$ENV{'user.name'};
1136: my $udom=$ENV{'user.domain'};
1137: my $plainname=&Apache::lonnet::escape(
1138: &Apache::loncommon::plainname($uname,$udom));
1139:
1.8 www 1140: # graphics settings
1.4 www 1141:
1.8 www 1142: $iconpath = $r->dir_config('lonIconsURL') . "/";
1143:
1.22 www 1144: my $now=time;
1.64 www 1145:
1.4 www 1146: # print screen
1.1 www 1147: $r->print(<<ENDDOCUMENT);
1148: <html>
1149: <head>
1150: <title>The LearningOnline Network with CAPA</title>
1.16 www 1151: <script>
1152: $script
1.20 www 1153: </script>
1.19 www 1154: ENDDOCUMENT
1155: if ($allowed) {
1156: $r->print(<<ENDNEWSCRIPT);
1.20 www 1157: <script>
1.16 www 1158: function makenewfolder(targetform,folderseq) {
1159: var foldername=prompt('Name of New Folder','New Folder');
1160: if (foldername) {
1161: targetform.importdetail.value=foldername+"="+folderseq;
1162: targetform.submit();
1163: }
1164: }
1165:
1.18 www 1166: function makenewext(targetname) {
1167: this.document.forms.extimport.useform.value=targetname;
1168: window.open('/adm/rat/extpickframe.html');
1169: }
1170:
1.62 www 1171: function makeexamupload() {
1172: var title=prompt('Listed Title for the Uploaded Score');
1173: if (title) {
1174: this.document.forms.newexamupload.importdetail.value=
1175: title+'=/res/lib/templates/examupload.problem';
1176: this.document.forms.newexamupload.submit();
1177: }
1178: }
1179:
1.22 www 1180: function makesmppage() {
1.38 www 1181: var title=prompt('Listed Title for the Page');
1182: if (title) {
1.22 www 1183: this.document.forms.newsmppg.importdetail.value=
1184: title+'=/adm/$udom/$uname/$now/smppg';
1185: this.document.forms.newsmppg.submit();
1.38 www 1186: }
1.22 www 1187: }
1188:
1.55 www 1189: function makesmpproblem() {
1190: var title=prompt('Listed Title for the Problem');
1191: if (title) {
1192: this.document.forms.newsmpproblem.importdetail.value=
1.63 www 1193: title+'=/res/lib/templates/simpleproblem.problem';
1.55 www 1194: this.document.forms.newsmpproblem.submit();
1195: }
1196: }
1197:
1.22 www 1198: function makebulboard() {
1.38 www 1199: var title=prompt('Listed Title for the Bulletin Board');
1200: if (title) {
1.22 www 1201: this.document.forms.newbul.importdetail.value=
1202: title+'=/adm/$udom/$uname/$now/bulletinboard';
1203: this.document.forms.newbul.submit();
1.38 www 1204: }
1.22 www 1205: }
1206:
1.101 www 1207: function makeabout() {
1208: var user=prompt("Enter user\@domain for User's 'About Me' Page");
1209: if (user) {
1210: var comp=new Array();
1211: comp=user.split('\@');
1212: if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
1213: if ((comp[0]) && (comp[1])) {
1214: this.document.forms.newaboutsomeone.importdetail.value=
1215: 'About '+user+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
1216: this.document.forms.newaboutsomeone.submit();
1217: }
1218: }
1219: }
1220: }
1221:
1.110 raeburn 1222: function makeims() {
1223: var caller = document.forms.ims.folder.value
1224: var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one"
1225: newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes")
1226: newWindow.location.href = newlocation
1227: }
1228:
1229:
1.18 www 1230: function finishpick() {
1231: var title=this.document.forms.extimport.title.value;
1232: var url=this.document.forms.extimport.url.value;
1233: var form=this.document.forms.extimport.useform.value;
1234: eval
1235: ('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+
1236: '";this.document.forms.'+form+'.submit();');
1.16 www 1237: }
1.36 www 1238:
1.115 albertel 1239: function changename(folderpath,index,oldtitle) {
1.36 www 1240: var title=prompt('New Title',oldtitle);
1241: if (title) {
1242: this.document.forms.renameform.title.value=title;
1243: this.document.forms.renameform.cmd.value='rename_'+index;
1.115 albertel 1244: this.document.forms.renameform.folderpath.value=folderpath;
1.54 www 1245: this.document.forms.renameform.submit();
1246: }
1247: }
1248:
1.115 albertel 1249: function removeres(folderpath,index,oldtitle) {
1.106 www 1250: if (confirm('Remove "'+oldtitle+'"?')) {
1.54 www 1251: this.document.forms.renameform.cmd.value='del_'+index;
1.115 albertel 1252: this.document.forms.renameform.folderpath.value=folderpath;
1.36 www 1253: this.document.forms.renameform.submit();
1254: }
1255: }
1.121 www 1256:
1.16 www 1257: </script>
1.42 www 1258:
1259: ENDNEWSCRIPT
1260: }
1261: # -------------------------------------------------------------------- Body tag
1262: $r->print('</head>'.
1.72 www 1263: &Apache::loncommon::bodytag('Course Documents','',$events,
1.99 www 1264: '','',$showdoc).
1.134 albertel 1265: &Apache::loncommon::help_open_menu('','','','',273,'RAT'));
1.42 www 1266: unless ($showdoc) {
1.81 www 1267: # -----------------------------------------------------------------------------
1268: my %lt=&Apache::lonlocal::texthash(
1269: 'uplm' => 'Upload a new main course document',
1270: 'upls' => 'Upload a new supplemental course document',
1271: 'impp' => 'Import a published document',
1272: 'spec' => 'Special documents',
1273: 'upld' => 'Upload Document',
1274: 'srch' => 'Search',
1275: 'impo' => 'Import',
1276: 'selm' => 'Select Map',
1277: 'load' => 'Load Map',
1278: 'newf' => 'New Folder',
1279: 'extr' => 'External Resource',
1280: 'syll' => 'Syllabus',
1281: 'navc' => 'Navigate Contents',
1282: 'sipa' => 'Simple Page',
1283: 'sipr' => 'Simple Problem',
1284: 'scuf' => 'Score Upload Form',
1285: 'bull' => 'Bulletin Board',
1.96 sakharuk 1286: 'mypi' => 'My Personal Info',
1.101 www 1287: 'abou' => 'About User',
1.110 raeburn 1288: 'imsf' => 'Import IMS package',
1.96 sakharuk 1289: 'file' => 'File',
1290: 'title' => 'Title',
1291: 'comment' => 'Comment'
1.81 www 1292: );
1293: # -----------------------------------------------------------------------------
1.42 www 1294: if ($allowed) {
1.74 www 1295: my $dumpbut=&dumpbutton();
1.88 www 1296: my %lt=&Apache::lonlocal::texthash(
1297: 'vc' => 'Verify Content',
1298: 'cv' => 'Check/Set Resource Versions',
1299: );
1.118 albertel 1300:
1301: my $folderpath=$ENV{'form.folderpath'};
1302: if (!$folderpath) {
1303: if ($ENV{'form.folder'} eq '' ||
1304: $ENV{'form.folder'} eq 'supplemental') {
1305: $folderpath='default&'.
1306: &Apache::lonnet::escape(&mt('Main Course Documents'));
1307: }
1308: }
1.42 www 1309: $r->print(<<ENDCOURSEVERIFY);
1.36 www 1310: <form name="renameform" method="post" action="/adm/coursedocs">
1311: <input type="hidden" name="title" />
1312: <input type="hidden" name="cmd" />
1.115 albertel 1313: <input type="hidden" name="folderpath" />
1.36 www 1314: </form>
1.39 www 1315: <form name="simpleedit" method="post" action="/adm/coursedocs">
1316: <input type=hidden name="importdetail" value="">
1.118 albertel 1317: <input type="hidden" name="folderpath" value="$folderpath" />
1.39 www 1318: </form>
1.26 www 1319: <form action="/adm/coursedocs" method="post" name="courseverify">
1.74 www 1320: <table bgcolor="#AAAAAA" width="100%" cellspacing="4" cellpadding="4">
1321: <tr><td bgcolor="#DDDDCC">
1.130 www 1322: <input type="submit" name="verify" value="$lt{'vc'}" />$help{'Verify_Content'}
1.74 www 1323: </td><td bgcolor="#DDDDCC">
1.130 www 1324: <input type="submit" name="versions" value="$lt{'cv'}" />$help{'Check_Resource_Versions'}
1.74 www 1325: $dumpbut
1326: </td></tr></table>
1.25 www 1327: </form>
1328: ENDCOURSEVERIFY
1.74 www 1329: $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc',
1.96 sakharuk 1330: &mt('Editing the Table of Contents for your Course')));
1.25 www 1331: }
1.17 www 1332: # --------------------------------------------------------- Standard documents
1.43 www 1333: $r->print('<table border=2 cellspacing=4 cellpadding=4>');
1.7 www 1334: if (($standard) && ($allowed) && (!$forcesupplement)) {
1.116 albertel 1335: $r->print('<tr><td bgcolor="#BBBBBB">');
1336: # '<h2>'.&mt('Main Course Documents').
1337: # ($allowed?' '.$help{'Main_Course_Documents'}:'').'</h2>');
1.7 www 1338: my $folder=$ENV{'form.folder'};
1.117 albertel 1339: if ($folder eq '' || $folder eq 'supplemental') {
1.112 raeburn 1340: $folder='default';
1.116 albertel 1341: $ENV{'form.folderpath'}='default&'.&Apache::lonnet::escape(&mt('Main Course Documents'));
1.112 raeburn 1342: }
1.51 www 1343: my $postexec='';
1344: if ($folder eq 'default') {
1345: $r->print('<script>this.window.name="loncapaclient";</script>');
1346: } else {
1.117 albertel 1347: #$postexec='self.close();';
1.51 www 1348: }
1.40 www 1349: $hadchanges=0;
1.7 www 1350: &editor($r,$coursenum,$coursedom,$folder,$allowed);
1.40 www 1351: if ($hadchanges) {
1.136 albertel 1352: &mark_hash_old()
1.40 www 1353: }
1.136 albertel 1354: &changewarning($r,$postexec);
1.16 www 1355: my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
1356: '.sequence';
1.8 www 1357: $r->print(<<ENDFORM);
1.43 www 1358: <table cellspacing=4 cellpadding=4><tr>
1.81 www 1359: <th bgcolor="#DDDDDD">$lt{'uplm'}</th>
1360: <th bgcolor="#DDDDDD">$lt{'impp'}</th>
1361: <th bgcolor="#DDDDDD">$lt{'spec'}</th>
1.11 www 1362: </tr>
1.16 www 1363: <tr><td bgcolor="#DDDDDD">
1.96 sakharuk 1364: $lt{'file'}:<br />
1.10 www 1365: <form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.59 www 1366: <input type="file" name="uploaddoc" size="40">
1.8 www 1367: <br />
1.96 sakharuk 1368: $lt{'title'}:<br />
1.11 www 1369: <input type="text" size="50" name="comment">
1.115 albertel 1370: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.10 www 1371: <input type="hidden" name="cmd" value="upload_default">
1.129 albertel 1372: <nobr>
1.81 www 1373: <input type="submit" value="$lt{'upld'}">
1.60 albertel 1374: $help{'Uploading_From_Harddrive'}
1.58 albertel 1375: </nobr>
1.60 albertel 1376: </form>
1.11 www 1377: </td>
1.16 www 1378: <td bgcolor="#DDDDDD">
1.39 www 1379: <form action="/adm/coursedocs" method="post" name="simpleeditdefault">
1.115 albertel 1380: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1381: <input type=button onClick="javascript:groupsearch()" value="$lt{'srch'}">
1.58 albertel 1382: <nobr>
1.115 albertel 1383: <input type=button onClick="javascript:groupimport();" value="$lt{'impo'}">
1.58 albertel 1384: $help{'Importing_LON-CAPA_Resource'}
1385: </nobr>
1.59 www 1386: <p>
1387: <hr />
1.68 bowersj2 1388: <input type="text" size="20" name="importmap"><br />
1389: <nobr><input type=button
1.52 www 1390: onClick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"
1.81 www 1391: value="$lt{'selm'}"> <input type="submit" name="loadmap" value="$lt{'load'}">
1.68 bowersj2 1392: $help{'Load_Map'}</nobr>
1.59 www 1393: </p>
1.52 www 1394: </form>
1.16 www 1395: </td><td bgcolor="#DDDDDD">
1.11 www 1396: <form action="/adm/coursedocs" method="post" name="newfolder">
1.115 albertel 1397: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.13 www 1398: <input type=hidden name="importdetail" value="">
1.58 albertel 1399: <nobr>
1.16 www 1400: <input name="newfolder" type="button"
1401: onClick="javascript:makenewfolder(this.form,'$folderseq');"
1.81 www 1402: value="$lt{'newf'}" />$help{'Adding_Folders'}
1.58 albertel 1403: </nobr>
1.11 www 1404: </form>
1405: <form action="/adm/coursedocs" method="post" name="newext">
1.115 albertel 1406: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.13 www 1407: <input type=hidden name="importdetail" value="">
1.58 albertel 1408: <nobr>
1.18 www 1409: <input name="newext" type="button" onClick="javascript:makenewext('newext');"
1.81 www 1410: value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
1.58 albertel 1411: </nobr>
1.11 www 1412: </form>
1413: <form action="/adm/coursedocs" method="post" name="newsyl">
1.115 albertel 1414: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.14 www 1415: <input type=hidden name="importdetail"
1416: value="Syllabus=/public/$coursedom/$coursenum/syllabus">
1.58 albertel 1417: <nobr>
1.81 www 1418: <input name="newsyl" type="submit" value="$lt{'syll'}" />
1.65 bowersj2 1419: $help{'Syllabus'}
1.58 albertel 1420: </nobr>
1421: </form>
1.17 www 1422: <form action="/adm/coursedocs" method="post" name="newnav">
1.115 albertel 1423: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.15 www 1424: <input type=hidden name="importdetail"
1425: value="Navigate Content=/adm/navmaps">
1.58 albertel 1426: <nobr>
1.81 www 1427: <input name="newnav" type="submit" value="$lt{'navc'}" />
1.47 www 1428: $help{'Navigate_Content'}
1.58 albertel 1429: </nobr>
1.22 www 1430: </form>
1431: <form action="/adm/coursedocs" method="post" name="newsmppg">
1.115 albertel 1432: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.22 www 1433: <input type=hidden name="importdetail" value="">
1.58 albertel 1434: <nobr>
1.81 www 1435: <input name="newsmppg" type="button" value="$lt{'sipa'}"
1.65 bowersj2 1436: onClick="javascript:makesmppage();" /> $help{'Simple Page'}
1.58 albertel 1437: </nobr>
1.55 www 1438: </form>
1439: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
1.115 albertel 1440: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.55 www 1441: <input type=hidden name="importdetail" value="">
1.58 albertel 1442: <nobr>
1.81 www 1443: <input name="newsmpproblem" type="button" value="$lt{'sipr'}"
1.65 bowersj2 1444: onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
1.62 www 1445: </nobr>
1446: </form>
1447: <form action="/adm/coursedocs" method="post" name="newexamupload">
1.115 albertel 1448: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.62 www 1449: <input type=hidden name="importdetail" value="">
1450: <nobr>
1.81 www 1451: <input name="newexamupload" type="button" value="$lt{'scuf'}"
1.62 www 1452: onClick="javascript:makeexamupload();" />
1.66 bowersj2 1453: $help{'Score_Upload_Form'}
1.58 albertel 1454: </nobr>
1.22 www 1455: </form>
1456: <form action="/adm/coursedocs" method="post" name="newbul">
1.115 albertel 1457: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.22 www 1458: <input type=hidden name="importdetail" value="">
1.58 albertel 1459: <nobr>
1.81 www 1460: <input name="newbulletin" type="button" value="$lt{'bull'}"
1.22 www 1461: onClick="javascript:makebulboard();" />
1.65 bowersj2 1462: $help{'Bulletin Board'}
1.58 albertel 1463: </nobr>
1464: </form>
1.12 www 1465: <form action="/adm/coursedocs" method="post" name="newaboutme">
1.115 albertel 1466: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.14 www 1467: <input type=hidden name="importdetail"
1468: value="$plainname=/adm/$udom/$uname/aboutme">
1.58 albertel 1469: <nobr>
1.81 www 1470: <input name="newaboutme" type="submit" value="$lt{'mypi'}" />
1.65 bowersj2 1471: $help{'My Personal Info'}
1.101 www 1472: </nobr>
1473: </form>
1474: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
1.115 albertel 1475: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.101 www 1476: <input type=hidden name="importdetail" value="">
1477: <nobr>
1478: <input name="newaboutsomeone" type="button" value="$lt{'abou'}"
1479: onClick="javascript:makeabout();" />
1.110 raeburn 1480: </nobr>
1481: </form>
1482: <form action="/adm/imsimportdocs" method="post" name="ims">
1.118 albertel 1483: <input type="hidden" name="folder" value="$folder" />
1.110 raeburn 1484: <input name="imsimport" type="button" value="$lt{'imsf'}" onClick="javascript:makeims();" />
1.58 albertel 1485: </nobr>
1486: </form>
1.11 www 1487: </td></tr>
1488: </table>
1.8 www 1489: ENDFORM
1.24 www 1490: $r->print('</td></tr>');
1.7 www 1491: }
1492: # ----------------------------------------------------- Supplemental documents
1493: if (!$forcestandard) {
1.116 albertel 1494: $r->print('<tr><td bgcolor="#BBBBBB">');
1495: # '<h2>'.&mt('Supplemental Course Documents').
1496: # ($allowed?' '.$help{'Supplemental'}:'').'</h2>');
1.7 www 1497: my $folder=$ENV{'form.folder'};
1.117 albertel 1498: unless ($folder=~/^supplemental/) {
1.116 albertel 1499: $folder='supplemental';
1.117 albertel 1500: }
1501: if ($folder =~ /^supplemental$/ &&
1502: $ENV{'form.folderpath'} =~ /^default\&/) {
1503: $ENV{'form.folderpath'}='supplemental&'.
1504: &Apache::lonnet::escape(&mt('Supplemental Course Documents'));
1.116 albertel 1505: }
1.7 www 1506: &editor($r,$coursenum,$coursedom,$folder,$allowed);
1.8 www 1507: if ($allowed) {
1.17 www 1508: my $folderseq=
1509: '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time.
1510: '.sequence';
1511:
1.8 www 1512: $r->print(<<ENDSUPFORM);
1.43 www 1513: <table cellspacing=4 cellpadding=4><tr>
1.81 www 1514: <th bgcolor="#DDDDDD">$lt{'upls'}</th>
1515: <th bgcolor="#DDDDDD">$lt{'spec'}</th>
1.17 www 1516: </tr>
1517: <tr><td bgcolor="#DDDDDD">
1.10 www 1518: <form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.59 www 1519: <input type="file" name="uploaddoc" size="40">
1.96 sakharuk 1520: <br />$lt{'comment'}:<br />
1.4 www 1521: <textarea cols=50 rows=4 name='comment'>
1522: </textarea>
1.115 albertel 1523: <br />
1524: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.10 www 1525: <input type="hidden" name="cmd" value="upload_supplemental">
1.58 albertel 1526: <nobr>
1.81 www 1527: <input type="submit" value="$lt{'upld'}">
1.58 albertel 1528: $help{'Uploading_From_Harddrive'}
1529: </nobr>
1530: </form>
1.17 www 1531: </td>
1532: <td bgcolor="#DDDDDD">
1.18 www 1533: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.115 albertel 1534: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.17 www 1535: <input type=hidden name="importdetail" value="">
1.58 albertel 1536: <nobr>
1.17 www 1537: <input name="newfolder" type="button"
1538: onClick="javascript:makenewfolder(this.form,'$folderseq');"
1.81 www 1539: value="$lt{'newf'}" /> $help{'Adding_Folders'}
1.58 albertel 1540: </nobr>
1.17 www 1541: </form>
1.18 www 1542: <form action="/adm/coursedocs" method="post" name="supnewext">
1.115 albertel 1543: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.17 www 1544: <input type=hidden name="importdetail" value="">
1.58 albertel 1545: <nobr>
1.18 www 1546: <input name="newext" type="button"
1547: onClick="javascript:makenewext('supnewext');"
1.81 www 1548: value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
1.58 albertel 1549: </nobr>
1.17 www 1550: </form>
1.18 www 1551: <form action="/adm/coursedocs" method="post" name="supnewsyl">
1.115 albertel 1552: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.17 www 1553: <input type=hidden name="importdetail"
1554: value="Syllabus=/public/$coursedom/$coursenum/syllabus">
1.58 albertel 1555: <nobr>
1.81 www 1556: <input name="newsyl" type="submit" value="$lt{'syll'}" />
1.65 bowersj2 1557: $help{'Syllabus'}
1.58 albertel 1558: </nobr>
1559: </form>
1.18 www 1560: <form action="/adm/coursedocs" method="post" name="subnewaboutme">
1.115 albertel 1561: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.17 www 1562: <input type=hidden name="importdetail"
1563: value="$plainname=/adm/$udom/$uname/aboutme">
1.58 albertel 1564: <nobr>
1.81 www 1565: <input name="newaboutme" type="submit" value="$lt{'mypi'}" />
1.65 bowersj2 1566: $help{'My Personal Info'}
1.58 albertel 1567: </nobr>
1568: </form>
1.17 www 1569: </td></tr>
1.24 www 1570: </table></td></tr>
1.8 www 1571: ENDSUPFORM
1572: }
1.7 www 1573: }
1.18 www 1574: if ($allowed) {
1575: $r->print('<form name="extimport"><input type="hidden" name="title"><input type="hidden" name="url"><input type="hidden" name="useform"></form>');
1576: }
1.24 www 1577: $r->print('</table>');
1.19 www 1578: } else {
1579: # -------------------------------------------------------- This is showdoc mode
1.81 www 1580: $r->print("<h1>".&mt('Uploaded Document').'</h1><p>'.
1581: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><p><table>".
1582: &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table></p>');
1.19 www 1583: }
1.26 www 1584: }
1.95 www 1585: $r->print('</body></html>');
1.26 www 1586: return OK;
1.1 www 1587: }
1588:
1589: 1;
1590: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>