BxBaseModProfileModule.php 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061
  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 BaseProfile Base classes for profile modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. define('BX_DOL_PROFILE_REDIRECT_PROFILE', 'profile');
  12. define('BX_DOL_PROFILE_REDIRECT_LAST', 'last');
  13. define('BX_DOL_PROFILE_REDIRECT_CUSTOM', 'custom');
  14. /**
  15. * Base class for profile modules.
  16. */
  17. class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolContentInfoService, iBxDolProfileService
  18. {
  19. protected $_iAccountId;
  20. function __construct(&$aModule)
  21. {
  22. parent::__construct($aModule);
  23. $this->_iAccountId = getLoggedId();
  24. }
  25. public function actionDeleteProfileImg($iFileId, $iContentId, $sFieldPicture)
  26. {
  27. $aResult = array();
  28. $CNF = &$this->_oConfig->CNF;
  29. $oSrorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']);
  30. if (!($aFile = $oSrorage->getFile((int)$iFileId)) || !($aContentInfo = $this->_oDb->getContentInfoById($iContentId)) || $aContentInfo[$sFieldPicture] != (int)$iFileId)
  31. $aResult = array('error' => 1, 'msg' => _t('_sys_storage_err_file_not_found'));
  32. $oAccountProfile = BxDolProfile::getInstanceAccountProfile();
  33. if ($oAccountProfile)
  34. $iAccountProfileId = $oAccountProfile->id();
  35. if ((!$aResult && !isLogged()) || (!$aResult && $aFile['profile_id'] != $iAccountProfileId && !$this->_isModerator()))
  36. $aResult = array('error' => 2, 'msg' => _t('_Access denied'));
  37. $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD'], $this->_oTemplate);
  38. if (!$aResult && !$oForm->_deleteFile($iContentId, $sFieldPicture, (int)$iFileId, true))
  39. $aResult = array('error' => 3, 'msg' => _t('_Failed'));
  40. elseif (!$aResult)
  41. $aResult = array('error' => 0, 'msg' => '');
  42. header('Content-Type: application/json; charset=utf-8');
  43. echo json_encode($aResult);
  44. }
  45. // ====== SERVICE METHODS
  46. public function serviceGetOptionsRedirectAfterAdd()
  47. {
  48. $CNF = &$this->_oConfig->CNF;
  49. $aResult = array();
  50. $aChoices = array(BX_DOL_PROFILE_REDIRECT_PROFILE, BX_DOL_PROFILE_REDIRECT_LAST, BX_DOL_PROFILE_REDIRECT_CUSTOM);
  51. foreach($aChoices as $sChoice)
  52. $aResult[] = array('key' => $sChoice, 'value' => _t($CNF['T']['option_redirect_aadd_' . $sChoice]));
  53. return $aResult;
  54. }
  55. public function serviceGetThumb ($iContentId, $sTranscoder = '')
  56. {
  57. $CNF = &$this->_oConfig->CNF;
  58. if(empty($sTranscoder) && !empty($CNF['OBJECT_IMAGES_TRANSCODER_THUMB']))
  59. $sTranscoder = $CNF['OBJECT_IMAGES_TRANSCODER_THUMB'];
  60. $mixedResult = $this->_getFieldValueThumb('FIELD_PICTURE', $iContentId, $sTranscoder);
  61. return $mixedResult !== false ? $mixedResult : '';
  62. }
  63. public function serviceGetSearchResultUnit ($iContentId, $sUnitTemplate = '')
  64. {
  65. if(empty($sUnitTemplate))
  66. $sUnitTemplate = 'unit_with_cover.html';
  67. return parent::serviceGetSearchResultUnit($iContentId, $sUnitTemplate);
  68. }
  69. public function servicePrivateProfileMsg()
  70. {
  71. return MsgBox(_t('_sys_access_denied_to_private_content'));
  72. }
  73. public function serviceGetContentInfoById($iContentId)
  74. {
  75. return $this->_oDb->getContentInfoById((int)$iContentId);
  76. }
  77. public function serviceGetMenuAddonManageTools()
  78. {
  79. bx_import('SearchResult', $this->_aModule);
  80. $sClass = $this->_aModule['class_prefix'] . 'SearchResult';
  81. $o = new $sClass();
  82. $o->fillFilters(array(
  83. 'perofileStatus' => BX_PROFILE_STATUS_PENDING
  84. ));
  85. $o->unsetPaginate();
  86. return $o->getNum();
  87. }
  88. public function serviceGetMenuAddonManageToolsProfileStats()
  89. {
  90. bx_import('SearchResult', $this->_aModule);
  91. $sClass = $this->_aModule['class_prefix'] . 'SearchResult';
  92. $o = new $sClass();
  93. $o->fillFilters(array(
  94. 'account_id' => getLoggedId(),
  95. 'perofileStatus' => ''
  96. ));
  97. $o->unsetPaginate();
  98. return $o->getNum();
  99. }
  100. public function serviceGetMenuAddonFavoritesProfileStats()
  101. {
  102. bx_import('SearchResult', $this->_aModule);
  103. $sClass = $this->_aModule['class_prefix'] . 'SearchResult';
  104. $o = new $sClass('favorite', array('user' => bx_get_logged_profile_id()));
  105. $o->unsetPaginate();
  106. return $o->getNum();
  107. }
  108. public function serviceGetSubmenuObject ()
  109. {
  110. return $this->_oConfig->CNF['OBJECT_MENU_SUBMENU_VIEW_ENTRY'];
  111. }
  112. public function serviceGetMenuSetNameForMenuTrigger ($sMenuTriggerName)
  113. {
  114. $CNF = &$this->_oConfig->CNF;
  115. if ($CNF['TRIGGER_MENU_PROFILE_VIEW_SUBMENU'] == $sMenuTriggerName)
  116. return $CNF['OBJECT_MENU_SUBMENU_VIEW_ENTRY'];
  117. elseif ($CNF['TRIGGER_MENU_PROFILE_VIEW_ACTIONS'] == $sMenuTriggerName)
  118. return $CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY'];
  119. return '';
  120. }
  121. public function serviceGetPageObjectForPageTrigger ($sPageTriggerName)
  122. {
  123. if (isset($this->_oConfig->CNF['TRIGGER_PAGE_VIEW_ENTRY']) && $this->_oConfig->CNF['TRIGGER_PAGE_VIEW_ENTRY'] == $sPageTriggerName)
  124. return $this->_oConfig->CNF['OBJECT_PAGE_VIEW_ENTRY'];
  125. return '';
  126. }
  127. public function serviceProfilesSearch ($sTerm, $iLimit)
  128. {
  129. $aRet = array();
  130. $a = $this->_oDb->searchByTerm($sTerm, $iLimit);
  131. foreach ($a as $r) {
  132. $oProfile = BxDolProfile::getInstance($r['profile_id']);
  133. $aRet[] = array (
  134. 'label' => $this->serviceProfileName($r['content_id']),
  135. 'value' => $r['profile_id'],
  136. 'url' => $oProfile->getUrl(),
  137. 'thumb' => $oProfile->getThumb(),
  138. 'unit' => $oProfile->getUnit(0, array('template' => 'unit_wo_info'))
  139. );
  140. }
  141. return $aRet;
  142. }
  143. public function serviceProfileUnit ($iContentId, $aParams = array())
  144. {
  145. $mixedContent = $this->_getContent($iContentId);
  146. if($mixedContent === false)
  147. return false;
  148. list($iContentId, $aContentInfo) = $mixedContent;
  149. $bCheckPrivateContent = isset($aParams['check_private_content']) ? (bool)$aParams['check_private_content'] : true;
  150. $sTemplate = (!empty($aParams['template']) ? $aParams['template'] : 'unit') . '.html';
  151. return $this->_oTemplate->unit($aContentInfo, $bCheckPrivateContent, $sTemplate);
  152. }
  153. public function serviceHasImage ($iContentId)
  154. {
  155. $CNF = &$this->_oConfig->CNF;
  156. $mixedContent = $this->_getContent($iContentId, 'getContentInfoById');
  157. if($mixedContent === false)
  158. return false;
  159. list($iContentId, $aContentInfo) = $mixedContent;
  160. return !empty($aContentInfo[$CNF['FIELD_PICTURE']]);
  161. }
  162. public function serviceProfilePicture ($iContentId)
  163. {
  164. return $this->_serviceTemplateFunc('urlPicture', $iContentId);
  165. }
  166. public function serviceProfileAvatar ($iContentId)
  167. {
  168. return $this->_serviceTemplateFunc('urlAvatar', $iContentId);
  169. }
  170. public function serviceProfileEditUrl ($iContentId)
  171. {
  172. return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $this->_oConfig->CNF['URI_EDIT_ENTRY'] . '&id=' . $iContentId);
  173. }
  174. public function serviceProfileThumb ($iContentId)
  175. {
  176. return $this->_serviceTemplateFunc('thumb', $iContentId);
  177. }
  178. public function serviceProfileIcon ($iContentId)
  179. {
  180. return $this->_serviceTemplateFunc('icon', $iContentId);
  181. }
  182. public function serviceProfileName ($iContentId)
  183. {
  184. if (!$iContentId)
  185. return false;
  186. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  187. if (!$aContentInfo)
  188. return false;
  189. return bx_process_output($aContentInfo[$this->_oConfig->CNF['FIELD_NAME']]);
  190. }
  191. public function serviceProfileCreateUrl ($bAbsolute = true)
  192. {
  193. $CNF = $this->_oConfig->CNF;
  194. if(empty($CNF['URL_CREATE']))
  195. return false;
  196. return $bAbsolute ? BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink($CNF['URL_CREATE']) : $CNF['URL_CREATE'];
  197. }
  198. public function serviceProfileUrl ($iContentId)
  199. {
  200. if (!$iContentId)
  201. return false;
  202. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  203. if (!$aContentInfo)
  204. return false;
  205. $CNF = $this->_oConfig->CNF;
  206. return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
  207. }
  208. /**
  209. * @see iBxDolProfileService::serviceCheckAllowedProfileView
  210. */
  211. public function serviceCheckAllowedProfileView($iContentId)
  212. {
  213. return $this->serviceCheckAllowedWithContent('View', $iContentId);
  214. }
  215. /**
  216. * @see iBxDolProfileService::serviceCheckAllowedPostInProfile
  217. */
  218. public function serviceCheckAllowedPostInProfile($iContentId)
  219. {
  220. return $this->serviceCheckAllowedProfileView($iContentId);
  221. }
  222. /**
  223. * Prepare fields from some universal set of fields to fields in particular profile module.
  224. * By default only 'name' and 'description' fields are supported.
  225. * After fields convertion it can be used in @see BxBaseModGeneralModule::serviceEntityAdd
  226. * @param $aFieldsProfile fields in soem universal format.
  227. * @return array which is ready to use for particular module
  228. */
  229. public function servicePrepareFields ($aFieldsProfile)
  230. {
  231. bx_alert($this->getName(), 'prepare_fields', 0, 0, array('fields_orig' => $aFieldsProfile, 'fields_result' => &$aFieldsProfile));
  232. return $aFieldsProfile;
  233. }
  234. protected function _servicePrepareFields ($aFieldsProfile, $aFieldsDefault, $aMap)
  235. {
  236. $aFieldsOrig = $aFieldsProfile;
  237. bx_import('BxDolPrivacy');
  238. $aFieldsDefault2 = array(
  239. 'allow_view_to' => BX_DOL_PG_ALL,
  240. );
  241. $aFieldsProfile = array_merge($aFieldsDefault2, $aFieldsDefault, $aFieldsProfile);
  242. foreach ($aMap as $k => $v) {
  243. if (isset($aFieldsProfile[$v]))
  244. $aFieldsProfile[$k] = $aFieldsProfile[$v];
  245. if ($k != $v && !isset($aMap[$v]))
  246. unset($aFieldsProfile[$v]);
  247. }
  248. bx_alert($this->getName(), 'prepare_fields', 0, 0, array('fields_orig' => $aFieldsOrig, 'fields_result' => &$aFieldsProfile));
  249. return $aFieldsProfile;
  250. }
  251. public function serviceFormsHelper ()
  252. {
  253. return parent::serviceFormsHelper ();
  254. }
  255. public function serviceEntityCreate ($sDisplay = false)
  256. {
  257. BxDolInformer::getInstance($this->_oTemplate)->setEnabled(false);
  258. return parent::serviceEntityCreate ($sDisplay);
  259. }
  260. public function serviceActAsProfile ()
  261. {
  262. return true;
  263. }
  264. public function serviceBrowseRecommended ($sUnitView = false, $bEmptyMessage = false, $bAjaxPaginate = true)
  265. {
  266. if (!isLogged())
  267. return '';
  268. return $this->_serviceBrowse ('recommended', $sUnitView ? array('unit_view' => $sUnitView) : false, BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  269. }
  270. public function serviceBrowseRecentProfiles ($bDisplayEmptyMsg = false)
  271. {
  272. return $this->_serviceBrowse ('recent', false, BX_DB_PADDING_DEF, $bDisplayEmptyMsg);
  273. }
  274. public function serviceBrowseActiveProfiles ($bDisplayEmptyMsg = false)
  275. {
  276. return $this->_serviceBrowse ('active', false, BX_DB_PADDING_DEF, $bDisplayEmptyMsg);
  277. }
  278. public function serviceBrowseTopProfiles ($bDisplayEmptyMsg = false)
  279. {
  280. return $this->_serviceBrowse ('top', false, BX_DB_PADDING_DEF, $bDisplayEmptyMsg);
  281. }
  282. public function serviceBrowseOnlineProfiles ($bDisplayEmptyMsg = false)
  283. {
  284. return $this->_serviceBrowse ('online', false, BX_DB_PADDING_DEF, $bDisplayEmptyMsg);
  285. }
  286. public function serviceBrowseConnections ($iProfileId, $sObjectConnections = 'sys_profiles_friends', $sConnectionsType = 'content', $iMutual = false, $iDesignBox = BX_DB_PADDING_DEF, $iProfileId2 = 0)
  287. {
  288. return $this->_serviceBrowse (
  289. 'connections',
  290. array(
  291. 'object' => $sObjectConnections,
  292. 'type' => $sConnectionsType,
  293. 'mutual' => $iMutual,
  294. 'profile' => (int)$iProfileId,
  295. 'profile2' => (int)$iProfileId2),
  296. $iDesignBox
  297. );
  298. }
  299. public function serviceBrowseConnectionsQuick ($iProfileId, $sObjectConnections = 'sys_profiles_friends', $sConnectionsType = 'content', $iMutual = false, $iProfileId2 = 0)
  300. {
  301. // get connections object
  302. $oConnection = BxDolConnection::getObjectInstance($sObjectConnections);
  303. if (!$oConnection)
  304. return '';
  305. // set some vars
  306. $iLimit = empty($this->_oConfig->CNF['PARAM_NUM_CONNECTIONS_QUICK']) ? 4 : getParam($this->_oConfig->CNF['PARAM_NUM_CONNECTIONS_QUICK']);
  307. if (!$iLimit)
  308. $iLimit = 4;
  309. $iStart = (int)bx_get('start');
  310. // get connections array
  311. bx_import('BxDolConnection');
  312. $a = $oConnection->getConnectionsAsArray ($sConnectionsType, $iProfileId, $iProfileId2, $iMutual, (int)bx_get('start'), $iLimit + 1, BX_CONNECTIONS_ORDER_ADDED_DESC);
  313. if (!$a)
  314. return '';
  315. return $this->_serviceBrowseQuick($a, $iStart, $iLimit);
  316. }
  317. public function serviceBrowseByAcl ($mixedLevelId, $iDesignBox = BX_DB_PADDING_DEF)
  318. {
  319. return $this->_serviceBrowse (
  320. 'acl',
  321. array(
  322. 'level' => $mixedLevelId,
  323. ),
  324. $iDesignBox,
  325. true
  326. );
  327. }
  328. public function serviceEntityEditCover ($iContentId = 0)
  329. {
  330. return $this->_serviceEntityForm ('editDataForm', $iContentId, $this->_oConfig->CNF['OBJECT_FORM_ENTRY_DISPLAY_EDIT_COVER']);
  331. }
  332. /**
  333. * Entry comments
  334. */
  335. public function serviceEntityCommentsByProfile ($iProfileId)
  336. {
  337. $CNF = &$this->_oConfig->CNF;
  338. if(empty($CNF['OBJECT_COMMENTS']))
  339. return '';
  340. $oProfile = BxDolProfile::getInstance($iProfileId);
  341. if(!$oProfile)
  342. return '';
  343. return $this->_entityComments($CNF['OBJECT_COMMENTS'], $oProfile->getContentId());
  344. }
  345. /**
  346. * Entry social sharing block
  347. */
  348. public function serviceEntitySocialSharing ($iContentId = 0)
  349. {
  350. $mixedContent = $this->_getContent($iContentId);
  351. if($mixedContent === false)
  352. return false;
  353. list($iContentId, $aContentInfo) = $mixedContent;
  354. $CNF = &$this->_oConfig->CNF;
  355. return $this->_entitySocialSharing ($iContentId, array(
  356. 'id_timeline' => 0,
  357. 'id_thumb' => !empty($CNF['FIELD_PICTURE']) && !empty($aContentInfo[$CNF['FIELD_PICTURE']]) ? $aContentInfo[$CNF['FIELD_PICTURE']] : '',
  358. 'title' => !empty($aContentInfo[$CNF['FIELD_TITLE']]) ? $aContentInfo[$CNF['FIELD_TITLE']] : '',
  359. 'object_storage' => !empty($CNF['OBJECT_STORAGE']) ? $CNF['OBJECT_STORAGE'] : '',
  360. 'object_transcoder' => false,
  361. 'object_vote' => '',
  362. 'object_favorite' => !empty($CNF['OBJECT_FAVORITES']) ? $CNF['OBJECT_FAVORITES'] : '',
  363. 'object_feature' => !empty($CNF['OBJECT_FEATURED']) ? $CNF['OBJECT_FEATURED'] : '',
  364. 'object_report' => !empty($CNF['OBJECT_REPORTS']) ? $CNF['OBJECT_REPORTS'] : '',
  365. 'uri_view_entry' => !empty($CNF['URI_VIEW_ENTRY']) ? $CNF['URI_VIEW_ENTRY'] : '',
  366. 'social_sharing' => false
  367. ));
  368. }
  369. public function serviceProfileMembership ($iContentId = 0)
  370. {
  371. $mixedContent = $this->_getContent($iContentId);
  372. if($mixedContent === false)
  373. return false;
  374. list($iContentId, $aContentInfo) = $mixedContent;
  375. return BxDolAcl::getInstance()->getProfileMembership($aContentInfo['profile_id']);
  376. }
  377. public function serviceProfileFriends ($iContentId = 0)
  378. {
  379. $mixedContent = $this->_getContent($iContentId);
  380. if($mixedContent === false)
  381. return false;
  382. list($iContentId, $aContentInfo) = $mixedContent;
  383. bx_import('BxDolConnection');
  384. $s = $this->serviceBrowseConnectionsQuick ($aContentInfo['profile_id'], 'sys_profiles_friends', BX_CONNECTIONS_CONTENT_TYPE_CONTENT, true);
  385. if (!$s)
  386. return MsgBox(_t('_sys_txt_empty'));
  387. return $s;
  388. }
  389. public function serviceProfileSubscriptions ($iContentId = 0)
  390. {
  391. $mixedContent = $this->_getContent($iContentId);
  392. if($mixedContent === false)
  393. return false;
  394. list($iContentId, $aContentInfo) = $mixedContent;
  395. bx_import('BxDolConnection');
  396. $s = $this->serviceBrowseConnectionsQuick ($aContentInfo['profile_id'], 'sys_profiles_subscriptions', BX_CONNECTIONS_CONTENT_TYPE_CONTENT);
  397. if (!$s)
  398. return MsgBox(_t('_sys_txt_empty'));
  399. return $s;
  400. }
  401. public function serviceProfileSubscribedMe ($iContentId = 0)
  402. {
  403. $mixedContent = $this->_getContent($iContentId);
  404. if($mixedContent === false)
  405. return false;
  406. list($iContentId, $aContentInfo) = $mixedContent;
  407. bx_import('BxDolConnection');
  408. $s = $this->serviceBrowseConnectionsQuick ($aContentInfo['profile_id'], 'sys_profiles_subscriptions', BX_CONNECTIONS_CONTENT_TYPE_INITIATORS);
  409. if (!$s)
  410. return MsgBox(_t('_sys_txt_empty'));
  411. return $s;
  412. }
  413. /**
  414. * For internal usage only.
  415. */
  416. public function serviceDeleteEntityService ($iContentId, $bDeleteWithContent = false)
  417. {
  418. return parent::serviceDeleteEntity ($iContentId, 'deleteDataService');
  419. }
  420. /**
  421. * Data for Notifications module
  422. */
  423. public function serviceGetNotificationsData()
  424. {
  425. $a = parent::serviceGetNotificationsData();
  426. $sModule = $this->_aModule['name'];
  427. $a['handlers'][] = 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');
  428. $a['alerts'][] = array('unit' => $sModule, 'action' => 'timeline_post_common');
  429. return $a;
  430. }
  431. /**
  432. * Notification about new member requst in the group
  433. */
  434. public function serviceGetNotificationsTimelinePostCommon($aEvent)
  435. {
  436. $CNF = &$this->_oConfig->CNF;
  437. $iContentId = (int)$aEvent['object_id'];
  438. $oGroupProfile = BxDolProfile::getInstanceByContentAndType((int)$iContentId, $this->getName());
  439. if(!$oGroupProfile)
  440. return array();
  441. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  442. if(empty($aContentInfo) || !is_array($aContentInfo))
  443. return array();
  444. $aSubcontentInfo = BxDolService::call('bx_timeline', 'get_info', array((int)$aEvent['subobject_id'], false));
  445. if(empty($aSubcontentInfo) || !is_array($aSubcontentInfo))
  446. return array();
  447. $sSubentryUrl = BxDolService::call('bx_timeline', 'get_link', array((int)$aEvent['subobject_id']));
  448. $sSubentrySample = $aSubcontentInfo['title'];
  449. if(empty($sSubentrySample))
  450. $sSubentrySample = strmaxtextlen($aSubcontentInfo['description'], 20, '...');
  451. return array(
  452. 'entry_sample' => $CNF['T']['txt_sample_single'],
  453. 'entry_url' => $oGroupProfile->getUrl(),
  454. 'entry_caption' => $oGroupProfile->getDisplayName(),
  455. 'entry_author' => $oGroupProfile->id(),
  456. 'subentry_sample' => $sSubentrySample,
  457. 'subentry_url' => $sSubentryUrl,
  458. 'lang_key' => $CNF['T']['txt_ntfs_timeline_post_common'],
  459. );
  460. }
  461. /**
  462. * Data for Timeline module
  463. */
  464. public function serviceGetTimelineData()
  465. {
  466. $CNF = &$this->_oConfig->CNF;
  467. $sModule = $this->_aModule['name'];
  468. $aAlerts = array();
  469. $aHandlers = array();
  470. if(!empty($CNF['FIELD_PICTURE'])) {
  471. $aAlerts = array_merge($aAlerts, array(
  472. array('unit' => $sModule, 'action' => 'profile_picture_changed'),
  473. array('unit' => $sModule, 'action' => 'profile_picture_deleted')
  474. ));
  475. $aHandlers = array_merge($aHandlers, array(
  476. array('group' => $sModule . '_profile_picture', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'profile_picture_changed', 'module_name' => $sModule, 'module_method' => 'get_timeline_profile_picture', 'module_class' => 'Module', 'groupable' => 0, 'group_by' => ''),
  477. array('group' => $sModule . '_profile_picture', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'profile_picture_deleted')
  478. ));
  479. }
  480. if(!empty($CNF['FIELD_COVER'])) {
  481. $aAlerts = array_merge($aAlerts, array(
  482. array('unit' => $sModule, 'action' => 'profile_cover_changed'),
  483. array('unit' => $sModule, 'action' => 'profile_cover_deleted')
  484. ));
  485. $aHandlers = array_merge($aHandlers, array(
  486. array('group' => $sModule . '_profile_cover', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'profile_cover_changed', 'module_name' => $sModule, 'module_method' => 'get_timeline_profile_cover', 'module_class' => 'Module', 'groupable' => 0, 'group_by' => ''),
  487. array('group' => $sModule . '_profile_cover', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'profile_cover_deleted')
  488. ));
  489. }
  490. $aResult = array();
  491. if(!empty($aAlerts) && !empty($aHandlers))
  492. $aResult = array(
  493. 'handlers' => $aHandlers,
  494. 'alerts' => $aAlerts
  495. );
  496. return $aResult;
  497. }
  498. /**
  499. * Entry post for Timeline module
  500. */
  501. public function serviceGetTimelineProfilePicture($aEvent, $aBrowseParams = array())
  502. {
  503. return $this->_serviceGetTimelineProfileImage($aEvent, $aBrowseParams, array(
  504. 'stg' => 'OBJECT_STORAGE',
  505. 'trans' => array('OBJECT_IMAGES_TRANSCODER_GALLERY', 'OBJECT_IMAGES_TRANSCODER_AVATAR'),
  506. 'trans_orig' => array('OBJECT_IMAGES_TRANSCODER_PICTURE', 'OBJECT_IMAGES_TRANSCODER_GALLERY'),
  507. 'txt_ss' => 'txt_sample_pp_single',
  508. 'txt_sswa' => 'txt_sample_pp_single_with_article',
  509. 'txt_sa' => 'txt_sample_pi_action',
  510. 'txt_sau' => 'txt_sample_pi_action_user'
  511. ));
  512. }
  513. public function serviceGetTimelineProfileCover($aEvent, $aBrowseParams = array())
  514. {
  515. return $this->_serviceGetTimelineProfileImage($aEvent, $aBrowseParams, array(
  516. 'stg' => 'OBJECT_STORAGE_COVER',
  517. 'trans' => array('OBJECT_IMAGES_TRANSCODER_GALLERY', 'OBJECT_IMAGES_TRANSCODER_COVER_THUMB'),
  518. 'trans_orig' => array('OBJECT_IMAGES_TRANSCODER_COVER', 'OBJECT_IMAGES_TRANSCODER_GALLERY'),
  519. 'txt_ss' => 'txt_sample_pc_single',
  520. 'txt_sswa' => 'txt_sample_pc_single_with_article',
  521. 'txt_sa' => 'txt_sample_pi_action',
  522. 'txt_sau' => 'txt_sample_pi_action_user'
  523. ));
  524. }
  525. public function serviceGetConnectionButtonsTitles($iProfileId, $sConnectionsObject = 'sys_profiles_friends')
  526. {
  527. if (!isLogged())
  528. return array();
  529. if (!($oConn = BxDolConnection::getObjectInstance($sConnectionsObject)))
  530. return array();
  531. $CNF = $this->_oConfig->CNF;
  532. if ($oConn->isConnectedNotMutual(bx_get_logged_profile_id(), $iProfileId)) {
  533. return array(
  534. 'add' => _t($CNF['T']['menu_item_title_befriend_sent']),
  535. 'remove' => _t($CNF['T']['menu_item_title_unfriend_cancel_request']),
  536. );
  537. } elseif ($oConn->isConnectedNotMutual($iProfileId, bx_get_logged_profile_id())) {
  538. return array(
  539. 'add' => _t($CNF['T']['menu_item_title_befriend_confirm']),
  540. 'remove' => _t($CNF['T']['menu_item_title_unfriend_reject_request']),
  541. );
  542. } elseif ($oConn->isConnected($iProfileId, bx_get_logged_profile_id(), true)) {
  543. return array(
  544. 'add' => '',
  545. 'remove' => _t($CNF['T']['menu_item_title_unfriend']),
  546. );
  547. } else {
  548. return array(
  549. 'add' => _t($CNF['T']['menu_item_title_befriend']),
  550. 'remove' => '',
  551. );
  552. }
  553. }
  554. // ====== PERMISSION METHODS
  555. /**
  556. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
  557. */
  558. public function checkAllowedAdd ($isPerformAction = false)
  559. {
  560. $oAccount = BxDolAccount::getInstance();
  561. if (!$oAccount || ($this->serviceActAsProfile() && $oAccount->isProfilesLimitReached()))
  562. return _t('_sys_txt_access_denied');
  563. return parent::checkAllowedAdd ($isPerformAction);
  564. }
  565. /**
  566. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
  567. */
  568. public function checkAllowedView ($aDataEntry, $isPerformAction = false)
  569. {
  570. $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$this->_oConfig->CNF['FIELD_ID']], $this->getName());
  571. if ($oProfile && $oProfile->id() == $this->_iProfileId)
  572. return CHECK_ACTION_RESULT_ALLOWED;
  573. return parent::checkAllowedView ($aDataEntry, $isPerformAction);
  574. }
  575. /**
  576. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  577. */
  578. public function checkAllowedViewProfileImage ($aDataEntry, $isPerformAction = false)
  579. {
  580. $CNF = &$this->_oConfig->CNF;
  581. // check privacy
  582. if (empty($CNF['OBJECT_PRIVACY_VIEW']))
  583. return CHECK_ACTION_RESULT_ALLOWED;
  584. $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']);
  585. if ($oPrivacy && !$oPrivacy->check($aDataEntry[$CNF['FIELD_ID']]) && !$oPrivacy->isPartiallyVisible($aDataEntry[$CNF['FIELD_ALLOW_VIEW_TO']]))
  586. return _t('_sys_access_denied_to_private_content');
  587. return CHECK_ACTION_RESULT_ALLOWED;
  588. }
  589. /**
  590. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  591. */
  592. public function checkAllowedViewCoverImage ($aDataEntry, $isPerformAction = false)
  593. {
  594. return $this->checkAllowedViewProfileImage($aDataEntry);
  595. }
  596. /**
  597. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  598. */
  599. public function checkAllowedPost ($aDataEntry, $isPerformAction = false)
  600. {
  601. return $this->checkAllowedView ($aDataEntry, $isPerformAction);
  602. }
  603. /**
  604. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  605. */
  606. public function checkAllowedEdit ($aDataEntry, $isPerformAction = false)
  607. {
  608. // moderator always has access
  609. if ($this->_isModerator($isPerformAction))
  610. return CHECK_ACTION_RESULT_ALLOWED;
  611. // owner (checked by account! not as profile as ususal) always have access
  612. $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$this->_oConfig->CNF['FIELD_ID']], $this->_aModule['name']);
  613. if (!$oProfile)
  614. return _t('_sys_txt_error_occured');
  615. if ($oProfile->getAccountId() == $this->_iAccountId)
  616. return CHECK_ACTION_RESULT_ALLOWED;
  617. return _t('_sys_txt_access_denied');
  618. }
  619. /**
  620. * Check if user can change cover image
  621. */
  622. public function checkAllowedChangeCover ($aDataEntry, $isPerformAction = false)
  623. {
  624. // moderator always has access
  625. if ($this->_isModerator($isPerformAction))
  626. return CHECK_ACTION_RESULT_ALLOWED;
  627. // owner (checked by account! not as profile as ususal) always have access
  628. $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$this->_oConfig->CNF['FIELD_ID']], $this->_aModule['name']);
  629. if (!$oProfile)
  630. return _t('_sys_txt_error_occured');
  631. if ($oProfile->getAccountId() == $this->_iAccountId)
  632. return CHECK_ACTION_RESULT_ALLOWED;
  633. return _t('_sys_txt_access_denied');
  634. }
  635. /**
  636. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  637. */
  638. public function checkAllowedDelete (&$aDataEntry, $isPerformAction = false)
  639. {
  640. // moderator always has access
  641. if ($this->_isModerator($isPerformAction))
  642. return CHECK_ACTION_RESULT_ALLOWED;
  643. // check ACL and owner (checked by account! not as profile as ususal)
  644. $aCheck = checkActionModule($this->_iProfileId, 'delete entry', $this->getName(), $isPerformAction);
  645. $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$this->_oConfig->CNF['FIELD_ID']], $this->_aModule['name'], $isPerformAction);
  646. if (!$oProfile)
  647. return _t('_sys_txt_error_occured');
  648. if ($oProfile->getAccountId() == $this->_iAccountId && $aCheck[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
  649. return CHECK_ACTION_RESULT_ALLOWED;
  650. return _t('_sys_txt_access_denied');
  651. }
  652. /**
  653. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  654. */
  655. public function checkAllowedViewMoreMenu (&$aDataEntry, $isPerformAction = false)
  656. {
  657. $oMenu = BxTemplMenu::getObjectInstance($this->_oConfig->CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY_MORE']);
  658. if (!$oMenu || !$oMenu->getCode())
  659. return _t('_sys_txt_access_denied');
  660. return CHECK_ACTION_RESULT_ALLOWED;
  661. }
  662. /**
  663. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  664. */
  665. public function checkAllowedCompose (&$aDataEntry, $isPerformAction = false)
  666. {
  667. $CNF = &$this->_oConfig->CNF;
  668. $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$CNF['FIELD_ID']], $this->getName());
  669. if($oProfile && $oProfile->id() == $this->_iProfileId)
  670. return _t('_sys_txt_access_denied');
  671. return $this->checkAllowedView ($aDataEntry, $isPerformAction);
  672. }
  673. /**
  674. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  675. */
  676. public function checkAllowedFriendAdd (&$aDataEntry, $isPerformAction = false)
  677. {
  678. return $this->_checkAllowedConnect ($aDataEntry, $isPerformAction, 'sys_profiles_friends', true, false);
  679. }
  680. /**
  681. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  682. */
  683. public function checkAllowedFriendRemove (&$aDataEntry, $isPerformAction = false)
  684. {
  685. if (CHECK_ACTION_RESULT_ALLOWED === $this->_checkAllowedConnect ($aDataEntry, $isPerformAction, 'sys_profiles_friends', false, true, true))
  686. return CHECK_ACTION_RESULT_ALLOWED;
  687. return $this->_checkAllowedConnect ($aDataEntry, $isPerformAction, 'sys_profiles_friends', false, true, false);
  688. }
  689. /**
  690. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  691. */
  692. public function checkAllowedSubscribeAdd (&$aDataEntry, $isPerformAction = false)
  693. {
  694. if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->checkAllowedView($aDataEntry)))
  695. return $sMsg;
  696. return $this->_checkAllowedConnect ($aDataEntry, $isPerformAction, 'sys_profiles_subscriptions', false, false);
  697. }
  698. /**
  699. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  700. */
  701. public function checkAllowedSubscribeRemove (&$aDataEntry, $isPerformAction = false)
  702. {
  703. return $this->_checkAllowedConnect ($aDataEntry, $isPerformAction, 'sys_profiles_subscriptions', false, true);
  704. }
  705. public function checkAllowedSubscriptionsView (&$aDataEntry, $isPerformAction = false)
  706. {
  707. $CNF = &$this->_oConfig->CNF;
  708. $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$CNF['FIELD_ID']], $this->_aModule['name']);
  709. if(!$oProfile || ($oProfile->id() != $this->_iProfileId && $this->_oDb->getParam($CNF['PARAM_PUBLIC_SBSN']) != 'on' && $this->_oDb->getParam($CNF['PARAM_PUBLIC_SBSD']) != 'on'))
  710. return _t('_sys_txt_access_denied');
  711. return CHECK_ACTION_RESULT_ALLOWED;
  712. }
  713. public function checkMyself($iContentId)
  714. {
  715. $iLogged = (int)bx_get_logged_profile_id();
  716. if(empty($iLogged))
  717. return false;
  718. $oProfile = BxDolProfile::getInstanceByContentAndType((int)$iContentId, $this->_oConfig->getName());
  719. if(!$oProfile)
  720. return false;
  721. return $oProfile->id() == $iLogged;
  722. }
  723. // ====== PROTECTED METHODS
  724. protected function _checkAllowedConnect (&$aDataEntry, $isPerformAction, $sObjConnection, $isMutual, $isInvertResult, $isSwap = false)
  725. {
  726. if (!$this->_iProfileId)
  727. return _t('_sys_txt_access_denied');
  728. $CNF = &$this->_oConfig->CNF;
  729. $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$CNF['FIELD_ID']], $this->_aModule['name']);
  730. if (!$oProfile || $oProfile->id() == $this->_iProfileId)
  731. return _t('_sys_txt_access_denied');
  732. // check ACL
  733. $aCheck = checkActionModule($this->_iProfileId, 'connect', 'system', $isPerformAction);
  734. if ($aCheck[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED)
  735. return $aCheck[CHECK_ACTION_MESSAGE];
  736. $oConn = BxDolConnection::getObjectInstance($sObjConnection);
  737. if ($isSwap)
  738. $isConnected = $oConn->isConnected($oProfile->id(), $this->_iProfileId, $isMutual);
  739. else
  740. $isConnected = $oConn->isConnected($this->_iProfileId, $oProfile->id(), $isMutual);
  741. if ($isInvertResult)
  742. $isConnected = !$isConnected;
  743. return $isConnected ? _t('_sys_txt_access_denied') : CHECK_ACTION_RESULT_ALLOWED;
  744. }
  745. protected function _buildRssParams($sMode, $aArgs)
  746. {
  747. $aParams = array ();
  748. $sMode = bx_process_input($sMode);
  749. switch ($sMode) {
  750. case 'connections':
  751. $aParams = array(
  752. 'object' => isset($aArgs[0]) ? $aArgs[0] : '',
  753. 'type' => isset($aArgs[1]) ? $aArgs[1] : '',
  754. 'profile' => isset($aArgs[2]) ? (int)$aArgs[2] : 0,
  755. 'mutual' => isset($aArgs[3]) ? (int)$aArgs[3] : 0,
  756. 'profile2' => isset($aArgs[4]) ? (int)$aArgs[4] : 0,
  757. );
  758. break;
  759. }
  760. return $aParams;
  761. }
  762. protected function _serviceBrowseQuick($aProfiles, $iStart = 0, $iLimit = 4)
  763. {
  764. // get paginate object
  765. $oPaginate = new BxTemplPaginate(array(
  766. 'on_change_page' => "return !loadDynamicBlockAutoPaginate(this, '{start}', '{per_page}');",
  767. 'num' => count($aProfiles),
  768. 'per_page' => $iLimit,
  769. 'start' => $iStart,
  770. ));
  771. // remove last item from connection array, because we've got one more item for pagination calculations only
  772. if (count($aProfiles) > $iLimit)
  773. array_pop($aProfiles);
  774. // get profiles HTML
  775. $s = '';
  776. foreach ($aProfiles as $iProfileId) {
  777. $oProfile = BxDolProfile::getInstance($iProfileId);
  778. if(!$oProfile)
  779. continue;
  780. $s .= $oProfile->getUnit();
  781. }
  782. // return profiles + paginate
  783. return $s . (!$iStart && $oPaginate->getNum() <= $iLimit ? '' : $oPaginate->getSimplePaginate());
  784. }
  785. protected function _serviceGetTimelineProfileImage($aEvent, $aBrowseParams, $aBuildParams)
  786. {
  787. $CNF = &$this->_oConfig->CNF;
  788. $aFileInfo = BxDolStorage::getObjectInstance($CNF[$aBuildParams['stg']])->getFile((int)$aEvent['object_id']);
  789. if(empty($aFileInfo) || !is_array($aFileInfo))
  790. return '';
  791. $aEventContent = unserialize($aEvent['content']);
  792. if(!is_array($aEventContent) || empty($aEventContent['content']))
  793. return '';
  794. $aContentInfo = $this->_oDb->getContentInfoById($aEventContent['content']);
  795. if(empty($aContentInfo) || !is_array($aContentInfo))
  796. return '';
  797. list($sUserName) = $this->getUserInfo($aContentInfo['profile_id']);
  798. $sSample = isset($CNF['T'][$aBuildParams['txt_sswa']]) ? $CNF['T'][$aBuildParams['txt_sswa']] : $CNF['T'][$aBuildParams['txt_ss']];
  799. //--- Title & Description
  800. $sTitle = !empty($aContentInfo[$CNF['FIELD_TITLE']]) ? $aContentInfo[$CNF['FIELD_TITLE']] : '';
  801. if(empty($sTitle) && !empty($aContentInfo[$CNF['FIELD_TEXT']]))
  802. $sTitle = $aContentInfo[$CNF['FIELD_TEXT']];
  803. $sDescription = _t($CNF['T'][$aBuildParams['txt_sau']], $sUserName, _t($sSample));
  804. return array(
  805. 'owner_id' => $aContentInfo['profile_id'],
  806. 'icon' => !empty($CNF['ICON']) ? $CNF['ICON'] : '',
  807. 'sample' => $sSample,
  808. 'sample_wo_article' => $CNF['T'][$aBuildParams['txt_ss']],
  809. 'sample_action' => isset($CNF['T'][$aBuildParams['txt_sa']]) ? $CNF['T'][$aBuildParams['txt_sa']] : '',
  810. 'url' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]),
  811. 'content' => $this->_getContentForTimelineProfileImage($aEvent, $aBrowseParams, $aBuildParams, $aContentInfo, $aFileInfo), //a string to display or array to parse default template before displaying.
  812. 'date' => $aContentInfo[$CNF['FIELD_ADDED']],
  813. 'views' => '',
  814. 'votes' => '',
  815. 'reports' => '',
  816. 'comments' => '',
  817. 'title' => $sTitle, //may be empty.
  818. 'description' => $sDescription //may be empty.
  819. );
  820. }
  821. protected function _getContentForTimelineProfileImage($aEvent, $aBrowseParams, $aBuildParams, $aContentInfo, $aFileInfo)
  822. {
  823. $CNF = &$this->_oConfig->CNF;
  824. $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
  825. //--- Image(s)
  826. $sImage = $this->_oConfig->getImageUrl($aFileInfo['id'], $aBuildParams['trans']);
  827. $sImageOrig = $this->_oConfig->getImageUrl($aFileInfo['id'], $aBuildParams['trans_orig']);
  828. if(!empty($sImage)) {
  829. if(empty($sImageOrig))
  830. $sImageOrig = $sImage;
  831. $aImages = array(
  832. array('url' => $sUrl, 'src' => $sImage, 'src_orig' => $sImageOrig),
  833. );
  834. }
  835. return array(
  836. 'sample' => isset($CNF['T'][$aBuildParams['txt_sswa']]) ? $CNF['T'][$aBuildParams['txt_sswa']] : $CNF['T'][$aBuildParams['txt_ss']],
  837. 'sample_wo_article' => $CNF['T'][$aBuildParams['txt_ss']],
  838. 'sample_action' => isset($CNF['T'][$aBuildParams['txt_sa']]) ? $CNF['T'][$aBuildParams['txt_sa']] : '',
  839. 'url' => $sUrl,
  840. 'title' => '',
  841. 'text' => '',
  842. 'images' => $aImages,
  843. 'videos' => array()
  844. );
  845. }
  846. protected function _entityComments($sObject, $iId = 0)
  847. {
  848. if(!$iId)
  849. $iId = bx_process_input(bx_get('id'), BX_DATA_INT);
  850. if(!$iId)
  851. $iId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
  852. if(!$iId)
  853. return false;
  854. $oCmts = BxDolCmts::getObjectInstance($sObject, $iId);
  855. if(!$oCmts || !$oCmts->isEnabled())
  856. return false;
  857. return $oCmts->getCommentsBlock(array(), array('in_designbox' => false));
  858. }
  859. protected function _getContent($iContentId = 0, $sFuncGetContent = 'getContentInfoById')
  860. {
  861. if(!$iContentId && bx_get('id') === false && bx_get('profile_id') !== false) {
  862. $oProfile = BxDolProfile::getInstance((int)bx_get('profile_id'));
  863. if($oProfile)
  864. $iContentId = $oProfile->getContentId();
  865. }
  866. return parent::_getContent($iContentId, $sFuncGetContent);
  867. }
  868. }
  869. /** @} */