Source for file new.php
Documentation is available at new.php
auth_require ('pear.election', 'pear.admin');
$years = array ($year-- , $year);
if (!isset ($_POST['step'])) {
require PEARWEB_TEMPLATEDIR . '/election/new-step1.tpl.php';
} elseif ($_POST['step'] == 2 ) {
require 'election/pear-election.php';
$election = new PEAR_Election;
$error = $election->validateStep1 ();
$info['purpose'] = $_POST['purpose'];
$info['detail'] = $_POST['detail'];
$info['choices'] = (int) $_POST['choices'];
$info['year'] = (int) $_POST['year'];
$info['month'] = $_POST['month'];
$info['day'] = $_POST['day'];
$info['length'] = (int) $_POST['length'];
$info['minimum'] = (int) $_POST['minimum'];
$info['maximum'] = (int) $_POST['maximum'];
$info['eligiblevoters'] = (int) $_POST['eligiblevoters'];
require PEARWEB_TEMPLATEDIR . '/election/new-step1.tpl.php';
for ($i = 1; $i <= $info['choices']; $i++ ) {
$info['summary' . $i] = empty ($_POST['summary' . $i]) ? '' : $_POST['summary' . $i];
$info['summary_link' . $i] =
empty ($_POST['summary_link' . $i]) ? '' : $_POST['summary_link' . $i];
require PEARWEB_TEMPLATEDIR . '/election/new-step2.tpl.php';
} elseif ($_POST['step'] == 3 ) {
require 'election/pear-election.php';
$election = new PEAR_Election;
$error = $election->validateStep1 ();
$info['purpose'] = $_POST['purpose'];
$info['detail'] = $_POST['detail'];
$info['choices'] = (int) $_POST['choices'];
$info['year'] = (int) $_POST['year'];
$info['month'] = $_POST['month'];
$info['day'] = $_POST['day'];
$info['length'] = (int) $_POST['length'];
$info['minimum'] = (int) $_POST['minimum'];
$info['maximum'] = (int) $_POST['maximum'];
$info['eligiblevoters'] = (int) $_POST['eligiblevoters'];
// this should never happen. It will only occur
// if the user manually fills POST data without going
// through the official form, and makes a mistake.
require PEARWEB_TEMPLATEDIR . '/election/new-step1.tpl.php';
$error = $election->validateStep2 ();
$info['choices'] = (int) $_POST['choices'];
for ($i = 1; $i <= $info['choices']; $i++ ) {
$info['summary' . $i] = empty ($_POST['summary' . $i]) ? '' : $_POST['summary' . $i];
$info['summary_link' . $i] =
empty ($_POST['summary_link' . $i]) ? '' : $_POST['summary_link' . $i];
require PEARWEB_TEMPLATEDIR . '/election/new-step2.tpl.php';
require PEARWEB_TEMPLATEDIR . '/election/new-step3.tpl.php';
} elseif ($_POST['step'] == 4 ) {
if (isset ($_POST['cancel'])) {
require 'election/pear-voter.php';
$currentelections = $voter->listCurrentElections ();
$completedelections = $voter->listCompletedElections ();
$allelections = $voter->listAllElections ();
$error = 'Election creation cancelled';
require PEARWEB_TEMPLATEDIR . '/election/vote.tpl.php';
require 'election/pear-election.php';
$election = new PEAR_Election;
$error = $election->validateStep1 ();
$info['purpose'] = $_POST['purpose'];
$info['detail'] = $_POST['detail'];
$info['choices'] = (int) $_POST['choices'];
$info['year'] = (int) $_POST['year'];
$info['month'] = $_POST['month'];
$info['day'] = $_POST['day'];
$info['length'] = (int) $_POST['length'];
$info['minimum'] = (int) $_POST['minimum'];
$info['maximum'] = (int) $_POST['maximum'];
$info['eligiblevoters'] = (int) $_POST['eligiblevoters'];
// this should never happen. It will only occur
// if the user manually fills POST data without going
// through the official form, and makes a mistake.
require PEARWEB_TEMPLATEDIR . '/election/new-step1.tpl.php';
for ($i = 1; $i <= $info['choices']; $i++ ) {
$info['summary' . $i] = empty ($_POST['summary' . $i]) ? '' : $_POST['summary' . $i];
$info['summary_link' . $i] =
empty ($_POST['summary_link' . $i]) ? '' : $_POST['summary_link' . $i];
$error = $election->validateStep2 ();
// this should never happen. It will only occur
// if the user manually fills POST data without going
// through the official form, and makes a mistake.
require PEARWEB_TEMPLATEDIR . '/election/new-step2.tpl.php';
$election->saveNewElection ();
require 'election/pear-voter.php';
$currentelections = $voter->listCurrentElections ();
$completedelections = $voter->listCompletedElections ();
$allelections = $voter->listAllElections ();
$info = 'Election saved';
require PEARWEB_TEMPLATEDIR . '/election/vote.tpl.php';
Documentation generated on Mon, 11 Mar 2019 15:34:35 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|