diff --git a/module/action/model.php b/module/action/model.php index 2514074ca5..f376963b2d 100644 --- a/module/action/model.php +++ b/module/action/model.php @@ -423,6 +423,93 @@ class actionModel extends model return $actions; } + /** + * Get project's actions as dynamic. + * + * @param string $objectType + * @param int $count + * @access public + * @return array + */ + public function getProjectDynamic($projectID = 0, $account = 'all', $period = 'all', $orderBy = 'date_desc', $pager = null) + { + $period = $this->computeBeginAndEnd($period); + extract($period); + + $actions = $this->dao->select('*')->from(TABLE_ACTION) + ->where('date')->gt($begin) + ->andWhere('date')->lt($end) + ->andWhere('project')->eq($projectID) + ->beginIF($account != 'all')->andWhere('actor')->eq($account)->fi() + ->orderBy($orderBy)->page($pager)->fetchAll(); + + if(!$actions) return array(); + + /* Group actions by objectType, and get there name field. */ + foreach($actions as $object) $objectTypes[$object->objectType][] = $object->objectID; + foreach($objectTypes as $objectType => $objectIds) + { + if(!isset($this->config->action->objectTables[$objectType])) continue; // If no defination for this type, omit it. + + $objectIds = array_unique($objectIds); + $table = $this->config->action->objectTables[$objectType]; + $field = $this->config->action->objectNameFields[$objectType]; + if($table != 'zt_todo') + { + $objectNames[$objectType] = $this->dao->select("id, $field AS name")->from($table)->where('id')->in($objectIds)->fetchPairs(); + } + else + { + $todos = $this->dao->select("id, $field AS name, account, private")->from($table)->where('id')->in($objectIds)->fetchAll('id'); + foreach($todos as $id => $todo) + { + if($todo->private == 1 and $todo->account != $this->app->user->account) + { + $objectNames[$objectType][$id] = $this->lang->todo->thisIsPrivate; + } + else + { + $objectNames[$objectType][$id] = $todo->name; + } + } + } + } + $objectNames['user'][0] = 'guest'; // Add guest account. + + foreach($actions as $action) + { + /* Add name field to the actions. */ + $action->objectName = isset($objectNames[$action->objectType][$action->objectID]) ? $objectNames[$action->objectType][$action->objectID] : ''; + + $actionType = strtolower($action->action); + $objectType = strtolower($action->objectType); + $action->date = date(DT_MONTHTIME2, strtotime($action->date)); + $action->actionLabel = isset($this->lang->action->label->$actionType) ? $this->lang->action->label->$actionType : $action->action; + $action->objectLabel = isset($this->lang->action->label->$objectType) ? $this->lang->action->label->$objectType : $objectType; + + /* If action type is login or logout, needn't link. */ + if($actionType == 'login' or $actionType == 'logout') + { + $action->objectLink = ''; + $action->objectLabel = ''; + continue; + } + + /* Other actions, create a link. */ + if(strpos($action->objectLabel, '|') !== false) + { + list($objectLabel, $moduleName, $methodName, $vars) = explode('|', $action->objectLabel); + $action->objectLink = helper::createLink($moduleName, $methodName, sprintf($vars, $action->objectID)); + $action->objectLabel = $objectLabel; + } + else + { + $action->objectLink = ''; + } + } + return $actions; + } + /** * Compute the begin date and end date of a period. * diff --git a/module/common/lang/en.php b/module/common/lang/en.php index 9f67906943..a84619b76c 100644 --- a/module/common/lang/en.php +++ b/module/common/lang/en.php @@ -156,6 +156,7 @@ $lang->project->menu->product = 'Link Product|project|manageproducts|projectID $lang->project->menu->linkstory = array('link' => 'Link Story|project|linkstory|projectID=%s'); $lang->project->menu->view = 'Info|project|view|projectID=%s'; $lang->project->menu->edit = 'Edit|project|edit|projectID=%s'; +$lang->project->menu->dynamic = 'Dynamic|project|dynamic|projectID=%s'; $lang->project->menu->create = array('link' => 'New Project|project|create', 'float' => 'right'); $lang->task->menu = $lang->project->menu; $lang->build->menu = $lang->project->menu; diff --git a/module/common/lang/zh-cn.php b/module/common/lang/zh-cn.php index 7477944151..f08b6cc5e7 100644 --- a/module/common/lang/zh-cn.php +++ b/module/common/lang/zh-cn.php @@ -156,6 +156,7 @@ $lang->project->menu->product = '产品|project|manageproducts|projectID=%s'; $lang->project->menu->linkstory = array('link' => '关联需求|project|linkstory|projectID=%s'); $lang->project->menu->view = '概况|project|view|projectID=%s'; $lang->project->menu->edit = '编辑|project|edit|projectID=%s'; +$lang->project->menu->dynamic = '动态|project|dynamic|projectID=%s'; $lang->project->menu->create = array('link' => '新增项目|project|create', 'float' => 'right'); $lang->task->menu = $lang->project->menu; $lang->build->menu = $lang->project->menu; diff --git a/module/project/control.php b/module/project/control.php index 93e7d12be4..6c4712132c 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -877,6 +877,57 @@ class project extends control } } + /** + * Project dynamic. + * + * @param string $type + * @param string $orderBy + * @param int $recTotal + * @param int $recPerPage + * @param int $pageID + * @access public + * @return void + */ + public function dynamic($projectID = 0, $type = 'today', $param = '', $orderBy = 'date_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) + { + /* Save session. */ + $uri = $this->app->getURI(true); + $this->session->set('productList', $uri); + $this->session->set('productPlanList', $uri); + $this->session->set('releaseList', $uri); + $this->session->set('storyList', $uri); + $this->session->set('projectList', $uri); + $this->session->set('taskList', $uri); + $this->session->set('buildList', $uri); + $this->session->set('bugList', $uri); + $this->session->set('caseList', $uri); + $this->session->set('testtaskList', $uri); + + $this->project->setMenu($this->projects, $projectID); + + /* Set the pager. */ + $this->app->loadClass('pager', $static = true); + $pager = pager::init($recTotal, $recPerPage, $pageID); + $this->view->orderBy = $orderBy; + $this->view->pager = $pager; + + /* Set the user and type. */ + $account = $type == 'account' ? $param : 'all'; + $period = $type == 'account' ? 'all' : $type; + + /* The header and position. */ + $this->view->header->title = $this->lang->company->common . $this->lang->colon . $this->lang->company->dynamic; + $this->view->position[] = $this->lang->company->dynamic; + + /* Assign. */ + $this->view->projectID = $projectID; + $this->view->type = $type; + $this->view->users = $this->loadModel('user')->getPairs('nodeleted|noletter'); + $this->view->account = $account; + $this->view->actions = $this->loadModel('action')->getProjectDynamic($projectID, $account, $period, $orderBy, $pager); + $this->display(); + } + /** * AJAX: get products of a project in html select. * diff --git a/module/project/js/dynamic.js b/module/project/js/dynamic.js new file mode 100755 index 0000000000..be82bb2190 --- /dev/null +++ b/module/project/js/dynamic.js @@ -0,0 +1,5 @@ +function changeUser(account, projectID) +{ + link = createLink('project', 'dynamic', 'projectID=' + projectID + '&type=account¶m=' + account); + location.href = link; +} diff --git a/module/project/view/dynamic.html.php b/module/project/view/dynamic.html.php new file mode 100755 index 0000000000..5c7899015c --- /dev/null +++ b/module/project/view/dynamic.html.php @@ -0,0 +1,56 @@ +dynamic view file of dashboard module of ZenTaoPMS. + * + * @copyright Copyright 2009-2011 青岛易软天创网络科技有限公司 (QingDao Nature Easy Soft Network Technology Co,LTD www.cnezsoft.com) + * @license LGPL (http://www.gnu.org/licenses/lgpl.html) + * @author Chunsheng Wang + * @package dashboard + * @version $Id: action->dynamic.html.php 1477 2011-03-01 15:25:50Z wwccss $ + * @link http://www.zentao.net + */ +?> + + +
+ ' . html::a(inlink('dynamic', "projectID=$projectID&type=today"), $lang->action->dynamic->today) . ''; + echo '' . html::a(inlink('dynamic', "projectID=$projectID&type=yesterday"), $lang->action->dynamic->yesterday) . ''; + echo '' . html::a(inlink('dynamic', "projectID=$projectID&type=twodaysago"), $lang->action->dynamic->twoDaysAgo) . ''; + echo '' . html::a(inlink('dynamic', "projectID=$projectID&type=thisweek"), $lang->action->dynamic->thisWeek) . ''; + echo '' . html::a(inlink('dynamic', "projectID=$projectID&type=lastweek"), $lang->action->dynamic->lastWeek) . ''; + echo '' . html::a(inlink('dynamic', "projectID=$projectID&type=thismonth"), $lang->action->dynamic->thisMonth) . ''; + echo '' . html::a(inlink('dynamic', "projectID=$projectID&type=lastmonth"), $lang->action->dynamic->lastMonth) . ''; + echo '' . html::a(inlink('dynamic', "projectID=$projectID&type=all"), $lang->action->dynamic->all) . ''; + echo "" . html::select('account', $users, $account, "onchange=changeUser(this.value,$projectID)") . ''; + ?> +
+ + + + + + + + + + + + + + + objectType == 'case' ? 'testcase' : $action->objectType;?> + + + + + + + + + + + +
action->date;?> action->actor;?>action->action;?> action->objectType;?> idAB;?>action->objectName;?>
date;?>actor]) ? print($users[$action->actor]) : print($action->actor);?>actionLabel;?>action->objectTypes[$action->objectType];?>objectID;?>objectLink, $action->objectName);?>
show();?>
+ +