BxGitHubConfig.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup GitHub GitHub
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxGitHubConfig extends BxBaseModGeneralConfig
  12. {
  13. protected $_oDb;
  14. protected $_sAuthorize;
  15. public function __construct($aModule)
  16. {
  17. parent::__construct($aModule);
  18. $this->CNF = array (
  19. // database tables
  20. 'TABLE_APPS' => $aModule['db_prefix'] . 'apps',
  21. 'TABLE_AUTHORIZATIONS' => $aModule['db_prefix'] . 'authorizations',
  22. 'TABLE_SETTINGS' => $aModule['db_prefix'] . 'settings',
  23. // database fields
  24. 'FIELD_' => '',
  25. // some params
  26. 'PARAM_AUTHORIZE' => 'bx_github_authorize',
  27. // page URIs
  28. 'URL_SETTINGS' => 'page.php?i=github-settings',
  29. // objects
  30. 'OBJECT_FORM_APPS' => 'bx_github_form_apps',
  31. 'OBJECT_FORM_APPS_DISPLAY_ADD' => 'bx_github_form_apps_add',
  32. 'OBJECT_FORM_APPS_DISPLAY_EDIT' => 'bx_github_form_apps_edit',
  33. 'OBJECT_FORM_SETTINGS' => 'bx_github_form_settings',
  34. 'OBJECT_FORM_SETTINGS_DISPLAY_EDIT' => 'bx_github_form_settings_edit',
  35. 'OBJECT_GRID_APPS' => 'bx_github_apps',
  36. 'OBJECT_GRID_AUTHORIZATIONS' => 'bx_github_authorizations',
  37. 'OBJECT_LOG_API' => 'bx_github_api'
  38. );
  39. $sHtmlPrefix = str_replace('_', '-', $this->_sName);
  40. $this->_aHtmlIds = array_merge($this->_aHtmlIds, [
  41. 'apps_popup_add' => $sHtmlPrefix . '-popup-apps-add',
  42. 'apps_popup_edit' => $sHtmlPrefix . '-popup-apps-edit'
  43. ]);
  44. }
  45. public function init(&$oDb)
  46. {
  47. $this->_oDb = &$oDb;
  48. $this->_sAuthorize = getParam($this->CNF['PARAM_AUTHORIZE']);
  49. }
  50. public function getAuthorize()
  51. {
  52. return $this->_sAuthorize;
  53. }
  54. public function isAuthorizeByApp()
  55. {
  56. return $this->_sAuthorize == BX_GITHUB_AUTHORIZE_APP;
  57. }
  58. public function isAuthorizeByPat()
  59. {
  60. return $this->_sAuthorize == BX_GITHUB_AUTHORIZE_PAT;
  61. }
  62. public function getHtmlIds($sKey = '')
  63. {
  64. if(empty($sKey))
  65. return $this->_aHtmlIds;
  66. return isset($this->_aHtmlIds[$sKey]) ? $this->_aHtmlIds[$sKey] : '';
  67. }
  68. }
  69. /** @} */