# The LearningOnline Network
# Documents
#
# $Id: lonextresedit.pm,v 1.1 2012/11/27 23:34:41 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
#
# LON-CAPA is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# LON-CAPA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LON-CAPA; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# /home/httpd/html/adm/gpl.txt
#
# http://www.lon-capa.org/
#
package Apache::lonextresedit;
use strict;
use Apache::Constants qw(:common :http);
use HTML::Entities;
use Apache::lonlocal;
use Apache::lonnet;
use Apache::loncommon;
use Apache::lonhtmlcommon;
use Apache::lonuserstate;
use LONCAPA::map();
use LONCAPA qw(:DEFAULT :match);
sub handler {
my $r=shift;
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
return OK if $r->header_only;
# Check for access
if (! &Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
$env{'user.error.msg'}=
$r->uri.":mdc:0:0:Cannot modify course content.";
return HTTP_NOT_ACCEPTABLE;
}
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
my $chome = $env{'course.'.$env{'request.course.id'}.'.home'};
my ($supplementalflag,$updated,$output,$errormsg,$residx,$url,$title,$symb);
if ((($env{'form.folderpath'} =~ /^supplemental/) && ($env{'form.suppurl'})) ||
($env{'form.symb'} =~ /^uploaded/)) {
$supplementalflag = 1;
($updated,$output,$errormsg,$residx,$url,$title,$symb) =
&process_changes($supplementalflag,$cdom,$cnum,$chome);
if ($supplementalflag) {
if ($url ne $env{'form.suppurl'}) {
$env{'form.suppurl'} = $url;
}
if ($title ne $env{'form.title'}) {
$env{'form.title'} = $title;
}
} else {
if ($symb ne $env{'form.symb'}) {
$env{'form.symb'} = $symb;
}
}
} else {
$errormsg = &mt('Information about external resource to edit is missing.');
}
if ($updated) {
$output = &Apache::lonhtmlcommon::confirm_success(&mt('External Resource updated'));
}
if ($errormsg) {
$errormsg = '
'.$errormsg.'
';
}
my $js = &Apache::lonhtmlcommon::scripttag(&extedit_javascript());
my $pathitem = '';
$r->print(&Apache::loncommon::start_page('External Resource Editor',$js).
'