--- loncom/interface/loncommon.pm 2006/07/28 06:09:34 1.438
+++ loncom/interface/loncommon.pm 2006/08/11 21:55:19 1.443
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.438 2006/07/28 06:09:34 albertel Exp $
+# $Id: loncommon.pm,v 1.443 2006/08/11 21:55:19 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2092,9 +2092,9 @@ sub screenname {
sub messagewrapper {
my ($link,$username,$domain,$subject,$text)=@_;
return
- ''.$link.'';
}
# --------------------------------------------------------------- Notes Wrapper
@@ -3200,6 +3200,9 @@ form, .inline { display: inline; }
.LC_success {
color: green;
}
+.LC_icon {
+ border: 0px;
+}
table#LC_top_nav, table#LC_menubuttons {
width: 100%;
@@ -3287,6 +3290,10 @@ table#LC_top_nav td.LC_top_nav_exit,
table#LC_top_nav td.LC_top_nav_help {
width: 2.0em;
}
+table#LC_top_nav td.LC_top_nav_login {
+ width: 4.0em;
+ text-align: center;
+}
table.LC_breadcrumbs td, table.LC_docs_path td {
background: $tabbg;
color: $font;
@@ -3327,6 +3334,11 @@ td.LC_menubuttons_img {
font-weight: bold;
}
+table.LC_aboutme_port {
+ border: 0px;
+ border-collapse: collapse;
+ border-spacing: 0px;
+}
table.LC_data_table, table.LC_mail_list {
border: 1px solid #000000;
border-collapse: separate;
@@ -3340,11 +3352,13 @@ table.LC_data_table tr th, table.LC_cale
background-color: $data_table_head;
font-size: smaller;
}
-table.LC_data_table tr td {
+table.LC_data_table tr td,
+table.LC_aboutme_port tr td {
background-color: $data_table_light;
padding: 2px;
}
-table.LC_data_table tr.LC_even_row td {
+table.LC_data_table tr.LC_even_row td,
+table.LC_aboutme_port tr.LC_even_row td {
background-color: $data_table_dark;
}
table.LC_data_table tr.LC_data_table_highlight td {
@@ -4342,13 +4356,20 @@ sub get_course_users {
}
}
if ((@{$roles} > 1) || ((@{$roles} == 1) && ($$roles[0] ne "st"))) {
- my @coursepersonnel = &Apache::lonnet::getkeys('nohist_userroles',$cdom,$cnum);
- foreach my $person (@coursepersonnel) {
+ my %coursepersonnel = &Apache::lonnet::dump('nohist_userroles',$cdom,$cnum);
+ my $now = time;
+ foreach my $person (sort(keys(%coursepersonnel))) {
my $match = 0;
my $secmatch = 0;
+ my $status;
my ($role,$user,$usec) = ($person =~ /^([^:]*):([^:]+:[^:]+):([^:]*)/);
$user =~ s/:$//;
- if (($role) && (grep(/^\Q$role\E$/,@{$roles}))) {
+ my ($end,$start) = split(/:/,$coursepersonnel{$person});
+ if ($end == -1 || $start == -1) {
+ next;
+ }
+ if (($role) && ((grep(/^\Q$role\E$/,@{$roles})) ||
+ (grep(/^cr$/,@{$roles}) && $role =~ /^cr\//))) {
my ($uname,$udom) = split(/:/,$user);
if ((ref($sections) eq 'ARRAY') && (@{$sections} > 0)) {
if (grep(/^all$/,@{$sections})) {
@@ -4370,8 +4391,13 @@ sub get_course_users {
$usec = 'none';
}
if ($uname ne '' && $udom ne '') {
- my $status = &check_user_status($udom,$uname,$cdom,$cnum,$role,
- $usec);
+ if ($end < $now) {
+ $status = 'previous';
+ } elsif ($start > $now) {
+ $status = 'future';
+ } else {
+ $status = 'active';
+ }
foreach my $type (keys(%{$types})) {
if ($status eq $type) {
if (!grep(/^\Q$type\E$/,@{$$users{$role}{$user}})) {
@@ -4396,7 +4422,10 @@ sub get_course_users {
my %csettings = &Apache::lonnet::get('environment',['internal.courseowner'],$cdom,$cnum);
if ( defined($csettings{'internal.courseowner'}) ) {
my $owner = $csettings{'internal.courseowner'};
- @{$$users{'ow'}{$owner.':'.$cdom}} = 'any';
+ if ($owner !~ /^[^:]+:[^:]+$/) {
+ $owner = $owner.':'.$cdom;
+ }
+ @{$$users{'ow'}{$owner}} = 'any';
if (defined($userdata) &&
!exists($$userdata{$owner.':'.$cdom})) {
&get_user_info($cdom,$owner,\%idx,$userdata);
@@ -5474,6 +5503,92 @@ sub restore_course_settings {
}
############################################################
+############################################################
+
+sub commit_customrole {
+ my ($udom,$uname,$url,$three,$four,$five,$start,$end) = @_;
+ my $output = &mt('Assigning custom role').' "'.$five.'" by '.$four.'@'.$three.' in '.$url.
+ ($start?', '.&mt('starting').' '.localtime($start):'').
+ ($end?', ending '.localtime($end):'').': '.
+ &Apache::lonnet::assigncustomrole(
+ $udom,$uname,$url,$three,$four,$five,$end,$start).
+ '
';
+ return $output;
+}
+
+sub commit_standardrole {
+ my ($udom,$uname,$url,$three,$start,$end,$one,$two,$sec) = @_;
+ my $output;
+ my $logmsg;
+ if ($three eq 'st') {
+ my $result = &commit_studentrole(\$logmsg,$udom,$uname,$url,$three,$start,$end,$one,$two,$sec);
+ if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course')) {
+ $output = "Error: $result\n";
+ } else {
+ $output = &mt('Assigning').' '.$three.' in '.$url.
+ ($start?', '.&mt('starting').' '.localtime($start):'').
+ ($end?', '.&mt('ending').' '.localtime($end):'').
+ ': '.$result.'
'.
+ &mt('Add to classlist').': ok
';
+ }
+ } else {
+ $output = &mt('Assigning').' '.$three.' in '.$url.
+ ($start?', '.&mt('starting').' '.localtime($start):'').
+ ($end?', '.&mt('ending').' '.localtime($end):'').': '.
+ &Apache::lonnet::assignrole(
+ $udom,$uname,$url,$three,$end,$start).
+ '
';
+ }
+ return $output;
+}
+
+sub commit_studentrole {
+ my ($logmsg,$udom,$uname,$url,$three,$start,$end,$one,$two,$sec) = @_;
+ my $linefeed = '
'."\n";
+ my $result;
+ if (defined($one) && defined($two)) {
+ my $cid=$one.'_'.$two;
+ my $oldsec=&Apache::lonnet::getsection($udom,$uname,$cid);
+ my $secchange = 0;
+ my $expire_role_result;
+ my $modify_section_result;
+ unless ($oldsec eq '-1') {
+ unless ($sec eq $oldsec) {
+ $secchange = 1;
+ my $uurl='/'.$cid;
+ $uurl=~s/\_/\//g;
+ if ($oldsec) {
+ $uurl.='/'.$oldsec;
+ }
+ $expire_role_result = &Apache::lonnet::assignrole($udom,$uname,$uurl,'st',time);
+ $result = $expire_role_result;
+ }
+ }
+ if (($expire_role_result eq 'ok') || ($secchange == 0)) {
+ $modify_section_result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,'','',$cid);
+ if ($modify_section_result =~ /^ok/) {
+ if ($secchange == 1) {
+ $$logmsg .= "Section for $uname switched from old section: $oldsec to new section: $sec".$linefeed;
+ } elsif ($oldsec eq '-1') {
+ $$logmsg .= "New student role for $uname in section $sec in course $cid".$linefeed;
+ } else {
+ $$logmsg .= "Student $uname assigned to unchanged section $sec in course $cid".$linefeed;
+ }
+ } else {
+ $$logmsg .= "Error when attempting section change for $uname from old section $oldsec to new section: $sec in course $cid -error: $modify_section_result".$linefeed;
+ }
+ $result = $modify_section_result;
+ } elsif ($secchange == 1) {
+ $$logmsg .= "Error when attempting to expire role for $uname in old section $oldsec in course $cid -error: $expire_role_result".$linefeed;
+ }
+ } else {
+ $$logmsg .= "Incomplete course id defined. Addition of user $uname from domain $udom to course $one\_$two, section $sec not completed.$linefeed";
+ $result = "error: incomplete course id\n";
+ }
+ return $result;
+}
+
+############################################################
############################################################
sub course_type {