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