--- loncom/interface/londocs.pm	2013/08/18 17:32:28	1.484.2.39
+++ loncom/interface/londocs.pm	2013/05/21 19:05:05	1.549
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.484.2.39 2013/08/18 17:32:28 raeburn Exp $
+# $Id: londocs.pm,v 1.549 2013/05/21 19:05:05 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -56,7 +56,6 @@ my $hashtied;
 my %alreadyseen=();
 
 my $hadchanges;
-my $suppchanges;
 
 
 my %help=();
@@ -80,11 +79,7 @@ sub storemap {
 			      $map,1,$report);
     if ($errtext) { return ($errtext,2); }
 
-    if ($map =~ /^default/) {
-        $hadchanges=1;
-    } else {
-        $suppchanges=1;
-    }
+    $hadchanges=1;
     return ($errtext,0);
 }
 
@@ -355,7 +350,7 @@ $initialtext
 </html>
 END
                 $env{'form.output'}=$newhtml;
-                my $result =
+                my $result = 
                     &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
                                                           'output',
                                                           "$filepath/$residx/$fname.html");
@@ -380,7 +375,7 @@ END
                           removefrommap => \%removefrommap,
                           removeparam   => \%removeparam,
                       );
-        my ($result,$msgsarray,$lockerror) =
+        my ($result,$msgsarray,$lockerror) = 
             &apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated);
         if (keys(%import_errors) > 0) {
             $fixuperrors =
@@ -407,13 +402,6 @@ END
     }
     my ($errtext,$fatal) =
         &storemap($coursenum, $coursedom, $folder.'.'.$container,1);
-    unless ($fatal) {
-        if ($folder =~ /^supplemental/) {
-            &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);
-            my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
-                                            $folder.'.'.$container);
-        }
-    }
     return ($errtext,$fatal,$fixuperrors);
 }
 
@@ -1319,7 +1307,7 @@ sub do_paste_from_buffer {
                     next;
 	        }
                 if ($lockerr{$prefix}) {
-                    $lockerrs{$suffix} = $lockerr{$prefix};
+                    $lockerrs{$suffix} = $lockerr{$prefix};  
                 }
             }
         }
@@ -1358,7 +1346,7 @@ sub do_paste_from_buffer {
                     if ($newdocsdir eq '') {
                         $newdocsdir = 'default';
                     }
-                    if (($prefixchg{$suffix}) ||
+                    if (($prefixchg{$suffix}) || 
                         ($srcdom{$suffix} ne $coursedom) || 
                         ($srcnum{$suffix} ne $coursenum) ||
                         ($env{'form.docs.markedcopy_options_'.$suffix} ne 'move')) {
@@ -1565,7 +1553,7 @@ sub dbcopy {
     if (ref($dbref) eq 'HASH') {
         if ($url =~ m{/(smppg|bulletinboard)$}) {
             my $prefix = $1;
-            if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
+            if (($dbref->{'cdom'} =~ /^$match_domain$/) && 
                 ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
                 my $db_name;
                 my $marker = (split(m{/},$url))[4];
@@ -1600,12 +1588,12 @@ sub dbcopy {
                         my $photo = $contents{'uploaded.photourl'};
                         my ($subdir,$fname) =
                             ($photo =~ m{^/uploaded/$match_domain/$match_courseid/+(bulletin|simplepage)/(?:|\d+/)([^/]+)$});
-                        my $newphoto;
+                        my $newphoto; 
                         if ($fname ne '') {
                             my $content = &Apache::lonnet::getfile($photo);
                             unless ($content eq '-1') {
                                 $env{'form.'.$suffix.'.photourl'} = $content;
-                                $newphoto =
+                                $newphoto = 
                                     &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$suffix.'.photourl',"$subdir/$suffix/$fname");
                                 delete($env{'form.'.$suffix.'.photourl'});
                             }
@@ -1622,18 +1610,16 @@ sub dbcopy {
                     }
                 }
                 if (($freedlock ne 'ok') && (ref($lockerrorsref) eq 'HASH')) {
-                    $lockerrorsref->{$prefix} =
+                    $lockerrorsref->{$prefix} = 
                         '<div class="LC_error">'.
                         &mt('There was a problem removing a lockfile.');
                     if ($prefix eq 'smppg') {
-                        $lockerrorsref->{$prefix} .=
-                            ' '.&mt('This will prevent creation of additional simple pages in this course.');
+                        $lockerrorsref->{$prefix} .= 
+                            &mt('This will prevent creation of additional simple pages in this course.');
                     } else {
-                        $lockerrorsref->{$prefix} .= ' '.&mt('This will prevent creation of additional bulletin boards in this course.');
+                        $lockerrorsref->{$prefix} .= &mt('This will prevent creation of additional bulletin boards in this course.');
                     }
-                    $lockerrorsref->{$prefix} .= ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
-                                                     '<a href="/adm/helpdesk" target="_helpdesk">','</a>').
-                                                 '</div>';
+                    $lockerrorsref->{$prefix} .= &mt('Please contact the domain coordinator for your LON-CAPA domain.').'</div>';
                 }
             }
         } elsif ($url =~ m{/syllabus$}) {
@@ -1750,7 +1736,7 @@ sub url_paste_fixups {
             }
             next if ($token->[2]->{'type'} eq 'external');
             if ($token->[2]->{'type'} eq 'zombie') {
-                next if ($skip);
+                next if ($skip);  
                 $zombies->{$oldurl}{$id} = $ressrc;
                 $changed = 1;
             } elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
@@ -2196,7 +2182,7 @@ sub update_parameter {
                          'randomorder'    => {},
                       );
         foreach my $which (keys(%allchecked)) {
-            $env{'form.all'.$which} =~ s/,$//;
+            $env{'form.all'.$which} =~ s/,$//;   
             if ($which eq 'randompick') {
                 foreach my $item (split(/,/,$env{'form.all'.$which})) {
                     my ($res,$value) = split(/:/,$item);
@@ -2223,7 +2209,7 @@ sub update_parameter {
             foreach my $which (keys(%allchecked)) {
                 if (($which eq 'randompick' || $which eq 'randomorder')) {
                     next if (!$is_map);
-                }
+                } 
                 my $oldvalue = 0;
                 my $newvalue = 0;
                 if ($allchecked{$which}{$res}) {
@@ -2682,11 +2668,11 @@ sub editor {
                     if (@allidx > 0) {
                         my $path;
                         if ($env{'form.folderpath'}) {
-                            $path =
+                            $path = 
                                 &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
                         }
                         if (@allidx > 1) {
-                            $to_show .=
+                            $to_show .= 
                                 &Apache::loncommon::continue_data_table_row().
                                 '<td colspan="2">&nbsp;</td>'.
                                 '<td>'.
@@ -2718,7 +2704,7 @@ sub editor {
             }
             $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll')
                        .'<div class="LC_info" id="contentlist">'
-                       .&mt('Currently empty')
+                       .&mt('Currently no documents.')
                        .'</div>'
                        .&Apache::loncommon::end_scrollbox();
         }
@@ -2731,7 +2717,7 @@ sub editor {
                       .'</div>';
         } else {
             $to_show = '<div class="LC_info" id="contentlist">'
-                      .&mt('Currently empty')
+                      .&mt('Currently no documents.')
                       .'</div>'
         }
     }
@@ -2816,30 +2802,8 @@ sub multiple_check_form {
 }
 
 sub process_file_upload {
-    my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd,$crstype) = @_;
+    my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd) = @_;
 # upload a file, if present
-    my $filesize = length($env{'form.uploaddoc'});
-    if (!$filesize) {
-        $$upload_output = '<div class="LC_error">'.
-                           &mt('Unable to upload [_1]. (size = [_2] bytes)',
-                          '<span class="LC_filename">'.$env{'form.uploaddoc.filename'}.'</span>',
-                          $filesize).'<br />'.
-                          &mt('Either the file you attempted to upload was empty, or your web browser was unable to read its contents.').'<br />'.
-                          '</div>';
-        return;
-    }
-    my $quotatype = 'unofficial';
-    if ($crstype eq 'Community') {
-        $quotatype = 'community';
-    } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.instcode'}) {
-        $quotatype = 'official';
-    }
-    if (&Apache::loncommon::get_user_quota($coursenum,$coursedom,'course',$quotatype)) {
-        $filesize = int($filesize/1000); #expressed in kb
-        $$upload_output = &Apache::loncommon::excess_filesize_warning($coursenum,$coursedom,'course',
-                                                                      $env{'form.uploaddoc.filename'},$filesize,'upload');
-        return if ($$upload_output);
-    }
     my ($parseaction,$showupload,$nextphase,$mimetype);
     if ($env{'form.parserflag'}) {
         $parseaction = 'parse';
@@ -3159,9 +3123,11 @@ ENDREM
                 push(@{$filtersref->{'canremove'}},$orderidx);
             }
         }
-        $renamelink=(<<ENDREN);
+        unless ($isexternal) {
+            $renamelink=(<<ENDREN);
 <a href='javascript:changename("$esc_path","$index","$renametitle");' class="LC_docs_rename">$lt{'rn'}</a>
 ENDREN
+        }
 	$line.=(<<END);
 <td>
 <div class="LC_docs_entry_move">
@@ -3300,7 +3266,7 @@ $form_common."\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>'.
-$form_end;
+$form_end; 
         }
     } elsif ($supplementalflag && !$allowed) {
         $url .= ($url =~ /\?/) ? '&amp;':'?';
@@ -3504,7 +3470,7 @@ sub new_timebased_suffix {
         }
     }
     if ($freedlock ne 'ok') {
-        $locknotfreed =
+        $locknotfreed = 
             '<div class="LC_error">'.
             &mt('There was a problem removing a lockfile.').' ';
         if ($type eq 'paste') {
@@ -3520,8 +3486,7 @@ sub new_timebased_suffix {
         }
         unless ($type eq 'paste') {
             $locknotfreed .=
-                ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
-                        '<a href="/adm/helpdesk" target="_helpdesk">','</a>');
+                ' '.&mt('Please contact the domain coordinator for your LON-CAPA domain.');
         }
         $locknotfreed .= '</div>';
     }
@@ -4064,6 +4029,7 @@ sub startContentScreen {
     if (($mode eq 'navmaps') || ($mode eq 'supplemental')) {
         $output .= '<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b>&nbsp;&nbsp;&nbsp;&nbsp;'.&mt('Content Overview').'&nbsp;&nbsp;&nbsp;&nbsp;</b></a></li>'."\n";
         $output .= '<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.&mt('Content Search').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></a></li>'."\n";
+        $output .= '<li'.(($mode eq 'courseindex')?' class="active"':'').'><a href="/adm/indexcourse"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.&mt('Content Index').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></a></li>'."\n";
         $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>';
     } else {
         $output .= '<li '.(($mode eq 'docs')?' class="active"':'').' id="tabbededitor"><a href="/adm/coursedocs?forcestandard=1"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.&mt('Main Content Editor').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></a></li>'."\n";
@@ -4112,8 +4078,7 @@ sub handler {
 	               'Supplemental','Score_Upload_Form','Adding_Pages',
 	               'Importing_LON-CAPA_Resource','Importing_IMS_Course',
                        'Uploading_From_Harddrive',
-	               'Check_Resource_Versions','Verify_Content',
-                       'Course_Roster','Web_Page','Dropbox') {
+	               'Check_Resource_Versions','Verify_Content') {
 	$help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
     }
     # Composite help files
@@ -4129,6 +4094,8 @@ sub handler {
 		  'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
     $help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
     $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
+    $help{'Course Roster'} = &Apache::loncommon::help_open_topic('Docs_Course_Roster');
+    $help{'Web Page'} =  &Apache::loncommon::help_open_topic('Docs_Web_Page');
  
     my $allowed;
 # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
@@ -4185,9 +4152,9 @@ sub handler {
 # supplementalflag=0: show standard documents
 # toolsflag=1: show utilities
 
-    my $unesc_folderpath = &unescape($env{'form.folderpath'});
-    my $supplementalflag=($unesc_folderpath=~/^supplemental/);
-    if (($unesc_folderpath=~/^default/) || ($unesc_folderpath eq "")) {
+    $env{'form.folderpath'} = &unescape($env{'form.folderpath'});
+    my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/);
+    if (($env{'form.folderpath'}=~/^default/) || ($env{'form.folderpath'} eq "")) {
        $supplementalflag=0;
     }
     if ($env{'form.forcesupplement'}) { $supplementalflag=1; }
@@ -4393,7 +4360,7 @@ sub handler {
           # Process file upload - phase one - upload and parse primary file.
 	  undef($hadchanges);
           $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,
-                                              \%allfiles,\%codebase,$context,$crstype);
+                                              \%allfiles,\%codebase,$context);
 	  if ($hadchanges) {
 	      &mark_hash_old();
 	  }
@@ -4445,7 +4412,7 @@ sub handler {
        my %lt=&Apache::lonlocal::texthash(
 		'copm' => 'All documents out of a published map into this folder',
                 'upfi' => 'Upload File',
-                'upld' => 'Upload Content',
+                'upld' => 'Import Content',
                 'srch' => 'Search',
                 'impo' => 'Import',
 		'lnks' => 'Import from Stored Links',
@@ -4458,7 +4425,7 @@ sub handler {
                 'navc' => 'Table of Contents',
                 'sipa' => 'Simple Course Page',
                 'sipr' => 'Simple Problem',
-                'webp' => 'Blank Web Page (editable)',
+                'webp' => 'Blank Web Page (editable)', 
                 'drbx' => 'Drop Box',
                 'scuf' => 'External Scores (handgrade, upload, clicker)',
                 'bull' => 'Discussion Board',
@@ -4466,8 +4433,8 @@ sub handler {
                 'grpo' => 'Group Portfolio',
                 'rost' => 'Course Roster',
                 'abou' => 'Personal Information Page for a User',
-                'imsf' => 'IMS Upload',
-                'imsl' => 'Upload IMS package',
+                'imsf' => 'IMS Import',
+                'imsl' => 'Import IMS package',
                 'cms'  => 'Origin of IMS package',
                 'se'   => 'Select',
                 'file' =>  'File',
@@ -4671,7 +4638,6 @@ NSPROBFORM
 	$pathitem
 	<input type="hidden" name="importdetail" value="" />
 	<a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a>
-        $help{'Dropbox'}
 	</form>
 NDBFORM
 
@@ -4722,7 +4688,7 @@ NASOFORM
 	<input type="hidden" name="importdetail" 
 	value="$lt{'rost'}=/adm/viewclasslist" />
 	<a class="LC_menubuttons_link" href="javascript:document.newroster.submit()">$lt{'rost'}</a>
-	$help{'Course_Roster'}
+	$help{'Course Roster'}
 	</form>
 NROSTFORM
 
@@ -4742,7 +4708,7 @@ NROSTFORM
         $pathitem
         <input type="hidden" name="importdetail" value="$newwebpage" />
         <a class="LC_menubuttons_link" href="javascript:makewebpage();">$lt{'webp'}</a>
-        $help{'Web_Page'}
+        $help{'Web Page'}
         </form>
 NWEBFORM
  
@@ -4819,7 +4785,7 @@ NGFFORM
             );
         }
         push(@importdoc,
-            {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'doc\');" />'=>$fileuploadform}
+            {'<img class="LC_noBorder_LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'doc\');" />'=>$fileuploadform}
         );
         $fileuploadform =  &create_form_ul(&create_list_elements(@importdoc));
 
@@ -4841,14 +4807,14 @@ NGFFORM
         $communityform = &create_form_ul(&create_list_elements(@communityforma));
 
 my %orderhash = (
-                'aa' => ['Upload',$fileuploadform],
-                'bb' => ['Import',$importpubform],
-                'cc' => ['Grading',$gradingform],
+                'aa' => ['Import Content',$fileuploadform],
+                'bb' => ['Published Content',$importpubform],
+                'cc' => ['Grading Resources',$gradingform],
                 );
 unless ($container eq 'page') {
     $orderhash{'00'} = ['Newfolder',$newfolderform];
     $orderhash{'dd'} = ['Collaboration',$communityform];
-    $orderhash{'ee'} = ['Other',$specialdocumentsform];
+    $orderhash{'ee'} = ['Special Pages',$specialdocumentsform];
 }
 
  $hadchanges=0;
@@ -4959,7 +4925,7 @@ SNAMFORM
         $pathitem
         <input type="hidden" name="importdetail" value="$supwebpage" />
         <a class="LC_menubuttons_link" href="javascript:makewebpage('supp');">$lt{'webp'}</a>
-        $help{'Web_Page'}
+        $help{'Web Page'}
         </form>
 SWEBFORM
 
@@ -4982,26 +4948,14 @@ my @supimportdoc = (
 $supupdocform =  &create_form_ul(&create_list_elements(@supimportdoc));
 my %suporderhash = (
 		'00' => ['Supnewfolder', $supnewfolderform],
-                'ee' => ['Upload',$supupdocform],
-                'ff' => ['Other',&create_form_ul(&create_list_elements(@specialdocs))]
+                'ee' => ['Import Content',$supupdocform],
+                'ff' => ['Special Pages',&create_form_ul(&create_list_elements(@specialdocs))]
                 );
         if ($supplementalflag) {
            my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
                                $supplementalflag,\%suporderhash,$iconpath,$pathitem);
            if ($error) {
               $r->print('<p><span class="LC_error">'.$error.'</span></p>');
-           } else {
-               if ($suppchanges) {
-                   my %servers = &Apache::lonnet::internet_dom_servers($coursedom);
-                   my @ids=&Apache::lonnet::current_machine_ids();
-                   foreach my $server (keys(%servers)) {
-                       next if (grep(/^\Q$server\E$/,@ids));
-                       my $hashid=$coursenum.':'.$coursedom;
-                       &Apache::lonnet::remote_devalidate_cache($server,'suppcount',$hashid);
-                   }
-                   &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);
-                   undef($suppchanges);
-               }
            }
         }
     } elsif ($supplementalflag) {
@@ -5376,7 +5330,7 @@ sub editing_js {
                                           p_msb => 'Title for the Problem',
                                           p_mdb => 'Title for the Drop Box',
                                           p_mbb => 'Title for the Discussion Board',
-                                          p_mwp => 'Title for Web Page',
+                                          p_mwp => 'Title for Web Page', 
                                           p_mab => "Enter user:domain for User's Personal Information Page",
                                           p_mab2 => 'Personal Information Page of ',
                                           p_mab_alrt1 => 'Not a valid user:domain',
@@ -5490,7 +5444,7 @@ function makewebpage(type) {
        formname = this.document.forms.newwebpage;
    }
    if (title) {
-       var webpage = formname.importdetail.value;
+       var webpage = formname.importdetail.value; 
        formname.importdetail.value = escape(title)+'='+webpage;
        formname.submit();
    }