$lt{'ad'}username\@domain,username\@domain, ...
+$lt{'ad'}username:domain,username:domain, ...
$lt{'sb'}:
@@ -1077,14 +1068,14 @@ Subject:
The file format for the uploaded portion of the message is:
-username1\@domain1: text
-username2\@domain2: text
-username3\@domain1: text
+username1:domain1: text
+username2:domain2: text
+username3:domain1: text
The messages will be assembled from all lines with the respective
-username\@domain , and appended to the general message text.
+username:domain , and appended to the general message text.
$dispcrit
@@ -1311,8 +1302,8 @@ ENDBFORM
sub examblock {
my ($r,$action) = @_;
unless ($env{'request.course.id'}) { return;}
- if (!&Apache::lonnet::allowed('srm',$env{'request.course.id'})
- && ! &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
+ if (!&Apache::lonnet::allowed('dcm',$env{'request.course.id'})
+ && ! &Apache::lonnet::allowed('dcm',$env{'request.course.id'}.
'/'.$env{'request.course.sec'})) {
$r->print('Not allowed');
return;
@@ -1331,6 +1322,7 @@ sub examblock {
'dura' => 'Duration',
'setb' => 'Set by',
'even' => 'Event',
+ 'blck' => 'Blocked?',
'actn' => 'Action',
'star' => 'Start',
'endd' => 'End'
@@ -1388,7 +1380,7 @@ sub blockstore {
my %blocking = ();
$r->print('
'.$lt{'head'}.' ');
foreach my $envkey (keys(%env)) {
- if ($envkey =~ m/^form\.modify_(\w+)$/) {
+ if ($envkey =~ m/^form\.modify_(\d+)$/) {
$adds{$1} = $1;
$removals{$1} = $1;
$modtotal ++;
@@ -1401,7 +1393,7 @@ sub blockstore {
} elsif ($envkey =~ m/^form\.add_(\d+)$/) {
$adds{$1} = $1;
$addtotal ++;
- }
+ }
}
foreach my $key (keys(%removals)) {
@@ -1415,7 +1407,12 @@ sub blockstore {
unless ( defined($cancels{$key}) ) {
my ($newstart,$newend) = &get_dates_from_form($key);
my $newkey = $newstart.'____'.$newend;
- $blocking{$newkey} = $env{'user.name'}.':'.$env{'user.domain'}.':'.$env{'form.title_'.$key};
+ my $blocktypes = &get_block_choices($key);
+ $blocking{$newkey} = {
+ setter => $env{'user.name'}.':'.$env{'user.domain'},
+ event => &escape($env{'form.title_'.$key}),
+ blocks => $blocktypes,
+ };
}
}
if ($addtotal + $modtotal > 0) {
@@ -1466,6 +1463,20 @@ sub get_blockdates {
}
}
+sub get_block_choices {
+ my $item = shift;
+ my $blocklist;
+ my ($typeorder,$types) = &blocktype_text();
+ foreach my $type (@{$typeorder}) {
+ if ($env{'form.'.$type.'_'.$item}) {
+ $blocklist->{$type} = 'on';
+ } else {
+ $blocklist->{$type} = 'off';
+ }
+ }
+ return $blocklist;
+}
+
sub display_blocker_status {
my ($r,$records,$ltext) = @_;
my $parmcount = 0;
@@ -1474,13 +1485,15 @@ sub display_blocker_status {
'modi' => 'Modify',
'canc' => 'Cancel',
);
+ my ($typeorder,$types) = &blocktype_text();
$r->print(&Apache::loncommon::start_data_table());
$r->print(<<"END");
- $$ltext{'dura'}
- $$ltext{'setb'}
- $$ltext{'even'}
- $$ltext{'actn'}?
+ $ltext->{'dura'}
+ $ltext->{'setb'}
+ $ltext->{'even'}
+ $ltext->{'blck'}
+ $ltext->{'actn'}?
END
foreach my $record (sort(keys(%{$records}))) {
@@ -1491,15 +1504,29 @@ END
my $startform = &Apache::lonhtmlcommon::date_setter('blockform','startdate_'.$parmcount,$start,$onchange);
my $endform = &Apache::lonhtmlcommon::date_setter('blockform','enddate_'.$parmcount,$end,$onchange);
- my ($setuname,$setudom,$title) =
- &parse_block_record($$records{$record});
+ my ($setuname,$setudom,$title,$blocks) =
+ &Apache::loncommon::parse_block_record($$records{$record});
$title = &HTML::Entities::encode($title,'"<>&');
- my $settername = &Apache::loncommon::plainname($setuname,$setudom);
+ my $settername =
+ &Apache::loncommon::aboutmewrapper(
+ &Apache::loncommon::plainname($setuname,$setudom),
+ $setuname,$setudom);
$r->print(&Apache::loncommon::start_data_table_row());
$r->print(<<"END");
- $$ltext{'star'}: $startform $$ltext{'endd'}: $endform
+ $ltext->{'star'}: $startform $ltext->{'endd'}: $endform
$settername
+
+END
+ foreach my $block (@{$typeorder}) {
+ my $blockstatus = '';
+ if ($blocks->{$block} eq 'on') {
+ $blockstatus = 'checked="true"';
+ }
+ $r->print(' '.$types->{$block}.' ');
+ }
+ $r->print(<<"END");
+
$lt{'modi'}? $lt{'canc'}?
END
$r->print(&Apache::loncommon::end_data_table_row());
@@ -1513,19 +1540,6 @@ END
return $parmcount;
}
-sub parse_block_record {
- my ($record) = @_;
- my ($setuname,$setudom,$title);
- my @data = split(/:/,$record,3);
- if (scalar(@data) eq 2) {
- $title = $data[1];
- ($setuname,$setudom) = split(/@/,$data[0]);
- } else {
- ($setuname,$setudom,$title) = @data;
- }
- return ($setuname,$setudom,$title);
-}
-
sub display_addblocker_table {
my ($r,$parmcount,$ltext) = @_;
my $start = time;
@@ -1540,21 +1554,30 @@ sub display_addblocker_table {
'exam' => 'e.g., Exam 1',
'addn' => 'Add new communication blocking periods'
);
+ my ($typeorder,$types) = &blocktype_text();
$r->print(<<"END");
$lt{'addn'}
END
$r->print(&Apache::loncommon::start_data_table());
$r->print(<<"END");
- $$ltext{'dura'}
- $$ltext{'even'} $lt{'exam'}
- $$ltext{'actn'}?
+ $ltext->{'dura'}
+ $ltext->{'even'} $lt{'exam'}
+ $ltext->{'blck'}
+ $ltext->{'actn'}?
END
- $r->print(&Apache::loncommon::start_data_table_row());
+ $r->print(&Apache::loncommon::start_data_table_row());
$r->print(<<"END");
- $$ltext{'star'}: $startform $$ltext{'endd'}: $endform
+ $ltext->{'star'}: $startform $ltext->{'endd'}: $endform
+
+END
+ foreach my $block (@{$typeorder}) {
+ $r->print(' '.$types->{$block}.' ');
+ }
+ $r->print(<<"END");
+
$lt{'addb'}?
END
$r->print(&Apache::loncommon::end_data_table_row());
@@ -1562,86 +1585,17 @@ END
return;
}
-sub blockcheck {
- my ($setters,$startblock,$endblock) = @_;
- # Retrieve active student roles and active course coordinator/instructor roles
- my %live_courses =
- map { $_ => 1} &Apache::loncommon::findallcourses();
- # FIXME should really probe for apriv, but ::allowed can only probe the
- # currently active role
- my %staff_of =
- map { $_ => 1} &Apache::loncommon::findallcourses(['cc','in']);
-
- # Retrieve blocking times and identity of blocker for active courses
- # for students.
- return if (!%live_courses);
-
- foreach my $course (keys(%live_courses)) {
- my $cdom = $env{'course.'.$course.'.domain'};
- my $cnum = $env{'course.'.$course.'.num'};
-
- # if they are a staff member and are currently not playing student
- next if ( $staff_of{$course}
- && ($env{'request.role'} !~ m{^st\./$cdom/$cnum}));
-
- $setters->{$course} = {};
- $setters->{$course}{'staff'} = [];
- $setters->{$course}{'times'} = [];
- my %records = &Apache::lonnet::dump('comm_block',$cdom,$cnum);
- foreach my $record (keys(%records)) {
- my ($start,$end) = ($record =~ m/^(\d+)____(\d+)$/);
- if ($start <= time && $end >= time) {
- my ($staff_name,$staff_dom,$title) =
- &parse_block_record($records{$record});
- push(@{$$setters{$course}{'staff'}}, [$staff_name,$staff_dom]);
- push(@{$$setters{$course}{'times'}}, [$start,$end]);
- if ( ($$startblock == 0) || ($$startblock > $1) ) {
- $$startblock = $1;
- }
- if ( ($$endblock == 0) || ($$endblock < $2) ) {
- $$endblock = $2;
- }
- }
- }
- }
-}
-
-sub build_block_table {
- my ($r,$startblock,$endblock,$setters) = @_;
- my %lt = &Apache::lonlocal::texthash(
- 'cacb' => 'Currently active communication blocks',
- 'cour' => 'Course/Group',
- 'dura' => 'Duration',
- 'blse' => 'Block set by'
+sub blocktype_text {
+ my %types = &Apache::lonlocal::texthash(
+ 'com' => 'Messaging',
+ 'chat' => 'Chat',
+ 'boards' => 'Discussion',
+ 'port' => 'Portfolio',
+ 'groups' => 'Groups',
+ 'blogs' => 'Blogs',
);
- $r->print(<<"END");
- $lt{'cacb'}:
-END
- $r->print(&Apache::loncommon::start_data_table());
- $r->print(<<"END");
-
- $lt{'cour'}
- $lt{'dura'}
- $lt{'blse'}
-
-END
- foreach my $course (keys(%{$setters})) {
- my %courseinfo=&Apache::lonnet::coursedescription($course);
- for (my $i=0; $i<@{$$setters{$course}{staff}}; $i++) {
- my ($uname,$udom) = @{$$setters{$course}{staff}[$i]};
- my $fullname = &Apache::loncommon::plainname($uname,$udom);
- my ($openblock,$closeblock) = @{$$setters{$course}{times}[$i]};
- $openblock = &Apache::lonlocal::locallocaltime($openblock);
- $closeblock= &Apache::lonlocal::locallocaltime($closeblock);
- $r->print(&Apache::loncommon::start_data_table_row().
- ''.$courseinfo{'description'}.' '.
- ''.$openblock.' to '.$closeblock.' '.
- ''.$fullname.' ('.$uname.':'.$udom.
- ') '.
- &Apache::loncommon::end_data_table_row());
- }
- }
- $r->print(&Apache::loncommon::end_data_table());
+ my $typeorder = ['com','chat','boards','port','groups','blogs'];
+ return ($typeorder,\%types);
}
# ----------------------------------------------------------- Display a message
@@ -1651,13 +1605,11 @@ sub displaymessage {
my $suffix=&Apache::lonmsg::foldersuffix($folder);
my %blocked = ();
my %setters = ();
- my $startblock = 0;
- my $endblock = 0;
my $numblocked = 0;
my $crstype = &Apache::loncommon::course_type();
# info to generate "next" and "previous" buttons and check if message is blocked
- &blockcheck(\%setters,\$startblock,\$endblock);
+ my ($startblock,$endblock) = &Apache::loncommon::blockcheck(\%setters,'com');
my @messages=&sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder);
if ( $blocked{$msgid} eq 'ON' ) {
&printheader($r,'/adm/email',&mt('Display a Message'));
@@ -1906,9 +1858,10 @@ sub sendoffmail {
}
} elsif ($env{'form.sendmode'} eq 'upload') {
foreach my $line (split(/[\n\r\f]+/,$env{'form.upfile'})) {
- my ($rec,$txt)=split(/\s*\:\s*/,$line);
+ my ($rec,$txt) = ($line =~ /^([^:]+:[^:]+):(.*)$/);
if ($txt) {
- $rec=~s/\@/\:/;
+ $rec =~ s/^\s+//;
+ $rec =~ s/\s+$//;
$toaddr{$rec}.=$txt."\n";
}
}
@@ -1919,7 +1872,7 @@ sub sendoffmail {
}
if ($env{'form.additionalrec'}) {
foreach my $rec (split(/\,/,$env{'form.additionalrec'})) {
- my ($auname,$audom)=split(/\@/,$rec);
+ my ($auname,$audom)=split(/:/,$rec);
if (($auname ne "") && ($audom ne "")) {
$toaddr{$auname.':'.$audom}='';
}
@@ -2261,7 +2214,7 @@ sub handler {
&storedcommentlisting($r);
} else {
&printheader($r,'','Display All Messages');
- &Apache::loncommunicate::menu($r);
+ &Apache::loncommunicate::menu($r);
&disall($r,($folder?$folder:$dismode));
}
$r->print(&Apache::loncommon::end_page());