Beispiel #1
0
 public function testEditTask()
 {
     $t = new Tasks();
     $t->add_task('titre', 'description', 'toto');
     $tasks = $t->get_tasks();
     $t->edit_task(count($tasks) - 1, 'titre2', 'description2', 'toto2', 1);
     $tasks = $t->get_tasks();
     $this->assertEquals($tasks[count($tasks) - 1]['title'], 'titre2');
     $this->assertEquals($tasks[count($tasks) - 1]['description'], 'description2');
     $this->assertEquals($tasks[count($tasks) - 1]['user'], 'toto2');
     $this->assertEquals($tasks[count($tasks) - 1]['state'], 1);
     $t->remove_task(count($tasks) - 1);
 }
Beispiel #2
0
$tasks = new Tasks();
$auth = new Authentification();
$id_connected = $auth->is_connected();
if (!$id_connected['loggedIn']) {
    return;
}
$params = json_decode(file_get_contents('php://input'), true);
switch ($params['action']) {
    //--------------- ADD_TASKS --------------
    case 'add_task':
        $tasks->add_task($params['task']['title'], strip_tags($params['task']['description']), $params['task']['user'], $params['task']['state']);
        break;
        //--------------- EDIT_TASKS --------------
    //--------------- EDIT_TASKS --------------
    case 'edit_task':
        $tasks->edit_task($params['id'], $params['task']['title'], strip_tags($params['task']['description']), $params['task']['user'], $params['task']['state']);
        break;
        //--------------- DELETE_TASK -----------------------------
    //--------------- DELETE_TASK -----------------------------
    case 'delete_task':
        $tasks->remove_task($params['id']);
        break;
}
$tasks = $tasks->get_tasks();
$todo = array();
$inprogress = array();
$done = array();
foreach ($tasks as $key => $value) {
    $value['id'] = $key;
    switch ($value['state']) {
        case 0: