Esempio n. 1
0
function main()
{
    if (isset($_GET['action'])) {
        $action = $_GET['action'];
    } else {
        $action = 'list';
    }
    create_html_start();
    check_post_values();
    // Just list todos
    if ($action == 'list') {
        list_todos();
    } else {
        if ($action == 'edit') {
            show_edit();
        } else {
            if ($action == 'delete') {
                if (isset($_GET['id'])) {
                    delete_todo($_GET['id']);
                }
            } else {
                if ($action == 'finished') {
                    if (isset($_GET['id'])) {
                        finish_todo($_GET['id']);
                        list_todos();
                    }
                } else {
                    if ($action == 'show_finished') {
                        show_finished();
                    }
                }
            }
        }
    }
    create_html_end();
}
Esempio n. 2
0
         //         var_dump($_SESSION);
         //         die();
         redirect(VIEWS . "/update_task.php");
     } else {
         $errors = array();
         array_push($errors, "Select a task!");
         $_SESSION["errors"] = $errors;
         redirect(VIEWS . "/home.php");
     }
     exit;
 } else {
     if ($action === "Delete") {
         todolog("todo.php | Trying to delete a todo");
         if (isset($_POST["todoId"])) {
             todolog("todo.php | todo id: " . $_POST["todoId"]);
             delete_todo($_POST["todoId"]);
         } else {
             $_SESSION["errors"] = array("Select a todo");
         }
         redirect(VIEWS . "/home.php");
         exit;
     } else {
         if ($action == "Update") {
             //$_SESSION["errors"] = array("Feature not implemented");
             //     var_dump($_POST);
             //     die();
             $todoId = $_POST["taskId"];
             $description = $_POST["description"];
             $status = $_POST["status"];
             $updated = update_todo($todoId, $description, $status);
             if (!$updated) {
Esempio n. 3
0
     delete_action(filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT));
     break;
 case "delete_note":
     delete_note(filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT));
     break;
 case "delete_relation":
     delete_relation(filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT));
     break;
 case "delete_requirement":
     delete_requirement(filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT));
     break;
 case "delete_tag":
     delete_tag(filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT));
     break;
 case "delete_todo":
     delete_todo(filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT));
     break;
 case "delete_top_action":
     delete_top_action(filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT));
     break;
 case "display_history":
     display_history(filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT));
     break;
 case "display_queue":
     display_queue();
     break;
 case "fetch_required_filter_status":
     fetch_required_filter_status();
     break;
 case "is_it_active":
     is_it_active(filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT));
Esempio n. 4
0
         $todo = get_todo($todoId);
         //var_dump($todo);
         $_SESSION['todo_info'] = $todo;
         var_dump($todoId);
         $_SESSION['todo_id'] = $todoId;
         redirect(VIEWS . "/update_task.php");
     } else {
         $_SESSION["error"] = "Select a task";
         redirect(VIEWS . "/home.php");
     }
     // Delete
 } else {
     if ($action == "Delete") {
         if (isset($_POST["taskId"])) {
             $todoId = $_POST["taskId"];
             delete_todo($todoId);
         } else {
             $_SESSION["error"] = "Select a task";
         }
         redirect(VIEWS . "/home.php");
     } else {
         if ($action == "Update") {
             // Update
             if (isset($_POST["taskId"])) {
                 $todoId = $_POST["taskId"];
                 $description = $_POST["description"];
                 $status = $_POST["status"];
                 $updated = update_todo($description, $status, $todoId);
                 if (!$updated) {
                     $_SESSION['error'] = 'You can only change the status by the ordor "Not Started=>Started=>Mid-way=>Completed"<br/>Completed task is read only';
                 }
Esempio n. 5
0
    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");
        }
    } else {
        if ($action == "Delete") {
            if (isset($_POST["taskId"])) {
                $taskId = $_POST["taskId"];
                delete_todo($taskId);
            } else {
                $_SESSION["error"] = "Select a task";
            }
            redirect(VIEWS . "/home.php");
        } else {
            if ($action == "Update") {
                if (isset($_POST["taskId"])) {
                    $taskId = $_POST["taskId"];
                    $description = $_POST["description"];
                    $status = $_POST["status"];
                    updateTask($description, $status, $taskId);
                } else {
                    $_SESSION["error"] = "Select a task";
                }
                redirect(VIEWS . "/home.php");