File:
[LON-CAPA] /
loncom /
interface /
lonviewcoauthors.pm
Revision
1.1:
download - view:
text,
annotated -
select for diffs
Fri Nov 3 01:12:15 2023 UTC (9 months, 2 weeks ago) by
raeburn
Branches:
MAIN
CVS tags:
HEAD
- Authoring Space defaults defaults which domain coordinator can override.
- Available Editors, WebDAV access, Disk Quota for Authoring Space
can be set for specific users by DC via "Add/modify user"
- Bug 5273 Co-authors in "group authoring" accounts can manage co-authors
- Existing co-author(s) can be assigned rights to add/revoke co-author
roles. Can be set by DC via "Add/modify user" or by author via "People"
- Co-authors and Assistant co-authors can view a list of co-authors for
the Authoring Space. Availability set by Author or Co-author "manager".
Listing can be set to "opt-in".
1: # The LearningOnline Network with CAPA
2: # Handler to display the coauthors
3: #
4: # $Id: lonviewcoauthors.pm,v 1.1 2023/11/03 01:12:15 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: ##############################################################
30:
31: package Apache::lonviewcoauthors;
32:
33: use strict;
34: use Apache::loncommon();
35: use Apache::lonhtmlcommon();
36: use Apache::Constants qw(:common :http REDIRECT);
37: use Apache::lonlocal;
38: use Apache::lonnet;
39: use LONCAPA qw(:DEFAULT :match);
40:
41: ###################################################################
42: ###################################################################
43:
44: ###################################################################
45: ###################################################################
46:
47: =pod
48:
49: =item &handler
50:
51: The typical handler you see in all these modules. Takes $r, the
52: http request, as an argument.
53:
54: =cut
55:
56: ###################################################################
57: ###################################################################
58: sub handler {
59: my $r=shift;
60: if ($r->header_only) {
61: &Apache::loncommon::content_type($r,'text/html');
62: $r->send_http_header;
63: return OK;
64: }
65: my ($role,$audom,$auname,$canview,$canedit,$start_page);
66: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
67: ['forceedit','state','action','caller']);
68:
69: # Get permissions
70: ($role,$audom,$auname,$canview,$canedit) = &get_allowable();
71: unless ($canview) {
72: $env{'user.error.msg'}=
73: "/adm/viewcoauthors:not in co-author role";
74: return HTTP_NOT_ACCEPTABLE;
75: }
76: &Apache::loncommon::content_type($r,'text/html');
77: $r->send_http_header;
78:
79: # Get view settings
80: my %viewsettings = &retrieve_view_settings($auname,$audom,$role);
81:
82: # Get caller
83: my $caller;
84: if ($env{'form.caller'} eq '/adm/createuser') {
85: $caller = $env{'form.caller'};
86: } else {
87: $caller = '/adm/viewcoauthors';
88: }
89:
90: # Get breadcrumbs
91: my $brcrum = [{'href' => $caller,
92: 'text' => 'Co-author listing'},];
93: if (($canedit) && ($env{'form.forceedit'})) {
94: &get_editor_crumbs($brcrum,$caller);
95: }
96:
97: # Print page header
98: my $args = { 'bread_crumbs' => $brcrum };
99: $r->print(&Apache::loncommon::start_page('Co-authors listing',undef,
100: $args));
101:
102: if (($canedit) && ($env{'form.forceedit'})) {
103: $r->print(&edit_settings($audom,$auname,$role,$caller,\%viewsettings));
104: } elsif ($viewsettings{'show'} eq 'none') {
105: $r->print('<h3>'.&mt('Coauthor-viewable listing').'</h3>'.
106: '<p class="LC_info">'.&mt('Listing of co-authors not enabled for this Authoring Space').'</p>');
107: } else {
108: &print_coauthors($r,$auname,$audom,$role,$caller,\%viewsettings);
109: }
110:
111: # Print page footer
112: $r->print(&Apache::loncommon::end_page());
113: return OK;
114: }
115:
116: sub get_allowable {
117: my ($role,$audom,$auname,$canview,$canedit);
118: if ($env{'request.role'} =~ m{^(ca|aa)\./($match_domain)/($match_username)$}) {
119: ($role,$audom,$auname) = ($1,$2,$3);
120: if ((&Apache::lonnet::allowed('vca',"$audom/$auname")) ||
121: (&Apache::lonnet::allowed('vaa',"$audom/$auname"))) {
122: if ($env{"environment.internal.manager./$audom/$auname"}) {
123: $canedit = 1;
124: }
125: }
126: $canview = 1;
127: } elsif ($env{'request.role'} eq "au./$env{'user.domain'}/") {
128: $role = 'au';
129: $auname = $env{'user.name'};
130: $audom = $env{'user.domain'};
131: if ((&Apache::lonnet::allowed('cca',"$audom/$auname")) ||
132: (&Apache::lonnet::allowed('caa',"$audom/$auname"))) {
133: $canedit = 1;
134: }
135: $canview = 1;
136: }
137: return ($role,$audom,$auname,$canview,$canedit);
138: }
139:
140: sub retrieve_view_settings {
141: my ($auname,$audom,$role) = @_;
142: my %viewsettings;
143: if (($auname ne '') & ($audom ne '')) {
144: if ($role eq 'au') {
145: if (exists($env{'environment.coauthorlist'})) {
146: $viewsettings{'show'} = $env{'environment.coauthorlist'};
147: }
148: if (exists($env{'environment.coauthoroptin'})) {
149: $viewsettings{'optin'} = $env{'environment.coauthoroptin'};
150: }
151: } elsif ($env{"environment.internal.coauthorlist./$audom/$auname"} =~ /^(role|all|none)$/) {
152: $viewsettings{'show'} = $env{"environment.internal.coauthorlist./$audom/$auname"};
153: $viewsettings{'optin'} = $env{"environment.internal.coauthoroptin./$audom/$auname"};
154: }
155: }
156: unless ((exists($viewsettings{'show'})) && (exists($viewsettings{'optin'}))) {
157: if ($audom ne '') {
158: my %domconfig =
159: &Apache::lonnet::get_dom('configuration',['authordefaults'],$audom);
160: my %domdefs;
161: if (ref($domconfig{'authordefaults'}) eq 'HASH') {
162: if (exists($domconfig{'authordefaults'}{'coauthorlist'})) {
163: $domdefs{'show'} = $domconfig{'authordefaults'}{'coauthorlist'};
164: }
165: if (exists($domconfig{'authordefaults'}{'coauthoroptin'})) {
166: $domdefs{'optin'} = $domconfig{'authordefaults'}{'coauthoroptin'};
167: }
168: }
169: unless (exists($viewsettings{'show'})) {
170: if (exists($domdefs{'show'})) {
171: $viewsettings{'show'} = $domdefs{'show'};
172: }
173: }
174: unless (exists($viewsettings{'optin'})) {
175: if (exists($domdefs{'optin'})) {
176: $viewsettings{'optin'} = $domdefs{'optin'};
177: }
178: }
179: }
180: }
181: unless (exists($viewsettings{'show'})) {
182: $viewsettings{'show'} = 'none';
183: }
184: unless (exists($viewsettings{'optin'})) {
185: $viewsettings{'optin'} = '0';
186: }
187: return %viewsettings;
188: }
189:
190: sub get_editor_crumbs {
191: my ($brcrum,$caller) = @_;
192: my $querystr = '?forceedit=1';
193: if ($caller eq '/adm/createuser') {
194: $querystr .= '&action=calist';
195: }
196: if (ref($brcrum) eq 'ARRAY') {
197: push(@{$brcrum},
198: {'href' => $caller.$querystr,
199: 'text' => 'Configure co-author listing'});
200: if ($env{'form.state'} eq 'setconfig') {
201: push(@{$brcrum},
202: {'href' => $caller.$querystr,
203: 'text' => 'Result'});
204: }
205: }
206: return;
207: }
208:
209: sub edit_settings {
210: my ($audom,$auname,$role,$caller,$settingsref) = @_;
211: my %viewsettings;
212: if (ref($settingsref) eq 'HASH') {
213: %viewsettings = %{$settingsref};
214: } else {
215: %viewsettings = &retrieve_view_settings($auname,$audom,$role);
216: }
217: my %userenv = &Apache::lonnet::userenvironment($audom,$auname,'',
218: 'coauthorlist','coauthoroptin');
219: my %titles = &Apache::lonlocal::texthash (
220: coauthorlist => 'List availability',
221: coauthoroptin => 'User agreement needed for listing',
222: );
223: my %options = &Apache::lonlocal::texthash (
224: role => "List only same type of co-author role as viewer",
225: all => "List both co-author(s) and assistant co-author(s)",
226: none => "No listing",
227: );
228: my %lt = &Apache::lonlocal::texthash (
229: yes => 'Yes',
230: no => 'No',
231: slcc => 'Settings for listing of co-authors changed',
232: ncms => 'No changes made to settings for listing of co-authors',
233: apos => 'A problem occurred saving your changes.',
234: cloc => 'Configure listing of co-authors',
235: set => 'Setting',
236: vale => 'Value',
237: sav => 'Save changes'
238: );
239: my $output;
240: if ($env{'form.state'} eq 'setconfig') {
241: my (%changed,$message);
242: my ($numchanged,%changes,%disallowed);
243: foreach my $key ('coauthorlist','coauthoroptin') {
244: if ($key eq 'coauthorlist') {
245: next unless ($env{'form.'.$key} =~ /^all|role|none$/);
246: } elsif ($key eq 'coauthoroptin') {
247: next unless ($env{'form.'.$key} =~ /^0|1$/);
248: }
249: if ($userenv{$key} ne $env{'form.'.$key}) {
250: $changed{$key} = $env{'form.'.$key};
251: }
252: }
253: if (keys(%changed)) {
254: my $putres = &Apache::lonnet::put('environment',\%changed,
255: $audom,$auname);
256: if ($putres eq 'ok') {
257: my $author;
258: if (($audom eq $env{'user.domain'}) && ($auname eq $env{'user.name'})) {
259: $author = 1;
260: }
261: my (%envhash,%newvaltext);
262: foreach my $key (keys(%changed)) {
263: if ($author) {
264: $envhash{"environment.$key"} = $changed{$key};
265: } else {
266: $envhash{"environment.internal.$key./$audom/$auname"} = $changed{$key};
267: }
268: if ($key eq 'coauthorlist') {
269: $newvaltext{$key} = $options{$changed{$key}};
270: } elsif ($key eq 'coauthoroptin') {
271: $newvaltext{$key} = ($changed{$key}? $lt{'yes'} : $lt{'no'});
272: }
273: }
274: &Apache::lonnet::appenv(\%envhash);
275: $output = '<h3>'.$lt{'slcc'}.'</h3><ul>';
276: foreach my $key ('coauthorlist','coauthoroptin') {
277: if (exists($changed{$key})) {
278: $output .= '<li>'.
279: &mt('[_1] set to "[_2]"',
280: $titles{$key},$newvaltext{$key}).
281: '</li>';
282: }
283: }
284: $output .= '</ul>';
285: } else {
286: $output = '<h3>'.$lt{'ncms'}.'</h3>'.
287: '<p class="LC_warning">'.$lt{'apos'}.'</p>';
288: }
289: } else {
290: $output = '<h3>'.$lt{'ncms'}.'</h3>';
291: }
292: } else {
293: my %sel;
294: foreach my $option (keys(%options)) {
295: if ($option eq $viewsettings{'show'}) {
296: $sel{$option} = ' selected="selected"';
297: } else {
298: $sel{$option} = '';
299: }
300: }
301: my ($checkedon,$checkedoff);
302: if ($viewsettings{'optin'}) {
303: $checkedon = ' checked="checked"';
304: } else {
305: $checkedoff = ' checked="checked"';
306: }
307: my $forceedit;
308: if ($env{'form.forceedit'}) {
309: $forceedit = 1;
310: }
311: my $hiddenaction;
312: if ($caller eq '/adm/createuser') {
313: $hiddenaction = '<input type="hidden" name="action" value="calist" />'."\n";
314: }
315: $output = '<h3>'.$lt{'cloc'}.'</h3>'."\n".
316: '<form method="post" name="display" action="'.$caller.'">'."\n".
317: '<input type="hidden" name="caller" value="'.$caller.'" />'."\n".
318: '<input type="hidden" name="state" value="setconfig" />'."\n".
319: '<input type="hidden" name="forceedit" value="'.$forceedit.'" />'."\n".
320: $hiddenaction.
321: &Apache::loncommon::start_data_table().
322: &Apache::loncommon::start_data_table_header_row().
323: '<th>'.$lt{'set'}.'</th><th>'.$lt{'val'}.'</th>'.
324: &Apache::loncommon::end_data_table_header_row().
325: &Apache::loncommon::start_data_table_row().
326: '<td>'.
327: $titles{'coauthorlist'}.'</td>'.
328: '<td><select name="coauthorlist">'.
329: '<option value="none"'.$sel{'none'}.'>'.$options{'none'}.'</option>'.
330: '<option value="role"'.$sel{'role'}.'>'.$options{'role'}.'</option>'.
331: '<option value="all"'.$sel{'all'}.'>'.$options{'all'}.'</option>'.
332: '</select></td>'.
333: &Apache::loncommon::end_data_table_row().
334: &Apache::loncommon::start_data_table_row().
335: '<td>'.$titles{'coauthoroptin'}.'</td>'.
336: '<td><span class="LC_nobreak">'.
337: '<label><input type="radio" name="coauthoroptin" value="0" '.
338: $checkedoff.' />'.$lt{'no'}.'</label> '.
339: '<label><input type="radio" name="coauthoroptin" value="1" '.
340: $checkedon.' />'.$lt{'yes'}.'</label>'.
341: '</span></td>'.
342: &Apache::loncommon::end_data_table_row().
343: &Apache::loncommon::end_data_table().
344: '<br clear="all" />'.
345: '<input type="submit" value="'.$lt{'sav'}.'" />'.
346: '</form>';
347: }
348: return $output;
349: }
350:
351: sub print_coauthors {
352: my ($r,$auname,$audom,$role,$caller,$settingsref) = @_;
353: my %viewsettings;
354: if (ref($settingsref) eq 'HASH') {
355: %viewsettings = %{$settingsref};
356: } else {
357: %viewsettings =
358: &Apache::lonviewcoauthors::&retrieve_view_settings($auname,$audom,$role);
359: }
360: my %lt = &Apache::lonlocal::texthash (
361: cvl => 'Coauthor-viewable listing',
362: nam => 'Name',
363: usr => 'Username:Domain',
364: rol => 'Role(s)',
365: and => 'and',
366: utd => 'Unable to determine Authoring Space context',
367: );
368: if (($auname ne '') && ($audom ne '')) {
369: my (%shownstatus,%coauthors);
370: $r->print("<h3>$lt{'cvl'}</h3>");
371: if ($env{'form.action'} eq 'setenv') {
372: $r->print(&process_coauthor_prefs($auname,$audom,$caller));
373: }
374: if ($viewsettings{'optin'}) {
375: if ($env{'request.role'} =~ /^(ca|aa)/) {
376: $r->print(&coauthor_listing_form($auname,$audom,$caller));
377: }
378: %shownstatus = &Apache::lonnet::dump('showncoauthors',$audom,$auname);
379: }
380: my $fullcount = 0;
381: my $viewablecount = 0;
382: my $displaycount = 0;
383: my ($output,$roletype);
384: my @showroles;
385: if ($env{'request.role'} eq "au./$env{'user.domain'}/") {
386: @showroles = ('ca','aa');
387: } elsif ($viewsettings{'show'} eq 'role') {
388: ($roletype) = ($env{'request.role'} =~ m{^(ca|aa)\./$audom/$auname$});
389: if ($roletype ne '') {
390: @showroles = ($roletype);
391: }
392: } else {
393: @showroles = ('ca','aa');
394: }
395: my %coauthors = &Apache::lonnet::get_my_roles($auname,$audom,undef,undef,
396: \@showroles,[$audom]);
397: my (%userinfo,%showuser);
398: foreach my $item (keys(%coauthors)) {
399: my ($username,$domain,$userrole) = split(/:/,$item);
400: my ($start,$end) = split(/:/,$coauthors{$item});
401: next if ($start eq '-1' && $end eq '-1');
402: if (ref($userinfo{$username.':'.$domain}) eq 'HASH') {
403: if (ref($userinfo{$username.':'.$domain}{roles}) eq 'ARRAY') {
404: unless (grep(/^$userrole$/,@{$userinfo{$username.':'.$domain}{roles}})) {
405: push(@{$userinfo{$username.':'.$domain}{roles}},$userrole);
406: }
407: } else {
408: $userinfo{$username.':'.$domain}{roles} = [$userrole];
409: }
410: } else {
411: $userinfo{$username.':'.$domain}{fullname} =
412: &Apache::loncommon::plainname($username,$domain,'lastname');
413: $userinfo{$username.':'.$domain}{roles} = [$userrole];
414: }
415: if ($viewsettings{'optin'}) {
416: if ($shownstatus{$username.':'.$domain}) {
417: $showuser{$username.':'.$domain} = $userinfo{$username.':'.$domain};
418: }
419: } else {
420: $showuser{$username.':'.$domain} = $userinfo{$username.':'.$domain};
421: }
422: }
423: $fullcount = scalar(keys(%userinfo));
424: $viewablecount = scalar(keys(%showuser));
425: my @rolenames = map { &Apache::lonnet::plaintext($_); } ('ca','aa');
426: if ($viewsettings{'optin'}) {
427: $displaycount = $viewablecount;
428: if ($fullcount > $viewablecount) {
429: if ($viewablecount) {
430: $output = &mt('Only users who have opted to be listed ([_1] out of [_2] users) are shown.',
431: $viewablecount,$fullcount).'<br />';
432: } else {
433: if ($fullcount == 1) {
434: if ($roletype) {
435: $output = &mt('The one user with a [_1] role has opted not to be listed.',
436: &Apache::lonnet::plaintext($roletype));
437: } else {
438: $output = &mt('The one user with a [_1] or [_2] role has opted not to be listed.',
439: $rolenames[0],$rolenames[1]);
440: }
441: } else {
442: if ($roletype) {
443: $output = &mt('None of the [_1] users with a [_2] role have opted to be listed.',
444: $fullcount,&Apache::lonnet::plaintext($roletype));
445: } else {
446: $output = &mt('None of the [_1] users with a [_2] or [_3] role have opted to be listed.',
447: $fullcount,$rolenames[0],$rolenames[1]);
448: }
449: }
450: }
451: } else {
452: if ($fullcount > 1) {
453: if ($roletype) {
454: $output = &mt('All [_1] users with a [_2] role have opted to be listed.',
455: $fullcount,&Apache::lonnet::plaintext($roletype));
456: } else {
457: $output = &mt('All [_1] users with a [_2] or [_3] role have opted to be listed.',
458: $fullcount,$rolenames[0],$rolenames[1]);
459: }
460: } elsif ($fullcount == 1) {
461: if ($roletype) {
462: $output = &mt('The one user with a [_1] role has opted to be listed.',
463: &Apache::lonnet::plaintext($roletype));
464: } else {
465: $output = &mt('The one user with a [_1] or [_2] role has opted to be listed.',
466: $rolenames[0],$rolenames[1]);
467: }
468: } else {
469: if ($roletype) {
470: $output = &mt('There are no users with a [_1] role.',
471: &Apache::lonnet::plaintext($roletype));
472: } else {
473: $output = &mt('There are no users with a [_1] or [_2] role.',
474: $rolenames[0],$rolenames[1]);
475: }
476: }
477: }
478: } else {
479: $displaycount = $fullcount;
480: if ($fullcount > 1) {
481: if ($roletype) {
482: $output = &mt('All [_1] users with a [_2] role are shown.',
483: $fullcount,&Apache::lonnet::plaintext($roletype));
484: } else {
485: $output = &mt('All [_1] users with a [_2] or [_3] role are shown.',
486: $fullcount,$rolenames[0],$rolenames[1]);
487: }
488: } elsif ($fullcount == 1) {
489: if ($roletype) {
490: $output = &mt('The one user with a [_1] role is shown.',
491: &Apache::lonnet::plaintext($roletype));
492: } else {
493: $output = &mt('The one user with a [_1] or [_2] role is shown.',
494: $rolenames[0],$rolenames[1]);
495: }
496: } else {
497: if ($roletype) {
498: $output = &mt('There are no users with a [_1] role.',
499: &Apache::lonnet::plaintext($roletype));
500: } else {
501: $output = &mt('There are no users with a [_1] or [_2] role.',
502: $rolenames[0],$rolenames[1]);
503: }
504: }
505: }
506: if ($displaycount) {
507: $r->print('<h4>'.$output.'</h4>');
508: my $table = '<br />'.&Apache::loncommon::start_data_table()."\n".
509: &Apache::loncommon::start_data_table_header_row()."\n".
510: '<th></th>'. # for the count
511: '<th>'.$lt{'nam'}.'</th>'.
512: '<th>'.$lt{'usr'}.'</th>';
513: unless ($roletype) {
514: $table .= '<th>'.$lt{'rol'}.'</th>';
515: }
516: $table .= &Apache::loncommon::end_data_table_header_row()."\n";
517: my $count = 0;
518: my @sorted = sort {
519: lc($showuser{$a}{fullname}) cmp lc($showuser{$b}{fullname})
520: } (keys(%showuser));
521: foreach my $user (@sorted) {
522: my ($username,$domain) = split(/:/,$user);
523: $count ++;
524: $table .= &Apache::loncommon::start_data_table_row()."\n".
525: '<td>'.$count.'</td>'.
526: '<td>'.&Apache::loncommon::aboutmewrapper($showuser{$user}{fullname},
527: $username,$domain).
528: '</td>'.
529: '<td>'.&Apache::loncommon::messagewrapper
530: ('<img src="/adm/lonIcons/mailto.gif" border="0" /> '.
531: $user,$username,$domain).
532: '</td>';
533: unless ($roletype) {
534: $table .= '<td>'.
535: join(" $lt{'and'} ", map { &Apache::lonnet::plaintext($_); }
536: @{$showuser{$user}{roles}}).
537: '</td>';
538: }
539: $table .= &Apache::loncommon::end_data_table_row()."\n";
540: }
541: $table .= &Apache::loncommon::end_data_table()."\n";
542: $r->print($table);
543: } else {
544: $r->print('<div class="LC_info">'.$output.'</div>');
545: }
546: } else {
547: $r->print('<div class="LC_warning"'.$lt{'utd'}.'</div>');
548: }
549: return;
550: }
551:
552: sub coauthor_listing_form {
553: my ($auname,$audom,$caller) = @_;
554: my $showinlist = $env{"environment.internal.showinlist./$audom/$auname"};
555: my ($showoff,$showon);
556: if ($showinlist) {
557: $showon = ' checked="checked" ';
558: $showoff = ' ';
559: } else {
560: $showoff = ' checked="checked" ';
561: $showon = ' ';
562: }
563: my %lt = &Apache::lonlocal::texthash (
564: yls => 'Your listing status',
565: yci => 'You are currently included in the coauthor-viewable listing.',
566: iyl => 'Include yourself in the listing?',
567: y => 'Yes',
568: n => 'No',
569: sav => 'Save changes',
570: );
571: my $output =
572: '<div class="LC_left_float">'
573: .'<fieldset><legend>'.$lt{'yls'}.'</legend>';
574: if ($showinlist) {
575: $output .= $lt{'yci'};
576: } else {
577: $output .= &mt('You are currently [_1]not[_2] included in the coauthor-viewable listing.','<b>','</b>');
578: }
579: $output .= '<br />'.$lt{'iyl'}.' '.
580: '<form name="coauthorparm" method="post" action="'.$caller.'">'.
581: '<span class="LC_nobreak">'.
582: '<label><input type="radio" name="showinlist" value="1"'.$showon.'/>'.$lt{'y'}.'</label> <label>'.
583: '<input type="radio" name="showinlist" value="0"'.$showoff.'/>'.$lt{'n'}.
584: '</label></span><br /><br />'.
585: '<input type="hidden" name="action" value="setenv" />'.
586: '<input type="submit" name="coauthorsubmit" value="'.$lt{'sav'}.'" />'.
587: '</form></fieldset></div><br clear="all" />';
588: return $output;
589: }
590:
591: sub process_coauthor_prefs {
592: my ($auname,$audom,$caller) = @_;
593: my $uname = $env{'user.name'};
594: my $udom = $env{'user.domain'};
595: my $user = $uname.':'.$udom;
596: my %shown = &Apache::lonnet::get('showncoauthors',[$user],$audom,$auname);
597: my %lt = &Apache::lonlocal::texthash (
598: on => 'on',
599: off => 'off',
600: err => 'Error occurred saving display setting.',
601: );
602: my $visibility = $lt{'off'};
603: my $showinlist = $env{'form.showinlist'};
604: if ($showinlist) {
605: $visibility = $lt{'on'};
606: }
607: my $listed = 0;
608: if ($shown{$user}) {
609: $listed = 1;
610: }
611:
612: my $output;
613: if ($listed ne $showinlist) {
614: my %changeHash = (
615: "internal.showinlist./$audom/$auname" => $showinlist,
616: );
617: my $putresult = &Apache::lonnet::put('environment',
618: \%changeHash,$udom,$uname);
619: if ($putresult eq 'ok') {
620: &Apache::lonnet::appenv({"environment.internal.showinlist./$audom/$auname" => $showinlist});
621: my $result = &Apache::lonnet::put('showncoauthors',{$user => $showinlist,},$audom,$auname);
622: if ($result eq 'ok') {
623: $output .=
624: &Apache::lonhtmlcommon::confirm_success(
625: &mt("Display of your name in the coauthor-viewable listing set to [_1].",'<b>'.$visibility.'</b>'));
626: } else {
627: $output .= &Apache::lonhtmlcommon::confirm_success($lt{'err'},1);
628: }
629: } else {
630: $output .= &Apache::lonhtmlcommon::confirm_success($lt{'err'},1);
631: }
632: } else {
633: $output .=
634: &Apache::lonhtmlcommon::confirm_success(
635: &mt("Display of your name in the coauthor-viewable listing unchanged (set to [_1]).",'<b>'.$visibility.'</b>'));
636: }
637: $output = &Apache::loncommon::confirmwrapper($output);
638: return $output;
639: }
640:
641: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>