Ejemplo n.º 1
0
 //get user_id
 $user_id = user_id($myemail);
 //check if user is in anyway attached to the election
 if (concluded($election["election_end_date"], $election["election_time_to"], 0)) {
     echo 'This election has been concluded.';
 } elseif ($openness == 1 && concluded($election["election_start_date"], $election["election_time_from"], 0)) {
     echo 'Voting for this election has commenced.';
 } elseif ($openness == 1 && concluded($election["election_start_date"], $election["election_time_from"], 3600)) {
     echo 'Voting for this election will commence in less an hour.Therefore your request cannot be processed.';
 } elseif (attached("request", $user_id, $election["election_id"]) === "request") {
     echo 'You have already sent a request to the admin of this election.Just hold on till your request is granted.Thank you.';
 } elseif (attached("election", $user_id, $election["election_id"]) == "election") {
     echo 'You are the admin of this election.You cannot send a request to yourself.';
 } elseif (attached("invites", $user_id, $election["election_id"]) === "invites") {
     echo 'You are already invited for this election.';
 } elseif (attached("joined", $user_id, $election["election_id"]) === "joined") {
     echo '<span >You have joined this election.There is no need to send request.Thank you.</span>';
 } else {
     #if open,add to joined. if closed,add to request
     $election_id = $election["election_id"];
     if ($openness == 1) {
         $query = "INSERT INTO request (user_id,election_id) VALUES ('{$user_id}','{$election_id}')";
         $success_message = '<p style="color: #008000">Request has been passed  to the admin successfully.</p>';
     } elseif ($openness == 2) {
         $query = "INSERT INTO joined (user_id,election_id) VALUES ('{$user_id}','{$election_id}')";
         $success_message = '<p style="color: #008000">You have successfully joined this open election.</p>';
     }
     if ($connection1->query($query)) {
         echo $success_message;
     } else {
         echo 'Request processing not successful.The problem will be fixed soon.Contact the admin to add you up.';
Ejemplo n.º 2
0
$check->execute();
$check->setFetchMode(PDO::FETCH_ASSOC);
$this_election = $check->fetchAll();
if (empty($this_election) && $error_msg == '') {
    //redirect to maindashboard
    header("Location:maindashboard.php");
} else {
    $this_election = $this_election[0];
    $privacy_degree = $this_election['privacy'];
    $_SESSION['election_id'] = $this_election['election_id'];
    //get user_id
    $user_id = user_id($myemail);
    $_SESSION['user_id'] = $user_id;
    $attachment = ['joined', 'request'];
    for ($i = 0; $i < 2; $i++) {
        $attach = attached($attachment[$i], $user_id, $_SESSION['election_id']);
        if ($attach != null) {
            break;
        }
    }
    if ($attach == 'joined') {
        $error_msg = '<span class="error">You have already joined this election. Reload your main
                                            browser to see the effect.
                         </span>';
    } elseif ($attach == 'request') {
        $error_msg = '<span class="error">Your request has been processed. Reload your main
                                            browser to see the effect.
                         </span>';
    }
    //get admin details
    $admin_id = $this_election['user_id'];
 $admin->execute();
 $admin->setFetchMode(PDO::FETCH_ASSOC);
 $admin = $admin->fetchAll()[0];
 $election_name = $admin['election_name'];
 $sender_name = strtoupper($admin['admin_fname']) . " " . $admin['admin_lname'];
 //get recipient
 $recipient = getAllMembers('users', ['*'], ['user_id', '=', $sender_id])[0];
 $recipient_address = $recipient['email'];
 $recipient_name = strtoupper($recipient['fname']) . " " . $recipient['lname'];
 $mail_subject = "Your request to join " . $election_name . " has been ";
 //delete request
 $delete_request_query = "DELETE FROM request WHERE user_id='{$sender_id}' AND election_id='{$election_id}'";
 if ($connection1->query($delete_request_query)) {
     if ($_POST["action"] === "accept") {
         //check if user has not been added to the election before
         if (attached('joined', $sender_id, $election_id) != 'joined') {
             //add sender to joined
             $adding_sender_query = "INSERT INTO joined(user_id,election_id) VALUES ('{$sender_id}','{$election_id}')";
             if ($connection1->query($adding_sender_query)) {
                 //send notification
                 $mail_subject .= "granted.";
                 $mail_body = "Hello " . $recipient['username'] . ".<br>\n                                                This is to notify you that " . $sender_name . "; the administrator of " . $election_name . "\n                                                has granted your request to join " . $election_name . ". Therefore, you are\n                                                now a valid voter in the election. <a href='http://evoting.oauife.edu.ng'>Login into your account.</a>\n                                                now to view the latest about the election.<br><br> We will like to remind\n                                                you that, at <a href='http://evoting.oauife.edu.ng'>OAU E-voting system</a>, it\n                                                is our responsibility to provide a reliable and trustworthy one-man-one-vote\n                                                online voting system for you always. Thank you.";
                 sendEmail($recipient_address, $recipient_name, $mail_subject, $mail_body);
                 echo 'user has been successfully added to election.';
             }
         }
     } elseif ($_POST["action"] == "reject") {
         //send notification
         $mail_subject .= "rejected.";
         $mail_body = "Hello " . $recipient['username'] . ".<br>\n                                                This is to notify you that " . $sender_name . "; the administrator of " . $election_name . "\n                                                has rejected your request to join " . $election_name . ". The possible cause\n                                                of this might be either you are not meant to be a voter in this election\n                                                or you did not meet-up to the necessary requirements, as stated by the\n                                                administrator of this election, needed to be a valid voter in this election.\n                                                Whatever the case may be, the administrators best understands why your\n                                                request was rejected.<br><br> We will like to remind you that, at\n                                                <a href='http://evoting.oauife.edu.ng'>OAU E-voting system</a>, it is our\n                                                responsibility to provide a reliable and trustworthy one-man-one-vote\n                                                online voting system for you always. Thank you.\n                                                <a href='http://evoting.oauife.edu.ng'>Login into your account.</a>";
         sendEmail($recipient_address, $recipient_name, $mail_subject, $mail_body);
include_once '../php/post_news.php';
include_once '../php/view_contestant.php';
include_once "../php/vote.php";
include_once "../php/database.php";
//check if election exists
$election_id = $_SESSION["election_id"];
$user_id = user_id($myemail);
$election = getElectionDetails($election_id);
$joined = getAllMembers("joined", ["*"], ["user_id", "=", $user_id], 0, "AND", ["election_id", "=", $election_id]);
if (count($election) == 0 | count($joined) == 0) {
    //that means the election does not exist or the user is not joined to the election
    header("Location:maindashboard.php");
}
// check if contestant or voter
$adekagun = "Voter";
if (attached("contestants", user_id($myemail), $_SESSION["election_id"]) === "contestants") {
    $adekagun = 'Contestant';
}
$_SESSION['adek_link'] = 'election_detailsNews.php?key=' . $_SESSION['election_key'];
$_SESSION['adek_status'] = $adekagun;
?>
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">

<head>
    <style type="text/css">

        .numbers {
          /*  border-style: ridge;*/
            border-width: 2px;
Ejemplo n.º 5
0
//session_start();
//include_once("connection.php");
$error_msg = '';
if (isset($_POST['join']) || isset($_POST['request'])) {
    $user_id = $_SESSION['user_id'];
    $election_id = $_SESSION['election_id'];
    if (isset($_POST['join'])) {
        //prevent this user from doing this the second time
        if (attached('joined', $user_id, $election_id) == 'joined') {
            $error_msg = '<span class="error">You have already joined this election. Reload your main
                                            browser to see the effect.
                         </span>';
        } else {
            $connection1->query("INSERT INTO joined(user_id,election_id) VALUES ('{$user_id}','{$election_id}')");
            header("Location:status_accept.php");
        }
    } elseif (isset($_POST['request'])) {
        //prevent this user from doing this the second time
        if (attached('request', $user_id, $election_id) == 'request') {
            $error_msg = '<span class="error">Your request has been processed. Reload your main
                                            browser to see the effect.
                         </span>';
        } else {
            $connection1->query("INSERT INTO request(user_id,election_id) VALUES ('{$user_id}','{$election_id}')");
            header("Location:request_sent.php");
        }
    }
    if ($error_msg == '') {
        die;
    }
}
Ejemplo n.º 6
0
function publicDisplayable($user_id, $election_id)
{
    $table_lists = array('election', 'joined', 'invites', 'request');
    $publicity = 'totally';
    for ($i = 0; $i < count($table_lists); $i++) {
        $attached = attached($table_lists[$i], $user_id, $election_id);
        if (!empty($attached)) {
            $publicity = 'partially';
            break;
        }
    }
    return $publicity;
}