diff --git a/module/my/control.php b/module/my/control.php
index 3036d3ac68..ede7602309 100644
--- a/module/my/control.php
+++ b/module/my/control.php
@@ -40,6 +40,12 @@ class my extends control
/* 用户的todo列表。*/
public function todo($type = 'today', $account = '', $status = 'all')
{
+ /* 登记session。*/
+ $uri = $this->app->getURI(true);
+ $this->session->set('todoList', $uri);
+ $this->session->set('bugList', $uri);
+ $this->session->set('taskList', $uri);
+
$this->view->header->title = $this->lang->my->common . $this->lang->colon . $this->lang->my->todo;
$this->view->position[] = $this->lang->my->todo;
diff --git a/module/my/view/todo.html.php b/module/my/view/todo.html.php
index eb43469c71..bd62d0d8ac 100644
--- a/module/my/view/todo.html.php
+++ b/module/my/view/todo.html.php
@@ -76,20 +76,14 @@ function changeDate(date)
date;?> |
todo->typeList->{$todo->type};?> |
pri;?> |
-
- type == 'bug') $link = $this->createLink('bug', 'view', "id={$todo->idvalue}");
- if($todo->type == 'task') $link = $this->createLink('task', 'edit', "id={$todo->idvalue}");
- if($todo->type == 'custom') $link = $this->createLink('todo', 'edit', "id={$todo->id}");
- echo html::a($link, $todo->name);
- ?>
- |
+ createLink('todo', 'view', "id={$todo->id}"), $todo->name);?> |
begin;?> |
end;?> |
todo->statusList[$todo->status];?> |
createLink('todo', 'mark', "id=$todo->id&status=$todo->status"), $lang->todo->{'mark'.ucfirst($todo->status)}, 'hiddenwin');
+ echo html::a($this->createLink('todo', 'view', "id=$todo->id&from=my"), $lang->todo->viewAB);
echo html::a($this->createLink('todo', 'edit', "id=$todo->id"), $lang->edit);
echo html::a($this->createLink('todo', 'delete', "id=$todo->id"), $lang->delete, 'hiddenwin');
?>
diff --git a/module/todo/control.php b/module/todo/control.php
index 4f95695b4f..85e118414a 100644
--- a/module/todo/control.php
+++ b/module/todo/control.php
@@ -39,8 +39,9 @@ class todo extends control
if($account == '') $account = $this->app->user->account;
if(!empty($_POST))
{
- $this->todo->create($date, $account);
+ $todoID = $this->todo->create($date, $account);
if(dao::isError()) die(js::error(dao::getError()));
+ $this->loadModel('action')->create('todo', $todoID, 'opened');
die(js::locate($this->createLink('my', 'todo', "date=$_POST[date]"), 'parent'));
}
@@ -61,9 +62,14 @@ class todo extends control
{
if(!empty($_POST))
{
- $this->todo->update($todoID);
+ $changes = $this->todo->update($todoID);
if(dao::isError()) die(js::error(dao::getError()));
- die(js::locate($this->createLink('my', 'todo', "date=$_POST[date]"), 'parent'));
+ if($changes)
+ {
+ $actionID = $this->loadModel('action')->create('todo', $todoID, 'edited');
+ $this->action->logHistory($actionID, $changes);
+ }
+ die(js::locate(inlink('view', "todoID=$todoID"), 'parent'));
}
/* 获取todo信息,判断是否是私人事务。*/
@@ -82,17 +88,25 @@ class todo extends control
}
/* 查看todo。*/
- public function view($todoID)
+ public function view($todoID, $from = 'company')
{
$todo = $this->todo->getById($todoID);
+ if(!$todo) die(js::error($this->lang->notFound) . js::locate('back'));
+
+ /* 登记session。*/
+ $this->session->set('taskList', $this->app->getURI(true));
+ $this->session->set('bugList', $this->app->getURI(true));
+
$this->lang->todo->menu = $this->lang->user->menu;
$this->loadModel('user')->setMenu($this->user->getPairs(), $todo->account);
- $this->lang->set('menugroup.todo', 'company');
+ $this->lang->set('menugroup.todo', $from);
$this->view->header->title = $this->lang->todo->view;
$this->view->position[] = $this->lang->todo->view;
$this->view->todo = $todo;
$this->view->times = $this->todo->buildTimeList();
+ $this->view->actions = $this->loadModel('action')->getList('todo', $todoID);
+ $this->view->from = $from;
$this->display();
}
@@ -107,10 +121,9 @@ class todo extends control
}
else
{
- $todo = $this->todo->getById($todoID);
- $this->todo->delete($todoID);
- echo js::locate($this->createLink('my', 'todo', "date={$todo->date}"), 'parent');
- exit;
+ $this->dao->delete()->from(TABLE_TODO)->where('id')->eq($todoID)->exec();
+ $this->loadModel('action')->create('todo', $todoID, 'erased');
+ die(js::locate($this->session->todoList, 'parent'));
}
}
diff --git a/module/todo/lang/zh-cn.php b/module/todo/lang/zh-cn.php
index f4e9abaffd..a682b077e3 100644
--- a/module/todo/lang/zh-cn.php
+++ b/module/todo/lang/zh-cn.php
@@ -26,6 +26,7 @@ $lang->todo->index = "todo一览";
$lang->todo->create = "新增TODO";
$lang->todo->edit = "更新TODO";
$lang->todo->view = "TODO详情";
+$lang->todo->viewAB = "详情";
$lang->todo->markDone = "未完成";
$lang->todo->markWait = "已完成";
$lang->todo->markDoing = "已完成";
@@ -79,3 +80,5 @@ $lang->todo->lastWeekTodos = '上周总结';
$lang->todo->allDaysTodos = '所有TODO';
$lang->todo->allUndone = '之前未完';
$lang->todo->todayTodos = '今日安排';
+
+$lang->todo->action->marked = array('main' => '$date, 由 $actor 标记为$extra。', 'extra' => $lang->todo->statusList);
diff --git a/module/todo/model.php b/module/todo/model.php
index 09a14b29c7..19f1b4c7a5 100644
--- a/module/todo/model.php
+++ b/module/todo/model.php
@@ -46,11 +46,14 @@ class todoModel extends model
->autoCheck()
->checkIF($todo->type == 'custom', $this->config->todo->create->requiredFields, 'notempty')
->exec();
+ return $this->dao->lastInsertID();
}
/* 更新一个todo。*/
public function update($todoID)
{
+ $oldTodo = $this->getById($todoID);
+ if($oldTodo->type != 'custom') $oldTodo->name = '';
$todo = fixer::input('post')
->cleanInt('date, pri, begin, end, private')
->specialChars('type,name,desc')
@@ -62,25 +65,23 @@ class todoModel extends model
->autoCheck()
->checkIF($todo->type == 'custom', $this->config->todo->edit->requiredFields, 'notempty')->where('id')->eq($todoID)
->exec();
+ if(!dao::isError()) return common::createChanges($oldTodo, $todo);
}
- /* 删除一个todo。*/
- public function delete($todoID)
- {
- return $this->dao->delete()->from(TABLE_TODO)->where('id')->eq((int)$todoID)->exec();
- }
-
/* 更改状态。*/
public function mark($todoID, $status)
{
$status = ($status == 'done') ? 'wait' : 'done';
- return $this->dao->update(TABLE_TODO)->set('status')->eq($status)->where('id')->eq((int)$todoID)->exec();
+ $this->dao->update(TABLE_TODO)->set('status')->eq($status)->where('id')->eq((int)$todoID)->exec();
+ $this->loadModel('action')->create('todo', $todoID, 'marked', '', $status);
+ return;
}
/* 获得一条todo信息。*/
public function getById($todoID)
{
$todo = $this->dao->findById((int)$todoID)->from(TABLE_TODO)->fetch();
+ if(!$todo) return false;
if($todo->type == 'task') $todo->name = $this->dao->findById($todo->idvalue)->from(TABLE_TASK)->fetch('name');
if($todo->type == 'bug') $todo->name = $this->dao->findById($todo->idvalue)->from(TABLE_BUG)->fetch('title');
$todo->date = str_replace('-', '', $todo->date);
diff --git a/module/todo/view/view.html.php b/module/todo/view/view.html.php
index 980299ec38..3f05ace50a 100644
--- a/module/todo/view/view.html.php
+++ b/module/todo/view/view.html.php
@@ -26,7 +26,10 @@
private or ($todo->private and $todo->account == $app->user->account)):?>
- todo->view;?>
+
+ todo->view;?>
+ session->todoList, $lang->goback);?>
+
| todo->date;?> |
date));?> |
@@ -41,7 +44,13 @@
| todo->name;?> |
- name;?> |
+
+ type == 'bug') echo html::a($this->createLink('bug', 'view', "id={$todo->idvalue}"), $todo->name);
+ if($todo->type == 'task') echo html::a($this->createLink('task', 'view', "id={$todo->idvalue}"), $todo->name);
+ if($todo->type == 'custom') echo $todo->name;
+ ?>
+ |
| todo->desc;?> |
@@ -60,9 +69,32 @@
?>
-
-
- todo->thisIsPrivate;?>
-
+
+
+ session->todoList)
+ {
+ $browseLink = $this->session->todoList;
+ }
+ elseif($todo->account == $app->user->account)
+ {
+ $browseLink = $this->createLink('my', 'todo');
+ }
+ else
+ {
+ $browseLink = $this->createLink('user', 'todo', "account=$todo->account");
+ }
+ if($todo->account == $app->user->account)
+ {
+ common::printLink('todo', 'edit', "todoID=$todo->id", $lang->edit);
+ common::printLink('todo', 'delete', "todoID=$todo->id", $lang->delete, 'hiddenwin');
+ }
+ echo html::a($browseLink, $lang->goback);
+ ?>
+
+
+
+ todo->thisIsPrivate;?>
+
diff --git a/module/user/control.php b/module/user/control.php
index 43ad0c4cf1..a24821af53 100644
--- a/module/user/control.php
+++ b/module/user/control.php
@@ -41,6 +41,8 @@ class user extends control
/* ûtodoб*/
public function todo($account, $type = 'today', $status = 'all')
{
+ $this->session->set('todoList', $this->app->getURI(true));
+
/* todo model*/
$this->loadModel('todo');
$this->lang->set('menugroup.user', 'company');
|