score->refresh; ?>
++
score->refreshTips; ?>
++ +
+diff --git a/db/update9.5.1.sql b/db/update9.5.1.sql index 8dbe395d1d..17036e2ff9 100644 --- a/db/update9.5.1.sql +++ b/db/update9.5.1.sql @@ -78,7 +78,7 @@ ALTER TABLE `zt_team` DROP PRIMARY KEY; ALTER TABLE `zt_team` ADD PRIMARY KEY (`project`, `task`, `account`); ALTER TABLE `zt_user` ADD `score` DECIMAL(12,1) NOT NULL DEFAULT '0' AFTER `deleted`; -ALTER TABLE `zt_user` ADD `score_level` DECIMAL(12,1) NOT NULL DEFAULT '0' AFTER `score`; +ALTER TABLE `zt_user` ADD `scoreLevel` DECIMAL(12,1) NOT NULL DEFAULT '0' AFTER `score`; CREATE TABLE `zt_score` ( `id` bigint(12) unsigned NOT NULL AUTO_INCREMENT, diff --git a/module/common/lang/en.php b/module/common/lang/en.php index 3de4a704e0..8c0f61f444 100644 --- a/module/common/lang/en.php +++ b/module/common/lang/en.php @@ -175,7 +175,7 @@ $lang->my->menu->dynamic = 'Dynamic|my|dynamic|'; $lang->my->menu->profile = array('link' => 'Profile|my|profile', 'alias' => 'editprofile'); $lang->my->menu->changePassword = 'Password|my|changepassword'; $lang->my->menu->manageContacts = 'Contact|my|managecontacts'; -$lang->my->menu->score = array('link' => 'Score|score|browse', 'subModule' => 'score'); +$lang->my->menu->score = 'Score|score|browse'; $lang->todo = new stdclass(); $lang->todo->menu = $lang->my->menu; diff --git a/module/common/lang/zh-cn.php b/module/common/lang/zh-cn.php index 81c8b2c620..48271a6558 100644 --- a/module/common/lang/zh-cn.php +++ b/module/common/lang/zh-cn.php @@ -175,7 +175,7 @@ $lang->my->menu->dynamic = '动态|my|dynamic|'; $lang->my->menu->profile = array('link' => '档案|my|profile', 'alias' => 'editprofile'); $lang->my->menu->changePassword = '密码|my|changepassword'; $lang->my->menu->manageContacts = '联系人|my|managecontacts'; -$lang->my->menu->score = array('link' => '积分|score|browse', 'subModule' => 'score'); +$lang->my->menu->score = '积分|my|score'; $lang->todo = new stdclass(); $lang->todo->menu = $lang->my->menu; diff --git a/module/common/lang/zh-tw.php b/module/common/lang/zh-tw.php index 4a68c6a53b..612d7e10c5 100644 --- a/module/common/lang/zh-tw.php +++ b/module/common/lang/zh-tw.php @@ -175,7 +175,7 @@ $lang->my->menu->dynamic = '動態|my|dynamic|'; $lang->my->menu->profile = array('link' => '檔案|my|profile', 'alias' => 'editprofile'); $lang->my->menu->changePassword = '密碼|my|changepassword'; $lang->my->menu->manageContacts = '聯繫人|my|managecontacts'; -$lang->my->menu->score = array('link' => '積分|score|browse', 'subModule' => 'score'); +$lang->my->menu->score = '積分|my|score'; $lang->todo = new stdclass(); $lang->todo->menu = $lang->my->menu; diff --git a/module/common/model.php b/module/common/model.php index 0fb9910539..d4637cf1bf 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -1162,8 +1162,8 @@ class commonModel extends model global $app; if(!empty($app->user->admin)) return true; - if($module = 'todo' and ($method == 'create' or $method == 'batchcreate')) return true; - if($module = 'effort' and ($method == 'createforobject' or $method == 'batchcreate')) return true; + if($module == 'todo' and ($method == 'create' or $method == 'batchcreate')) return true; + if($module == 'effort' and ($method == 'createforobject' or $method == 'batchcreate')) return true; // limited project $limitedProject = false; diff --git a/module/group/lang/resource.php b/module/group/lang/resource.php index 23ef7835c1..b8cdc4885e 100644 --- a/module/group/lang/resource.php +++ b/module/group/lang/resource.php @@ -85,6 +85,7 @@ $lang->resource->my->unbind = 'unbind'; $lang->resource->my->manageContacts = 'manageContacts'; $lang->resource->my->deleteContacts = 'deleteContacts'; $lang->resource->my->limited = 'limited'; +$lang->resource->my->score = 'score'; $lang->my->methodOrder[0] = 'index'; $lang->my->methodOrder[5] = 'todo'; @@ -101,7 +102,8 @@ $lang->my->methodOrder[55] = 'changePassword'; $lang->my->methodOrder[60] = 'unbind'; $lang->my->methodOrder[65] = 'manageContacts'; $lang->my->methodOrder[75] = 'deleteContacts'; -$lang->my->methodOrder[80] = 'limited'; +$lang->my->methodOrder[80] = 'score'; +$lang->my->methodOrder[85] = 'limited'; /* Todo. */ $lang->resource->todo = new stdclass(); diff --git a/module/my/control.php b/module/my/control.php index 1e44bd4f92..b851d2dc49 100644 --- a/module/my/control.php +++ b/module/my/control.php @@ -37,6 +37,30 @@ class my extends control $this->display(); } + /** + * Get score list + * + * @param int $recTotal + * @param int $recPerPage + * @param int $pageID + * + * @access public + * @return mixed + */ + public function score($recTotal = 0, $recPerPage = 20, $pageID = 1) + { + $this->app->loadClass('pager', $static = true); + $pager = new pager($recTotal, $recPerPage, $pageID); + $scores = $this->loadModel('score')->getScores($pager); + + $this->view->title = $this->lang->score->common; + $this->view->user = $this->loadModel('user')->getById($this->app->user->account); + $this->view->pager = $pager; + $this->view->scores = $scores; + $this->display(); + } + + /** * My todos. * diff --git a/module/my/lang/en.php b/module/my/lang/en.php index eea0299035..a7a97bf96e 100644 --- a/module/my/lang/en.php +++ b/module/my/lang/en.php @@ -18,6 +18,7 @@ $lang->my->unbind = 'Unbind Ranger'; $lang->my->manageContacts = 'Maintain Contact'; $lang->my->deleteContacts = 'Delete Contact'; $lang->my->limited = 'Restricted operation (editing only content related to itself)'; +$lang->my->score = 'Score'; $lang->my->taskMenu = new stdclass(); $lang->my->taskMenu->assignedToMe = 'Assigned to Me'; diff --git a/module/my/lang/zh-cn.php b/module/my/lang/zh-cn.php index 5cc94ef9e7..5730690d15 100644 --- a/module/my/lang/zh-cn.php +++ b/module/my/lang/zh-cn.php @@ -18,6 +18,7 @@ $lang->my->unbind = '解除然之绑定'; $lang->my->manageContacts = '维护联系人'; $lang->my->deleteContacts = '删除联系人'; $lang->my->limited = '受限操作(只能编辑与自己相关的内容)'; +$lang->my->score = '积分'; $lang->my->taskMenu = new stdclass(); $lang->my->taskMenu->assignedToMe = '指派给我'; diff --git a/module/my/lang/zh-tw.php b/module/my/lang/zh-tw.php index 6ee5ca897a..bedb913c94 100644 --- a/module/my/lang/zh-tw.php +++ b/module/my/lang/zh-tw.php @@ -18,6 +18,7 @@ $lang->my->unbind = '解除然之綁定'; $lang->my->manageContacts = '維護聯繫人'; $lang->my->deleteContacts = '刪除聯繫人'; $lang->my->limited = '受限操作(只能編輯與自己相關的內容)'; +$lang->my->score = '積分'; $lang->my->taskMenu = new stdclass(); $lang->my->taskMenu->assignedToMe = '指派給我'; diff --git a/module/score/control.php b/module/score/control.php index f271b7c464..cec152cb98 100644 --- a/module/score/control.php +++ b/module/score/control.php @@ -9,44 +9,6 @@ */ class score extends control { - /** - * score constructor. - * - * @param string $module - * @param string $method - * - * @access public - * @return mixed - */ - public function __construct($module = '', $method = '') - { - parent::__construct($module, $method); - $this->loadModel('my')->setMenu(); - } - - /** - * Get score list - * - * @param int $recTotal - * @param int $recPerPage - * @param int $pageID - * - * @access public - * @return mixed - */ - public function browse($recTotal = 0, $recPerPage = 20, $pageID = 1) - { - $this->app->loadClass('pager', $static = true); - $pager = new pager($recTotal, $recPerPage, $pageID); - $scores = $this->score->getScores($pager); - - $this->view->title = $this->lang->score->common; - $this->view->user = $this->loadModel('user')->getById($this->app->user->account); - $this->view->pager = $pager; - $this->view->scores = $scores; - $this->display(); - } - /** * Ajax action score * @@ -78,8 +40,21 @@ class score extends control $this->display(); } - public function refresh() + public function refresh($lastID = 0) { + if(helper::isAjaxRequest()) + { + $result = $this->score->refresh($lastID); + if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError())); + if($result['status'] == 'finish') + { + $this->send(array('result' => 'finished', 'message' => $this->lang->score->refreshFinish)); + } + else + { + $this->send(array('result' => 'unfinished', 'message' => $this->lang->score->refreshLoading, 'lastID' => $result['lastID'])); + } + } $this->display(); } } \ No newline at end of file diff --git a/module/score/model.php b/module/score/model.php index 2b9b4561c1..b558d4dfdb 100644 --- a/module/score/model.php +++ b/module/score/model.php @@ -48,7 +48,7 @@ class scoreModel extends model switch($model) { case 'user': - if($method == 'login') $desc = $this->lang->score->methods[$model][$method] . 'IP:' . helper::getRemoteIp(); + if($method == 'login') $desc = $this->lang->score->methods[$model][$method]; if($method == 'changePassword') { if(!empty($rule['ext'][$param])) $rule['score'] = $rule['score'] + $rule['ext'][$param]; @@ -87,7 +87,7 @@ class scoreModel extends model } break; case 'bug': - $desc .= 'ID:' . $param; + if(is_numeric($param)) $desc .= 'ID:' . $param; if($method == 'createFormCase') { $desc = $this->lang->score->models['testcase'] . 'ID:' . $param; @@ -125,14 +125,14 @@ class scoreModel extends model $objectID = $param->id; if(!empty($param->PM)) { - $rule['score'] = $param->end > date('Y-m-d') ? $rule['ext']['manager'][0] + $rule['ext']['manager'][1] : $rule['ext']['manager'][0]; + $rule['score'] = $param->end > date('Y-m-d', $time) ? $rule['ext']['manager'][0] + $rule['ext']['manager'][1] : $rule['ext']['manager'][0]; $this->saveScore($param->PM, $rule, $model, $method, $desc, $objectID, $time); } $teams = $this->dao->select('account')->from(TABLE_TEAM)->where('project')->eq($param->id)->fetchGroup('account'); if(!empty($teams)) { $users = array_keys($teams); - $rule['score'] = $param->end > date('Y-m-d') ? $rule['ext']['member'][0] + $rule['ext']['member'][1] : $rule['ext']['member'][0]; + $rule['score'] = $param->end > date('Y-m-d', $time) ? $rule['ext']['member'][0] + $rule['ext']['member'][1] : $rule['ext']['member'][0]; foreach($users as $user) { if($user != $param->PM) $this->saveScore($user, $rule, $model, $method, $desc, $objectID, $time); @@ -208,7 +208,7 @@ class scoreModel extends model $data->after = $user->score + $rule['score']; $data->time = empty($time) ? helper::now() : $time; $this->dao->insert(TABLE_SCORE)->data($data)->exec(); - $this->dao->query("UPDATE " . TABLE_USER . " SET `score`=`score` + " . $rule['score'] . ",`score_level`=`score_level` + " . $rule['score'] . " WHERE `account`='" . $account . "'"); + $this->dao->query("UPDATE " . TABLE_USER . " SET `score`=`score` + " . $rule['score'] . ",`scoreLevel`=`scoreLevel` + " . $rule['score'] . " WHERE `account`='" . $account . "'"); $this->dao->commit(); } catch(ErrorException $e) @@ -218,14 +218,32 @@ class scoreModel extends model } /** - * reset all user score and level score - * + * refresh all user score and level score + * + * @param int $lastID + * * @access public * @return void */ - public function resetScore() + public function refresh($lastID = 0) { - + if($lastID == 0) + { + $this->dao->query("DROP TABLE IF EXISTS `score_bak`"); + $this->dao->query("RENAME TABLE " . TABLE_SCORE . ' TO score_bak'); + $this->dao->query("CREATE TABLE " . TABLE_SCORE . ' LIKE score_bak'); + $this->dao->query("UPDATE " . TABLE_USER . " SET `score`=0,`scoreLevel`=0"); + } + $actions = $this->dao->select('*')->from('score_bak')->where('id')->gt($lastID)->orderBy('id_asc')->limit(100)->fetchAll('id'); + if(empty($actions)) return array('num' => 0, 'status' => 'finish'); + foreach($actions as $action) + { + $param = $action->objectID; + if($action->model == 'project' && $action->method == 'close') $param = $this->dao->findById($action->objectID)->from(TABLE_PROJECT)->fetch(); + if($action->model == 'bug' && ($action->method == 'confirmBug' || $action->method == 'resolve')) $param = $this->dao->findById($action->objectID)->from(TABLE_BUG)->fetch(); + $this->score($action->model, $action->method, $param, $action->account, $action->time); + } + return array('status' => 'more', 'lastID' => max(array_keys($actions))); } /** @@ -240,7 +258,7 @@ class scoreModel extends model { if($lastID == 0) { - $this->dao->query("UPDATE " . TABLE_USER . " SET `score`=0,`score_level`=0"); + $this->dao->query("UPDATE " . TABLE_USER . " SET `score`=0,`scoreLevel`=0"); $this->dao->query("TRUNCATE TABLE " . TABLE_SCORE); } $actions = $this->dao->select('*')->from(TABLE_ACTION)->where('id')->gt($lastID)->orderBy('id_asc')->limit(100)->fetchAll('id'); diff --git a/module/score/view/browse.html.php b/module/score/view/browse.html.php deleted file mode 100644 index 6843840b89..0000000000 --- a/module/score/view/browse.html.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @package score - * @version $Id$ - * @link http://www.zentao.net - */ -?> - -
| score->time; ?> | -score->model; ?> | -score->method; ?> | -score->before; ?> | -score->score; ?> | -score->after; ?> | -score->desc; ?> | -
|---|---|---|---|---|---|---|
| time; ?> | -score->models[$score->model]; ?> | -score->methods[$score->model][$score->method]; ?> | -before; ?> | -score; ?> | -after; ?> | -desc; ?> | -
| - show(); ?> - | -||||||