Subversion Repositories ORC

Rev

Rev 25 | Rev 31 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 25 Rev 29
Line 60... Line 60...
60
 
60
 
61
sub process_form {
61
sub process_form {
62
  my $F = shift // "";
62
  my $F = shift // "";
Line 63... Line 63...
63
  push @ERRORS, "Tried to save an empty form." and return unless $F;
63
  push @ERRORS, "Tried to save an empty form." and return unless $F;
64
 
64
 
65
	$F->{email}       = WebDB::trim param ('email')      // '';
65
	$F->{email}       = lc WebDB::trim param ('email')   // '';
66
	$F->{password}    = WebDB::trim param ('password')   // '';
66
	$F->{password}    = WebDB::trim param ('password')   // '';
67
	$F->{derby_name}  = WebDB::trim param ('derby_name') // '';
67
	$F->{derby_name}  = WebDB::trim param ('derby_name') // '';
68
	$F->{real_name}   = WebDB::trim param ('real_name')  // '';
68
	$F->{real_name}   = WebDB::trim param ('real_name')  // '';
Line 132... Line 132...
132
 
132
 
133
      if ($F->{password}) { # They've possibly included an updated password.
133
      if ($F->{password}) { # They've possibly included an updated password.
134
#    		my $sth = $dbh->prepare("replace into official (RCid, email, password, derby_name, real_name, phone, level, type, access, department, clinic_pass) values (?, ?, password(?), ?, ?, ?, ?, ?, ?, ?, ?)");
134
#    		my $sth = $dbh->prepare("replace into official (RCid, email, password, derby_name, real_name, phone, level, type, access, department, clinic_pass) values (?, ?, password(?), ?, ?, ?, ?, ?, ?, ?, ?)");
135
#    		$sth->execute ($F->{RCid}, $EM, $F->{password}, $F->{derby_name}, $F->{real_name}, $F->{phone}, $F->{level}, $F->{type}, $F->{access}, $F->{department}, $F->{clinic_pass})
135
#    		$sth->execute ($F->{RCid}, $EM, $F->{password}, $F->{derby_name}, $F->{real_name}, $F->{phone}, $F->{level}, $F->{type}, $F->{access}, $F->{department}, $F->{clinic_pass})
136
    		my $sth = $dbh->prepare("replace into official (RCid, email, password, derby_name, real_name, pronouns, tshirt, phone, access, department, added, last_login) values (?, ?, password(?), ?, ?, ?, ?, ?, ?, ?, ?, ?)");
136
    		my $sth = $dbh->prepare("replace into official (RCid, email, password, derby_name, real_name, pronouns, tshirt, phone, access, department, added, last_login) values (?, ?, password(?), ?, ?, ?, ?, ?, ?, ?, ?, ?)");
137
    		$sth->execute ($F->{RCid}, $EM, $F->{password}, $F->{derby_name}, $F->{real_name}, $F->{pronouns}, $F->{tshirt}, $F->{phone}, $F->{access}, $F->{department}, getUser($EM)->{added}, getUser($EM)->{last_login})
137
    		$sth->execute ($F->{RCid}, lc $EM, $F->{password}, $F->{derby_name}, $F->{real_name}, $F->{pronouns}, $F->{tshirt}, $F->{phone}, $F->{access}, $F->{department}, getUser($EM)->{added}, getUser($EM)->{last_login})
138
    			or $ERRMSG = "ERROR: Can't execute SQL statement: ".$sth->errstr()."\n";
138
    			or $ERRMSG = "ERROR: Can't execute SQL statement: ".$sth->errstr()."\n";
139
    	} else { # No password was included, just keep the existing one.
139
    	} else { # No password was included, just keep the existing one.
140
#    		my $sth = $dbh->prepare("replace into official (RCid, email, password, derby_name, real_name, phone, level, type, access, department, clinic_pass) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
140
#    		my $sth = $dbh->prepare("replace into official (RCid, email, password, derby_name, real_name, phone, level, type, access, department, clinic_pass) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
141
#    		$sth->execute($F->{RCid}, $EM, $PWD, $F->{derby_name}, $F->{real_name}, $F->{phone}, $F->{level}, $F->{type}, $F->{access}, $F->{department}, $F->{clinic_pass})
141
#    		$sth->execute($F->{RCid}, $EM, $PWD, $F->{derby_name}, $F->{real_name}, $F->{phone}, $F->{level}, $F->{type}, $F->{access}, $F->{department}, $F->{clinic_pass})
142
    		my $sth = $dbh->prepare("replace into official (RCid, email, password, derby_name, real_name, pronouns, tshirt, phone, access, department, added, last_login) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
142
    		my $sth = $dbh->prepare("replace into official (RCid, email, password, derby_name, real_name, pronouns, tshirt, phone, access, department, added, last_login) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
143
    		$sth->execute($F->{RCid}, $EM, $PWD, $F->{derby_name}, $F->{real_name}, $F->{pronouns}, $F->{tshirt}, $F->{phone}, $F->{access}, $F->{department}, getUser($EM)->{added}, getUser($EM)->{last_login})
143
    		$sth->execute($F->{RCid}, lc $EM, $PWD, $F->{derby_name}, $F->{real_name}, $F->{pronouns}, $F->{tshirt}, $F->{phone}, $F->{access}, $F->{department}, getUser($EM)->{added}, getUser($EM)->{last_login})
144
    			or $ERRMSG = "ERROR: Can't execute SQL statement: ".$sth->errstr()."\n";
144
    			or $ERRMSG = "ERROR: Can't execute SQL statement: ".$sth->errstr()."\n";
Line 145... Line 145...
145
    	}
145
    	}
146
 
146
 
Line 177... Line 177...
177
				logit ($F->{RCid}, "Updated User Details (by ".getUser($EM)->{derby_name}.")");
177
				logit ($F->{RCid}, "Updated User Details (by ".getUser($EM)->{derby_name}.")");
178
				logit (getUser($EM)->{RCid}, "Updated User Details: ".$F->{derby_name}." (".$F->{RCid}.")");
178
				logit (getUser($EM)->{RCid}, "Updated User Details: ".$F->{derby_name}." (".$F->{RCid}.")");
179
			}
179
			}
180
		} else {
180
		} else {
181
			$ERRMSG = "Attempting to update someone else's record, and you don't have permission to do that.";
181
			$ERRMSG = "Attempting to update someone else's record, and you don't have permission to do that.";
182
			logit ($F->{RCid}, "FAIL: $EM doesn't have access to update $FORM->{email}'s record");
182
			logit ($F->{RCid}, "FAIL: ($EM) doesn't have access to update ($F->{email})'s record");
183
		}
183
		}
184
	}
184
	}
185
	$F->{password} = "*******";
185
	$F->{password} = "*******";
186
	$F->{buttons}		= $h->input ({ type=>"hidden", name=>"RCid", value=>$F->{RCid} }).$h->input ({ type=>"submit", name=>"submit", value=>"Edit" });
186
	$F->{buttons}		= $h->input ({ type=>"hidden", name=>"RCid", value=>$F->{RCid} }).$h->input ({ type=>"submit", name=>"submit", value=>"Edit" });
187
#	my $checked = $F->{clinic_pass} ? "checked" : "";
187
#	my $checked = $F->{clinic_pass} ? "checked" : "";
Line 237... Line 237...
237
  		$F->{buttons}		 = join " ", $h->input ({ type=>"submit", name=>"submit", value=>"Save" }), $h->input ({ type=>"reset", value=>"Reset" }), $h->input ({ type=>"submit", name=>"submit", value=>"Cancel" });
237
  		$F->{buttons}		 = join " ", $h->input ({ type=>"submit", name=>"submit", value=>"Save" }), $h->input ({ type=>"reset", value=>"Reset" }), $h->input ({ type=>"submit", name=>"submit", value=>"Cancel" });
Line 238... Line 238...
238
  		  		
238
  		  		
239
    	$F->{department} = convertDepartments ($F->{department});
239
    	$F->{department} = convertDepartments ($F->{department});
240
    	$currentuser->{department} = convertDepartments ($currentuser->{department});
240
    	$currentuser->{department} = convertDepartments ($currentuser->{department});
-
 
241
    	foreach my $k (keys %{$depts}) {
241
    	foreach my $k (keys %{$depts}) {
242
    	  next if $k eq "CMP";
242
    	  if ($currentuser->{access} > 4) {
243
    	  if ($currentuser->{access} > 4) {
243
    	    # SysAdmin can change anyone's department level
244
    	    # SysAdmin can change anyone's department level
244
    	    $F->{department}->{$k} = $h->select ({ name=>"DEPT-".$k }, [ $h->option ({ value=>"" }, ""), map { $_ eq $F->{department}->{$k} ? $h->option ({ value=>$_, selected=>[] }, $AccessLevel->{$_}) : $h->option ({ value=>$_ }, $AccessLevel->{$_}) } (0..4) ]);
245
    	    $F->{department}->{$k} = $h->select ({ name=>"DEPT-".$k }, [ $h->option ({ value=>"" }, ""), map { $_ eq $F->{department}->{$k} ? $h->option ({ value=>$_, selected=>[] }, $AccessLevel->{$_}) : $h->option ({ value=>$_ }, $AccessLevel->{$_}) } (0..4) ]);
245
    	  } elsif ($currentuser->{department}->{$k} > 1 and $currentuser->{department}->{$k} > $F->{department}->{$k}) {
246
    	  } elsif ($currentuser->{department}->{$k} > 1 and $currentuser->{department}->{$k} > $F->{department}->{$k}) {
Line 257... Line 258...
257
  	} else {
258
  	} else {
258
  		$ERRMSG = "Attempting to update someone else's record, and you don't have permission to do that.";
259
  		$ERRMSG = "Attempting to update someone else's record, and you don't have permission to do that.";
259
  	}
260
  	}
Line 260... Line 261...
260
 
261
 
-
 
262
  } elsif ($view eq 'New User') {
261
  } elsif ($view eq 'New User') {
263
    $errors = $h->br."NOTE: You will not be able to login until your account has been reviewed and approved. Watch your email for notification.";
262
  	# Skip authentication
264
  	# Skip authentication
263
 		$F->{email}      = $h->input ({ type=>"text", name=>"email", value=>$F->{email} });
265
 		$F->{email}      = $h->input ({ type=>"text", name=>"email", value=>$F->{email} });
264
 		$F->{password}   = $h->input ({ type=>"password", name=>"password" });
266
 		$F->{password}   = $h->input ({ type=>"password", name=>"password" });
265
 		$F->{derby_name} = $h->input ({ type=>"text", name=>"derby_name", value=>$F->{derby_name} });
267
 		$F->{derby_name} = $h->input ({ type=>"text", name=>"derby_name", value=>$F->{derby_name} });
Line 271... Line 273...
271
#  	$F->{type}       = "<SELECT NAME=type>".selectOptions ($F->{type}, ["", qw(official nso referee)])."</SELECT>";
273
#  	$F->{type}       = "<SELECT NAME=type>".selectOptions ($F->{type}, ["", qw(official nso referee)])."</SELECT>";
272
 		$F->{RCid}         = $h->input ({ type=>"hidden", name=>"RCid", value=>"New" })."TBD&nbsp;";
274
 		$F->{RCid}         = $h->input ({ type=>"hidden", name=>"RCid", value=>"New" })."TBD&nbsp;";
273
  	$F->{access}			= $h->input ({ type=>"hidden", name=>"access", value=>0 })."0";
275
  	$F->{access}			= $h->input ({ type=>"hidden", name=>"access", value=>0 })."0";
274
#  	$F->{clinic_pass}	= "<INPUT type='checkbox' name='clinic_pass' disabled readonly>";
276
#  	$F->{clinic_pass}	= "<INPUT type='checkbox' name='clinic_pass' disabled readonly>";
275
  	foreach (keys %{$depts}) {
277
  	foreach (keys %{$depts}) {
-
 
278
  	  next if $_ eq "CMP";
276
  	  if (defined param ("DEPT-$_")) {
279
  	  if (defined param ("DEPT-$_")) {
277
  	    $F->{department}->{$_} = $h->label ({ class=>"switch" }, [$h->input ({ type=>"checkbox", name=>"DEPT-$_", value=>0, checked=>[] }), $h->span ({ class=>"slider round" })]);
280
  	    $F->{department}->{$_} = $h->label ({ class=>"switch" }, [$h->input ({ type=>"checkbox", name=>"DEPT-$_", value=>0, checked=>[] }), $h->span ({ class=>"slider round" })]);
278
  	  } else {
281
  	  } else {
279
  	    $F->{department}->{$_} = $h->label ({ class=>"switch" }, [$h->input ({ type=>"checkbox", name=>"DEPT-$_", value=>0 }), $h->span ({ class=>"slider round" })]);
282
  	    $F->{department}->{$_} = $h->label ({ class=>"switch" }, [$h->input ({ type=>"checkbox", name=>"DEPT-$_", value=>0 }), $h->span ({ class=>"slider round" })]);
280
  	  }
283
  	  }
Line 404... Line 407...
404
	my $context = shift;
407
	my $context = shift;
405
	my $data = shift;
408
	my $data = shift;
406
	use RCMailer;
409
	use RCMailer;
Line 407... Line 410...
407
 
410
 
408
	my $email = $data->{email};
411
	my $email = $data->{email};
409
	my $subject = 'Officiating RollerCon Schedule Manager - New User Request';
412
	my $subject = 'RollerCon Volunteer Schedule Manager - New User';
410
	my $body;
413
	my $body;
-
 
414
	if ($context eq "New User") {
411
	if ($context eq "New User") {
415
    $subject .= " Request";
Line 412... Line 416...
412
	  $body = "Greetings,
416
	  $body = "Greetings,
Line 413... Line 417...
413
 
417
 
Line 433... Line 437...
433
If you didn't make this request, well, you're still the only one who received this email, and you now have an account request.  You should probably let us know that someone is messing with you.
437
If you didn't make this request, well, you're still the only one who received this email, and you now have an account request.  You should probably let us know that someone is messing with you.
Line 434... Line 438...
434
 
438
 
435
-RollerCon Management
439
-RollerCon Management
436
";
440
";
-
 
441
  } elsif ($context eq "Activate") {
437
  } elsif ($context eq "Activate") {
442
    $subject .= " Activated!";
438
    my $tempDepartments = convertDepartments ($data->{department});
443
    my $tempDepartments = convertDepartments ($data->{department});
439
    my $printableDepartments = join "\n", map { $depts->{$_}.": ".$AccessLevel->{$tempDepartments->{$_}} } sort keys %{$tempDepartments};
444
    my $printableDepartments = join "\n", map { $depts->{$_}.": ".$AccessLevel->{$tempDepartments->{$_}} } sort keys %{$tempDepartments};
Line 440... Line 445...
440
    $body = "Greetings again,
445
    $body = "Greetings again,