BxBaseModProfileModule.php 42 KB

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