Ejemplo n.º 1
0
$message = "";
global $session;
if ($session->is_logged_in()) {
    $message = "logged in";
} else {
    $message = "not logged in";
}
?>
 <?php 
echo $message;
?>
<link rel="stylesheet" href="../stylesheets/styles.css" media="screen" />
<div id="divTable" align="center">
<!--PRESIDENT-->
<?php 
$nominees = Nominee::get_all_by_position("President");
if (count($nominees) <= 0) {
    $message = "No Nominees";
}
echo output_message($message);
?>
<table border="1">
  <tr>
 	<th>Action</th>
    <th>Name</th>
    <th>Position</th>
    <th>Year Level</th>
    <th>Section</th>
    <th>Votes</th>
  </tr>
  <?php 
Ejemplo n.º 2
0
<?php

require_once "initialize.php";
global $session;
if ($session->is_logged_in()) {
    if (isset($_GET['nominee_id']) && isset($_GET['position'])) {
        $nominee_id = (int) $_GET['nominee_id'];
        $nominee_position = $_GET['position'];
        if (previously_voted($session->user_id, $nominee_id, $nominee_position) == true) {
            //1 = true
            Nominee::un_vote($nominee_id);
            Vote::delete_vote($session->user_id, $nominee_id, $nominee_position);
        } else {
            if (can_vote($session->user_id, $nominee_position) == true) {
                // 0 = true
                Nominee::add_vote($nominee_id);
                $vote = new Vote();
                $vote->user_id = $session->user_id;
                $vote->nominee_id = $nominee_id;
                $vote->nominee_position = $nominee_position;
                $vote->create();
            }
        }
    }
    redirect_to("../public/index.php?prev=" . previously_voted($session->user_id, $nominee_id, $nominee_position) . "&can_vote=" . can_vote($session->user_id, $nominee_position));
} else {
    redirect_to("../public/index.php");
}
function previously_voted($user_id, $nominee_id, $nominee_pos)
{
    global $db;