--- loncom/interface/lonwishlist.pm 2012/05/22 16:31:38 1.14 +++ loncom/interface/lonwishlist.pm 2012/06/07 02:28:04 1.15 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Utility-routines for wishlist # -# $Id: lonwishlist.pm,v 1.14 2012/05/22 16:31:38 bisitz Exp $ +# $Id: lonwishlist.pm,v 1.15 2012/06/07 02:28:04 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -50,7 +50,7 @@ use Apache::lonnet; use Apache::loncommon(); use Apache::lonhtmlcommon; use Apache::lonlocal; -use LONCAPA; +use LONCAPA qw(:DEFAULT :match); use Tree; @@ -466,11 +466,13 @@ sub getNodesToArray { Recursive call starting with all children of the root of the tree (parameter nodes is reference to an array containing the nodes of the current level). -=item * &wishlistImport(nodes) +=item * &wishlistImport(nodes, numskipped) Returns the table-HTML-markup for the wishlist in mode "import". - Recursive call starting with all children of the root of the tree (parameter nodes is reference to an array containing the nodes of the current level). - + Recursive call starting with all children of the root of the tree (parameter nodes is reference to an array containing the nodes of the current level). + Side effect: increments the scalar ref: numskipped with a count of items in + Stored Links unavailable for selection, (e.g., now marked obsolete or + inaccessible in Community context). =item * &makePage(mode, marked) @@ -810,7 +812,9 @@ sub JSforWishlist { function setChecked(row,checked) { var childCHECK = document.getElementById(row.id.replace('row','check')); - childCHECK.checked = checked; + if (!childCHECK.disabled) { + childCHECK.checked = checked; + } } function getPreviousFolderRows(row) { @@ -1010,14 +1014,18 @@ sub JSforWishlist { function checkAll() { var checkboxes = document.getElementsByName('check'); for (var i = 0; i < checkboxes.length; i++) { - checkboxes[i].checked = "checked"; + if (!checkboxes[i].disabled) { + checkboxes[i].checked = "checked"; + } } } function uncheckAll() { var checkboxes = document.getElementsByName('check'); for (var i = 0; i < checkboxes.length; i++) { - checkboxes[i].checked = ""; + if (!checkboxes[i].disabled) { + checkboxes[i].checked = ""; + } } } @@ -1336,10 +1344,30 @@ my $wishlistHTMLimport; my $indent = $indentConst; my $form = 1; sub wishlistImport { - my $nodes = shift; + my ($nodes,$numskipped) = @_; + + my ($is_community,%nopick); + if ($env{'request.course.id'}) { + if (&Apache::loncommon::course_type() eq 'Community') { + $is_community = 1; + } + } foreach my $n (@$nodes) { my $index = $n->value()->nindex(); + if ($n->value()->path() =~ m{^(/res/$match_domain/$match_username/)}) { + if ($is_community) { + unless (&Apache::lonnet::allowed('bro',$n->value()->path())) { + $nopick{$n->value()->path()} = $n->value()->title(); + $$numskipped ++; + } + } else { + unless (&Apache::lonnet::allowed('bre',$n->value()->path())) { + $nopick{$n->value()->path()} = $n->value()->title(); + $$numskipped ++; + } + } + } # start row, use data_table routines to set class to LC_even or LC_odd automatically. this row contains a checkbox, the title and the note-icon. # only display the top level entries on load @@ -1348,13 +1376,22 @@ sub wishlistImport { # checkboxes - $wishlistHTMLimport .= '
'. - &mt('Please note that you can use the checkboxes corresponding to a folder to '. - 'easily check all links within this folder.'. - ' The folder structure itself cannot be imported.'). - ' '.&mt('All checked links will be imported into the current folder of your course.'). - '
'; + ''. - &mt('Please note that you can use the checkboxes corresponding to a folder to '. - 'easily check all links within this folder.'. - ' The folder structure itself cannot be imported.'). - '
'; + ''.&mt('Note: where a Stored Link is unavailable for import in the current context it is grayed out.').'
'; + } $wishlistHTMLimport = ''; $inner .= '';