gitlabwebhook.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * The repo entry point of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.cnezsoft.com)
  6. * @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author xiawenlong <xiawenlong@cnezsoft.com>
  8. * @package repo
  9. * @version 1
  10. * @link https://www.zentao.net
  11. */
  12. class gitlabWebhookEntry extends baseEntry
  13. {
  14. /**
  15. * Repo webhook.
  16. *
  17. * @access public
  18. * @return string
  19. */
  20. public function post()
  21. {
  22. $headers = getallheaders(); /* Fetch all HTTP request headers. */
  23. $event = isset($headers['X-Gitlab-Event']) ? $headers['X-Gitlab-Event'] : '';
  24. if(empty($event)) return;
  25. $repoID = $this->param('repoID');
  26. if(empty($repoID)) return;
  27. $this->app->user = new stdclass();
  28. $this->app->user->account = '';
  29. $this->app->user->admin = false;
  30. $this->app->user->rights['rights'] = array();
  31. $this->app->user->rights['acls'] = array();
  32. $repo = $this->loadModel('repo')->getByID($repoID);
  33. if(empty($repo)) return;
  34. $this->loadController('user', 'login');
  35. $this->repo->handleWebhook($event, $this->requestBody, $repo);
  36. }
  37. }