--- loncom/interface/loncommon.pm 2009/05/07 16:25:02 1.806
+++ loncom/interface/loncommon.pm 2009/07/27 22:35:12 1.871
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.806 2009/05/07 16:25:02 bisitz Exp $
+# $Id: loncommon.pm,v 1.871 2009/07/27 22:35:12 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -407,6 +407,7 @@ sub studentbrowser_javascript {
) { return ''; }
return (<<'ENDSTDBRW');
ENDSTDBRW
}
@@ -461,6 +463,7 @@ sub selectstudent_link {
sub authorbrowser_javascript {
return <<"ENDAUTHORBRW";
ENDAUTHORBRW
}
sub coursebrowser_javascript {
my ($domainfilter,$sec_element,$formname)=@_;
- my $crs_or_grp_alert = &mt('Please select the type of LON-CAPA entity - Course or Group - for which you wish to add/modify a user role');
+ my $crs_or_grp_alert = &mt('Please select the type of LON-CAPA entity - Course or Community - for which you wish to add/modify a user role');
my $output = '
';
return $output;
}
@@ -614,12 +620,16 @@ function setSect(sectionlist) {
sub selectcourse_link {
my ($form,$unameele,$udomele,$desc,$extra_element,$multflag,$selecttype)=@_;
+ my $linktext = &mt('Select Course');
+ if ($selecttype eq 'Community') {
+ $linktext = &mt('Select Community');
+ }
return ''
."".&mt('Select Course').''
+ ."'>".$linktext.''
.'';
}
@@ -829,6 +839,7 @@ sub linked_select_forms {
# output the javascript to do the changing
my $result = '';
$result.='
END
# output the initial values for the selection lists
@@ -1027,7 +1039,9 @@ sub update_help_link {
my $banner_link = "/adm/helpmenu?page=banner&topic=$topic&component_help=$component_help&faq=$faq&bug=$bug&origurl=$origurl&stamp=$timestamp&stayonpage=$stayOnPage";
my $output .= <<"ENDOUTPUT";
ENDOUTPUT
return $output;
@@ -1394,6 +1408,7 @@ sub resize_textarea_js {
my $geometry = &viewport_geometry_js();
return <<"RESIZE";
RESIZE
@@ -2299,7 +2315,7 @@ sub authform_internal{
$result = &mt
('[_1] Internally authenticated (with initial password [_2])',
''.$autharg);
- $result.="';
+ $result.="';
return $result;
}
@@ -3754,7 +3770,7 @@ sub blockcheck {
($env{'request.role'} !~ m{^st\./\Q$cdom\E/\Q$cnum\E}));
next if ($no_userblock);
- # Retrieve blocking times and identity of blocker for course
+ # Retrieve blocking times and identity of locker for course
# of specified user, unless user has 'evb' privilege.
my ($start,$end)=&get_blocks($setters,$activity,$cdom,$cnum);
@@ -3819,103 +3835,48 @@ sub parse_block_record {
return ($setuname,$setudom,$title,$blocks);
}
-sub build_block_table {
- my ($startblock,$endblock,$setters) = @_;
- my %lt = &Apache::lonlocal::texthash(
- 'cacb' => 'Currently active communication blocks',
- 'cour' => 'Course',
- 'dura' => 'Duration',
- 'blse' => 'Block set by'
- );
- my $output;
- $output = ' '.$lt{'cacb'}.': ';
- $output .= &start_data_table();
- $output .= '
-
-
'.$lt{'cour'}.'
-
'.$lt{'dura'}.'
-
'.$lt{'blse'}.'
-
-';
- 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 = &plainname($uname,$udom);
- if (defined($env{'user.name'}) && defined($env{'user.domain'})
- && $env{'user.name'} ne 'public'
- && $env{'user.domain'} ne 'public') {
- $fullname = &aboutmewrapper($fullname,$uname,$udom);
- }
- my ($openblock,$closeblock) = @{$$setters{$course}{times}[$i]};
- $openblock = &Apache::lonlocal::locallocaltime($openblock);
- $closeblock= &Apache::lonlocal::locallocaltime($closeblock);
- $output .= &Apache::loncommon::start_data_table_row().
- '
'.$courseinfo{'description'}.'
'.
- '
'.$openblock.' to '.$closeblock.'
'.
- '
'.$fullname.'
'.
- &Apache::loncommon::end_data_table_row();
- }
- }
- $output .= &end_data_table();
-}
-
sub blocking_status {
- my ($activity,$uname,$udom) = @_;
- my %setters;
- my ($blocked,$output,$ownitem,$is_course);
- my ($startblock,$endblock)=&blockcheck(\%setters,$activity,$uname,$udom);
- if ($startblock && $endblock) {
- $blocked = 1;
- if (wantarray) {
- my $category;
- if ($activity eq 'boards') {
- $category = 'Discussion posts in this course';
- } elsif ($activity eq 'blogs') {
- $category = 'Blogs';
- } elsif ($activity eq 'port') {
- if (defined($uname) && defined($udom)) {
- if ($uname eq $env{'user.name'} &&
- $udom eq $env{'user.domain'}) {
- $ownitem = 1;
- }
- }
- $is_course = &Apache::lonnet::is_course($udom,$uname);
- if ($ownitem) {
- $category = 'Your portfolio files';
- } elsif ($is_course) {
- my $coursedesc;
- foreach my $course (keys(%setters)) {
- my %courseinfo =
- &Apache::lonnet::coursedescription($course);
- $coursedesc = $courseinfo{'description'};
- }
- $category = "Group portfolio in the course '$coursedesc'";
- } else {
- $category = 'Portfolio files belonging to ';
- if ($env{'user.name'} eq 'public' &&
- $env{'user.domain'} eq 'public') {
- $category .= &plainname($uname,$udom);
- } else {
- $category .= &aboutmewrapper(&plainname($uname,$udom),$uname,$udom);
- }
- }
- } elsif ($activity eq 'groups') {
- $category = 'Groups in this course';
- }
- my $showstart = &Apache::lonlocal::locallocaltime($startblock);
- my $showend = &Apache::lonlocal::locallocaltime($endblock);
- $output = ' '.&mt('[_1] will be inaccessible between [_2] and [_3] because communication is being blocked.',$category,$showstart,$showend).' ';
- if (!($activity eq 'port' && !($ownitem) && !($is_course))) {
- $output .= &build_block_table($startblock,$endblock,\%setters);
- }
- }
- }
- if (wantarray) {
- return ($blocked,$output);
- } else {
- return $blocked;
+ my $blocked;
+ my ($activity,$uname,$udom) = @_;
+ my %setters;
+ my ($startblock,$endblock)=&blockcheck(\%setters,$activity,$uname,$udom);
+ if ($startblock && $endblock) {
+ $blocked = 1;
+ }
+ if(!wantarray) {
+ return $blocked;
+ }
+ my $output;
+ my $querystring;
+ $querystring = "?activity=$activity";
+
+ $output .= <<"END_MYBLOCK";
+
+END_MYBLOCK
+ my $popupUrl = "/adm/blockingstatus/$querystring";
+ $output .= <<"END_BLOCK";
+
+
+END_BLOCK
+
+ return ($blocked, $output);
}
###############################################
@@ -4144,41 +4105,120 @@ Returns: value of designparamter $which
##############################################
sub designparm {
my ($which,$domain)=@_;
- if ($env{'browser.blackwhite'} eq 'on') {
- if ($which=~/\.(font|alink|vlink|link|textcol)$/) {
- return '#000000';
- }
- if ($which=~/\.(pgbg|sidebg|bgcol)$/) {
- return '#FFFFFF';
- }
- if ($which=~/\.tabbg$/) {
- return '#CCCCCC';
- }
- }
if (exists($env{'environment.color.'.$which})) {
- return $env{'environment.color.'.$which};
+ return $env{'environment.color.'.$which};
}
$domain=&determinedomain($domain);
my %domdesign = &get_domainconf($domain);
my $output;
if ($domdesign{$domain.'.'.$which} ne '') {
- $output = $domdesign{$domain.'.'.$which};
+ $output = $domdesign{$domain.'.'.$which};
} else {
$output = $defaultdesign{$which};
}
if (($which =~ /^(student|coordinator|author|admin)\.img$/) ||
($which =~ /login\.(img|logo|domlogo|login)/)) {
if ($output =~ m{^/(adm|res)/}) {
- if ($output =~ m{^/res/}) {
- my $local_name = &Apache::lonnet::filelocation('',$output);
- &Apache::lonnet::repcopy($local_name);
- }
+ if ($output =~ m{^/res/}) {
+ my $local_name = &Apache::lonnet::filelocation('',$output);
+ &Apache::lonnet::repcopy($local_name);
+ }
$output = &lonhttpdurl($output);
}
}
return $output;
}
+##############################################
+=pod
+
+=item * &authorspace()
+
+Inputs: ./.
+
+Returns: Path to the Construction Space of the current user's
+ accessed author space
+ The author space will be that of the current user
+ when accessing the own author space
+ and that of the co-author/assistent co-author
+ when accessing the co-author's/assistent co-author's
+ space
+
+=cut
+
+sub authorspace {
+ my $caname = '';
+ if ($env{'request.role'} =~ /^ca|^aa/) {
+ (undef,$caname) =
+ ($env{'request.role'}=~/($match_domain)\/($match_username)$/);
+ } else {
+ $caname = $env{'user.name'};
+ }
+ return '/priv/'.$caname.'/';
+}
+
+##############################################
+=pod
+
+=item * &head_subbox()
+
+Inputs: $content (contains HTML code with page functions, etc.)
+
+Returns: HTML div with $content
+ To be included in page header
+
+=cut
+
+sub head_subbox {
+ my ($content)=@_;
+ my $output =
+ '
'
+ .$content
+ .'
'
+}
+
+##############################################
+=pod
+
+=item * &CSTR_pageheader()
+
+Inputs: ./.
+
+Returns: HTML div with CSTR path and recent box
+ To be included on Construction Space pages
+
+=cut
+
+sub CSTR_pageheader {
+ # this is for resources; directories have customtitle, and crumbs
+ # and select recent are created in lonpubdir.pm
+ my ($uname,$thisdisfn)=
+ ($env{'request.filename'} =~ m|^/home/([^/]+)/public_html/(.*)|);
+ my $formaction='/priv/'.$uname.'/'.$thisdisfn;
+ $formaction=~s/\/+/\//g;
+
+ my $parentpath = '';
+ my $lastitem = '';
+ if ($thisdisfn =~ m-(.+/)([^/]*)$-) {
+ $parentpath = $1;
+ $lastitem = $2;
+ } else {
+ $lastitem = $thisdisfn;
+ }
+ return
+ '
'
+ .&Apache::loncommon::help_open_menu('','',3,'Authoring') #FIXME: Broken? Where is it?
+ .''.&mt('Construction Space:').' '
+ .''
+ .&Apache::lonmenu::constspaceform()
+ .'
';
+}
+
###############################################
###############################################
@@ -4211,17 +4251,11 @@ Inputs:
=item * $forcereg, if page should register as content page (relevant for
text interface only)
-=item * $customtitle, alternate text to use instead of $title
- in the title box that appears, this text
- is not auto translated like the $title is
-
-=item * $notopbar, if true, keep the 'what is this' info but remove the
- navigational links
+=item * $no_nav_bar, if true, keep the 'what is this' info but remove the
+ navigational links
=item * $bgcolor, used to override the bgcolor on a webpage to a specific value
-=item * $notitle, if true keep the nav controls, but remove the title bar
-
=item * $no_inline_link, if true and in remote mode, don't show the
'Switch To Inline Menu' link
@@ -4241,8 +4275,8 @@ other decorations will be returned.
=cut
sub bodytag {
- my ($title,$function,$addentries,$bodyonly,$domain,$forcereg,$customtitle,
- $notopbar,$bgcolor,$notitle,$no_inline_link,$args)=@_;
+ my ($title,$function,$addentries,$bodyonly,$domain,$forcereg,
+ $no_nav_bar,$bgcolor,$no_inline_link,$args)=@_;
if (!$args->{'no_auto_mt_title'}) { $title = &mt($title); }
@@ -4296,25 +4330,7 @@ sub bodytag {
$name = &aboutmewrapper($name,$env{'user.name'},$env{'user.domain'});
}
- my $roleinfo=(<
-
- $name
-
-
-
-$role
-
-
-$realm
-
-
-ENDROLE
-
my $titleinfo = '
'.$title.'
';
- if ($customtitle) {
- $titleinfo = $customtitle;
- }
#
# Extra info if you are the DC
my $dc_info = '';
@@ -4327,55 +4343,33 @@ ENDROLE
$dc_info = '('.$dc_info.')';
}
- if (($env{'environment.remote'} eq 'off') || ($args->{'suppress_header_logos'})) {
+ $role = "($role)" if $role;
+ &get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['inhibitmenu']);
+
+ if ($env{'environment.remote'} eq 'off') {
# No Remote
if ($env{'request.state'} eq 'construct') {
$forcereg=1;
}
- if (!$customtitle && $env{'request.state'} eq 'construct') {
- # this is for resources; directories have customtitle, and crumbs
- # and select recent are created in lonpubdir.pm
- my ($uname,$thisdisfn)=
- ($env{'request.filename'} =~ m|^/home/([^/]+)/public_html/(.*)|);
- my $formaction='/priv/'.$uname.'/'.$thisdisfn;
- $formaction=~s/\/+/\//g;
-
- my $parentpath = '';
- my $lastitem = '';
- if ($thisdisfn =~ m-(.+/)([^/]*)$-) {
- $parentpath = $1;
- $lastitem = $2;
- } else {
- $lastitem = $thisdisfn;
- }
- $titleinfo =
- &Apache::loncommon::help_open_menu('','',3,'Authoring')
- .''.&mt('Construction Space').': '
- .''
- .&Apache::lonmenu::constspaceform();
- }
-
- my $titletable;
- if (!$notitle) {
- $titletable =
- '
'.
- "
$titleinfo $dc_info
".$roleinfo.
- '
';
- }
- if ($notopbar) {
+# if ($env{'request.state'} eq 'construct') {
+# $titleinfo = &CSTR_pageheader(); #FIXME: Will be removed once all scripts have their own calls
+# }
+
+ my $titletable = '