1
0

BxBaseModGroupsModule.php 22 KB

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