BxBaseModNotificationsResponse.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 BaseNotifications Base classes for Notifications like modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxBaseModNotificationsResponse extends BxDolAlertsResponse
  12. {
  13. protected $_oModule;
  14. function __construct()
  15. {
  16. parent::__construct();
  17. }
  18. /**
  19. * Note. Check priority is IMPORTANT!
  20. * Don't swap the checks without a REAL need.
  21. */
  22. protected function _getObjectOwnerId($aExtras)
  23. {
  24. if(!is_array($aExtras))
  25. return 0;
  26. if(isset($aExtras['parent_author_id']))
  27. return (int)$aExtras['parent_author_id'];
  28. if(isset($aExtras['object_author_id']))
  29. return (int)$aExtras['object_author_id'];
  30. return 0;
  31. }
  32. protected function _getObjectPrivacyView($aExtras)
  33. {
  34. return $this->_oModule->getObjectPrivacyView($aExtras);
  35. }
  36. protected function _getObjectCf($aExtras)
  37. {
  38. return $this->_oModule->getObjectCf($aExtras);
  39. }
  40. /**
  41. * Note. Check priority is NOT IMPORTANT!
  42. */
  43. protected function _getSubObjectId($aExtras)
  44. {
  45. if(!is_array($aExtras))
  46. return 0;
  47. if(isset($aExtras['comment_id']))
  48. return (int)$aExtras['comment_id'];
  49. if(isset($aExtras['vote_id']))
  50. return (int)$aExtras['vote_id'];
  51. if(isset($aExtras['score_id']))
  52. return (int)$aExtras['score_id'];
  53. if(isset($aExtras['repost_id']))
  54. return (int)$aExtras['repost_id'];
  55. if(isset($aExtras['timeline_post_id']))
  56. return (int)$aExtras['timeline_post_id'];
  57. if(isset($aExtras['performer_id']))
  58. return (int)$aExtras['performer_id'];
  59. if(isset($aExtras['subobject_id']))
  60. return (int)$aExtras['subobject_id'];
  61. if(isset($aExtras['subobjects_ids']))
  62. return is_array($aExtras['subobjects_ids']) ? $aExtras['subobjects_ids'] : array($aExtras['subobjects_ids']);
  63. return 0;
  64. }
  65. }
  66. /** @} */