--- loncom/interface/lonwishlistdisplay.pm 2011/01/27 14:38:44 1.1 +++ loncom/interface/lonwishlistdisplay.pm 2021/12/24 00:48:30 1.7 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to display the wishlist (handler) # -# $Id: lonwishlistdisplay.pm,v 1.1 2011/01/27 14:38:44 wenzelju Exp $ +# $Id: lonwishlistdisplay.pm,v 1.7 2021/12/24 00:48:30 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -29,7 +29,7 @@ package Apache::lonwishlistdisplay; use strict; -use Apache::Constants qw(:common); +use Apache::Constants qw(:common :http); use Apache::lonnet; use Apache::loncommon(); use Apache::lonhtmlcommon; @@ -48,8 +48,36 @@ my %TreeHash; # ----------------------------------------------------- Main Handler, package lonwishlistdisplay sub handler { my ($r) = @_; - &Apache::loncommon::content_type($r,'text/html'); - $r->send_http_header; + + if ($r->header_only) { + &Apache::loncommon::content_type($r,'text/html'); + $r->send_http_header; + return OK; + } + + if ($env{'user.adv'}) { + &Apache::loncommon::content_type($r,'text/html'); + $r->send_http_header; + } else { + $env{'user.error.msg'}= + "/adm/wishlist:bre:0:0:No rights to access Stored Links"; + return HTTP_NOT_ACCEPTABLE; + } + + my $clientip = &Apache::lonnet::get_requestor_ip($r); + my ($blocked,$blocktext) = + &Apache::loncommon::blocking_status('wishlist',$clientip); + if ($blocked) { + &Apache::lonhtmlcommon::clear_breadcrumbs(); + &Apache::lonhtmlcommon::add_breadcrumb( + { href => '/adm/wishlist', + text => 'Stored Links'}); + my $startPage = &Apache::loncommon::start_page('Stored Links'); + my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Stored Links','Wishlist'); + my $endpage = &Apache::loncommon::end_page(); + $r->print($startPage.$breadcrumbs.$blocktext); + return OK; + } if (&Apache::lonwishlist::getWishlist() ne 'error') { # get wishlist entries from user-data db-file and build a tree out of these entries @@ -63,12 +91,12 @@ sub handler { $root = &Apache::lonwishlist::newEntry($root, $env{'form.title'}, $env{'form.path'}, $env{'form.note'}); } - # get unprocessed_cgi (i.e. marked entries, mode ...) - &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['action','mark','markedToMove','mode','newtitle','note','rat']); + # get unprocessed_cgi (i.e. marked entries, mode ...) + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['action','mark','markedToMove','mode','newtitle','note','rat','setTitle','setPath']); # change the order of entries within a level, that means sorting the entries my $changeOrder = 0; - if (defined $env{'form.sel'}) { + if (defined($env{'form.sel'})) { my @sel = &Apache::loncommon::get_env_multiple('form.sel'); my $indexNode; my $at; @@ -80,37 +108,35 @@ sub handler { } if ($at ne '') { $changeOrder = 1; - $root = &Apache::lonwishlist::sortEntries($root, $indexNode,$at); + $root = &Apache::lonwishlist::sortEntries($root, $indexNode,$at); } } # get all marked (checkboxes) entries my @marked = (); - if (defined $env{'form.mark'}) { + if (defined($env{'form.mark'})) { @marked = &Apache::loncommon::get_env_multiple('form.mark'); } # move entries from one folder to another - if (defined $env{'form.markedToMove'}) { + if (defined($env{'form.markedToMove'})) { my $markedToMove = $env{'form.markedToMove'}; my @ToMove = split(/\,/,$markedToMove); my $moveTo = $env{'form.mark'}; - if (defined $moveTo){ - $root = &Apache::lonwishlist::moveEntries($root, \@ToMove,$moveTo); + if (defined($moveTo)) { + $root = &Apache::lonwishlist::moveEntries($root, \@ToMove,$moveTo); } $changeOrder = 1; - } # delete entries if ($env{'form.action'} eq 'delete') { $root = &Apache::lonwishlist::deleteEntries($root, \@marked); } - # get all titles and notes and save them # only save, if user wants to save changes - # do not save, when current action is 'delete' or 'sort' or 'move' + # do not save, when current action is 'delete' or 'sort' or 'move' my @newTitles = (); my @newPaths = (); my @newNotes = (); @@ -143,24 +169,23 @@ sub handler { my $page; if ($env{'form.mode'} eq 'edit') { $page = &Apache::lonwishlist::makePage($root, "edit"); - } - elsif ($env{'form.mode'} eq 'move') { + } elsif ($env{'form.mode'} eq 'move') { $page = &Apache::lonwishlist::makePage($root, "move", \@marked); - } - elsif ($env{'form.mode'} eq 'import') { + } elsif ($env{'form.mode'} eq 'import') { $page = &Apache::lonwishlist::makePageImport($root, $env{'form.rat'}); - } - elsif ($env{'form.mode'} eq 'set') { + } elsif ($env{'form.mode'} eq 'newLink') { + $page = &Apache::lonwishlist::makePopUpNewLink($env{'form.setTitle'},$env{'form.setPath'}); + } elsif ($env{'form.mode'} eq 'newFolder') { + $page = &Apache::lonwishlist::makePopUpNewFolder(); + } elsif ($env{'form.mode'} eq 'set') { $page = &Apache::lonwishlist::makePageSet(); - } - else { + } else { $page = &Apache::lonwishlist::makePage($root, "view"); } @marked = (); $r->print($page); - } - # An error occured, print an error-page - else { + } else { + # An error occurred, print an error-page my $errorPage = &Apache::lonwishlist::makeErrorPage(); $r->print($errorPage); }