implemented additional todo functionality
This commit is contained in:
+20
-7
@@ -7,21 +7,34 @@ if (isset($_POST['ajax_id'])) {
|
||||
handle_todo();
|
||||
break;
|
||||
}
|
||||
} else
|
||||
echo 'Received malformed request.';
|
||||
} else {
|
||||
$response = [
|
||||
'error' => 'Malformed URI request.',
|
||||
];
|
||||
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
function handle_todo()
|
||||
{
|
||||
$response = [];
|
||||
|
||||
include 'functions/todo_functions.php';
|
||||
|
||||
if (isset($_POST['todo_id']) && isset($_POST['action_id']) && isset($_POST['status'])) {
|
||||
$response = ['log' => []];
|
||||
if (isset($_POST['todo_id']) && isset($_POST['action_id'])) {
|
||||
$response['log'][] = 'Required parameters met.';
|
||||
switch ($_POST['action_id']) {
|
||||
case 'status':
|
||||
$response['todo_status'] = $_POST['status'];
|
||||
$response['log'][] = 'Changing status on ' . $_POST['todo_id'] . ' to ' . $_POST['status'] . '.';
|
||||
change_status($_POST['todo_id'], $_POST['status']);
|
||||
break;
|
||||
case 'create_update_todo':
|
||||
if ($_POST['todo_id'] != -1) {
|
||||
$response['log'][] = 'Updating todo information on ' . $_POST['todo_id'] . '.';
|
||||
update_todo($_POST['todo_id'], urldecode($_POST['todo']));
|
||||
} else {
|
||||
$response['log'][] = 'Creating todo information on ' . $_POST['todo_id'] . '.';
|
||||
create_todo(urldecode($_POST['todo']));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user