function convertVote( $store, $record ) {
		if ( $this->crypt ) {
			$status = $this->crypt->decrypt( $record );
			if ( !$status->isOK() ) {
				return $status;
			}
			$record = $status->value;
		}
		$record = rtrim( $record );
		$record = $this->ballot->convertRecord( $record );
		if ( $record === false ) {
			spFatal( 'Error: missing question in vote record' );
		}
		foreach ( $record as $qid => $qrecord ) {
			$this->votes[$qid][] = $qrecord;
		}
		return Status::newGood();
	}
	}
	$electionIds = $context->getStore()->getAllElectionIds();
	if ( !count( $electionIds ) ) {
		spFatal( "No elections found in XML file \"{$args[0]}\"" );
	}
	$election = $context->getElection( reset( $electionIds ) );
} else {
	$election = $context->getElectionByTitle( $options['name'] );
	if ( !$election ) {
		spFatal( "The specified election does not exist." );
	}
}

$tallier = new SecurePoll_CommentDumper( $context, $election, false );
$status = $tallier->execute();
if ( !$status->isOK() ) {
	spFatal( "Tally error: " . $status->getWikiText() );
}
//$tallier = $status->value;
if ( isset( $options['html'] ) ) {
	echo $tallier->getHtmlResult();
} else {
	echo $tallier->getTextResult();
}


function spFatal( $message ) {
	fwrite( STDERR, rtrim( $message ) . "\n" );
	exit( 1 );
}
Esempio n. 3
0
$confXml = $election->getConfXml( array(
	'jump' => isset( $options['jump'] ),
	'langs' => $langs 
) );

$cbdata = array(
	'header' => "<SecurePoll>\n<election>\n$confXml",
	'outFile' => $outFile
);
$election->cbdata = $cbdata;

# Write vote records
if ( isset( $options['votes'] ) ) {
	$status = $election->dumpVotesToCallback( 'spDumpVote' );
	if ( !$status->isOK() ) {
		spFatal( $status->getWikiText() );
	}
}
if ( $election->cbdata['header'] ) {
	fwrite( $outFile, $election->cbdata['header'] );
}

fwrite( $outFile, "</election>\n</SecurePoll>\n" );

function spFatal( $message ) {
	fwrite( STDERR, rtrim( $message ) . "\n" );
	exit( 1 );
}

function spDumpVote( $election, $row ) {
	if ( $election->cbdata['header'] ) {