[LON-CAPA-cvs] cvs: loncom /interface lonmenu.pm mydesk.tab
droeschl
droeschl@source.lon-capa.org
Sun, 06 Jun 2010 11:56:12 -0000
droeschl Sun Jun 6 11:56:12 2010 EDT
Modified files:
/loncom/interface lonmenu.pm mydesk.tab
Log:
Bugzilla #5331
Added Construction Space and Browse links to secondary menus for authors.
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.328 loncom/interface/lonmenu.pm:1.329
--- loncom/interface/lonmenu.pm:1.328 Sun May 30 18:30:52 2010
+++ loncom/interface/lonmenu.pm Sun Jun 6 11:56:12 2010
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.328 2010/05/30 18:30:52 droeschl Exp $
+# $Id: lonmenu.pm,v 1.329 2010/06/06 11:56:12 droeschl Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -225,6 +225,30 @@
return "<ol class=\"LC_primary_menu LC_right\">$menu</ol>";
}
+#returns hashref {user=>'',dom=>''} containing:
+# own name, domain if user is au
+# name, domain of parent author if user is ca or aa
+#empty return if user is not an author or not on homeserver
+#
+#TODO this should probably be moved somewhere more central
+#since it can be used by different parts of the system
+sub getauthor{
+ return unless $env{'request.role'}=~/^(ca|aa|au)/; #nothing to do if user isn't some kind of author
+
+ #co- or assistent author?
+ my ($dom, $user) = ($env{'request.role'} =~ /^(?:ca|aa)\.\/($match_domain)\/($match_username)$/)
+ ? ($1, $2) #domain, username of the parent author
+ : @env{ ('request.role.domain', 'user.name') }; #own domain, username
+
+ # current server == home server?
+ my $home = &Apache::lonnet::homeserver($user,$dom);
+ foreach (&Apache::lonnet::current_machine_ids()){
+ return {user => $user, dom => $dom} if $_ eq $home;
+ }
+
+ # if wrong server
+ return;
+}
sub secondary_menu {
my $menu;
@@ -238,6 +262,7 @@
my $canmodifyuser = &Apache::lonnet::allowed('cst', $crs_sec);
my $canviewwnew = &Apache::lonnet::allowed('whn', $crs_sec);
my $canmodpara = &Apache::lonnet::allowed('opa', $crs_sec);
+ my $author = getauthor();
my $showlink = &show_return_link();
my %groups = &Apache::lonnet::get_active_groups(
@@ -249,6 +274,7 @@
# evaluate conditions
next if ref($menuitem) ne 'ARRAY';
next if $$menuitem[4] ne 'always'
+ && $$menuitem[4] ne 'author'
&& !$env{'request.course.id'};
next if $$menuitem[4] eq 'showreturn'
&& !$showlink
@@ -268,6 +294,8 @@
next if $$menuitem[4] =~ /showgroups$/
&& !$canviewgrps
&& !%groups;
+ next if $$menuitem[4] eq 'author'
+ && !$author;
if ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
# special treatment for role selector
@@ -300,6 +328,8 @@
$menu =~ s/\[url\]/$escurl/g;
$menu =~ s/\[symb\]/$escsymb/g;
}
+ $menu =~ s/\[uname\]/$$author{user}/g;
+ $menu =~ s/\[udom\]/$$author{dom}/g;
return "<ul id=\"LC_secondary_menu\">$menu</ul>";
}
Index: loncom/interface/mydesk.tab
diff -u loncom/interface/mydesk.tab:1.135 loncom/interface/mydesk.tab:1.136
--- loncom/interface/mydesk.tab:1.135 Fri May 28 17:09:06 2010
+++ loncom/interface/mydesk.tab Sun Jun 6 11:56:12 2010
@@ -46,6 +46,7 @@
# - whn: access what's new
# - cst: Grant/revoke role of Student:Grant/revoke role of Member
# - opa: Set assessment parameters
+# - author: authors (au, ca, aa)
# prim:link:icon:alt:text:condition
scnd:/adm/whatsnew:::What's New:whn
scnd:/adm/navmaps?postdata=[url]&postsymb=[symb]:::Contents:
@@ -56,6 +57,8 @@
scnd:/adm/courseprefs:::Settings:opa
scnd:/adm/roles:::Roles:
scnd:/adm/flip?postdata=return%3a:::Return to Last Location:showreturn
+scnd:/priv/[uname]/:::Construction Space:author
+scnd:/res/[udom]/[uname]/?launch=1:::Browse:author
# Categories for main menu