public function createAction()
 {
     //create a new todo item
     $todo = new TodoItem();
     $todo->title = $this->_params['title'];
     $todo->description = $this->_params['description'];
     $todo->due_date = $this->_params['due_date'];
     $todo->is_done = 'false';
     //pass the user's username and password to authenticate the user
     $todo->save($this->_params['username'], $this->_params['userpass']);
     //return the todo item in array format
     return $todo->toArray();
 }
Beispiel #2
0
 public function Test_of_populate_todo_list()
 {
     for ($i = 0; $i <= 30; $i++) {
         $attributes = array('task' => 'Task number ' . ($i + 3), 'due_time' => Ak::getDate(Ak::time() + 60 * 60 * 24 * $i));
         $TodoTask = new TodoItem($attributes);
         $this->assertTrue($TodoTask->save());
         $this->assertTrue($TodoTask->task == $attributes['task'] && $TodoTask->due_time == $attributes['due_time']);
     }
 }
Beispiel #3
0
    forward(REFERER);
}
if (empty($due)) {
    unset($due);
}
$new_entity_created = false;
if (empty($entity)) {
    // check due date for the past
    if (!empty($due) && $due < mktime(0, 0, 0)) {
        register_error(elgg_echo('todos:action:todoitem:edit:due_in_past'));
        forward(REFERER);
    }
    $entity = new TodoItem();
    $entity->container_guid = $todolist->getGUID();
    $entity->access_id = $todolist->access_id;
    $entity->save();
    $new_entity_created = true;
}
$entity->title = $title;
$entity->setDueDate($due);
if ($entity->canAssign($assignee, true)) {
    $entity->assign($assignee);
}
if (!empty($attachment)) {
    $filename = $_FILES['attachment']['name'];
    $entity->attach($filename, $attachment);
}
if ($entity->save()) {
    system_message(elgg_echo('todos:action:todoitem:edit:success'));
    if ($new_entity_created) {
        add_to_river('river/object/todoitem/create', 'create', elgg_get_logged_in_user_guid(), $entity->guid);