Diff for /loncom/interface/loncommon.pm between versions 1.654 and 1.655

version 1.654, 2008/05/27 22:26:11 version 1.655, 2008/05/29 02:58:41
Line 7955  defdom (domain for which to retrieve con Line 7955  defdom (domain for which to retrieve con
 origmail (scalar - email address of recipient from loncapa.conf,   origmail (scalar - email address of recipient from loncapa.conf, 
 i.e., predates configuration by DC via domainprefs.pm   i.e., predates configuration by DC via domainprefs.pm 
   
 Returns: comma separated list of addresses to which to send e-mail.     Returns: comma separated list of addresses to which to send e-mail.
   
   =back
   
 =cut  =cut
   
Line 8006  sub build_recipient_list { Line 8008  sub build_recipient_list {
 ############################################################  ############################################################
 ############################################################  ############################################################
   
   =pod
   
   =head1 Course Catalog Routines
   
   =over 4
   
   =item * &gather_categories()
   
   Converts category definitions - keys of categories hash stored in  
   coursecategories in configuration.db on the primary library server in a 
   domain - to an array.  Also generates javascript and idx hash used to 
   generate Domain Coordinator interface for editing Course Categories.
   
   Inputs:
   categories (reference to hash of category definitions).
   cats (reference to array of arrays/hashes which encapsulates hierarchy of
         categories and subcategories).
   idx (reference to hash of counters used in Domain Coordinator interface for 
         editing Course Categories).
   jsarray (reference to array of categories used to create Javascript arrays for
            Domain Coordinator interface for editing Course Categories).
   
   Returns: nothing
   
   Side effects: populates cats, idx and jsarray. 
   
   =cut
   
   sub gather_categories {
       my ($categories,$cats,$idx,$jsarray) = @_;
       my %counters;
       my $num = 0;
       foreach my $item (keys(%{$categories})) {
           my ($cat,$container,$depth) = map { &unescape($_); } split(/:/,$item);
           if ($container eq '' && $depth == 0) {
               $cats->[$depth][$categories->{$item}] = $cat;
           } else {
               $cats->[$depth]{$container}[$categories->{$item}] = $cat;
           }
           my ($escitem,$tail) = split(/:/,$item,2);
           if ($counters{$tail} eq '') {
               $counters{$tail} = $num;
               $num ++;
           }
           if (ref($idx) eq 'HASH') {
               $idx->{$item} = $counters{$tail};
           }
           if (ref($jsarray) eq 'ARRAY') {
               push(@{$jsarray->[$counters{$tail}]},$item);
           }
       }
       return;
   }
   
   =pod
   
   =item * &extract_categories()
   
   Used to generate breadcrumb trails for course categories.
   
   Inputs:
   categories (reference to hash of category definitions).
   cats (reference to array of arrays/hashes which encapsulates hierarchy of
         categories and subcategories).
   trails (reference to array of breacrumb trails for each category).
   allitems (reference to hash - key is category key 
            (format: escaped(name):escaped(parent category):depth in hierarchy).
   idx (reference to hash of counters used in Domain Coordinator interface for
         editing Course Categories).
   jsarray (reference to array of categories used to create Javascript arrays for
            Domain Coordinator interface for editing Course Categories).
   
   Returns: nothing
   
   Side effects: populates trails and allitems hash references.
   
   =cut
   
   sub extract_categories {
       my ($categories,$cats,$trails,$allitems,$idx,$jsarray) = @_;
       if (ref($categories) eq 'HASH') {
           &gather_categories($categories,$cats,$idx,$jsarray);
           if (ref($cats->[0]) eq 'ARRAY') {
               for (my $i=0; $i<@{$cats->[0]}; $i++) {
                   my $name = $cats->[0][$i];
                   my $item = &escape($name).'::0';
                   my $trailstr;
                   if ($name eq 'instcode') {
                       $trailstr = &mt('Official courses (with institutional codes)');
                   } else {
                       $trailstr = $name;
                   }
                   if ($allitems->{$item} eq '') {
                       push(@{$trails},$trailstr);
                       $allitems->{$item} = scalar(@{$trails})-1;
                   }
                   my @parents = ($name);
                   if (ref($cats->[1]{$name}) eq 'ARRAY') {
                       for (my $j=0; $j<@{$cats->[1]{$name}}; $j++) {
                           my $category = $cats->[1]{$name}[$j];
                           &recurse_categories($cats,2,$category,$trails,$allitems,\@parents);
                       }
                   }
               }
           }
       }
       return;
   }
   
   =pod
   
   =item *&recurse_categories()
   
   Recursively used to generate breadcrumb trails for course categories.
   
   Inputs:
   cats (reference to array of arrays/hashes which encapsulates hierarchy of
         categories and subcategories).
   depth (current depth in hierarchy of categories and sub-categories - 0 indexed).
   category (current course category, for which breadcrumb trail is being generated).   
   trails (reference to array of breacrumb trails for each category).
   allitems (reference to hash - key is category key
            (format: escaped(name):escaped(parent category):depth in hierarchy).
   parents (array containing containers directories for current category, 
            back to top level). 
   
   Returns: nothing
   
   Side effects: populates trails and allitems hash references
   
   =back
   
   =cut
   
   sub recurse_categories {
       my ($cats,$depth,$category,$trails,$allitems,$parents) = @_;
       my $shallower = $depth - 1;
       if (ref($cats->[$depth]{$category}) eq 'ARRAY') {
           for (my $k=0; $k<@{$cats->[$depth]{$category}}; $k++) {
               my $name = $cats->[$depth]{$category}[$k];
               my $item = &escape($category).':'.&escape($parents->[-1]).':'.$shallower;
               my $trailstr = join(' -&gt; ',(@{$parents},$category));
               if ($allitems->{$item} eq '') {
                   push(@{$trails},$trailstr);
                   $allitems->{$item} = scalar(@{$trails})-1;
               }
               my $deeper = $depth+1;
               push(@{$parents},$category);
               &recurse_categories($cats,$deeper,$name,$trails,$allitems,$parents);
               pop(@{$parents});
           }
       } else {
           my $item = &escape($category).':'.&escape($parents->[-1]).':'.$shallower;
           my $trailstr = join(' -&gt; ',(@{$parents},$category));
           if ($allitems->{$item} eq '') {
               push(@{$trails},$trailstr);
               $allitems->{$item} = scalar(@{$trails})-1;
           }
       }
       return;
   }
   
   ############################################################
   ############################################################
   
   
 sub commit_customrole {  sub commit_customrole {
     my ($udom,$uname,$url,$three,$four,$five,$start,$end) = @_;      my ($udom,$uname,$url,$three,$four,$five,$start,$end) = @_;
     my $output = &mt('Assigning custom role').' "'.$five.'" by '.$four.':'.$three.' in '.$url.      my $output = &mt('Assigning custom role').' "'.$five.'" by '.$four.':'.$three.' in '.$url.

Removed from v.1.654  
changed lines
  Added in v.1.655


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>