diff --git a/config/zentaopms.php b/config/zentaopms.php index b5e0f771de..a0b8dc0ede 100644 --- a/config/zentaopms.php +++ b/config/zentaopms.php @@ -179,7 +179,7 @@ define('TABLE_LOG', '`' . $config->db->prefix . 'log`'); define('TABLE_SCORE', '`' . $config->db->prefix . 'score`'); define('TABLE_NOTIFY', '`' . $config->db->prefix . 'notify`'); define('TABLE_OAUTH', '`' . $config->db->prefix . 'oauth`'); -define('TABLE_PIPLINE', '`' . $config->db->prefix . 'jenkins`'); +define('TABLE_PIPLINE', '`' . $config->db->prefix . 'pipline`'); define('TABLE_JOB', '`' . $config->db->prefix . 'job`'); define('TABLE_COMPILE', '`' . $config->db->prefix . 'compile`'); diff --git a/module/gitlab/config.php b/module/gitlab/config.php index 854bdb3c4d..3a840d46db 100644 --- a/module/gitlab/config.php +++ b/module/gitlab/config.php @@ -2,5 +2,5 @@ $config->gitlab->create = new stdclass(); $config->gitlab->edit = new stdclass(); -$config->gitlab->create->requiredFields = 'name,url'; -$config->gitlab->edit->requiredFields = 'name,url'; +$config->gitlab->create->requiredFields = 'name,url,token'; +$config->gitlab->edit->requiredFields = 'name,url,token'; diff --git a/module/gitlab/control.php b/module/gitlab/control.php index f00cc8b081..c83b1e0103 100644 --- a/module/gitlab/control.php +++ b/module/gitlab/control.php @@ -72,7 +72,9 @@ class gitlab extends control */ public function bind() { - echo 123;die; + var_dump($this->gitlab->getPermissionsByToken('http://127.0.0.1:8090/','rpz2PZKriNE6TD34QtDA')); + die; + $this->display(); } @@ -113,7 +115,7 @@ class gitlab extends control { if($confim != 'yes') die(js::confirm($this->lang->gitlab->confirmDelete, inlink('delete', "id=$id&confirm=yes"))); - $this->gitlab->delete(TABLE_GITLAB, $id); + $this->gitlab->delete(TABLE_PIPLINE, $id); die(js::reload('parent')); } diff --git a/module/gitlab/js/create.js b/module/gitlab/js/create.js index 6410b0fdc0..549191d4ee 100644 --- a/module/gitlab/js/create.js +++ b/module/gitlab/js/create.js @@ -1,24 +1,25 @@ $(function () { - $('#token, #url').change(function () { - //取用户名 - var uid = $("#uid").val(); + $('#url,#token').change(function () { + $('#url, #url').change(function () { + host = Base64.encode($('#url').val()); + token = $('#token').val(); + url = createLink('gitlab', 'ajaxCheckToken', "host=" + host + '&token=' + token); + if (host == '' || token == '') return false; + + $.get(url, function (response) { + if(response.message == '401 Unauthorized') + { + $('td.demand').each(function() { + var dl = $(this).text(); + // change the td html to the link, referencing the DL-XXX number + $(this).html('' + dl + ''); + }); + }else if (response.message == '403 Forbidden'){ + + }else { - //调ajax - $.ajax({ - url: "uidchuli.php", - data: {u: uid}, - type: "POST", - dataType: "TEXT", - success: function (data) { - if (data > 0) { - $("#ts").html("该应户名已存在"); - $("#ts").css("color", "red"); - } else { - $("#ts").html("该应户名可用"); - $("#ts").css("color", "green"); } - } - + }); }); - }) + }); }); diff --git a/module/gitlab/model.php b/module/gitlab/model.php index 51d296384a..e1a9f6873b 100644 --- a/module/gitlab/model.php +++ b/module/gitlab/model.php @@ -21,7 +21,7 @@ class gitlabModel extends model */ public function getByID($id) { - $gitlab = $this->dao->select('*')->from(TABLE_JENKINS)->where('id')->eq($id)->fetch(); + $gitlab = $this->dao->select('*')->from(TABLE_PIPLINE)->where('id')->eq($id)->fetch(); $gitlab->password = base64_decode($gitlab->password); return $gitlab; @@ -37,7 +37,7 @@ class gitlabModel extends model */ public function getList($orderBy = 'id_desc', $pager = null) { - return $this->dao->select('*')->from(TABLE_JENKINS) + return $this->dao->select('*')->from(TABLE_PIPLINE) ->where('deleted')->eq('0') ->andwhere('type')->eq('1') ->orderBy($orderBy) @@ -52,7 +52,7 @@ class gitlabModel extends model */ public function getPairs() { - $gitlab = $this->dao->select('id,name')->from(TABLE_JENKINS) + $gitlab = $this->dao->select('id,name')->from(TABLE_PIPLINE) ->where('deleted')->eq('0') ->orderBy('id')->fetchPairs('id', 'name'); $gitlab = array('' => '') + $gitlab; @@ -74,9 +74,9 @@ class gitlabModel extends model ->skipSpecial('url,token') ->get(); - $this->dao->insert(TABLE_JENKINS)->data($gitlab) + + $this->dao->insert(TABLE_PIPLINE)->data($gitlab) ->batchCheck($this->config->gitlab->create->requiredFields, 'notempty') - ->batchCheck("url", 'URL') ->autoCheck() ->exec(); if(dao::isError()) return false; @@ -98,7 +98,7 @@ class gitlabModel extends model ->skipSpecial('url,token') ->get(); - $this->dao->update(TABLE_JENKINS)->data($gitlab) + $this->dao->update(TABLE_PIPLINE)->data($gitlab) ->batchCheck($this->config->gitlab->edit->requiredFields, 'notempty') ->batchCheck("url", 'URL') ->autoCheck() @@ -118,7 +118,7 @@ class gitlabModel extends model public function getPermissionsByToken($host, $token) { $host = rtrim($host, '/'); - $host .= '/api/v4/activities'; + $host .= '/api/v4/user/activities'; $results = json_decode(file_get_contents($host . "?private_token=$token")); diff --git a/module/gitlab/view/create.html.php b/module/gitlab/view/create.html.php index c34e0d8d05..9340117584 100644 --- a/module/gitlab/view/create.html.php +++ b/module/gitlab/view/create.html.php @@ -32,7 +32,7 @@