<?php require_once 'classes/achievements.php'; require_once 'classes/todo.php'; $achievement = new Achievements(); $todo = new Todo(); if (isset($_GET['action'])) { $data["goal_id"] = $_POST['goal_id']; $data["user_id"] = (int) $_SESSION['userid']; $data["comments"] = $_POST['comments']; $data["location"] = $_POST['location']; $data["date"] = time(); $id = $achievement->add($data); $todo->remove($data["goal_id"], $_SESSION["userid"]); $msg = "Achievement Successfully Achieved!"; echo "Achievement Successfully Achieved!"; event::fire('USER_GOAL_COMPLETION'); }
$todo = new Todo(); if ($_GET['action'] == 'addGoal') { $id = (int) $_GET['id']; $userid = $_SESSION['userid']; $add = $todo->add($id, $userid); if ($add < 0) { $msg = 'Failed to add goal to your TODO list'; return; } if (empty($add)) { event::fire('USER_NEW_GOAL'); $msg = "Added successfully. <a href='todo.php'>View your list</a>"; } else { $msg = $add; } return $msg; } else { if ($_GET['action'] == 'remGoal') { $id = (int) $_GET['id']; $userid = $_SESSION['userid']; $remove = $todo->remove($id, $userid); if (!empty($remove)) { $msg = 'Failed to remove goal from your TODO list'; return; } if (empty($add)) { event::fire('USER_REMOVE_GOAL'); $msg = 'Goal removed successfully.'; } } }