File:  [LON-CAPA] / loncom / interface / lonpickauthor.pm
Revision 1.7: download - view: text, annotated - select for diffs
Wed Mar 15 20:18:06 2017 UTC (7 years, 1 month ago) by raeburn
Branches: MAIN
CVS tags: version_2_12_X, version_2_11_X, version_2_11_4_uiuc, version_2_11_4_msu, version_2_11_4, version_2_11_3_uiuc, version_2_11_3_msu, version_2_11_3, version_2_11_2_uiuc, version_2_11_2_msu, version_2_11_2_educog, version_2_11_2, HEAD
- lonroles::check_for_adhoc() expects four args.

    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.7 2017/03/15 20:18:06 raeburn 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 $update=$env{'user.update.time'};
   57:     if (!$update) {
   58:         $update = $then;
   59:     }
   60:     my (%dcroles,%helpdeskroles,%dom_roles,$earlyout,$domdesc);
   61:     my ($numdc) = &Apache::lonroles::check_for_adhoc(\%dcroles,\%helpdeskroles,$update,$then);
   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) {
   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); 
   71:                 }
   72:             } else {
   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);
   74:             }
   75:         } else {
   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.');
   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 {
  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));
  126:     }
  127:     $r->print(&Apache::loncommon::end_page());
  128:     return OK;
  129: }
  130: 
  131: 1;

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