Esempio n. 1
0
 public function testInOut()
 {
     $ts = new Todos();
     $ts->loadFromFile('todo.txt');
     $file = tempnam(sys_get_temp_dir(), 'otodo');
     $ts->saveToFile($file);
     $this->assertEquals(sha1_file('todo.txt'), sha1_file($file));
     unlink($file);
 }
Esempio n. 2
0
 public function testASortPersistent()
 {
     $ts = new Todos();
     $ts->loadFromFile('todo.txt');
     $file = tempnam(sys_get_temp_dir(), 'otodo');
     $ts->asort(array('done' => true, 'priority' => false, 'text' => false));
     $ts->saveToFile($file);
     $this->assertEquals(sha1_file('todo.txt'), sha1_file($file));
     unlink($file);
 }
Esempio n. 3
0
 protected function sortCmp($col, $asc, $a, $b)
 {
     switch ($col) {
         case 'due':
             if ($a->{$col} === null) {
                 if ($b->{$col} === null) {
                     return 0;
                 }
                 return 1;
             } elseif ($b->{$col} === null) {
                 return -1;
             }
             $diff = $a->{$col}->diff($b->{$col});
             if ($diff->days == 0) {
                 return 0;
             }
             if ($diff->invert) {
                 return $asc ? 1 : -1;
             } else {
                 return $asc ? -1 : 1;
             }
             break;
         default:
             return parent::sortCmp($col, $asc, $a, $b);
             break;
     }
 }
 public function Add_itemAction()
 {
     $todo_id = $this->request->getPost('todo_id');
     $todo_title = $this->request->getPost('todo_title');
     $todo = Todos::find('hex(uuid) = "' . $todo_id . '"');
     if ($todo) {
         $todo_item = new Todoitems();
         $todo_item->setTodoId($todo_id);
         $todo_item->title = $todo_title;
         $todo_item->save();
     }
     return $this->response->redirect("/");
 }
Esempio n. 5
0
 public function actionUpdate()
 {
     $data = Yii::app()->request->getRestParams();
     $newTask = Todos::model()->findByPk((int) $data['id']);
     $newTask->status = $data['status'];
     if (!$newTask->validate()) {
         $this->_sendResponse(400, 'Error: the model is bad');
     }
     if ($newTask->save()) {
         $this->_sendResponse(200, CJSON::encode($newTask));
     } else {
         $this->_sendResponse(500, 'Error: the model is not saved');
     }
 }
Esempio n. 6
0
 public function markAllCompleted($userId)
 {
     try {
         $todos = Todos::where('user_id', $userId)->where('status', 'incomplete')->get(array('id'))->toArray();
         if ($todos == null) {
             //No Todos found
             return 'error';
         } else {
             foreach ($todos as $todo) {
                 $tempTodo = \Todos::find($todo['id']);
                 $tempTodo->status = 'completed';
                 $tempTodo->save();
             }
             return 'success';
         }
     } catch (Exception $e) {
         \Log::error('Something Went Wrong in Todo Repository - markAllCompleted():' . $e->getMessage());
         throw new SomeThingWentWrongException();
     }
 }
    /**
     * get data
     *
     * @return Response
     */
    public function getData()
    {
        $list = Todos::leftjoin('users', 'users.id', '=', 'todos.admin_id')->select(array('todos.id', 'todos.title', 'todos.status', 'todos.description', 'todos.created_at', 'todos.due_at', 'users.displayname'));
        if (Api::Enabled()) {
            $u = $list->get();
            return Api::make($u->toArray());
        } else {
            return Datatables::of($list)->edit_column('status', '{{{ Lang::get(\'admin/todos/todos.status_\'.$status) }}}')->edit_column('due_at', '{{{ Carbon::parse($due_at)->diffForHumans() }}}')->edit_column('created_at', '{{{ Carbon::parse($created_at)->diffForHumans() }}}')->edit_column('displayname', '{{{ $displayname ? : "Nobody" }}}')->add_column('actions', '<div class="btn-group" style="width: 200px">
		<a href="{{{ URL::to(\'admin/todos/\' . $id . \'/edit\' ) }}}" class="modalfy btn btn-sm btn-primary">{{{ Lang::get(\'button.edit\') }}}</a> 
		<a href="{{{ URL::to(\'admin/todos/\' . $id . \'/assign\' ) }}}" data-row="{{{  $id }}}" data-table="todos" class="ajax-alert-confirm btn btn-sm btn-default">{{{ Lang::get(\'button.assign_to_me\') }}}</a>
			<a data-row="{{{  $id }}}" data-table="todos" data-method="delete" href="{{{ URL::to(\'admin/todos/\' . $id . \'\' ) }}}" class="ajax-alert-confirm btn btn-sm btn-danger">{{{ Lang::get(\'button.delete\') }}}</a>
		</div>
            ')->make();
        }
    }
 public function indexAction()
 {
     $todos = Todos::find();
     $this->view->todos = $todos;
 }