version 1.17, 2007/12/21 12:41:25
|
version 1.21, 2007/12/21 20:34:26
|
Line 771 sub forceid_change {
|
Line 771 sub forceid_change {
|
############################################################### |
############################################################### |
############################################################### |
############################################################### |
sub print_upload_manager_form { |
sub print_upload_manager_form { |
my ($r,$context) = @_; |
my ($r,$context,$permission) = @_; |
my $firstLine; |
my $firstLine; |
my $datatoken; |
my $datatoken; |
if (!$env{'form.datatoken'}) { |
if (!$env{'form.datatoken'}) { |
Line 2423 ENDTWO
|
Line 2423 ENDTWO
|
} |
} |
|
|
sub date_section_selector { |
sub date_section_selector { |
my ($context) = @_; |
my ($context,$permission) = @_; |
my $callingform = $env{'form.callingform'}; |
my $callingform = $env{'form.callingform'}; |
my $formname = 'dateselect'; |
my $formname = 'dateselect'; |
my $groupslist = &get_groupslist(); |
my $groupslist = &get_groupslist(); |
Line 2502 END
|
Line 2502 END
|
$starttime = time; |
$starttime = time; |
} |
} |
$date_items = &date_setting_table($starttime,undef,$context, |
$date_items = &date_setting_table($starttime,undef,$context, |
$env{'form.bulkaction'}); |
$env{'form.bulkaction'},$formname, |
|
$permission); |
} |
} |
$output .= '<h3>'.$headertext.'</h3>'. |
$output .= '<h3>'.$headertext.'</h3>'. |
'<form name="'.$formname.'" method="post">'."\n". |
'<form name="'.$formname.'" method="post">'."\n". |
Line 2536 END
|
Line 2537 END
|
$info = '<input type="hidden" name="retainsec" value="0" />'; |
$info = '<input type="hidden" name="retainsec" value="0" />'; |
} |
} |
my $sections_select .= &course_sections(\%sections_count,$env{'form.showrole'}); |
my $sections_select .= &course_sections(\%sections_count,$env{'form.showrole'}); |
my $secbox = '<p>'.&Apache::lonhtmlcommon::start_pick_box()."\n". |
my $rowtitle = &mt('New section to assign'); |
&Apache::lonhtmlcommon::row_title(&mt('New section to assign'),'LC_oddrow_value')."\n". |
my $secbox = §ion_picker($cdom,$cnum,$env{'form.showrole'},$rowtitle,$permission,$context); |
'<table class="LC_createuser"><tr class="LC_section_row">'."\n". |
|
'<td align="center">'.&mt('Existing sections')."\n". |
|
'<br />'.$sections_select.'</td><td align="center">'. |
|
&mt('New section').'<br />'."\n". |
|
'<input type="text" name="newsec" size="15" />'."\n". |
|
'<input type="hidden" name="sections" value="" />'."\n". |
|
'</td></tr></table>'."\n". |
|
&Apache::lonhtmlcommon::row_closure(1)."\n". |
|
&Apache::lonhtmlcommon::end_pick_box().'</p>'; |
|
$output .= $info.$secbox; |
$output .= $info.$secbox; |
} |
} |
$output .= '<p>'. |
$output .= '<p>'. |
Line 2883 sub print_first_users_upload_form {
|
Line 2875 sub print_first_users_upload_form {
|
|
|
# ================================================= Drop/Add from uploaded file |
# ================================================= Drop/Add from uploaded file |
sub upfile_drop_add { |
sub upfile_drop_add { |
my ($r,$context) = @_; |
my ($r,$context,$permission) = @_; |
&Apache::loncommon::load_tmp_file($r); |
&Apache::loncommon::load_tmp_file($r); |
my @userdata=&Apache::loncommon::upfile_record_sep(); |
my @userdata=&Apache::loncommon::upfile_record_sep(); |
if($env{'form.noFirstLine'}){shift(@userdata);} |
if($env{'form.noFirstLine'}){shift(@userdata);} |
Line 3810 sub can_create_user {
|
Line 3802 sub can_create_user {
|
return $cancreate; |
return $cancreate; |
} |
} |
|
|
|
sub can_modify_userinfo { |
|
my ($context,$dom,$fields,$userroles) = @_; |
|
my %domconfig = |
|
&Apache::lonnet::get_dom('configuration',['usermodification'], |
|
$dom); |
|
my %canmodify; |
|
if (ref($fields) eq 'ARRAY') { |
|
foreach my $field (@{$fields}) { |
|
$canmodify{$field} = 0; |
|
if (&Apache::lonnet::allowed('mau',$dom)) { |
|
$canmodify{$field} = 1; |
|
} else { |
|
if (ref($domconfig{'usermodification'}) eq 'HASH') { |
|
if (ref($domconfig{'usermodification'}{$context}) eq 'HASH') { |
|
if (ref($userroles) eq 'ARRAY') { |
|
foreach my $role (@{$userroles}) { |
|
my $testrole; |
|
if ($role =~ /^cr\//) { |
|
$testrole = 'cr'; |
|
} else { |
|
$testrole = $role; |
|
} |
|
if (ref($domconfig{'usermodification'}{$context}{$testrole}) eq 'HASH') { |
|
if ($domconfig{'usermodification'}{$context}{$testrole}{$field}) { |
|
$canmodify{$field} = 1; |
|
last; |
|
} |
|
} |
|
} |
|
} else { |
|
foreach my $key (keys(%{$domconfig{'usermodification'}{$context}})) { |
|
if (ref($domconfig{'usermodification'}{$context}{$key}) eq 'HASH') { |
|
if ($domconfig{'usermodification'}{$context}{$key}{$field}) { |
|
$canmodify{$field} = 1; |
|
last; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} elsif ($context eq 'course') { |
|
if (ref($userroles) eq 'ARRAY') { |
|
if (grep(/^st$/,@{$userroles})) { |
|
$canmodify{$field} = 1; |
|
} |
|
} else { |
|
$canmodify{$field} = 1; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
return %canmodify; |
|
} |
|
|
|
sub check_usertype { |
|
my ($dom,$uname,$rules) = @_; |
|
my $usertype; |
|
if (ref($rules) eq 'HASH') { |
|
my @user_rules = keys(%{$rules}); |
|
if (@user_rules > 0) { |
|
my %rule_check = &Apache::lonnet::inst_rulecheck($dom,$uname,undef,'username',\@user_rules); |
|
if (keys(%rule_check) > 0) { |
|
$usertype = 'unofficial'; |
|
foreach my $item (keys(%rule_check)) { |
|
if ($rule_check{$item}) { |
|
$usertype = 'official'; |
|
last; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
return $usertype; |
|
} |
|
|
sub roles_by_context { |
sub roles_by_context { |
my ($context,$custom) = @_; |
my ($context,$custom) = @_; |
my @allroles; |
my @allroles; |
Line 3919 sub get_course_identity {
|
Line 3987 sub get_course_identity {
|
return ($cnum,$cdom,$cdesc); |
return ($cnum,$cdom,$cdesc); |
} |
} |
|
|
|
sub dc_setcourse_js { |
|
my ($formname,$mode) = @_; |
|
my $dc_setcourse_code; |
|
my $cctext = &Apache::lonnet::plaintext('cc'); |
|
my %alerts = §ioncheck_alerts(); |
|
my $role = 'role'; |
|
if ($mode eq 'upload') { |
|
$role = 'courserole'; |
|
} |
|
$dc_setcourse_code = (<<"SCRIPTTOP"); |
|
function setCourse() { |
|
var course = document.$formname.dccourse.value; |
|
if (course != "") { |
|
if (document.$formname.dcdomain.value != document.$formname.origdom.value) { |
|
alert("$alerts{'curd'}"); |
|
return; |
|
} |
|
var userrole = document.$formname.$role.options[document.$formname.$role.selectedIndex].value |
|
var section=""; |
|
var numsections = 0; |
|
var newsecs = new Array(); |
|
for (var i=0; i<document.$formname.currsec.length; i++) { |
|
if (document.$formname.currsec.options[i].selected == true ) { |
|
if (document.$formname.currsec.options[i].value != "" && document.$formname.currsec.options[i].value != null) { |
|
if (numsections == 0) { |
|
section = document.$formname.currsec.options[i].value |
|
numsections = 1; |
|
} |
|
else { |
|
section = section + "," + document.$formname.currsec.options[i].value |
|
numsections ++; |
|
} |
|
} |
|
} |
|
} |
|
if (document.$formname.newsec.value != "" && document.$formname.newsec.value != null) { |
|
if (numsections == 0) { |
|
section = document.$formname.newsec.value |
|
} |
|
else { |
|
section = section + "," + document.$formname.newsec.value |
|
} |
|
newsecs = document.$formname.newsec.value.split(/,/g); |
|
numsections = numsections + newsecs.length; |
|
} |
|
if ((userrole == 'st') && (numsections > 1)) { |
|
alert("$alerts{'inea'}. $alerts{'youh'} "+numsections+" $alerts{'sect'}.\\n$alerts{'plsm'}.") |
|
return; |
|
} |
|
for (var j=0; j<newsecs.length; j++) { |
|
if ((newsecs[j] == 'all') || (newsecs[j] == 'none')) { |
|
alert("'"+newsecs[j]+"' $alerts{'mayn'}.\\n$alerts{'plsc'}."); |
|
return; |
|
} |
|
if (document.$formname.groups.value != '') { |
|
var groups = document.$formname.groups.value.split(/,/g); |
|
for (var k=0; k<groups.length; k++) { |
|
if (newsecs[j] == groups[k]) { |
|
alert("'"+newsecs[j]+"' $alerts{'mayt'}.\\n$alerts{'secn'}. $alerts{'plsc'}."); |
|
return; |
|
} |
|
} |
|
} |
|
} |
|
if ((userrole == 'cc') && (numsections > 0)) { |
|
alert("$alerts{'secd'} $cctext $alerts{'role'}.\\n$alerts{'accr'}."); |
|
section = ""; |
|
} |
|
SCRIPTTOP |
|
if ($mode ne 'upload') { |
|
$dc_setcourse_code .= (<<"ENDSCRIPT"); |
|
var coursename = "_$env{'request.role.domain'}"+"_"+course+"_"+userrole |
|
var numcourse = getIndex(document.$formname.dccourse); |
|
if (numcourse == "-1") { |
|
alert("$alerts{'thwa'}"); |
|
return; |
|
} |
|
else { |
|
document.$formname.elements[numcourse].name = "act"+coursename; |
|
var numnewsec = getIndex(document.$formname.newsec); |
|
if (numnewsec != "-1") { |
|
document.$formname.elements[numnewsec].name = "sec"+coursename; |
|
document.$formname.elements[numnewsec].value = section; |
|
} |
|
var numstart = getIndex(document.$formname.start); |
|
if (numstart != "-1") { |
|
document.$formname.elements[numstart].name = "start"+coursename; |
|
} |
|
var numend = getIndex(document.$formname.end); |
|
if (numend != "-1") { |
|
document.$formname.elements[numend].name = "end"+coursename |
|
} |
|
} |
|
} |
|
document.$formname.submit(); |
|
} |
|
|
|
ENDSCRIPT |
|
} else { |
|
$dc_setcourse_code .= " |
|
document.$formname.sections.value = section; |
|
} |
|
return 'ok'; |
|
} |
|
"; |
|
} |
|
$dc_setcourse_code .= (<<"ENDSCRIPT"); |
|
|
|
function getIndex(caller) { |
|
for (var i=0;i<document.$formname.elements.length;i++) { |
|
if (document.$formname.elements[i] == caller) { |
|
return i; |
|
} |
|
} |
|
return -1; |
|
} |
|
ENDSCRIPT |
|
} |
|
|
|
sub sectioncheck_alerts { |
|
my %alerts = &Apache::lonlocal::texthash( |
|
curd => 'You must select a course in the current domain', |
|
inea => 'In each course, each user may only have one student role at a time', |
|
youh => 'You had selected', |
|
sect => 'sections', |
|
plsm => 'Please modify your selections so they include no more than one section', |
|
mayn => 'may not be used as the name for a section, as it is a reserved word', |
|
plsc => 'Please choose a different section name', |
|
mayt => 'may not be used as the name for a section, as it is the name of a course group', |
|
secn => 'Section names and group names must be distinct', |
|
secd => 'Section designations do not apply to ', |
|
role => 'roles', |
|
accr => 'role will be added with access to all sections', |
|
thwa => 'There was a problem with your course selection' |
|
); |
|
return %alerts; |
|
} |
|
|
|
|
1; |
1; |