File:  [LON-CAPA] / loncom / interface / lonpickauthor.pm
Revision 1.2: download - view: text, annotated - select for diffs
Wed Oct 15 09:49:52 2008 UTC (15 years, 6 months ago) by bisitz
Branches: MAIN
CVS tags: version_2_9_X, version_2_9_99_0, version_2_9_1, version_2_9_0, version_2_8_X, version_2_8_99_1, version_2_8_99_0, version_2_8_2, version_2_8_1, version_2_8_0, version_2_7_99_1, version_2_7_99_0, version_2_10_X, version_2_10_1, version_2_10_0_RC2, version_2_10_0_RC1, version_2_10_0, loncapaMITrelate_1, language_hyphenation_merge, language_hyphenation, bz6209-base, bz6209, bz5969, bz2851, PRINT_INCOMPLETE_base, PRINT_INCOMPLETE, HEAD, GCI_3, GCI_2, GCI_1, BZ5971-printing-apage, BZ5434-fox, BZ4492-merge, BZ4492-feature_horizontal_radioresponse
Corrected typos (2x "you" missing)

    1: # The LearningOnline Network with CAPA
    2: # Display authors in domain for selection of ad loc co-author role by Domain Coordinator. 
    3: #
    4: # $Id: lonpickauthor.pm,v 1.2 2008/10/15 09:49:52 bisitz Exp $
    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'};
   56:     my (%dcroles,%dom_roles,$earlyout,$domdesc);
   57:     my $numdc = &Apache::lonroles::check_fordc(\%dcroles,$then);
   58:     if ($env{'form.roledom'} ne '') {
   59:         $domdesc = &Apache::lonnet::domain($env{'form.roledom'});
   60:         if ($domdesc eq '') {
   61:             $earlyout = $earlyout = &mt('Invalid domain'); 
   62:         } elsif ($numdc) {
   63:             if ($dcroles{$env{'form.roledom'}}) {
   64:                 %dom_roles = &Apache::lonnet::get_domain_roles($env{'form.roledom'},['au']);
   65:                 if (keys(%dom_roles) == 0) {
   66:                     $earlyout = &mt('There are no library servers containing Construction spaces currently in domain: [_1], so you can not assume a co-author role.',$domdesc); 
   67:                 }
   68:             } else {
   69:                 $earlyout = &mt('You do not have a domain coordinator role in domain: [_1], so you cannot choose a Construction space for which you can assume a co-author role.',$domdesc);
   70:             }
   71:         } else {
   72:             $earlyout = &mt('You do not have a domain coordinator role, so you cannot choose a Construction space for which you can assume a co-author role.');
   73:         }
   74:     } else {
   75:         $earlyout = &mt('Invalid domain'); 
   76:     }
   77:     if ($earlyout) {
   78:         $r->print('<span class="LC_error">'.$earlyout.'</span>');
   79:         $r->print(&Apache::loncommon::end_page());
   80:         return OK;
   81:     }
   82:     $r->print(<<ENDSCRIPT);
   83: <script type="text/javascript">
   84: function username_display_launch(username,domain) {
   85:     document.location.href = '/adm/'+domain+'/'+username+'/aboutme';
   86:     return;
   87: }
   88: 
   89: function gochoose(uname) {
   90:     var coauthorTarget = "ca./$env{'form.roledom'}/"+uname;
   91:     opener.document.title='Role selected. Please stand by.';
   92:     opener.status='Role selected. Please stand by.';
   93:     opener.document.$env{'form.form'}.newrole.value=coauthorTarget
   94:     opener.document.$env{'form.form'}.submit();
   95:     self.close();
   96: }
   97: </script>
   98: ENDSCRIPT
   99:     my $formname = 'pickauthor';
  100:     my $caller = 'pickauthor';
  101:     my $context = 'domain';
  102:     my $format = 'html';
  103:     my (%userlist,%userinfo);
  104:     my ($indexhash,$keylist) = &Apache::lonuserutils::make_keylist_array();
  105:     my ($permission,$allowed) = &Apache::lonuserutils::get_permission($context);
  106:     $env{'form.roletype'} = 'domain';
  107:     $env{'form.showrole'} = 'au';
  108:     foreach my $key (keys(%dom_roles)) {
  109:         if (ref($dom_roles{$key}) eq 'HASH') {
  110:             &Apache::lonuserutils::gather_userinfo($context,$format,\%userlist,$indexhash,
  111:                                                   \%userinfo,$dom_roles{$key},$permission);
  112:         }
  113:     }
  114:     if (keys(%userlist) > 0) {
  115:         $r->print('<form name="'.$formname.'" action="/adm/pickauthor">');
  116:         &Apache::lonuserutils::show_users_list($r,$context,$caller,$permission,
  117:                                                'Any',\%userlist,$keylist,$formname);
  118:         $r->print('<input type="hidden" name="roledom" value="'.$env{'form.roledom'}.'" />'."\n".
  119:                   '<input type="hidden" name="form" value="'.$env{'form.form'}.'" /></form>');
  120:     } else {
  121:        $r->print(&mt('There are no author roles currently in domain: [_1], so there are no Construction spaces for which you can assume a co-author role.',$domdesc));
  122:     }
  123:     $r->print(&Apache::loncommon::end_page());
  124:     return OK;
  125: }
  126: 
  127: 1;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>