BxBaseModProfileModule.php 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580
  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. $CNF = &$this->_oConfig->CNF;
  24. if(!empty($CNF['FIELD_ALLOW_POST_TO']))
  25. $this->_aSearchableNamesExcept[] = $CNF['FIELD_ALLOW_POST_TO'];
  26. $this->_iAccountId = getLoggedId();
  27. }
  28. public function actionDeleteProfileImg($iFileId, $iContentId, $sFieldPicture)
  29. {
  30. $aResult = array();
  31. $CNF = &$this->_oConfig->CNF;
  32. $oSrorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']);
  33. if (!($aFile = $oSrorage->getFile((int)$iFileId)) || !($aContentInfo = $this->_oDb->getContentInfoById($iContentId)) || $aContentInfo[$sFieldPicture] != (int)$iFileId)
  34. $aResult = array('error' => 1, 'msg' => _t('_sys_storage_err_file_not_found'));
  35. $oAccountProfile = BxDolProfile::getInstanceAccountProfile();
  36. if ($oAccountProfile)
  37. $iAccountProfileId = $oAccountProfile->id();
  38. if ((!$aResult && !isLogged()) || (!$aResult && $aFile['profile_id'] != $iAccountProfileId && !$this->_isModerator()))
  39. $aResult = array('error' => 2, 'msg' => _t('_Access denied'));
  40. $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD'], $this->_oTemplate);
  41. if (!$aResult && !$oForm->_deleteFile($iContentId, $sFieldPicture, (int)$iFileId, true))
  42. $aResult = array('error' => 3, 'msg' => _t('_Failed'));
  43. elseif (!$aResult)
  44. $aResult = array('error' => 0, 'msg' => '');
  45. header('Content-Type: application/json; charset=utf-8');
  46. echo json_encode($aResult);
  47. }
  48. // ====== SERVICE METHODS
  49. public function serviceGetOptionsRedirectAfterAdd()
  50. {
  51. $CNF = &$this->_oConfig->CNF;
  52. $aResult = array();
  53. $aChoices = array(BX_DOL_PROFILE_REDIRECT_PROFILE, BX_DOL_PROFILE_REDIRECT_LAST, BX_DOL_PROFILE_REDIRECT_CUSTOM);
  54. foreach($aChoices as $sChoice)
  55. $aResult[] = array('key' => $sChoice, 'value' => _t($CNF['T']['option_redirect_aadd_' . $sChoice]));
  56. return $aResult;
  57. }
  58. public function serviceGetThumb ($iContentId, $sTranscoder = '')
  59. {
  60. $CNF = &$this->_oConfig->CNF;
  61. if(empty($sTranscoder) && !empty($CNF['OBJECT_IMAGES_TRANSCODER_THUMB']))
  62. $sTranscoder = $CNF['OBJECT_IMAGES_TRANSCODER_THUMB'];
  63. $mixedResult = $this->_getFieldValueThumb('FIELD_PICTURE', $iContentId, $sTranscoder);
  64. return $mixedResult !== false ? $mixedResult : '';
  65. }
  66. public function serviceGetSearchResultUnit ($iContentId, $sUnitTemplate = '')
  67. {
  68. if(empty($sUnitTemplate))
  69. $sUnitTemplate = 'unit_with_cover.html';
  70. return parent::serviceGetSearchResultUnit($iContentId, $sUnitTemplate);
  71. }
  72. public function serviceGetSearchableFieldsExtended($aInputsAdd = array())
  73. {
  74. $CNF = &$this->_oConfig->CNF;
  75. $aResult = parent::serviceGetSearchableFieldsExtended($aInputsAdd);
  76. if(!$this->serviceActAsProfile())
  77. return $aResult;
  78. if(!in_array('online', $this->_aSearchableNamesExcept))
  79. $aResult['online'] = array(
  80. 'type' => 'checkbox',
  81. 'caption' => $CNF['T']['form_field_online'],
  82. 'info' => '',
  83. 'value' => '1',
  84. 'values' => '',
  85. 'pass' => ''
  86. );
  87. if(!empty($CNF['FIELD_PICTURE']) && !in_array($CNF['FIELD_PICTURE'], $this->_aSearchableNamesExcept))
  88. $aResult[$CNF['FIELD_PICTURE']] = array(
  89. 'type' => 'checkbox',
  90. 'caption' => $CNF['T']['form_field_picture'],
  91. 'info' => '',
  92. 'value' => '1',
  93. 'values' => '',
  94. 'pass' => '',
  95. 'search_operator' => '>='
  96. );
  97. return $aResult;
  98. }
  99. public function servicePrivateProfileMsg()
  100. {
  101. $mixedContent = $this->_getContent();
  102. if ($mixedContent) {
  103. list($iContentId, $aContentInfo) = $mixedContent;
  104. return $this->checkAllowedView($aContentInfo);
  105. }
  106. return MsgBox(_t('_sys_access_denied_to_private_content'));
  107. }
  108. public function serviceGetContentInfoById($iContentId)
  109. {
  110. return $this->_oDb->getContentInfoById((int)$iContentId);
  111. }
  112. public function serviceGetMenuAddonManageTools()
  113. {
  114. bx_import('SearchResult', $this->_aModule);
  115. $sClass = $this->_aModule['class_prefix'] . 'SearchResult';
  116. $o = new $sClass();
  117. $o->unsetPaginate();
  118. $iNumTotal = $o->getNum();
  119. $o->fillFilters(array(
  120. 'perofileStatus' => BX_PROFILE_STATUS_PENDING
  121. ));
  122. $iNum1 = $o->getNum();
  123. $iNum2 = 0;
  124. $CNF = &$this->_oConfig->CNF;
  125. if (isset($CNF['OBJECT_REPORTS'])){
  126. $o->fillFilters(array('perofileStatus' => ''));
  127. $o->fillFiltersByObjects(array('reported' => array('value' => '0', 'field' => 'reports', 'operator' => '>', 'table' => $CNF['TABLE_ENTRIES'])));
  128. $iNum2 = $o->getNum();
  129. }
  130. return array('counter1_value' => $iNum1, 'counter2_value' => $iNum2, 'counter3_value' => $iNumTotal, 'counter1_caption' => _t('_sys_menu_dashboard_manage_tools_addon_counter1_caption_profile_default'));
  131. }
  132. public function serviceGetMenuAddonManageToolsProfileStats()
  133. {
  134. bx_import('SearchResult', $this->_aModule);
  135. $sClass = $this->_aModule['class_prefix'] . 'SearchResult';
  136. $o = new $sClass();
  137. $o->fillFilters(array(
  138. 'account_id' => getLoggedId(),
  139. 'perofileStatus' => ''
  140. ));
  141. $o->unsetPaginate();
  142. return $o->getNum();
  143. }
  144. public function serviceGetMenuAddonFavoritesProfileStats()
  145. {
  146. bx_import('SearchResult', $this->_aModule);
  147. $sClass = $this->_aModule['class_prefix'] . 'SearchResult';
  148. $o = new $sClass('favorite', array('user' => bx_get_logged_profile_id()));
  149. $o->unsetPaginate();
  150. return $o->getNum();
  151. }
  152. public function serviceGetSubmenuObject ()
  153. {
  154. return $this->_oConfig->CNF['OBJECT_MENU_SUBMENU_VIEW_ENTRY'];
  155. }
  156. public function serviceGetMenuSetNameForMenuTrigger ($sMenuTriggerName)
  157. {
  158. $CNF = &$this->_oConfig->CNF;
  159. if (isset($CNF['TRIGGER_MENU_PROFILE_VIEW_SUBMENU']) && $CNF['TRIGGER_MENU_PROFILE_VIEW_SUBMENU'] == $sMenuTriggerName)
  160. return $CNF['OBJECT_MENU_SUBMENU_VIEW_ENTRY'];
  161. elseif (isset($CNF['TRIGGER_MENU_PROFILE_SNIPPET_META']) && $CNF['TRIGGER_MENU_PROFILE_SNIPPET_META'] == $sMenuTriggerName)
  162. return $CNF['OBJECT_MENU_SNIPPET_META'];
  163. else if (isset($CNF['TRIGGER_MENU_PROFILE_VIEW_ACTIONS']) && $CNF['TRIGGER_MENU_PROFILE_VIEW_ACTIONS'] == $sMenuTriggerName) {
  164. if(empty($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY_ALL']))
  165. return $CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY'];
  166. else
  167. return array($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY'], $CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY_ALL']);
  168. }
  169. return '';
  170. }
  171. public function serviceGetSnippetMenuVars($iProfileId, $bPublic = null)
  172. {
  173. return $this->_oTemplate->getSnippetMenuVars($iProfileId, $bPublic);
  174. }
  175. public function serviceGetPageObjectForPageTrigger ($sPageTriggerName)
  176. {
  177. if (isset($this->_oConfig->CNF['TRIGGER_PAGE_VIEW_ENTRY']) && $this->_oConfig->CNF['TRIGGER_PAGE_VIEW_ENTRY'] == $sPageTriggerName)
  178. return $this->_oConfig->CNF['OBJECT_PAGE_VIEW_ENTRY'];
  179. return '';
  180. }
  181. public function serviceProfilesSearch ($sTerm, $iLimit)
  182. {
  183. $aRet = array();
  184. $a = $this->_oDb->searchByTerm($sTerm, $iLimit);
  185. foreach ($a as $r) {
  186. $oProfile = BxDolProfile::getInstance($r['profile_id']);
  187. $aRet[] = array (
  188. 'label' => $this->serviceProfileName($r['content_id']),
  189. 'value' => $r['profile_id'],
  190. 'url' => $oProfile->getUrl(),
  191. 'thumb' => $oProfile->getThumb(),
  192. 'unit' => $oProfile->getUnit(0, array('template' => 'unit_wo_info'))
  193. );
  194. }
  195. return $aRet;
  196. }
  197. public function serviceProfileUnit ($iContentId, $aParams = array())
  198. {
  199. $mixedContent = $this->_getContent($iContentId);
  200. if($mixedContent === false)
  201. return false;
  202. list($iContentId, $aContentInfo) = $mixedContent;
  203. $bCheckPrivateContent = isset($aParams['check_private_content']) ? (bool)$aParams['check_private_content'] : true;
  204. $sTemplate = 'unit.html';
  205. $sTemplateSize = false;
  206. $aTemplateVars = array();
  207. if(!empty($aParams['template'])) {
  208. if(is_string($aParams['template']))
  209. $sTemplate = $aParams['template'] . '.html';
  210. else if(is_array($aParams['template'])) {
  211. if(!empty($aParams['template']['name']))
  212. $sTemplate = $aParams['template']['name'] . '.html';
  213. if(!empty($aParams['template']['size']))
  214. $sTemplateSize = $aParams['template']['size'];
  215. if(!empty($aParams['template']['vars']))
  216. $aTemplateVars = $aParams['template']['vars'];
  217. }
  218. }
  219. return $this->_oTemplate->unit($aContentInfo, $bCheckPrivateContent, array($sTemplate, $sTemplateSize, $aTemplateVars));
  220. }
  221. public function serviceHasImage ($iContentId)
  222. {
  223. $CNF = &$this->_oConfig->CNF;
  224. $mixedContent = $this->_getContent($iContentId, 'getContentInfoById');
  225. if($mixedContent === false)
  226. return false;
  227. list($iContentId, $aContentInfo) = $mixedContent;
  228. return !empty($aContentInfo[$CNF['FIELD_PICTURE']]);
  229. }
  230. public function serviceProfilePicture ($iContentId)
  231. {
  232. return $this->_serviceTemplateFunc('urlPicture', $iContentId);
  233. }
  234. public function serviceProfileAvatar ($iContentId)
  235. {
  236. return $this->_serviceTemplateFunc('urlAvatar', $iContentId);
  237. }
  238. public function serviceProfileCover ($iContentId)
  239. {
  240. return $this->_serviceTemplateFunc('urlCover', $iContentId);
  241. }
  242. public function serviceProfileUnitCover ($iContentId)
  243. {
  244. return $this->_serviceTemplateFunc('urlCoverUnit', $iContentId);
  245. }
  246. public function serviceProfileEditUrl ($iContentId)
  247. {
  248. return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $this->_oConfig->CNF['URI_EDIT_ENTRY'] . '&id=' . $iContentId);
  249. }
  250. public function serviceProfileThumb ($iContentId)
  251. {
  252. return $this->_serviceTemplateFunc('thumb', $iContentId);
  253. }
  254. public function serviceProfileIcon ($iContentId)
  255. {
  256. return $this->_serviceTemplateFunc('icon', $iContentId);
  257. }
  258. public function serviceProfileName ($iContentId)
  259. {
  260. if (!$iContentId)
  261. return false;
  262. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  263. if (!$aContentInfo)
  264. return false;
  265. return bx_process_output($aContentInfo[$this->_oConfig->CNF['FIELD_NAME']]);
  266. }
  267. public function serviceProfileCreateUrl ($bAbsolute = true)
  268. {
  269. $CNF = $this->_oConfig->CNF;
  270. if(empty($CNF['URL_CREATE']))
  271. return false;
  272. return $bAbsolute ? BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink($CNF['URL_CREATE']) : $CNF['URL_CREATE'];
  273. }
  274. public function serviceProfileUrl ($iContentId)
  275. {
  276. if (!$iContentId)
  277. return false;
  278. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  279. if (!$aContentInfo)
  280. return false;
  281. $CNF = $this->_oConfig->CNF;
  282. return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
  283. }
  284. /**
  285. * @see iBxDolProfileService::serviceGetSpaceTitle
  286. */
  287. public function serviceGetSpaceTitle()
  288. {
  289. return _t('_sys_ps_space_title_friend');
  290. }
  291. /**
  292. * @see iBxDolProfileService::serviceGetParticipatingProfiles
  293. */
  294. public function serviceGetParticipatingProfiles($iProfileId, $aConnectionObjects = false)
  295. {
  296. if (false === $aConnectionObjects)
  297. $aConnectionObjects = array('sys_profiles_friends');
  298. $a = array();
  299. foreach ($aConnectionObjects as $sConnectionObject) {
  300. if (!($o = BxDolConnection::getObjectInstance($sConnectionObject)))
  301. continue;
  302. if (BX_CONNECTIONS_TYPE_MUTUAL == $o->getType())
  303. $a = array_merge($a, $o->getConnectedContent($iProfileId, true));
  304. else
  305. $a = array_merge($a, $o->getConnectedContent($iProfileId));
  306. }
  307. $a = array_unique($a);
  308. $aRet = array();
  309. foreach ($a as $iConnectedProfileId) {
  310. if (!($oConnectedProfile = BxDolProfile::getInstance($iConnectedProfileId)))
  311. continue;
  312. if ($oConnectedProfile->getModule() != $this->getName())
  313. continue;
  314. if (CHECK_ACTION_RESULT_ALLOWED === bx_srv($oConnectedProfile->getModule(), 'check_allowed_post_in_profile', array($oConnectedProfile->getContentId(), $iProfileId)))
  315. $aRet[] = $iConnectedProfileId;
  316. }
  317. bx_alert('system', 'get_participating_profiles', $iProfileId, false, array(
  318. 'module' => $this->_oConfig->getName(),
  319. 'profiles' => &$aRet
  320. ));
  321. return $aRet;
  322. }
  323. /**
  324. * Prepare fields from some universal set of fields to fields in particular profile module.
  325. * By default only 'name' and 'description' fields are supported.
  326. * After fields convertion it can be used in @see BxBaseModGeneralModule::serviceEntityAdd
  327. * @param $aFieldsProfile fields in soem universal format.
  328. * @return array which is ready to use for particular module
  329. */
  330. public function servicePrepareFields ($aFieldsProfile)
  331. {
  332. bx_alert($this->getName(), 'prepare_fields', 0, 0, array('fields_orig' => $aFieldsProfile, 'fields_result' => &$aFieldsProfile));
  333. return $aFieldsProfile;
  334. }
  335. protected function _servicePrepareFields ($aFieldsProfile, $aFieldsDefault, $aMap)
  336. {
  337. $aFieldsOrig = $aFieldsProfile;
  338. bx_import('BxDolPrivacy');
  339. $aFieldsDefault2 = array(
  340. 'allow_view_to' => BX_DOL_PG_ALL,
  341. 'allow_post_to' => BX_DOL_PG_FRIENDS,
  342. );
  343. $aFieldsProfile = array_merge($aFieldsDefault2, $aFieldsDefault, $aFieldsProfile);
  344. foreach ($aMap as $k => $v) {
  345. if (isset($aFieldsProfile[$v]))
  346. $aFieldsProfile[$k] = $aFieldsProfile[$v];
  347. if ($k != $v && !isset($aMap[$v]))
  348. unset($aFieldsProfile[$v]);
  349. }
  350. bx_alert($this->getName(), 'prepare_fields', 0, 0, array('fields_orig' => $aFieldsOrig, 'fields_result' => &$aFieldsProfile));
  351. return $aFieldsProfile;
  352. }
  353. public function serviceFormsHelper ()
  354. {
  355. return parent::serviceFormsHelper ();
  356. }
  357. public function serviceEntityCreate ($sDisplay = false)
  358. {
  359. BxDolInformer::getInstance($this->_oTemplate)->setEnabled(false);
  360. return parent::serviceEntityCreate ($sDisplay);
  361. }
  362. public function serviceActAsProfile ()
  363. {
  364. return true;
  365. }
  366. public function serviceBrowseRecommended ($sUnitView = false, $bEmptyMessage = false, $bAjaxPaginate = true)
  367. {
  368. if (!isLogged())
  369. return '';
  370. return $this->_serviceBrowse ('recommended', $sUnitView ? array('unit_view' => $sUnitView) : false, BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  371. }
  372. public function serviceBrowseRecentProfiles ($bDisplayEmptyMsg = false, $bAjaxPaginate = true)
  373. {
  374. return $this->_serviceBrowse ('recent', false, BX_DB_PADDING_DEF, $bDisplayEmptyMsg, $bAjaxPaginate);
  375. }
  376. public function serviceBrowseActiveProfiles ($sUnitView = false, $bEmptyMessage = false, $bAjaxPaginate = false)
  377. {
  378. return $this->_serviceBrowse ('active', $sUnitView ? array('unit_view' => $sUnitView) : false, BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  379. }
  380. public function serviceBrowseTopProfiles ($bDisplayEmptyMsg = false, $bAjaxPaginate = false)
  381. {
  382. return $this->_serviceBrowse ('top', false, BX_DB_PADDING_DEF, $bDisplayEmptyMsg, $bAjaxPaginate);
  383. }
  384. public function serviceBrowseOnlineProfiles ($bDisplayEmptyMsg = false, $bAjaxPaginate = false)
  385. {
  386. return $this->_serviceBrowse ('online', false, BX_DB_PADDING_DEF, $bDisplayEmptyMsg, $bAjaxPaginate);
  387. }
  388. public function serviceBrowseConnections ($iProfileId, $sObjectConnections = 'sys_profiles_friends', $sConnectionsType = 'content', $iMutual = false, $iDesignBox = BX_DB_PADDING_DEF, $iProfileId2 = 0)
  389. {
  390. return $this->_serviceBrowse (
  391. 'connections',
  392. array(
  393. 'object' => $sObjectConnections,
  394. 'type' => $sConnectionsType,
  395. 'mutual' => $iMutual,
  396. 'profile' => (int)$iProfileId,
  397. 'profile2' => (int)$iProfileId2),
  398. $iDesignBox
  399. );
  400. }
  401. public function serviceBrowseRelationsQuick ($iProfileId, $sObjectConnections = 'sys_profiles_friends', $sConnectionsType = 'content', $iMutual = false, $iProfileId2 = 0)
  402. {
  403. // get connections object
  404. $oConnection = BxDolConnection::getObjectInstance($sObjectConnections);
  405. if (!$oConnection)
  406. return '';
  407. // set some vars
  408. $iStart = (int)bx_get('start');
  409. $iLimit = empty($this->_oConfig->CNF['PARAM_NUM_CONNECTIONS_QUICK']) ? 4 : getParam($this->_oConfig->CNF['PARAM_NUM_CONNECTIONS_QUICK']);
  410. if (!$iLimit)
  411. $iLimit = 4;
  412. // get connections array
  413. bx_import('BxDolConnection');
  414. $aConnections = $oConnection->getConnectionsAsArrayExt($sConnectionsType, $iProfileId, $iProfileId2, $iMutual, $iStart, $iLimit + 1, BX_CONNECTIONS_ORDER_ADDED_DESC);
  415. if(empty($aConnections) || !is_array($aConnections))
  416. return '';
  417. $aResult = array();
  418. foreach($aConnections as $iProfile => $aConnection)
  419. $aResult[] = array(
  420. 'id' => $iProfile,
  421. 'info' => array(
  422. 'addon' => $oConnection->getRelationTranslation($aConnection['relation'])
  423. )
  424. );
  425. return $this->_serviceBrowseQuick($aResult, $iStart, $iLimit);
  426. }
  427. public function serviceBrowseConnectionsQuick ($iProfileId, $sObjectConnections = 'sys_profiles_friends', $sConnectionsType = 'content', $iMutual = false, $iProfileId2 = 0)
  428. {
  429. // get connections object
  430. $oConnection = BxDolConnection::getObjectInstance($sObjectConnections);
  431. if (!$oConnection)
  432. return '';
  433. // set some vars
  434. $iLimit = empty($this->_oConfig->CNF['PARAM_NUM_CONNECTIONS_QUICK']) ? 4 : getParam($this->_oConfig->CNF['PARAM_NUM_CONNECTIONS_QUICK']);
  435. if (!$iLimit)
  436. $iLimit = 4;
  437. $iStart = (int)bx_get('start');
  438. // get connections array
  439. bx_import('BxDolConnection');
  440. $a = $oConnection->getConnectionsAsArray ($sConnectionsType, $iProfileId, $iProfileId2, $iMutual, (int)bx_get('start'), $iLimit + 1, BX_CONNECTIONS_ORDER_ADDED_DESC);
  441. if (!$a)
  442. return '';
  443. return $this->_serviceBrowseQuick($a, $iStart, $iLimit);
  444. }
  445. public function serviceBrowseConnectionsByType ($aParamsCnn, $aParamsBrs = array())
  446. {
  447. $sAll = 'all';
  448. $aParamsCnn['object'] = !empty($aParamsCnn['object']) ? $aParamsCnn['object'] : 'sys_profiles_friends';
  449. $aParamsCnn['type'] = !empty($aParamsCnn['type']) ? $aParamsCnn['type'] : 'content';
  450. $aParamsCnn['profile_id2'] = !empty($aParamsCnn['profile_id2']) ? (int)$aParamsCnn['profile_id2'] : 0;
  451. $aParamsCnn['mutual'] = isset($aParamsCnn['mutual']) ? $aParamsCnn['mutual'] : false;
  452. $oConnection = BxDolConnection::getObjectInstance($aParamsCnn['object']);
  453. if(!$oConnection)
  454. return '';
  455. $aSQLParts = $oConnection->getConnectionsAsSQLParts ($aParamsCnn['type'], 'sys_profiles', 'id', $aParamsCnn['profile_id'], $aParamsCnn['profile_id2'], $aParamsCnn['mutual']);
  456. $sType = !empty($aParamsBrs['type']) ? $aParamsBrs['type'] : $sAll;
  457. if(bx_get('type') !== false)
  458. $sType = bx_process_input(bx_get('type'));
  459. $iStart = (int)bx_get('start');
  460. $iLimitDefault = 4;
  461. $iLimit = !empty($this->_oConfig->CNF['PARAM_NUM_CONNECTIONS_QUICK']) ? getParam($this->_oConfig->CNF['PARAM_NUM_CONNECTIONS_QUICK']) : $iLimitDefault;
  462. if(!empty($aParamsBrs['per_page']))
  463. $iLimit = (int)$aParamsBrs['per_page'];
  464. if(!$iLimit)
  465. $iLimit = $iLimitDefault;
  466. $aProfiles = BxDolProfileQuery::getInstance()->getConnectedProfilesByType($aSQLParts, ($sType != $sAll ? $sType : ''), $iStart, $iLimit + 1);
  467. $mixedMenu = '';
  468. if(!isset($aParamsBrs['filter_menu']) || $aParamsBrs['filter_menu'] === true) {
  469. $aModules = array(
  470. array('name' => $sAll)
  471. );
  472. $aModules = array_merge($aModules, BxDolModuleQuery::getInstance()->getModulesBy(array('type' => 'modules', 'active' => 1)));
  473. $aMenuItems = array();
  474. foreach($aModules as $aModule)
  475. if($aModule['name'] == $sAll || BxDolRequest::serviceExists($aModule['name'], 'act_as_profile'))
  476. $aMenuItems[] = array(
  477. 'id' => $aModule['name'],
  478. 'name' => $aModule['name'],
  479. 'class' => '',
  480. 'link' => 'javascript:void(0)',
  481. 'onclick' => "return !loadDynamicBlockAutoPaginate(this, " . $iStart . ", " . $iLimit . ", " . bx_js_string(json_encode(array('type' => $aModule['name']))) . ");",
  482. 'target' => '_self',
  483. 'title' => _t('_' . $aModule['name']),
  484. 'active' => 1
  485. );
  486. if(!empty($aMenuItems)) {
  487. $mixedMenu = new BxTemplMenu(array('template' => 'menu_vertical.html', 'menu_id'=> $this->_oConfig->getName() . '-connections-by-type', 'menu_items' => $aMenuItems));
  488. $mixedMenu->setSelected('', $sType);
  489. }
  490. }
  491. return array(
  492. 'menu' => $mixedMenu,
  493. 'content' => $this->_serviceBrowseQuick(array_keys($aProfiles), $iStart, $iLimit, array('type' => $sType))
  494. );
  495. }
  496. public function serviceBrowseByAcl ($mixedLevelId, $iDesignBox = BX_DB_PADDING_DEF)
  497. {
  498. return $this->_serviceBrowse (
  499. 'acl',
  500. array(
  501. 'level' => $mixedLevelId,
  502. ),
  503. $iDesignBox,
  504. true
  505. );
  506. }
  507. public function serviceEntityEditCover ($iContentId = 0)
  508. {
  509. return $this->_serviceEntityForm ('editDataForm', $iContentId, $this->_oConfig->CNF['OBJECT_FORM_ENTRY_DISPLAY_EDIT_COVER']);
  510. }
  511. /**
  512. * Entry comments
  513. */
  514. public function serviceEntityCommentsByProfile ($iProfileId)
  515. {
  516. $CNF = &$this->_oConfig->CNF;
  517. if(empty($CNF['OBJECT_COMMENTS']))
  518. return '';
  519. $oProfile = BxDolProfile::getInstance($iProfileId);
  520. if(!$oProfile)
  521. return '';
  522. return $this->_entityComments($CNF['OBJECT_COMMENTS'], $oProfile->getContentId());
  523. }
  524. /**
  525. * Entry social sharing block
  526. */
  527. public function serviceEntitySocialSharing ($mixedContent = false, $aParams = array())
  528. {
  529. if(!empty($mixedContent)) {
  530. if(!is_array($mixedContent))
  531. $mixedContent = array((int)$mixedContent, array());
  532. }
  533. else {
  534. $mixedContent = $this->_getContent();
  535. if($mixedContent === false)
  536. return false;
  537. }
  538. list($iContentId, $aContentInfo) = $mixedContent;
  539. return parent::serviceEntitySocialSharing(array($iContentId, $aContentInfo), array(
  540. 'id_thumb' => !empty($CNF['FIELD_PICTURE']) && !empty($aContentInfo[$CNF['FIELD_PICTURE']]) ? $aContentInfo[$CNF['FIELD_PICTURE']] : 0,
  541. ));
  542. }
  543. public function serviceProfileMembership ($iContentId = 0)
  544. {
  545. $mixedContent = $this->_getContent($iContentId);
  546. if($mixedContent === false)
  547. return false;
  548. list($iContentId, $aContentInfo) = $mixedContent;
  549. return BxDolAcl::getInstance()->getProfileMembership($aContentInfo['profile_id']);
  550. }
  551. public function serviceProfileFriends ($iContentId = 0)
  552. {
  553. $mixedContent = $this->_getContent($iContentId);
  554. if($mixedContent === false)
  555. return false;
  556. list($iContentId, $aContentInfo) = $mixedContent;
  557. bx_import('BxDolConnection');
  558. $s = $this->serviceBrowseConnectionsQuick ($aContentInfo['profile_id'], 'sys_profiles_friends', BX_CONNECTIONS_CONTENT_TYPE_CONTENT, true);
  559. if (!$s)
  560. return MsgBox(_t('_sys_txt_empty'));
  561. return $s;
  562. }
  563. public function serviceProfileSubscriptions ($iContentId = 0, $aParams = array())
  564. {
  565. $mixedContent = $this->_getContent($iContentId);
  566. if($mixedContent === false)
  567. return false;
  568. list($iContentId, $aContentInfo) = $mixedContent;
  569. bx_import('BxDolConnection');
  570. $aResult = $this->serviceBrowseConnectionsByType(array(
  571. 'profile_id' => $aContentInfo['profile_id'],
  572. 'object' => 'sys_profiles_subscriptions',
  573. 'type' => BX_CONNECTIONS_CONTENT_TYPE_CONTENT
  574. ), array(
  575. 'type' => isset($aParams['type']) ? $aParams['type'] : '',
  576. 'filter_menu' => isset($aParams['filter_menu']) ? $aParams['filter_menu'] : true,
  577. ));
  578. if(empty($aResult['content']))
  579. $aResult['content'] = MsgBox(_t('_sys_txt_empty'));
  580. return $aResult;
  581. }
  582. public function serviceProfileSubscribedMe ($iContentId = 0)
  583. {
  584. $mixedContent = $this->_getContent($iContentId);
  585. if($mixedContent === false)
  586. return false;
  587. list($iContentId, $aContentInfo) = $mixedContent;
  588. bx_import('BxDolConnection');
  589. $s = $this->serviceBrowseConnectionsQuick ($aContentInfo['profile_id'], 'sys_profiles_subscriptions', BX_CONNECTIONS_CONTENT_TYPE_INITIATORS);
  590. if (!$s)
  591. return MsgBox(_t('_sys_txt_empty'));
  592. return $s;
  593. }
  594. public function serviceProfileRelations ($iContentId = 0, $aParams = array())
  595. {
  596. $mixedContent = $this->_getContent($iContentId);
  597. if($mixedContent === false)
  598. return false;
  599. list($iContentId, $aContentInfo) = $mixedContent;
  600. bx_import('BxDolConnection');
  601. $s = $this->serviceBrowseRelationsQuick ($aContentInfo['profile_id'], 'sys_profiles_relations', BX_CONNECTIONS_CONTENT_TYPE_CONTENT, 1);
  602. if (!$s)
  603. return MsgBox(_t('_sys_txt_empty'));
  604. return $s;
  605. }
  606. public function serviceProfileRelatedMe ($iContentId = 0)
  607. {
  608. $mixedContent = $this->_getContent($iContentId);
  609. if($mixedContent === false)
  610. return false;
  611. list($iContentId, $aContentInfo) = $mixedContent;
  612. bx_import('BxDolConnection');
  613. $s = $this->serviceBrowseRelationsQuick ($aContentInfo['profile_id'], 'sys_profiles_relations', BX_CONNECTIONS_CONTENT_TYPE_INITIATORS, 1);
  614. if (!$s)
  615. return MsgBox(_t('_sys_txt_empty'));
  616. return $s;
  617. }
  618. /**
  619. * check enabled profile activation letter
  620. */
  621. public function serviceIsEnableProfileActivationLetter()
  622. {
  623. $CNF = &$this->_oConfig->CNF;
  624. return isset($CNF['PARAM_ENABLE_ACTIVATION_LETTER']) ? (bool)getParam($CNF['PARAM_ENABLE_ACTIVATION_LETTER']) : true;
  625. }
  626. public function serviceIsEnableRelations()
  627. {
  628. $sModule = $this->_oConfig->getName();
  629. $oRelations = BxDolConnection::getObjectInstance('sys_profiles_relations');
  630. return $oRelations->isRelationAvailableWithProfile($sModule) || $oRelations->isRelationAvailableFromProfile($sModule);
  631. }
  632. /**
  633. * For internal usage only.
  634. */
  635. public function serviceDeleteEntityService ($iContentId, $bDeleteWithContent = false)
  636. {
  637. return parent::serviceDeleteEntity ($iContentId, 'deleteDataService');
  638. }
  639. /**
  640. * Data for Notifications module
  641. */
  642. public function serviceGetNotificationsData()
  643. {
  644. $a = parent::serviceGetNotificationsData();
  645. $sModule = $this->_aModule['name'];
  646. $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');
  647. $a['settings'][] = array('group' => 'timeline_post', 'unit' => $sModule, 'action' => 'timeline_post_common', 'types' => array('follow_member'));
  648. $a['alerts'][] = array('unit' => $sModule, 'action' => 'timeline_post_common');
  649. return $a;
  650. }
  651. public function serviceGetNotificationsPost($aEvent)
  652. {
  653. $aResult = parent::serviceGetNotificationsVote($aEvent);
  654. if(empty($aResult) || !is_array($aResult) || !$this->serviceActAsProfile())
  655. return $aResult;
  656. $oProfile = BxDolProfile::getInstanceByContentAndType((int)$aEvent['object_id'], $this->_oConfig->getName());
  657. if($oProfile !== false)
  658. $aResult['entry_author'] = $oProfile->id();
  659. return $aResult;
  660. }
  661. public function serviceGetNotificationsVote($aEvent)
  662. {
  663. $aResult = parent::serviceGetNotificationsVote($aEvent);
  664. if(empty($aResult) || !is_array($aResult) || !$this->serviceActAsProfile())
  665. return $aResult;
  666. $oProfile = BxDolProfile::getInstanceByContentAndType((int)$aEvent['object_id'], $this->_oConfig->getName());
  667. if($oProfile !== false)
  668. $aResult['entry_author'] = $oProfile->id();
  669. return $aResult;
  670. }
  671. /**
  672. * Notification about new member requst in the group
  673. */
  674. public function serviceGetNotificationsTimelinePostCommon($aEvent)
  675. {
  676. $CNF = &$this->_oConfig->CNF;
  677. $iContentId = (int)$aEvent['object_id'];
  678. $oGroupProfile = BxDolProfile::getInstanceByContentAndType((int)$iContentId, $this->getName());
  679. if(!$oGroupProfile)
  680. return array();
  681. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  682. if(empty($aContentInfo) || !is_array($aContentInfo))
  683. return array();
  684. $aSubcontentInfo = BxDolService::call('bx_timeline', 'get_info', array((int)$aEvent['subobject_id'], false));
  685. if(empty($aSubcontentInfo) || !is_array($aSubcontentInfo))
  686. return array();
  687. $sSubentryUrl = BxDolService::call('bx_timeline', 'get_link', array((int)$aEvent['subobject_id']));
  688. $sSubentrySample = $aSubcontentInfo['title'];
  689. if(empty($sSubentrySample))
  690. $sSubentrySample = strmaxtextlen($aSubcontentInfo['description'], 20, '...');
  691. return array(
  692. 'entry_sample' => $CNF['T']['txt_sample_single'],
  693. 'entry_url' => $oGroupProfile->getUrl(),
  694. 'entry_caption' => $oGroupProfile->getDisplayName(),
  695. 'entry_author' => $oGroupProfile->id(),
  696. 'subentry_sample' => $sSubentrySample,
  697. 'subentry_url' => $sSubentryUrl,
  698. 'lang_key' => $CNF['T']['txt_ntfs_timeline_post_common'],
  699. );
  700. }
  701. /**
  702. * Data for Timeline module
  703. */
  704. public function serviceGetTimelineData()
  705. {
  706. $CNF = &$this->_oConfig->CNF;
  707. $sModule = $this->_aModule['name'];
  708. $aAlerts = array();
  709. $aHandlers = array();
  710. if(!empty($CNF['FIELD_PICTURE'])) {
  711. $aAlerts = array_merge($aAlerts, array(
  712. array('unit' => $sModule, 'action' => 'profile_picture_changed'),
  713. array('unit' => $sModule, 'action' => 'profile_picture_deleted')
  714. ));
  715. $aHandlers = array_merge($aHandlers, array(
  716. 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' => ''),
  717. array('group' => $sModule . '_profile_picture', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'profile_picture_deleted')
  718. ));
  719. }
  720. if(!empty($CNF['FIELD_COVER'])) {
  721. $aAlerts = array_merge($aAlerts, array(
  722. array('unit' => $sModule, 'action' => 'profile_cover_changed'),
  723. array('unit' => $sModule, 'action' => 'profile_cover_deleted')
  724. ));
  725. $aHandlers = array_merge($aHandlers, array(
  726. 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' => ''),
  727. array('group' => $sModule . '_profile_cover', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'profile_cover_deleted')
  728. ));
  729. }
  730. $aResult = array();
  731. if(!empty($aAlerts) && !empty($aHandlers))
  732. $aResult = array(
  733. 'handlers' => $aHandlers,
  734. 'alerts' => $aAlerts
  735. );
  736. return $aResult;
  737. }
  738. /**
  739. * Entry post for Timeline module
  740. */
  741. public function serviceGetTimelineProfilePicture($aEvent, $aBrowseParams = array())
  742. {
  743. $aResult = $this->_serviceGetTimelineProfileImage($aEvent, $aBrowseParams, array(
  744. 'stg' => 'OBJECT_STORAGE',
  745. 'trans' => array('OBJECT_IMAGES_TRANSCODER_GALLERY', 'OBJECT_IMAGES_TRANSCODER_AVATAR'),
  746. 'trans_orig' => array('OBJECT_IMAGES_TRANSCODER_PICTURE', 'OBJECT_IMAGES_TRANSCODER_GALLERY'),
  747. 'txt_ss' => 'txt_sample_pp_single',
  748. 'txt_sswa' => 'txt_sample_pp_single_with_article',
  749. 'txt_sa' => 'txt_sample_pi_action',
  750. 'txt_sau' => 'txt_sample_pi_action_user'
  751. ));
  752. $aResult['allowed_view'] = array('module' => $this->_oConfig->getName(), 'method' => 'get_timeline_profile_picture_allowed_view');
  753. return $aResult;
  754. }
  755. public function serviceGetTimelineProfilePictureAllowedView($aEvent)
  756. {
  757. return $this->_serviceGetTimelineProfileImageAllowedView($aEvent);
  758. }
  759. public function serviceGetTimelineProfileCover($aEvent, $aBrowseParams = array())
  760. {
  761. $aResult = $this->_serviceGetTimelineProfileImage($aEvent, $aBrowseParams, array(
  762. 'stg' => 'OBJECT_STORAGE_COVER',
  763. 'trans' => array('OBJECT_IMAGES_TRANSCODER_GALLERY', 'OBJECT_IMAGES_TRANSCODER_COVER_THUMB'),
  764. 'trans_orig' => array('OBJECT_IMAGES_TRANSCODER_COVER', 'OBJECT_IMAGES_TRANSCODER_GALLERY'),
  765. 'txt_ss' => 'txt_sample_pc_single',
  766. 'txt_sswa' => 'txt_sample_pc_single_with_article',
  767. 'txt_sa' => 'txt_sample_pi_action',
  768. 'txt_sau' => 'txt_sample_pi_action_user'
  769. ));
  770. $aResult['allowed_view'] = array('module' => $this->_oConfig->getName(), 'method' => 'get_timeline_profile_cover_allowed_view');
  771. return $aResult;
  772. }
  773. public function serviceGetTimelineProfileCoverAllowedView($aEvent)
  774. {
  775. return $this->_serviceGetTimelineProfileImageAllowedView($aEvent);
  776. }
  777. public function serviceGetConnectionButtonsTitles($iProfileId, $sConnectionsObject = 'sys_profiles_friends')
  778. {
  779. if (!isLogged())
  780. return array();
  781. if (!($oConn = BxDolConnection::getObjectInstance($sConnectionsObject)))
  782. return array();
  783. $CNF = $this->_oConfig->CNF;
  784. if ($oConn->isConnectedNotMutual(bx_get_logged_profile_id(), $iProfileId)) {
  785. return array(
  786. 'add' => _t($CNF['T']['menu_item_title_befriend_sent']),
  787. 'remove' => _t($CNF['T']['menu_item_title_unfriend_cancel_request']),
  788. );
  789. } elseif ($oConn->isConnectedNotMutual($iProfileId, bx_get_logged_profile_id())) {
  790. return array(
  791. 'add' => _t($CNF['T']['menu_item_title_befriend_confirm']),
  792. 'remove' => _t($CNF['T']['menu_item_title_unfriend_reject_request']),
  793. );
  794. } elseif ($oConn->isConnected($iProfileId, bx_get_logged_profile_id(), true)) {
  795. return array(
  796. 'add' => '',
  797. 'remove' => _t($CNF['T']['menu_item_title_unfriend']),
  798. );
  799. } else {
  800. return array(
  801. 'add' => _t($CNF['T']['menu_item_title_befriend']),
  802. 'remove' => '',
  803. );
  804. }
  805. }
  806. // ====== PERMISSION METHODS
  807. /**
  808. * @see iBxDolProfileService::serviceCheckAllowedProfileView
  809. */
  810. public function serviceCheckAllowedProfileView($iContentId)
  811. {
  812. return $this->serviceCheckAllowedWithContent('View', $iContentId);
  813. }
  814. /**
  815. * @see iBxDolProfileService::serviceCheckAllowedPostInProfile
  816. */
  817. public function serviceCheckAllowedPostInProfile($iContentId)
  818. {
  819. return $this->serviceCheckAllowedWithContent('Post', $iContentId);
  820. }
  821. /**
  822. * @see iBxDolProfileService::serviceCheckSpacePrivacy
  823. */
  824. public function serviceCheckSpacePrivacy($iContentId)
  825. {
  826. return $this->serviceCheckAllowedProfileView($iContentId);
  827. }
  828. /**
  829. * Check if the profile can be viewed.
  830. *
  831. * NOTE. This service should be used if it's needed to pass some specific values in
  832. * $isPerformAction and $iProfileId parameters, otherwise it's recommended to use
  833. * BxBaseModProfileModule::serviceCheckAllowedProfileView service method or
  834. * BxDolProfile::checkAllowedProfileView method.
  835. *
  836. * @param type $aDataEntry - entry which the action will be performed for
  837. * @param type $isPerformAction - perform or just check the action
  838. * @param type $iProfileId - performer's profile ID
  839. * @return integer - one of CHECK_ACTION_RESULT_XXX constants.
  840. */
  841. public function serviceCheckAllowedViewForProfile ($aDataEntry, $isPerformAction = false, $iProfileId = false)
  842. {
  843. if (!$iProfileId)
  844. $iProfileId = $this->_iProfileId;
  845. $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$this->_oConfig->CNF['FIELD_ID']], $this->getName());
  846. if ($oProfile && $oProfile->id() == $iProfileId)
  847. return CHECK_ACTION_RESULT_ALLOWED;
  848. return parent::serviceCheckAllowedViewForProfile ($aDataEntry, $isPerformAction, $iProfileId);
  849. }
  850. /**
  851. * Check if posting (comment, post in Timeline) is available.
  852. *
  853. * NOTE. This service should be used if it's needed to pass some specific values in
  854. * $isPerformAction and $iProfileId parameters, otherwise it's recommended to use
  855. * BxBaseModProfileModule::serviceCheckAllowedPostInProfile service method or
  856. * BxDolProfile::checkAllowedPostInProfile method.
  857. *
  858. * @param type $aDataEntry - entry which the action will be performed for
  859. * @param type $isPerformAction - perform or just check the action
  860. * @param type $iProfileId - performer's profile ID
  861. * @return integer - one of CHECK_ACTION_RESULT_XXX constants.
  862. */
  863. public function serviceCheckAllowedPostForProfile ($aDataEntry, $isPerformAction = false, $iProfileId = false)
  864. {
  865. $CNF = &$this->_oConfig->CNF;
  866. if(!$iProfileId)
  867. $iProfileId = $this->_iProfileId;
  868. // check is view allowed
  869. if(($mixedResult = $this->serviceCheckAllowedViewForProfile($aDataEntry, $isPerformAction, $iProfileId)) !== CHECK_ACTION_RESULT_ALLOWED)
  870. return $mixedResult;
  871. // moderator and owner always have access
  872. $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$CNF['FIELD_ID']], $this->getName());
  873. if(($oProfile && $oProfile->id() == $iProfileId) || $this->_isModerator($isPerformAction))
  874. return CHECK_ACTION_RESULT_ALLOWED;
  875. // check privacy
  876. if(!empty($CNF['OBJECT_PRIVACY_POST'])) {
  877. $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_POST']);
  878. if($oPrivacy && !$oPrivacy->check($aDataEntry[$CNF['FIELD_ID']], $iProfileId))
  879. return _t('_sys_access_denied_to_private_content');
  880. }
  881. // check alert to allow custom checks
  882. $mixedResult = null;
  883. bx_alert('system', 'check_allowed_post', 0, 0, array('module' => $this->getName(), 'content_info' => $aDataEntry, 'profile_id' => $iProfileId, 'override_result' => &$mixedResult));
  884. if($mixedResult !== null)
  885. return $mixedResult;
  886. return CHECK_ACTION_RESULT_ALLOWED;
  887. }
  888. public function serviceSetViewProfileCover($oPage, $aProfileInfo)
  889. {
  890. $this->_oTemplate->setCover($oPage,$aProfileInfo);
  891. }
  892. /**
  893. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
  894. */
  895. public function checkAllowedAdd ($isPerformAction = false)
  896. {
  897. $oAccount = BxDolAccount::getInstance();
  898. if (!$oAccount || ($this->serviceActAsProfile() && $oAccount->isProfilesLimitReached()))
  899. return _t('_sys_txt_access_denied');
  900. return parent::checkAllowedAdd ($isPerformAction);
  901. }
  902. /**
  903. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
  904. */
  905. public function checkAllowedView ($aDataEntry, $isPerformAction = false)
  906. {
  907. return $this->serviceCheckAllowedViewForProfile ($aDataEntry, $isPerformAction);
  908. }
  909. /**
  910. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  911. */
  912. public function checkAllowedViewProfileImage ($aDataEntry, $isPerformAction = false)
  913. {
  914. $CNF = &$this->_oConfig->CNF;
  915. // check privacy
  916. if (empty($CNF['OBJECT_PRIVACY_VIEW']))
  917. return CHECK_ACTION_RESULT_ALLOWED;
  918. $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']);
  919. if ($oPrivacy && !$oPrivacy->check($aDataEntry[$CNF['FIELD_ID']]) && !$oPrivacy->isPartiallyVisible($aDataEntry[$CNF['FIELD_ALLOW_VIEW_TO']]))
  920. return _t('_sys_access_denied_to_private_content');
  921. return CHECK_ACTION_RESULT_ALLOWED;
  922. }
  923. /**
  924. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  925. */
  926. public function checkAllowedViewCoverImage ($aDataEntry, $isPerformAction = false)
  927. {
  928. return $this->checkAllowedViewProfileImage($aDataEntry);
  929. }
  930. /**
  931. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  932. */
  933. public function checkAllowedPost ($aDataEntry, $isPerformAction = false)
  934. {
  935. return $this->serviceCheckAllowedPostForProfile ($aDataEntry, $isPerformAction);
  936. }
  937. /**
  938. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  939. */
  940. public function checkAllowedEdit ($aDataEntry, $isPerformAction = false)
  941. {
  942. // moderator always has access
  943. if ($this->_isModerator($isPerformAction))
  944. return CHECK_ACTION_RESULT_ALLOWED;
  945. // owner (checked by account! not as profile as ususal) always have access
  946. $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$this->_oConfig->CNF['FIELD_ID']], $this->_aModule['name']);
  947. if (!$oProfile)
  948. return _t('_sys_txt_error_occured');
  949. if ($oProfile->getAccountId() == $this->_iAccountId)
  950. return CHECK_ACTION_RESULT_ALLOWED;
  951. return _t('_sys_txt_access_denied');
  952. }
  953. /**
  954. * Check if user can change cover image
  955. */
  956. public function checkAllowedChangeCover ($aDataEntry, $isPerformAction = false)
  957. {
  958. // moderator always has access
  959. if ($this->_isModerator($isPerformAction))
  960. return CHECK_ACTION_RESULT_ALLOWED;
  961. // owner (checked by account! not as profile as ususal) always have access
  962. $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$this->_oConfig->CNF['FIELD_ID']], $this->_aModule['name']);
  963. if (!$oProfile)
  964. return _t('_sys_txt_error_occured');
  965. if ($oProfile->getAccountId() == $this->_iAccountId)
  966. return CHECK_ACTION_RESULT_ALLOWED;
  967. return _t('_sys_txt_access_denied');
  968. }
  969. /**
  970. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  971. */
  972. public function checkAllowedDelete (&$aDataEntry, $isPerformAction = false)
  973. {
  974. // moderator always has access
  975. if ($this->_isModerator($isPerformAction))
  976. return CHECK_ACTION_RESULT_ALLOWED;
  977. // check ACL and owner (checked by account! not as profile as ususal)
  978. $aCheck = checkActionModule($this->_iProfileId, 'delete entry', $this->getName(), $isPerformAction);
  979. $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$this->_oConfig->CNF['FIELD_ID']], $this->_aModule['name'], $isPerformAction);
  980. if (!$oProfile)
  981. return _t('_sys_txt_error_occured');
  982. if ($oProfile->getAccountId() == $this->_iAccountId && $aCheck[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
  983. return CHECK_ACTION_RESULT_ALLOWED;
  984. return _t('_sys_txt_access_denied');
  985. }
  986. /**
  987. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  988. */
  989. public function checkAllowedViewMoreMenu (&$aDataEntry, $isPerformAction = false)
  990. {
  991. $oMenu = BxTemplMenu::getObjectInstance($this->_oConfig->CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY_MORE']);
  992. if (!$oMenu || !$oMenu->getCode())
  993. return _t('_sys_txt_access_denied');
  994. return CHECK_ACTION_RESULT_ALLOWED;
  995. }
  996. /**
  997. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  998. */
  999. public function checkAllowedCompose (&$aDataEntry, $isPerformAction = false)
  1000. {
  1001. $CNF = &$this->_oConfig->CNF;
  1002. $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$CNF['FIELD_ID']], $this->getName());
  1003. if($oProfile && $oProfile->id() == $this->_iProfileId)
  1004. return _t('_sys_txt_access_denied');
  1005. return $this->checkAllowedView ($aDataEntry, $isPerformAction);
  1006. }
  1007. /**
  1008. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  1009. */
  1010. public function checkAllowedFriendAdd (&$aDataEntry, $isPerformAction = false)
  1011. {
  1012. return $this->_checkAllowedConnect ($aDataEntry, $isPerformAction, 'sys_profiles_friends', true, false);
  1013. }
  1014. /**
  1015. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  1016. */
  1017. public function checkAllowedFriendRemove (&$aDataEntry, $isPerformAction = false)
  1018. {
  1019. if (CHECK_ACTION_RESULT_ALLOWED === $this->_checkAllowedConnect ($aDataEntry, $isPerformAction, 'sys_profiles_friends', false, true, true))
  1020. return CHECK_ACTION_RESULT_ALLOWED;
  1021. return $this->_checkAllowedConnect ($aDataEntry, $isPerformAction, 'sys_profiles_friends', false, true, false);
  1022. }
  1023. /**
  1024. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  1025. */
  1026. public function checkAllowedRelationAdd (&$aDataEntry, $isPerformAction = false)
  1027. {
  1028. if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->checkAllowedView($aDataEntry)))
  1029. return $sMsg;
  1030. return $this->_checkAllowedConnect ($aDataEntry, $isPerformAction, 'sys_profiles_relations', false, false);
  1031. }
  1032. /**
  1033. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  1034. */
  1035. public function checkAllowedRelationRemove (&$aDataEntry, $isPerformAction = false)
  1036. {
  1037. return $this->_checkAllowedConnect ($aDataEntry, $isPerformAction, 'sys_profiles_relations', false, true);
  1038. }
  1039. public function checkAllowedRelationsView (&$aDataEntry, $isPerformAction = false)
  1040. {
  1041. $sResult = _t('_sys_txt_access_denied');
  1042. $sModule = $this->_oConfig->getName();
  1043. $oRelations = BxDolConnection::getObjectInstance('sys_profiles_relations');
  1044. if(!$oRelations->isRelationAvailableWithProfile($sModule) && !$oRelations->isRelationAvailableFromProfile($sModule))
  1045. return $sResult;
  1046. if(empty($aDataEntry) || !is_array($aDataEntry))
  1047. return $sResult;
  1048. return CHECK_ACTION_RESULT_ALLOWED;
  1049. }
  1050. /**
  1051. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  1052. */
  1053. public function checkAllowedSubscribeAdd (&$aDataEntry, $isPerformAction = false)
  1054. {
  1055. if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->checkAllowedView($aDataEntry)))
  1056. return $sMsg;
  1057. return $this->_checkAllowedConnect ($aDataEntry, $isPerformAction, 'sys_profiles_subscriptions', false, false);
  1058. }
  1059. /**
  1060. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  1061. */
  1062. public function checkAllowedSubscribeRemove (&$aDataEntry, $isPerformAction = false)
  1063. {
  1064. return $this->_checkAllowedConnect ($aDataEntry, $isPerformAction, 'sys_profiles_subscriptions', false, true);
  1065. }
  1066. public function checkAllowedSubscriptionsView (&$aDataEntry, $isPerformAction = false)
  1067. {
  1068. $CNF = &$this->_oConfig->CNF;
  1069. $sResult = _t('_sys_txt_access_denied');
  1070. if(empty($aDataEntry) || !is_array($aDataEntry))
  1071. return $sResult;
  1072. $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$CNF['FIELD_ID']], $this->_aModule['name']);
  1073. if(!$oProfile || ($oProfile->id() != $this->_iProfileId && $this->_oDb->getParam($CNF['PARAM_PUBLIC_SBSN']) != 'on' && $this->_oDb->getParam($CNF['PARAM_PUBLIC_SBSD']) != 'on'))
  1074. return $sResult;
  1075. return CHECK_ACTION_RESULT_ALLOWED;
  1076. }
  1077. public function checkMyself($iContentId)
  1078. {
  1079. $iLogged = (int)bx_get_logged_profile_id();
  1080. if(empty($iLogged))
  1081. return false;
  1082. $oProfile = BxDolProfile::getInstanceByContentAndType((int)$iContentId, $this->_oConfig->getName());
  1083. if(!$oProfile)
  1084. return false;
  1085. return $oProfile->id() == $iLogged;
  1086. }
  1087. // ====== COMMON METHODS
  1088. public function alertAfterAdd($aContentInfo)
  1089. {
  1090. $CNF = &$this->_oConfig->CNF;
  1091. $sModule = $this->getName();
  1092. $iContentId = (int)$aContentInfo[$CNF['FIELD_ID']];
  1093. $aParams = array();
  1094. if(isset($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]))
  1095. $aParams['privacy_view'] = $aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']];
  1096. bx_alert($sModule, 'added', $iContentId, false, $aParams);
  1097. }
  1098. public function alertAfterEdit($aContentInfo)
  1099. {
  1100. $CNF = &$this->_oConfig->CNF;
  1101. $sModule = $this->getName();
  1102. $iContentId = (int)$aContentInfo[$CNF['FIELD_ID']];
  1103. $oProfile = BxDolProfile::getInstanceByContentAndType($iContentId, $sModule);
  1104. bx_alert($sModule, 'edited', $iContentId);
  1105. bx_alert('profile', 'edit', $oProfile->id(), 0, array('content' => $iContentId, 'module' => $sModule));
  1106. }
  1107. public function getProfileByCurrentUrl ()
  1108. {
  1109. $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
  1110. if ($iProfileId)
  1111. return BxDolProfile::getInstance($iProfileId);
  1112. $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  1113. if ($iContentId)
  1114. return BxDolProfile::getInstanceByContentAndType($iContentId, $this->getName());
  1115. return false;
  1116. }
  1117. // ====== PROTECTED METHODS
  1118. protected function _checkAllowedConnect (&$aDataEntry, $isPerformAction, $sObjConnection, $isMutual, $isInvertResult, $isSwap = false)
  1119. {
  1120. if (!$this->_iProfileId)
  1121. return _t('_sys_txt_access_denied');
  1122. $CNF = &$this->_oConfig->CNF;
  1123. $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$CNF['FIELD_ID']], $this->_aModule['name']);
  1124. if (!$oProfile || $oProfile->id() == $this->_iProfileId)
  1125. return _t('_sys_txt_access_denied');
  1126. return BxDolConnection::getObjectInstance($sObjConnection)->checkAllowedConnect ($this->_iProfileId, $oProfile->id(), $isPerformAction, $isMutual, $isInvertResult, $isSwap);
  1127. }
  1128. protected function _buildRssParams($sMode, $aArgs)
  1129. {
  1130. $aParams = array ();
  1131. $sMode = bx_process_input($sMode);
  1132. switch ($sMode) {
  1133. case 'connections':
  1134. $aParams = array(
  1135. 'object' => isset($aArgs[0]) ? $aArgs[0] : '',
  1136. 'type' => isset($aArgs[1]) ? $aArgs[1] : '',
  1137. 'profile' => isset($aArgs[2]) ? (int)$aArgs[2] : 0,
  1138. 'mutual' => isset($aArgs[3]) ? (int)$aArgs[3] : 0,
  1139. 'profile2' => isset($aArgs[4]) ? (int)$aArgs[4] : 0,
  1140. );
  1141. break;
  1142. }
  1143. return $aParams;
  1144. }
  1145. protected function _serviceBrowseQuick($aProfiles, $iStart = 0, $iLimit = 4, $aAdditionalParams = array())
  1146. {
  1147. // get paginate object
  1148. $oPaginate = new BxTemplPaginate(array(
  1149. 'on_change_page' => "return !loadDynamicBlockAutoPaginate(this, '{start}', '{per_page}', " . bx_js_string(json_encode($aAdditionalParams)) . ");",
  1150. 'num' => count($aProfiles),
  1151. 'per_page' => $iLimit,
  1152. 'start' => $iStart,
  1153. ));
  1154. // remove last item from connection array, because we've got one more item for pagination calculations only
  1155. if (count($aProfiles) > $iLimit)
  1156. array_pop($aProfiles);
  1157. // get profiles HTML
  1158. $s = '';
  1159. foreach ($aProfiles as $mixedProfile) {
  1160. $bProfile = is_array($mixedProfile);
  1161. $oProfile = BxDolProfile::getInstance($bProfile ? (int)$mixedProfile['id'] : (int)$mixedProfile);
  1162. if(!$oProfile)
  1163. continue;
  1164. $aUnitParams = array();
  1165. if($bProfile && is_array($mixedProfile['info']))
  1166. $aUnitParams = array('template' => array('vars' => $mixedProfile['info']));
  1167. $s .= $oProfile->getUnit(0, $aUnitParams);
  1168. }
  1169. // return profiles + paginate
  1170. return $s . (!$iStart && $oPaginate->getNum() <= $iLimit ? '' : $oPaginate->getSimplePaginate());
  1171. }
  1172. protected function _serviceGetTimelineProfileImage($aEvent, $aBrowseParams, $aBuildParams)
  1173. {
  1174. $CNF = &$this->_oConfig->CNF;
  1175. $aFileInfo = BxDolStorage::getObjectInstance($CNF[$aBuildParams['stg']])->getFile((int)$aEvent['object_id']);
  1176. if(empty($aFileInfo) || !is_array($aFileInfo))
  1177. return false;
  1178. $aEventContent = unserialize($aEvent['content']);
  1179. if(!is_array($aEventContent) || empty($aEventContent['content']))
  1180. return false;
  1181. $aContentInfo = $this->_oDb->getContentInfoById($aEventContent['content']);
  1182. if(empty($aContentInfo) || !is_array($aContentInfo))
  1183. return false;
  1184. $oProfile = BxDolProfile::getInstanceMagic($aContentInfo['profile_id']);
  1185. if (!$oProfile->isActive())
  1186. return false;
  1187. $sUserName = $oProfile->getDisplayName();
  1188. $sSample = isset($CNF['T'][$aBuildParams['txt_sswa']]) ? $CNF['T'][$aBuildParams['txt_sswa']] : $CNF['T'][$aBuildParams['txt_ss']];
  1189. //--- Title & Description
  1190. $sTitle = !empty($aContentInfo[$CNF['FIELD_TITLE']]) ? $aContentInfo[$CNF['FIELD_TITLE']] : '';
  1191. if(empty($sTitle) && !empty($aContentInfo[$CNF['FIELD_TEXT']]))
  1192. $sTitle = $aContentInfo[$CNF['FIELD_TEXT']];
  1193. $sDescription = _t($CNF['T'][$aBuildParams['txt_sau']], $sUserName, _t($sSample));
  1194. return array(
  1195. 'owner_id' => $aEvent['owner_id'],
  1196. 'object_owner_id' => $aContentInfo['profile_id'],
  1197. 'icon' => !empty($CNF['ICON']) ? $CNF['ICON'] : '',
  1198. 'sample' => $sSample,
  1199. 'sample_wo_article' => $CNF['T'][$aBuildParams['txt_ss']],
  1200. 'sample_action' => isset($CNF['T'][$aBuildParams['txt_sa']]) ? $CNF['T'][$aBuildParams['txt_sa']] : '',
  1201. 'url' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]),
  1202. 'content' => $this->_getContentForTimelineProfileImage($aEvent, $aBrowseParams, $aBuildParams, $aContentInfo, $aFileInfo), //a string to display or array to parse default template before displaying.
  1203. 'date' => $aContentInfo[$CNF['FIELD_ADDED']],
  1204. 'views' => '',
  1205. 'votes' => '',
  1206. 'scores' => '',
  1207. 'reports' => '',
  1208. 'comments' => '',
  1209. 'title' => $sTitle, //may be empty.
  1210. 'description' => $sDescription //may be empty.
  1211. );
  1212. }
  1213. protected function _serviceGetTimelineProfileImageAllowedView($aEvent)
  1214. {
  1215. $sError = _t('_sys_access_denied_to_private_content');
  1216. if(empty($aEvent['content']) || !is_array($aEvent['content']) || empty($aEvent['content']['id']))
  1217. return $sError;
  1218. $aContentInfo = $this->_oDb->getContentInfoById($aEvent['content']['id']);
  1219. if(empty($aContentInfo) || !is_array($aContentInfo))
  1220. return $sError;
  1221. return $this->serviceCheckAllowedViewForProfile($aContentInfo);
  1222. }
  1223. protected function _getContentForTimelineProfileImage($aEvent, $aBrowseParams, $aBuildParams, $aContentInfo, $aFileInfo)
  1224. {
  1225. $CNF = &$this->_oConfig->CNF;
  1226. $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
  1227. //--- Image(s)
  1228. $sImage = $this->_oConfig->getImageUrl($aFileInfo['id'], $aBuildParams['trans']);
  1229. $sImageOrig = $this->_oConfig->getImageUrl($aFileInfo['id'], $aBuildParams['trans_orig']);
  1230. if(!empty($sImage)) {
  1231. if(empty($sImageOrig))
  1232. $sImageOrig = $sImage;
  1233. $a = array('url' => $sUrl, 'src' => $sImage);
  1234. if (CHECK_ACTION_RESULT_ALLOWED === $this->checkAllowedView($aContentInfo))
  1235. $a['src_orig'] = $sImageOrig;
  1236. $aImages = array($a);
  1237. }
  1238. return array(
  1239. 'sample' => isset($CNF['T'][$aBuildParams['txt_sswa']]) ? $CNF['T'][$aBuildParams['txt_sswa']] : $CNF['T'][$aBuildParams['txt_ss']],
  1240. 'sample_wo_article' => $CNF['T'][$aBuildParams['txt_ss']],
  1241. 'sample_action' => isset($CNF['T'][$aBuildParams['txt_sa']]) ? $CNF['T'][$aBuildParams['txt_sa']] : '',
  1242. 'id' => $aContentInfo[$CNF['FIELD_ID']],
  1243. 'url' => $sUrl,
  1244. 'title' => '',
  1245. 'text' => '',
  1246. 'images' => $aImages,
  1247. 'videos' => array()
  1248. );
  1249. }
  1250. protected function _entityComments($sObject, $iId = 0)
  1251. {
  1252. if(!$iId)
  1253. $iId = bx_process_input(bx_get('id'), BX_DATA_INT);
  1254. if(!$iId)
  1255. $iId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
  1256. if(!$iId)
  1257. return false;
  1258. $oCmts = BxDolCmts::getObjectInstance($sObject, $iId);
  1259. if(!$oCmts || !$oCmts->isEnabled())
  1260. return false;
  1261. return $oCmts->getCommentsBlock(array(), array('in_designbox' => false));
  1262. }
  1263. protected function _getContent($iContentId = 0, $sFuncGetContent = 'getContentInfoById')
  1264. {
  1265. if(!$iContentId && bx_get('id') === false && bx_get('profile_id') !== false) {
  1266. $oProfile = BxDolProfile::getInstance((int)bx_get('profile_id'));
  1267. if($oProfile)
  1268. $iContentId = $oProfile->getContentId();
  1269. }
  1270. return parent::_getContent($iContentId, $sFuncGetContent);
  1271. }
  1272. /** Returns list of members by mode with limited number of records for React Jot
  1273. * @param string $sMode
  1274. * @param int $iStart
  1275. * @param int $iPerPage
  1276. * @return mixed
  1277. */
  1278. public function serviceGetMembers($sMode = 'active', $iStart = 0, $iPerPage = 10){
  1279. bx_import('SearchResult', $this->_aModule);
  1280. $sClass = $this->_aModule['class_prefix'] . 'SearchResult';
  1281. $o = new $sClass($sMode);
  1282. $o -> aCurrent['paginate'] = array('perPage' => $iPerPage, 'forceStart' => $iStart);
  1283. return $o -> getSearchData();
  1284. }
  1285. }
  1286. /** @} */