--- loncom/lond	2021/02/08 14:50:53	1.565
+++ loncom/lond	2021/03/31 02:19:58	1.566
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.565 2021/02/08 14:50:53 raeburn Exp $
+# $Id: lond,v 1.566 2021/03/31 02:19:58 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -65,7 +65,7 @@ my $DEBUG = 0;		       # Non zero to ena
 my $status='';
 my $lastlog='';
 
-my $VERSION='$Revision: 1.565 $'; #' stupid emacs
+my $VERSION='$Revision: 1.566 $'; #' stupid emacs
 my $remoteVERSION;
 my $currenthostid="default";
 my $currentdomainid;
@@ -213,6 +213,7 @@ my %trust = (
                autovalidateclass_sec => {catalog => 1},
                autovalidatecourse => {remote => 1, enroll => 1},
                autovalidateinstcode => {domroles => 1, remote => 1, enroll => 1},
+               autovalidateinstcrosslist => {remote => 1, enroll => 1},
                changeuserauth => {remote => 1, domroles => 1},
                chatretr => {remote => 1, enroll => 1},
                chatsend => {remote => 1, enroll => 1},
@@ -5948,6 +5949,39 @@ sub validate_instcode_handler {
 }
 &register_handler("autovalidateinstcode", \&validate_instcode_handler, 0, 1, 0);
 
+#
+#  Validate co-owner for cross-listed institutional code and
+#  institutional course code itself used for a LON-CAPA course.
+#
+# Formal Parameters:
+#   $cmd          - The command request that got us dispatched.
+#   $tail         - The tail of the command.  In this case,
+#                   this is a colon separated string containing:
+#      $dom            - Course's LON-CAPA domain
+#      $instcode       - Institutional course code for the course
+#      $inst_xlist     - Institutional course Id for the crosslisting
+#      $coowner        - Username of co-owner
+#      (values for all but $dom have been escaped). 
+#
+#   $client       - Socket open on the client.
+# Returns:
+#    1           - Indicating processing should continue.
+#
+sub validate_instcrosslist_handler  {
+    my ($cmd, $tail, $client) = @_;
+    my $userinput = "$cmd:$tail";
+    my ($dom,$instcode,$inst_xlist,$coowner) = split(/:/,$tail);
+    $instcode = &unescape($instcode);
+    $inst_xlist = &unescape($inst_xlist);
+    $coowner = &unescape($coowner);
+    my $outcome = &localenroll::validate_crosslist_access($dom,$instcode,
+                                                          $inst_xlist,$coowner);
+    &Reply($client, \$outcome, $userinput);
+
+    return 1;
+}
+&register_handler("autovalidateinstcrosslist", \&validate_instcrosslist_handler, 0, 1, 0);
+
 #   Get the official sections for which auto-enrollment is possible.
 #   Since the admin people won't know about 'unofficial sections' 
 #   we cannot auto-enroll on them.