BxJobsModule.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 Jobs Jobs
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * Jobs profiles module.
  13. */
  14. class BxJobsModule extends BxBaseModGroupsModule
  15. {
  16. public function __construct(&$aModule)
  17. {
  18. parent::__construct($aModule);
  19. $CNF = &$this->_oConfig->CNF;
  20. $this->_aSearchableNamesExcept = array_merge($this->_aSearchableNamesExcept, [
  21. $CNF['FIELD_TIMEZONE'],
  22. $CNF['FIELD_JOIN_CONFIRMATION'],
  23. ]);
  24. }
  25. public function serviceApplicants ($iContentId = 0, $bAsArray = false)
  26. {
  27. $CNF = &$this->_oConfig->CNF;
  28. if(!$iContentId)
  29. $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  30. if(!$iContentId)
  31. return false;
  32. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  33. if(!$aContentInfo)
  34. return false;
  35. if(!($oGroupProfile = BxDolProfile::getInstanceByContentAndType($iContentId, $this->getName())))
  36. return false;
  37. $iGroupProfileId = $oGroupProfile->id();
  38. if(!$this->serviceIsAdmin($iGroupProfileId))
  39. return false;
  40. if(!$bAsArray) {
  41. bx_import('BxDolConnection');
  42. $mixedResult = $this->serviceBrowseConnectionsQuick ($iGroupProfileId, $CNF['OBJECT_CONNECTIONS'], BX_CONNECTIONS_CONTENT_TYPE_INITIATORS, 0);
  43. if(!$mixedResult)
  44. return MsgBox(_t('_sys_txt_empty'));
  45. }
  46. else
  47. $mixedResult = BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTIONS'])->getConnectedInitiators($iGroupProfileId, 0);
  48. return $mixedResult;
  49. }
  50. public function decodeDataAPI($aData, $aParams = [])
  51. {
  52. $aResult = parent::decodeDataAPI($aData, $aParams);
  53. if(isset($aParams['template']) && $aParams['template'] == 'unit_wo_info')
  54. return $aResult;
  55. $aResult = array_merge($aResult, [
  56. 'description' => strip_tags($aData['desc']),
  57. 'date_start ' => $aData['date_start'],
  58. 'date_end' => $aData['date_end'],
  59. 'pay_hourly' => $aData['pay_hourly'],
  60. 'pay_total' => $aData['pay_total'],
  61. 'votes' => $aData['votes'],
  62. 'votes_avg' => $aData['rate']
  63. ]);
  64. return $aResult;
  65. }
  66. }
  67. /** @} */