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