<?php
require('../setClassPath.php');
require_once('object/User.php');
require_once('db/UserDB.php');
require_once('db/TransManager.php');
require_once('ui/Component.php');
require_once('util/InputHelper.php');

$uswitch    = intval($_GET['u']);

session_start();
$user = $_SESSION['user'];
if (!$user)
    exit();

try {
    $trans = TransManager::getInstance();
    $trans->beginTrans();
    $userdb = new UserDB();

    $setting = $userdb->getUserSettings($user->getUserId(), $trans->getPDO());

    $trans->commit();
    $trans->disconnect();
}
catch (Exception $e) {
    if ($trans)
        $trans->handleException();
}


?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Update Your Account Settings</title>
<link type="text/css" rel="stylesheet" href="/css/main.css">
<style type="text/css">
.hd { font-weight: bold; margin: 10px 0 8px 0; }
</style>
</head>
<body>
<div id="body">
<div id="widetop">
<h1>Modify Your Account Settings</h1>
<?php
if ($uswitch == 1)
    echo '<p>Your changes have been saved!</p>';
else
    echo '<p>Use this page to adjust your account settings to suit your preference.</p>';
?>
</div>

  <form action="usettings_update.html" method="post">
    <div class="hd">Make changes to your notification settings.</div>
    <p>** Disabling notifications means we will have no way to notify you of activity relevant to your account. 
        Please note we do not spam. We send account activity alerts at least two weeks apart because we don't 
        want to pollute your inbox.</p>
    <input type="checkbox" name="setting1" value="1"<?= ($setting['Block Quiz Taken Notify'] ? ' checked' : '') ?>> <label for="setting1">Don't notify me when people take my quiz</label><br>
    <input type="checkbox" name="setting2" value="1"<?= ($setting['Block New Message Notify'] ? ' checked' : '') ?>> <label for="setting2">Don't notify me when I have new messages</label><br>
    <input type="checkbox" name="setting3" value="1"<?= ($setting['Block New Post Notify'] ? ' checked' : '') ?>> <label for="setting3">Don't notify me when people reply to my posts</label><br>
    <input type="submit" value="Make Change"><br>
  </form>

  <div class="hd">Delete Your Account</div>
  <p>If you are sure you no longer want to participate on Would I Date You, <a href="deleteacct.html">click here</a>.</p>

  
<?php
$ui = Component::getInstance();
$ui->drawHeader($user);
$ui->drawFooter();
?>
</div>
</body>
</html>
