[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface londocs.pm
raeburn
raeburn at source.lon-capa.org
Tue Nov 29 19:41:25 EST 2016
raeburn Wed Nov 30 00:41:25 2016 EDT
Modified files: (Branch: version_2_11_X)
/loncom/interface londocs.pm
Log:
- For 2.11
- Backport 1.611, 1.612, 1.613, 1.614, 1.615, 1.616, 1.617, 1.618
(calls to: &editing_js(), &editor(), &entryline(), and
lonextresedit::extedit_form() omit LTI-related args).
-------------- next part --------------
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.484.2.66 loncom/interface/londocs.pm:1.484.2.67
--- loncom/interface/londocs.pm:1.484.2.66 Mon Oct 31 20:48:30 2016
+++ loncom/interface/londocs.pm Wed Nov 30 00:41:24 2016
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.484.2.66 2016/10/31 20:48:30 raeburn Exp $
+# $Id: londocs.pm,v 1.484.2.67 2016/11/30 00:41:24 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -139,7 +139,43 @@
return $title;
}
-
+sub default_folderpath {
+ my ($coursenum,$coursedom,$navmapref) = @_;
+ return unless ($coursenum && $coursedom && ref($navmapref));
+# Check if entire course is hidden and/or encrypted
+ my ($hiddenmap,$encryptmap,$folderpath,$hiddentop);
+ my $toplevel = "uploaded/$coursedom/$coursenum/default.sequence";
+ unless (ref($$navmapref)) {
+ $$navmapref = Apache::lonnavmaps::navmap->new();
+ }
+ if (ref($$navmapref)) {
+ if (lc($$navmapref->get_mapparam(undef,$toplevel,"0.hiddenresource")) eq 'yes') {
+ my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
+ my @resources = $$navmapref->retrieveResources($toplevel,$filterFunc,1,1);
+ unless (@resources) {
+ $hiddenmap = 1;
+ unless ($env{'request.role.adv'}) {
+ $hiddentop = 1;
+ if ($env{'form.folder'}) {
+ undef($env{'form.folder'});
+ }
+ }
+ }
+ }
+ if (lc($$navmapref->get_mapparam(undef,$toplevel,"0.encrypturl")) eq 'yes') {
+ $encryptmap = 1;
+ }
+ }
+ unless ($hiddentop) {
+ $folderpath='default&'.&escape(&mt('Main Content')).
+ '::'.$hiddenmap.':'.$encryptmap.'::';
+ }
+ if (wantarray) {
+ return ($folderpath,$hiddentop);
+ } else {
+ return $folderpath;
+ }
+}
sub dumpcourse {
my ($r) = @_;
@@ -791,12 +827,14 @@
}
sub docs_change_log {
- my ($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath)=@_;
+ my ($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath,$canedit)=@_;
my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/);
+ my $navmap;
my $js = '<script type="text/javascript">'."\n".
'// <![CDATA['."\n".
&Apache::loncommon::display_filter_js('docslog')."\n".
- &editing_js($env{'user.domain'},$env{'user.name'},$supplementalflag)."\n".
+ &editing_js($env{'user.domain'},$env{'user.name'},$supplementalflag,
+ $coursedom,$coursenum,$canedit,\$navmap)."\n".
&history_tab_js()."\n".
&Apache::lonratedt::editscript('simple')."\n".
'// ]]>'."\n".
@@ -812,8 +850,9 @@
}
my $folderpath=$env{'form.folderpath'};
if ($folderpath eq '') {
- $folderpath = 'default&'.&escape(&mt('Main Content').':::::');
+ $folderpath = &default_folderpath($coursenum,$coursedom,\$navmap);
}
+ undef($navmap);
$pathitem = '<input type="hidden" name="folderpath" value="'.
&HTML::Entities::encode($folderpath,'<>&"').'" />';
my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
@@ -2706,7 +2745,8 @@
sub editor {
my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype,
- $supplementalflag,$orderhash,$iconpath,$pathitem)=@_;
+ $supplementalflag,$orderhash,$iconpath,$pathitem,$canedit,$navmapref,
+ $hiddentop)=@_;
my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order,$container);
if ($allowed) {
(my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,
@@ -2729,9 +2769,21 @@
$randompick = -1;
}
- my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
- $folder.'.'.$container);
- return $errtext if ($fatal);
+ my ($errtext,$fatal);
+ if (($folder eq '') && (!$supplementalflag)) {
+ if (@LONCAPA::map::order) {
+ undef(@LONCAPA::map::order);
+ undef(@LONCAPA::map::resources);
+ undef(@LONCAPA::map::resparms);
+ undef(@LONCAPA::map::zombies);
+ }
+ $folder = 'default';
+ $container = 'sequence';
+ } else {
+ ($errtext,$fatal) = &mapread($coursenum,$coursedom,
+ $folder.'.'.$container);
+ return $errtext if ($fatal);
+ }
if ($#LONCAPA::map::order<1) {
my $idx=&LONCAPA::map::getresidx();
@@ -2743,7 +2795,7 @@
# ------------------------------------------------------------ Process commands
# ---------------- if they are for this folder and user allowed to make changes
- if (($allowed) && ($env{'form.folder'} eq $folder)) {
+ if (($allowed && $canedit) && ($env{'form.folder'} eq $folder)) {
# set parameters and change order
&snapshotbefore();
@@ -3009,19 +3061,20 @@
if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
push(@allmapidx,$res);
}
+
$output .= &entryline($idx,$name,$url,$folder,$allowed,$res,
$coursenum,$coursedom,$crstype,
$pathitem,$supplementalflag,$container,
- \%filters,\%curr_groups);
+ \%filters,\%curr_groups,$canedit,$isencrypted,$navmapref);
$idx++;
$shown++;
}
&Apache::loncommon::end_data_table_count();
my $need_save;
- if (($allowed) || ($supplementalflag && $folder eq 'supplemental')) {
+ if ($allowed || ($supplementalflag && $folder eq 'supplemental')) {
my $toolslink;
- if ($allowed || &Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
+ if ($allowed) {
$toolslink = '<table><tr><td>'
.&Apache::loncommon::help_open_menu('Navigation Screen',
'Navigation_Screen',undef,'RAT')
@@ -3068,12 +3121,12 @@
&Apache::loncommon::continue_data_table_row().
'<td colspan="2"> </td>'.
'<td>'.
- &multiple_check_form('actions',\%lists).
+ &multiple_check_form('actions',\%lists,$canedit).
'</td>'.
'<td> </td>'.
'<td> </td>'.
'<td colspan="4">'.
- &multiple_check_form('settings',\%lists).
+ &multiple_check_form('settings',\%lists,$canedit).
'</td>'.
&Apache::loncommon::end_data_table_row();
$need_save = 1;
@@ -3094,9 +3147,15 @@
if (!$allowed) {
$to_show .= $toolslink;
}
+ my $noresmsg;
+ if ($allowed && $hiddentop && !$supplementalflag) {
+ $noresmsg = &mt('Main Content Hidden');
+ } else {
+ $noresmsg = &mt('Currently empty');
+ }
$to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll')
.'<div class="LC_info" id="contentlist">'
- .&mt('Currently empty')
+ .$noresmsg
.'</div>'
.&Apache::loncommon::end_scrollbox();
}
@@ -3120,8 +3179,10 @@
if ($allowed) {
my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
$r->print(&generate_edit_table($tid,$orderhash,$to_show,$iconpath,
- $jumpto,$readfile,$need_save,"$folder.$container"));
- &print_paste_buffer($r,$container,$folder,$coursedom,$coursenum);
+ $jumpto,$readfile,$need_save,"$folder.$container",$canedit));
+ if ($canedit)
+ &print_paste_buffer($r,$container,$folder,$coursedom,$coursenum);
+ }
} else {
$r->print($to_show);
}
@@ -3129,8 +3190,12 @@
}
sub multiple_check_form {
- my ($caller,$listsref) = @_;
+ my ($caller,$listsref,$canedit) = @_;
return unless (ref($listsref) eq 'HASH');
+ my $disabled;
+ unless ($canedit) {
+ $disabled = 'disabled="disabled"';
+ }
my $output =
'<form action="/adm/coursedocs" method="post" name="togglemult'.$caller.'">'.
'<span class="LC_nobreak" style="font-size:x-small;font-weight:bold;">'.
@@ -3143,15 +3208,15 @@
'<table><tr>'.
'<td class="LC_docs_entry_parameter">'.
'<span class="LC_nobreak"><label>'.
- '<input type="checkbox" name="hiddenresourceall" id="hiddenresourceall" onclick="propagateState(this.form,'."'hiddenresource'".')" />'.&mt('Hidden').
+ '<input type="checkbox" name="hiddenresourceall" id="hiddenresourceall" onclick="propagateState(this.form,'."'hiddenresource'".')"'.$disabled.' />'.&mt('Hidden').
'</label></span></td>'.
'<td class="LC_docs_entry_parameter">'.
- '<span class="LC_nobreak"><label><input type="checkbox" name="randompickall" id="randompickall" onclick="updatePick(this.form,'."'all','check'".');propagateState(this.form,'."'randompick'".');propagateState(this.form,'."'rpicknum'".');" />'.&mt('Randomly Pick').'</label><span id="rpicktextall"></span><input type="hidden" name="rpicknumall" id="rpicknumall" value="" />'.
+ '<span class="LC_nobreak"><label><input type="checkbox" name="randompickall" id="randompickall" onclick="updatePick(this.form,'."'all','check'".');propagateState(this.form,'."'randompick'".');propagateState(this.form,'."'rpicknum'".');"'.$disabled.' />'.&mt('Randomly Pick').'</label><span id="rpicktextall"></span><input type="hidden" name="rpicknumall" id="rpicknumall" value="" />'.
'</span></td>'.
'</tr>'."\n".
'<tr>'.
'<td class="LC_docs_entry_parameter">'.
- '<span class="LC_nobreak"><label><input type="checkbox" name="encrypturlall" id="encrypturlall" onclick="propagateState(this.form,'."'encrypturl'".')" />'.&mt('URL hidden').'</label></span></td><td class="LC_docs_entry_parameter"><span class="LC_nobreak"><label><input type="checkbox" name="randomorderall" id="randomorderall" onclick="propagateState(this.form,'."'randomorder'".')" />'.&mt('Random Order').
+ '<span class="LC_nobreak"><label><input type="checkbox" name="encrypturlall" id="encrypturlall" onclick="propagateState(this.form,'."'encrypturl'".')"'.$disabled.' />'.&mt('URL hidden').'</label></span></td><td class="LC_docs_entry_parameter"><span class="LC_nobreak"><label><input type="checkbox" name="randomorderall" id="randomorderall" onclick="propagateState(this.form,'."'randomorder'".')"'.$disabled.' />'.&mt('Random Order').
'</label></span>'.
'</td></tr></table>'."\n";
} else {
@@ -3159,15 +3224,15 @@
'<table><tr>'.
'<td class="LC_docs_entry_parameter">'.
'<span class="LC_nobreak LC_docs_remove">'.
- '<label><input type="checkbox" name="removeall" id="removeall" onclick="propagateState(this.form,'."'remove'".')" />'.&mt('Remove').
+ '<label><input type="checkbox" name="removeall" id="removeall" onclick="propagateState(this.form,'."'remove'".')"'.$disabled.' />'.&mt('Remove').
'</label></span></td>'.
'<td class="LC_docs_entry_parameter">'.
'<span class="LC_nobreak LC_docs_cut">'.
- '<label><input type="checkbox" name="cut" id="cutall" onclick="propagateState(this.form,'."'cut'".');" />'.&mt('Cut').
+ '<label><input type="checkbox" name="cut" id="cutall" onclick="propagateState(this.form,'."'cut'".');"'.$disabled.' />'.&mt('Cut').
'</label></span></td>'."\n".
'<td class="LC_docs_entry_parameter">'.
'<span class="LC_nobreak LC_docs_copy">'.
- '<label><input type="checkbox" name="copyall" id="copyall" onclick="propagateState(this.form,'."'copy'".')" />'.&mt('Copy').
+ '<label><input type="checkbox" name="copyall" id="copyall" onclick="propagateState(this.form,'."'copy'".')"'.$disabled.' />'.&mt('Copy').
'</label></span></td>'.
'</tr></table>'."\n";
}
@@ -3378,7 +3443,8 @@
sub entryline {
my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom,
- $crstype,$pathitem,$supplementalflag,$container,$filtersref,$currgroups)=@_;
+ $crstype,$pathitem,$supplementalflag,$container,$filtersref,$currgroups,
+ $canedit,$isencrypted,$navmapref)=@_;
my ($foldertitle,$renametitle,$oldtitle);
if (&is_supplemental_title($title)) {
($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title);
@@ -3388,6 +3454,12 @@
$foldertitle=$title;
}
+ my ($disabled,$readonly,$js_lt);
+ unless ($canedit) {
+ $disabled = 'disabled="disabled"';
+ $readonly = 1;
+ }
+
my $orderidx=$LONCAPA::map::order[$index];
$renametitle=~s/\\/\\\\/g;
@@ -3451,7 +3523,7 @@
ne '')) {
$selectbox=
'<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
- '<select name="newpos" onchange="this.form.submit()">';
+ '<select name="newpos" onchange="this.form.submit()"'.$disabled.'>';
for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) {
if ($i==$incindex) {
$selectbox.='<option value="" selected="selected">('.$i.')</option>';
@@ -3473,7 +3545,8 @@
'pr' => 'Preview',
'sv' => 'Save',
'ul' => 'URL',
- 'ti' => 'Title',
+ 'ti' => 'Title',
+ 'er' => 'Editing rights unavailable for your current role.',
);
my %denied = &action_restrictions($coursenum,$coursedom,$url,
$env{'form.folderpath'},
@@ -3506,7 +3579,7 @@
$copylink=(<<ENDCOPY);
<form name="$formname" method="post" action="/adm/coursedocs">
$form_common
-<input type="checkbox" name="copy" id="copy_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','copy');" class="LC_hidden" /><a href="$js" class="LC_docs_copy">$lt{'cp'}</a>
+<input type="checkbox" name="copy" id="copy_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','copy');" class="LC_hidden" $disabled /><a href="$js" class="LC_docs_copy">$lt{'cp'}</a>
$form_end
ENDCOPY
if (($ishash) && (ref($filtersref->{'cancopy'}) eq 'ARRAY')) {
@@ -3524,7 +3597,7 @@
<form name="$formname" method="post" action="/adm/coursedocs">
$form_common
<input type="hidden" name="skip_$orderidx" id="skip_cut_$orderidx" value="$skip_confirm" />
-<input type="checkbox" name="cut" id="cut_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','cut');" class="LC_hidden" /><a href="$js" class="LC_docs_cut">$lt{'ct'}</a>
+<input type="checkbox" name="cut" id="cut_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','cut');" class="LC_hidden" $disabled /><a href="$js" class="LC_docs_cut">$lt{'ct'}</a>
$form_end
ENDCUT
if (($ishash) && (ref($filtersref->{'cancut'}) eq 'ARRAY')) {
@@ -3543,7 +3616,7 @@
$form_common
<input type="hidden" name="skip_$orderidx" id="skip_remove_$orderidx" value="$skip_confirm" />
<input type="hidden" name="confirm_rem_$orderidx" id="confirm_removal_$orderidx" value="$confirm_removal" />
-<input type="checkbox" name="remove" id="remove_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','remove');" class="LC_hidden" /><a href="$js" class="LC_docs_remove">$lt{'rm'}</a>
+<input type="checkbox" name="remove" id="remove_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','remove');" class="LC_hidden" $disabled /><a href="$js" class="LC_docs_remove">$lt{'rm'}</a>
$form_end
ENDREM
if (($ishash) && (ref($filtersref->{'canremove'}) eq 'ARRAY')) {
@@ -3553,15 +3626,23 @@
$renamelink=(<<ENDREN);
<a href='javascript:changename("$esc_path","$index","$oldtitle");' class="LC_docs_rename">$lt{'rn'}</a>
ENDREN
+ my ($uplink,$downlink);
+ if ($canedit) {
+ $uplink = "/adm/coursedocs?cmd=up_$index&folderpath=$esc_path&symb=$symb";
+ $downlink = "/adm/coursedocs?cmd=down_$index&folderpath=$esc_path&symb=$symb";
+ } else {
+ $uplink = "javascript:alert('".&js_escape($lt{'er'})."');";
+ $downlink = $uplink;
+ }
$line.=(<<END);
<td>
<div class="LC_docs_entry_move">
- <a href='/adm/coursedocs?cmd=up_$index&folderpath=$esc_path&symb=$symb'>
+ <a href="$uplink">
<img src="${iconpath}move_up.gif" alt="$lt{'up'}" class="LC_icon" />
</a>
</div>
<div class="LC_docs_entry_move">
- <a href='/adm/coursedocs?cmd=down_$index&folderpath=$esc_path&symb=$symb'>
+ <a href="$downlink">
<img src="${iconpath}move_down.gif" alt="$lt{'dw'}" class="LC_icon" />
</a>
</div>
@@ -3587,6 +3668,7 @@
my $isfolder;
my $ispage;
my $containerarg;
+ my $folderurl;
if ($uploaded) {
if (($extension eq 'sequence') || ($extension eq 'page')) {
$url=~/\Q$coursenum\E\/([\/\w]+)\.\Q$extension\E$/;
@@ -3598,6 +3680,7 @@
$icon=$iconpath.'page.gif';
$ispage=1;
}
+ $folderurl = &Apache::lonnet::declutter($url);
if ($allowed) {
$url='/adm/coursedocs?';
} else {
@@ -3608,7 +3691,7 @@
}
}
- my ($editlink,$extresform,$anchor);
+ my ($editlink,$extresform,$anchor,$hiddenres);
my $orig_url = $url;
$orig_url=~s{http(:|:)//https(:|:)//}{https$2//};
$url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
@@ -3640,7 +3723,47 @@
}
}
}
- $url.=(($url=~/\?/)?'&':'?').'symb='.&HTML::Entities::encode($shownsymb,'"<>&');
+ unless ($env{'request.role.adv'}) {
+ if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
+ $url = '';
+ }
+ if (&Apache::lonnet::EXT('resource.0.hiddenresource',$symb) =~ /^yes$/i) {
+ $url = '';
+ $hiddenres = 1;
+ }
+ }
+ if ($url ne '') {
+ $url.=(($url=~/\?/)?'&':'?').'symb='.&HTML::Entities::encode($shownsymb,'"<>&');
+ }
+ } elsif (!$env{'request.role.adv'}) {
+ my $checkencrypt;
+ if (((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) ||
+ $isencrypted || (&Apache::lonnet::EXT('resource.0.encrypturl',$symb) =~ /^yes$/i)) {
+ $checkencrypt = 1;
+ } else {
+ unless (ref($$navmapref)) {
+ $$navmapref = Apache::lonnavmaps::navmap->new();
+ }
+ if (ref($$navmapref)) {
+ if (lc($$navmapref->get_mapparam($symb,undef,"0.encrypturl")) eq 'yes') {
+ $checkencrypt = 1;
+ }
+ }
+ }
+ if ($checkencrypt) {
+ my $shownsymb = &Apache::lonenc::encrypted($symb);
+ my $shownurl = &Apache::lonenc::encrypted($url);
+ if (&Apache::lonnet::symbverify($shownsymb,$shownurl)) {
+ $url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&HTML::Entities::encode($shownsymb,'"<>&');
+ if ($env{'request.enc'} ne '') {
+ delete($env{'request.enc'});
+ }
+ } else {
+ $url='';
+ }
+ } else {
+ $url='';
+ }
} else {
$url='';
}
@@ -3653,7 +3776,8 @@
}
}
}
- my ($rand_pick_text,$rand_order_text);
+ my ($rand_pick_text,$rand_order_text,$hiddenfolder);
+ my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
if ($isfolder || $ispage || $extension eq 'sequence' || $extension eq 'page') {
my $foldername=&escape($foldertitle);
my $folderpath=$env{'form.folderpath'};
@@ -3662,21 +3786,44 @@
$folderpath.=$containerarg.'&'.$foldername;
$url.='folderpath='.&escape($folderpath);
} else {
-# Append randompick number, hidden, and encrypted with ":" to foldername,
-# so it gets transferred between levels
- $folderpath.=$containerarg.'&'.$foldername.
- ':'.(&LONCAPA::map::getparameter($orderidx,
- 'parameter_randompick'))[0]
- .':'.((&LONCAPA::map::getparameter($orderidx,
- 'parameter_hiddenresource'))[0]=~/^yes$/i)
- .':'.((&LONCAPA::map::getparameter($orderidx,
- 'parameter_encrypturl'))[0]=~/^yes$/i)
- .':'.((&LONCAPA::map::getparameter($orderidx,
- 'parameter_randomorder'))[0]=~/^yes$/i)
- .':'.$ispage;
- $url.='folderpath='.&escape($folderpath);
my $rpicknum = (&LONCAPA::map::getparameter($orderidx,
'parameter_randompick'))[0];
+ my $randorder = ((&LONCAPA::map::getparameter($orderidx,
+ 'parameter_randomorder'))[0]=~/^yes$/i);
+ my $hiddenmap = ((&LONCAPA::map::getparameter($orderidx,
+ 'parameter_hiddenresource'))[0]=~/^yes$/i);
+ my $encryptmap = ((&LONCAPA::map::getparameter($orderidx,
+ 'parameter_encrypturl'))[0]=~/^yes$/i);
+ unless ($hiddenmap) {
+ unless (ref($$navmapref)) {
+ $$navmapref = Apache::lonnavmaps::navmap->new();
+ }
+ if (ref($$navmapref)) {
+ if (lc($$navmapref->get_mapparam(undef,$folderurl,"0.hiddenresource")) eq 'yes') {
+ my @resources = $$navmapref->retrieveResources($folderurl,$filterFunc,1,1);
+ unless (@resources) {
+ $hiddenmap = 1;
+ unless ($env{'request.role.adv'}) {
+ $url = '';
+ $hiddenfolder = 1;
+ }
+ }
+ }
+ }
+ }
+ unless ($encryptmap) {
+ if (lc($$navmapref->get_mapparam(undef,$folderurl,"0.encrypturl")) eq 'yes') {
+ $encryptmap = 1;
+ }
+ }
+
+# Append randompick number, hidden, and encrypted with ":" to foldername,
+# so it gets transferred between levels
+ $folderpath.=$containerarg.'&'.$foldername.
+ ':'.$rpicknum.':'.$hiddenmap.':'.$encryptmap.':'.$randorder.':'.$ispage;
+ unless ($url eq '') {
+ $url.='folderpath='.&escape($folderpath);
+ }
my $rpckchk;
if ($rpicknum) {
$rpckchk = ' checked="checked"';
@@ -3689,14 +3836,14 @@
'<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
$form_param."\n".
$form_common."\n".
-'<span class="LC_nobreak"><label><input type="checkbox" name="randompick_'.$orderidx.'" id="randompick_'.$orderidx.'" onclick="'."updatePick(this.form,'$orderidx','check');".'"'.$rpckchk.' /> '.&mt('Randomly Pick').'</label><input type="hidden" name="rpicknum_'.$orderidx.'" id="rpicknum_'.$orderidx.'" value="'.$rpicknum.'" /><span id="randompicknum_'.$orderidx.'">';
+'<span class="LC_nobreak"><label><input type="checkbox" name="randompick_'.$orderidx.'" id="randompick_'.$orderidx.'" onclick="'."updatePick(this.form,'$orderidx','check');".'"'.$rpckchk.$disabled.' /> '.&mt('Randomly Pick').'</label><input type="hidden" name="rpicknum_'.$orderidx.'" id="rpicknum_'.$orderidx.'" value="'.$rpicknum.'" /><span id="randompicknum_'.$orderidx.'">';
if ($rpicknum ne '') {
$rand_pick_text .= ': <a href="javascript:updatePick('."document.$formname,'$orderidx','link'".')">'.$rpicknum.'</a>';
}
$rand_pick_text .= '</span></span>'.
$form_end;
my $ro_set;
- if ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i) {
+ if ($randorder) {
$ro_set = 'checked="checked"';
if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
push(@{$filtersref->{'randomorder'}},$orderidx);
@@ -3707,7 +3854,7 @@
'<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
$form_param."\n".
$form_common."\n".
-'<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" id="randomorder_'.$orderidx.'" onclick="checkForSubmit(this.form,'."'randomorder','settings'".');" '.$ro_set.' /> '.&mt('Random Order').' </label></span>'.
+'<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" id="randomorder_'.$orderidx.'" onclick="checkForSubmit(this.form,'."'randomorder','settings'".');" '.$ro_set.$disabled.' /> '.&mt('Random Order').' </label></span>'.
$form_end;
}
} elsif ($supplementalflag && !$allowed) {
@@ -3729,7 +3876,8 @@
&Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url));
if ($isexternal) {
($editlink,$extresform) =
- &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem);
+ &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,
+ undef,undef,undef,$disabled);
} elsif (!$isfolder && !$ispage) {
my ($cfile,$home,$switchserver,$forceedit,$forceview) =
&Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url);
@@ -3771,8 +3919,8 @@
$anchor = '#'.&HTML::Entities::encode($anchor,'"<>&');
}
}
- $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'.
- (($anchor ne '')?$anchor:''),
+ $line.=&Apache::loncommon::modal_link(&js_escape($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'.
+ (($anchor ne '')?$anchor:'')),
'<img src="'.$icon.'" alt="" class="LC_icon" />',600,500);
} else {
$line.='<img src="'.$icon.'" alt="" class="LC_icon" />';
@@ -3781,9 +3929,11 @@
if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
$line.='<a href="'.$url.'">'.$title.'</a>';
} elsif ($url) {
- $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'.
- (($anchor ne '')?$anchor:''),
+ $line.=&Apache::loncommon::modal_link(&js_escape($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'.
+ (($anchor ne '')?$anchor:'')),
$title,600,500);
+ } elsif (($hiddenfolder) || ($hiddenres)) {
+ $line.=$title.' <span class="LC_warning LC_docs_reinit_warn">'.&mt('(Hidden)').'</span>';
} else {
$line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';
}
@@ -3814,13 +3964,13 @@
<form action="/adm/coursedocs" method="post" name="$formhidden">
$form_param
$form_common
- <label><input type="checkbox" name="hiddenresource_$orderidx" id="hiddenresource_$orderidx" onclick="checkForSubmit(this.form,'hiddenresource','settings');" $hidtext /> $lt{'hd'}</label>
+ <label><input type="checkbox" name="hiddenresource_$orderidx" id="hiddenresource_$orderidx" onclick="checkForSubmit(this.form,'hiddenresource','settings');" $hidtext $disabled /> $lt{'hd'}</label>
$form_end
<br />
<form action="/adm/coursedocs" method="post" name="$formurlhidden">
$form_param
$form_common
- <label><input type="checkbox" name="encrypturl_$orderidx" id="encrypturl_$orderidx" onclick="checkForSubmit(this.form,'encrypturl','settings');" $enctext /> $lt{'ec'}</label>
+ <label><input type="checkbox" name="encrypturl_$orderidx" id="encrypturl_$orderidx" onclick="checkForSubmit(this.form,'encrypturl','settings');" $enctext $disabled /> $lt{'ec'}</label>
$form_end
</td>
<td class="LC_docs_entry_parameter">$rand_pick_text<br />
@@ -4155,7 +4305,7 @@
}
sub checkversions {
- my ($r) = @_;
+ my ($r,$canedit) = @_;
my $crstype = &Apache::loncommon::course_type();
$r->print(&Apache::loncommon::start_page("Check $crstype Resource Versions"));
$r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Resource Versions"));
@@ -4176,51 +4326,53 @@
$hashtied=0;
&tiehash();
- my %newsetversions=();
- if ($env{'form.setmostrecent'}) {
- $haschanged=1;
- foreach my $key (keys(%hash)) {
- if ($key=~/^ids\_(\/res\/.+)$/) {
- $newsetversions{$1}='mostrecent';
- &devalidateversioncache($1);
+ if ($canedit) {
+ my %newsetversions=();
+ if ($env{'form.setmostrecent'}) {
+ $haschanged=1;
+ foreach my $key (keys(%hash)) {
+ if ($key=~/^ids\_(\/res\/.+)$/) {
+ $newsetversions{$1}='mostrecent';
+ &devalidateversioncache($1);
+ }
}
- }
- } elsif ($env{'form.setcurrent'}) {
- $haschanged=1;
- foreach my $key (keys(%hash)) {
- if ($key=~/^ids\_(\/res\/.+)$/) {
- my $getvers=&Apache::lonnet::getversion($1);
- if ($getvers>0) {
- $newsetversions{$1}=$getvers;
- &devalidateversioncache($1);
- }
+ } elsif ($env{'form.setcurrent'}) {
+ $haschanged=1;
+ foreach my $key (keys(%hash)) {
+ if ($key=~/^ids\_(\/res\/.+)$/) {
+ my $getvers=&Apache::lonnet::getversion($1);
+ if ($getvers>0) {
+ $newsetversions{$1}=$getvers;
+ &devalidateversioncache($1);
+ }
+ }
}
- }
- } elsif ($env{'form.setversions'}) {
- $haschanged=1;
- foreach my $key (keys(%env)) {
- if ($key=~/^form\.set_version_(.+)$/) {
- my $src=$1;
- if (($env{$key}) && ($env{$key} ne $setversions{$src})) {
- $newsetversions{$src}=$env{$key};
- &devalidateversioncache($src);
- }
+ } elsif ($env{'form.setversions'}) {
+ $haschanged=1;
+ foreach my $key (keys(%env)) {
+ if ($key=~/^form\.set_version_(.+)$/) {
+ my $src=$1;
+ if (($env{$key}) && ($env{$key} ne $setversions{$src})) {
+ $newsetversions{$src}=$env{$key};
+ &devalidateversioncache($src);
+ }
+ }
}
- }
- }
- if ($haschanged) {
- if (&Apache::lonnet::put('resourceversions',\%newsetversions,
- $env{'course.'.$env{'request.course.id'}.'.domain'},
- $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
- $r->print(&Apache::loncommon::confirmwrapper(
- &Apache::lonhtmlcommon::confirm_success(&mt('Your Version Settings have been Saved'))));
- } else {
- $r->print(&Apache::loncommon::confirmwrapper(
- &Apache::lonhtmlcommon::confirm_success(&mt('An Error Occured while Attempting to Save your Version Settings'),1)));
- }
- &mark_hash_old();
+ }
+ if ($haschanged) {
+ if (&Apache::lonnet::put('resourceversions',\%newsetversions,
+ $env{'course.'.$env{'request.course.id'}.'.domain'},
+ $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
+ $r->print(&Apache::loncommon::confirmwrapper(
+ &Apache::lonhtmlcommon::confirm_success(&mt('Your Version Settings have been Saved'))));
+ } else {
+ $r->print(&Apache::loncommon::confirmwrapper(
+ &Apache::lonhtmlcommon::confirm_success(&mt('An Error Occured while Attempting to Save your Version Settings'),1)));
+ }
+ &mark_hash_old();
+ }
+ &changewarning($r,'');
}
- &changewarning($r,'');
if ($env{'form.timerange'} eq 'all') {
# show all documents
$header=&mt('All content in '.$crstype);
@@ -4287,6 +4439,11 @@
'save' => 'Save changes',
'vers' => 'Version choice(s) for specific resources',
'act' => 'Actions');
+ my ($disabled,$readonly);
+ unless ($canedit) {
+ $disabled = 'disabled="disabled"';
+ $readonly = 1;
+ }
$r->print(<<ENDHEADERS);
<h4 class="LC_info">$header</h4>
<form action="/adm/coursedocs" method="post">
@@ -4307,8 +4464,8 @@
<div class="LC_left_float">
<fieldset>
<legend>$lt{'act'}</legend>
-$lt{'sm'}: <input type="submit" name="setmostrecent" value="Go" /><br />
-$lt{'sc'}: <input type="submit" name="setcurrent" value="Go" />
+$lt{'sm'}: <input type="submit" name="setmostrecent" value="Go" $disabled /><br />
+$lt{'sc'}: <input type="submit" name="setcurrent" value="Go" $disabled />
</fieldset>
</div>
<br clear="all" />
@@ -4337,7 +4494,7 @@
return;
}
$r->print(
- '<input type="submit" name="setversions" value="'.$lt{'save'}.'" />'.
+ '<input type="submit" name="setversions" value="'.$lt{'save'}.'"'.$disabled.' />'.
&Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row().
'<th>'.&mt('Resources').'</th>'.
@@ -4382,7 +4539,7 @@
{'select_form_order' => ['',1..$currentversion,'mostrecent'],
'' => '',
'mostrecent' => &mt('most recent'),
- map {$_,$_} (1..$currentversion)}));
+ map {$_,$_} (1..$currentversion)},'',$readonly));
my $lastold=1;
for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
my $url=$root.'.'.$prevvers.'.'.$extension;
@@ -4416,7 +4573,7 @@
}
$r->print(
&Apache::loncommon::end_data_table().
- '<input type="submit" name="setversions" value="'.$lt{'save'}.'" />'.
+ '<input type="submit" name="setversions" value="'.$lt{'save'}.'"'.$disabled.' />'.
'</form>'
);
@@ -4582,13 +4739,22 @@
$help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
$help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
- my $allowed;
+ my ($allowed,$canedit,$canview,$disabled);
# URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
unless ($r->uri eq '/adm/supplemental') {
# does this user have privileges to modify content.
- $allowed = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
+ if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
+ $allowed = 1;
+ $canedit = 1;
+ $canview = 1;
+ } elsif (&Apache::lonnet::allowed('cev',$env{'request.course.id'})) {
+ $allowed = 1;
+ $canview = 1;
+ }
+ }
+ unless ($canedit) {
+ $disabled = ' disabled="disabled"';
}
-
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['inhibitmenu']);
if ($allowed && $env{'form.verify'}) {
&init_breadcrumbs('verify','Verify Content','Docs_Verify_Content');
@@ -4602,11 +4768,11 @@
if ($folder eq '') {
$folder='default';
}
- &docs_change_log($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath);
+ &docs_change_log($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath,$canedit);
} elsif ($allowed && $env{'form.versions'}) {
&init_breadcrumbs('versions','Check/Set Resource Versions','Docs_Check_Resource_Versions');
- &checkversions($r);
- } elsif ($allowed && $env{'form.dumpcourse'}) {
+ &checkversions($r,$canedit);
+ } elsif ($canedit && $env{'form.dumpcourse'}) {
&init_breadcrumbs('dumpcourse','Copy '.&Apache::loncommon::course_type().' Content to Authoring Space');
&dumpcourse($r);
} elsif ($allowed && $env{'form.exportcourse'}) {
@@ -4651,13 +4817,15 @@
my $container;
my $containertag;
my $pathitem;
+ my $hiddentop;
+ my $navmap;
+ my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
# Do we directly jump somewhere?
-
if (($env{'form.command'} eq 'direct') || ($env{'form.command'} eq 'directnav')) {
if ($env{'form.symb'} ne '') {
$env{'form.folderpath'}=
- &Apache::loncommon::symb_to_docspath($env{'form.symb'});
+ &Apache::loncommon::symb_to_docspath($env{'form.symb'},\$navmap);
&Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
$env{'form.command'}.'_'.$env{'form.symb'}});
} elsif ($env{'form.supppath'} ne '') {
@@ -4666,12 +4834,10 @@
$env{'form.command'}.'_'.$env{'form.supppath'}});
}
} elsif ($env{'form.command'} eq 'editdocs') {
- $env{'form.folderpath'} = 'default&'.
- &escape(&mt('Main Content').':::::');
+ $env{'form.folderpath'} = &default_folderpath($coursenum,$coursedom,\$navmap);
&Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => $env{'form.command'}});
} elsif ($env{'form.command'} eq 'editsupp') {
- $env{'form.folderpath'} = 'supplemental&'.
- &escape('Supplemental Content');
+ $env{'form.folderpath'} = &supplemental_base();
&Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/supplemental'});
} elsif ($env{'form.command'} eq 'contents') {
&Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/navmaps'});
@@ -4690,7 +4856,14 @@
if ((!$env{'form.folderpath'}) && $allowed) {
&Apache::loncommon::restore_course_settings($stored_folderpath,
{'folderpath' => 'scalar'});
- unless (&unescape($env{'form.folderpath'}) =~ m{^(default|supplemental)&}) {
+
+ if (&unescape($env{'form.folderpath'}) =~ m{^(default|supplemental)&}) {
+ if ($supplementalflag) {
+ undef($env{'form.folderpath'}) if ($1 eq 'default');
+ } else {
+ undef($env{'form.folderpath'}) if ($1 eq 'supplemental');
+ }
+ } else {
undef($env{'form.folderpath'});
}
}
@@ -4707,19 +4880,48 @@
.'&'.
$env{'form.folderpath'};
}
+# If allowed and user's role is not advanced check folderpath is not hidden
+ if (($allowed) && (!$env{'request.role.adv'}) &&
+ ($env{'form.folderpath'} ne '') && (!$supplementalflag)) {
+ my $folderurl;
+ my @pathitems = split(/\&/,$env{'form.folderpath'});
+ my $folder = $pathitems[-2];
+ if ($folder eq '') {
+ undef($env{'form.folderpath'});
+ } else {
+ $folderurl = "uploaded/$coursedom/$coursenum/$folder";
+ if ((split(/\:/,$pathitems[-1]))[4]) {
+ $folderurl .= '.page';
+ } else {
+ $folderurl .= '.sequence';
+ }
+ unless (ref($navmap)) {
+ $navmap = Apache::lonnavmaps::navmap->new();
+ }
+ if (ref($navmap)) {
+ if (lc($navmap->get_mapparam(undef,$folderurl,"0.hiddenresource")) eq 'yes') {
+ my @resources = $navmap->retrieveResources($folderurl,$filterFunc,1,1);
+ unless (@resources) {
+ undef($env{'form.folderpath'});
+ }
+ }
+ }
+ }
+ }
+
+
# If after all of this, we still don't have any paths, make them
unless ($env{'form.folderpath'}) {
if ($supplementalflag) {
$env{'form.folderpath'}=&supplemental_base();
- } else {
- $env{'form.folderpath'}='default&'.&escape(&mt('Main Content').
- ':::::');
+ } elsif ($allowed) {
+ ($env{'form.folderpath'},$hiddentop) = &default_folderpath($coursenum,$coursedom,\$navmap);
}
}
# Store this
unless ($toolsflag) {
- if ($allowed) {
+ if (($allowed) && ($env{'form.folderpath'} ne '')) {
&Apache::loncommon::store_course_settings($stored_folderpath,
{'folderpath' => 'scalar'});
}
@@ -4737,8 +4939,12 @@
} else {
if ($env{'form.folder'} eq '' ||
$env{'form.folder'} eq 'supplemental') {
- $folderpath='default&'.
- &escape(&mt('Main Content').':::::');
+ if ($env{'form.folder'} eq 'supplemental') {
+ $folderpath=&supplemental_base();
+ } elsif (!$hiddentop) {
+ $folderpath='default&'.
+ &escape(&mt('Main Content').':::::');
+ }
}
}
$containertag = '<input type="hidden" name="folderpath" value="" />';
@@ -4749,7 +4955,7 @@
if ($showdoc) { # got called in sequence from course
$allowed=0;
} else {
- if ($allowed) {
+ if ($canedit) {
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
$script=&Apache::lonratedt::editscript('simple');
}
@@ -4788,7 +4994,8 @@
}
}
my $tabidstr = join("','", at tabids);
- $script .= &editing_js($udom,$uname,$supplementalflag).
+ $script .= &editing_js($udom,$uname,$supplementalflag,$coursedom,$coursenum
+ $canedit,\$navmap).
&history_tab_js().
&inject_data_js().
&Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid).
@@ -4817,34 +5024,52 @@
$r->print(&Apache::loncommon::start_page("$crstype documents",undef,
{'force_register' => $showdoc,}));
} elsif ($toolsflag) {
+ my ($breadtext,$breadtitle);
+ $breadtext = "$crstype Editor";
+ if ($canedit) {
+ $breadtitle = 'Editing '.$crstype.' Contents';
+ } else {
+ $breadtext .= ' (View-only mode)';
+ $breadtitle = 'Viewing '.$crstype.' Contents';
+ }
&Apache::lonhtmlcommon::add_breadcrumb({
- href=>"/adm/coursedocs",text=>"$crstype Contents"});
+ href=>"/adm/coursedocs",text=>$breadtext});
$r->print(&Apache::loncommon::start_page("$crstype Contents", $script)
.&Apache::loncommon::help_open_menu('','',273,'RAT')
.&Apache::lonhtmlcommon::breadcrumbs(
- 'Editing Course Contents')
+ $breadtitle)
);
} elsif ($r->uri eq '/adm/supplemental') {
my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype);
$r->print(&Apache::loncommon::start_page("Supplemental $crstype Content",undef,
{'bread_crumbs' => $brcrum,}));
} else {
+ my ($breadtext,$breadtitle,$helpitem);
+ $breadtext = "$crstype Editor";
+ if ($canedit) {
+ $breadtitle = 'Editing '.$crstype.' Contents';
+ $helpitem = 'Docs_Adding_Course_Doc';
+ } else {
+ $breadtext .= ' (View-only mode)';
+ $breadtitle = 'Viewing '.$crstype.' Contents';
+ $helpitem = 'Docs_Viewing_Course_Doc';
+ }
&Apache::lonhtmlcommon::add_breadcrumb({
- href=>"/adm/coursedocs",text=>"$crstype Contents"});
+ href=>"/adm/coursedocs",text=>$breadtext});
$r->print(&Apache::loncommon::start_page("$crstype Contents", $script,
{'add_entries' => $addentries}
)
.&Apache::loncommon::help_open_menu('','',273,'RAT')
.&Apache::lonhtmlcommon::breadcrumbs(
- 'Editing '.$crstype.' Contents',
- 'Docs_Adding_Course_Doc')
+ $breadtitle,
+ $helpitem)
);
}
my %allfiles = ();
my %codebase = ();
my ($upload_result,$upload_output,$uploadphase);
- if ($allowed) {
+ if ($canedit) {
if (($env{'form.uploaddoc.filename'}) &&
($env{'form.cmd'}=~/^upload_(\w+)/)) {
my $context = $1;
@@ -4896,7 +5121,7 @@
if ($allowed && $toolsflag) {
$r->print(&startContentScreen('tools'));
- $r->print(&generate_admin_menu($crstype));
+ $r->print(&generate_admin_menu($crstype,$canedit));
$r->print(&endContentScreen());
} elsif ((!$showdoc) && (!$uploadphase)) {
# -----------------------------------------------------------------------------
@@ -4936,6 +5161,7 @@
'bb6' => 'Blackboard 6',
'angel5' => 'ANGEL 5.5',
'webctce4' => 'WebCT 4 Campus Edition',
+ 'er' => 'Editing rights unavailable for your current role.',
);
# -----------------------------------------------------------------------------
# Calculate free quota space for a user or course.
@@ -4972,7 +5198,7 @@
my $fileupload=(<<FIUP);
$quotainfo
$lt{'file'}:<br />
- <input type="file" name="uploaddoc" size="40" />
+ <input type="file" name="uploaddoc" size="40" $disabled />
FIUP
my $checkbox=(<<CHBO);
@@ -4980,7 +5206,7 @@
<input type="checkbox" name="parserflag" />
</label> -->
<label>
- <input type="checkbox" name="parserflag" checked="checked" /> $lt{'parse'}
+ <input type="checkbox" name="parserflag" checked="checked" $disabled /> $lt{'parse'}
</label>
CHBO
my $imsfolder = $env{'form.folder'};
@@ -4997,7 +5223,7 @@
<br />
<p>
$lt{'cms'}:
- <select name="source">
+ <select name="source" $disabled>
<option value="-1" selected="selected">$lt{'se'}</option>
<option value="bb5">$lt{'bb5'}</option>
<option value="bb6">$lt{'bb6'}</option>
@@ -5007,7 +5233,7 @@
<input type="hidden" name="folder" value="$imsfolder" />
</p>
<input type="hidden" name="phase" value="one" />
- <input type="button" value="$lt{'imsl'}" onclick="makeims(this.form);" />
+ <input type="button" value="$lt{'imsl'}" onclick="makeims(this.form);" $disabled />
</fieldset>
</form>
IMSFORM
@@ -5022,7 +5248,7 @@
$fileupload
<br />
$lt{'title'}:<br />
- <input type="text" size="60" name="comment" />
+ <input type="text" size="60" name="comment" $disabled />
$pathitem
<input type="hidden" name="cmd" value="upload_default" />
<br />
@@ -5030,11 +5256,17 @@
$checkbox
</span>
<br clear="all" />
- <input type="submit" value="$lt{'upld'}" />
+ <input type="submit" value="$lt{'upld'}" $disabled />
</fieldset>
</form>
FUFORM
+ my $mapimportjs;
+ if ($canedit) {
+ $mapimportjs = "javascript:openbrowser('mapimportform','importmap','sequence,page','');";
+ } else {
+ $mapimportjs = "javascript:alert('".&js_escape($lt{'er'})."');";
+ }
my $importpubform=(<<SEDFFORM);
<a class="LC_menubuttons_link" href="javascript:toggleMap('map');">
$lt{'impm'}</a>$help{'Load_Map'}
@@ -5045,31 +5277,42 @@
$lt{'copm'}<br />
<span class="LC_nobreak">
<input type="text" name="importmap" size="40" value=""
- onfocus="this.blur();openbrowser('mapimportform','importmap','sequence,page','');" />
- <a href="javascript:openbrowser('mapimportform','importmap','sequence,page','');">$lt{'selm'}</a></span><br />
- <input type="submit" name="loadmap" value="$lt{'load'}" />
+ onfocus="this.blur();$mapimportjs" $disabled />
+ <a href="$mapimportjs">$lt{'selm'}</a></span><br />
+ <input type="submit" name="loadmap" value="$lt{'load'}" $disabled />
</fieldset>
</form>
SEDFFORM
+
+ my $fromstoredjs;
+ if ($canedit) {
+ $fromstoredjs = 'open_StoredLinks_Import()';
+ } else {
+ $fromstoredjs = "alert('".&js_escape($lt{'er'})."')";
+ }
+
my @importpubforma = (
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/src.png" alt="'.$lt{srch}.'" onclick="javascript:groupsearch()" />' => $pathitem."<a class='LC_menubuttons_link' href='javascript:groupsearch()'>$lt{'srch'}</a>" },
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/res.png" alt="'.$lt{impo}.'" onclick="javascript:groupimport();"/>' => "<a class='LC_menubuttons_link' href='javascript:groupimport();'>$lt{'impo'}</a>$help{'Importing_LON-CAPA_Resource'}" },
- { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/wishlist.png" alt="'.$lt{lnks}.'" onclick="javascript:open_StoredLinks_Import();" />' => "<a class='LC_menubuttons_link' href='javascript:open_StoredLinks_Import();'>$lt{'lnks'}</a>" },
+ { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/wishlist.png" alt="'.$lt{lnks}.'" onclick="javascript:'.$fromstoredjs.';" />' => '<a class="LC_menubuttons_link" href="javascript:'.$fromstoredjs.';">'.$lt{'lnks'}.'</a>' },
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/sequence.png" alt="'.$lt{impm}.'" onclick="javascript:toggleMap(\'map\');" />' => $importpubform }
);
$importpubform = &create_form_ul(&create_list_elements(@importpubforma));
my $extresourcesform =
&Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
- $help{'Adding_External_Resource'});
+ $help{'Adding_External_Resource'},
+ undef,undef,$disabled);
if ($allowed) {
my $folder = $env{'form.folder'};
if ($folder eq '') {
$folder='default';
}
- my $output = &update_paste_buffer($coursenum,$coursedom,$folder);
- if ($output) {
- $r->print($output);
+ if ($canedit) {
+ my $output = &update_paste_buffer($coursenum,$coursedom,$folder);
+ if ($output) {
+ $r->print($output);
+ }
}
$r->print(<<HIDDENFORM);
<form name="renameform" method="post" action="/adm/coursedocs">
@@ -5106,7 +5349,7 @@
if ($allowed) {
my $folder=$env{'form.folder'};
- if ($folder eq '' || $supplementalflag) {
+ if ((($folder eq '') && (!$hiddentop)) || ($supplementalflag)) {
$folder='default';
$savefolderpath = $env{'form.folderpath'};
$env{'form.folderpath'}='default&'.&escape(&mt('Main Content'));
@@ -5134,7 +5377,7 @@
$pathitem
<input type="hidden" name="importdetail"
value="$lt{'navc'}=/adm/navmaps" />
- <a class="LC_menubuttons_link" href="javascript:document.newnav.submit()">$lt{'navc'}</a>
+ <a class="LC_menubuttons_link" href="javascript:makenew(document.newnav);">$lt{'navc'}</a>
$help{'Navigate_Content'}
</form>
NNFORM
@@ -5195,7 +5438,7 @@
$pathitem
<input type="hidden" name="importdetail"
value="$plainname=/adm/$udom/$uname/aboutme" />
- <a class="LC_menubuttons_link" href="javascript:document.newaboutme.submit()">$lt{'mypi'}</a>
+ <a class="LC_menubuttons_link" href="javascript:makenew(document.newaboutme);">$lt{'mypi'}</a>
$help{'My Personal Information Page'}
</form>
NAMFORM
@@ -5215,7 +5458,7 @@
$pathitem
<input type="hidden" name="importdetail"
value="$lt{'rost'}=/adm/viewclasslist" />
- <a class="LC_menubuttons_link" href="javascript:document.newroster.submit()">$lt{'rost'}</a>
+ <a class="LC_menubuttons_link" href="javascript:makenew(document.newroster);">$lt{'rost'}</a>
$help{'Course_Roster'}
</form>
NROSTFORM
@@ -5278,7 +5521,7 @@
$pathitem
<input type="hidden" name="importdetail"
value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
- <a class="LC_menubuttons_link" href="javascript:document.newsyl.submit()">$lt{'syll'}</a>
+ <a class="LC_menubuttons_link" href="javascript:makenew(document.newsyl);">$lt{'syll'}</a>
$help{'Syllabus'}
</form>
@@ -5290,14 +5533,14 @@
$pathitem
<input type="hidden" name="importdetail"
value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
- <a class="LC_menubuttons_link" href="javascript:document.newgroupfiles.submit()">$lt{'grpo'}</a>
+ <a class="LC_menubuttons_link" href="javascript:makenew(document.newgroupfiles);">$lt{'grpo'}</a>
$help{'Group Portfolio'}
</form>
NGFFORM
@specialdocumentsforma=(
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/page.png" alt="'.$lt{newp}.'" onclick="javascript:makenewpage(document.newpage,\''.$pageseq.'\');" />'=>$newpageform},
- {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.newsyl.submit()" />'=>$newsylform},
- {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="document.newnav.submit()" />'=>$newnavform},
+ {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="javascript:makenew(document.newsyl);" />'=>$newsylform},
+ {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="javascript:makenew(document.newnav);" />'=>$newnavform},
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform},
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage();" />'=>$newwebpageform},
);
@@ -5329,8 +5572,8 @@
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/bchat.png" alt="'.$lt{bull}.'" onclick="javascript:makebulboard();" />'=>$newbulform},
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makebulboard();" />'=>$newaboutmeform},
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/aboutme.png" alt="'.$lt{abou}.'" onclick="javascript:makeabout();" />'=>$newaboutsomeoneform},
- {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/clst.png" alt="'.$lt{rost}.'" onclick="document.newroster.submit()" />'=>$newrosterform},
- {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/groupportfolio.png" alt="'.$lt{grpo}.'" onclick="document.newgroupfiles.submit()" />'=>$newgroupfileform},
+ {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/clst.png" alt="'.$lt{rost}.'" onclick="javascript:makenew(document.newroster);" />'=>$newrosterform},
+ {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/groupportfolio.png" alt="'.$lt{grpo}.'" onclick="javascript:makenew(document.newgroupfiles);" />'=>$newgroupfileform},
);
$communityform = &create_form_ul(&create_list_elements(@communityforma));
@@ -5348,7 +5591,9 @@
$hadchanges=0;
unless (($supplementalflag || $toolsflag)) {
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
- $supplementalflag,\%orderhash,$iconpath,$pathitem);
+ $supplementalflag,\%orderhash,$iconpath,$pathitem,
+ $canedit,\$navmap,$hiddentop));
+ undef($navmap);
if ($error) {
$r->print('<p><span class="LC_error">'.$error.'</span></p>');
}
@@ -5413,7 +5658,8 @@
my $supextform =
&Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
- $help{'Adding_External_Resource'});
+ $help{'Adding_External_Resource'},
+ undef,undef,$disabled);
my $supnewsylform=(<<SNSFORM);
<form action="/adm/coursedocs" method="post" name="supnewsyl">
@@ -5421,7 +5667,7 @@
$pathitem
<input type="hidden" name="importdetail"
value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
- <a class="LC_menubuttons_link" href="javascript:document.supnewsyl.submit()">$lt{'syll'}</a>
+ <a class="LC_menubuttons_link" href="javascript:makenew(document.supnewsyl);">$lt{'syll'}</a>
$help{'Syllabus'}
</form>
SNSFORM
@@ -5432,7 +5678,7 @@
$pathitem
<input type="hidden" name="importdetail"
value="$plainname=/adm/$udom/$uname/aboutme" />
- <a class="LC_menubuttons_link" href="javascript:document.supnewaboutme.submit()">$lt{'mypi'}</a>
+ <a class="LC_menubuttons_link" href="javascript:makenew(document.supnewaboutme);">$lt{'mypi'}</a>
$help{'My Personal Information Page'}
</form>
SNAMFORM
@@ -5459,9 +5705,9 @@
my @specialdocs = (
- {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.supnewsyl.submit()" />'
+ {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="javascript:makenew(document.supnewsyl);" />'
=>$supnewsylform},
- {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="document.supnewaboutme.submit()" />'
+ {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makenew(document.supnewaboutme);" />'
=>$supnewaboutmeform},
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage('."'supp'".');" />'=>$supwebpageform},
@@ -5481,7 +5727,8 @@
);
if ($supplementalflag) {
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
- $supplementalflag,\%suporderhash,$iconpath,$pathitem);
+ $supplementalflag,\%suporderhash,$iconpath,$pathitem,
+ $canedit);
if ($error) {
$r->print('<p><span class="LC_error">'.$error.'</span></p>');
} else {
@@ -5686,7 +5933,7 @@
}
sub generate_admin_menu {
- my ($crstype) = @_;
+ my ($crstype,$canedit) = @_;
my $lc_crstype = lc($crstype);
my ($home,$other,%outhash)=&authorhosts();
my %lt= ( # do not translate here
@@ -5744,7 +5991,9 @@
linktitle => "List the unique identifier used for each resource instance in your $lc_crstype"
},
]
- },
+ });
+ if ($canedit) {
+ push(@menu,
{ categorytitle=>'Export',
items =>[
{ linktext => $lt{'imse'},
@@ -5763,6 +6012,7 @@
},
]
});
+ }
return '<form action="/adm/coursedocs" method="post" name="courseverify">'."\n".
'<input type="hidden" id="dummy" />'."\n".
&Apache::lonhtmlcommon::generate_menu(@menu)."\n".
@@ -5771,15 +6021,16 @@
sub generate_edit_table {
my ($tid,$orderhash_ref,$to_show,$iconpath,$jumpto,$readfile,
- $need_save,$copyfolder) = @_;
+ $need_save,$copyfolder,$canedit) = @_;
return unless(ref($orderhash_ref) eq 'HASH');
my %orderhash = %{$orderhash_ref};
- my $form;
- my $activetab;
- my $active;
+ my ($form, $activetab, $active, $disabled);
if (($env{'form.active'} ne '') && ($env{'form.active'} ne '00')) {
$activetab = $env{'form.active'};
}
+ unless ($canedit) {
+ $disabled = ' disabled="disabled"';
+ }
my $backicon = $iconpath.'clickhere.gif';
my $backtext = &mt('Exit Editor');
$form = '<div class="LC_Box" style="margin:0;">'.
@@ -5843,7 +6094,7 @@
<input type="hidden" name="multicopy" value="" />
<input type="hidden" name="multichange" value="" />
<input type="hidden" name="copyfolder" value="$copyfolder" />
-<input type="submit" name="savemultiples" value="$button" />
+<input type="submit" name="savemultiples" value="$button" $disabled />
</form>
</div>
END
@@ -5869,7 +6120,7 @@
}
sub editing_js {
- my ($udom,$uname,$supplementalflag) = @_;
+ my ($udom,$uname,$supplementalflag,$coursedom,$coursenum,$canedit,$navmapref) = @_;
my %js_lt = &Apache::lonlocal::texthash(
p_mnf => 'Name of New Folder',
t_mnf => 'New Folder',
@@ -5909,6 +6160,7 @@
noor => 'No actions selected or changes to settings specified.',
noch => 'No changes to settings specified.',
noac => 'No actions selected.',
+ edri => 'Editing rights unavailable for your current role.',
);
&js_escape(\%js_lt);
@@ -5918,11 +6170,10 @@
if (&HTML::Entities::decode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'}) =~ /\:1$/) {
$main_container_page = 1;
}
- my $toplevelmain =
- &escape(&mt('Main Content').':::::');
+ my $backtourl;
+ my $toplevelmain = &escape(&default_folderpath($coursenum,$coursedom,$navmapref));
my $toplevelsupp = &supplemental_base();
- my $backtourl;
if ($env{'docs.exit.'.$env{'request.course.id'}} =~ /^direct_(.+)$/) {
my $caller = $1;
if ($caller =~ /^supplemental/) {
@@ -5938,6 +6189,8 @@
if (($caller =~ m{^([^#]+)\Q#$anchor\E$})) {
$caller = $1.&escape('#').$anchor;
}
+ } else {
+ $url = $res;
}
$backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($url),'<>&"').'?symb='.
&HTML::Entities::encode($caller,'<>&"');
@@ -5965,7 +6218,9 @@
$fieldsets = "'suppext','suppdoc'";
}
- return <<ENDNEWSCRIPT;
+ my $jsmakefunctions;
+ if ($canedit) {
+ $jsmakefunctions = <<ENDNEWSCRIPT;
function makenewfolder(targetform,folderseq) {
var foldername=prompt('$js_lt{"p_mnf"}','$js_lt{"t_mnf"}');
if (foldername) {
@@ -6051,16 +6306,101 @@
if ((comp[0]) && (comp[1])) {
this.document.forms.newaboutsomeone.importdetail.value=
'$js_lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
- this.document.forms.newaboutsomeone.submit();
- } else {
- alert("$js_lt{'p_mab_alrt1'}");
- }
-} else {
- alert("$js_lt{'p_mab_alrt2'}");
+ this.document.forms.newaboutsomeone.submit();
+ } else {
+ alert("$js_lt{'p_mab_alrt1'}");
+ }
+ } else {
+ alert("$js_lt{'p_mab_alrt2'}");
+ }
+ }
}
+
+function makenew(targetform) {
+ targetform.submit();
}
+
+function changename(folderpath,index,oldtitle) {
+ var title=prompt('$js_lt{"p_chn"}',oldtitle);
+ if (title) {
+ this.document.forms.renameform.markcopy.value='';
+ this.document.forms.renameform.title.value=title;
+ this.document.forms.renameform.cmd.value='rename_'+index;
+ this.document.forms.renameform.folderpath.value=folderpath;
+ this.document.forms.renameform.submit();
+ }
}
+ENDNEWSCRIPT
+ } else {
+ $jsmakefunctions = <<ENDNEWSCRIPT;
+
+function makenewfolder() {
+ alert("$js_lt{'edri'}");
+}
+
+function makenewpage() {
+ alert("$js_lt{'edri'}");
+}
+
+function makeexamupload() {
+ alert("$js_lt{'edri'}");
+}
+
+function makesmppage() {
+ alert("$js_lt{'edri'}");
+}
+
+function makewebpage(type) {
+ alert("$js_lt{'edri'}");
+}
+
+function makesmpproblem() {
+ alert("$js_lt{'edri'}");
+}
+
+function makedropbox() {
+ alert("$js_lt{'edri'}");
+}
+
+function makebulboard() {
+ alert("$js_lt{'edri'}");
+}
+
+function makeabout() {
+ alert("$js_lt{'edri'}");
+}
+
+function changename() {
+ alert("$js_lt{'edri'}");
+}
+
+function makenew() {
+ alert("$js_lt{'edri'}");
+}
+
+function groupimport() {
+ alert("$js_lt{'edri'}");
+}
+
+function groupsearch() {
+ alert("$js_lt{'edri'}");
+}
+
+function groupopen(url,recover) {
+ var options="scrollbars=1,resizable=1,menubar=0";
+ idxflag=1;
+ idx=open("/adm/groupsort?inhibitmenu=yes&mode=simple&recover="+recover+"&readfile="+url,"idxout",options);
+ idx.focus();
+}
+
+ENDNEWSCRIPT
+
+ }
+ return <<ENDSCRIPT;
+
+$jsmakefunctions
+
function toggleUpload(caller) {
var blocks = Array($fieldsets);
for (var i=0; i<blocks.length; i++) {
@@ -6105,17 +6445,6 @@
imsform.submit();
}
-function changename(folderpath,index,oldtitle) {
-var title=prompt('$js_lt{"p_chn"}',oldtitle);
-if (title) {
-this.document.forms.renameform.markcopy.value='';
-this.document.forms.renameform.title.value=title;
-this.document.forms.renameform.cmd.value='rename_'+index;
-this.document.forms.renameform.folderpath.value=folderpath;
-this.document.forms.renameform.submit();
-}
-}
-
function updatePick(targetform,index,caller) {
var pickitem;
var picknumitem;
@@ -6281,6 +6610,11 @@
}
function checkForSubmit(targetform,param,context,idx,folderpath,index,oldtitle,skip_confirm,container,folder,confirm_removal) {
+ var canedit = '$canedit';
+ if (canedit == '') {
+ alert("$js_lt{'edri'}");
+ return;
+ }
var dosettings;
var doaction;
var control = document.togglemultsettings;
@@ -6826,7 +7160,7 @@
return;
}
-ENDNEWSCRIPT
+ENDSCRIPT
}
sub history_tab_js {
More information about the LON-CAPA-cvs
mailing list