File:
[LON-CAPA] /
loncom /
interface /
coursecatalog.pm
Revision
1.63:
download - view:
text,
annotated -
select for diffs
Thu Jul 8 23:19:19 2010 UTC (14 years, 1 month ago) by
raeburn
Branches:
MAIN
CVS tags:
HEAD
- Bug 6333.
Ensure that form element names for select boxes for institutional codes
are always named Year, Semester, Department, Number, for consistency with
names used in javascript to update select box items dynamically.
- Names of categories in domain from localenroll::instcode_format():
codetitles array can differ from these form element names.
1: # The LearningOnline Network with CAPA
2: # Handler for displaying the course catalog interface
3: #
4: # $Id: coursecatalog.pm,v 1.63 2010/07/08 23:19:19 raeburn Exp $
5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28:
29: package Apache::coursecatalog;
30:
31: use strict;
32: use lib qw(/home/httpd/lib/perl);
33: use Apache::Constants qw(:common);
34: use Apache::loncommon;
35: use Apache::lonhtmlcommon;
36: use Apache::lonnet;
37: use Apache::lonlocal;
38: use Apache::courseclassifier;
39: use Apache::lonacc;
40: use LONCAPA;
41:
42: sub handler {
43: my ($r) = @_;
44: &Apache::loncommon::content_type($r,'text/html');
45: $r->send_http_header;
46: if ($r->header_only) {
47: return OK;
48: }
49: my $handle = &Apache::lonnet::check_for_valid_session($r);
50: my $lonidsdir=$r->dir_config('lonIDsDir');
51: if ($handle ne '') {
52: &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);
53: }
54: &Apache::lonacc::get_posted_cgi($r);
55: &Apache::lonlocal::get_language_handle($r);
56: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
57: ['sortby','showdom']);
58:
59: my $codedom = &Apache::lonnet::default_login_domain();
60:
61: if (($env{'user.domain'} ne '') && ($env{'user.domain'} ne 'public')) {
62: $codedom = $env{'user.domain'};
63: if ($env{'request.role.domain'} ne '') {
64: $codedom = $env{'request.role.domain'};
65: }
66: }
67: my $formname = 'coursecatalog';
68: if ($env{'form.showdom'} ne '') {
69: if (&Apache::lonnet::domain($env{'form.showdom'}) ne '') {
70: $codedom = $env{'form.showdom'};
71: }
72: }
73: my $domdesc = &Apache::lonnet::domain($codedom,'description');
74: &Apache::lonhtmlcommon::clear_breadcrumbs();
75:
76: my %domconfig =
77: &Apache::lonnet::get_dom('configuration',['coursecategories'],$codedom);
78: my (@cats,@trails,%allitems,%idx,@jsarray,%subcathash,$cathash);
79: if (ref($domconfig{'coursecategories'}) eq 'HASH') {
80: $cathash = $domconfig{'coursecategories'}{'cats'};
81: } else {
82: $cathash = {};
83: }
84: my $subcats;
85: if ($env{'form.withsubcats'}) {
86: $subcats = \%subcathash;
87: }
88: &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,\%allitems,
89: \%idx,\@jsarray,$subcats);
90: my ($numtitles,@codetitles);
91: if ($env{'form.coursenum'} ne '' && &user_is_known()) {
92: if ($env{'form.currcat_0'} eq 'instcode::0') {
93: $numtitles = &instcode_course_selector($r,$codedom,$formname,$domdesc,
94: undef,undef,\@codetitles);
95: }
96: &course_details($r,$codedom,$formname,$domdesc,\@trails,\%allitems,\@codetitles);
97: } else {
98: my ($catlinks,$has_subcats,$selitem) = &category_breadcrumbs($codedom,@cats);
99: my $catjs = <<"ENDSCRIPT";
100:
101: function setCatDepth(depth) {
102: document.coursecats.catalog_maxdepth.value = depth;
103: if (depth == '') {
104: document.coursecats.currcat_0.value = '';
105: }
106: document.coursecats.submit();
107: return;
108: }
109:
110: function changeSort(caller) {
111: document.$formname.sortby.value = caller;
112: document.$formname.submit();
113: }
114:
115: function setCourseId(caller) {
116: document.$formname.coursenum.value = caller;
117: document.$formname.submit();
118: }
119:
120: ENDSCRIPT
121: $catjs .= &courselink_javascript();
122: if ($env{'form.currcat_0'} eq 'instcode::0') {
123: $numtitles = &instcode_course_selector($r,$codedom,$formname,$domdesc,
124: $catlinks,$catjs,\@codetitles);
125: if ($env{'form.state'} eq 'listing') {
126: $r->print(&print_course_listing($codedom,$numtitles,undef,undef,undef,
127: \@codetitles));
128: }
129: } else {
130: my (%add_entries);
131: my ($currdepth,$deeper) = &get_depth_values();
132: if ($selitem) {
133: my $alert = &mt('Choose a subcategory to display');
134: if (!$deeper) {
135: $alert = &mt('Choose a category to display');
136: }
137: $catjs .= <<ENDJS;
138: function check_selected() {
139: if (document.coursecats.$selitem.options[document.coursecats.$selitem.selectedIndex].value == "") {
140: alert('$alert');
141: return false;
142: }
143: }
144: ENDJS
145: }
146: $catjs = '<script type="text/javascript">'."\n".$catjs."\n".'</script>';
147: &cat_header($r,$codedom,$catjs,\%add_entries,$catlinks);
148: if ($env{'form.currcat_0'} ne '') {
149: $r->print('<form name="'.$formname.
150: '" method="post" action="/adm/coursecatalog">'.
151: &additional_filters($codedom,$has_subcats)."\n");
152: $r->print('<input type="hidden" name="catalog_maxdepth" value="'.
153: $deeper.'" />'."\n");
154: for (my $i=0; $i<$deeper; $i++) {
155: $r->print('<input type="hidden" name="currcat_'.$i.'" value="'.$env{'form.currcat_'.$i}.'" />'."\n");
156: }
157: my $display_button;
158: if ($env{'form.currcat_0'} eq 'communities::0') {
159: $display_button = &mt('Display communities');
160: } else {
161: $display_button = &mt('Display courses');
162: }
163: $r->print('<input type="hidden" name="coursenum" value="" />'."\n".
164: '<input type="hidden" name="sortby" value="" />'."\n".
165: '<input type="hidden" name="state" value="listing" />'."\n".
166: '<input type="hidden" name="showdom" value="'.
167: $env{'form.showdom'}.'" />'.
168: '<input type="submit" name="catalogfilter" value="'.
169: $display_button.'" /></form><br /><br />');
170: }
171: if ($env{'form.state'} eq 'listing') {
172: $r->print(&print_course_listing($codedom,undef,\@trails,\%allitems,$subcats,\@codetitles));
173: }
174: }
175: }
176: $r->print('<br />'.&Apache::loncommon::end_page());
177: return OK;
178: }
179:
180: sub course_details {
181: my ($r,$codedom,$formname,$domdesc,$trails,$allitems,$codetitles) = @_;
182: my $output;
183: my %add_entries = (topmargin => "0",
184: marginheight => "0",);
185: my $js = '<script type="text/javascript">'."\n".
186: &courselink_javascript().'</script>'."\n";
187: my $start_page =
188: &Apache::loncommon::start_page('Course/Community Catalog',$js,
189: {'add_entries' => \%add_entries, });
190: $r->print($start_page);
191: if ($env{'form.numtitles'} > 0) {
192: &Apache::lonhtmlcommon::add_breadcrumb
193: ({href=>"/adm/coursecatalog",
194: text=>"Course/Community Catalog"});
195: }
196: my $brtextone = 'Course listing';
197: my $brtexttwo = 'Course details';
198: if ($env{'form.currcat_0'} eq 'communities::0') {
199: $brtextone = 'Community listing';
200: $brtexttwo = 'Community details';
201: }
202: &Apache::lonhtmlcommon::add_breadcrumb
203: ({href=>"javascript:document.$formname.submit()",
204: text=>$brtextone},
205: {text=>$brtexttwo});
206: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course/Community Catalog'));
207: $r->print('<br />');
208: if ($env{'form.currcat_0'} eq 'communities::0') {
209: $r->print(&mt('Detailed community information:'));
210: } else {
211: $r->print(&mt('Detailed course information:'));
212: }
213: $r->print('<br /><br />'.
214: &print_course_listing($codedom,undef,$trails,$allitems,undef,$codetitles).
215: '<br /><br />');
216: $r->print('<form name="'.$formname.'" method="post" action="/adm/coursecatalog">'.
217: '<a href = "javascript:document.coursecatalog.submit()">');
218: if ($env{'form.currcat_0'} eq 'communities::0') {
219: $r->print(&mt('Back to community listing'));
220: } else {
221: $r->print(&mt('Back to course listing'));
222: }
223: $r->print('</a>'.
224: &Apache::lonhtmlcommon::echo_form_input(['coursenum','catalogfilter',
225: 'showdetails','courseid']).'</form>');
226: return;
227: }
228:
229: sub courselink_javascript {
230: return <<"END";
231:
232: function ToSyllabus(cdom,cnum) {
233: if (cdom == '' || cdom == null) {
234: return;
235: }
236: if (cnum == '' || cnum == null) {
237: return;
238: }
239: document.linklaunch.action = "/public/"+cdom+"/"+cnum+"/syllabus";
240: document.linklaunch.submit();
241: }
242:
243: function ToSelfenroll(courseid) {
244: if (courseid == '') {
245: return;
246: }
247: document.linklaunch.action = "/adm/selfenroll";
248: document.linklaunch.courseid.value = courseid;
249: document.linklaunch.submit();
250: }
251:
252: END
253: }
254:
255: sub instcode_course_selector {
256: my ($r,$codedom,$formname,$domdesc,$catlinks,$catjs,$codetitles) = @_;
257: my %coursecodes = ();
258: my %codes = ();
259: my %cat_titles = ();
260: my %cat_order = ();
261: my %cat_items;
262: my $caller = 'global';
263: my $format_reply;
264: my %add_entries = (topmargin => "0",
265: marginheight => "0",);
266: my ($jscript,$totcodes,$numtitles,$lasttitle) =
267: &Apache::courseclassifier::instcode_selectors_data($codedom,$formname,
268: \%cat_items,$codetitles,\%cat_titles,\%cat_order);
269: my $js = '<script type"text/javascript">'."\n$jscript\n$catjs\n".
270: '</script>';
271: if ($totcodes) {
272: if (($env{'form.state'} eq 'listing') && ($numtitles > 0)) {
273: $add_entries{'onLoad'} = 'setElements()';
274: }
275: &cat_header($r,$codedom,$js,\%add_entries,$catlinks,$numtitles);
276: my $cat_maxdepth = $env{'form.catalog_maxdepth'};
277: $r->print('<form name="'.$formname.'" method="post" action="/adm/coursecatalog">'.
278: '<input type="hidden" name="catalog_maxdepth" value="'.$cat_maxdepth.'" />'."\n".
279: '<input type="hidden" name="showdom" value="'.$env{'form.showdom'}.'" />'."\n".
280: '<input type="hidden" name="currcat_0" value="instcode::0" />'.
281: &additional_filters($codedom));
282: if ($numtitles > 0) {
283: $r->print('<b>'.&mt('Choose which course(s) to list.').'</b><br />'.
284: &Apache::courseclassifier::build_instcode_selectors($numtitles,
285: $lasttitle,\%cat_items,$codetitles,\%cat_titles,\%cat_order));
286: }
287: $r->print('<input type="hidden" name="coursenum" value="" />'."\n".
288: '<input type="hidden" name="sortby" value="" />'."\n".
289: '<input type="hidden" name="state" value="listing" />'."\n".
290: '<input type="hidden" name="form.currcat_0" value="instcode::0" />'."\n".
291: '<input type="submit" name="catalogfilter" value="'.
292: &mt('Display courses').'" />'.
293: '<input type="hidden" name="numtitles" value="'.$numtitles.
294: '" /></form><br /><br />');
295: } else {
296: $js = '<script type"text/javascript">'."\n$catjs\n".'</script>';
297: &cat_header($r,$codedom,$js,\%add_entries,$catlinks,$numtitles);
298: my $cat_maxdepth = $env{'form.catalog_maxdepth'};
299: $r->print('<form name="'.$formname.'" method="post" action="/adm/coursecatalog">'.
300: '<input type="hidden" name="catalog_maxdepth" value="'.$cat_maxdepth.'" />'.
301: '<input type="hidden" name="showdom" value="'.$env{'form.showdom'}.'" />'.
302: '<input type="hidden" name="currcat_0" value="instcode::0" />');
303: $r->print('<br />'.&mt('No official courses to display for [_1].',$domdesc).'</form>');
304: }
305: return $numtitles;
306: }
307:
308: sub cat_header {
309: my ($r,$codedom,$js,$add_entries,$catlinks,$numtitles) = @_;
310: my $start_page =
311: &Apache::loncommon::start_page('Other',$js,
312: { 'add_entries' => $add_entries, });
313: $r->print($start_page);
314: my $brtext = 'Course listing';
315: if ($env{'form.currcat_0'} eq 'communities::0') {
316: $brtext = 'Community listing';
317: }
318: if ($env{'form.state'} eq 'listing') {
319: if ($numtitles > 0) {
320: &Apache::lonhtmlcommon::add_breadcrumb
321: ({href=>"/adm/coursecatalog",
322: text=>"Course/Community Catalog"},
323: {text=>$brtext});
324: } else {
325: &Apache::lonhtmlcommon::add_breadcrumb
326: ({text=>$brtext});
327: }
328: } else {
329: &Apache::lonhtmlcommon::add_breadcrumb
330: ({href=>"/adm/coursecatalog",
331: text=>"Course/Community Catalog"});
332: }
333: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course/Community Catalog'));
334: my $onchange = 'this.form.submit()';
335: $r->print('<form name="coursecatdom" method="post" action="/adm/coursecatalog">'.
336: '<table border="0"><tr><td><b>'.&mt('Domain:').'</b></td><td>'.
337: &Apache::loncommon::select_dom_form($codedom,'showdom','',1,$onchange));
338: if (!$onchange) {
339: $r->print(' <input type="submit" name="godom" value="'.&mt('Change').'" />');
340: }
341: $r->print('</td></tr></table></form>'.
342: '<form name="coursecats" method="post" action="/adm/coursecatalog"'.
343: ' onsubmit="return check_selected();">'.
344: '<table border="0"><tr>'.$catlinks.'</tr></table></form>');
345: return;
346: }
347:
348: sub category_breadcrumbs {
349: my ($dom,@cats) = @_;
350: my $crumbsymbol = ' ▶ ';
351: my ($currdepth,$deeper) = &get_depth_values();
352: my $currcat_str =
353: '<input type="hidden" name="catalog_maxdepth" value="'.$deeper.'" />'.
354: '<input type="hidden" name="showdom" value="'.$dom.'" />';
355: my $catlinks = '<td valign="top"><b>'.&mt('Catalog:').'</b></td><td><table><tr><td>';
356: my $has_subcats;
357: my $selitem;
358: if (ref($cats[0]) eq 'ARRAY') {
359: if (@{$cats[0]} == 0) {
360: $catlinks .= &mt('No categories defined in this domain');
361: } elsif (@{$cats[0]} == 1) {
362: if ($cats[0][0] eq 'instcode') {
363: $catlinks .= &mt('Official courses (with institutional codes)');
364: $env{'form.currcat_0'} = 'instcode::0';
365: } elsif ($cats[0][0] eq 'communities') {
366: $catlinks .= &mt('Communities');
367: $env{'form.currcat_0'} = 'communities::0';
368: } else {
369: my $name = $cats[0][0];
370: my $item = &escape($name).'::0';
371: $catlinks .= $name;
372: $env{'form.currcat_0'} = $item;
373: }
374: $currcat_str .= '<input type="hidden" name="currcat_0" value="'.$env{'form.currcat_0'}.'" />';
375: } else {
376: $catlinks .= &main_category_selector(@cats);
377: if (($env{'form.currcat_0'} ne '') &&
378: ($env{'form.currcat_0'} ne 'instcode::0')) {
379: $catlinks .= $crumbsymbol;
380: } else {
381: $catlinks .= '</td>';
382: }
383: }
384: } else {
385: $catlinks .= &mt('Official courses (with institutional codes)');
386: $env{'form.currcat_0'} = 'instcode::0';
387: $currcat_str .= '<input type="hidden" name="currcat_0" value="'.$env{'form.currcat_0'}.'" />';
388: }
389: if ($deeper) {
390: for (my $i=1; $i<=$deeper; $i++) {
391: my $shallower = $i-1;
392: next if ($shallower == 0);
393: my ($cat,$container,$depth) = map { &unescape($_); } split(/:/,$env{'form.currcat_'.$shallower});
394: if ($cat ne '') {
395: $catlinks .= '<td valign="top">'.
396: '<select name="currcat_'.$shallower.'" onchange="'.
397: 'setCatDepth('."'$shallower'".');this.form.submit();">';
398: if (ref($cats[$shallower]{$container}) eq 'ARRAY') {
399: $catlinks .= '<option value="">'.&mt('De-select').'</option>';
400: for (my $j=0; $j<@{$cats[$shallower]{$container}}; $j++) {
401: my $name = $cats[$shallower]{$container}[$j];
402: my $item = &escape($name).':'.$container.':'.$shallower;
403: my $selected = '';
404: if ($item eq $env{'form.currcat_'.$shallower}) {
405: $selected = ' selected="selected"';
406: }
407: $catlinks .=
408: '<option value="'.$item.'"'.$selected.'>'.$name.'</option>';
409: }
410: }
411: $catlinks .= '</select>';
412: }
413: unless ($i == $deeper) {
414: $catlinks .= $crumbsymbol;
415: }
416: }
417: my ($cat,$container,$depth);
418: if ($env{'form.currcat_'.$currdepth} eq '') {
419: my $shallower = $currdepth - 1;
420: ($cat,$container,$depth) = map { &unescape($_); } split(/:/,$env{'form.currcat_'.$shallower});
421: } else {
422: ($cat,$container,$depth) = map { &unescape($_); } split(/:/,$env{'form.currcat_'.$currdepth});
423: }
424: my $deeperlevel = $depth +1;
425: if (ref($cats[$deeperlevel]{$cat}) eq 'ARRAY') {
426: $has_subcats = 1;
427: my $buttontext = &mt('Show subcategories');
428: my $selitem = 'currcat_'.$deeperlevel;
429: $catlinks .= ' <select name="'.$selitem.'" onchange="this.form.submit()">';
430: if (@{$cats[$deeperlevel]{$cat}}) {
431: $catlinks .= '<option value="" selected="selected">'.
432: &mt('Subcategory ...').'</option>';
433: }
434: for (my $k=0; $k<@{$cats[$deeperlevel]{$cat}}; $k++) {
435: my $name = $cats[$deeperlevel]{$cat}[$k];
436: my $item = &escape($name).':'.&escape($cat).':'.$deeperlevel;
437: $catlinks .= '<option value="'.$item.'">'.$name.'</option>'."\n";
438: }
439: $catlinks .= '</select>'."\n";
440: } elsif ($cat ne 'instcode') {
441: $catlinks .= ' '.&mt('(No subcategories)');
442: }
443: } else {
444: $selitem = 'currcat_0';
445: }
446: $catlinks .= $currcat_str.'</td></tr></table></td>';
447: return ($catlinks,$has_subcats,$selitem);
448: }
449:
450: sub main_category_selector {
451: my (@cats) = @_;
452: my $maincatlinks = '<select name="currcat_0" onchange="setCatDepth('."'0'".');this.form.submit();">'."\n";
453: if (ref($cats[0]) eq 'ARRAY') {
454: if (@{$cats[0]} > 1) {
455: my $selected = '';
456: if ($env{'form.currcat_0'} eq '') {
457: $selected = ' selected="selected"';
458: }
459: $maincatlinks .=
460: '<option value=""'.$selected.'>'.&mt('Select').'</option>'."\n";
461: }
462: for (my $i=0; $i<@{$cats[0]}; $i++) {
463: my $name = $cats[0][$i];
464: my $item = &escape($name).'::0';
465: my $selected;
466: if ($env{'form.currcat_0'} eq $item) {
467: $selected = ' selected="selected"';
468: }
469: $maincatlinks .= '<option value="'.$item.'"'.$selected.'>';
470: if ($name eq 'instcode') {
471: $maincatlinks .= &mt('Official courses (with institutional codes)');
472: } elsif ($name eq 'communities') {
473: $maincatlinks .= &mt('Communities');
474: } else {
475: $maincatlinks .= $name;
476: }
477: $maincatlinks .= '</option>'."\n";
478: }
479: $maincatlinks .= '</select>'."\n";
480: }
481: return $maincatlinks;
482: }
483:
484: sub get_depth_values {
485: my $currdepth = 0;
486: my $deeper = 0;
487: if ($env{'form.catalog_maxdepth'} ne '') {
488: $currdepth = $env{'form.catalog_maxdepth'};
489: if ($env{'form.currcat_'.$currdepth} eq '') {
490: $deeper = $currdepth;
491: } else {
492: $deeper = $currdepth + 1;
493: }
494: }
495: return ($currdepth,$deeper);
496: }
497:
498: sub additional_filters {
499: my ($codedom,$has_subcats) = @_;
500: my $output = '<table>';
501: if (($env{'form.currcat_0'} ne 'instcode::0') &&
502: ($env{'form.currcat_0'} ne '') && ($has_subcats)) {
503: my $include_subcat_status;
504: if ($env{'form.withsubcats'}) {
505: $include_subcat_status = 'checked="checked" ';
506: }
507: my $counter = $env{'form.catalog_maxdepth'};
508: if ($counter > 0) {
509: if ($env{'form.state'} eq 'listing') {
510: $counter --;
511: } elsif ($env{'form.currcat_'.$counter} eq '') {
512: $counter --;
513: }
514: }
515: my ($catname) = split(/:/,$env{'form.currcat_'.$counter});
516: if ($catname ne '') {
517: $output .= '<tr><td><label>'.
518: '<input type="checkbox" name="withsubcats" value="1" '.
519: $include_subcat_status.'/>'.
520: &mt('Include subcategories within "[_1]"',
521: &unescape($catname)).'</label></td></tr>';
522: }
523: }
524: my $show_selfenroll_status;
525: if ($env{'form.showselfenroll'}) {
526: $show_selfenroll_status = 'checked="checked" ';
527: }
528: my $selfenroll_text;
529: if ($env{'form.currcat_0'} eq 'communities::0') {
530: $selfenroll_text = &mt('Only show communities which allow self-enrollment');
531: } else {
532: $selfenroll_text = &mt('Only show courses which allow self-enrollment');
533: }
534: $output .= '<tr><td>'.
535: '<label><input type="checkbox" name="showselfenroll" value="1" '.
536: $show_selfenroll_status.'/>'.$selfenroll_text.
537: '</label></td></tr>';
538: if (&user_is_dc($codedom)) {
539: my $showdetails_status;
540: if ($env{'form.showdetails'}) {
541: $showdetails_status = 'checked="checked" ';
542: }
543: my $showhidden_status;
544: if ($env{'form.showhidden'}) {
545: $showhidden_status = 'checked="checked" ';
546: }
547: my $dc_title = &Apache::lonnet::plaintext('dc');
548: my ($details_text,$hidden_text);
549: if ($env{'form.currcat_0'} eq 'communities::0') {
550: $details_text = &mt('Show full details for each community ([_1] only)',$dc_title);
551: $hidden_text = &mt('Include communities set to be hidden from catalog ([_1] only)',$dc_title);
552: } else {
553: $details_text = &mt('Show full details for each course ([_1] only)',$dc_title);
554: $hidden_text = &mt('Include courses set to be hidden from catalog ([_1] only)',$dc_title);
555: }
556: $output .= '<tr><td>'."\n".
557: '<label><input type="checkbox" name="showdetails" value="1" '.
558: $showdetails_status.'/>'.$details_text.
559: '</label>'."\n".'</td></tr><tr><td>'.
560: '<label><input type="checkbox" name="showhidden" value="1" '.
561: $showhidden_status.'/>'.$hidden_text.
562: '</label>'."\n".'</td></tr>';
563: }
564: $output .= '</table><br />';
565: return $output;
566: }
567:
568: sub user_is_dc {
569: my ($codedom) = @_;
570: if (exists($env{'user.role.dc./'.$codedom.'/'})) {
571: my $livedc = 1;
572: my $now = time;
573: my ($start,$end)=split(/\./,$env{'user.role.dc./'.$codedom.'/'});
574: if ($start && $start>$now) { $livedc = 0; }
575: if ($end && $end <$now) { $livedc = 0; }
576: return $livedc;
577: }
578: return;
579: }
580:
581: sub search_official_courselist {
582: my ($domain,$numtitles,$codetitles) = @_;
583: my $instcode = &Apache::courseclassifier::instcode_search_str($domain,$numtitles,$codetitles);
584: my $showhidden;
585: if (&user_is_dc($domain)) {
586: $showhidden = $env{'form.showhidden'};
587: }
588: my %courses =
589: &Apache::lonnet::courseiddump($domain,'.',1,$instcode,'.','.',undef,undef,
590: 'Course',1,$env{'form.showselfenroll'},undef,
591: $showhidden,'coursecatalog');
592: return %courses;
593: }
594:
595: sub search_courselist {
596: my ($domain,$subcats) = @_;
597: my $cat_maxdepth = $env{'form.catalog_maxdepth'};
598: my $filter = $env{'form.currcat_'.$cat_maxdepth};
599: if (($filter eq '') && ($cat_maxdepth > 0)) {
600: my $shallower = $cat_maxdepth - 1;
601: $filter = $env{'form.currcat_'.$shallower};
602: }
603: my %courses;
604: my $filterstr;
605: if ($filter ne '') {
606: if ($env{'form.withsubcats'}) {
607: if (ref($subcats) eq 'HASH') {
608: if (ref($subcats->{$filter}) eq 'ARRAY') {
609: $filterstr = join('&',@{$subcats->{$filter}});
610: if ($filterstr ne '') {
611: $filterstr = $filter.'&'.$filterstr;
612: }
613: } else {
614: $filterstr = $filter;
615: }
616: } else {
617: $filterstr = $filter;
618: }
619: } else {
620: $filterstr = $filter;
621: }
622: my ($showhidden,$typefilter);
623: if (&user_is_dc($domain)) {
624: $showhidden = $env{'form.showhidden'};
625: }
626: if ($env{'form.currcat_0'} eq 'communities::0') {
627: $typefilter = 'Community';
628: } else {
629: $typefilter = '.';
630: }
631: %courses =
632: &Apache::lonnet::courseiddump($domain,'.',1,'.','.','.',undef,undef,
633: $typefilter,1,$env{'form.showselfenroll'},
634: $filterstr,$showhidden,'coursecatalog');
635: }
636: return %courses;
637: }
638:
639: sub print_course_listing {
640: my ($domain,$numtitles,$trails,$allitems,$subcats,$codetitles) = @_;
641: my $output;
642: my %courses;
643: my $knownuser = &user_is_known();
644: my $details = $env{'form.coursenum'};
645: if (&user_is_dc($domain)) {
646: if ($env{'form.showdetails'}) {
647: $details = 1;
648: }
649: }
650: if ($env{'form.coursenum'} ne '') {
651: %courses = &Apache::lonnet::courseiddump($domain,'.',1,'.','.',
652: $env{'form.coursenum'},
653: undef,undef,'.',1);
654: if (keys(%courses) == 0) {
655: if ($env{'form.currcat_0'} eq 'communities::0') {
656: $output .= &mt('The courseID provided does not match a community in this domain.');
657: } else {
658: $output .= &mt('The courseID provided does not match a course in this domain.');
659: }
660: return $output;
661: }
662: } else {
663: if ($env{'form.currcat_0'} eq 'instcode::0') {
664: %courses = &search_official_courselist($domain,$numtitles,$codetitles);
665: } else {
666: %courses = &search_courselist($domain,$subcats);
667: }
668: if (keys(%courses) == 0) {
669: if ($env{'form.currcat_0'} eq 'communities::0') {
670: $output = &mt('No communities match the criteria you selected.');
671: } else {
672: $output = &mt('No courses match the criteria you selected.');
673: }
674: return $output;
675: }
676: if (($knownuser) && (!$env{'form.showdetails'}) && (!&user_is_dc($domain))) {
677: $output = '<b>'.&mt('Note for students:').'</b> '
678: .&mt('If you are officially enrolled in a course but the course is not listed in your LON-CAPA courses, click the "Show more details" link for the specific course and check the default access dates and/or automated enrollment settings.')
679: .'<br /><br />';
680: }
681: }
682: my $now = time;
683: my %domconfig =
684: &Apache::lonnet::get_dom('configuration',['usercreation'],$domain);
685: $output .= &construct_data_table($knownuser,\%courses,$details,undef,$now,\%domconfig,$trails,$allitems);
686: $output .= "\n".'<form name="linklaunch" method="post" action="">'.
687: '<input type="hidden" name="backto" value="coursecatalog" />'.
688: '<input type="hidden" name="courseid" value="" />'.
689: &Apache::lonhtmlcommon::echo_form_input(['catalogfilter','courseid']).'</form>';
690: return $output;
691: }
692:
693: sub construct_data_table {
694: my ($knownuser,$courses,$details,$usersections,$now,$domconfig,$trails,
695: $allitems) = @_;
696: my %sortname;
697: if (($details eq '') || ($env{'form.showdetails'})) {
698: $sortname{'Code'} = 'code';
699: $sortname{'Categories'} = 'cats';
700: $sortname{'Title'} = 'title';
701: $sortname{'Owner(s)'} = 'owner';
702: }
703: my $output = &Apache::loncommon::start_data_table().
704: &Apache::loncommon::start_data_table_header_row();
705: my @coltitles = ('Count');
706: if ($env{'form.currcat_0'} eq 'instcode::0') {
707: push(@coltitles,'Code');
708: } else {
709: push(@coltitles,'Categories');
710: }
711: push(@coltitles,('Sections','Crosslisted','Title','Owner(s)'));
712: if (ref($usersections) eq 'HASH') {
713: $coltitles[1] = 'Your Section';
714: }
715: foreach my $item (@coltitles) {
716: $output .= '<th>';
717: if (defined($sortname{$item})) {
718: $output .= '<a href="javascript:changeSort('."'$sortname{$item}'".')">'.&mt($item).'</a>';
719: } elsif ($item eq 'Count') {
720: $output .= ' ';
721: } else {
722: $output .= &mt($item);
723: }
724: $output .= '</th>';
725: }
726: if ($knownuser) {
727: if ($details) {
728: if ($env{'form.currcat_0'} eq 'communities::0') {
729: $output .= '<th>'.&mt('Default Access Dates for Members').'</th>';
730: } else {
731: $output .=
732: '<th>'.&mt('Default Access Dates for Students').'</th>'.
733: '<th>'.&mt('Student Counts').'</th>'.
734: '<th>'.&mt('Auto-enrollment of[_1]registered students','<br />').'</th>';
735: }
736: } else {
737: $output .= '<th>'.&mt('Details').'</th>';
738: }
739: }
740: $output .= '<th>'.&mt('Self-enroll (if permitted)').'</th>';
741: &Apache::loncommon::end_data_table_header_row();
742: my %courseinfo = &build_courseinfo_hash($courses,$knownuser,$details,
743: $usersections);
744: my %Sortby;
745: foreach my $course (sort(keys(%{$courses}))) {
746: if ($env{'form.sortby'} eq 'code') {
747: push(@{$Sortby{$courseinfo{$course}{'code'}}},$course);
748: } elsif ($env{'form.sortby'} eq 'cats') {
749: push(@{$Sortby{$courseinfo{$course}{'categories'}}},$course);
750: } elsif ($env{'form.sortby'} eq 'owner') {
751: push(@{$Sortby{$courseinfo{$course}{'ownerlastnames'}}},$course);
752: } else {
753: my $clean_title = $courseinfo{$course}{'title'};
754: $clean_title =~ s/\W+//g;
755: if ($clean_title eq '') {
756: $clean_title = $courseinfo{$course}{'title'};
757: }
758: push(@{$Sortby{$clean_title}},$course);
759: }
760: }
761: my @sorted_courses;
762: if (($env{'form.sortby'} eq 'code') || ($env{'form.sortby'} eq 'owner') ||
763: ($env{'form.sortby'} eq 'cats')) {
764: @sorted_courses = sort(keys(%Sortby));
765: } else {
766: @sorted_courses = sort { lc($a) cmp lc($b) } (keys(%Sortby));
767: }
768: my $count = 1;
769: foreach my $item (@sorted_courses) {
770: foreach my $course (@{$Sortby{$item}}) {
771: $output.=&Apache::loncommon::start_data_table_row();
772: $output.=&courseinfo_row($courseinfo{$course},$knownuser,$details,
773: \$count,$now,$course,$trails,$allitems);
774: $output.=&Apache::loncommon::end_data_table_row();
775: }
776: }
777: $output .= &Apache::loncommon::end_data_table();
778: return $output;
779: }
780:
781: sub build_courseinfo_hash {
782: my ($courses,$knownuser,$details,$usersections) = @_;
783: my %courseinfo;
784: my $now = time;
785: foreach my $course (keys(%{$courses})) {
786: my $descr;
787: if (ref($courses->{$course}) eq 'HASH') {
788: $descr = $courses->{$course}{'description'};
789: }
790: my $cleandesc=&HTML::Entities::encode($descr,'<>&"');
791: $cleandesc=~s/'/\\'/g;
792: $cleandesc =~ s/^\s+//;
793: my ($cdom,$cnum)=split(/\_/,$course);
794: my ($instcode,$singleowner,$ttype,$selfenroll_types,
795: $selfenroll_start,$selfenroll_end,@owners,%ownernames,$categories);
796: if (ref($courses->{$course}) eq 'HASH') {
797: $descr = $courses->{$course}{'description'};
798: $instcode = $courses->{$course}{'inst_code'};
799: $singleowner = $courses->{$course}{'owner'};
800: $ttype = $courses->{$course}{'type'};
801: $selfenroll_types = $courses->{$course}{'selfenroll_types'};
802: $selfenroll_start = $courses->{$course}{'selfenroll_start_date'};
803: $selfenroll_end = $courses->{$course}{'selfenroll_end_date'};
804: $categories = $courses->{$course}{'categories'};
805: push(@owners,$singleowner);
806: if (ref($courses->{$course}{'co-owners'}) eq 'ARRAY') {
807: foreach my $item (@{$courses->{$course}{'co-owners'}}) {
808: push(@owners,$item);
809: }
810: }
811: }
812: foreach my $owner (@owners) {
813: my ($ownername,$ownerdom);
814: if ($owner =~ /:/) {
815: ($ownername,$ownerdom) = split(/:/,$owner);
816: } else {
817: $ownername = $owner;
818: if ($owner ne '') {
819: $ownerdom = $cdom;
820: }
821: }
822: if ($ownername ne '' && $ownerdom ne '') {
823: my %namehash=&Apache::loncommon::getnames($ownername,$ownerdom);
824: $ownernames{$ownername.':'.$ownerdom} = \%namehash;
825: }
826: }
827: $courseinfo{$course}{'cdom'} = $cdom;
828: $courseinfo{$course}{'cnum'} = $cnum;
829: $courseinfo{$course}{'code'} = $instcode;
830: my @lastnames;
831: foreach my $owner (keys(%ownernames)) {
832: if (ref($ownernames{$owner}) eq 'HASH') {
833: push(@lastnames,$ownernames{$owner}{'lastname'});
834: }
835: }
836: $courseinfo{$course}{'ownerlastnames'} = join(', ',sort(@lastnames));
837: $courseinfo{$course}{'title'} = $cleandesc;
838: $courseinfo{$course}{'owner'} = $singleowner;
839: $courseinfo{$course}{'selfenroll_types'} = $selfenroll_types;
840: $courseinfo{$course}{'selfenroll_start'} = $selfenroll_start;
841: $courseinfo{$course}{'selfenroll_end'} = $selfenroll_end;
842: $courseinfo{$course}{'categories'} = $categories;
843:
844: my %coursehash = &Apache::lonnet::dump('environment',$cdom,$cnum);
845: my @classids;
846: my @crosslistings;
847: my ($seclist,$numsec) =
848: &identify_sections($coursehash{'internal.sectionnums'});
849: if (ref($usersections) eq 'HASH') {
850: if (ref($usersections->{$course}) eq 'ARRAY') {
851: $seclist = join(', ',@{$usersections->{$course}});
852: }
853: }
854: $courseinfo{$course}{'seclist'} = $seclist;
855: my ($xlist_items,$numxlist) =
856: &identify_sections($coursehash{'internal.crosslistings'});
857: my $showsyllabus = 1; # default is to include a syllabus link
858: if (defined($coursehash{'showsyllabus'})) {
859: $showsyllabus = $coursehash{'showsyllabus'};
860: }
861: $courseinfo{$course}{'showsyllabus'} = $showsyllabus;
862: if (((defined($env{'form.coursenum'}) && ($cnum eq $env{'form.coursenum'}))) ||
863: ($knownuser && ($details == 1))) {
864: $courseinfo{$course}{'counts'} = &count_students($cdom,$cnum,$numsec);
865: $courseinfo{$course}{'autoenrollment'} =
866: &autoenroll_info(\%coursehash,$now,$seclist,$xlist_items,
867: $instcode,\@owners,$cdom,$cnum);
868:
869: my $startaccess = '';
870: my $endaccess = '';
871: my $accessdates;
872: if ( defined($coursehash{'default_enrollment_start_date'}) ) {
873: $startaccess = &Apache::lonlocal::locallocaltime($coursehash{'default_enrollment_start_date'});
874: }
875: if ( defined($coursehash{'default_enrollment_end_date'}) ) {
876: $endaccess = &Apache::lonlocal::locallocaltime($coursehash{'default_enrollment_end_date'});
877: if ($coursehash{'default_enrollment_end_date'} == 0) {
878: $endaccess = &mt('No ending date');
879: }
880: }
881: if ($startaccess) {
882: $accessdates .= '<i>'.&mt('From:[_1]','</i> '.$startaccess).'<br />';
883: }
884: if ($endaccess) {
885: $accessdates .= '<i>'.&mt('To:[_1]','</i> '.$endaccess).'<br />';
886: }
887: if (($selfenroll_types ne '') &&
888: ($selfenroll_end > 0 && $selfenroll_end > $now)) {
889: my ($selfenroll_start_access,$selfenroll_end_access);
890: if (($coursehash{'default_enrollment_start_date'} ne
891: $coursehash{'internal.selfenroll_start_access'}) ||
892: ($coursehash{'default_enrollment_end_date'} ne
893: $coursehash{'internal.selfenroll_end_access'})) {
894: if ( defined($coursehash{'internal.selfenroll_start_access'}) ) {
895: $selfenroll_start_access = &Apache::lonlocal::locallocaltime($coursehash{'internal.selfenroll_start_access'});
896: }
897: if ( defined($coursehash{'default_enrollment_end_date'}) ) {
898: $selfenroll_end_access = &Apache::lonlocal::locallocaltime($coursehash{'internal.selfenroll_end_access'});
899: if ($coursehash{'internal.selfenroll_end_access'} == 0) {
900: $selfenroll_end_access = &mt('No ending date');
901: }
902: }
903: if ($selfenroll_start_access || $selfenroll_end_access) {
904: $accessdates .= '<br/><br /><i>'.&mt('Self-enrollers:').'</i><br />';
905: if ($selfenroll_start_access) {
906: $accessdates .= '<i>'.&mt('From:[_1]','</i> '.$selfenroll_start_access).'<br />';
907: }
908: if ($selfenroll_end_access) {
909: $accessdates .= '<i>'.&mt('To:[_1]','</i> '.$selfenroll_end_access).'<br />';
910: }
911: }
912: }
913: }
914: $courseinfo{$course}{'access'} = $accessdates;
915: }
916: if ($xlist_items eq '') {
917: $xlist_items = &mt('No');
918: }
919: $courseinfo{$course}{'xlist'} = $xlist_items;
920: }
921: return %courseinfo;
922: }
923:
924: sub count_students {
925: my ($cdom,$cnum,$numsec) = @_;
926: my $classlist = &Apache::loncoursedata::get_classlist($cdom,$cnum);
927: my %student_count = (
928: Active => 0,
929: Future => 0,
930: Expired => 0,
931: );
932: my %idx;
933: $idx{'status'} = &Apache::loncoursedata::CL_STATUS();
934: my %status_title = &Apache::lonlocal::texthash(
935: Expired => 'Previous access',
936: Active => 'Current access',
937: Future => 'Future access',
938: );
939:
940: while (my ($student,$data) = each(%$classlist)) {
941: $student_count{$data->[$idx{'status'}]} ++;
942: }
943:
944: my $countslist = &mt('[quant,_1,section:,sections:,No sections]',$numsec).'<br />';
945: foreach my $status ('Active','Future') {
946: $countslist .= '<span class="LC_nobreak">'.$status_title{$status}.': '.
947: $student_count{$status}.'</span><br />';
948: }
949: return $countslist;
950: }
951:
952: sub courseinfo_row {
953: my ($info,$knownuser,$details,$countref,$now,$course,$trails,$allitems) = @_;
954: my ($cdom,$cnum,$title,$ownerlast,$code,$owner,$seclist,$xlist_items,
955: $accessdates,$showsyllabus,$counts,$autoenrollment,$output,$categories);
956: if (ref($info) eq 'HASH') {
957: $cdom = $info->{'cdom'};
958: $cnum = $info->{'cnum'};
959: $title = $info->{'title'};
960: $ownerlast = $info->{'ownerlastnames'};
961: $code = $info->{'code'};
962: $owner = $info->{'owner'};
963: $seclist = $info->{'seclist'};
964: $xlist_items = $info->{'xlist'};
965: $accessdates = $info->{'access'};
966: $counts = $info->{'counts'};
967: $autoenrollment = $info->{'autoenrollment'};
968: $showsyllabus = $info->{'showsyllabus'};
969: $categories = $info->{'categories'};
970: } else {
971: $output = '<td colspan="8">'.&mt('No information available for [_1].',
972: $code).'</td>';
973: return $output;
974: }
975: $output .= '<td>'.$$countref.'</td>';
976: if ($env{'form.currcat_0'} eq 'instcode::0') {
977: $output .= '<td>'.$code.'</td>';
978: } else {
979: my ($categorylist,@cats);
980: if ($categories ne '') {
981: @cats = split('&',$categories);
982: }
983: if ((ref($trails) eq 'ARRAY') && (ref($allitems) eq 'HASH')) {
984: my @categories = map { $trails->[$allitems->{$_}]; } @cats;
985: $categorylist = join('<br />',@categories);
986: }
987: if ($categorylist eq '') {
988: $categorylist = ' ';
989: }
990: $output .= '<td>'.$categorylist.'</td>';
991: }
992: $output .= '<td>'.$seclist.'</td>'.
993: '<td>'.$xlist_items.'</td>'.
994: '<td>'.$title.' <font size="-2">';
995: if ($showsyllabus) {
996: $output .= '<a href="javascript:ToSyllabus('."'$cdom','$cnum'".')">'.&mt('Syllabus').'</a>';
997: } else {
998: $output .= ' ';
999: }
1000: $output .= '</font></td>'.
1001: '<td>'.$ownerlast.'</td>';
1002: if ($knownuser) {
1003: if ($details) {
1004: if ($env{'form.currcat_0'} eq 'communities::0') {
1005: $output .= '<td>'.$accessdates.'</td>';
1006: } else {
1007: $output .=
1008: '<td>'.$accessdates.'</td>'.
1009: '<td>'.$counts.'</td>'.
1010: '<td>'.$autoenrollment.'</td>';
1011: }
1012: } else {
1013: $output .= "<td><a href=\"javascript:setCourseId('$cnum')\">".&mt('Show more details').'</a></td>';
1014: }
1015: }
1016: my $selfenroll;
1017: if ($info->{'selfenroll_types'}) {
1018: my $showstart = &Apache::lonlocal::locallocaltime($info->{'selfenroll_start'});
1019: my $showend = &Apache::lonlocal::locallocaltime($info->{'selfenroll_end'});
1020: if (($info->{'selfenroll_end'} > 0) && ($info->{'selfenroll_end'} > $now)) {
1021: if (($info->{'selfenroll_start'} > 0) && ($info->{'selfenroll_start'} > $now)) {
1022: $output .= '<td>'.&mt('Starts: [_1]','<span class="LC_cusr_emph">'.$showstart.'</span>').'<br />'.&mt('Ends: [_1]','<span class="LC_cusr_emph">'.$showend.'</span>').'</td>';
1023: } else {
1024: $output .= '<td><a href="javascript:ToSelfenroll('."'$course'".')">'.&mt('Enroll in course').'</a></td>';
1025: }
1026: $selfenroll = 1;
1027: }
1028: }
1029: if (!$selfenroll) {
1030: $output .= '<td> </td>';
1031: }
1032: $$countref ++;
1033: return $output;
1034: }
1035:
1036: sub identify_sections {
1037: my ($seclist) = @_;
1038: my @secnums;
1039: if ($seclist =~ /,/) {
1040: my @sections = split(/,/,$seclist);
1041: foreach my $sec (@sections) {
1042: $sec =~ s/:[^:]*$//;
1043: push(@secnums,$sec);
1044: }
1045: } else {
1046: if ($seclist =~ m/^([^:]+):/) {
1047: my $sec = $1;
1048: if (!grep(/^\Q$sec\E$/,@secnums)) {
1049: push(@secnums,$sec);
1050: }
1051: }
1052: }
1053: @secnums = sort {$a <=> $b} @secnums;
1054: $seclist = join(', ',@secnums);
1055: my $numsec = @secnums;
1056: return ($seclist,$numsec);
1057: }
1058:
1059: sub get_valid_classes {
1060: my ($seclist,$xlist_items,$crscode,$owners,$cdom,$cnum) = @_;
1061: my $response;
1062: my %validations;
1063: @{$validations{'sections'}} = ();
1064: @{$validations{'xlists'}} = ();
1065: my $totalitems = 0;
1066: if ($seclist) {
1067: foreach my $sec (split(/, /,$seclist)) {
1068: my $class = $crscode.$sec;
1069: if (&Apache::lonnet::auto_validate_class_sec($cdom,$cnum,$owners,
1070: $class) eq 'ok') {
1071: if (!grep(/^\Q$sec$\E/,@{$validations{'sections'}})) {
1072: push(@{$validations{'sections'}},$sec);
1073: $totalitems ++;
1074: }
1075: }
1076: }
1077: }
1078: if ($xlist_items) {
1079: foreach my $item (split(/, /,$xlist_items)) {
1080: if (&Apache::lonnet::auto_validate_class_sec($cdom,$cnum,$owners,
1081: $item) eq 'ok') {
1082: if (!grep(/^\Q$item$\E/,@{$validations{'xlists'}})) {
1083: push(@{$validations{'xlists'}},$item);
1084: $totalitems ++;
1085: }
1086: }
1087: }
1088: }
1089: if ($totalitems > 0) {
1090: if (@{$validations{'sections'}}) {
1091: $response = &mt('Sections:').' '.
1092: join(', ',@{$validations{'sections'}}).'<br />';
1093: }
1094: if (@{$validations{'xlists'}}) {
1095: $response .= &mt('Courses:').' '.
1096: join(', ',@{$validations{'xlists'}});
1097: }
1098: }
1099: return $response;
1100: }
1101:
1102: sub autoenroll_info {
1103: my ($coursehash,$now,$seclist,$xlist_items,$code,$owners,$cdom,$cnum) = @_;
1104: my $autoenrolldates = &mt('Not enabled');
1105: if (defined($coursehash->{'internal.autoadds'}) && $coursehash->{'internal.autoadds'} == 1) {
1106: my ($autostart,$autoend);
1107: if ( defined($coursehash->{'internal.autostart'}) ) {
1108: $autostart = &Apache::lonlocal::locallocaltime($coursehash->{'internal.autostart'});
1109: }
1110: if ( defined($coursehash->{'internal.autoend'}) ) {
1111: $autoend = &Apache::lonlocal::locallocaltime($coursehash->{'internal.autoend'});
1112: }
1113: if ($coursehash->{'internal.autostart'} > $now) {
1114: if ($coursehash->{'internal.autoend'} && $coursehash->{'internal.autoend'} < $now) {
1115: $autoenrolldates = &mt('Not enabled');
1116: } else {
1117: my $valid_classes =
1118: &get_valid_classes($seclist,$xlist_items,$code,
1119: $owners,$cdom,$cnum);
1120: if ($valid_classes ne '') {
1121: $autoenrolldates = &mt('Not enabled').'<br />'
1122: .&mt('Starts: [_1]',$autostart)
1123: .'<br />'.$valid_classes;
1124: }
1125: }
1126: } else {
1127: if ($coursehash->{'internal.autoend'} && $coursehash->{'internal.autoend'} < $now) {
1128: $autoenrolldates = &mt('Not enabled').'<br />'
1129: .&mt('Ended: [_1]',$autoend);
1130: } else {
1131: my $valid_classes = &get_valid_classes($seclist,$xlist_items,
1132: $code,$owners,$cdom,$cnum);
1133: if ($valid_classes ne '') {
1134: $autoenrolldates = &mt('Currently enabled').'<br />'.
1135: $valid_classes;
1136: }
1137: }
1138: }
1139: }
1140: return $autoenrolldates;
1141: }
1142:
1143: sub user_is_known {
1144: my $known = 0;
1145: if ($env{'user.name'} ne '' && $env{'user.name'} ne 'public'
1146: && $env{'user.domain'} ne '' && $env{'user.domain'} ne 'public') {
1147: $known = 1;
1148: }
1149: return $known;
1150: }
1151:
1152: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>