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