From 7ee8e8dbef4e9e9e6c538f4d2d5c11ce6f29a75f Mon Sep 17 00:00:00 2001 From: zenggang Date: Mon, 8 Nov 2021 06:25:03 +0000 Subject: [PATCH] * Add gitlab user avatar --- module/gitlab/css/createuser.css | 4 ++++ module/gitlab/js/createuser.js | 17 +++++++++++++++++ module/gitlab/lang/en.php | 1 + module/gitlab/lang/zh-cn.php | 1 + module/gitlab/model.php | 1 + module/gitlab/view/browse.html.php | 4 ++-- module/gitlab/view/createuser.html.php | 16 ++++++++++++++-- 7 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 module/gitlab/css/createuser.css create mode 100644 module/gitlab/js/createuser.js diff --git a/module/gitlab/css/createuser.css b/module/gitlab/css/createuser.css new file mode 100644 index 0000000000..2d047c2e0a --- /dev/null +++ b/module/gitlab/css/createuser.css @@ -0,0 +1,4 @@ +#avatarUpload {display: inline-block; width: 50px; height: 50px; position: relative;} +#avatarUploadBtn {display: block; position: absolute; top: 0; left: 0; right: 0; bottom: 0;} +#avatarUploadBtn {opacity: 0; color: #fff; border-radius: 50%; line-height: 50px;} +#avatarUploadBtn:hover {opacity: 1; background-color: rgba(0,0,0,.5);} \ No newline at end of file diff --git a/module/gitlab/js/createuser.js b/module/gitlab/js/createuser.js new file mode 100644 index 0000000000..a9181027e8 --- /dev/null +++ b/module/gitlab/js/createuser.js @@ -0,0 +1,17 @@ +$(document).ready(function() +{ + $('#avatarUploadBtn').on('click', function() + { + $('#files').click(); + }); + $("#files").change(function(){ + var files = this.files; + if(!files.length) + { + return; + } + + $(".avatar img").attr("src", window.URL.createObjectURL(files[0])); + $(".avatar").removeClass('hidden'); + }); +}); \ No newline at end of file diff --git a/module/gitlab/lang/en.php b/module/gitlab/lang/en.php index c41f37ce6c..3ef8062003 100644 --- a/module/gitlab/lang/en.php +++ b/module/gitlab/lang/en.php @@ -85,6 +85,7 @@ $lang->gitlab->user->canCreateGroup = "Can create group"; $lang->gitlab->user->external = "External"; $lang->gitlab->user->externalTip = "External users cannot see internal or private projects unless access is explicitly granted. Also, external users cannot create projects, groups, or personal snippets."; $lang->gitlab->user->bind = "Bind Zentao user"; +$lang->gitlab->user->avatar = "Avatar"; $lang->gitlab->user->skype = "Skype"; $lang->gitlab->user->linkedin = "Linkedin"; $lang->gitlab->user->twitter = "Twitter"; diff --git a/module/gitlab/lang/zh-cn.php b/module/gitlab/lang/zh-cn.php index e5d0f8d65f..525f36b6bb 100644 --- a/module/gitlab/lang/zh-cn.php +++ b/module/gitlab/lang/zh-cn.php @@ -85,6 +85,7 @@ $lang->gitlab->user->canCreateGroup = "可创建组"; $lang->gitlab->user->external = "外部人员"; $lang->gitlab->user->externalTip = "除非明确授予访问权限,否则外部用户无法查看内部或私有项目。另外,外部用户无法创建项目,群组或个人代码片段。"; $lang->gitlab->user->bind = "绑定禅道用户"; +$lang->gitlab->user->avatar = "头像"; $lang->gitlab->user->skype = "Skype"; $lang->gitlab->user->linkedin = "Linkedin"; $lang->gitlab->user->twitter = "Twitter"; diff --git a/module/gitlab/model.php b/module/gitlab/model.php index fcbd385ad3..9d18684664 100644 --- a/module/gitlab/model.php +++ b/module/gitlab/model.php @@ -1691,6 +1691,7 @@ class gitlabModel extends model public function createUser($gitlabID) { $user = fixer::input('post')->get(); + if($_FILES['avatar']) $user->avatar = curl_file_create($_FILES['avatar']['tmp_name'], $_FILES['avatar']['type'], $_FILES['avatar']['name']); if(empty($user->name)) dao::$errors['name'][] = $this->lang->gitlab->user->name . $this->lang->gitlab->user->emptyError; if(empty($user->username)) dao::$errors['username'][] = $this->lang->gitlab->user->username . $this->lang->gitlab->user->emptyError; diff --git a/module/gitlab/view/browse.html.php b/module/gitlab/view/browse.html.php index 1cf719fe7d..13e8707a29 100644 --- a/module/gitlab/view/browse.html.php +++ b/module/gitlab/view/browse.html.php @@ -49,8 +49,8 @@ $disabled = !empty($gitlab->isAdminToken) ? '' : 'disabled'; common::printLink('gitlab', 'projectBrowse', "gitlabID=$id", " ", '',"title={$lang->gitlab->browseProject} 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', 'bindUser', "id=$id", " ", '', "title={$lang->gitlab->bindUser} class='btn {$disabled}' ,'disabled'"); + common::printLink('gitlab', 'userBrowse', "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 a3a268a072..f2a09473fa 100644 --- a/module/gitlab/view/createuser.html.php +++ b/module/gitlab/view/createuser.html.php @@ -18,7 +18,7 @@

gitlab->user->create;?>

-
+ @@ -68,6 +68,18 @@ + + + + + + @@ -92,7 +104,7 @@
gitlab->user->name;?>gitlab->user->bind;?>
gitlab->user->avatar;?> +
+ ' ', 'account'=>''), 50); ?> + + ', '', "class='btn-avatar' id='avatarUploadBtn' data-toggle='tooltip' data-container='body' data-placement='bottom' title='{$lang->gitlab->user->avatar}'");?> +
+
gitlab->user->skype;?> gitlab->user->skype}'");?> - goback, '', 'class="btn btn-wide"');?> + goback, '', 'class="btn btn-wide"');?>