From 86431ddb80d37a94f979166d405dd643315e9fe5 Mon Sep 17 00:00:00 2001 From: zenggang Date: Tue, 16 Nov 2021 05:34:41 +0000 Subject: [PATCH] * Adjust code style --- module/gitlab/control.php | 20 +++++++++---------- .../css/{groupbrowse.css => browsegroup.css} | 0 .../{projectbrowse.css => browseproject.css} | 0 module/gitlab/lang/en.php | 18 ++++++++--------- module/gitlab/lang/zh-cn.php | 18 ++++++++--------- module/gitlab/model.php | 18 ++++++++--------- module/gitlab/view/browse.html.php | 6 +++--- module/gitlab/view/createuser.html.php | 2 +- module/gitlab/view/edituser.html.php | 2 +- 9 files changed, 41 insertions(+), 43 deletions(-) rename module/gitlab/css/{groupbrowse.css => browsegroup.css} (100%) rename module/gitlab/css/{projectbrowse.css => browseproject.css} (100%) diff --git a/module/gitlab/control.php b/module/gitlab/control.php index 1df00a2f8e..1aad585492 100644 --- a/module/gitlab/control.php +++ b/module/gitlab/control.php @@ -391,18 +391,17 @@ class gitlab extends control { if($_POST) { - $data = (array) fixer::input('post')->get(); - extract($data); + $data = fixer::input('post')->get(); - $ids = array_filter($ids); + $ids = array_filter($data->ids); if(count($ids) != count(array_unique($ids))) return $this->send(array('result' => 'fail', 'message' => $this->lang->gitlab->group->repeatError)); $newMembers = array(); foreach($ids as $key => $id) { /* Check whether each member has selected accesslevel. */ - if(empty($levels[$key])) return $this->send(array('result' => 'fail', 'message' => $this->lang->gitlab->group->memberAccessLevel . $this->lang->gitlab->group->emptyError )); + if(empty($data->levels[$key])) return $this->send(array('result' => 'fail', 'message' => $this->lang->gitlab->group->memberAccessLevel . $this->lang->gitlab->group->emptyError )); - $newMembers[$id] = (object)array('access_level'=>$levels[$key], 'expires_at'=>$expires[$key]); + $newMembers[$id] = (object)array('access_level'=>$data->levels[$key], 'expires_at'=>$data->expires[$key]); } $currentMembers = $this->gitlab->apiGetGroupMembers($gitlabID, $groupID); @@ -812,10 +811,9 @@ class gitlab extends control { if($_POST) { - $data = (array) fixer::input('post')->get(); - extract($data); + $data = fixer::input('post')->get(); - $accounts = array_filter($accounts); + $accounts = array_filter($data->accounts); if(count($accounts) != count(array_unique($accounts))) return $this->send(array('result' => 'fail', 'message' => $this->lang->gitlab->group->repeatError)); $repo = $this->loadModel('repo')->getRepoByID($repoID); @@ -830,10 +828,10 @@ class gitlab extends control foreach($accounts as $key => $account) { /* If the user has set permissions, check whether they are bound. */ - if(!empty($levels[$key])) + if(!empty($data->levels[$key])) { if(!isset($bindedUsers[$account])) return $this->send(array('result' => 'fail', 'message' => $users[$account] . ' ' . $this->lang->gitlab->project->notbindedError)); - $newGitlabMembers[$bindedUsers[$account]] = (object) array('access_level' => $levels[$key], 'expires_at' => $expires[$key]); + $newGitlabMembers[$bindedUsers[$account]] = (object) array('access_level' => $data->levels[$key], 'expires_at' => $data->expires[$key]); } } @@ -918,7 +916,7 @@ class gitlab extends control $users = $this->loadModel('user')->getPairs('noletter|noempty|nodeleted'); $projectMembers = $this->gitlab->apiGetProjectMembers($repo->gitlab, $repo->project); - /* Get users accesslevel */ + /* Get users accesslevel. */ $userAccessData = array(); $bindedUsers = $this->dao->select('openID,account') ->from(TABLE_OAUTH) diff --git a/module/gitlab/css/groupbrowse.css b/module/gitlab/css/browsegroup.css similarity index 100% rename from module/gitlab/css/groupbrowse.css rename to module/gitlab/css/browsegroup.css diff --git a/module/gitlab/css/projectbrowse.css b/module/gitlab/css/browseproject.css similarity index 100% rename from module/gitlab/css/projectbrowse.css rename to module/gitlab/css/browseproject.css diff --git a/module/gitlab/lang/en.php b/module/gitlab/lang/en.php index ff3d6cce51..eb460eb6df 100644 --- a/module/gitlab/lang/en.php +++ b/module/gitlab/lang/en.php @@ -56,17 +56,17 @@ $lang->gitlab->bindUserError = "Can not bind users repeatedly %s"; $lang->gitlab->importIssueError = "The execution to which this issue belongs is not selected."; $lang->gitlab->importIssueWarn = "There is a problem of import failure, you can try to import again."; -$lang->gitlab->accessLevel[10] = 'Guest'; -$lang->gitlab->accessLevel[20] = 'Reporter'; -$lang->gitlab->accessLevel[30] = 'Developer'; -$lang->gitlab->accessLevel[40] = 'Maintainer'; -$lang->gitlab->accessLevel[50] = 'Owner'; +$lang->gitlab->accessLevels[10] = 'Guest'; +$lang->gitlab->accessLevels[20] = 'Reporter'; +$lang->gitlab->accessLevels[30] = 'Developer'; +$lang->gitlab->accessLevels[40] = 'Maintainer'; +$lang->gitlab->accessLevels[50] = 'Owner'; $lang->gitlab->project = new stdclass; $lang->gitlab->project->id = "Project ID"; $lang->gitlab->project->name = "Project name"; -$lang->gitlab->project->create = "Create {$lang->gitlab->gitlabProject}"; -$lang->gitlab->project->edit = "Edit {$lang->gitlab->gitlabProject}"; +$lang->gitlab->project->create = "Create Gitlab project"; +$lang->gitlab->project->edit = "Edit Gitlab project"; $lang->gitlab->project->url = "Project URL"; $lang->gitlab->project->path = "Project slug"; $lang->gitlab->project->description = "Project description"; @@ -104,8 +104,8 @@ $lang->gitlab->user->websiteUrl = "Website url"; $lang->gitlab->user->note = "Note"; $lang->gitlab->user->createOn = "Created on"; $lang->gitlab->user->lastActivity = "Last activity"; -$lang->gitlab->user->create = "Create {$lang->gitlab->gitlabAccount}"; -$lang->gitlab->user->edit = "Edit {$lang->gitlab->gitlabAccount}"; +$lang->gitlab->user->create = "Create Gitlab user"; +$lang->gitlab->user->edit = "Edit Gitlab user"; $lang->gitlab->user->emptyError = "cannot be empty"; $lang->gitlab->user->passwordError = "The second password is inconsistent!"; $lang->gitlab->user->bindError = "The user has been bound!"; diff --git a/module/gitlab/lang/zh-cn.php b/module/gitlab/lang/zh-cn.php index 8b6e750e23..71958c83b5 100644 --- a/module/gitlab/lang/zh-cn.php +++ b/module/gitlab/lang/zh-cn.php @@ -56,17 +56,17 @@ $lang->gitlab->bindUserError = "不能重复绑定用户 %s"; $lang->gitlab->importIssueError = "未选择该issue所属的执行。"; $lang->gitlab->importIssueWarn = "存在导入失败的issue,可再次尝试导入。"; -$lang->gitlab->accessLevels[10] = '客人'; -$lang->gitlab->accessLevels[20] = '报告者'; -$lang->gitlab->accessLevels[30] = '开发者'; -$lang->gitlab->accessLevels[40] = '维护者'; -$lang->gitlab->accessLevels[50] = '所有者'; +$lang->gitlab->accessLevels[10] = 'Guest'; +$lang->gitlab->accessLevels[20] = 'Reporter'; +$lang->gitlab->accessLevels[30] = 'Developer'; +$lang->gitlab->accessLevels[40] = 'Maintainer'; +$lang->gitlab->accessLevels[50] = 'Owner'; $lang->gitlab->project = new stdclass; $lang->gitlab->project->id = "项目ID"; $lang->gitlab->project->name = "项目名称"; -$lang->gitlab->project->create = "添加{$lang->gitlab->gitlabProject}"; -$lang->gitlab->project->edit = "编辑{$lang->gitlab->gitlabProject}"; +$lang->gitlab->project->create = "添加Gitlab项目"; +$lang->gitlab->project->edit = "编辑Gitlab项目"; $lang->gitlab->project->url = "项目 URL"; $lang->gitlab->project->path = "项目标识串"; $lang->gitlab->project->description = "项目描述"; @@ -104,8 +104,8 @@ $lang->gitlab->user->websiteUrl = "网站地址"; $lang->gitlab->user->note = "备注"; $lang->gitlab->user->createOn = "创建于"; $lang->gitlab->user->lastActivity = "上次活动"; -$lang->gitlab->user->create = "添加{$lang->gitlab->gitlabAccount}"; -$lang->gitlab->user->edit = "编辑{$lang->gitlab->gitlabAccount}"; +$lang->gitlab->user->create = "添加Gitlab用户"; +$lang->gitlab->user->edit = "编辑Gitlab用户"; $lang->gitlab->user->emptyError = "不能为空"; $lang->gitlab->user->passwordError = "二次密码不一致!"; $lang->gitlab->user->bindError = "该用户已经被绑定!"; diff --git a/module/gitlab/model.php b/module/gitlab/model.php index d1e116197d..aa6e3385aa 100644 --- a/module/gitlab/model.php +++ b/module/gitlab/model.php @@ -2015,12 +2015,12 @@ class gitlabModel extends model return false; } /* Check whether the user has been bind. */ - if($user->bind) + if($user->account) { - $zentaoBindUser = $this->dao->select('account')->from(TABLE_OAUTH)->where('providerType')->eq('gitlab')->andWhere('providerID')->eq($gitlabID)->andWhere('account')->eq($user->bind)->fetch(); + $zentaoBindUser = $this->dao->select('account')->from(TABLE_OAUTH)->where('providerType')->eq('gitlab')->andWhere('providerID')->eq($gitlabID)->andWhere('account')->eq($user->account)->fetch(); if($zentaoBindUser) { - dao::$errors['bind'][] = $this->lang->gitlab->user->bindError; + dao::$errors['account'][] = $this->lang->gitlab->user->bindError; return false; } } @@ -2030,12 +2030,12 @@ class gitlabModel extends model if(!empty($reponse->id)) { /* Bind user. */ - if($user->bind) + if($user->account) { $userBind = new stdclass; $userBind->providerID = $gitlabID; $userBind->providerType = 'gitlab'; - $userBind->account = $user->bind; + $userBind->account = $user->account; $userBind->openID = $reponse->id; $this->dao->insert(TABLE_OAUTH)->data($userBind)->exec(); } @@ -2067,9 +2067,9 @@ class gitlabModel extends model return false; } /* Check whether the user has been bind. */ - if($user->bind) + if($user->account) { - $zentaoBindUser = $this->dao->select('account')->from(TABLE_OAUTH)->where('providerType')->eq('gitlab')->andWhere('providerID')->eq($gitlabID)->andWhere('account')->eq($user->bind)->fetch(); + $zentaoBindUser = $this->dao->select('account')->from(TABLE_OAUTH)->where('providerType')->eq('gitlab')->andWhere('providerID')->eq($gitlabID)->andWhere('account')->eq($user->account)->fetch(); $changeBind = (!$zentaoBindUser or $zentaoBindUser->openID != $user->id) ? true : false; if($zentaoBindUser && $changeBind) { @@ -2083,12 +2083,12 @@ class gitlabModel extends model if(!empty($reponse->id)) { /* Bind user. */ - if($user->bind && $changeBind) + if($user->account && $changeBind) { $userBind = new stdclass; $userBind->providerID = $gitlabID; $userBind->providerType = 'gitlab'; - $userBind->account = $user->bind; + $userBind->account = $user->account; $userBind->openID = $reponse->id; $this->dao->replace(TABLE_OAUTH)->data($userBind)->exec(); } diff --git a/module/gitlab/view/browse.html.php b/module/gitlab/view/browse.html.php index 5bfcea49e1..de475d25e6 100644 --- a/module/gitlab/view/browse.html.php +++ b/module/gitlab/view/browse.html.php @@ -47,10 +47,10 @@ isAdminToken) ? '' : 'disabled'; - common::printLink('gitlab', 'projectBrowse', "gitlabID=$id", " ", '',"title={$lang->gitlab->browseProject} class='btn btn-primary'"); - common::printLink('gitlab', 'groupBrowse', "gitlabID=$id", " ", '', "title={$lang->gitlab->browseGroup} class='btn btn-primary'"); + common::printLink('gitlab', 'browseProject', "gitlabID=$id", " ", '',"title={$lang->gitlab->browseProject} class='btn btn-primary'"); + common::printLink('gitlab', 'browseGroup', "gitlabID=$id", " ", '', "title={$lang->gitlab->browseGroup} class='btn btn-primary'"); common::printLink('gitlab', 'edit', "gitlabID=$id", " ", '',"title={$lang->gitlab->edit} class='btn btn-primary'"); - common::printLink('gitlab', 'userBrowse', "gitlabID=$id", " ", '', "title={$lang->gitlab->browseUser} class='btn {$disabled}' ,'disabled'"); + common::printLink('gitlab', 'browseUser', "gitlabID=$id", " ", '', "title={$lang->gitlab->browseUser} class='btn {$disabled}' ,'disabled'"); common::printLink('gitlab', 'bindUser', "id=$id", " ", '', "title={$lang->gitlab->bindUser} class='btn {$disabled}' ,'disabled'"); if(common::hasPriv('gitlab', 'delete')) echo html::a($this->createLink('gitlab', 'delete', "gitlabID=$id"), '', 'hiddenwin', "title='{$lang->gitlab->delete}' class='btn'"); ?> diff --git a/module/gitlab/view/createuser.html.php b/module/gitlab/view/createuser.html.php index 58f1842199..4e897a7c68 100644 --- a/module/gitlab/view/createuser.html.php +++ b/module/gitlab/view/createuser.html.php @@ -65,7 +65,7 @@ gitlab->user->bind;?> - + diff --git a/module/gitlab/view/edituser.html.php b/module/gitlab/view/edituser.html.php index 25b24b8e49..b4217039f9 100644 --- a/module/gitlab/view/edituser.html.php +++ b/module/gitlab/view/edituser.html.php @@ -66,7 +66,7 @@ gitlab->user->bind;?> - +