--- loncom/interface/loncommon.pm 2007/08/31 17:58:47 1.577 +++ loncom/interface/loncommon.pm 2007/09/03 15:34:12 1.578 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.577 2007/08/31 17:58:47 raeburn Exp $ +# $Id: loncommon.pm,v 1.578 2007/09/03 15:34:12 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -6983,7 +6983,7 @@ sub commit_studentrole { ############################################################ sub check_clone { - my ($args) = @_; + my ($args,$linefeed) = @_; my $cloneid='/'.$args->{'clonedomain'}.'/'.$args->{'clonecourse'}; my ($clonecrsudom,$clonecrsunum)= &LONCAPA::split_courseid($cloneid); my $clonehome=&Apache::lonnet::homeserver($clonecrsunum,$clonecrsudom); @@ -6991,8 +6991,7 @@ sub check_clone { my $can_clone = 0; if ($clonehome eq 'no_host') { - $clonemsg = &mt('Attempting to clone non-existing [_1]', - $args->{'crstype'}); + $clonemsg = &mt('No new course created.').$linefeed.&mt('A new course could not be cloned from the specified original - [_1] - because it is a non-existent course.',$args->{'clonecourse'}.':'.$args->{'clonedomain'}); } else { my %clonedesc = &Apache::lonnet::coursedescription($cloneid,{'one_time' => 1}); if ($env{'request.role.domain'} eq $args->{'clonedomain'}) { @@ -7001,18 +7000,24 @@ sub check_clone { my %clonehash = &Apache::lonnet::get('environment',['cloners'], $args->{'clonedomain'},$args->{'clonecourse'}); my @cloners = split(/,/,$clonehash{'cloners'}); - my %roleshash = - &Apache::lonnet::get_my_roles($args->{'ccuname'}, - $args->{'ccdomain'},'userroles',['active'],['cc'], - [$args->{'clonedomain'}]); - if (($roleshash{$args->{'clonecourse'}.':'.$args->{'clonedomain'}.':cc'}) || (grep(/^\Q$args->{'ccuname'}\E:\Q$args->{'ccdomain'}\E$/,@cloners))) { - $can_clone = 1; - } else { - $clonemsg = &mt('The new course was not cloned from an existing course because the new course owner ([_1]) does not have cloning rights in the existing course ([_2]).',$args->{'ccuname'}.':'.$args->{'ccdomain'},$clonedesc{'description'}); + if (grep(/^\*$/,@cloners)) { + $can_clone = 1; + } elsif (grep(/^\*\:\Q$args->{'ccdomain'}\E$/,@cloners)) { + $can_clone = 1; + } else { + my %roleshash = + &Apache::lonnet::get_my_roles($args->{'ccuname'}, + $args->{'ccdomain'}, + 'userroles',['active'],['cc'], + [$args->{'clonedomain'}]); + if (($roleshash{$args->{'clonecourse'}.':'.$args->{'clonedomain'}.':cc'}) || (grep(/^\Q$args->{'ccuname'}\E:\Q$args->{'ccdomain'}\E$/,@cloners))) { + $can_clone = 1; + } else { + $clonemsg = &mt('No new course created.').$linefeed.&mt('The new course could not be cloned from the existing course because the new course owner ([_1]) does not have cloning rights in the existing course ([_2]).',$args->{'ccuname'}.':'.$args->{'ccdomain'},$clonedesc{'description'}); + } } - } + } } - return ($can_clone, $clonemsg, $cloneid, $clonehome); } @@ -7029,9 +7034,11 @@ sub construct_course { # my ($can_clone, $clonemsg, $cloneid, $clonehome); if (($args->{'clonecourse'}) && ($args->{'clonedomain'})) { - ($can_clone, $clonemsg, $cloneid, $clonehome) = &check_clone($args); + ($can_clone, $clonemsg, $cloneid, $clonehome) = &check_clone($args,$linefeed); if ($context ne 'auto') { - $clonemsg = ''.$clonemsg.''; + if ($clonemsg ne '') { + $clonemsg = ''.$clonemsg.''; + } } $outcome .= $clonemsg.$linefeed;