Annotation of loncom/interface/lonpickauthor.pm, revision 1.5
1.1 raeburn 1: # The LearningOnline Network with CAPA
2: # Display authors in domain for selection of ad loc co-author role by Domain Coordinator.
3: #
1.5 ! bisitz 4: # $Id: lonpickauthor.pm,v 1.4 2013/06/04 22:32:23 raeburn Exp $
1.1 raeburn 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA#
23: # /home/httpd/html/adm/gpl.txt
24: #
25: # http://www.lon-capa.org/
26: #
27: #
28: ###############################################################
29: ###############################################################
30:
31: package Apache::lonpickauthor;
32:
33: use strict;
34: use Apache::Constants qw(:common);
35: use Apache::loncommon;
36: use Apache::lonnet;
37: use Apache::lonlocal;
38: use Apache::lonroles;
39: use Apache::lonuserutils;
40: use LONCAPA;
41:
42: sub handler {
43: my $r = shift;
44: &Apache::loncommon::content_type($r,'text/html');
45: $r->send_http_header;
46: return OK if $r->header_only;
47:
48: # ------------------------------------------------------------ Print the screen
49: $r->print(&Apache::loncommon::start_page("Selecting an Author",undef,
50: {'no_nav_bar' => 1}));
51:
52:
53: &Apache::loncommon::get_unprocessed_cgi
54: ($ENV{'QUERY_STRING'},['form','roledom','sortby']);
55: my $then=$env{'user.login.time'};
1.3 raeburn 56: my $update=$env{'user.update.time'};
57: if (!$update) {
58: $update = $then;
59: }
1.1 raeburn 60: my (%dcroles,%dom_roles,$earlyout,$domdesc);
1.3 raeburn 61: my $numdc = &Apache::lonroles::check_fordc(\%dcroles,$update,$then);
1.1 raeburn 62: if ($env{'form.roledom'} ne '') {
63: $domdesc = &Apache::lonnet::domain($env{'form.roledom'});
64: if ($domdesc eq '') {
65: $earlyout = $earlyout = &mt('Invalid domain');
66: } elsif ($numdc) {
67: if ($dcroles{$env{'form.roledom'}}) {
68: %dom_roles = &Apache::lonnet::get_domain_roles($env{'form.roledom'},['au']);
69: if (keys(%dom_roles) == 0) {
1.5 ! bisitz 70: $earlyout = &mt('There are no library servers containing Authoring Spaces currently in domain: [_1], so you can not assume a co-author role.',$domdesc);
1.1 raeburn 71: }
72: } else {
1.5 ! bisitz 73: $earlyout = &mt('You do not have a domain coordinator role in domain: [_1], so you cannot choose an Authoring Space for which you can assume a co-author role.',$domdesc);
1.1 raeburn 74: }
75: } else {
1.5 ! bisitz 76: $earlyout = &mt('You do not have a domain coordinator role, so you cannot choose an Authoring Space for which you can assume a co-author role.');
1.1 raeburn 77: }
78: } else {
79: $earlyout = &mt('Invalid domain');
80: }
81: if ($earlyout) {
82: $r->print('<span class="LC_error">'.$earlyout.'</span>');
83: $r->print(&Apache::loncommon::end_page());
84: return OK;
85: }
86: $r->print(<<ENDSCRIPT);
87: <script type="text/javascript">
88: function username_display_launch(username,domain) {
89: document.location.href = '/adm/'+domain+'/'+username+'/aboutme';
90: return;
91: }
92:
93: function gochoose(uname) {
94: var coauthorTarget = "ca./$env{'form.roledom'}/"+uname;
95: opener.document.title='Role selected. Please stand by.';
96: opener.status='Role selected. Please stand by.';
97: opener.document.$env{'form.form'}.newrole.value=coauthorTarget
98: opener.document.$env{'form.form'}.submit();
99: self.close();
100: }
101: </script>
102: ENDSCRIPT
103: my $formname = 'pickauthor';
104: my $caller = 'pickauthor';
105: my $context = 'domain';
106: my $format = 'html';
107: my (%userlist,%userinfo);
108: my ($indexhash,$keylist) = &Apache::lonuserutils::make_keylist_array();
109: my ($permission,$allowed) = &Apache::lonuserutils::get_permission($context);
110: $env{'form.roletype'} = 'domain';
111: $env{'form.showrole'} = 'au';
112: foreach my $key (keys(%dom_roles)) {
113: if (ref($dom_roles{$key}) eq 'HASH') {
114: &Apache::lonuserutils::gather_userinfo($context,$format,\%userlist,$indexhash,
115: \%userinfo,$dom_roles{$key},$permission);
116: }
117: }
118: if (keys(%userlist) > 0) {
119: $r->print('<form name="'.$formname.'" action="/adm/pickauthor">');
120: &Apache::lonuserutils::show_users_list($r,$context,$caller,$permission,
121: 'Any',\%userlist,$keylist,$formname);
122: $r->print('<input type="hidden" name="roledom" value="'.$env{'form.roledom'}.'" />'."\n".
123: '<input type="hidden" name="form" value="'.$env{'form.form'}.'" /></form>');
124: } else {
1.5 ! bisitz 125: $r->print(&mt('There are no author roles currently in domain: [_1], so there are no Authoring Spaces for which you can assume a co-author role.',$domdesc));
1.1 raeburn 126: }
127: $r->print(&Apache::loncommon::end_page());
128: return OK;
129: }
130:
131: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>