BxGitHubTemplate.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 BxGitHubTemplate extends BxDolModuleTemplate
  12. {
  13. public function __construct(&$oConfig, &$oDb)
  14. {
  15. parent::__construct($oConfig, $oDb);
  16. }
  17. public function getBlockSettings($iProfileId)
  18. {
  19. $CNF = &$this->_oConfig->CNF;
  20. $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_SETTINGS'], $CNF['OBJECT_FORM_SETTINGS_DISPLAY_EDIT'], $this);
  21. if(!$oForm)
  22. return MsgBox(_t('_sys_txt_error_occured'));
  23. $aSettings = $this->_oDb->getSettings(['sample' => 'profile_id', 'profile_id' => $iProfileId]);
  24. $bSettings = !empty($aSettings) && is_array($aSettings);
  25. $sResultTimer = 0;
  26. $sResultMessage = '';
  27. $oForm->initChecker($aSettings);
  28. if($oForm->isSubmittedAndValid()) {
  29. if((!$bSettings && (int)$oForm->insert(['profile_id' => $iProfileId]) > 0) || ($bSettings && $oForm->update($aSettings['id']) !== false)) {
  30. $sResultTimer = 3;
  31. $sResultMessage = '_bx_github_msg_save_settings';
  32. }
  33. else
  34. $sResultMessage = '_bx_github_err_save_settings';
  35. }
  36. return (!empty($sResultMessage) ? MsgBox(_t($sResultMessage), $sResultTimer) : '') . $oForm->getCode();
  37. }
  38. }
  39. /** @} */