BxJobsModule.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 checkAllowedFans(&$aDataEntry, $isPerformAction = false)
  51. {
  52. $CNF = &$this->_oConfig->CNF;
  53. if($aDataEntry[$CNF['FIELD_AUTHOR']] == bx_get_logged_profile_id())
  54. return _t('_sys_txt_access_denied');
  55. return parent::checkAllowedFans($aDataEntry, $isPerformAction);
  56. }
  57. public function decodeDataAPI($aData, $aParams = [])
  58. {
  59. $aResult = parent::decodeDataAPI($aData, $aParams);
  60. if(isset($aParams['template']) && $aParams['template'] == 'unit_wo_info')
  61. return $aResult;
  62. $aResult = array_merge($aResult, [
  63. 'description' => strip_tags($aData['desc']),
  64. 'date_start ' => $aData['date_start'],
  65. 'date_end' => $aData['date_end'],
  66. 'pay_hourly' => $aData['pay_hourly'],
  67. 'pay_total' => $aData['pay_total'],
  68. 'votes' => $aData['votes'],
  69. 'votes_avg' => $aData['rate']
  70. ]);
  71. return $aResult;
  72. }
  73. }
  74. /** @} */