diff --git a/module/action/model.php b/module/action/model.php index c5fac8e54c..2514074ca5 100644 --- a/module/action/model.php +++ b/module/action/model.php @@ -336,6 +336,93 @@ class actionModel extends model return $actions; } + /** + * Get product's actions as dynamic. + * + * @param string $objectType + * @param int $count + * @access public + * @return array + */ + public function getProductDynamic($productID = 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('product')->eq($productID) + ->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 41bb8b8d9b..9f67906943 100644 --- a/module/common/lang/en.php +++ b/module/common/lang/en.php @@ -128,19 +128,20 @@ $lang->my->menu->profile = array('link' => 'Profile|my|profile|', 'alias' => 'e $lang->todo->menu = $lang->my->menu; /* Product menu. */ -$lang->product->menu->list = '%s'; -$lang->product->menu->story = array('link' => 'Story|product|browse|productID=%s', 'subModule' => 'story'); -$lang->product->menu->plan = array('link' => 'Plan|productplan|browse|productID=%s', 'subModule' => 'productplan'); -$lang->product->menu->release= array('link' => 'Release|release|browse|productID=%s', 'subModule' => 'release'); -$lang->product->menu->roadmap= 'Roadmap|product|roadmap|productID=%s'; -$lang->product->menu->doc = array('link' => 'Doc|product|doc|productID=%s', 'subModule' => 'doc'); -$lang->product->menu->view = 'Info|product|view|productID=%s'; -$lang->product->menu->edit = 'Edit|product|edit|productID=%s'; -$lang->product->menu->module = 'Modules|tree|browse|productID=%s&view=story'; -$lang->product->menu->create = array('link' => 'New Product|product|create', 'float' => 'right'); -$lang->story->menu = $lang->product->menu; -$lang->productplan->menu = $lang->product->menu; -$lang->release->menu = $lang->product->menu; +$lang->product->menu->list = '%s'; +$lang->product->menu->story = array('link' => 'Story|product|browse|productID=%s', 'subModule' => 'story'); +$lang->product->menu->plan = array('link' => 'Plan|productplan|browse|productID=%s', 'subModule' => 'productplan'); +$lang->product->menu->release = array('link' => 'Release|release|browse|productID=%s', 'subModule' => 'release'); +$lang->product->menu->roadmap = 'Roadmap|product|roadmap|productID=%s'; +$lang->product->menu->doc = array('link' => 'Doc|product|doc|productID=%s', 'subModule' => 'doc'); +$lang->product->menu->view = 'Info|product|view|productID=%s'; +$lang->product->menu->edit = 'Edit|product|edit|productID=%s'; +$lang->product->menu->module = 'Modules|tree|browse|productID=%s&view=story'; +$lang->product->menu->dynamic = 'Dynamic|product|dynamic|productID=%s'; +$lang->product->menu->create = array('link' => 'New Product|product|create', 'float' => 'right'); +$lang->story->menu = $lang->product->menu; +$lang->productplan->menu = $lang->product->menu; +$lang->release->menu = $lang->product->menu; /* Project menu. */ $lang->project->menu->list = '%s'; diff --git a/module/common/lang/zh-cn.php b/module/common/lang/zh-cn.php index 63fd85c06e..7477944151 100644 --- a/module/common/lang/zh-cn.php +++ b/module/common/lang/zh-cn.php @@ -128,19 +128,20 @@ $lang->my->menu->profile = array('link' => '我的档案|my|profile|', 'alias' $lang->todo->menu = $lang->my->menu; /* 产品视图设置。*/ -$lang->product->menu->list = '%s'; -$lang->product->menu->story = array('link' => '需求|product|browse|productID=%s', 'subModule' => 'story'); -$lang->product->menu->plan = array('link' => '计划|productplan|browse|productID=%s', 'subModule' => 'productplan'); -$lang->product->menu->release= array('link' => '发布|release|browse|productID=%s', 'subModule' => 'release'); -$lang->product->menu->roadmap= '路线图|product|roadmap|productID=%s'; -$lang->product->menu->doc = array('link' => '文档|product|doc|productID=%s', 'subModule' => 'doc'); -$lang->product->menu->view = '概况|product|view|productID=%s'; -$lang->product->menu->edit = '编辑|product|edit|productID=%s'; -$lang->product->menu->module = '模块|tree|browse|productID=%s&view=story'; -$lang->product->menu->create = array('link' => '新增产品|product|create', 'float' => 'right'); -$lang->story->menu = $lang->product->menu; -$lang->productplan->menu = $lang->product->menu; -$lang->release->menu = $lang->product->menu; +$lang->product->menu->list = '%s'; +$lang->product->menu->story = array('link' => '需求|product|browse|productID=%s', 'subModule' => 'story'); +$lang->product->menu->plan = array('link' => '计划|productplan|browse|productID=%s', 'subModule' => 'productplan'); +$lang->product->menu->release = array('link' => '发布|release|browse|productID=%s', 'subModule' => 'release'); +$lang->product->menu->roadmap = '路线图|product|roadmap|productID=%s'; +$lang->product->menu->doc = array('link' => '文档|product|doc|productID=%s', 'subModule' => 'doc'); +$lang->product->menu->view = '概况|product|view|productID=%s'; +$lang->product->menu->edit = '编辑|product|edit|productID=%s'; +$lang->product->menu->module = '模块|tree|browse|productID=%s&view=story'; +$lang->product->menu->dynamic = '动态|product|dynamic|productID=%s'; +$lang->product->menu->create = array('link' => '新增产品|product|create', 'float' => 'right'); +$lang->story->menu = $lang->product->menu; +$lang->productplan->menu = $lang->product->menu; +$lang->release->menu = $lang->product->menu; /* 项目视图菜单设置。*/ $lang->project->menu->list = '%s'; diff --git a/module/product/control.php b/module/product/control.php index 75172d44af..eeec508520 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -310,6 +310,57 @@ class product extends control $this->display(); } + /** + * Product dynamic. + * + * @param string $type + * @param string $orderBy + * @param int $recTotal + * @param int $recPerPage + * @param int $pageID + * @access public + * @return void + */ + public function dynamic($productID = 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->product->setMenu($this->products, $productID); + + /* 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->productID = $productID; + $this->view->type = $type; + $this->view->users = $this->loadModel('user')->getPairs('nodeleted|noletter'); + $this->view->account = $account; + $this->view->actions = $this->loadModel('action')->getProductDynamic($productID, $account, $period, $orderBy, $pager); + $this->display(); + } + /** * AJAX: get projects of a product in html select. * diff --git a/module/product/js/dynamic.js b/module/product/js/dynamic.js new file mode 100755 index 0000000000..094de9d376 --- /dev/null +++ b/module/product/js/dynamic.js @@ -0,0 +1,5 @@ +function changeUser(account, productID) +{ + link = createLink('product', 'dynamic', 'productID=' + productID + '&type=account¶m=' + account); + location.href = link; +} diff --git a/module/product/view/dynamic.html.php b/module/product/view/dynamic.html.php new file mode 100755 index 0000000000..89ece16cf4 --- /dev/null +++ b/module/product/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', "productID=$productID&type=today"), $lang->action->dynamic->today) . ''; + echo '' . html::a(inlink('dynamic', "productID=$productID&type=yesterday"), $lang->action->dynamic->yesterday) . ''; + echo '' . html::a(inlink('dynamic', "productID=$productID&type=twodaysago"), $lang->action->dynamic->twoDaysAgo) . ''; + echo '' . html::a(inlink('dynamic', "productID=$productID&type=thisweek"), $lang->action->dynamic->thisWeek) . ''; + echo '' . html::a(inlink('dynamic', "productID=$productID&type=lastweek"), $lang->action->dynamic->lastWeek) . ''; + echo '' . html::a(inlink('dynamic', "productID=$productID&type=thismonth"), $lang->action->dynamic->thisMonth) . ''; + echo '' . html::a(inlink('dynamic', "productID=$productID&type=lastmonth"), $lang->action->dynamic->lastMonth) . ''; + echo '' . html::a(inlink('dynamic', "productID=$productID&type=all"), $lang->action->dynamic->all) . ''; + echo "" . html::select('account', $users, $account, "onchange=changeUser(this.value,$productID)") . ''; + ?> +
+ + + + + + + + + + + + + + + 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();?>
+ +