From e47515aa62804a2b01e264e3b2956aca413f8c56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BB=94=E5=93=A5?= Date: Fri, 14 Sep 2018 10:52:58 +0800 Subject: [PATCH 1/3] * Finish task#4794 --- db/update10.3.1.sql | 3 +++ module/common/model.php | 10 ++++++++++ module/entry/config.php | 1 + module/entry/control.php | 2 ++ module/entry/lang/en.php | 1 + module/entry/lang/zh-cn.php | 1 + module/entry/view/create.html.php | 5 +++++ module/entry/view/edit.html.php | 7 ++++++- 8 files changed, 29 insertions(+), 1 deletion(-) diff --git a/db/update10.3.1.sql b/db/update10.3.1.sql index cf99b234bf..6dd225d20f 100644 --- a/db/update10.3.1.sql +++ b/db/update10.3.1.sql @@ -4,3 +4,6 @@ CREATE TABLE `zt_userview` ( `projects` text NOT NULL, UNIQUE KEY `account` (`account`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +ALTER TABLE `zt_entry` ADD `account` VARCHAR(30) NOT NULL DEFAULT '' AFTER `code`; + diff --git a/module/common/model.php b/module/common/model.php index 7ba0904287..80c0620129 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -1601,9 +1601,19 @@ EOD; $entry = $this->entry->getByCode($this->get->code); if(!$entry) $this->response('EMPTY_ENTRY'); if(!$entry->key) $this->response('EMPTY_KEY'); + if(empty($entry->account)) $this->response('ACCOUNT_UNBOUND'); if(!$this->checkIP($entry->ip)) $this->response('IP_DENIED'); if(!$this->checkEntryToken($entry->key)) $this->response('INVALID_TOKEN'); + $this->loadModel('user'); + $user = $this->dao->findByAccount($entry->account)->from(TABLE_USER)->fetch(); + $user->rights = $this->user->authorize($user->account); + $user->groups = $this->user->getGroups($user->account); + $user->view = $this->user->grantUserView($user->account, $user->rights['acls']); + $user->admin = strpos($this->app->company->admins, ",{$user->account},") !== false; + $this->session->set('user', $user); + $this->app->user = $user; + $this->session->set('ENTRY_CODE', $this->get->code); $this->session->set('VALID_ENTRY', md5(md5($this->get->code) . $this->server->remote_addr)); $this->loadModel('entry')->saveLog($entry->id, $this->server->request_uri); diff --git a/module/entry/config.php b/module/entry/config.php index 7f529f1375..e35c03c351 100644 --- a/module/entry/config.php +++ b/module/entry/config.php @@ -14,4 +14,5 @@ $config->entry->errcode['EMPTY_KEY'] = 401; $config->entry->errcode['INVALID_TOKEN'] = 401; $config->entry->errcode['SESSION_VERIFY_FAILED'] = 401; $config->entry->errcode['IP_DENIED'] = 403; +$config->entry->errcode['ACCOUNT_UNBOUND'] = 403; $config->entry->errcode['EMPTY_ENTRY'] = 404; diff --git a/module/entry/control.php b/module/entry/control.php index dcd86a9293..31d15f2d3a 100644 --- a/module/entry/control.php +++ b/module/entry/control.php @@ -53,6 +53,7 @@ class entry extends control } $this->view->title = $this->lang->entry->api . $this->lang->colon . $this->lang->entry->create; + $this->view->users = $this->loadModel('user')->getPairs('nodeleted|noclosed'); $this->view->position[] = html::a(inlink('browse'), $this->lang->entry->api); $this->view->position[] = html::a(inlink('browse'), $this->lang->entry->common); $this->view->position[] = $this->lang->entry->create; @@ -83,6 +84,7 @@ class entry extends control $entry = $this->entry->getById($id); $this->view->title = $this->lang->entry->edit . $this->lang->colon . $entry->name; + $this->view->users = $this->loadModel('user')->getPairs('nodeleted|noclosed'); $this->view->position[] = html::a(inlink('browse'), $this->lang->entry->api); $this->view->position[] = html::a(inlink('browse'), $this->lang->entry->common); $this->view->position[] = $this->lang->entry->edit; diff --git a/module/entry/lang/en.php b/module/entry/lang/en.php index 4465605caf..bad65cec59 100644 --- a/module/entry/lang/en.php +++ b/module/entry/lang/en.php @@ -14,6 +14,7 @@ $lang->entry->createKey = 'Regenerate'; $lang->entry->id = 'ID'; $lang->entry->name = 'Name'; +$lang->entry->account = 'Account'; $lang->entry->code = 'Code'; $lang->entry->key = 'Key'; $lang->entry->ip = 'IP'; diff --git a/module/entry/lang/zh-cn.php b/module/entry/lang/zh-cn.php index ab2b5553da..bc85af9863 100644 --- a/module/entry/lang/zh-cn.php +++ b/module/entry/lang/zh-cn.php @@ -14,6 +14,7 @@ $lang->entry->createKey = '重新生成密钥'; $lang->entry->id = 'ID'; $lang->entry->name = '名称'; +$lang->entry->account = '账号'; $lang->entry->code = '代号'; $lang->entry->key = '密钥'; $lang->entry->ip = 'IP'; diff --git a/module/entry/view/create.html.php b/module/entry/view/create.html.php index 32babe1cba..8fb3dac71b 100644 --- a/module/entry/view/create.html.php +++ b/module/entry/view/create.html.php @@ -32,6 +32,11 @@ entry->note->code}' placeholder='{$lang->entry->note->code}'");?> + + entry->account;?> + + + entry->key;?> diff --git a/module/entry/view/edit.html.php b/module/entry/view/edit.html.php index d2a65bfb50..c4211a126d 100644 --- a/module/entry/view/edit.html.php +++ b/module/entry/view/edit.html.php @@ -31,6 +31,11 @@ entry->code;?> code, "class='form-control' title='{$lang->entry->note->code}' placeholder='{$lang->entry->note->code}'");?> + + + entry->account;?> + account, "class='form-control chosen'");?> + entry->key;?> key, "class='form-control' readonly='readonly'");?> @@ -53,7 +58,7 @@ - + entry->help, $lang->entry->help, '_blank', "class='help'");?> From dd282e82cb22215717b8dd12bf1fd99da0270400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BB=94=E5=93=A5?= Date: Fri, 14 Sep 2018 10:55:43 +0800 Subject: [PATCH 2/3] * Fix bug. --- module/entry/lang/en.php | 1 + module/entry/lang/zh-cn.php | 1 + 2 files changed, 2 insertions(+) diff --git a/module/entry/lang/en.php b/module/entry/lang/en.php index bad65cec59..e08a5918bd 100644 --- a/module/entry/lang/en.php +++ b/module/entry/lang/en.php @@ -42,4 +42,5 @@ $lang->entry->errmsg['EMPTY_KEY'] = 'Key of entry is missing.'; $lang->entry->errmsg['INVALID_TOKEN'] = 'Invalid token.'; $lang->entry->errmsg['SESSION_VERIFY_FAILED'] = 'Session verification failed.'; $lang->entry->errmsg['IP_DENIED'] = 'IP is denied.'; +$lang->entry->errmsg['ACCOUNT_UNBOUND'] = 'Account unbound.'; $lang->entry->errmsg['EMPTY_ENTRY'] = 'Key of entry is missing.'; diff --git a/module/entry/lang/zh-cn.php b/module/entry/lang/zh-cn.php index bc85af9863..d3019c83d6 100644 --- a/module/entry/lang/zh-cn.php +++ b/module/entry/lang/zh-cn.php @@ -42,4 +42,5 @@ $lang->entry->errmsg['EMPTY_KEY'] = '应用未设置密钥'; $lang->entry->errmsg['INVALID_TOKEN'] = '无效的token参数'; $lang->entry->errmsg['SESSION_VERIFY_FAILED'] = 'session验证失败'; $lang->entry->errmsg['IP_DENIED'] = '该IP被限制访问'; +$lang->entry->errmsg['ACCOUNT_UNBOUND'] = '未绑定用户'; $lang->entry->errmsg['EMPTY_ENTRY'] = '应用不存在'; From 10a69fdafe5951a167f9304e741c3214a340b0d2 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Fri, 14 Sep 2018 11:26:06 +0800 Subject: [PATCH 3/3] * adjust for new get projects. --- module/bug/model.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/module/bug/model.php b/module/bug/model.php index 371b1cdfd8..66e5e62de8 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -1335,14 +1335,13 @@ class bugModel extends model */ public function getUserBugPairs($account, $appendProduct = true, $limit = 0) { - $projects = $this->loadModel('project')->getPairs('empty|withdelete'); $bugs = array(); $stmt = $this->dao->select('t1.id, t1.title, t2.name as product') ->from(TABLE_BUG)->alias('t1') ->leftJoin(TABLE_PRODUCT)->alias('t2') ->on('t1.product=t2.id') ->where('t1.assignedTo')->eq($account) - ->andWhere('t1.project')->in(array_keys($projects)) + ->beginIF(!$this->app->user->admin)->andWhere('t1.project')->in($this->app->user->view->projects)->fi() ->andWhere('t1.deleted')->eq(0) ->orderBy('id desc') ->beginIF($limit > 0)->limit($limit)->fi()