This commit is contained in:
liukmqd@gmail.com
2011-04-18 08:44:00 +00:00
parent 23da695efe
commit 1beea76da8
10 changed files with 167 additions and 7 deletions
+2
View File
@@ -12,6 +12,7 @@ $config->action->objectTables['testtask'] = TABLE_TESTTASK;
$config->action->objectTables['user'] = TABLE_USER;
$config->action->objectTables['doc'] = TABLE_DOC;
$config->action->objectTables['doclib'] = TABLE_DOCLIB;
$config->action->objectTables['todo'] = TABLE_TODO;
$config->action->objectNameFields['product'] = 'name';
$config->action->objectNameFields['story'] = 'title';
@@ -26,3 +27,4 @@ $config->action->objectNameFields['testtask'] = 'name';
$config->action->objectNameFields['user'] = 'account';
$config->action->objectNameFields['doc'] = 'title';
$config->action->objectNameFields['doclib'] = 'name';
$config->action->objectNameFields['todo'] = 'name';
+9
View File
@@ -21,6 +21,15 @@ $lang->action->date = 'Date';
$lang->action->trashTips = "Tips:The deleting actions in zentao are all logic, the real data don't be erased from the database.
So if you want to erase a record, can use phpmyadmin and such tools to remove it from database.";
$lang->action->dynamic->today = 'Today';
$lang->action->dynamic->yesterday = 'Yesterday';
$lang->action->dynamic->twoDaysAgo= 'The day Before Yesterday';
$lang->action->dynamic->thisWeek = 'This Week';
$lang->action->dynamic->lastWeek = 'Last Week';
$lang->action->dynamic->thisMonth = 'This Month';
$lang->action->dynamic->lastMonth = 'Last Month';
$lang->action->dynamic->all = 'All';
$lang->action->objectTypes['product'] = 'PRODUCT';
$lang->action->objectTypes['story'] = 'STORY';
$lang->action->objectTypes['productplan'] = 'PLAN';
+11
View File
@@ -17,10 +17,20 @@ $lang->action->objectType = '对象类型';
$lang->action->objectID = '对象ID';
$lang->action->objectName = '对象名称';
$lang->action->actor = '操作者';
$lang->action->action = '动作';
$lang->action->date = '日期';
$lang->action->trashTips = '提示:禅道系统的删除都是标记删除,并没有真正从数据库里面删除数据。这样做是为了系统数据的完整和安全。
因此如果你确定要删除某一条数据,可以使用phpmyadmin等管理工具,进数据库删除。';
$lang->action->dynamic->today = '今天';
$lang->action->dynamic->yesterday = '昨天';
$lang->action->dynamic->twoDaysAgo= '前天';
$lang->action->dynamic->thisWeek = '本周';
$lang->action->dynamic->lastWeek = '上周';
$lang->action->dynamic->thisMonth = '本月';
$lang->action->dynamic->lastMonth = '上月';
$lang->action->dynamic->all = '所有';
$lang->action->objectTypes['product'] = '产品';
$lang->action->objectTypes['story'] = '需求';
$lang->action->objectTypes['productplan'] = '产品计划';
@@ -34,6 +44,7 @@ $lang->action->objectTypes['testtask'] = '测试任务';
$lang->action->objectTypes['user'] = '用户';
$lang->action->objectTypes['doc'] = '文档';
$lang->action->objectTypes['doclib'] = '文档库';
$lang->action->objectTypes['todo'] = 'TODO';
/* 用来描述操作历史记录。*/
$lang->action->desc->common = '$date, <strong>$action</strong> by <strong>$actor</strong>' . "\n";
+56 -3
View File
@@ -211,14 +211,34 @@ class actionModel extends model
* @access public
* @return void
*/
public function getDynamic($objectType = 'all', $count = 30)
public function getDynamic($account = 'all', $period = 'all', $orderBy = 'id_desc', $pager = null)
{
$period = $this->computeBeginAndEnd($period);
extract($period);
$actions = $this->dao->select('*')->from(TABLE_ACTION)
->beginIF($objectType != 'all')->where('objectType')->eq($objectType)->fi()
->orderBy('id desc')->limit($count)->fetchAll();
->where('date')->gt($begin)
->andWhere('date')->lt($end)
->beginIF($account != 'all')->andWhere('actor')->eq($account)->fi()
->orderBy($orderBy)->page($pager)->fetchAll();
if(!$actions) return array();
/* Group trashes by objectType, and get there name field. */
foreach($actions as $object) $objectTypes[$object->objectType][] = $object->objectID;
foreach($objectTypes as $objectType => $objectIds)
{
$objectIds = array_unique($objectIds);
$table = $this->config->action->objectTables[$objectType];
$field = $this->config->action->objectNameFields[$objectType];
$objectNames[$objectType] = $this->dao->select("id, $field AS name")->from($table)->where('id')->in($objectIds)->fetchPairs();
}
foreach($actions as $action)
{
/* Add name field to the trashes. */
$action->objectName = $objectNames[$action->objectType][$action->objectID];
$actionType = strtolower($action->action);
$objectType = strtolower($action->objectType);
$action->date = date(DT_MONTHTIME2, strtotime($action->date));
@@ -248,6 +268,39 @@ class actionModel extends model
return $actions;
}
/**
* Compute the begin date and end date of a period.
*
* @param string $period
* @access private
* @return array
*/
private function computeBeginAndEnd($period)
{
$this->loadModel('todo');
$today = $this->todo->today();
$tomorrow = $this->todo->tomorrow();
$yesterday = $this->todo->yesterday();
$twoDaysAgo = $this->todo->twoDaysAgo();
if($period == 'all') return array('begin' => '1970-1-1', 'end' => '2109-1-1');
if($period == 'today') return array('begin' => $today, 'end' => $tomorrow);
if($period == 'yesterday') return array('begin' => $yesterday, 'end' => $today);
if($period == 'twodaysago') return array('begin' => $twoDaysAgo, 'end' => $yesterday);
/* If the period is by week, add the end time to the end date. */
if($period == 'thisweek' or $period == 'lastweek')
{
$func = "get$period";
extract($this->todo->$func());
return array('begin' => $begin, 'end' => $end . ' 23:59:59');
}
if($period == 'thismonth') return $this->todo->getThisMonth();
if($period == 'lastmonth') return $this->todo->getLastMonth();
}
/**
* Print changes of every action.
*
+3 -3
View File
@@ -17,10 +17,10 @@
<thead>
<tr class='colhead'>
<th class='w-80px'><?php common::printOrderLink('objectType', $orderBy, $vars, $lang->action->objectType);?></th>
<th class='w-id'><?php common::printOrderLink('objectID', $orderBy, $vars, $lang->idAB);?></th>
<th class='w-id'> <?php common::printOrderLink('objectID', $orderBy, $vars, $lang->idAB);?></th>
<th><?php echo $lang->action->objectName;?></th>
<th class='w-100px'><?php common::printOrderLink('actor', $orderBy, $vars, $lang->action->actor);?></th>
<th class='w-150px'><?php common::printOrderLink('date', $orderBy, $vars, $lang->action->date);?></th>
<th class='w-100px'><?php common::printOrderLink('actor', $orderBy, $vars, $lang->action->actor);?></th>
<th class='w-150px'><?php common::printOrderLink('date', $orderBy, $vars, $lang->action->date);?></th>
<th class='w-80px'><?php echo $lang->actions;?></th>
</tr>
</thead>