--- loncom/interface/domainprefs.pm 2010/01/02 22:02:44 1.102.2.7
+++ loncom/interface/domainprefs.pm 2018/07/06 03:18:36 1.327
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.102.2.7 2010/01/02 22:02:44 raeburn Exp $
+# $Id: domainprefs.pm,v 1.327 2018/07/06 03:18:36 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -19,14 +19,15 @@
#
# You should have received a copy of the GNU General Public License
# along with LON-CAPA; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA#
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
# /home/httpd/html/adm/gpl.txt
#
# http://www.lon-capa.org/
#
#
###############################################################
-##############################################################
+###############################################################
=pod
@@ -45,7 +46,7 @@ described at http://www.lon-capa.org.
=head1 OVERVIEW
Each institution using LON-CAPA will typically have a single domain designated
-for use by individuals affliated with the institution. Accordingly, each domain
+for use by individuals affiliated with the institution. Accordingly, each domain
may define a default set of logos and a color scheme which can be used to "brand"
the LON-CAPA instance. In addition, an institution will typically have a language
and timezone which are used for the majority of courses.
@@ -86,15 +87,16 @@ $dom,$settings,$rowtotal,$action.
$dom is the domain, $settings is a reference to a hash of current settings for
the current context, $rowtotal is a reference to the scalar used to record the
-number of rows displayed on the page, and $action is the context (either quotas
-or requestcourses).
+number of rows displayed on the page, and $action is the context (quotas,
+requestcourses or requestauthor).
The print_quotas routine was orginally created to display/store information
about default quota sizes for portfolio spaces for the different types of
institutional affiliation in the domain (e.g., Faculty, Staff, Student etc.),
but is now also used to manage availability of user tools:
i.e., blogs, aboutme page, and portfolios, and the course request tool,
-used by course owners to request creation of a course.
+used by course owners to request creation of a course, and to display/store
+default quota sizes for Authoring Spaces.
Outputs: 1
@@ -102,8 +104,8 @@ $datatable - HTML containing form eleme
In the case of course requests, radio buttons are displayed for each institutional
affiliate type (and also default, and _LC_adv) for each of the course types
-(official, unofficial and community). In each case the radio buttons allow the
-selection of one of four values:
+(official, unofficial, community, textbook, placement, and lti).
+In each case the radio buttons allow the selection of one of four values:
0, approval, validate, autolimit=N (where N is blank, or a positive integer).
which have the following effects:
@@ -140,7 +142,7 @@ autolimit
=over
-- course requests will be processed autoatically up to a limit of
+- course requests will be processed automatically up to a limit of
N requests for the course type for the particular requestor.
If N is undefined, there is no limit to the number of course requests
which a course owner may submit and have processed automatically.
@@ -163,13 +165,20 @@ use Apache::lonhtmlcommon();
use Apache::lonlocal;
use Apache::lonmsg();
use Apache::lonconfigsettings;
+use Apache::lonuserutils();
+use Apache::loncoursequeueadmin();
use LONCAPA qw(:DEFAULT :match);
use LONCAPA::Enrollment;
use LONCAPA::lonauthcgi();
+use LONCAPA::SSL;
use File::Copy;
use Locale::Language;
use DateTime::TimeZone;
use DateTime::Locale;
+use Time::HiRes qw( sleep );
+
+my $registered_cleanup;
+my $modified_urls;
sub handler {
my $r=shift;
@@ -190,6 +199,10 @@ sub handler {
"/adm/domainprefs:mau:0:0:Cannot modify domain settings";
return HTTP_NOT_ACCEPTABLE;
}
+
+ $registered_cleanup=0;
+ @{$modified_urls}=();
+
&Apache::lonhtmlcommon::clear_breadcrumbs();
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['phase','actions']);
@@ -197,17 +210,55 @@ sub handler {
if ( exists($env{'form.phase'}) ) {
$phase = $env{'form.phase'};
}
+ my %servers = &Apache::lonnet::internet_dom_servers($dom);
my %domconfig =
&Apache::lonnet::get_dom('configuration',['login','rolecolors',
- 'quotas','autoenroll','autoupdate','directorysrch',
- 'usercreation','usermodification','contacts','defaults',
- 'scantron','coursecategories','serverstatuses',
- 'requestcourses','coursedefaults'],$dom);
+ 'quotas','autoenroll','autoupdate','autocreate',
+ 'directorysrch','usercreation','usermodification',
+ 'contacts','defaults','scantron','coursecategories',
+ 'serverstatuses','requestcourses','helpsettings',
+ 'coursedefaults','usersessions','loadbalancing',
+ 'requestauthor','selfenrollment','inststatus',
+ 'ltitools','ssl','trust','lti'],$dom);
+ my %encconfig =
+ &Apache::lonnet::get_dom('encconfig',['ltitools','lti'],$dom);
+ if (ref($domconfig{'ltitools'}) eq 'HASH') {
+ if (ref($encconfig{'ltitools'}) eq 'HASH') {
+ foreach my $id (keys(%{$domconfig{'ltitools'}})) {
+ if ((ref($domconfig{'ltitools'}{$id}) eq 'HASH') &&
+ (ref($encconfig{'ltitools'}{$id}) eq 'HASH')) {
+ foreach my $item ('key','secret') {
+ $domconfig{'ltitools'}{$id}{$item} = $encconfig{'ltitools'}{$id}{$item};
+ }
+ }
+ }
+ }
+ }
+ if (ref($domconfig{'lti'}) eq 'HASH') {
+ if (ref($encconfig{'lti'}) eq 'HASH') {
+ foreach my $id (keys(%{$domconfig{'lti'}})) {
+ if ((ref($domconfig{'lti'}{$id}) eq 'HASH') &&
+ (ref($encconfig{'lti'}{$id}) eq 'HASH')) {
+ foreach my $item ('key','secret') {
+ $domconfig{'lti'}{$id}{$item} = $encconfig{'lti'}{$id}{$item};
+ }
+ }
+ }
+ }
+ }
my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll',
- 'autoupdate','directorysrch','contacts',
- 'usercreation','usermodification','scantron',
- 'requestcourses','coursecategories','serverstatuses',
- 'coursedefaults');
+ 'autoupdate','autocreate','directorysrch','contacts',
+ 'usercreation','selfcreation','usermodification','scantron',
+ 'requestcourses','requestauthor','coursecategories',
+ 'serverstatuses','helpsettings','coursedefaults',
+ 'ltitools','selfenrollment','usersessions','ssl','trust','lti');
+ my %existing;
+ if (ref($domconfig{'loadbalancing'}) eq 'HASH') {
+ %existing = %{$domconfig{'loadbalancing'}};
+ }
+ if ((keys(%servers) > 1) || (keys(%existing) > 0)) {
+ push(@prefs_order,'loadbalancing');
+ }
my %prefs = (
'rolecolors' =>
{ text => 'Default color schemes',
@@ -220,53 +271,92 @@ sub handler {
col2 => '',},
{col1 => 'Administrator Settings',
col2 => '',}],
+ print => \&print_rolecolors,
+ modify => \&modify_rolecolors,
},
- 'login' =>
+ 'login' =>
{ text => 'Log-in page options',
help => 'Domain_Configuration_Login_Page',
- header => [{col1 => 'Item',
- col2 => '',}],
+ header => [{col1 => 'Log-in Page Items',
+ col2 => '',},
+ {col1 => 'Log-in Help',
+ col2 => 'Value'},
+ {col1 => 'Custom HTML in document head',
+ col2 => 'Value'}],
+ print => \&print_login,
+ modify => \&modify_login,
},
'defaults' =>
- { text => 'Default authentication/language/timezone',
+ { text => 'Default authentication/language/timezone/portal/types',
help => 'Domain_Configuration_LangTZAuth',
header => [{col1 => 'Setting',
- col2 => 'Value'}],
+ col2 => 'Value'},
+ {col1 => 'Internal Authentication',
+ col2 => 'Value'},
+ {col1 => 'Institutional user types',
+ col2 => 'Name displayed'}],
+ print => \&print_defaults,
+ modify => \&modify_defaults,
},
'quotas' =>
- { text => 'User blogs, personal information pages and portfolios',
+ { text => 'Blogs, personal web pages, webDAV/quotas, portfolios',
help => 'Domain_Configuration_Quotas',
header => [{col1 => 'User affiliation',
col2 => 'Available tools',
- col3 => 'Portfolio quota',}],
+ col3 => 'Quotas, MB; (Authoring requires role)',}],
+ print => \&print_quotas,
+ modify => \&modify_quotas,
},
'autoenroll' =>
{ text => 'Auto-enrollment settings',
help => 'Domain_Configuration_Auto_Enrollment',
header => [{col1 => 'Configuration setting',
col2 => 'Value(s)'}],
+ print => \&print_autoenroll,
+ modify => \&modify_autoenroll,
},
'autoupdate' =>
{ text => 'Auto-update settings',
help => 'Domain_Configuration_Auto_Updates',
header => [{col1 => 'Setting',
col2 => 'Value',},
+ {col1 => 'Setting',
+ col2 => 'Affiliation'},
{col1 => 'User population',
- col2 => 'Updataeable user data'}],
+ col2 => 'Updatable user data'}],
+ print => \&print_autoupdate,
+ modify => \&modify_autoupdate,
+ },
+ 'autocreate' =>
+ { text => 'Auto-course creation settings',
+ help => 'Domain_Configuration_Auto_Creation',
+ header => [{col1 => 'Configuration Setting',
+ col2 => 'Value',}],
+ print => \&print_autocreate,
+ modify => \&modify_autocreate,
},
'directorysrch' =>
- { text => 'Institutional directory searches',
+ { text => 'Directory searches',
help => 'Domain_Configuration_InstDirectory_Search',
- header => [{col1 => 'Setting',
+ header => [{col1 => 'Institutional Directory Setting',
+ col2 => 'Value',},
+ {col1 => 'LON-CAPA Directory Setting',
col2 => 'Value',}],
+ print => \&print_directorysrch,
+ modify => \&modify_directorysrch,
},
'contacts' =>
- { text => 'Contact Information',
+ { text => 'E-mail addresses and helpform',
help => 'Domain_Configuration_Contact_Info',
- header => [{col1 => 'Setting',
- col2 => 'Value',}],
+ header => [{col1 => 'Default e-mail addresses',
+ col2 => 'Value',},
+ {col1 => 'Recipient(s) for notifications',
+ col2 => 'Value',},
+ {col1 => 'Ask helpdesk form settings',
+ col2 => 'Value',},],
+ print => \&print_contacts,
+ modify => \&modify_contacts,
},
-
'usercreation' =>
{ text => 'User creation',
help => 'Domain_Configuration_User_Creation',
@@ -276,16 +366,30 @@ sub handler {
col2 => 'Usernames which may be created',},
{col1 => 'Context',
col2 => 'Assignable authentication types'}],
+ print => \&print_usercreation,
+ modify => \&modify_usercreation,
+ },
+ 'selfcreation' =>
+ { text => 'Users self-creating accounts',
+ help => 'Domain_Configuration_Self_Creation',
+ header => [{col1 => 'Self-creation with institutional username',
+ col2 => 'Enabled?'},
+ {col1 => 'Institutional user type (login/SSO self-creation)',
+ col2 => 'Information user can enter'},
+ {col1 => 'Self-creation with e-mail verification',
+ col2 => 'Settings'}],
+ print => \&print_selfcreation,
+ modify => \&modify_selfcreation,
},
'usermodification' =>
{ text => 'User modification',
help => 'Domain_Configuration_User_Modification',
header => [{col1 => 'Target user has role',
- col2 => 'User information updateable in author context'},
+ col2 => 'User information updatable in author context'},
{col1 => 'Target user has role',
- col2 => 'User information updateable in course context'},
- {col1 => "Status of user",
- col2 => 'Information settable when self-creating account (if directory data blank)'}],
+ col2 => 'User information updatable in course context'}],
+ print => \&print_usermodification,
+ modify => \&modify_usermodification,
},
'scantron' =>
{ text => 'Bubblesheet format file',
@@ -293,6 +397,8 @@ sub handler {
header => [ {col1 => 'Item',
col2 => '',
}],
+ print => \&print_scantron,
+ modify => \&modify_scantron,
},
'requestcourses' =>
{text => 'Request creation of courses',
@@ -300,16 +406,38 @@ sub handler {
header => [{col1 => 'User affiliation',
col2 => 'Availability/Processing of requests',},
{col1 => 'Setting',
+ col2 => 'Value'},
+ {col1 => 'Available textbooks',
+ col2 => ''},
+ {col1 => 'Available templates',
+ col2 => ''},
+ {col1 => 'Validation (not official courses)',
+ col2 => 'Value'},],
+ print => \&print_quotas,
+ modify => \&modify_quotas,
+ },
+ 'requestauthor' =>
+ {text => 'Request Authoring Space',
+ help => 'Domain_Configuration_Request_Author',
+ header => [{col1 => 'User affiliation',
+ col2 => 'Availability/Processing of requests',},
+ {col1 => 'Setting',
col2 => 'Value'}],
+ print => \&print_quotas,
+ modify => \&modify_quotas,
},
'coursecategories' =>
{ text => 'Cataloging of courses/communities',
help => 'Domain_Configuration_Cataloging_Courses',
- header => [{col1 => 'Category settings',
+ header => [{col1 => 'Catalog type/availability',
+ col2 => '',},
+ {col1 => 'Category settings for standard catalog',
col2 => '',},
{col1 => 'Categories',
col2 => '',
}],
+ print => \&print_coursecategories,
+ modify => \&modify_coursecategories,
},
'serverstatuses' =>
{text => 'Access to server status pages',
@@ -318,25 +446,215 @@ sub handler {
col2 => 'Other named users',
col3 => 'Specific IPs',
}],
+ print => \&print_serverstatuses,
+ modify => \&modify_serverstatuses,
+ },
+ 'helpsettings' =>
+ {text => 'Support settings',
+ help => 'Domain_Configuration_Help_Settings',
+ header => [{col1 => 'Help Page Settings (logged-in users)',
+ col2 => 'Value'},
+ {col1 => 'Helpdesk Roles',
+ col2 => 'Settings'},],
+ print => \&print_helpsettings,
+ modify => \&modify_helpsettings,
},
- 'coursedefaults' =>
+ 'coursedefaults' =>
{text => 'Course/Community defaults',
help => 'Domain_Configuration_Course_Defaults',
+ header => [{col1 => 'Defaults which can be overridden in each course by a CC',
+ col2 => 'Value',},
+ {col1 => 'Defaults which can be overridden for each course by a DC',
+ col2 => 'Value',},],
+ print => \&print_coursedefaults,
+ modify => \&modify_coursedefaults,
+ },
+ 'selfenrollment' =>
+ {text => 'Self-enrollment in Course/Community',
+ help => 'Domain_Configuration_Selfenrollment',
+ header => [{col1 => 'Configuration Rights',
+ col2 => 'Configured by Course Personnel or Domain Coordinator?'},
+ {col1 => 'Defaults',
+ col2 => 'Value'},
+ {col1 => 'Self-enrollment validation (optional)',
+ col2 => 'Value'},],
+ print => \&print_selfenrollment,
+ modify => \&modify_selfenrollment,
+ },
+ 'privacy' =>
+ {text => 'User Privacy',
+ help => 'Domain_Configuration_User_Privacy',
+ header => [{col1 => 'Setting',
+ col2 => 'Value',}],
+ print => \&print_privacy,
+ modify => \&modify_privacy,
+ },
+ 'usersessions' =>
+ {text => 'User session hosting/offloading',
+ help => 'Domain_Configuration_User_Sessions',
+ header => [{col1 => 'Domain server',
+ col2 => 'Servers to offload sessions to when busy'},
+ {col1 => 'Hosting of users from other domains',
+ col2 => 'Rules'},
+ {col1 => "Hosting domain's own users elsewhere",
+ col2 => 'Rules'}],
+ print => \&print_usersessions,
+ modify => \&modify_usersessions,
+ },
+ 'loadbalancing' =>
+ {text => 'Dedicated Load Balancer(s)',
+ help => 'Domain_Configuration_Load_Balancing',
+ header => [{col1 => 'Balancers',
+ col2 => 'Default destinations',
+ col3 => 'User affiliation',
+ col4 => 'Overrides'},
+ ],
+ print => \&print_loadbalancing,
+ modify => \&modify_loadbalancing,
+ },
+ 'ltitools' =>
+ {text => 'External Tools (LTI)',
+ help => 'Domain_Configuration_LTI_Tools',
header => [{col1 => 'Setting',
col2 => 'Value',}],
+ print => \&print_ltitools,
+ modify => \&modify_ltitools,
+ },
+ 'ssl' =>
+ {text => 'LON-CAPA Network (SSL)',
+ help => 'Domain_Configuration_Network_SSL',
+ header => [{col1 => 'Server',
+ col2 => 'Certificate Status'},
+ {col1 => 'Connections to other servers',
+ col2 => 'Rules'},
+ {col1 => 'Connections from other servers',
+ col2 => 'Rules'},
+ {col1 => "Replicating domain's published content",
+ col2 => 'Rules'}],
+ print => \&print_ssl,
+ modify => \&modify_ssl,
+ },
+ 'trust' =>
+ {text => 'Trust Settings',
+ help => 'Domain_Configuration_Trust',
+ header => [{col1 => "Access to this domain's content by others",
+ col2 => 'Rules'},
+ {col1 => "Access to other domain's content by this domain",
+ col2 => 'Rules'},
+ {col1 => "Enrollment in this domain's courses by others",
+ col2 => 'Rules',},
+ {col1 => "Co-author roles in this domain for others",
+ col2 => 'Rules',},
+ {col1 => "Co-author roles for this domain's users elsewhere",
+ col2 => 'Rules',},
+ {col1 => "Domain roles in this domain assignable to others",
+ col2 => 'Rules'},
+ {col1 => "Course catalog for this domain displayed elsewhere",
+ col2 => 'Rules'},
+ {col1 => "Requests for creation of courses in this domain by others",
+ col2 => 'Rules'},
+ {col1 => "Users in other domains can send messages to this domain",
+ col2 => 'Rules'},],
+ print => \&print_trust,
+ modify => \&modify_trust,
+ },
+ 'lti' =>
+ {text => 'LTI Provider',
+ help => 'Domain_Configuration_LTI_Provider',
+ header => [{col1 => 'Setting',
+ col2 => 'Value',}],
+ print => \&print_lti,
+ modify => \&modify_lti,
},
);
+ if (keys(%servers) > 1) {
+ $prefs{'login'} = { text => 'Log-in page options',
+ help => 'Domain_Configuration_Login_Page',
+ header => [{col1 => 'Log-in Service',
+ col2 => 'Server Setting',},
+ {col1 => 'Log-in Page Items',
+ col2 => ''},
+ {col1 => 'Log-in Help',
+ col2 => 'Value'},
+ {col1 => 'Custom HTML in document head',
+ col2 => 'Value'}],
+ print => \&print_login,
+ modify => \&modify_login,
+ };
+ }
+
my @roles = ('student','coordinator','author','admin');
my @actions = &Apache::loncommon::get_env_multiple('form.actions');
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:changePage(document.$phase,'pickactions')",
- text=>"Pick functionality"});
+ text=>"Settings to display/modify"});
my $confname = $dom.'-domainconfig';
+
if ($phase eq 'process') {
- &Apache::lonconfigsettings::make_changes($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,\@roles);
+ my $result = &Apache::lonconfigsettings::make_changes($r,$dom,$phase,$context,\@prefs_order,
+ \%prefs,\%domconfig,$confname,\@roles);
+ if ((ref($result) eq 'HASH') && (keys(%{$result}))) {
+ $r->rflush();
+ &devalidate_remote_domconfs($dom,$result);
+ }
} elsif ($phase eq 'display') {
- &Apache::lonconfigsettings::display_settings($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname);
+ my $js = &recaptcha_js().
+ &toggle_display_js();
+ if ((keys(%servers) > 1) || (keys(%existing) > 0)) {
+ my ($othertitle,$usertypes,$types) =
+ &Apache::loncommon::sorted_inst_types($dom);
+ $js .= &lonbalance_targets_js($dom,$types,\%servers,
+ $domconfig{'loadbalancing'}).
+ &new_spares_js().
+ &common_domprefs_js().
+ &Apache::loncommon::javascript_array_indexof();
+ }
+ if (grep(/^requestcourses$/,@actions)) {
+ my $javascript_validations;
+ my $coursebrowserjs=&Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'});
+ $js .= <
+$javascript_validations
+
+$coursebrowserjs
+END
+ }
+ if (grep(/^selfcreation$/,@actions)) {
+ $js .= &selfcreate_javascript();
+ }
+ if (grep(/^contacts$/,@actions)) {
+ $js .= &contacts_javascript();
+ }
+ &Apache::lonconfigsettings::display_settings($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,$js);
} else {
+# check if domconfig user exists for the domain.
+ my $servadm = $r->dir_config('lonAdmEMail');
+ my ($configuserok,$author_ok,$switchserver) =
+ &config_check($dom,$confname,$servadm);
+ unless ($configuserok eq 'ok') {
+ &Apache::lonconfigsettings::print_header($r,$phase,$context);
+ $r->print(&mt('The domain configuration user "[_1]" has yet to be created.',
+ $confname).
+ '
'
+ );
+ if ($switchserver) {
+ $r->print(&mt('Ordinarily, that domain configuration user is created when the ./UPDATE script is run to install LON-CAPA for the first time.').
+ '
'.
+ &mt('However, that does not apply when new domains are added to a multi-domain server, and ./UPDATE has not been run recently.').
+ '
'.
+ &mt('The "[_1]" user can be created automatically when a Domain Coordinator visits the web-based "Set domain configuration" screen, in a session hosted on the primary library server.',$confname).
+ '
'.
+ &mt('To do that now, use the following link: [_1]',$switchserver)
+ );
+ } else {
+ $r->print(&mt('To create that user from the command line run the ./UPDATE script found in the top level directory of the extracted LON-CAPA tarball.').
+ '
'.
+ &mt('Once that is done, you will be able to use the web-based "Set domain configuration" to configure the domain')
+ );
+ }
+ $r->print(&Apache::loncommon::end_page());
+ return OK;
+ }
if (keys(%domconfig) == 0) {
my $primarylibserv = &Apache::lonnet::domain($dom,'primary');
my @ids=&Apache::lonnet::current_machine_ids();
@@ -376,43 +694,65 @@ sub handler {
}
sub process_changes {
- my ($r,$dom,$confname,$action,$roles,$values) = @_;
+ my ($r,$dom,$confname,$action,$roles,$values,$lastactref) = @_;
my %domconfig;
if (ref($values) eq 'HASH') {
%domconfig = %{$values};
}
my $output;
if ($action eq 'login') {
- $output = &modify_login($r,$dom,$confname,%domconfig);
+ $output = &modify_login($r,$dom,$confname,$lastactref,%domconfig);
} elsif ($action eq 'rolecolors') {
$output = &modify_rolecolors($r,$dom,$confname,$roles,
- %domconfig);
+ $lastactref,%domconfig);
} elsif ($action eq 'quotas') {
- $output = &modify_quotas($dom,$action,%domconfig);
+ $output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig);
} elsif ($action eq 'autoenroll') {
- $output = &modify_autoenroll($dom,%domconfig);
+ $output = &modify_autoenroll($dom,$lastactref,%domconfig);
} elsif ($action eq 'autoupdate') {
$output = &modify_autoupdate($dom,%domconfig);
+ } elsif ($action eq 'autocreate') {
+ $output = &modify_autocreate($dom,%domconfig);
} elsif ($action eq 'directorysrch') {
- $output = &modify_directorysrch($dom,%domconfig);
+ $output = &modify_directorysrch($dom,$lastactref,%domconfig);
} elsif ($action eq 'usercreation') {
$output = &modify_usercreation($dom,%domconfig);
+ } elsif ($action eq 'selfcreation') {
+ $output = &modify_selfcreation($dom,$lastactref,%domconfig);
} elsif ($action eq 'usermodification') {
$output = &modify_usermodification($dom,%domconfig);
} elsif ($action eq 'contacts') {
- $output = &modify_contacts($dom,%domconfig);
+ $output = &modify_contacts($dom,$lastactref,%domconfig);
} elsif ($action eq 'defaults') {
- $output = &modify_defaults($dom,$r);
+ $output = &modify_defaults($dom,$lastactref,%domconfig);
} elsif ($action eq 'scantron') {
- $output = &modify_scantron($r,$dom,$confname,%domconfig);
+ $output = &modify_scantron($r,$dom,$confname,$lastactref,%domconfig);
} elsif ($action eq 'coursecategories') {
- $output = &modify_coursecategories($dom,%domconfig);
+ $output = &modify_coursecategories($dom,$lastactref,%domconfig);
} elsif ($action eq 'serverstatuses') {
$output = &modify_serverstatuses($dom,%domconfig);
} elsif ($action eq 'requestcourses') {
- $output = &modify_quotas($dom,$action,%domconfig);
+ $output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig);
+ } elsif ($action eq 'requestauthor') {
+ $output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig);
+ } elsif ($action eq 'helpsettings') {
+ $output = &modify_helpsettings($r,$dom,$confname,$lastactref,%domconfig);
} elsif ($action eq 'coursedefaults') {
- $output = &modify_coursedefaults($dom,%domconfig);
+ $output = &modify_coursedefaults($dom,$lastactref,%domconfig);
+ } elsif ($action eq 'selfenrollment') {
+ $output = &modify_selfenrollment($dom,$lastactref,%domconfig)
+ } elsif ($action eq 'usersessions') {
+ $output = &modify_usersessions($dom,$lastactref,%domconfig);
+ } elsif ($action eq 'loadbalancing') {
+ $output = &modify_loadbalancing($dom,%domconfig);
+ } elsif ($action eq 'ltitools') {
+ $output = &modify_ltitools($r,$dom,$action,$lastactref,%domconfig);
+ } elsif ($action eq 'ssl') {
+ $output = &modify_ssl($dom,$lastactref,%domconfig);
+ } elsif ($action eq 'trust') {
+ $output = &modify_trust($dom,$lastactref,%domconfig);
+ } elsif ($action eq 'lti') {
+ $output = &modify_lti($r,$dom,$action,$lastactref,%domconfig);
}
return $output;
}
@@ -423,42 +763,75 @@ sub print_config_box {
my $output;
if ($action eq 'coursecategories') {
$output = &coursecategories_javascript($settings);
+ } elsif ($action eq 'defaults') {
+ $output = &defaults_javascript($settings);
+ } elsif ($action eq 'helpsettings') {
+ my (%privs,%levelscurrent);
+ my %full=();
+ my %levels=(
+ course => {},
+ domain => {},
+ system => {},
+ );
+ my $context = 'domain';
+ my $crstype = 'Course';
+ my $formname = 'display';
+ &Apache::lonuserutils::custom_role_privs(\%privs,\%full,\%levels,\%levelscurrent);
+ my @templateroles = &Apache::lonuserutils::custom_template_roles($context,$crstype);
+ $output =
+ &Apache::lonuserutils::custom_roledefs_js($context,$crstype,$formname,\%full,
+ \@templateroles);
}
- $output .=
+ $output .=
'
- '.
+ | '.
&mt($item->{text}).' '.
&Apache::loncommon::help_open_topic($item->{'help'}).' | '."\n".
'
';
$rowtotal ++;
- if (($action eq 'autoupdate') || ($action eq 'rolecolors') ||
- ($action eq 'usercreation') || ($action eq 'usermodification') ||
- ($action eq 'coursecategories') || ($action eq 'requestcourses')) {
+ my $numheaders = 1;
+ if (ref($item->{'header'}) eq 'ARRAY') {
+ $numheaders = scalar(@{$item->{'header'}});
+ }
+ if ($numheaders > 1) {
my $colspan = '';
- if (($action eq 'rolecolors') || ($action eq 'coursecategories')) {
+ my $rightcolspan = '';
+ if (($action eq 'rolecolors') || ($action eq 'defaults') ||
+ ($action eq 'directorysrch') ||
+ (($action eq 'login') && ($numheaders < 4))) {
$colspan = ' colspan="2"';
}
+ if ($action eq 'usersessions') {
+ $rightcolspan = ' colspan="3"';
+ }
$output .= '
'.&mt($item->{'header'}->[0]->{'col1'}).' |
- '.&mt($item->{'header'}->[0]->{'col2'}).' |
+ '.&mt($item->{'header'}->[0]->{'col2'}).' |
';
$rowtotal ++;
- if ($action eq 'autoupdate') {
- $output .= &print_autoupdate('top',$dom,$settings,\$rowtotal);
- } elsif ($action eq 'usercreation') {
- $output .= &print_usercreation('top',$dom,$settings,\$rowtotal);
- } elsif ($action eq 'usermodification') {
- $output .= &print_usermodification('top',$dom,$settings,\$rowtotal);
+ if (($action eq 'autoupdate') || ($action eq 'usercreation') || ($action eq 'selfcreation') ||
+ ($action eq 'usermodification') || ($action eq 'defaults') || ($action eq 'coursedefaults') ||
+ ($action eq 'selfenrollment') || ($action eq 'usersessions') || ($action eq 'ssl') ||
+ ($action eq 'directorysrch') || ($action eq 'trust') || ($action eq 'helpsettings') ||
+ ($action eq 'contacts')) {
+ $output .= $item->{'print'}->('top',$dom,$settings,\$rowtotal);
} elsif ($action eq 'coursecategories') {
- $output .= &print_coursecategories('top',$dom,$item,$settings,\$rowtotal);
- } elsif ($action eq 'requestcourses') {
+ $output .= $item->{'print'}->('top',$dom,$item,$settings,\$rowtotal);
+ } elsif ($action eq 'login') {
+ if ($numheaders == 4) {
+ $colspan = ' colspan="2"';
+ $output .= &print_login('service',$dom,$confname,$phase,$settings,\$rowtotal);
+ } else {
+ $output .= &print_login('page',$dom,$confname,$phase,$settings,\$rowtotal);
+ }
+ } elsif (($action eq 'requestcourses') || ($action eq 'requestauthor')) {
$output .= &print_quotas($dom,$settings,\$rowtotal,$action);
- } else {
+ } elsif ($action eq 'rolecolors') {
$output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal);
}
$output .= '
@@ -469,15 +842,52 @@ sub print_config_box {
- '.&mt($item->{'header'}->[1]->{'col1'}).' | ';
- $output .= '
+ '.&mt($item->{'header'}->[1]->{'col1'}).' |
'.&mt($item->{'header'}->[1]->{'col2'}).' |
';
$rowtotal ++;
- if ($action eq 'autoupdate') {
- $output .= &print_autoupdate('bottom',$dom,$settings,\$rowtotal);
- } elsif ($action eq 'usercreation') {
- $output .= &print_usercreation('middle',$dom,$settings,\$rowtotal).'
+ if (($action eq 'autoupdate') || ($action eq 'usercreation') ||
+ ($action eq 'selfcreation') || ($action eq 'selfenrollment') ||
+ ($action eq 'usersessions') || ($action eq 'coursecategories') ||
+ ($action eq 'trust') || ($action eq 'contacts') || ($action eq 'defaults')) {
+ if ($action eq 'coursecategories') {
+ $output .= &print_coursecategories('middle',$dom,$item,$settings,\$rowtotal);
+ $colspan = ' colspan="2"';
+ } elsif ($action eq 'trust') {
+ $output .= $item->{'print'}->('shared',$dom,$settings,\$rowtotal);
+ } else {
+ $output .= $item->{'print'}->('middle',$dom,$settings,\$rowtotal);
+ }
+ if ($action eq 'trust') {
+ $output .= '
+
+ |
+ ';
+ my @trusthdrs = qw(2 3 4 5 6 7);
+ my @prefixes = qw(enroll othcoau coaurem domroles catalog reqcrs);
+ for (my $i=0; $i<@trusthdrs; $i++) {
+ $output .= '
+
+
+
+
+ '.&mt($item->{'header'}->[$trusthdrs[$i]]->{'col1'}).' |
+ '.&mt($item->{'header'}->[$trusthdrs[$i]]->{'col2'}).' | '.
+ $item->{'print'}->($prefixes[$i],$dom,$settings,\$rowtotal).'
+
+ |
+ ';
+ }
+ $output .= '
+
+
+
+
+ '.&mt($item->{'header'}->[8]->{'col1'}).' |
+ '.&mt($item->{'header'}->[8]->{'col2'}).' | '.
+ $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);
+ } else {
+ $output .= '
|
@@ -486,11 +896,44 @@ sub print_config_box {
'.&mt($item->{'header'}->[2]->{'col1'}).' |
- '.&mt($item->{'header'}->[2]->{'col2'}).' | '.
- &print_usercreation('bottom',$dom,$settings,\$rowtotal);
+ '.&mt($item->{'header'}->[2]->{'col2'}).' |
+ '."\n";
+ if ($action eq 'coursecategories') {
+ $output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal);
+ } else {
+ $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);
+ }
+ }
$rowtotal ++;
- } elsif ($action eq 'usermodification') {
- $output .= &print_usermodification('middle',$dom,$settings,\$rowtotal).'
+ } elsif (($action eq 'usermodification') || ($action eq 'coursedefaults') ||
+ ($action eq 'defaults') || ($action eq 'directorysrch') ||
+ ($action eq 'helpsettings')) {
+ $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);
+ } elsif ($action eq 'ssl') {
+ $output .= $item->{'print'}->('connto',$dom,$settings,\$rowtotal).'
+
+
+
+
+
+
+
+ '.&mt($item->{'header'}->[2]->{'col1'}).' |
+ '.&mt($item->{'header'}->[2]->{'col2'}).' | '.
+ $item->{'print'}->('connfrom',$dom,$settings,\$rowtotal).'
+
+ |
+
+
+
+
+
+ '.&mt($item->{'header'}->[3]->{'col1'}).' |
+ '.&mt($item->{'header'}->[3]->{'col2'}).' | '.
+ $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);
+ } elsif ($action eq 'login') {
+ if ($numheaders == 4) {
+ $output .= &print_login('page',$dom,$confname,$phase,$settings,\$rowtotal).'
|
@@ -499,15 +942,73 @@ sub print_config_box {
'.&mt($item->{'header'}->[2]->{'col1'}).' |
- '.&mt($item->{'header'}->[2]->{'col2'}).' | '.
-
- &print_usermodification('bottom',$dom,$settings,\$rowtotal);
+ '.&mt($item->{'header'}->[2]->{'col2'}).' | '.
+ &print_login('help',$dom,$confname,$phase,$settings,\$rowtotal);
+ $rowtotal ++;
+ } else {
+ $output .= &print_login('help',$dom,$confname,$phase,$settings,\$rowtotal);
+ }
+ $output .= '
+
+
+
+
+
+
+ ';
+ if ($numheaders == 4) {
+ $output .= '
+ '.&mt($item->{'header'}->[3]->{'col1'}).' |
+ '.&mt($item->{'header'}->[3]->{'col2'}).' |
+ ';
+ } else {
+ $output .= '
+ '.&mt($item->{'header'}->[2]->{'col1'}).' |
+ '.&mt($item->{'header'}->[2]->{'col2'}).' |
+ ';
+ }
$rowtotal ++;
- } elsif ($action eq 'coursecategories') {
- $output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal);
+ $output .= &print_login('headtag',$dom,$confname,$phase,$settings,\$rowtotal);
} elsif ($action eq 'requestcourses') {
- $output .= &print_courserequestmail($dom,$settings,\$rowtotal);
- } else {
+ $output .= &print_requestmail($dom,$action,$settings,\$rowtotal);
+ $rowtotal ++;
+ $output .= &print_studentcode($settings,\$rowtotal).'
+
+ |
+
+
+
+
+
+ '.&mt($item->{'header'}->[2]->{'col1'}).' |
+ '.&mt($item->{'header'}->[2]->{'col2'}).' | '.
+ &textbookcourses_javascript($settings).
+ &print_textbookcourses($dom,'textbooks',$settings,\$rowtotal).'
+
+ |
+
+
+
+
+
+ '.&mt($item->{'header'}->[3]->{'col1'}).' |
+ '.&mt($item->{'header'}->[3]->{'col2'}).' | '.
+ &print_textbookcourses($dom,'templates',$settings,\$rowtotal).'
+
+ |
+
+
+
+
+
+ '.&mt($item->{'header'}->[4]->{'col1'}).' |
+ '.&mt($item->{'header'}->[4]->{'col2'}).' |
+ '.
+ &print_validation_rows('requestcourses',$dom,$settings,\$rowtotal);
+ } elsif ($action eq 'requestauthor') {
+ $output .= &print_requestmail($dom,$action,$settings,\$rowtotal);
+ $rowtotal ++;
+ } elsif ($action eq 'rolecolors') {
$output .= &print_rolecolors($phase,'coordinator',$dom,$confname,$settings,\$rowtotal).'
|
@@ -516,9 +1017,9 @@ sub print_config_box {
- '.
+ | '.
&mt($item->{'header'}->[2]->{'col1'}).' |
- '.
+ | '.
&mt($item->{'header'}->[2]->{'col2'}).' |
'.
&print_rolecolors($phase,'author',$dom,$confname,$settings,\$rowtotal).'
@@ -541,57 +1042,56 @@ sub print_config_box {
';
- if (($action eq 'login') || ($action eq 'directorysrch')) {
+ if ($action eq 'login') {
$output .= '
'.&mt($item->{'header'}->[0]->{'col1'}).' | ';
} elsif ($action eq 'serverstatuses') {
$output .= '
- '.&mt($item->{'header'}->[0]->{'col1'}).
+ | '.&mt($item->{'header'}->[0]->{'col1'}).
' ('.&mt('Automatic access for Dom. Coords.').') | ';
} else {
$output .= '
- '.&mt($item->{'header'}->[0]->{'col1'}).' | ';
+ '.&mt($item->{'header'}->[0]->{'col1'}).' | ';
}
if (defined($item->{'header'}->[0]->{'col3'})) {
- $output .= ''.
+ $output .= ' | '.
&mt($item->{'header'}->[0]->{'col2'});
if ($action eq 'serverstatuses') {
$output .= ' ('.&mt('user1:domain1,user2:domain2 etc.').')';
}
} else {
- $output .= ' | '.
+ $output .= ' | '.
&mt($item->{'header'}->[0]->{'col2'});
}
$output .= ' | ';
if ($item->{'header'}->[0]->{'col3'}) {
- $output .= ''.
- &mt($item->{'header'}->[0]->{'col3'});
+ if (defined($item->{'header'}->[0]->{'col4'})) {
+ $output .= ' | '.
+ &mt($item->{'header'}->[0]->{'col3'});
+ } else {
+ $output .= ' | '.
+ &mt($item->{'header'}->[0]->{'col3'});
+ }
if ($action eq 'serverstatuses') {
$output .= ' ('.&mt('IP1,IP2 etc.').')';
}
$output .= ' | ';
}
+ if ($item->{'header'}->[0]->{'col4'}) {
+ $output .= ''.
+ &mt($item->{'header'}->[0]->{'col4'});
+ }
$output .= ' | ';
$rowtotal ++;
- if ($action eq 'login') {
- $output .= &print_login($dom,$confname,$phase,$settings,\$rowtotal);
- } elsif ($action eq 'quotas') {
+ if ($action eq 'quotas') {
$output .= &print_quotas($dom,$settings,\$rowtotal,$action);
- } elsif ($action eq 'autoenroll') {
- $output .= &print_autoenroll($dom,$settings,\$rowtotal);
- } elsif ($action eq 'directorysrch') {
- $output .= &print_directorysrch($dom,$settings,\$rowtotal);
- } elsif ($action eq 'contacts') {
- $output .= &print_contacts($dom,$settings,\$rowtotal);
- } elsif ($action eq 'defaults') {
- $output .= &print_defaults($dom,\$rowtotal);
+ } elsif (($action eq 'autoenroll') || ($action eq 'autocreate') ||
+ ($action eq 'serverstatuses') || ($action eq 'loadbalancing') ||
+ ($action eq 'ltitools') || ($action eq 'lti')) {
+ $output .= $item->{'print'}->($dom,$settings,\$rowtotal);
} elsif ($action eq 'scantron') {
$output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal);
- } elsif ($action eq 'serverstatuses') {
- $output .= &print_serverstatuses($dom,$settings,\$rowtotal);
- } elsif ($action eq 'coursedefaults') {
- $output .= &print_coursedefaults($dom,$settings,\$rowtotal);
}
}
$output .= '
@@ -603,136 +1103,343 @@ sub print_config_box {
}
sub print_login {
- my ($dom,$confname,$phase,$settings,$rowtotal) = @_;
+ my ($caller,$dom,$confname,$phase,$settings,$rowtotal) = @_;
+ my ($css_class,$datatable);
my %choices = &login_choices();
- my %defaultchecked = (
- 'coursecatalog' => 'on',
- 'adminmail' => 'off',
- 'newuser' => 'off',
- );
- my @toggles = ('coursecatalog','adminmail','newuser');
- my (%checkedon,%checkedoff);
- foreach my $item (@toggles) {
- if ($defaultchecked{$item} eq 'on') {
- $checkedon{$item} = ' checked="checked" ';
- $checkedoff{$item} = ' ';
- } elsif ($defaultchecked{$item} eq 'off') {
- $checkedoff{$item} = ' checked="checked" ';
- $checkedon{$item} = ' ';
+
+ if ($caller eq 'service') {
+ my %servers = &Apache::lonnet::internet_dom_servers($dom);
+ my $choice = $choices{'disallowlogin'};
+ $css_class = ' class="LC_odd_row"';
+ $datatable .= ''.$choice.' | '.
+ ''.$choices{'hostid'}.' | '.
+ ''.$choices{'server'}.' | '.
+ ''.$choices{'serverpath'}.' | '.
+ ''.$choices{'custompath'}.' | '.
+ ''.$choices{'exempt'}.' | '."\n";
+ my %disallowed;
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{'loginvia'}) eq 'HASH') {
+ %disallowed = %{$settings->{'loginvia'}};
+ }
}
- }
- my $loginheader = 'image';
- my @images = ('img','logo','domlogo','login');
- my @logintext = ('textcol','bgcol');
- my @bgs = ('pgbg','mainbg','sidebg');
- my @links = ('link','alink','vlink');
- my %designhash = &Apache::loncommon::get_domainconf($dom);
- my %defaultdesign = %Apache::loncommon::defaultdesign;
- my (%is_custom,%designs);
- my %defaults = (
- font => $defaultdesign{'login.font'},
- );
- foreach my $item (@images) {
- $defaults{$item} = $defaultdesign{'login.'.$item};
- $defaults{'showlogo'}{$item} = 1;
- }
- foreach my $item (@bgs) {
- $defaults{'bgs'}{$item} = $defaultdesign{'login.'.$item};
- }
- foreach my $item (@logintext) {
- $defaults{'logintext'}{$item} = $defaultdesign{'login.'.$item};
- }
- foreach my $item (@links) {
- $defaults{'links'}{$item} = $defaultdesign{'login.'.$item};
- }
- if (ref($settings) eq 'HASH') {
+ foreach my $lonhost (sort(keys(%servers))) {
+ my $direct = 'selected="selected"';
+ if (ref($disallowed{$lonhost}) eq 'HASH') {
+ if ($disallowed{$lonhost}{'server'} ne '') {
+ $direct = '';
+ }
+ }
+ $datatable .= ''.$servers{$lonhost}.' | '.
+ ' | '.
+ ' | ';
+ my ($custom,$exempt);
+ if (ref($disallowed{$lonhost}) eq 'HASH') {
+ $custom = $disallowed{$lonhost}{'custompath'};
+ $exempt = $disallowed{$lonhost}{'exempt'};
+ }
+ $datatable .= ' | '.
+ ' | '.
+ ' ';
+ }
+ $datatable .= '
| ';
+ return $datatable;
+ } elsif ($caller eq 'page') {
+ my %defaultchecked = (
+ 'coursecatalog' => 'on',
+ 'helpdesk' => 'on',
+ 'adminmail' => 'off',
+ 'newuser' => 'off',
+ );
+ my @toggles = ('coursecatalog','adminmail','helpdesk','newuser');
+ my (%checkedon,%checkedoff);
foreach my $item (@toggles) {
- if ($settings->{$item} eq '1') {
- $checkedon{$item} = ' checked="checked" ';
+ if ($defaultchecked{$item} eq 'on') {
+ $checkedon{$item} = ' checked="checked" ';
$checkedoff{$item} = ' ';
- } elsif ($settings->{$item} eq '0') {
- $checkedoff{$item} = ' checked="checked" ';
+ } elsif ($defaultchecked{$item} eq 'off') {
+ $checkedoff{$item} = ' checked="checked" ';
$checkedon{$item} = ' ';
}
}
+ my @images = ('img','logo','domlogo','login');
+ my @logintext = ('textcol','bgcol');
+ my @bgs = ('pgbg','mainbg','sidebg');
+ my @links = ('link','alink','vlink');
+ my %designhash = &Apache::loncommon::get_domainconf($dom);
+ my %defaultdesign = %Apache::loncommon::defaultdesign;
+ my (%is_custom,%designs);
+ my %defaults = (
+ font => $defaultdesign{'login.font'},
+ );
foreach my $item (@images) {
- if (defined($settings->{$item})) {
- $designs{$item} = $settings->{$item};
- $is_custom{$item} = 1;
- }
- if (defined($settings->{'showlogo'}{$item})) {
- $designs{'showlogo'}{$item} = $settings->{'showlogo'}{$item};
- }
+ $defaults{$item} = $defaultdesign{'login.'.$item};
+ $defaults{'showlogo'}{$item} = 1;
}
- foreach my $item (@logintext) {
- if ($settings->{$item} ne '') {
- $designs{'logintext'}{$item} = $settings->{$item};
- $is_custom{$item} = 1;
- }
+ foreach my $item (@bgs) {
+ $defaults{'bgs'}{$item} = $defaultdesign{'login.'.$item};
}
- if ($settings->{'loginheader'} ne '') {
- $loginheader = $settings->{'loginheader'};
+ foreach my $item (@logintext) {
+ $defaults{'logintext'}{$item} = $defaultdesign{'login.'.$item};
}
- if ($settings->{'font'} ne '') {
- $designs{'font'} = $settings->{'font'};
- $is_custom{'font'} = 1;
+ foreach my $item (@links) {
+ $defaults{'links'}{$item} = $defaultdesign{'login.'.$item};
}
- foreach my $item (@bgs) {
- if ($settings->{$item} ne '') {
- $designs{'bgs'}{$item} = $settings->{$item};
- $is_custom{$item} = 1;
+ if (ref($settings) eq 'HASH') {
+ foreach my $item (@toggles) {
+ if ($settings->{$item} eq '1') {
+ $checkedon{$item} = ' checked="checked" ';
+ $checkedoff{$item} = ' ';
+ } elsif ($settings->{$item} eq '0') {
+ $checkedoff{$item} = ' checked="checked" ';
+ $checkedon{$item} = ' ';
+ }
}
- }
- foreach my $item (@links) {
- if ($settings->{$item} ne '') {
- $designs{'links'}{$item} = $settings->{$item};
- $is_custom{$item} = 1;
+ foreach my $item (@images) {
+ if (defined($settings->{$item})) {
+ $designs{$item} = $settings->{$item};
+ $is_custom{$item} = 1;
+ }
+ if (defined($settings->{'showlogo'}{$item})) {
+ $designs{'showlogo'}{$item} = $settings->{'showlogo'}{$item};
+ }
+ }
+ foreach my $item (@logintext) {
+ if ($settings->{$item} ne '') {
+ $designs{'logintext'}{$item} = $settings->{$item};
+ $is_custom{$item} = 1;
+ }
+ }
+ if ($settings->{'font'} ne '') {
+ $designs{'font'} = $settings->{'font'};
+ $is_custom{'font'} = 1;
+ }
+ foreach my $item (@bgs) {
+ if ($settings->{$item} ne '') {
+ $designs{'bgs'}{$item} = $settings->{$item};
+ $is_custom{$item} = 1;
+ }
+ }
+ foreach my $item (@links) {
+ if ($settings->{$item} ne '') {
+ $designs{'links'}{$item} = $settings->{$item};
+ $is_custom{$item} = 1;
+ }
+ }
+ } else {
+ if ($designhash{$dom.'.login.font'} ne '') {
+ $designs{'font'} = $designhash{$dom.'.login.font'};
+ $is_custom{'font'} = 1;
+ }
+ foreach my $item (@images) {
+ if ($designhash{$dom.'.login.'.$item} ne '') {
+ $designs{$item} = $designhash{$dom.'.login.'.$item};
+ $is_custom{$item} = 1;
+ }
+ }
+ foreach my $item (@bgs) {
+ if ($designhash{$dom.'.login.'.$item} ne '') {
+ $designs{'bgs'}{$item} = $designhash{$dom.'.login.'.$item};
+ $is_custom{$item} = 1;
+ }
+ }
+ foreach my $item (@links) {
+ if ($designhash{$dom.'.login.'.$item} ne '') {
+ $designs{'links'}{$item} = $designhash{$dom.'.login.'.$item};
+ $is_custom{$item} = 1;
+ }
}
}
- } else {
- if ($designhash{$dom.'.login.font'} ne '') {
- $designs{'font'} = $designhash{$dom.'.login.font'};
- $is_custom{'font'} = 1;
+ my %alt_text = &Apache::lonlocal::texthash ( img => 'Log-in banner',
+ logo => 'Institution Logo',
+ domlogo => 'Domain Logo',
+ login => 'Login box');
+ my $itemcount = 1;
+ foreach my $item (@toggles) {
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ $datatable .=
+ ''.$choices{$item}.
+ ' | '.
+ ' | '.
+ ' ';
+ $itemcount ++;
+ }
+ $datatable .= &display_color_options($dom,$confname,$phase,'login',$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text,$rowtotal,\@logintext);
+ $datatable .= ' | ';
+ } elsif ($caller eq 'help') {
+ my ($defaulturl,$defaulttype,%url,%type,%lt,%langchoices);
+ my $switchserver = &check_switchserver($dom,$confname);
+ my $itemcount = 1;
+ $defaulturl = '/adm/loginproblems.html';
+ $defaulttype = 'default';
+ %lt = &Apache::lonlocal::texthash (
+ del => 'Delete?',
+ rep => 'Replace:',
+ upl => 'Upload:',
+ default => 'Default',
+ custom => 'Custom',
+ );
+ %langchoices = &Apache::lonlocal::texthash(&get_languages_hash());
+ my @currlangs;
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{'helpurl'}) eq 'HASH') {
+ foreach my $key (sort(keys(%{$settings->{'helpurl'}}))) {
+ next if ($settings->{'helpurl'}{$key} eq '');
+ $url{$key} = $settings->{'helpurl'}{$key}.'?inhibitmenu=yes';
+ $type{$key} = 'custom';
+ unless ($key eq 'nolang') {
+ push(@currlangs,$key);
+ }
+ }
+ } elsif ($settings->{'helpurl'} ne '') {
+ $type{'nolang'} = 'custom';
+ $url{'nolang'} = $settings->{'helpurl'}.'?inhibitmenu=yes';
+ }
+ }
+ foreach my $lang ('nolang',sort(@currlangs)) {
+ $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+ $datatable .= '';
+ if ($url{$lang} eq '') {
+ $url{$lang} = $defaulturl;
+ }
+ if ($type{$lang} eq '') {
+ $type{$lang} = $defaulttype;
+ }
+ $datatable .= '';
+ if ($lang eq 'nolang') {
+ $datatable .= &mt('Log-in help page if no specific language file: [_1]',
+ &Apache::loncommon::modal_link($url{$lang},$lt{$type{$lang}},600,500));
+ } else {
+ $datatable .= &mt('Log-in help page for language: [_1] is [_2]',
+ $langchoices{$lang},
+ &Apache::loncommon::modal_link($url{$lang},$lt{$type{$lang}},600,500));
+ }
+ $datatable .= ' | '."\n".
+ '';
+ if ($type{$lang} eq 'custom') {
+ $datatable .= ' '.$lt{'rep'}.'';
+ } else {
+ $datatable .= $lt{'upl'};
+ }
+ $datatable .=' ';
+ if ($switchserver) {
+ $datatable .= &mt('Upload to library server: [_1]',$switchserver);
+ } else {
+ $datatable .= '';
+ }
+ $datatable .= ' | ';
+ $itemcount ++;
}
- foreach my $item (@images) {
- if ($designhash{$dom.'.login.'.$item} ne '') {
- $designs{$item} = $designhash{$dom.'.login.'.$item};
- $is_custom{$item} = 1;
+ my @addlangs;
+ foreach my $lang (sort(keys(%langchoices))) {
+ next if ((grep(/^\Q$lang\E$/,@currlangs)) || ($lang eq 'x_chef'));
+ push(@addlangs,$lang);
+ }
+ if (@addlangs > 0) {
+ my %toadd;
+ map { $toadd{$_} = $langchoices{$_} ; } @addlangs;
+ $toadd{''} = &mt('Select');
+ $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+ $datatable .= ''.
+ &mt('Add log-in help page for a specific language:').' '.
+ &Apache::loncommon::select_form('','loginhelpurl_add_lang',\%toadd).
+ ' | '.$lt{'upl'}.' ';
+ if ($switchserver) {
+ $datatable .= &mt('Upload to library server: [_1]',$switchserver);
+ } else {
+ $datatable .= '';
}
+ $datatable .= ' | ';
+ $itemcount ++;
}
- foreach my $item (@bgs) {
- if ($designhash{$dom.'.login.'.$item} ne '') {
- $designs{'bgs'}{$item} = $designhash{$dom.'.login.'.$item};
- $is_custom{$item} = 1;
+ $datatable .= &captcha_choice('login',$settings,$itemcount);
+ } elsif ($caller eq 'headtag') {
+ my %domservers = &Apache::lonnet::get_servers($dom);
+ my $choice = $choices{'headtag'};
+ $css_class = ' class="LC_odd_row"';
+ $datatable .= ''.$choice.' | '.
+ ' | ';
}
- my %alt_text = &Apache::lonlocal::texthash ( img => 'Log-in banner',
- logo => 'Institution Logo',
- domlogo => 'Domain Logo',
- login => 'Login box');
- my $itemcount = 1;
- my ($css_class,$datatable);
- foreach my $item (@toggles) {
- $css_class = $itemcount%2?' class="LC_odd_row"':'';
- $datatable .=
- ''.$choices{$item}.
- ' | '.
- ' | '.
- ' ';
- $itemcount ++;
- }
- $datatable .= &display_color_options($dom,$confname,$phase,'login',$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text,$rowtotal,\@logintext,$loginheader);
- $datatable .= ' | ';
return $datatable;
}
@@ -740,23 +1447,34 @@ sub login_choices {
my %choices =
&Apache::lonlocal::texthash (
coursecatalog => 'Display Course/Community Catalog link?',
- adminmail => "Display Administrator's E-mail Address?",
- newuser => "Link to create a user account",
- img => "Header",
- logo => "Main Logo",
- domlogo => "Domain Logo",
- login => "Log-in Header",
- textcol => "Text color",
- bgcol => "Box color",
- bgs => "Background colors",
- links => "Link colors",
- font => "Font color",
- pgbg => "Header",
- mainbg => "Page",
- sidebg => "Login box",
- link => "Link",
- alink => "Active link",
- vlink => "Visited link",
+ adminmail => "Display Administrator's E-mail Address?",
+ helpdesk => 'Display "Contact Helpdesk" link',
+ disallowlogin => "Login page requests redirected",
+ hostid => "Server",
+ server => "Redirect to:",
+ serverpath => "Path",
+ custompath => "Custom",
+ exempt => "Exempt IP(s)",
+ directlogin => "No redirect",
+ newuser => "Link to create a user account",
+ img => "Header",
+ logo => "Main Logo",
+ domlogo => "Domain Logo",
+ login => "Log-in Header",
+ textcol => "Text color",
+ bgcol => "Box color",
+ bgs => "Background colors",
+ links => "Link colors",
+ font => "Font color",
+ pgbg => "Header",
+ mainbg => "Page",
+ sidebg => "Login box",
+ link => "Link",
+ alink => "Active link",
+ vlink => "Visited link",
+ headtag => "Custom markup",
+ action => "Action",
+ current => "Current",
);
return %choices;
}
@@ -771,16 +1489,7 @@ sub print_rolecolors {
my %designhash = &Apache::loncommon::get_domainconf($dom);
my %defaultdesign = %Apache::loncommon::defaultdesign;
my (%is_custom,%designs);
- my %defaults = (
- img => $defaultdesign{$role.'.img'},
- font => $defaultdesign{$role.'.font'},
- );
- foreach my $item (@bgs) {
- $defaults{'bgs'}{$item} = $defaultdesign{$role.'.'.$item};
- }
- foreach my $item (@links) {
- $defaults{'links'}{$item} = $defaultdesign{$role.'.'.$item};
- }
+ my %defaults = &role_defaults($role,\@bgs,\@links,\@images);
if (ref($settings) eq 'HASH') {
if (ref($settings->{$role}) eq 'HASH') {
if ($settings->{$role}->{'img'} ne '') {
@@ -791,6 +1500,10 @@ sub print_rolecolors {
$designs{'font'} = $settings->{$role}->{'font'};
$is_custom{'font'} = 1;
}
+ if ($settings->{$role}->{'fontmenu'} ne '') {
+ $designs{'fontmenu'} = $settings->{$role}->{'fontmenu'};
+ $is_custom{'fontmenu'} = 1;
+ }
foreach my $item (@bgs) {
if ($settings->{$role}->{$item} ne '') {
$designs{'bgs'}{$item} = $settings->{$role}->{$item};
@@ -809,6 +1522,10 @@ sub print_rolecolors {
$designs{img} = $designhash{$dom.'.'.$role.'.img'};
$is_custom{'img'} = 1;
}
+ if ($designhash{$dom.'.'.$role.'.fontmenu'} ne '') {
+ $designs{fontmenu} = $designhash{$dom.'.'.$role.'.fontmenu'};
+ $is_custom{'fontmenu'} = 1;
+ }
if ($designhash{$dom.'.'.$role.'.font'} ne '') {
$designs{font} = $designhash{$dom.'.'.$role.'.font'};
$is_custom{'font'} = 1;
@@ -833,9 +1550,48 @@ sub print_rolecolors {
return $datatable;
}
+sub role_defaults {
+ my ($role,$bgs,$links,$images,$logintext) = @_;
+ my %defaults;
+ unless ((ref($bgs) eq 'ARRAY') && (ref($links) eq 'ARRAY') && (ref($images) eq 'ARRAY')) {
+ return %defaults;
+ }
+ my %defaultdesign = %Apache::loncommon::defaultdesign;
+ if ($role eq 'login') {
+ %defaults = (
+ font => $defaultdesign{$role.'.font'},
+ );
+ if (ref($logintext) eq 'ARRAY') {
+ foreach my $item (@{$logintext}) {
+ $defaults{'logintext'}{$item} = $defaultdesign{$role.'.'.$item};
+ }
+ }
+ foreach my $item (@{$images}) {
+ $defaults{'showlogo'}{$item} = 1;
+ }
+ } else {
+ %defaults = (
+ img => $defaultdesign{$role.'.img'},
+ font => $defaultdesign{$role.'.font'},
+ fontmenu => $defaultdesign{$role.'.fontmenu'},
+ );
+ }
+ foreach my $item (@{$bgs}) {
+ $defaults{'bgs'}{$item} = $defaultdesign{$role.'.'.$item};
+ }
+ foreach my $item (@{$links}) {
+ $defaults{'links'}{$item} = $defaultdesign{$role.'.'.$item};
+ }
+ foreach my $item (@{$images}) {
+ $defaults{$item} = $defaultdesign{$role.'.'.$item};
+ }
+ return %defaults;
+}
+
sub display_color_options {
my ($dom,$confname,$phase,$role,$itemcount,$choices,$is_custom,$defaults,$designs,
- $images,$bgs,$links,$alt_text,$rowtotal,$logintext,$loginheader) = @_;
+ $images,$bgs,$links,$alt_text,$rowtotal,$logintext) = @_;
+ my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
my $css_class = $itemcount%2?' class="LC_odd_row"':'';
my $datatable = ''.
''.$choices->{'font'}.' | ';
@@ -844,13 +1600,28 @@ sub display_color_options {
} else {
$datatable .= ' | ';
}
- my $fontlink = &color_pick($phase,$role,'font',$choices->{'font'},$designs->{'font'});
+ my $current_color = $designs->{'font'} ? $designs->{'font'} : $defaults->{'font'};
+
$datatable .= ''.
- ' '.$fontlink.
- ' '.
- ' | ';
+ ' '.
+ ' ';
+ unless ($role eq 'login') {
+ $datatable .= ''.
+ ''.$choices->{'fontmenu'}.' | ';
+ if (!$is_custom->{'fontmenu'}) {
+ $datatable .= ''.&mt('Default in use:').' '.$defaults->{'fontmenu'}.' | ';
+ } else {
+ $datatable .= ' | ';
+ }
+ $current_color = $designs->{'fontmenu'} ?
+ $designs->{'fontmenu'} : $defaults->{'fontmenu'};
+ $datatable .= ''.
+ ' '.
+ ' | ';
+ }
my $switchserver = &check_switchserver($dom,$confname);
foreach my $img (@{$images}) {
$itemcount ++;
@@ -861,11 +1632,10 @@ sub display_color_options {
if ($role eq 'login') {
if ($img eq 'login') {
$login_hdr_pick =
- &login_header_options($img,$role,$defaults,$is_custom,$choices,
- $loginheader);
+ &login_header_options($img,$role,$defaults,$is_custom,$choices);
$logincolors =
&login_text_colors($img,$role,$logintext,$phase,$choices,
- $designs);
+ $designs,$defaults);
} elsif ($img ne 'domlogo') {
$datatable.= &logo_display_options($img,$defaults,$designs);
}
@@ -898,19 +1668,20 @@ sub display_color_options {
$showfile = $imgfile;
my $imgdir = $1;
my $filename = $2;
- if (-e "/home/httpd/html/$imgdir/tn-".$filename) {
+ if (-e "$londocroot/$imgdir/tn-".$filename) {
$showfile = "/$imgdir/tn-".$filename;
} else {
- my $input = "/home/httpd/html".$imgfile;
- my $output = '/home/httpd/html/'.$imgdir.'/tn-'.$filename;
+ my $input = $londocroot.$imgfile;
+ my $output = "$londocroot/$imgdir/tn-".$filename;
if (!-e $output) {
my ($width,$height) = &thumb_dimensions();
my ($fullwidth,$fullheight) = &check_dimensions($input);
if ($fullwidth ne '' && $fullheight ne '') {
if ($fullwidth > $width && $fullheight > $height) {
my $size = $width.'x'.$height;
- system("convert -sample $size $input $output");
- $showfile = '/'.$imgdir.'/tn-'.$filename;
+ my @args = ('convert','-sample',$size,$input,$output);
+ system({$args[0]} @args);
+ $showfile = "/$imgdir/tn-".$filename;
}
}
}
@@ -939,22 +1710,24 @@ sub display_color_options {
}
$datatable .= '';
if ($img eq 'login') {
- $datatable .= $login_hdr_pick;
- }
+ $datatable .= $login_hdr_pick;
+ }
$datatable .= &image_changes($is_custom->{$img},$alt_text->{$img},$img_import,
$showfile,$fullsize,$role,$img,$imgfile,$logincolors);
} else {
- $datatable .= ' | '.
- &mt('Upload:');
+ $datatable .= ' | | '.
+ &mt('Upload:').' ';
}
} else {
- $datatable .= ' | '.
- &mt('Upload:');
+ $datatable .= ' | | '.
+ &mt('Upload:').' ';
}
if ($switchserver) {
$datatable .= &mt('Upload to library server: [_1]',$switchserver);
} else {
- $datatable .=' ';
+ if ($img ne 'login') { # suppress file selection for Log-in header
+ $datatable .=' ';
+ }
}
$datatable .= ' | ';
}
@@ -975,13 +1748,14 @@ sub display_color_options {
}
$datatable .= ''.
' | ';
@@ -1003,13 +1777,12 @@ sub display_color_options {
$datatable .= ''.
'';
foreach my $item (@{$links}) {
- $datatable .= ''."\n".
- &color_pick($phase,$role,$item,$choices->{$item},
- $designs->{'links'}{$item});
+ my $color = $designs->{'links'}{$item} ? $designs->{'links'}{$item} : $defaults->{'links'}{$item};
+ $datatable .= ' | '.$choices->{$item}."\n";
if ($designs->{'links'}{$item}) {
- $datatable.=' ';
+ $datatable.=' ';
}
- $datatable .= '
| ';
}
$$rowtotal += $itemcount;
@@ -1043,20 +1816,10 @@ sub logo_display_options {
}
sub login_header_options {
- my ($img,$role,$defaults,$is_custom,$choices,$loginheader) = @_;
- my $image_checked = ' checked="checked" ';
- my $text_checked = ' ';
- if ($loginheader eq 'text') {
- $image_checked = ' ';
- $text_checked = ' checked="checked" ';
- }
- my $output = ' '.
- ' '."\n";
+ my ($img,$role,$defaults,$is_custom,$choices) = @_;
+ my $output = '';
if ((!$is_custom->{'textcol'}) || (!$is_custom->{'bgcol'})) {
- $output .= &mt('Text default(s)').': ';
+ $output .= &mt('Text default(s):').' ';
if (!$is_custom->{'textcol'}) {
$output .= $choices->{'textcol'}.': '.$defaults->{'logintext'}{'textcol'}.
' ';
@@ -1073,17 +1836,13 @@ sub login_header_options {
}
sub login_text_colors {
- my ($img,$role,$logintext,$phase,$choices,$designs) = @_;
+ my ($img,$role,$logintext,$phase,$choices,$designs,$defaults) = @_;
my $color_menu = ' ';
return $color_menu;
@@ -1092,37 +1851,35 @@ sub login_text_colors {
sub image_changes {
my ($is_custom,$alt_text,$img_import,$showfile,$fullsize,$role,$img,$imgfile,$logincolors) = @_;
my $output;
- if (!$is_custom) {
+ if ($img eq 'login') {
+ # suppress image for Log-in header
+ } elsif (!$is_custom) {
if ($img ne 'domlogo') {
$output .= &mt('Default image:').' ';
} else {
$output .= &mt('Default in use:').' ';
}
}
- if ($img_import) {
- $output .= '';
- }
- $output .= '';
- if ($is_custom) {
- $output .= ''.$logincolors.' '.&mt('Replace:').' ';
+ if ($img eq 'login') { # suppress image for Log-in header
+ $output .= ' | '.$logincolors;
} else {
- $output .= ' | '.$logincolors.&mt('Upload:').' ';
+ if ($img_import) {
+ $output .= '';
+ }
+ $output .= ' | ';
+ if ($is_custom) {
+ $output .= ''.$logincolors.' '.&mt('Replace:').' ';
+ } else {
+ $output .= ' | '.$logincolors.&mt('Upload:').' ';
+ }
}
return $output;
}
-sub color_pick {
- my ($phase,$role,$item,$desc,$curcol) = @_;
- my $link = ''.$desc.'';
- return $link;
-}
-
sub print_quotas {
my ($dom,$settings,$rowtotal,$action) = @_;
my $context;
@@ -1131,29 +1888,37 @@ sub print_quotas {
} else {
$context = $action;
}
- my ($datatable,$defaultquota,@usertools,@options,%validations);
+ my ($datatable,$defaultquota,$authorquota,@usertools,@options,%validations);
my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
my $typecount = 0;
my ($css_class,%titles);
if ($context eq 'requestcourses') {
- @usertools = ('official','unofficial','community');
- @options =('norequest','approval','autolimit','validate');
+ @usertools = ('official','unofficial','community','textbook','placement','lti');
+ @options =('norequest','approval','validate','autolimit');
%validations = &Apache::lonnet::auto_courserequest_checks($dom);
%titles = &courserequest_titles();
+ } elsif ($context eq 'requestauthor') {
+ @usertools = ('author');
+ @options = ('norequest','approval','automatic');
+ %titles = &authorrequest_titles();
} else {
- @usertools = ('aboutme','blog','portfolio');
+ @usertools = ('aboutme','blog','webdav','portfolio');
%titles = &tool_titles();
}
if (ref($types) eq 'ARRAY') {
foreach my $type (@{$types}) {
- my $currdefquota;
- unless ($context eq 'requestcourses') {
+ my ($currdefquota,$currauthorquota);
+ unless (($context eq 'requestcourses') ||
+ ($context eq 'requestauthor')) {
if (ref($settings) eq 'HASH') {
if (ref($settings->{defaultquota}) eq 'HASH') {
- $currdefquota = $settings->{defaultquota}->{$type};
+ $currdefquota = $settings->{defaultquota}->{$type};
} else {
$currdefquota = $settings->{$type};
}
+ if (ref($settings->{authorquota}) eq 'HASH') {
+ $currauthorquota = $settings->{authorquota}->{$type};
+ }
}
}
if (defined($usertypes->{$type})) {
@@ -1206,16 +1971,38 @@ sub print_quotas {
$cell{$item} .= ' ';
+ $titles{$option}.'';
if ($option eq 'autolimit') {
- $cell{$item} .= '';
}
+ $cell{$item} .= ' ';
if ($option eq 'autolimit') {
$cell{$item} .= $titles{'unlimited'};
}
- $cell{$item} .= ' ';
+ }
+ } elsif ($context eq 'requestauthor') {
+ my $curroption;
+ if (ref($settings) eq 'HASH') {
+ $curroption = $settings->{$type};
+ }
+ if (!$curroption) {
+ $curroption = 'norequest';
+ }
+ foreach my $option (@options) {
+ my $val = $option;
+ if ($option eq 'norequest') {
+ $val = 0;
+ }
+ my $checked = '';
+ if ($option eq $curroption) {
+ $checked = ' checked="checked"';
+ }
+ $datatable .= ' ';
}
} else {
my $checked = 'checked="checked" ';
@@ -1237,30 +2024,40 @@ sub print_quotas {
if ($context eq 'requestcourses') {
$datatable .= ' | ';
foreach my $item (@usertools) {
- $datatable .= ''.$cell{$item}.' | ';
+ $datatable .= ''.$cell{$item}.' | ';
}
$datatable .= ' ';
}
$datatable .= ' | ';
- unless ($context eq 'requestcourses') {
+ unless (($context eq 'requestcourses') ||
+ ($context eq 'requestauthor')) {
$datatable .=
- ''.
+ ' | '.
+ ''.&mt('Portfolio').': '.
' Mb | ';
+ '" size="5" />'.(' ' x 2).
+ ''.&mt('Authoring').': '.
+ '';
}
$datatable .= '';
}
}
}
- unless ($context eq 'requestcourses') {
+ unless (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
$defaultquota = '20';
+ $authorquota = '500';
if (ref($settings) eq 'HASH') {
if (ref($settings->{'defaultquota'}) eq 'HASH') {
$defaultquota = $settings->{'defaultquota'}->{'default'};
} elsif (defined($settings->{'default'})) {
$defaultquota = $settings->{'default'};
}
+ if (ref($settings->{'authorquota'}) eq 'HASH') {
+ $authorquota = $settings->{'authorquota'}->{'default'};
+ }
}
}
$typecount ++;
@@ -1314,15 +2111,37 @@ sub print_quotas {
'_default" value="'.$val.'"'.$checked.' />'.
$titles{$option}.'';
if ($option eq 'autolimit') {
- $defcell{$item} .= '';
}
- $defcell{$item} .= ' ';
+ $defcell{$item} .= ' ';
if ($option eq 'autolimit') {
$defcell{$item} .= $titles{'unlimited'};
}
}
+ } elsif ($context eq 'requestauthor') {
+ my $curroption;
+ if (ref($settings) eq 'HASH') {
+ $curroption = $settings->{'default'};
+ }
+ if (!$curroption) {
+ $curroption = 'norequest';
+ }
+ foreach my $option (@options) {
+ my $val = $option;
+ if ($option eq 'norequest') {
+ $val = 0;
+ }
+ my $checked = '';
+ if ($option eq $curroption) {
+ $checked = ' checked="checked"';
+ }
+ $datatable .= ' ';
+ }
} else {
my $checked = 'checked="checked" ';
if (ref($settings) eq 'HASH') {
@@ -1343,21 +2162,25 @@ sub print_quotas {
if ($context eq 'requestcourses') {
$datatable .= '';
foreach my $item (@usertools) {
- $datatable .= ''.$defcell{$item}.' | ';
+ $datatable .= ''.$defcell{$item}.' | ';
}
$datatable .= ' ';
}
$datatable .= ' | ';
- unless ($context eq 'requestcourses') {
- $datatable .= ''.
+ unless (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
+ $datatable .= ' | '.
+ ''.&mt('Portfolio').': '.
' Mb | ';
+ $defaultquota.'" size="5" />'.(' ' x2).
+ ''.&mt('Authoring').': '.
+ '';
}
$datatable .= '
';
$typecount ++;
$css_class = $typecount%2?' class="LC_odd_row"':'';
$datatable .= ''.
- ''.&mt('LON-CAPA Advanced Users').' ';
+ ' | '.&mt('LON-CAPA Advanced Users').' ';
if ($context eq 'requestcourses') {
$datatable .= &mt('(overrides affiliation, if set)').
' | '.
@@ -1417,15 +2240,42 @@ sub print_quotas {
'__LC_adv" value="'.$val.'"'.$checked.' />'.
$titles{$option}.'';
if ($option eq 'autolimit') {
- $advcell{$item} .= '';
}
- $advcell{$item} .= ' ';
+ $advcell{$item} .= ' ';
if ($option eq 'autolimit') {
$advcell{$item} .= $titles{'unlimited'};
}
}
+ } elsif ($context eq 'requestauthor') {
+ my $curroption;
+ if (ref($settings) eq 'HASH') {
+ $curroption = $settings->{'_LC_adv'};
+ }
+ my $checked = '';
+ if ($curroption eq '') {
+ $checked = ' checked="checked"';
+ }
+ $datatable .= ' ';
+ foreach my $option (@options) {
+ my $val = $option;
+ if ($option eq 'norequest') {
+ $val = 0;
+ }
+ my $checked = '';
+ if ($val eq $curroption) {
+ $checked = ' checked="checked"';
+ }
+ $datatable .= ' ';
+ }
} else {
my $checked = 'checked="checked" ';
if (ref($settings) eq 'HASH') {
@@ -1446,7 +2296,7 @@ sub print_quotas {
if ($context eq 'requestcourses') {
$datatable .= '
';
foreach my $item (@usertools) {
- $datatable .= ''.$advcell{$item}.' | ';
+ $datatable .= ''.$advcell{$item}.' | ';
}
$datatable .= '
';
}
@@ -1455,88 +2305,652 @@ sub print_quotas {
return $datatable;
}
-sub print_courserequestmail {
- my ($dom,$settings,$rowtotal) = @_;
- my ($now,$datatable,%dompersonnel,@domcoord,@currapproval,$rows);
+sub print_requestmail {
+ my ($dom,$action,$settings,$rowtotal,$customcss,$rowstyle) = @_;
+ my ($now,$datatable,%currapp);
$now = time;
- $rows = 0;
- %dompersonnel = &Apache::lonnet::get_domain_roles($dom,['dc'],$now,$now);
- foreach my $server (keys(%dompersonnel)) {
- foreach my $user (sort(keys(%{$dompersonnel{$server}}))) {
- my ($trole,$uname,$udom,$runame,$rudom,$rsec) = split(/:/,$user);
- if (!grep(/^$uname:$udom$/,@domcoord)) {
- push(@domcoord,$uname.':'.$udom);
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{'notify'}) eq 'HASH') {
+ if ($settings->{'notify'}{'approval'} ne '') {
+ map {$currapp{$_}=1;} split(/,/,$settings->{'notify'}{'approval'});
}
}
}
+ my $numinrow = 2;
+ my $css_class;
+ if ($$rowtotal%2) {
+ $css_class = 'LC_odd_row';
+ }
+ if ($customcss) {
+ $css_class .= " $customcss";
+ }
+ $css_class =~ s/^\s+//;
+ if ($css_class) {
+ $css_class = ' class="'.$css_class.'"';
+ }
+ if ($rowstyle) {
+ $css_class .= ' style="'.$rowstyle.'"';
+ }
+ my $text;
+ if ($action eq 'requestcourses') {
+ $text = &mt('Receive notification of course requests requiring approval');
+ } elsif ($action eq 'requestauthor') {
+ $text = &mt('Receive notification of Authoring Space requests requiring approval');
+ } else {
+ $text = &mt('Receive notification of queued requests for self-created user accounts requiring approval');
+ }
+ $datatable = ''.
+ ' '.$text.' | '.
+ ' ';
+ my ($numdc,$table,$rows) = &active_dc_picker($dom,$numinrow,'checkbox',
+ $action.'notifyapproval',%currapp);
+ if ($numdc > 0) {
+ $datatable .= $table;
+ } else {
+ $datatable .= &mt('There are no active Domain Coordinators');
+ }
+ $datatable .=' |
';
+ return $datatable;
+}
+
+sub print_studentcode {
+ my ($settings,$rowtotal) = @_;
+ my $rownum = 0;
+ my ($output,%current);
+ my @crstypes = ('official','unofficial','community','textbook','placement','lti');
if (ref($settings) eq 'HASH') {
- if (ref($settings->{'notify'}) eq 'HASH') {
- if ($settings->{'notify'}{'approval'} ne '') {
- @currapproval = split(',',$settings->{'notify'}{'approval'});
+ if (ref($settings->{'uniquecode'}) eq 'HASH') {
+ foreach my $type (@crstypes) {
+ $current{$type} = $settings->{'uniquecode'}{$type};
}
}
}
- if (@currapproval) {
- foreach my $dc (@currapproval) {
- unless (grep(/^\Q$dc\E$/,@domcoord)) {
- push(@domcoord,$dc);
+ $output .= ''.
+ ''.&mt('Generate unique six character code as course identifier?').' | '.
+ '';
+ foreach my $type (@crstypes) {
+ my $check = ' ';
+ if ($current{$type}) {
+ $check = ' checked="checked" ';
+ }
+ $output .= ''.(' 'x2).' ';
+ }
+ $output .= ' |
';
+ $$rowtotal ++;
+ return $output;
+}
+
+sub print_textbookcourses {
+ my ($dom,$type,$settings,$rowtotal) = @_;
+ my $rownum = 0;
+ my $css_class;
+ my $itemcount = 1;
+ my $maxnum = 0;
+ my $bookshash;
+ if (ref($settings) eq 'HASH') {
+ $bookshash = $settings->{$type};
+ }
+ my %ordered;
+ if (ref($bookshash) eq 'HASH') {
+ foreach my $item (keys(%{$bookshash})) {
+ if (ref($bookshash->{$item}) eq 'HASH') {
+ my $num = $bookshash->{$item}{'order'};
+ $ordered{$num} = $item;
}
}
}
- @domcoord = sort(@domcoord);
- my $numinrow = 4;
- my $numdc = @domcoord;
- my $css_class = 'class="LC_odd_row"';
- $datatable = ''.
- ' '.&mt('Receive notification of course requests requiring approval.').
- ' | '.
- ' ';
- if (@domcoord > 0) {
- $datatable .= '';
- for (my $i=0; $i<$numdc; $i++) {
- my $rem = $i%($numinrow);
- if ($rem == 0) {
- if ($i > 0) {
- $datatable .= '';
+ my $confname = $dom.'-domainconfig';
+ my $switchserver = &check_switchserver($dom,$confname);
+ my $maxnum = scalar(keys(%ordered));
+ my $datatable;
+ if (keys(%ordered)) {
+ my @items = sort { $a <=> $b } keys(%ordered);
+ for (my $i=0; $i<@items; $i++) {
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ my $key = $ordered{$items[$i]};
+ my %coursehash=&Apache::lonnet::coursedescription($key);
+ my $coursetitle = $coursehash{'description'};
+ my ($subject,$title,$author,$publisher,$image,$imgsrc,$cdom,$cnum);
+ if (ref($bookshash->{$key}) eq 'HASH') {
+ $subject = $bookshash->{$key}->{'subject'};
+ $title = $bookshash->{$key}->{'title'};
+ if ($type eq 'textbooks') {
+ $publisher = $bookshash->{$key}->{'publisher'};
+ $author = $bookshash->{$key}->{'author'};
+ $image = $bookshash->{$key}->{'image'};
+ if ($image ne '') {
+ my ($path,$imagefile) = ($image =~ m{^(.+)/([^/]+)$});
+ my $imagethumb = "$path/tn-".$imagefile;
+ $imgsrc = '';
+ }
}
- $datatable .= '';
- $rows ++;
}
- my $check = ' ';
- if (grep(/^\Q$domcoord[$i]\E$/,@currapproval)) {
- $check = ' checked="checked" ';
- }
- my ($uname,$udom) = split(':',$domcoord[$i]);
- my $fullname = &Apache::loncommon::plainname($uname,$udom);
- if ($i == $numdc-1) {
- my $colsleft = $numinrow-$rem;
- if ($colsleft > 1) {
- $datatable .= '';
+ my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'$type".'_'."$key','$type'".');"';
+ $datatable .= ' | '
+ .''.(' 'x2).
+ ' | '.
+ ''.
+ ''.&mt('Subject:').' '.
+ (' 'x2).
+ ''.&mt('Title:').' ';
+ if ($type eq 'textbooks') {
+ $datatable .= (' 'x2).
+ ''.&mt('Publisher:').' '.
+ (' 'x2).
+ ''.&mt('Author(s):').' '.
+ (' 'x2).
+ ''.&mt('Thumbnail:');
+ if ($image) {
+ $datatable .= $imgsrc.
+ ' '.
+ ' '.&mt('Replace:').' ';
+ }
+ if ($switchserver) {
+ $datatable .= &mt('Upload to library server: [_1]',$switchserver);
} else {
- $datatable .= ' | ';
+ $datatable .= '';
}
- } else {
- $datatable .= ' | ';
}
- $datatable .= ' | ';
+ $datatable .= ' '.
+ ''.&mt('LON-CAPA course:').' '.
+ $coursetitle.' '."\n";
+ $itemcount ++;
}
- $datatable .= ' ';
- } else {
- $datatable .= &mt('There are no active Domain Coordinators');
- $rows ++;
}
- $datatable .=' |
';
- $$rowtotal += $rows;
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'$type"."_addbook_pos','$type'".');"';
+ $datatable .= ''."\n".
+ ''."\n".
+ ' '."\n".
+ ''.&mt('Add').' | '."\n".
+ ''.
+ ''.&mt('Subject:').' '."\n".
+ (' 'x2).
+ ''.&mt('Title:').' '."\n".
+ (' 'x2);
+ if ($type eq 'textbooks') {
+ $datatable .= ''.&mt('Publisher:').' '."\n".
+ (' 'x2).
+ ''.&mt('Author(s):').' '."\n".
+ (' 'x2).
+ ''.&mt('Image:').' ';
+ if ($switchserver) {
+ $datatable .= &mt('Upload to library server: [_1]',$switchserver);
+ } else {
+ $datatable .= '';
+ }
+ }
+ $datatable .= ''."\n".
+ ''.&mt('LON-CAPA course:').' '.
+ &Apache::loncommon::select_dom_form($env{'request.role.domain'},$type.'_addbook_cdom').
+ ''.
+ &Apache::loncommon::selectcourse_link
+ ('display',$type.'_addbook_cnum',$type.'_addbook_cdom',undef,undef,undef,'Course');
+ ' | '."\n".
+ '
'."\n";
+ $itemcount ++;
return $datatable;
}
+sub textbookcourses_javascript {
+ my ($settings) = @_;
+ return unless(ref($settings) eq 'HASH');
+ my (%ordered,%total,%jstext);
+ foreach my $type ('textbooks','templates') {
+ $total{$type} = 0;
+ if (ref($settings->{$type}) eq 'HASH') {
+ foreach my $item (keys(%{$settings->{$type}})) {
+ if (ref($settings->{$type}->{$item}) eq 'HASH') {
+ my $num = $settings->{$type}->{$item}{'order'};
+ $ordered{$type}{$num} = $item;
+ }
+ }
+ $total{$type} = scalar(keys(%{$settings->{$type}}));
+ }
+ my @jsarray = ();
+ foreach my $item (sort {$a <=> $b } (keys(%{$ordered{$type}}))) {
+ push(@jsarray,$ordered{$type}{$item});
+ }
+ $jstext{$type} = ' var '.$type.' = Array('."'".join("','",@jsarray)."'".');'."\n";
+ }
+ return <<"ENDSCRIPT";
+
+
+ENDSCRIPT
+}
+
+sub ltitools_javascript {
+ my ($settings) = @_;
+ my $togglejs = <itools_toggle_js();
+ unless (ref($settings) eq 'HASH') {
+ return $togglejs;
+ }
+ my (%ordered,$total,%jstext);
+ $total = 0;
+ foreach my $item (keys(%{$settings})) {
+ if (ref($settings->{$item}) eq 'HASH') {
+ my $num = $settings->{$item}{'order'};
+ $ordered{$num} = $item;
+ }
+ }
+ $total = scalar(keys(%{$settings}));
+ my @jsarray = ();
+ foreach my $item (sort {$a <=> $b } (keys(%ordered))) {
+ push(@jsarray,$ordered{$item});
+ }
+ my $jstext = ' var ltitools = Array('."'".join("','",@jsarray)."'".');'."\n";
+ return <<"ENDSCRIPT";
+
+
+$togglejs
+
+ENDSCRIPT
+}
+
+sub ltitools_toggle_js {
+ return <<"ENDSCRIPT";
+
+
+ENDSCRIPT
+}
+
+sub lti_javascript {
+ my ($settings) = @_;
+ my $togglejs = <i_toggle_js();
+ unless (ref($settings) eq 'HASH') {
+ return $togglejs;
+ }
+ my (%ordered,$total,%jstext);
+ $total = 0;
+ foreach my $item (keys(%{$settings})) {
+ if (ref($settings->{$item}) eq 'HASH') {
+ my $num = $settings->{$item}{'order'};
+ $ordered{$num} = $item;
+ }
+ }
+ $total = scalar(keys(%{$settings}));
+ my @jsarray = ();
+ foreach my $item (sort {$a <=> $b } (keys(%ordered))) {
+ push(@jsarray,$ordered{$item});
+ }
+ my $jstext = ' var lti = Array('."'".join("','",@jsarray)."'".');'."\n";
+ return <<"ENDSCRIPT";
+
+
+$togglejs
+
+ENDSCRIPT
+}
+
+sub lti_toggle_js {
+ my %lcauthparmtext = &Apache::lonlocal::texthash (
+ localauth => 'Local auth argument',
+ krb => 'Kerberos domain',
+ );
+ return <<"ENDSCRIPT";
+
+
+ENDSCRIPT
+}
+
sub print_autoenroll {
my ($dom,$settings,$rowtotal) = @_;
my $autorun = &Apache::lonnet::auto_run(undef,$dom),
- my ($defdom,$runon,$runoff);
+ my ($defdom,$runon,$runoff,$coownerson,$coownersoff,$failsafe);
if (ref($settings) eq 'HASH') {
if (exists($settings->{'run'})) {
if ($settings->{'run'} eq '0') {
@@ -1555,9 +2969,24 @@ sub print_autoenroll {
$runon = ' ';
}
}
+ if (exists($settings->{'co-owners'})) {
+ if ($settings->{'co-owners'} eq '0') {
+ $coownersoff = ' checked="checked" ';
+ $coownerson = ' ';
+ } else {
+ $coownerson = ' checked="checked" ';
+ $coownersoff = ' ';
+ }
+ } else {
+ $coownersoff = ' checked="checked" ';
+ $coownerson = ' ';
+ }
if (exists($settings->{'sender_domain'})) {
$defdom = $settings->{'sender_domain'};
}
+ if (exists($settings->{'autofailsafe'})) {
+ $failsafe = $settings->{'autofailsafe'};
+ }
} else {
if ($autorun) {
$runon = ' checked="checked" ';
@@ -1585,8 +3014,20 @@ sub print_autoenroll {
&mt('username').': '.
' '.&mt('domain').
- ': '.$domform.'';
- $$rowtotal += 2;
+ ': '.$domform.''.
+ ''.
+ ''.&mt('Automatically assign co-ownership').' | '.
+ ' '.
+ ' | '.
+ '
'.
+ ''.&mt('Failsafe for no drops when institutional data missing').' | '.
+ ''.
+ ' |
';
+ $$rowtotal += 4;
return $datatable;
}
@@ -1628,9 +3069,17 @@ sub print_autoupdate {
$classlistsoff.'value="0" />'.&mt('No').''.
'';
$$rowtotal += 2;
+ } elsif ($position eq 'middle') {
+ my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
+ my $numinrow = 3;
+ my $locknamesettings;
+ $datatable .= &insttypes_row($settings,$types,$usertypes,
+ $dom,$numinrow,$othertitle,
+ 'lockablenames',$rowtotal);
+ $$rowtotal ++;
} else {
my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
- my @fields = ('lastname','firstname','middlename','gen',
+ my @fields = ('lastname','firstname','middlename','generation',
'permanentemail','id');
my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
my $numrows = 0;
@@ -1651,196 +3100,1005 @@ sub print_autoupdate {
return $datatable;
}
-sub print_directorysrch {
+sub print_autocreate {
my ($dom,$settings,$rowtotal) = @_;
- my $srchon = ' ';
- my $srchoff = ' checked="checked" ';
- my ($exacton,$containson,$beginson);
- my $localon = ' ';
- my $localoff = ' checked="checked" ';
+ my (%createon,%createoff,%currhash);
+ my @types = ('xml','req');
if (ref($settings) eq 'HASH') {
- if ($settings->{'available'} eq '1') {
- $srchon = $srchoff;
- $srchoff = ' ';
- }
- if ($settings->{'localonly'} eq '1') {
- $localon = $localoff;
- $localoff = ' ';
- }
- if (ref($settings->{'searchtypes'}) eq 'ARRAY') {
- foreach my $type (@{$settings->{'searchtypes'}}) {
- if ($type eq 'exact') {
- $exacton = ' checked="checked" ';
- } elsif ($type eq 'contains') {
- $containson = ' checked="checked" ';
- } elsif ($type eq 'begins') {
- $beginson = ' checked="checked" ';
+ foreach my $item (@types) {
+ $createoff{$item} = ' checked="checked" ';
+ $createon{$item} = ' ';
+ if (exists($settings->{$item})) {
+ if ($settings->{$item}) {
+ $createon{$item} = ' checked="checked" ';
+ $createoff{$item} = ' ';
}
}
- } else {
- if ($settings->{'searchtypes'} eq 'exact') {
- $exacton = ' checked="checked" ';
- } elsif ($settings->{'searchtypes'} eq 'contains') {
- $containson = ' checked="checked" ';
- } elsif ($settings->{'searchtypes'} eq 'specify') {
- $exacton = ' checked="checked" ';
- $containson = ' checked="checked" ';
- }
+ }
+ if ($settings->{'xmldc'} ne '') {
+ $currhash{$settings->{'xmldc'}} = 1;
+ }
+ } else {
+ foreach my $item (@types) {
+ $createoff{$item} = ' checked="checked" ';
+ $createon{$item} = ' ';
}
}
- my ($searchtitles,$titleorder) = &sorted_searchtitles();
- my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
-
- my $numinrow = 4;
- my $cansrchrow = 0;
+ $$rowtotal += 2;
+ my $numinrow = 2;
my $datatable=''.
- ''.&mt('Directory search available?').' | '.
+ ''.&mt('Create pending official courses from XML files').' | '.
' '.
- ' | '.
- '
'.
- ''.&mt('Other domains can search?').' | '.
+ ''.&mt('Yes').' '.
+ ''.
+ '
'.
+ ''.&mt('Create pending requests for official courses (if validated)').' | '.
' '.
- ' | '.
- '
';
- $$rowtotal += 2;
- if (ref($usertypes) eq 'HASH') {
- if (keys(%{$usertypes}) > 0) {
- $datatable .= &insttypes_row($settings,$types,$usertypes,$dom,
- $numinrow,$othertitle,'cansearch');
- $cansrchrow = 1;
- }
- }
- if ($cansrchrow) {
- $$rowtotal ++;
- $datatable .= '';
+ ''.&mt('Yes').' '.
+ '';
+ my ($numdc,$dctable,$rows) = &active_dc_picker($dom,$numinrow,'radio',
+ 'autocreate_xmldc',%currhash);
+ $datatable .= '
';
+ if ($numdc > 1) {
+ $datatable .= &mt('Course creation processed as: (choose Dom. Coord.)').
+ ' | ';
} else {
- $datatable .= ' |
';
+ $datatable .= &mt('Course creation processed as:').
+ '';
}
- $datatable .= ' | '.&mt('Supported search methods').
- ' | |
';
- $$rowtotal ++;
- if ($cansrchrow) {
- $datatable .= '';
+ my ($searchtitles,$titleorder) = &sorted_searchtitles();
+ my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
+
+ my $numinrow = 4;
+ my $cansrchrow = 0;
+ $datatable='
'.
+ ''.&mt('Institutional directory search available?').' | '.
+ ' '.
+ ' | '.
+ '
'.
+ ''.&mt('Other domains can search institution?').' | '.
+ ' '.
+ ' | '.
+ '
';
+ $$rowtotal += 2;
+ if (ref($usertypes) eq 'HASH') {
+ if (keys(%{$usertypes}) > 0) {
+ $datatable .= &insttypes_row($settings,$types,$usertypes,$dom,
+ $numinrow,$othertitle,'cansearch',
+ $rowtotal);
+ $cansrchrow = 1;
+ }
+ }
+ if ($cansrchrow) {
+ $$rowtotal ++;
+ $datatable .= '';
+ } else {
+ $datatable .= '
';
+ }
+ $datatable .= ''.&mt('Supported search methods').
+ ' | |
';
+ $$rowtotal ++;
+ if ($cansrchrow) {
+ $datatable .= '';
+ } else {
+ $datatable .= '
';
+ }
+ $datatable .= ''.&mt('Search latitude').' | '.
+ ''.
+ ' '.
+ ' '.
+ ' |
';
+ $$rowtotal ++;
} else {
- $datatable .= '';
+ my $domsrchon = ' checked="checked" ';
+ my $domsrchoff = ' ';
+ my $domlocalon = ' ';
+ my $domlocaloff = ' checked="checked" ';
+ if (ref($settings) eq 'HASH') {
+ if ($settings->{'lclocalonly'} eq '1') {
+ $domlocalon = $domlocaloff;
+ $domlocaloff = ' ';
+ }
+ if ($settings->{'lcavailable'} eq '0') {
+ $domsrchoff = $domsrchon;
+ $domsrchon = ' ';
+ }
+ }
+ $datatable='
'.
+ ''.&mt('LON-CAPA directory search available?').' | '.
+ ' '.
+ ' | '.
+ '
'.
+ ''.&mt('Other domains can search LON-CAPA domain?').' | '.
+ ' '.
+ ' | '.
+ '
';
+ $$rowtotal += 2;
}
- $datatable .= ''.&mt('Search latitude').' | '.
- ''.
- ' '.
- ' '.
- ' | ';
- $$rowtotal ++;
return $datatable;
}
sub print_contacts {
- my ($dom,$settings,$rowtotal) = @_;
+ my ($position,$dom,$settings,$rowtotal) = @_;
my $datatable;
my @contacts = ('adminemail','supportemail');
- my (%checked,%to,%otheremails);
- my @mailings = ('errormail','packagesmail','lonstatusmail','helpdeskmail',
- 'requestsmail');
- foreach my $type (@mailings) {
- $otheremails{$type} = '';
- }
- if (ref($settings) eq 'HASH') {
- foreach my $item (@contacts) {
- if (exists($settings->{$item})) {
- $to{$item} = $settings->{$item};
+ my (%checked,%to,%otheremails,%bccemails,%includestr,%includeloc,%currfield,
+ $maxsize,$fields,$fieldtitles,$fieldoptions,$possoptions,@mailings);
+ if ($position eq 'top') {
+ if (ref($settings) eq 'HASH') {
+ foreach my $item (@contacts) {
+ if (exists($settings->{$item})) {
+ $to{$item} = $settings->{$item};
+ }
}
}
+ } elsif ($position eq 'middle') {
+ @mailings = ('errormail','packagesmail','lonstatusmail','requestsmail',
+ 'updatesmail','idconflictsmail');
foreach my $type (@mailings) {
- if (exists($settings->{$type})) {
- if (ref($settings->{$type}) eq 'HASH') {
- foreach my $item (@contacts) {
- if ($settings->{$type}{$item}) {
- $checked{$type}{$item} = ' checked="checked" ';
+ $otheremails{$type} = '';
+ }
+ } else {
+ @mailings = ('helpdeskmail','otherdomsmail');
+ foreach my $type (@mailings) {
+ $otheremails{$type} = '';
+ }
+ $bccemails{'helpdeskmail'} = '';
+ $bccemails{'otherdomsmail'} = '';
+ $includestr{'helpdeskmail'} = '';
+ $includestr{'otherdomsmail'} = '';
+ ($fields,$fieldtitles,$fieldoptions,$possoptions) = &helpform_fields();
+ }
+ if (ref($settings) eq 'HASH') {
+ unless ($position eq 'top') {
+ foreach my $type (@mailings) {
+ if (exists($settings->{$type})) {
+ if (ref($settings->{$type}) eq 'HASH') {
+ foreach my $item (@contacts) {
+ if ($settings->{$type}{$item}) {
+ $checked{$type}{$item} = ' checked="checked" ';
+ }
+ }
+ $otheremails{$type} = $settings->{$type}{'others'};
+ if (($type eq 'helpdeskmail') || ($type eq 'otherdomsmail')) {
+ $bccemails{$type} = $settings->{$type}{'bcc'};
+ if ($settings->{$type}{'include'} ne '') {
+ ($includeloc{$type},$includestr{$type}) = split(/:/,$settings->{$type}{'include'},2);
+ $includestr{$type} = &unescape($includestr{$type});
+ }
}
}
- $otheremails{$type} = $settings->{$type}{'others'};
+ } elsif ($type eq 'lonstatusmail') {
+ $checked{'lonstatusmail'}{'adminemail'} = ' checked="checked" ';
}
- } elsif ($type eq 'lonstatusmail') {
- $checked{'lonstatusmail'}{'adminemail'} = ' checked="checked" ';
+ }
+ }
+ if ($position eq 'bottom') {
+ foreach my $type (@mailings) {
+ $bccemails{$type} = $settings->{$type}{'bcc'};
+ if ($settings->{$type}{'include'} ne '') {
+ ($includeloc{$type},$includestr{$type}) = split(/:/,$settings->{$type}{'include'},2);
+ $includestr{$type} = &unescape($includestr{$type});
+ }
+ }
+ if (ref($settings->{'helpform'}) eq 'HASH') {
+ if (ref($fields) eq 'ARRAY') {
+ foreach my $field (@{$fields}) {
+ $currfield{$field} = $settings->{'helpform'}{$field};
+ }
+ }
+ if (exists($settings->{'helpform'}{'maxsize'})) {
+ $maxsize = $settings->{'helpform'}{'maxsize'};
+ } else {
+ $maxsize = '1.0';
+ }
+ } else {
+ if (ref($fields) eq 'ARRAY') {
+ foreach my $field (@{$fields}) {
+ $currfield{$field} = 'yes';
+ }
+ }
+ $maxsize = '1.0';
}
}
} else {
- $to{'supportemail'} = $Apache::lonnet::perlvar{'lonSupportEMail'};
- $to{'adminemail'} = $Apache::lonnet::perlvar{'lonAdmEMail'};
- $checked{'errormail'}{'adminemail'} = ' checked="checked" ';
- $checked{'packagesmail'}{'adminemail'} = ' checked="checked" ';
- $checked{'helpdeskmail'}{'supportemail'} = ' checked="checked" ';
- $checked{'lonstatusmail'}{'adminemail'} = ' checked="checked" ';
- $checked{'requestsmail'}{'adminemail'} = ' checked="checked" ';
+ if ($position eq 'top') {
+ $to{'supportemail'} = $Apache::lonnet::perlvar{'lonSupportEMail'};
+ $to{'adminemail'} = $Apache::lonnet::perlvar{'lonAdmEMail'};
+ $checked{'errormail'}{'adminemail'} = ' checked="checked" ';
+ $checked{'packagesmail'}{'adminemail'} = ' checked="checked" ';
+ $checked{'lonstatusmail'}{'adminemail'} = ' checked="checked" ';
+ $checked{'requestsmail'}{'adminemail'} = ' checked="checked" ';
+ $checked{'updatesmail'}{'adminemail'} = ' checked="checked" ';
+ $checked{'idconflictsmail'}{'adminemail'} = ' checked="checked" ';
+ } elsif ($position eq 'bottom') {
+ $checked{'helpdeskmail'}{'supportemail'} = ' checked="checked" ';
+ $checked{'otherdomsmail'}{'supportemail'} = ' checked="checked" ';
+ if (ref($fields) eq 'ARRAY') {
+ foreach my $field (@{$fields}) {
+ $currfield{$field} = 'yes';
+ }
+ }
+ $maxsize = '1.0';
+ }
}
my ($titles,$short_titles) = &contact_titles();
my $rownum = 0;
my $css_class;
- foreach my $item (@contacts) {
- $rownum ++;
- $css_class = $rownum%2?' class="LC_odd_row"':'';
- $datatable .= ''.
- ''.$titles->{$item}.
- ' | '.
- ' |
';
- }
- foreach my $type (@mailings) {
- $rownum ++;
+ if ($position eq 'top') {
+ foreach my $item (@contacts) {
+ $css_class = $rownum%2?' class="LC_odd_row"':'';
+ $datatable .= ''.
+ ''.$titles->{$item}.
+ ' | '.
+ ' |
';
+ $rownum ++;
+ }
+ } elsif ($position eq 'bottom') {
$css_class = $rownum%2?' class="LC_odd_row"':'';
$datatable .= ''.
- ''.
- $titles->{$type}.': | '.
- ''.
- '';
- foreach my $item (@contacts) {
- $datatable .= ' ';
- }
- $datatable .= ' '.&mt('Others').': '.
- ''.
- ' |
'."\n";
+ ''.&mt('Extra helpdesk form fields:').' '.
+ &mt('(e-mail, subject, and description always shown)').
+ ' | ';
+ if ((ref($fields) eq 'ARRAY') && (ref($fieldtitles) eq 'HASH') &&
+ (ref($fieldoptions) eq 'HASH') && (ref($possoptions) eq 'HASH')) {
+ $datatable .= '';
+ }
+ $datatable .= ' | '."\n";
+ $rownum ++;
+ }
+ unless ($position eq 'top') {
+ foreach my $type (@mailings) {
+ $css_class = $rownum%2?' class="LC_odd_row"':'';
+ $datatable .= ''.
+ ''.
+ $titles->{$type}.': | '.
+ '';
+ if (($type eq 'helpdeskmail') || ($type eq 'otherdomsmail')) {
+ $datatable .= ''.
+ '';
+ }
+ $datatable .= ' |
'."\n";
+ $rownum ++;
+ }
+ }
+ if ($position eq 'middle') {
+ my %choices;
+ $choices{'reporterrors'} = &mt('E-mail error reports to [_1]',
+ &Apache::loncommon::modal_link('http://loncapa.org/core.html',
+ &mt('LON-CAPA core group - MSU'),600,500));
+ $choices{'reportupdates'} = &mt('E-mail record of completed LON-CAPA updates to [_1]',
+ &Apache::loncommon::modal_link('http://loncapa.org/core.html',
+ &mt('LON-CAPA core group - MSU'),600,500));
+ my @toggles = ('reporterrors','reportupdates');
+ my %defaultchecked = ('reporterrors' => 'on',
+ 'reportupdates' => 'on');
+ (my $reports,$rownum) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
+ \%choices,$rownum);
+ $datatable .= $reports;
+ } elsif ($position eq 'bottom') {
+ my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
+ my (@posstypes,%usertypeshash);
+ if (ref($types) eq 'ARRAY') {
+ @posstypes = @{$types};
+ }
+ if (@posstypes) {
+ if (ref($usertypes) eq 'HASH') {
+ %usertypeshash = %{$usertypes};
+ }
+ my @overridden;
+ my $numinrow = 4;
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{'overrides'}) eq 'HASH') {
+ foreach my $key (sort(keys(%{$settings->{'overrides'}}))) {
+ if (ref($settings->{'overrides'}{$key}) eq 'HASH') {
+ push(@overridden,$key);
+ foreach my $item (@contacts) {
+ if ($settings->{'overrides'}{$key}{$item}) {
+ $checked{'override_'.$key}{$item} = ' checked="checked" ';
+ }
+ }
+ $otheremails{'override_'.$key} = $settings->{'overrides'}{$key}{'others'};
+ $bccemails{'override_'.$key} = $settings->{'overrides'}{$key}{'bcc'};
+ $includeloc{'override_'.$key} = '';
+ $includestr{'override_'.$key} = '';
+ if ($settings->{'overrides'}{$key}{'include'} ne '') {
+ ($includeloc{'override_'.$key},$includestr{'override_'.$key}) =
+ split(/:/,$settings->{'overrides'}{$key}{'include'},2);
+ $includestr{'override_'.$key} = &unescape($includestr{'override_'.$key});
+ }
+ }
+ }
+ }
+ }
+ my $customclass = 'LC_helpdesk_override';
+ my $optionsprefix = 'LC_options_helpdesk_';
+
+ my $onclicktypes = "toggleHelpdeskRow(this.form,'overrides','$customclass','$optionsprefix');";
+
+ $datatable .= &insttypes_row($settings,$types,$usertypes,$dom,
+ $numinrow,$othertitle,'overrides',
+ \$rownum,$onclicktypes,$customclass);
+ $rownum ++;
+ $usertypeshash{'default'} = $othertitle;
+ foreach my $status (@posstypes) {
+ my $css_class;
+ if ($rownum%2) {
+ $css_class = 'LC_odd_row ';
+ }
+ $css_class .= $customclass;
+ my $rowid = $optionsprefix.$status;
+ my $hidden = 1;
+ my $currstyle = 'display:none';
+ if (grep(/^\Q$status\E$/,@overridden)) {
+ $currstyle = 'display:table-row';
+ $hidden = 0;
+ }
+ my $key = 'override_'.$status;
+ $datatable .= &overridden_helpdesk($checked{$key},$otheremails{$key},$bccemails{$key},
+ $includeloc{$key},$includestr{$key},$status,$rowid,
+ $usertypeshash{$status},$css_class,$currstyle,
+ \@contacts,$short_titles);
+ unless ($hidden) {
+ $rownum ++;
+ }
+ }
+ }
}
$$rowtotal += $rownum;
return $datatable;
}
+sub overridden_helpdesk {
+ my ($checked,$otheremails,$bccemails,$includeloc,$includestr,$type,$rowid,
+ $typetitle,$css_class,$rowstyle,$contacts,$short_titles) = @_;
+ my $class = 'LC_left_item';
+ if ($css_class) {
+ $css_class = ' class="'.$css_class.'"';
+ }
+ if ($rowid) {
+ $rowid = ' id="'.$rowid.'"';
+ }
+ if ($rowstyle) {
+ $rowstyle = ' style="'.$rowstyle.'"';
+ }
+ my ($output,$description);
+ $description = &mt('Helpdesk requests from: [_1] in this domain (overrides default)',"$typetitle");
+ $output = ''.
+ "$description | \n".
+ ''.
+ ''.
+ ''.
+ ' |
'."\n";
+ return $output;
+}
+
+sub contacts_javascript {
+ return <<"ENDSCRIPT";
+
+
+
+ENDSCRIPT
+}
+
+sub print_helpsettings {
+ my ($position,$dom,$settings,$rowtotal) = @_;
+ my $confname = $dom.'-domainconfig';
+ my $formname = 'display';
+ my ($datatable,$itemcount);
+ if ($position eq 'top') {
+ $itemcount = 1;
+ my (%choices,%defaultchecked,@toggles);
+ $choices{'submitbugs'} = &mt('Display link to: [_1]?',
+ &Apache::loncommon::modal_link('http://bugs.loncapa.org',
+ &mt('LON-CAPA bug tracker'),600,500));
+ %defaultchecked = ('submitbugs' => 'on');
+ @toggles = ('submitbugs');
+ ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
+ \%choices,$itemcount);
+ $$rowtotal ++;
+ } else {
+ my $css_class;
+ my %existing=&Apache::lonnet::dump('roles',$dom,$confname,'rolesdef_');
+ my (%customroles,%ordered,%current);
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{'adhoc'}) eq 'HASH') {
+ %current = %{$settings->{'adhoc'}};
+ }
+ }
+ my $count = 0;
+ foreach my $key (sort(keys(%existing))) {
+ if ($key=~/^rolesdef\_(\w+)$/) {
+ my $rolename = $1;
+ my (%privs,$order);
+ ($privs{'system'},$privs{'domain'},$privs{'course'}) = split(/\_/,$existing{$key});
+ $customroles{$rolename} = \%privs;
+ if (ref($current{$rolename}) eq 'HASH') {
+ $order = $current{$rolename}{'order'};
+ }
+ if ($order eq '') {
+ $order = $count;
+ }
+ $ordered{$order} = $rolename;
+ $count++;
+ }
+ }
+ my $maxnum = scalar(keys(%ordered));
+ my @roles_by_num = ();
+ foreach my $item (sort {$a <=> $b } (keys(%ordered))) {
+ push(@roles_by_num,$item);
+ }
+ my $context = 'domprefs';
+ my $crstype = 'Course';
+ my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
+ my @accesstypes = ('all','dh','da','none');
+ my ($numstatustypes,@jsarray);
+ if (ref($types) eq 'ARRAY') {
+ if (@{$types} > 0) {
+ $numstatustypes = scalar(@{$types});
+ push(@accesstypes,'status');
+ @jsarray = ('bystatus');
+ }
+ }
+ my %domhelpdesk = &Apache::lonnet::get_active_domroles($dom,['dh','da']);
+ if (keys(%domhelpdesk)) {
+ push(@accesstypes,('inc','exc'));
+ push(@jsarray,('notinc','notexc'));
+ }
+ my $hiddenstr = join("','",@jsarray);
+ $datatable .= &helpsettings_javascript(\@roles_by_num,$maxnum,$hiddenstr,$formname);
+ my $context = 'domprefs';
+ my $crstype = 'Course';
+ my $prefix = 'helproles_';
+ my $add_class = 'LC_hidden';
+ foreach my $num (@roles_by_num) {
+ my $role = $ordered{$num};
+ my ($desc,$access,@statuses);
+ if (ref($current{$role}) eq 'HASH') {
+ $desc = $current{$role}{'desc'};
+ $access = $current{$role}{'access'};
+ if (ref($current{$role}{'insttypes'}) eq 'ARRAY') {
+ @statuses = @{$current{$role}{'insttypes'}};
+ }
+ }
+ if ($desc eq '') {
+ $desc = $role;
+ }
+ my $identifier = 'custhelp'.$num;
+ my %full=();
+ my %levels= (
+ course => {},
+ domain => {},
+ system => {},
+ );
+ my %levelscurrent=(
+ course => {},
+ domain => {},
+ system => {},
+ );
+ &Apache::lonuserutils::custom_role_privs($customroles{$role},\%full,\%levels,\%levelscurrent);
+ my @templateroles = &Apache::lonuserutils::custom_template_roles($context,$crstype);
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ my $chgstr = ' onchange="javascript:reorderHelpRoles(this.form,'."'helproles_".$num."_pos'".');"';
+ $datatable .= ''.$role.' '.
+ ''.(' 'x2).
+ ''.
+ ' | '.
+ ''.
+ &helpdeskroles_access($dom,$prefix,$num,$add_class,$current{$role},\@accesstypes,
+ $othertitle,$usertypes,$types,\%domhelpdesk).
+ ' | ';
+ $itemcount ++;
+ }
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ my $newcust = 'custhelp'.$count;
+ my (%privs,%levelscurrent);
+ my %full=();
+ my %levels= (
+ course => {},
+ domain => {},
+ system => {},
+ );
+ &Apache::lonuserutils::custom_role_privs(\%privs,\%full,\%levels,\%levelscurrent);
+ my @templateroles = &Apache::lonuserutils::custom_template_roles($context,$crstype);
+ my $chgstr = ' onchange="javascript:reorderHelpRoles(this.form,'."'helproles_".$count."_pos'".');"';
+ $datatable .= '
| '.
+ ''.
+ &helpdeskroles_access($dom,$prefix,$count,'',undef,\@accesstypes,$othertitle,
+ $usertypes,$types,\%domhelpdesk).
+ ' |
';
+ $count ++;
+ $$rowtotal += $count;
+ }
+ return $datatable;
+}
+
+sub adhocbutton {
+ my ($prefix,$num,$field,$visibility) = @_;
+ my %lt = &Apache::lonlocal::texthash(
+ show => 'Show details',
+ hide => 'Hide details',
+ );
+ return ''.(' 'x10).
+ ''.(' 'x2).''.(' 'x2);
+}
+
+sub helpsettings_javascript {
+ my ($roles_by_num,$total,$hiddenstr,$formname) = @_;
+ return unless(ref($roles_by_num) eq 'ARRAY');
+ my %html_js_lt = &Apache::lonlocal::texthash(
+ show => 'Show details',
+ hide => 'Hide details',
+ );
+ &html_escape(\%html_js_lt);
+ my $jstext = ' var helproles = Array('."'".join("','",@{$roles_by_num})."'".');'."\n";
+ return <<"ENDSCRIPT";
+
+
+ENDSCRIPT
+}
+
+sub helpdeskroles_access {
+ my ($dom,$prefix,$num,$add_class,$current,$accesstypes,$othertitle,
+ $usertypes,$types,$domhelpdesk) = @_;
+ return unless ((ref($accesstypes) eq 'ARRAY') && (ref($domhelpdesk) eq 'HASH'));
+ my %lt = &Apache::lonlocal::texthash(
+ 'rou' => 'Role usage',
+ 'whi' => 'Which helpdesk personnel may use this role?',
+ 'all' => 'All with domain helpdesk or helpdesk assistant role',
+ 'dh' => 'All with domain helpdesk role',
+ 'da' => 'All with domain helpdesk assistant role',
+ 'none' => 'None',
+ 'status' => 'Determined based on institutional status',
+ 'inc' => 'Include all, but exclude specific personnel',
+ 'exc' => 'Exclude all, but include specific personnel',
+ );
+ my %usecheck = (
+ all => ' checked="checked"',
+ );
+ my %displaydiv = (
+ status => 'none',
+ inc => 'none',
+ exc => 'none',
+ priv => 'block',
+ );
+ my $output;
+ if (ref($current) eq 'HASH') {
+ if (($current->{'access'} ne '') && ($current->{'access'} ne 'all')) {
+ if (grep(/^\Q$current->{access}\E$/,@{$accesstypes})) {
+ $usecheck{$current->{access}} = $usecheck{'all'};
+ delete($usecheck{'all'});
+ if ($current->{access} =~ /^(status|inc|exc)$/) {
+ my $access = $1;
+ $displaydiv{$access} = 'inline';
+ } elsif ($current->{access} eq 'none') {
+ $displaydiv{'priv'} = 'none';
+ }
+ }
+ }
+ }
+ $output = '
';
+ }
+ $output .= '';
+ return $output;
+}
+
sub radiobutton_prefs {
- my ($settings,$toggles,$defaultchecked,$choices,$itemcount) = @_;
+ my ($settings,$toggles,$defaultchecked,$choices,$itemcount,$onclick,
+ $additional,$align) = @_;
return unless ((ref($toggles) eq 'ARRAY') && (ref($defaultchecked) eq 'HASH') &&
(ref($choices) eq 'HASH'));
@@ -1866,49 +4124,2439 @@ sub radiobutton_prefs {
}
}
}
+ if ($onclick) {
+ $onclick = ' onclick="'.$onclick.'"';
+ }
foreach my $item (@{$toggles}) {
$css_class = $itemcount%2?' class="LC_odd_row"':'';
$datatable .=
- ''.$choices->{$item}.
- ' | '.
- ''.
+ ''.
+ ''.$choices->{$item}.
+ ' | ';
+ if ($align eq 'left') {
+ $datatable .= '';
+ } else {
+ $datatable .= ' | ';
+ }
+ $datatable .=
+ ''.
' '.
- ' | '.
+ $checkedoff{$item}.' value="0"'.$onclick.' />'.&mt('No').''.
+ ''.$additional.
+ ''.
' ';
$itemcount ++;
}
return ($datatable,$itemcount);
}
-sub print_coursedefaults {
+sub print_ltitools {
my ($dom,$settings,$rowtotal) = @_;
+ my $rownum = 0;
+ my $css_class;
+ my $itemcount = 1;
+ my $maxnum = 0;
+ my %ordered;
+ if (ref($settings) eq 'HASH') {
+ foreach my $item (keys(%{$settings})) {
+ if (ref($settings->{$item}) eq 'HASH') {
+ my $num = $settings->{$item}{'order'};
+ $ordered{$num} = $item;
+ }
+ }
+ }
+ my $confname = $dom.'-domainconfig';
+ my $switchserver = &check_switchserver($dom,$confname);
+ my $maxnum = scalar(keys(%ordered));
+ my $datatable = <itools_javascript($settings);
+ my %lt = <itools_names();
+ my @courseroles = ('cc','in','ta','ep','st');
+ my @ltiroles = qw(Instructor ContentDeveloper TeachingAssistant Learner);
+ my @fields = ('fullname','firstname','lastname','email','roles','user');
+ if (keys(%ordered)) {
+ my @items = sort { $a <=> $b } keys(%ordered);
+ for (my $i=0; $i<@items; $i++) {
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ my $item = $ordered{$items[$i]};
+ my ($title,$key,$secret,$url,$lifetime,$imgsrc,%sigsel);
+ if (ref($settings->{$item}) eq 'HASH') {
+ $title = $settings->{$item}->{'title'};
+ $url = $settings->{$item}->{'url'};
+ $key = $settings->{$item}->{'key'};
+ $secret = $settings->{$item}->{'secret'};
+ $lifetime = $settings->{$item}->{'lifetime'};
+ my $image = $settings->{$item}->{'image'};
+ if ($image ne '') {
+ $imgsrc = '';
+ }
+ if ($settings->{$item}->{'sigmethod'} eq 'HMAC-256') {
+ $sigsel{'HMAC-256'} = ' selected="selected"';
+ } else {
+ $sigsel{'HMAC-SHA1'} = ' selected="selected"';
+ }
+ }
+ my $chgstr = ' onchange="javascript:reorderLTITools(this.form,'."'ltitools_".$item."'".');"';
+ $datatable .= ''
+ .''.(' 'x2).
+ ' | '.
+ ''.
+ ''.
+ '';
+ my (%checkedfields,%rolemaps,$userincdom);
+ if (ref($settings->{$item}) eq 'HASH') {
+ if (ref($settings->{$item}->{'fields'}) eq 'HASH') {
+ %checkedfields = %{$settings->{$item}->{'fields'}};
+ }
+ $userincdom = $settings->{$item}->{'incdom'};
+ if (ref($settings->{$item}->{'roles'}) eq 'HASH') {
+ %rolemaps = %{$settings->{$item}->{'roles'}};
+ $checkedfields{'roles'} = 1;
+ }
+ }
+ $datatable .= ''.
+ '';
+ my %courseconfig;
+ if (ref($settings->{$item}) eq 'HASH') {
+ if (ref($settings->{$item}->{'crsconf'}) eq 'HASH') {
+ %courseconfig = %{$settings->{$item}->{'crsconf'}};
+ }
+ }
+ $datatable .= ''.
+ ' | '."\n";
+ $itemcount ++;
+ }
+ }
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ my $chgstr = ' onchange="javascript:reorderLTITools(this.form,'."'ltitools_add_pos'".');"';
+ $datatable .= ''."\n".
+ ''."\n".
+ ' '."\n".
+ ''.&mt('Add').' | '."\n".
+ ''.
+ ''.
+ ''.
+ '';
+ $datatable .= ''.
+ ''.
+ ' | '."\n".
+ ' | '."\n".
+ '
'."\n";
+ $itemcount ++;
+ return $datatable;
+}
+
+sub ltitools_names {
+ my %lt = &Apache::lonlocal::texthash(
+ 'title' => 'Title',
+ 'version' => 'Version',
+ 'msgtype' => 'Message Type',
+ 'sigmethod' => 'Signature Method',
+ 'url' => 'URL',
+ 'key' => 'Key',
+ 'lifetime' => 'Nonce lifetime (s)',
+ 'secret' => 'Secret',
+ 'icon' => 'Icon',
+ 'user' => 'User',
+ 'fullname' => 'Full Name',
+ 'firstname' => 'First Name',
+ 'lastname' => 'Last Name',
+ 'email' => 'E-mail',
+ 'roles' => 'Role',
+ 'window' => 'Window',
+ 'tab' => 'Tab',
+ 'iframe' => 'iFrame',
+ 'height' => 'Height',
+ 'width' => 'Width',
+ 'linktext' => 'Default Link Text',
+ 'explanation' => 'Default Explanation',
+ 'passback' => 'Tool can return grades:',
+ 'roster' => 'Tool can retrieve roster:',
+ 'crstarget' => 'Display target',
+ 'crslabel' => 'Course label',
+ 'crstitle' => 'Course title',
+ 'crslinktext' => 'Link Text',
+ 'crsexplanation' => 'Explanation',
+ 'crsappend' => 'Provider URL',
+ );
+ return %lt;
+}
+
+sub print_lti {
+ my ($dom,$settings,$rowtotal) = @_;
+ my $itemcount = 1;
+ my $maxnum = 0;
+ my $css_class;
+ my %ordered;
+ if (ref($settings) eq 'HASH') {
+ foreach my $item (keys(%{$settings})) {
+ if (ref($settings->{$item}) eq 'HASH') {
+ my $num = $settings->{$item}{'order'};
+ $ordered{$num} = $item;
+ }
+ }
+ }
+ my $maxnum = scalar(keys(%ordered));
+ my $datatable = <i_javascript($settings);
+ my %lt = <i_names();
+ if (keys(%ordered)) {
+ my @items = sort { $a <=> $b } keys(%ordered);
+ for (my $i=0; $i<@items; $i++) {
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ my $item = $ordered{$items[$i]};
+ my ($key,$secret,$lifetime,$consumer,$current);
+ if (ref($settings->{$item}) eq 'HASH') {
+ $key = $settings->{$item}->{'key'};
+ $secret = $settings->{$item}->{'secret'};
+ $lifetime = $settings->{$item}->{'lifetime'};
+ $consumer = $settings->{$item}->{'consumer'};
+ $current = $settings->{$item};
+ }
+ my $chgstr = ' onchange="javascript:reorderLTI(this.form,'."'lti_pos_".$item."'".');"';
+ $datatable .= ''
+ .''.(' 'x2).
+ ' | '.
+ ''.
+ ''.<i_options($i,$current,$itemcount,%lt).' |
';
+ $itemcount ++;
+ }
+ }
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ my $chgstr = ' onchange="javascript:reorderLTI(this.form,'."'lti_pos_add'".');"';
+ $datatable .= ''."\n".
+ ''."\n".
+ ' '."\n".
+ ''.&mt('Add').' | '."\n".
+ ''.
+ ''.<i_options('add',undef,$itemcount,%lt).
+ ' | '."\n".
+ '
'."\n";
+ $$rowtotal ++;
+ return $datatable;;
+}
+
+sub lti_names {
+ my %lt = &Apache::lonlocal::texthash(
+ 'version' => 'LTI Version',
+ 'url' => 'URL',
+ 'key' => 'Key',
+ 'lifetime' => 'Nonce lifetime (s)',
+ 'consumer' => 'LTI Consumer',
+ 'secret' => 'Secret',
+ 'email' => 'Email address',
+ 'sourcedid' => 'User ID',
+ 'other' => 'Other',
+ 'passback' => 'Can return grades to Consumer:',
+ 'roster' => 'Can retrieve roster from Consumer:',
+ 'topmenu' => 'Display LON-CAPA page header',
+ 'inlinemenu'=> 'Display LON-CAPA inline menu',
+ );
+ return %lt;
+}
+
+sub lti_options {
+ my ($num,$current,$itemcount,%lt) = @_;
+ my (%checked,%rolemaps,$crssecsrc,$userfield,$cidfield);
+ $checked{'mapuser'}{'sourcedid'} = ' checked="checked"';
+ $checked{'mapcrs'}{'course_offering_sourcedid'} = ' checked="checked"';
+ $checked{'makecrs'}{'N'} = ' checked="checked"';
+ $checked{'mapcrstype'} = {};
+ $checked{'makeuser'} = {};
+ $checked{'selfenroll'} = {};
+ $checked{'crssec'} = {};
+ $checked{'crssecsrc'} = {};
+ $checked{'lcauth'} = {};
+ $checked{'menuitem'} = {};
+ if ($num eq 'add') {
+ $checked{'lcauth'}{'lti'} = ' checked="checked"';
+ }
+ my $userfieldsty = 'none';
+ my $crsfieldsty = 'none';
+ my $crssecfieldsty = 'none';
+ my $secsrcfieldsty = 'none';
+ my $lcauthparm;
+ my $lcauthparmstyle = 'display:none';
+ my $lcauthparmtext;
+ my $menusty;
+ my $numinrow = 4;
+ my %menutitles = <imenu_titles();
+
+ if (ref($current) eq 'HASH') {
+ if (($current->{'mapuser'} ne '') && ($current->{'mapuser'} ne 'lis_person_sourcedid')) {
+ $checked{'mapuser'}{'sourcedid'} = '';
+ if ($current->{'mapuser'} eq 'lis_person_contact_email_primary') {
+ $checked{'mapuser'}{'email'} = ' checked="checked"';
+ } else {
+ $checked{'mapuser'}{'other'} = ' checked="checked"';
+ $userfield = $current->{'mapuser'};
+ $userfieldsty = 'inline-block';
+ }
+ }
+ if (($current->{'mapcrs'} ne '') && ($current->{'mapcrs'} ne 'course_offering_sourcedid')) {
+ $checked{'mapcrs'}{'course_offering_sourcedid'} = '';
+ if ($current->{'mapcrs'} eq 'context_id') {
+ $checked{'mapcrs'}{'context_id'} = ' checked="checked"';
+ } else {
+ $checked{'mapcrs'}{'other'} = ' checked="checked"';
+ $cidfield = $current->{'mapcrs'};
+ $crsfieldsty = 'inline-block';
+ }
+ }
+ if (ref($current->{'mapcrstype'}) eq 'ARRAY') {
+ foreach my $type (@{$current->{'mapcrstype'}}) {
+ $checked{'mapcrstype'}{$type} = ' checked="checked"';
+ }
+ }
+ if ($current->{'makecrs'}) {
+ $checked{'makecrs'}{'Y'} = ' checked="checked"';
+ }
+ if (ref($current->{'makeuser'}) eq 'ARRAY') {
+ foreach my $role (@{$current->{'makeuser'}}) {
+ $checked{'makeuser'}{$role} = ' checked="checked"';
+ }
+ }
+ if ($current->{'lcauth'} =~ /^(internal|localauth|krb4|krb5|lti)$/) {
+ $checked{'lcauth'}{$1} = ' checked="checked"';
+ unless (($current->{'lcauth'} eq 'lti') || ($current->{'lcauth'} eq 'internal')) {
+ $lcauthparm = $current->{'lcauthparm'};
+ $lcauthparmstyle = 'display:table-row';
+ if ($current->{'lcauth'} eq 'localauth') {
+ $lcauthparmtext = &mt('Local auth argument');
+ } else {
+ $lcauthparmtext = &mt('Kerberos domain');
+ }
+ }
+ }
+ if (ref($current->{'selfenroll'}) eq 'ARRAY') {
+ foreach my $role (@{$current->{'selfenroll'}}) {
+ $checked{'selfenroll'}{$role} = ' checked="checked"';
+ }
+ }
+ if (ref($current->{'maproles'}) eq 'HASH') {
+ %rolemaps = %{$current->{'maproles'}};
+ }
+ if ($current->{'section'} ne '') {
+ $checked{'crssec'}{'Y'} = ' checked="checked"';
+ $crssecfieldsty = 'inline-block';
+ if ($current->{'section'} eq 'course_section_sourcedid') {
+ $checked{'crssecsrc'}{'sourcedid'} = ' checked="checked"';
+ } else {
+ $checked{'crssecsrc'}{'other'} = ' checked="checked"';
+ $crssecsrc = $current->{'section'};
+ $secsrcfieldsty = 'inline-block';
+ }
+ } else {
+ $checked{'crssec'}{'N'} = ' checked="checked"';
+ }
+ if ($current->{'topmenu'}) {
+ $checked{'topmenu'}{'Y'} = ' checked="checked"';
+ } else {
+ $checked{'topmenu'}{'N'} = ' checked="checked"';
+ }
+ if ($current->{'inlinemenu'}) {
+ $checked{'inlinemenu'}{'Y'} = ' checked="checked"';
+ } else {
+ $checked{'inlinemenu'}{'N'} = ' checked="checked"';
+ }
+ if (($current->{'topmenu'}) || ($current->{'inlinemenu'})) {
+ $menusty = 'inline-block';
+ if (ref($current->{'lcmenu'}) eq 'ARRAY') {
+ foreach my $item (@{$current->{'lcmenu'}}) {
+ if (exists($menutitles{$item})) {
+ $checked{'menuitem'}{$item} = ' checked="checked"';
+ }
+ }
+ }
+ } else {
+ $menusty = 'none';
+ }
+ } else {
+ $checked{'makecrs'}{'N'} = ' checked="checked"';
+ $checked{'crssec'}{'N'} = ' checked="checked"';
+ $checked{'topmenu'}{'N'} = ' checked="checked"';
+ $checked{'inlinemenu'}{'Y'} = ' checked="checked"';
+ $checked{'menuitem'}{'grades'} = ' checked="checked"';
+ $menusty = 'inline-block';
+ }
+ my @coursetypes = ('official','unofficial','community','textbook','placement','lti');
+ my %coursetypetitles = &Apache::lonlocal::texthash (
+ official => 'Official',
+ unofficial => 'Unofficial',
+ community => 'Community',
+ textbook => 'Textbook',
+ placement => 'Placement Test',
+ lti => 'LTI Provider',
+ );
+ my @authtypes = ('internal','krb4','krb5','localauth');
+ my %shortauth = (
+ internal => 'int',
+ krb4 => 'krb4',
+ krb5 => 'krb5',
+ localauth => 'loc'
+ );
+ my %authnames = &authtype_names();
+ my @ltiroles = qw(Learner Instructor ContentDeveloper TeachingAssistant Mentor Member Manager Administrator);
+ my @lticourseroles = qw(Learner Instructor TeachingAssistant Mentor);
+ my @courseroles = ('cc','in','ta','ep','st');
+ my $onclickuser = ' onclick="toggleLTI(this.form,'."'user','$num'".');"';
+ my $onclickcrs = ' onclick="toggleLTI(this.form,'."'crs','$num'".');"';
+ my $onclicksec = ' onclick="toggleLTI(this.form,'."'sec','$num'".');"';
+ my $onclicksecsrc = ' onclick="toggleLTI(this.form,'."'secsrc','$num'".')"';
+ my $onclicklcauth = ' onclick="toggleLTI(this.form,'."'lcauth','$num'".')"';
+ my $onclickmenu = ' onclick="toggleLTI(this.form,'."'lcmenu','$num'".');"';
+ my $output = ''.
+ ''.
+ ''.
+ ''.
+ ''.
+ ''.
+ ''.
+ ''.
+ '