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