Exemplo n.º 1
0
    if (isset($_POST["description"])) {
        $owner = $_SESSION[CURRENT_USER];
        $description = $_POST["description"];
        //validate task description
        //var_dump($description);
        $valid = validate_decription($description);
        //max lengh
        //$valid = true;
        if ($valid) {
            $scheduledDate = time();
            if (isset($_POST["scheduledDate"]) && strlen(trim($_POST["scheduledDate"])) > 0) {
                $scheduledDate = strtotime($_POST["scheduledDate"]);
            }
            //var_dump($scheduledDate);
            //var_dump($_SESSION);
            new_todo($description, $scheduledDate, $owner);
        } else {
            $_SESSION["error"] = "Task description is required and can have upto 120 characters";
        }
    }
    redirect(VIEWS . "/home.php");
} else {
    if ($action == "Edit") {
        // Edit the content of selected todo;
        if (isset($_POST["taskId"])) {
            $todoId = $_POST["taskId"];
            $todo = get_todo($todoId);
            //var_dump($todo);
            $_SESSION['todo_info'] = $todo;
            var_dump($todoId);
            $_SESSION['todo_id'] = $todoId;
Exemplo n.º 2
0
        $descValid = is_todo_description_valid($description);
        $errors = array();
        if (!$descValid) {
            array_push($errors, "Description must not be empty and can have a max of 256 characters");
        }
        $dateValid = is_scheduled_date_valid($scheduledDate);
        if (!$dateValid) {
            array_push($errors, "Scheduled date may only be a max of 7 days from today");
        }
        if (count($errors) > 0) {
            todolog("todo.php | Validation errors found");
            $_SESSION["errors"] = $errors;
        } else {
            todolog("todo.php | Valid todo. Saving.");
            //valid todo. save.
            $todo = new_todo($description, $scheduledDate, $_SESSION[CURRENT_USER]);
            $_SESSION["success"] = "Saved todo";
        }
    } else {
        todolog("todo.php | No description or date found");
        $errors = array();
        array_push($errors, "Description is required");
        array_push($errors, "Scheduled date is required");
        $_SESSION["errors"] = $errors;
    }
    redirect(VIEWS . "/home.php");
    exit;
} else {
    if ($action === "Edit") {
        //$_SESSION["errors"] = array("Feature not implemented");
        //var_dump($_POST);
Exemplo n.º 3
0
    redirect(VIEWS . "/home.php");
}
$action = $_POST["action"];
//------------------------------------ADD---------------------------------------
if ($action == "Add") {
    if (isset($_POST["description"])) {
        $description = $_POST["description"];
        //validate task description
        $valid = validateRequired($description);
        if ($valid) {
            $scheduledDate = time();
            //$scheduledDate = date("D F d Y",$scheduledDate);
            if (isset($_POST["scheduledDate"]) && strlen(trim($_POST["scheduledDate"])) > 0) {
                $scheduledDate = strtotime($_POST["scheduledDate"]);
            }
            new_todo($description, $scheduledDate);
        } else {
            $_SESSION["error"] = "Task description is required and can have upto 120 characters";
        }
    }
    redirect(VIEWS . "/home.php");
} else {
    if ($action == "Edit") {
        if (isset($_POST["taskId"])) {
            $taskId = $_POST["taskId"];
            $_SESSION["taskId"] = $taskId;
            redirect(VIEWS . "/update_task.php");
        } else {
            $_SESSION["error"] = "Select a task";
            redirect(VIEWS . "/home.php");
        }