Exemplo n.º 1
0
 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();
 }
Exemplo n.º 2
0
 public function deleteAction()
 {
     //delete a todo item
     //retrieve the todo item first
     $todo = TodoItem::getItem($this->_params['todo_id'], $this->_params['username'], $this->_params['userpass']);
     //delete the TODO item while passing the username and password to authenticate
     $todo->delete($this->_params['username'], $this->_params['userpass']);
     //return the deleted todo item
     //in array format, for display purposes
     return $todo->toArray();
 }
 /**
  * Complete the Item by adding a completed date.
  *
  * @param  int  $list_id
  * @param  int  $item_id
  * @return Response
  */
 public function complete($list_id, $item_id)
 {
     $item = TodoItem::findOrFail($item_id);
     $item->completed_on = date('Y-m-d H:i:s');
     $item->update();
     return Redirect::route('todos.show', $list_id)->withMessage('Item completed');
 }
Exemplo n.º 4
0
 public function Test_of_decrementPositionsOnHigherItems()
 {
     $TodoItems = new TodoItem();
     $TodoItems->transactionStart();
     $this->assertTrue($TodoItems->list->decrementPositionsOnHigherItems(10));
     $todo_list = $this->_getTodoList();
     $this->assertEqual($todo_list[0], 'Email Hilario with new product specs');
     $this->assertEqual($todo_list[9], 'Task number 10');
     $TodoItems->transactionFail();
     $TodoItems->transactionComplete();
 }
Exemplo n.º 5
0
	function submitUpdate( $request ) {
		$id = $request->getInt( 'wpItem' );
		$item = TodoItem::loadFromId( $id );
		if ( is_null( $item ) ) {
			return Status::newFatal( 'todo-invalid-item' );
		}

		global $wgUser;
		if ( $item->owner != $wgUser->getId() ) {
			return Status::newFatal( 'todo-update-else-item' );
		}

		switch( $request->getVal( 'wpUpdateField' ) ) {
		case 'queue':
			return $item->setQueue( $request->getText( 'wpQueue' ) );
			break;
		case 'comment':
			return $item->setComment( $request->getText( 'wpComment' ) );
			break;
		case 'title':
			return $item->setTitle( $request->getText( 'wpTitle' ) );
			break;
		default:
			return Status::newFatal( 'todo-unrecognize-type' );
		}
	}
Exemplo n.º 6
0
 public function delete()
 {
     TodoItem::where('todo_list_id', $this->id)->delete();
     parent::delete();
 }
Exemplo n.º 7
0
<?php

include_once 'config.php';
$data = $_POST['data'];
$method = $_POST['method'];
$user_id = (include_once 'user.php');
$data = (array) json_decode($data);
$data['user_id'] = $user_id;
// Connect TodoItem class
include 'todoClass.php';
if ($data) {
    $item = new TodoItem($data);
    if ($method != '') {
        switch ($method) {
            case 'setName':
                $sth = $item->write('name', $item->name);
                break;
            case 'setCheck':
                $sth = $item->write('check', $item->check);
                break;
            case 'updatePosition':
                $sth = $item->updatePosition();
                break;
            case 'create':
                $sth = $item->create();
                break;
            case 'delete':
                $sth = $item->delete();
                break;
        }
        if ($method == 'getLast') {
Exemplo n.º 8
0
}
if (!$todolist->canWriteToContainer(0, 'object', TodoItem::SUBTYPE)) {
    register_error(elgg_echo('todos:action:todoitem:edit:cant_write'));
    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()) {