BxPersonsModule.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 Persons Persons
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * Person profiles module.
  13. */
  14. class BxPersonsModule extends BxBaseModProfileModule
  15. {
  16. function __construct(&$aModule)
  17. {
  18. parent::__construct($aModule);
  19. $this->_aSearchableNamesExcept[] = $this->_oConfig->CNF['FIELD_AUTHOR'];
  20. }
  21. public function servicePrepareFields ($aFieldsProfile)
  22. {
  23. $a = parent::_servicePrepareFields($aFieldsProfile, array(), array());
  24. if (empty($a['fullname']))
  25. $a['fullname'] = $aFieldsProfile['name'];
  26. }
  27. /**
  28. * @page service Service Calls
  29. * @section bx_persons Persons
  30. * @subsection bx_persons-other Other
  31. * @subsubsection bx_persons-get_search_options
  32. *
  33. * @code bx_srv('bx_persons', 'get_search_options', [...]); @endcode
  34. *
  35. * Get options for searchable fields
  36. *
  37. * @return array - params or false.
  38. *
  39. * @see BxPersonsModule::serviceGetSearchOptions
  40. */
  41. /**
  42. * @ref bx_persons-get_search_options "get_search_options"
  43. */
  44. public function serviceGetSearchOptions ($sField, $sFieldType, $sSearchType)
  45. {
  46. $CNF = $this->_oConfig->CNF;
  47. if (isset($CNF['OBJECT_FORM_ENTRY']) && isset($CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD'])){
  48. $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD'], $this->_oTemplate);
  49. foreach ($oForm->aInputs as $aFld) {
  50. if ($aFld['name'] == $sField && $aFld['type'] == $sFieldType && isset($aFld['checker']) && isset($aFld['checker']['params'])){
  51. return $aFld['checker']['params'];
  52. }
  53. }
  54. }
  55. if (isset($CNF['OBJECT_FORM_ENTRY']) && isset($CNF['OBJECT_FORM_ENTRY_DISPLAY_EDIT'])){
  56. $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $CNF['OBJECT_FORM_ENTRY_DISPLAY_EDIT'], $this->_oTemplate);
  57. foreach ($oForm->aInputs as $aFld) {
  58. if ($aFld['name'] == $sField && $aFld['type'] == $sFieldType && isset($aFld['checker']) && isset($aFld['checker']['params'])){
  59. return $aFld['checker']['params'];
  60. }
  61. }
  62. }
  63. return false;
  64. }
  65. }
  66. /** @} */