BxPersonsModule.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. return parent::_servicePrepareFields($aFieldsProfile, array(), array('fullname' => 'name'));
  24. }
  25. /**
  26. * @page service Service Calls
  27. * @section bx_persons Persons
  28. * @subsection bx_persons-other Other
  29. * @subsubsection bx_persons-get_search_options
  30. *
  31. * @code bx_srv('bx_persons', 'get_search_options', [...]); @endcode
  32. *
  33. * Get options for searchable fields
  34. *
  35. * @return array - params or false.
  36. *
  37. * @see BxPersonsModule::serviceGetSearchOptions
  38. */
  39. /**
  40. * @ref bx_persons-get_search_options "get_search_options"
  41. */
  42. public function serviceGetSearchOptions ($sField, $sFieldType, $sSearchType)
  43. {
  44. $CNF = $this->_oConfig->CNF;
  45. if (isset($CNF['OBJECT_FORM_ENTRY']) && isset($CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD'])){
  46. $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD'], $this->_oTemplate);
  47. foreach ($oForm->aInputs as $aFld) {
  48. if ($aFld['name'] == $sField && $aFld['type'] == $sFieldType && isset($aFld['checker']) && isset($aFld['checker']['params'])){
  49. return $aFld['checker']['params'];
  50. }
  51. }
  52. }
  53. if (isset($CNF['OBJECT_FORM_ENTRY']) && isset($CNF['OBJECT_FORM_ENTRY_DISPLAY_EDIT'])){
  54. $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $CNF['OBJECT_FORM_ENTRY_DISPLAY_EDIT'], $this->_oTemplate);
  55. foreach ($oForm->aInputs as $aFld) {
  56. if ($aFld['name'] == $sField && $aFld['type'] == $sFieldType && isset($aFld['checker']) && isset($aFld['checker']['params'])){
  57. return $aFld['checker']['params'];
  58. }
  59. }
  60. }
  61. return false;
  62. }
  63. }
  64. /** @} */