BxBaseModGroupsModule.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  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 BaseGroups Base classes for groups modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * Groups profiles module.
  13. */
  14. class BxBaseModGroupsModule extends BxBaseModProfileModule
  15. {
  16. function __construct(&$aModule)
  17. {
  18. parent::__construct($aModule);
  19. }
  20. /**
  21. * Get possible recipients for start conversation form
  22. */
  23. public function actionAjaxGetInitialMembers ()
  24. {
  25. $sTerm = bx_get('term');
  26. $a = BxDolService::call('system', 'profiles_search', array($sTerm), 'TemplServiceProfiles');
  27. header('Content-Type:text/javascript; charset=utf-8');
  28. echo(json_encode($a));
  29. }
  30. /**
  31. * Check if this module entry can be used as profile
  32. */
  33. public function serviceActAsProfile ()
  34. {
  35. return false;
  36. }
  37. /**
  38. * Check if this module is group profile
  39. */
  40. public function serviceIsGroupProfile ()
  41. {
  42. return true;
  43. }
  44. /**
  45. * check if provided profile is member if the group
  46. */
  47. public function serviceIsFan ($iGroupProfileId, $iProfileId = false)
  48. {
  49. $oGroupProfile = BxDolProfile::getInstance($iGroupProfileId);
  50. return $this->isFan($oGroupProfile->getContentId(), $iProfileId);
  51. }
  52. /**
  53. * Delete profile from fans and admins tables
  54. * @param $iProfileId profile id
  55. */
  56. public function serviceDeleteProfileFromFansAndAdmins ($iProfileId)
  57. {
  58. $CNF = &$this->_oConfig->CNF;
  59. $this->_oDb->deleteAdminsByProfileId($iProfileId);
  60. if (isset($CNF['OBJECT_CONNECTIONS']) && ($oConnection = BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTIONS'])))
  61. $oConnection->onDeleteInitiatorAndContent($iProfileId);
  62. }
  63. /**
  64. * Reset group's author for particular group
  65. * @param $iContentId group id
  66. * @return false of error, or number of updated records on success
  67. */
  68. public function serviceReassignEntityAuthor ($iContentId)
  69. {
  70. $aContentInfo = $this->_oDb->getContentInfoById((int)$iContentId);
  71. if (!$aContentInfo)
  72. return false;
  73. if (!($oGroupProfile = BxDolProfile::getInstanceByContentAndType($iContentId, $this->getName())))
  74. return false;
  75. $aAdmins = $this->_oDb->getAdmins($oGroupProfile->id());
  76. return $this->_oDb->updateAuthorById($iContentId, $aAdmins ? array_pop($aAdmins) : 0);
  77. }
  78. /**
  79. * Reset group's author when author profile is deleted
  80. * @param $iProfileId profile id
  81. * @return number of changed items
  82. */
  83. public function serviceReassignEntitiesByAuthor ($iProfileId)
  84. {
  85. $a = $this->_oDb->getEntriesByAuthor((int)$iProfileId);
  86. if (!$a)
  87. return 0;
  88. $iCount = 0;
  89. foreach ($a as $aContentInfo)
  90. $iCount += ('' == $this->serviceReassignEntityAuthor($aContentInfo[$this->_oConfig->CNF['FIELD_ID']]) ? 1 : 0);
  91. return $iCount;
  92. }
  93. public function servicePrepareFields ($aFieldsProfile)
  94. {
  95. $CNF = &$this->_oConfig->CNF;
  96. $aFieldsProfile[$CNF['FIELD_NAME']] = $aFieldsProfile['name'];
  97. $aFieldsProfile[$CNF['FIELD_TEXT']] = isset($aFieldsProfile['description']) ? $aFieldsProfile['description'] : '';
  98. unset($aFieldsProfile['name']);
  99. unset($aFieldsProfile['description']);
  100. return $aFieldsProfile;
  101. }
  102. public function serviceOnRemoveConnection ($iGroupProfileId, $iInitiatorId)
  103. {
  104. $CNF = &$this->_oConfig->CNF;
  105. list ($iProfileId, $iGroupProfileId, $oGroupProfile) = $this->_prepareProfileAndGroupProfile($iGroupProfileId, $iInitiatorId);
  106. if (!$oGroupProfile)
  107. return false;
  108. $this->_oDb->fromAdmins($iGroupProfileId, $iProfileId);
  109. if ($oConn = BxDolConnection::getObjectInstance('sys_profiles_subscriptions'))
  110. $oConn->removeConnection($iProfileId, $iGroupProfileId);
  111. }
  112. public function serviceAddMutualConnection ($iGroupProfileId, $iInitiatorId, $iIgnoreJoinConfirmation = false)
  113. {
  114. $CNF = &$this->_oConfig->CNF;
  115. list ($iProfileId, $iGroupProfileId, $oGroupProfile) = $this->_prepareProfileAndGroupProfile($iGroupProfileId, $iInitiatorId);
  116. if (!$oGroupProfile)
  117. return false;
  118. if (!($aContentInfo = $this->_oDb->getContentInfoById((int)BxDolProfile::getInstance($iGroupProfileId)->getContentId())))
  119. return false;
  120. if (!($oConnection = BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTIONS'])))
  121. return false;
  122. $sEntryTitle = $aContentInfo[$CNF['FIELD_NAME']];
  123. $sEntryUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
  124. // send invitation to the group
  125. if ($iIgnoreJoinConfirmation && !$oConnection->isConnected((int)$iInitiatorId, $oGroupProfile->id()) && !$oConnection->isConnected($oGroupProfile->id(), (int)$iInitiatorId) && bx_get_logged_profile_id() != $iProfileId) {
  126. bx_alert($this->getName(), 'join_invitation', $aContentInfo[$CNF['FIELD_ID']], $iGroupProfileId, array('content' => $aContentInfo, 'entry_title' => $sEntryTitle, 'entry_url' => $sEntryUrl, 'group_profile' => $iGroupProfileId, 'profile' => $iProfileId, 'notification_subobject_id' => $iProfileId, 'object_author_id' => $aContentInfo[$CNF['FIELD_AUTHOR']]));
  127. }
  128. // send notification to group's admins that new connection is pending confirmation
  129. elseif (!$iIgnoreJoinConfirmation && $oConnection->isConnected((int)$iInitiatorId, $oGroupProfile->id()) && !$oConnection->isConnected($oGroupProfile->id(), (int)$iInitiatorId) && $aContentInfo['join_confirmation']) {
  130. bx_alert($this->getName(), 'join_request', $aContentInfo[$CNF['FIELD_ID']], $iGroupProfileId, array('content' => $aContentInfo, 'entry_title' => $sEntryTitle, 'entry_url' => $sEntryUrl, 'group_profile' => $iGroupProfileId, 'profile' => $iProfileId, 'notification_subobject_id' => $iProfileId, 'object_author_id' => $aContentInfo[$CNF['FIELD_AUTHOR']]));
  131. }
  132. // send notification that join request was accepted
  133. else if (!$iIgnoreJoinConfirmation && $oConnection->isConnected((int)$iInitiatorId, $oGroupProfile->id(), true) && $oGroupProfile->getModule() != $this->getName() && bx_get_logged_profile_id() != $iProfileId) {
  134. bx_alert($this->getName(), 'join_request_accepted', $aContentInfo[$CNF['FIELD_ID']], $iGroupProfileId, array('content' => $aContentInfo, 'entry_title' => $sEntryTitle, 'entry_url' => $sEntryUrl, 'group_profile' => $iGroupProfileId, 'profile' => $iProfileId, 'notification_subobject_id' => $iProfileId, 'object_author_id' => $aContentInfo[$CNF['FIELD_AUTHOR']]));
  135. }
  136. // new fan was added
  137. if ($oConnection->isConnected($oGroupProfile->id(), (int)$iInitiatorId, true)) {
  138. bx_alert($this->getName(), 'fan_added', $aContentInfo[$CNF['FIELD_ID']], $iGroupProfileId, array('content' => $aContentInfo, 'entry_title' => $sEntryTitle, 'entry_url' => $sEntryUrl, 'group_profile' => $iGroupProfileId, 'profile' => $iProfileId, 'notification_subobject_id' => $iProfileId, 'object_author_id' => $aContentInfo[$CNF['FIELD_AUTHOR']]));
  139. return false;
  140. }
  141. // don't automatically add back connection (mutual) if group requires manual join confirmation
  142. if (!$iIgnoreJoinConfirmation && $aContentInfo['join_confirmation'])
  143. return false;
  144. // check if connection already exists
  145. if ($oConnection->isConnected($oGroupProfile->id(), (int)$iInitiatorId, true) || $oConnection->isConnected($oGroupProfile->id(), (int)$iInitiatorId))
  146. return false;
  147. if (!$oConnection->addConnection($oGroupProfile->id(), (int)$iInitiatorId))
  148. return false;
  149. return true;
  150. }
  151. public function serviceFansTable ()
  152. {
  153. $oGrid = BxDolGrid::getObjectInstance($this->_oConfig->CNF['OBJECT_GRID_CONNECTIONS']);
  154. if (!$oGrid)
  155. return false;
  156. return $oGrid->getCode();
  157. }
  158. public function serviceFans ($iContentId = 0)
  159. {
  160. if (!$iContentId)
  161. $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  162. if (!$iContentId)
  163. return false;
  164. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  165. if (!$aContentInfo)
  166. return false;
  167. if (!($oGroupProfile = BxDolProfile::getInstanceByContentAndType($iContentId, $this->getName())))
  168. return false;
  169. bx_import('BxDolConnection');
  170. $s = $this->serviceBrowseConnectionsQuick ($oGroupProfile->id(), $this->_oConfig->CNF['OBJECT_CONNECTIONS'], BX_CONNECTIONS_CONTENT_TYPE_CONTENT, true);
  171. if (!$s)
  172. return MsgBox(_t('_sys_txt_empty'));
  173. return $s;
  174. }
  175. public function serviceAdmins ($iContentId = 0)
  176. {
  177. $CNF = &$this->_oConfig->CNF;
  178. if(!$iContentId)
  179. $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  180. if(!$iContentId)
  181. return false;
  182. $oGroupProfile = BxDolProfile::getInstanceByContentAndType($iContentId, $this->getName());
  183. if(!$oGroupProfile)
  184. return false;
  185. $aProfiles = $this->_oDb->getAdmins($oGroupProfile->id());
  186. if(empty($aProfiles) || !is_array($aProfiles))
  187. return false;
  188. $iStart = (int)bx_get('start');
  189. $iLimit = !empty($CNF['PARAM_NUM_CONNECTIONS_QUICK']) ? getParam($CNF['PARAM_NUM_CONNECTIONS_QUICK']) : 4;
  190. if(!$iLimit)
  191. $iLimit = 4;
  192. return $this->_serviceBrowseQuick($aProfiles, $iStart, $iLimit);
  193. }
  194. public function serviceBrowseJoinedEntries ($iProfileId = 0, $bDisplayEmptyMsg = false)
  195. {
  196. if (!$iProfileId)
  197. $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
  198. if (!$iProfileId)
  199. return '';
  200. return $this->_serviceBrowse ('joined_entries', array('joined_profile' => $iProfileId), BX_DB_PADDING_DEF, $bDisplayEmptyMsg);
  201. }
  202. public function serviceEntityInvite ($iContentId = 0)
  203. {
  204. return $this->_serviceEntityForm ('editDataForm', $iContentId, $this->_oConfig->CNF['OBJECT_FORM_ENTRY_DISPLAY_INVITE']);
  205. }
  206. /**
  207. * Entry social sharing block
  208. */
  209. public function serviceEntitySocialSharing ($iContentId = 0)
  210. {
  211. if (!$iContentId)
  212. $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  213. if (!$iContentId)
  214. return false;
  215. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  216. if (!$aContentInfo)
  217. return false;
  218. $oGroupProfile = BxDolProfile::getInstanceByContentAndType((int)$iContentId, $this->getName());
  219. if (!$oGroupProfile)
  220. return false;
  221. $CNF = &$this->_oConfig->CNF;
  222. return $this->_entitySocialSharing ($iContentId, array(
  223. 'id_timeline' => $iContentId,
  224. 'id_thumb' => 0,
  225. 'title' => $oGroupProfile->getDisplayName(),
  226. 'object_storage' => false,
  227. 'object_transcoder' => false,
  228. 'object_vote' => $CNF['OBJECT_VOTES'],
  229. 'object_favorite' => $CNF['OBJECT_FAVORITES'],
  230. 'object_feature' => $CNF['OBJECT_FEATURED'],
  231. 'object_report' => $CNF['OBJECT_REPORTS'],
  232. 'uri_view_entry' => $CNF['URI_VIEW_ENTRY']
  233. ));
  234. }
  235. /**
  236. * Data for Notifications module
  237. */
  238. public function serviceGetNotificationsData()
  239. {
  240. $sModule = $this->_aModule['name'];
  241. return array(
  242. 'handlers' => array(
  243. array('group' => $sModule . '_vote', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'doVote', 'module_name' => $sModule, 'module_method' => 'get_notifications_vote', 'module_class' => 'Module'),
  244. array('group' => $sModule . '_vote', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'undoVote'),
  245. array('group' => $sModule . '_fan_added', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'fan_added', 'module_name' => $sModule, 'module_method' => 'get_notifications_fan_added', 'module_class' => 'Module'),
  246. array('group' => $sModule . '_join_request', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'join_request', 'module_name' => $sModule, 'module_method' => 'get_notifications_join_request', 'module_class' => 'Module', 'module_event_privacy' => $this->_oConfig->CNF['OBJECT_PRIVACY_VIEW_NOTIFICATION_EVENT']),
  247. array('group' => $sModule . '_timeline_post_common', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'timeline_post_common', 'module_name' => $sModule, 'module_method' => 'get_notifications_timeline_post_common', 'module_class' => 'Module'),
  248. ),
  249. 'alerts' => array(
  250. array('unit' => $sModule, 'action' => 'doVote'),
  251. array('unit' => $sModule, 'action' => 'undoVote'),
  252. array('unit' => $sModule, 'action' => 'fan_added'),
  253. array('unit' => $sModule, 'action' => 'join_request'),
  254. array('unit' => $sModule, 'action' => 'timeline_post_common'),
  255. )
  256. );
  257. }
  258. /**
  259. * Notification about new member requst in the group
  260. */
  261. public function serviceGetNotificationsJoinRequest($aEvent)
  262. {
  263. return $this->_serviceGetNotification($aEvent, $this->_oConfig->CNF['T']['txt_ntfs_join_request']);
  264. }
  265. /**
  266. * Notification about new member in the group
  267. */
  268. public function serviceGetNotificationsFanAdded($aEvent)
  269. {
  270. return $this->_serviceGetNotification($aEvent, $this->_oConfig->CNF['T']['txt_ntfs_fan_added']);
  271. }
  272. /**
  273. * Entry post for Timeline module
  274. */
  275. public function serviceGetTimelinePost($aEvent)
  276. {
  277. $a = parent::serviceGetTimelinePost($aEvent);
  278. $oGroupProfile = BxDolProfile::getInstanceByContentAndType($aEvent['object_id'], $this->getName());
  279. $a['content']['url'] = $oGroupProfile->getUrl();
  280. $a['content']['title'] = $oGroupProfile->getDisplayName();
  281. return $a;
  282. }
  283. /**
  284. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  285. */
  286. public function checkAllowedViewCoverImage ($aDataEntry, $isPerformAction = false)
  287. {
  288. $oPrivacy = BxDolPrivacy::getObjectInstance($this->_oConfig->CNF['OBJECT_PRIVACY_VIEW']);
  289. if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = parent::checkAllowedViewCoverImage($aDataEntry)) && $oPrivacy->isPartiallyVisible($aDataEntry[$this->_oConfig->CNF['FIELD_ALLOW_VIEW_TO']]))
  290. return CHECK_ACTION_RESULT_ALLOWED;
  291. return $sMsg;
  292. }
  293. /**
  294. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  295. */
  296. public function checkAllowedViewProfileImage ($aDataEntry, $isPerformAction = false)
  297. {
  298. return $this->checkAllowedViewCoverImage($aDataEntry, $isPerformAction);
  299. }
  300. /**
  301. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  302. */
  303. public function checkAllowedPost ($aDataEntry, $isPerformAction = false)
  304. {
  305. if ($this->isFan($aDataEntry[$this->_oConfig->CNF['FIELD_ID']]))
  306. return CHECK_ACTION_RESULT_ALLOWED;
  307. return _t('_sys_txt_access_denied');
  308. }
  309. /**
  310. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  311. */
  312. public function checkAllowedView ($aDataEntry, $isPerformAction = false)
  313. {
  314. if ($this->isFan($aDataEntry[$this->_oConfig->CNF['FIELD_ID']]))
  315. return CHECK_ACTION_RESULT_ALLOWED;
  316. return parent::checkAllowedView ($aDataEntry, $isPerformAction);
  317. }
  318. /**
  319. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  320. */
  321. public function checkAllowedCompose (&$aDataEntry, $isPerformAction = false)
  322. {
  323. if (!$this->isFan($aDataEntry[$this->_oConfig->CNF['FIELD_ID']]))
  324. return _t('_sys_txt_access_denied');
  325. return parent::checkAllowedCompose ($aDataEntry, $isPerformAction);
  326. }
  327. /**
  328. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  329. */
  330. public function checkAllowedFanAdd (&$aDataEntry, $isPerformAction = false)
  331. {
  332. if (!$this->isFan($aDataEntry[$this->_oConfig->CNF['FIELD_ID']]) && isLogged())
  333. return CHECK_ACTION_RESULT_ALLOWED;
  334. return $this->_checkAllowedConnect ($aDataEntry, $isPerformAction, $this->_oConfig->CNF['OBJECT_CONNECTIONS'], true, false);
  335. }
  336. /**
  337. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  338. */
  339. public function checkAllowedFanRemove (&$aDataEntry, $isPerformAction = false)
  340. {
  341. if (CHECK_ACTION_RESULT_ALLOWED === $this->_checkAllowedConnect ($aDataEntry, $isPerformAction, $this->_oConfig->CNF['OBJECT_CONNECTIONS'], false, true, true))
  342. return CHECK_ACTION_RESULT_ALLOWED;
  343. return $this->_checkAllowedConnect ($aDataEntry, $isPerformAction, $this->_oConfig->CNF['OBJECT_CONNECTIONS'], false, true, false);
  344. }
  345. public function checkAllowedManageAdmins ($mixedDataEntry, $isPerformAction = false)
  346. {
  347. if (is_array($mixedDataEntry)) {
  348. $aDataEntry = $mixedDataEntry;
  349. }
  350. else {
  351. $oGroupProfile = BxDolProfile::getInstance((int)$mixedDataEntry);
  352. $aDataEntry = $oGroupProfile && $this->getName() == $oGroupProfile->getModule() ? $this->_oDb->getContentInfoById($oGroupProfile->getContentId()) : array();
  353. }
  354. return parent::checkAllowedEdit ($aDataEntry, $isPerformAction);
  355. }
  356. public function checkAllowedEdit ($aDataEntry, $isPerformAction = false)
  357. {
  358. $oGroupProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$this->_oConfig->CNF['FIELD_ID']], $this->getName());
  359. if ($this->_oDb->isAdmin($oGroupProfile->id(), bx_get_logged_profile_id(), $aDataEntry))
  360. return CHECK_ACTION_RESULT_ALLOWED;
  361. return parent::checkAllowedEdit ($aDataEntry, $isPerformAction);
  362. }
  363. public function checkAllowedInvite ($aDataEntry, $isPerformAction = false)
  364. {
  365. return $this->checkAllowedEdit ($aDataEntry, $isPerformAction);
  366. }
  367. public function checkAllowedChangeCover ($aDataEntry, $isPerformAction = false)
  368. {
  369. $oGroupProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$this->_oConfig->CNF['FIELD_ID']], $this->getName());
  370. if ($this->_oDb->isAdmin($oGroupProfile->id(), bx_get_logged_profile_id(), $aDataEntry))
  371. return CHECK_ACTION_RESULT_ALLOWED;
  372. return parent::checkAllowedChangeCover ($aDataEntry, $isPerformAction);
  373. }
  374. public function checkAllowedDelete (&$aDataEntry, $isPerformAction = false)
  375. {
  376. $oGroupProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$this->_oConfig->CNF['FIELD_ID']], $this->getName());
  377. if ($oGroupProfile && $this->_oDb->isAdmin($oGroupProfile->id(), bx_get_logged_profile_id(), $aDataEntry))
  378. return CHECK_ACTION_RESULT_ALLOWED;
  379. return parent::checkAllowedDelete ($aDataEntry, $isPerformAction);
  380. }
  381. public function checkAllowedSubscribeAdd (&$aDataEntry, $isPerformAction = false)
  382. {
  383. if (!$this->isFan($aDataEntry[$this->_oConfig->CNF['FIELD_ID']]))
  384. return _t('_sys_txt_access_denied');
  385. return parent::checkAllowedSubscribeAdd ($aDataEntry, $isPerformAction);
  386. }
  387. protected function _checkAllowedConnect (&$aDataEntry, $isPerformAction, $sObjConnection, $isMutual, $isInvertResult, $isSwap = false)
  388. {
  389. $sResult = $this->checkAllowedView($aDataEntry);
  390. $oPrivacy = BxDolPrivacy::getObjectInstance($this->_oConfig->CNF['OBJECT_PRIVACY_VIEW']);
  391. if (CHECK_ACTION_RESULT_ALLOWED !== $sResult && !$oPrivacy->isPartiallyVisible($aDataEntry[$this->_oConfig->CNF['FIELD_ALLOW_VIEW_TO']]))
  392. return $sResult;
  393. return parent::_checkAllowedConnect ($aDataEntry, $isPerformAction, $sObjConnection, $isMutual, $isInvertResult, $isSwap);
  394. }
  395. public function isFan ($iContentId, $iProfileId = false)
  396. {
  397. $oGroupProfile = BxDolProfile::getInstanceByContentAndType($iContentId, $this->getName());
  398. return $oGroupProfile && ($oConnection = BxDolConnection::getObjectInstance($this->_oConfig->CNF['OBJECT_CONNECTIONS'])) && $oConnection->isConnected($iProfileId ? $iProfileId : bx_get_logged_profile_id(), $oGroupProfile->id(), true);
  399. }
  400. protected function _getImagesForTimelinePost($aEvent, $aContentInfo, $sUrl)
  401. {
  402. $CNF = &$this->_oConfig->CNF;
  403. if(empty($aContentInfo[$CNF['FIELD_PICTURE']]))
  404. return array();
  405. $oGroupProfile = BxDolProfile::getInstanceByContentAndType($aEvent['object_id'], $this->getName());
  406. return array(
  407. array('url' => $sUrl, 'src' => $oGroupProfile->getPicture()),
  408. );
  409. }
  410. protected function _prepareProfileAndGroupProfile($iGroupProfileId, $iInitiatorId)
  411. {
  412. if (!($oGroupProfile = BxDolProfile::getInstance($iGroupProfileId)))
  413. return array(0, 0, null);
  414. if ($oGroupProfile->getModule() == $this->getName()) {
  415. $iProfileId = $iInitiatorId;
  416. $iGroupProfileId = $oGroupProfile->id();
  417. } else {
  418. $iProfileId = $oGroupProfile->id();
  419. $iGroupProfileId = $iInitiatorId;
  420. }
  421. return array($iProfileId, $iGroupProfileId, $oGroupProfile);
  422. }
  423. }
  424. /** @} */