1
0

BxBaseModNotificationsResponse.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. /**
  37. * Note. Check priority is NOT IMPORTANT!
  38. */
  39. protected function _getSubObjectId($aExtras)
  40. {
  41. if(!is_array($aExtras))
  42. return 0;
  43. if(isset($aExtras['comment_id']))
  44. return (int)$aExtras['comment_id'];
  45. if(isset($aExtras['vote_id']))
  46. return (int)$aExtras['vote_id'];
  47. if(isset($aExtras['score_id']))
  48. return (int)$aExtras['score_id'];
  49. if(isset($aExtras['repost_id']))
  50. return (int)$aExtras['repost_id'];
  51. if(isset($aExtras['timeline_post_id']))
  52. return (int)$aExtras['timeline_post_id'];
  53. if(isset($aExtras['performer_id']))
  54. return (int)$aExtras['performer_id'];
  55. if(isset($aExtras['subobject_id']))
  56. return (int)$aExtras['subobject_id'];
  57. if(isset($aExtras['subobjects_ids']))
  58. return is_array($aExtras['subobjects_ids']) ? $aExtras['subobjects_ids'] : array($aExtras['subobjects_ids']);
  59. return 0;
  60. }
  61. }
  62. /** @} */