BxDolRecommendationProfile.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php defined('BX_DOL') or defined('BX_DOL_INSTALL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. */
  6. class BxDolRecommendationProfile extends BxTemplRecommendation
  7. {
  8. protected function __construct($aOptions, $oTemplate)
  9. {
  10. parent::__construct($aOptions, $oTemplate);
  11. }
  12. public function actionAdd($iProfileId = 0, $iItemId = 0)
  13. {
  14. if(!$iProfileId)
  15. $iProfileId = $this->_iProfileId;
  16. if(!$iItemId)
  17. $iItemId = bx_process_input(bx_get('id'), BX_DATA_INT);
  18. if(!empty($this->_aObject['connection'])) {
  19. $aResult = BxDolConnection::getObjectInstance($this->_aObject['connection'])->actionAdd($iItemId, $iProfileId);
  20. if($aResult['err'] == true)
  21. return ['code' => 2, 'msg' => $aResult['msg']];
  22. }
  23. if(!$this->add($iProfileId, $iItemId))
  24. return ['code' => 1, 'msg' => '_sys_txt_error_occured'];
  25. return ['code' => 0];
  26. }
  27. public function getItemsTypes($aIds)
  28. {
  29. return BxDolProfileQuery::getInstance()->getProfiles(['type' => 'id_to_type', 'ids' => $aIds]);
  30. }
  31. }
  32. /** @} */