예제 #1
0
/**
 * create a new member and let it become participant of the supplied ballot
 *
 * @param Period  $period
 * @param mixed   $ballot Ballot, true or null
 * @param integer $case
 * @param string  $i
 */
function add_participant(Period $period, $ballot, $case, $i) {
	global $date, $password;

	Login::$member = new Member;
	Login::$member->invite = Login::generate_token(24);
	Login::$member->eligible = true;
	Login::$member->verified = true;
	Login::$member->create();
	Login::$member->username = "******".$date."c".$case."p".(is_object($ballot)?$ballot->id:$ballot).$i;
	Login::$member->password = $password;
	$update_fields = array('username', 'password', 'eligible');

	// Enable this only in local development environment, because it may lead to a lot if notification mails!
	//Login::$member->mail = ERROR_MAIL;
	//$update_fields[] = "mail";

	Login::$member->update($update_fields, 'activated=now()');
	Login::$member->update_ngroups([1]);
	if ($ballot) {
		if (is_object($ballot)) $period->select_ballot($ballot); else $period->select_postal();
	}
}
예제 #2
0
			break;
		}
		if ($ballot->id) {
			$ballot->update();
		} else {
			if ($period->state=="ballot_assignment") {
				warning(_("Ballot assignment has already begun, so ballot applications are not allowed anymore."));
				redirect("ballots.php?period=".$period->id);
			}
			$ballot->create();
			if (!$ballot->id) {
				warning(_("The ballot could not be created!"));
				redirect();
			}
		}
		$period->select_ballot($ballot, true);
		redirect("ballots.php?period=".$period->id);

	default:
		warning(_("Unknown action"));
		redirect();
	}
}


if ($ballot->id) {
	html_head(sprintf(_("Edit Ballot %d"), $ballot->id), true);
} else {
	html_head(_("New ballot"), true);
}
예제 #3
0
		Login::access_action("entitled", $_SESSION['ngroup']);
		action_required_parameters('ballot');
		$ballot = new Ballot($_POST['ballot']);
		if (!$ballot->id) {
			warning("The requested area does not exist!");
			redirect();
		}
		if ($period->state=="ballot_preparation") {
			warning(_("In ballot preparation phase it is not allowed anymore to select or change the ballot."));
			redirect();
		}
		if ($period->state=="ballot_assignment" and !$ballot->approved) {
			warning(_("In ballot assignment phase it is only allowed to select approved ballots."));
			redirect();
		}
		$period->select_ballot($ballot);
		redirect();
		break;
	case "select_postal":
		Login::access_action("entitled", $_SESSION['ngroup']);
		if ($period->state=="ballot_preparation") {
			warning(_("In ballot preparation phase it is not allowed anymore to select postal voting."));
			redirect();
		}
		$period->select_postal();
		redirect();
		break;
	case "unselect":
		Login::access_action("entitled", $_SESSION['ngroup']);
		if ($period->state=="ballot_preparation") {
			warning(_("In ballot preparation phase it is not allowed anymore to change the ballot choice."));