<?php

require dirname(__FILE__) . '/includes/bootstrap.php';
//Getting Current User ID
if (!buckys_check_user_acl(USER_ACL_REGISTERED)) {
    buckys_redirect('/register.php');
}
//Choose Moderator
if (isset($_GET['action'])) {
    if ($_GET['action'] == 'delete-candidate') {
        if (!buckys_check_id_encrypted($_GET['id'], $_GET['idHash'])) {
            buckys_redirect('/moderator.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
        }
        BuckysModerator::deleteCandidate($userID, $_GET['id']);
        buckys_redirect('/moderator.php');
    }
    if ($_GET['action'] == 'delete-moderator') {
        //Confirm that the user is administrator
        if (!buckys_check_user_acl(USER_ACL_ADMINISTRATOR)) {
            buckys_redirect('/moderator.php', MSG_PERMISSION_DENIED, MSG_TYPE_ERROR);
        }
        if (!buckys_check_id_encrypted($_GET['id'], $_GET['idHash'])) {
            buckys_redirect('/moderator.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
        }
        BuckysModerator::deleteModerator($_GET['id']);
        buckys_redirect('/moderator.php');
    }
    if ($_GET['action'] == 'reset-voting') {
        //Confirm that the user is administrator
        if (!buckys_check_user_acl(USER_ACL_ADMINISTRATOR)) {
            buckys_redirect('/moderator.php', MSG_PERMISSION_DENIED, MSG_TYPE_ERROR);