1
0

BxBaseModProfileModule.php 78 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062
  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. define('BX_DOL_PROFILE_REDIRECT_HOMEPAGE', 'homepage');
  15. define('BX_DOL_PROFILE_ACTIVATE_ALWAYS', 'on');
  16. define('BX_DOL_PROFILE_ACTIVATE_NEVER', 'off');
  17. define('BX_DOL_PROFILE_ACTIVATE_ADD', 'add');
  18. define('BX_DOL_PROFILE_ACTIVATE_EDIT', 'edit');
  19. /**
  20. * Base class for profile modules.
  21. */
  22. class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolContentInfoService, iBxDolProfileService
  23. {
  24. protected $_iAccountId;
  25. function __construct(&$aModule)
  26. {
  27. parent::__construct($aModule);
  28. $CNF = &$this->_oConfig->CNF;
  29. if(!empty($CNF['FIELD_ALLOW_POST_TO']))
  30. $this->_aSearchableNamesExcept[] = $CNF['FIELD_ALLOW_POST_TO'];
  31. if(!empty($CNF['FIELD_ALLOW_CONTACT_TO']))
  32. $this->_aSearchableNamesExcept[] = $CNF['FIELD_ALLOW_CONTACT_TO'];
  33. $this->_iAccountId = getLoggedId();
  34. }
  35. public function actionDeleteProfileImg($iFileId, $iContentId, $sFieldPicture)
  36. {
  37. $aResult = array();
  38. $CNF = &$this->_oConfig->CNF;
  39. $oSrorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']);
  40. if (!($aFile = $oSrorage->getFile((int)$iFileId)) || !($aContentInfo = $this->_oDb->getContentInfoById($iContentId)) || $aContentInfo[$sFieldPicture] != (int)$iFileId)
  41. $aResult = array('error' => 1, 'msg' => _t('_sys_storage_err_file_not_found'));
  42. $oAccountProfile = BxDolProfile::getInstanceAccountProfile();
  43. if ($oAccountProfile)
  44. $iAccountProfileId = $oAccountProfile->id();
  45. if ((!$aResult && !isLogged()) || (!$aResult && $aFile['profile_id'] != $iAccountProfileId && !$this->_isModerator()))
  46. $aResult = array('error' => 2, 'msg' => _t('_Access denied'));
  47. $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD'], $this->_oTemplate);
  48. if (!$aResult && !$oForm->_deleteFile($iContentId, $sFieldPicture, (int)$iFileId, true))
  49. $aResult = array('error' => 3, 'msg' => _t('_Failed'));
  50. elseif (!$aResult)
  51. $aResult = array('error' => 0, 'msg' => '');
  52. header('Content-Type: application/json; charset=utf-8');
  53. echo json_encode($aResult);
  54. }
  55. public function actionProfileCalendarData()
  56. {
  57. $iProfileId = (int)bx_get('profile_id');
  58. $aEntries = array();
  59. $BxDolModuleQuery = BxDolModuleQuery::getInstance();
  60. $aModules = $BxDolModuleQuery->getModulesBy(array('type' => 'modules', 'active' => 1));
  61. foreach($aModules as $aModule){
  62. $sModuleName = $aModule['name'];
  63. $oModule = BxDolModule::getInstance($sModuleName);
  64. if($oModule instanceof iBxDolCalendarService){
  65. if(BxDolRequest::serviceExists($sModuleName, 'get_calendar_entries')){
  66. $aEntries2 = BxDolService::call($sModuleName, 'get_calendar_entries', array($iProfileId));
  67. $aEntries = array_merge($aEntries, $aEntries2);
  68. }
  69. }
  70. }
  71. header('Content-Type: application/json; charset=utf-8');
  72. echo json_encode($aEntries);
  73. }
  74. public function actionEmbed($iContentId, $sUnitTemplate = '', $sAddCode = '')
  75. {
  76. return parent::actionEmbed($iContentId, 'unit_with_cover.html');
  77. }
  78. // ====== SERVICE METHODS
  79. public function serviceGetSafeServices()
  80. {
  81. $a = parent::serviceGetSafeServices();
  82. return array_merge($a, array (
  83. 'ProfileUnitSafe' => '',
  84. 'ProfileUrl' => '',
  85. 'EntityCreate' => '',
  86. 'BrowseRecommended' => '',
  87. 'BrowseRecentProfiles' => '',
  88. 'BrowseActiveProfiles' => '',
  89. 'BrowseTopProfiles' => '',
  90. 'BrowseOnlineProfiles' => '',
  91. 'BrowseByAcl' => '',
  92. ));
  93. }
  94. public function serviceGetOptionsRedirectAfterAdd()
  95. {
  96. $CNF = &$this->_oConfig->CNF;
  97. $aResult = array();
  98. $aChoices = array(BX_DOL_PROFILE_REDIRECT_PROFILE, BX_DOL_PROFILE_REDIRECT_LAST, BX_DOL_PROFILE_REDIRECT_CUSTOM, BX_DOL_PROFILE_REDIRECT_HOMEPAGE);
  99. foreach($aChoices as $sChoice)
  100. $aResult[] = array('key' => $sChoice, 'value' => _t($CNF['T']['option_redirect_aadd_' . $sChoice]));
  101. return $aResult;
  102. }
  103. public function serviceGetOptionsActivation()
  104. {
  105. $CNF = &$this->_oConfig->CNF;
  106. $aResult = array();
  107. $aChoices = array(BX_DOL_PROFILE_ACTIVATE_ALWAYS, BX_DOL_PROFILE_ACTIVATE_NEVER, BX_DOL_PROFILE_ACTIVATE_ADD, BX_DOL_PROFILE_ACTIVATE_EDIT);
  108. foreach($aChoices as $sChoice)
  109. $aResult[] = array('key' => $sChoice, 'value' => _t($CNF['T']['option_activation_' . $sChoice]));
  110. return $aResult;
  111. }
  112. public function serviceGetThumb ($iContentId, $sTranscoder = '')
  113. {
  114. $CNF = &$this->_oConfig->CNF;
  115. if(empty($sTranscoder) && !empty($CNF['OBJECT_IMAGES_TRANSCODER_THUMB']))
  116. $sTranscoder = $CNF['OBJECT_IMAGES_TRANSCODER_THUMB'];
  117. $mixedResult = $this->_getFieldValueThumb('FIELD_PICTURE', $iContentId, $sTranscoder);
  118. return $mixedResult !== false ? $mixedResult : '';
  119. }
  120. public function serviceGetSearchResultUnit ($iContentId, $sUnitTemplate = '')
  121. {
  122. if(empty($sUnitTemplate))
  123. $sUnitTemplate = 'unit_with_cover.html';
  124. return parent::serviceGetSearchResultUnit($iContentId, $sUnitTemplate);
  125. }
  126. public function serviceGetSearchableFieldsExtended($aInputsAdd = array())
  127. {
  128. $CNF = &$this->_oConfig->CNF;
  129. $aResult = parent::serviceGetSearchableFieldsExtended($aInputsAdd);
  130. if(!$this->serviceActAsProfile())
  131. return $aResult;
  132. if(!in_array('online', $this->_aSearchableNamesExcept))
  133. $aResult['online'] = array(
  134. 'type' => 'checkbox',
  135. 'caption' => $CNF['T']['form_field_online'],
  136. 'info' => '',
  137. 'value' => '1',
  138. 'values' => '',
  139. 'pass' => ''
  140. );
  141. if(!empty($CNF['FIELD_PICTURE']) && !in_array($CNF['FIELD_PICTURE'], $this->_aSearchableNamesExcept))
  142. $aResult[$CNF['FIELD_PICTURE']] = array(
  143. 'type' => 'checkbox',
  144. 'caption' => $CNF['T']['form_field_picture'],
  145. 'info' => '',
  146. 'value' => '1',
  147. 'values' => '',
  148. 'pass' => '',
  149. 'search_operator' => '>='
  150. );
  151. return $aResult;
  152. }
  153. /**
  154. * @page service Service Calls
  155. * @section bx_base_profile Base Profile
  156. * @subsection bx_base_profile-general General
  157. * @subsubsection bx_base_profile-entity_calendar entity_calendar
  158. *
  159. * @code bx_srv('bx_persons', 'entity_calendar', [...]); @endcode
  160. *
  161. * Get calendar block
  162. * @param $iContentId content ID
  163. *
  164. * @see BxBaseModProfileModule::serviceEntityCalendar
  165. */
  166. /**
  167. * @ref bx_base_profile-entity_calendar "entity_calendar"
  168. */
  169. public function serviceEntityCalendar($iContentId = 0, $sTemplate = 'calendar.html')
  170. {
  171. $iContentId = $this->_getContent($iContentId, false);
  172. $oProfile = BxDolProfile::getInstanceByContentAndType($iContentId, $this->_oConfig->getName());
  173. if($oProfile){
  174. $o = new BxTemplCalendar(array(
  175. 'eventSources' => array (
  176. bx_append_url_params(BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'profile_calendar_data', array('profile_id' => $oProfile->id())),
  177. ),
  178. ), $this->_oTemplate);
  179. return $o->display($sTemplate);
  180. }
  181. return '';
  182. }
  183. public function servicePrivateProfileMsg()
  184. {
  185. $mixedContent = $this->_getContent();
  186. if ($mixedContent) {
  187. list($iContentId, $aContentInfo) = $mixedContent;
  188. return $this->checkAllowedView($aContentInfo);
  189. }
  190. return MsgBox(_t('_sys_access_denied_to_private_content'));
  191. }
  192. public function serviceGetContentInfoById($iContentId)
  193. {
  194. return $this->_oDb->getContentInfoById((int)$iContentId);
  195. }
  196. public function serviceGetMenuAddonManageTools()
  197. {
  198. $CNF = &$this->_oConfig->CNF;
  199. $iNumTotal = $this->_oDb->getEntriesNumByParams();
  200. $iNum1 = $this->_oDb->getEntriesNumByParams([
  201. [
  202. 'key' => 'status',
  203. 'table' => 'sys_profiles',
  204. 'value' => BX_PROFILE_STATUS_PENDING,
  205. 'operator' => '='
  206. ]
  207. ]);
  208. $iNum2 = 0;
  209. if (isset($CNF['OBJECT_REPORTS'])){
  210. $iNum2 = $this->_oDb->getEntriesNumByParams([
  211. [
  212. 'key' => 'reports',
  213. 'value' => '0',
  214. 'operator' => '>'
  215. ]
  216. ]);
  217. }
  218. return array('counter1_value' => $iNum1, 'counter2_value' => $iNum2, 'counter3_value' => $iNumTotal, 'counter1_caption' => _t('_sys_menu_dashboard_manage_tools_addon_counter1_caption_profile_default'));
  219. }
  220. public function serviceGetMenuAddonManageToolsProfileStats()
  221. {
  222. bx_import('SearchResult', $this->_aModule);
  223. $sClass = $this->_aModule['class_prefix'] . 'SearchResult';
  224. $o = new $sClass();
  225. $o->fillFilters(array(
  226. 'account_id' => getLoggedId(),
  227. 'perofileStatus' => ''
  228. ));
  229. $o->unsetPaginate();
  230. return $o->getNum();
  231. }
  232. public function serviceGetMenuAddonFavoritesProfileStats()
  233. {
  234. bx_import('SearchResult', $this->_aModule);
  235. $sClass = $this->_aModule['class_prefix'] . 'SearchResult';
  236. $o = new $sClass('favorite', array('user' => bx_get_logged_profile_id()));
  237. $o->unsetPaginate();
  238. return $o->getNum();
  239. }
  240. public function serviceGetSubmenuObject ()
  241. {
  242. return $this->_oConfig->CNF['OBJECT_MENU_SUBMENU_VIEW_ENTRY'];
  243. }
  244. public function serviceGetMenuSetNameForMenuTrigger ($sMenuTriggerName)
  245. {
  246. $CNF = &$this->_oConfig->CNF;
  247. if (isset($CNF['TRIGGER_MENU_PROFILE_VIEW_SUBMENU']) && $CNF['TRIGGER_MENU_PROFILE_VIEW_SUBMENU'] == $sMenuTriggerName)
  248. return $CNF['OBJECT_MENU_SUBMENU_VIEW_ENTRY'];
  249. elseif (isset($CNF['TRIGGER_MENU_PROFILE_SNIPPET_META']) && $CNF['TRIGGER_MENU_PROFILE_SNIPPET_META'] == $sMenuTriggerName)
  250. return $CNF['OBJECT_MENU_SNIPPET_META'];
  251. else if (isset($CNF['TRIGGER_MENU_PROFILE_VIEW_ACTIONS']) && $CNF['TRIGGER_MENU_PROFILE_VIEW_ACTIONS'] == $sMenuTriggerName) {
  252. if(empty($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY_ALL']))
  253. return $CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY'];
  254. else
  255. return array($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY'], $CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY_ALL']);
  256. }
  257. return '';
  258. }
  259. public function serviceGetSnippetMenuVars($iProfileId, $bPublic = null)
  260. {
  261. return $this->_oTemplate->getSnippetMenuVars($iProfileId, $bPublic);
  262. }
  263. public function serviceGetPageObjectForPageTrigger ($sPageTriggerName)
  264. {
  265. if (isset($this->_oConfig->CNF['TRIGGER_PAGE_VIEW_ENTRY']) && $this->_oConfig->CNF['TRIGGER_PAGE_VIEW_ENTRY'] == $sPageTriggerName)
  266. return $this->_oConfig->CNF['OBJECT_PAGE_VIEW_ENTRY'];
  267. return '';
  268. }
  269. public function serviceProfilesSearch ($sTerm, $iLimit)
  270. {
  271. $aRet = array();
  272. $a = $this->_oDb->searchByTerm($sTerm, $iLimit);
  273. foreach ($a as $r) {
  274. $oProfile = BxDolProfile::getInstance($r['profile_id']);
  275. $aRet[] = array (
  276. 'label' => $this->serviceProfileName($r['content_id']),
  277. 'value' => $r['profile_id'],
  278. 'url' => $oProfile->getUrl(),
  279. 'thumb' => $oProfile->getThumb(),
  280. 'unit' => $oProfile->getUnit(0, ['template' => ['name' => 'unit_wo_info', 'size' => 'icon']])
  281. );
  282. }
  283. return $aRet;
  284. }
  285. /**
  286. * @page service Service Calls
  287. * @section bx_base_profile Base Profile
  288. * @subsection bx_base_profile-general General
  289. * @subsubsection bx_base_profile-profile_unit_safe profile_unit_safe
  290. *
  291. * @code bx_srv('bx_persons', 'profile_unit_safe', [...]); @endcode
  292. *
  293. * Get profile unit
  294. * @param $iContentId content ID
  295. *
  296. * @see BxBaseModProfileModule::serviceProfileUnitSafe
  297. */
  298. /**
  299. * @ref bx_base_profile-profile_unit_safe "profile_unit_safe"
  300. */
  301. public function serviceProfileUnitSafe ($iContentId, $aParams = array())
  302. {
  303. unset($aParams['check_private_content']);
  304. return $this->serviceProfileUnit ($iContentId, $aParams);
  305. }
  306. public function serviceProfileUnit ($iContentId, $aParams = array())
  307. {
  308. $mixedContent = $this->_getContent($iContentId);
  309. if($mixedContent === false)
  310. return false;
  311. list($iContentId, $aContentInfo) = $mixedContent;
  312. $bCheckPrivateContent = isset($aParams['check_private_content']) ? (bool)$aParams['check_private_content'] : true;
  313. $sTemplate = 'unit.html';
  314. $sTemplateSize = false;
  315. $aTemplateVars = array();
  316. if(!empty($aParams['template'])) {
  317. if(is_string($aParams['template']))
  318. $sTemplate = $aParams['template'] . '.html';
  319. else if(is_array($aParams['template'])) {
  320. if(!empty($aParams['template']['name']))
  321. $sTemplate = $aParams['template']['name'] . '.html';
  322. if(!empty($aParams['template']['size']))
  323. $sTemplateSize = $aParams['template']['size'];
  324. if(!empty($aParams['template']['vars']))
  325. $aTemplateVars = $aParams['template']['vars'];
  326. }
  327. }
  328. return $this->_oTemplate->unit($aContentInfo, $bCheckPrivateContent, array($sTemplate, $sTemplateSize, $aTemplateVars));
  329. }
  330. public function serviceHasImage ($iContentId)
  331. {
  332. $CNF = &$this->_oConfig->CNF;
  333. $mixedContent = $this->_getContent($iContentId, 'getContentInfoById');
  334. if($mixedContent === false)
  335. return false;
  336. list($iContentId, $aContentInfo) = $mixedContent;
  337. return !empty($aContentInfo[$CNF['FIELD_PICTURE']]);
  338. }
  339. public function serviceProfilePicture ($iContentId)
  340. {
  341. return $this->_serviceTemplateFunc('urlPicture', $iContentId);
  342. }
  343. public function serviceProfileAvatar ($iContentId)
  344. {
  345. return $this->_serviceTemplateFunc('urlAvatar', $iContentId);
  346. }
  347. public function serviceProfileAvatarBig ($iContentId)
  348. {
  349. return $this->_serviceTemplateFunc('urlAvatarBig', $iContentId);
  350. }
  351. public function serviceProfileCover ($iContentId)
  352. {
  353. return $this->_serviceTemplateFunc('urlCover', $iContentId);
  354. }
  355. public function serviceProfileUnitCover ($iContentId)
  356. {
  357. return $this->_serviceTemplateFunc('urlCoverUnit', $iContentId);
  358. }
  359. public function serviceProfileEditUrl ($iContentId)
  360. {
  361. return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $this->_oConfig->CNF['URI_EDIT_ENTRY'] . '&id=' . $iContentId);
  362. }
  363. public function serviceProfileThumb ($iContentId)
  364. {
  365. return $this->_serviceTemplateFunc('urlThumb', $iContentId);
  366. }
  367. public function serviceProfileIcon ($iContentId)
  368. {
  369. return $this->_serviceTemplateFunc('urlIcon', $iContentId);
  370. }
  371. public function serviceProfileName ($iContentId)
  372. {
  373. if (!$iContentId)
  374. return false;
  375. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  376. if (!$aContentInfo)
  377. return false;
  378. $sDisplayName = $this->getProfileName($aContentInfo);
  379. bx_alert($this->getName(), 'profile_name', $aContentInfo['profile_id'], 0, array('info' => $aContentInfo, 'display_name' => &$sDisplayName));
  380. return $sDisplayName;
  381. }
  382. public function serviceProfileCreateUrl ($bAbsolute = true)
  383. {
  384. $CNF = $this->_oConfig->CNF;
  385. if(empty($CNF['URL_CREATE']))
  386. return false;
  387. return $bAbsolute ? BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink($CNF['URL_CREATE']) : $CNF['URL_CREATE'];
  388. }
  389. /**
  390. * @page service Service Calls
  391. * @section bx_base_profile Base Profile
  392. * @subsection bx_base_profile-general General
  393. * @subsubsection bx_base_profile-profile_url profile_url
  394. *
  395. * @code bx_srv('bx_persons', 'profile_url', [...]); @endcode
  396. *
  397. * Get profile URL
  398. * @param $iContentId content ID
  399. *
  400. * @see BxBaseModProfileModule::serviceProfileUrl
  401. */
  402. /**
  403. * @ref bx_base_profile-profile_url "profile_url"
  404. */
  405. public function serviceProfileUrl ($iContentId)
  406. {
  407. if (!$iContentId)
  408. return false;
  409. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  410. if (!$aContentInfo)
  411. return false;
  412. $CNF = $this->_oConfig->CNF;
  413. return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
  414. }
  415. /**
  416. * @see iBxDolProfileService::serviceGetSpaceTitle
  417. */
  418. public function serviceGetSpaceTitle()
  419. {
  420. return _t('_sys_ps_space_title_friend');
  421. }
  422. /**
  423. * @see iBxDolProfileService::serviceGetParticipatingProfiles
  424. */
  425. public function serviceGetParticipatingProfiles($iProfileId, $aConnectionObjects = false)
  426. {
  427. if (false === $aConnectionObjects)
  428. $aConnectionObjects = array('sys_profiles_friends');
  429. $a = array();
  430. foreach ($aConnectionObjects as $sConnectionObject) {
  431. if (!($o = BxDolConnection::getObjectInstance($sConnectionObject)))
  432. continue;
  433. if (BX_CONNECTIONS_TYPE_MUTUAL == $o->getType())
  434. $a = array_merge($a, $o->getConnectedContentByType($iProfileId, $this->getName(), true));
  435. else
  436. $a = array_merge($a, $o->getConnectedContentByType($iProfileId, $this->getName()));
  437. }
  438. $aRet = array_unique($a);
  439. // the check for an ability to post in profile has been moved to BxDolPrivacy because we need to have an extended check
  440. // with an ability to check for extended roles taking into account the type of content which is going be posted/edited
  441. // so now this service returns just a fans, not filtered by an ability to post into an entry's context
  442. /*foreach ($a as $iConnectedProfileId) {
  443. if (!($oConnectedProfile = BxDolProfile::getInstance($iConnectedProfileId)))
  444. continue;
  445. if (CHECK_ACTION_RESULT_ALLOWED === bx_srv($oConnectedProfile->getModule(), 'check_allowed_post_in_profile', array($oConnectedProfile->getContentId(), $iProfileId)))
  446. $aRet[] = $iConnectedProfileId;
  447. }*/
  448. bx_alert('system', 'get_participating_profiles', $iProfileId, false, array(
  449. 'module' => $this->_oConfig->getName(),
  450. 'profiles' => &$aRet
  451. ));
  452. return $aRet;
  453. }
  454. /**
  455. * Prepare fields from some universal set of fields to fields in particular profile module.
  456. * By default only 'name' and 'description' fields are supported.
  457. * After fields convertion it can be used in @see BxBaseModGeneralModule::serviceEntityAdd
  458. * @param $aFieldsProfile fields in soem universal format.
  459. * @return array which is ready to use for particular module
  460. */
  461. public function servicePrepareFields ($aFieldsProfile)
  462. {
  463. bx_alert($this->getName(), 'prepare_fields', 0, 0, array('fields_orig' => $aFieldsProfile, 'fields_result' => &$aFieldsProfile));
  464. return $aFieldsProfile;
  465. }
  466. protected function _servicePrepareFields ($aFieldsProfile, $aFieldsDefault, $aMap)
  467. {
  468. $aFieldsOrig = $aFieldsProfile;
  469. bx_import('BxDolPrivacy');
  470. $aFieldsDefault2 = array(
  471. 'allow_view_to' => BX_DOL_PG_ALL,
  472. 'allow_contact_to' => BX_DOL_PG_ALL,
  473. 'allow_post_to' => BX_DOL_PG_FRIENDS,
  474. );
  475. $aFieldsProfile = array_merge($aFieldsDefault2, $aFieldsDefault, $aFieldsProfile);
  476. foreach ($aMap as $k => $v) {
  477. if (isset($aFieldsProfile[$v]))
  478. $aFieldsProfile[$k] = $aFieldsProfile[$v];
  479. if ($k != $v && !isset($aMap[$v]))
  480. unset($aFieldsProfile[$v]);
  481. }
  482. bx_alert($this->getName(), 'prepare_fields', 0, 0, array('fields_orig' => $aFieldsOrig, 'fields_result' => &$aFieldsProfile));
  483. return $aFieldsProfile;
  484. }
  485. public function serviceFormsHelper ()
  486. {
  487. return parent::serviceFormsHelper ();
  488. }
  489. /**
  490. * @page service Service Calls
  491. * @section bx_base_profile Base Profile
  492. * @subsection bx_base_profile-forms Forms
  493. * @subsubsection bx_base_profile-entity_create entity_create
  494. *
  495. * @code bx_srv('bx_persons', 'entity_create', [...]); @endcode
  496. *
  497. * Get profile creation form
  498. * @param $sDisplay optional form display name
  499. *
  500. * @see BxBaseModProfileModule::serviceEntityCreate
  501. */
  502. /**
  503. * @ref bx_base_profile-entity_create "entity_create"
  504. */
  505. public function serviceEntityCreate ($sDisplay = false)
  506. {
  507. BxDolInformer::getInstance($this->_oTemplate)->setEnabled(false);
  508. return parent::serviceEntityCreate ($sDisplay);
  509. }
  510. public function serviceActAsProfile ()
  511. {
  512. return true;
  513. }
  514. /**
  515. * @page service Service Calls
  516. * @section bx_base_profile Base Profile
  517. * @subsection bx_base_profile-browse Browse
  518. * @subsubsection bx_base_profile-browse_recommended browse_recommended
  519. *
  520. * @code bx_srv('bx_persons', 'browse_recommended', [...]); @endcode
  521. *
  522. * Browse recommended profiles
  523. * @param $sUnitView optional, unit view, for example - showcase
  524. * @param $bEmptyMessage optional, display or not "empty" message when there is no content
  525. * @param $bAjaxPaginate optional, use AJAX paginate or not
  526. *
  527. * @see BxBaseModProfileModule::serviceBrowseRecommended
  528. */
  529. /**
  530. * @ref bx_base_profile-browse_recommended "browse_recommended"
  531. */
  532. public function serviceBrowseRecommended ($sUnitView = false, $bEmptyMessage = false, $bAjaxPaginate = true)
  533. {
  534. if (!isLogged())
  535. return '';
  536. return $this->_serviceBrowse ('recommended', $sUnitView ? array('unit_view' => $sUnitView) : false, BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  537. }
  538. /**
  539. * @page service Service Calls
  540. * @section bx_base_profile Base Profile
  541. * @subsection bx_base_profile-browse Browse
  542. * @subsubsection bx_base_profile-browse_recent_profiles browse_recent_profiles
  543. *
  544. * @code bx_srv('bx_persons', 'browse_recent_profiles', [...]); @endcode
  545. *
  546. * Browse recently joined profiles
  547. * @param $bEmptyMessage optional, display or not "empty" message when there is no content
  548. * @param $bAjaxPaginate optional, use AJAX paginate or not
  549. *
  550. * @see BxBaseModProfileModule::serviceBrowseRecentProfiles
  551. */
  552. /**
  553. * @ref bx_base_profile-browse_recent_profiles "browse_recent_profiles"
  554. */
  555. public function serviceBrowseRecentProfiles ($bDisplayEmptyMsg = false, $bAjaxPaginate = true)
  556. {
  557. return $this->_serviceBrowse ('recent', false, BX_DB_PADDING_DEF, $bDisplayEmptyMsg, $bAjaxPaginate);
  558. }
  559. /**
  560. * @page service Service Calls
  561. * @section bx_base_profile Base Profile
  562. * @subsection bx_base_profile-browse Browse
  563. * @subsubsection bx_base_profile-browse_active_profiles browse_active_profiles
  564. *
  565. * @code bx_srv('bx_persons', 'browse_active_profiles', [...]); @endcode
  566. *
  567. * Browse recently active profiles
  568. * @param $bEmptyMessage optional, display or not "empty" message when there is no content
  569. * @param $bAjaxPaginate optional, use AJAX paginate or not
  570. *
  571. * @see BxBaseModProfileModule::serviceBrowseActiveProfiles
  572. */
  573. /**
  574. * @ref bx_base_profile-browse_active_profiles "browse_active_profiles"
  575. */
  576. public function serviceBrowseActiveProfiles ($sUnitView = false, $bEmptyMessage = false, $bAjaxPaginate = false)
  577. {
  578. return $this->_serviceBrowse ('active', $sUnitView ? array('unit_view' => $sUnitView) : false, BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  579. }
  580. /**
  581. * @page service Service Calls
  582. * @section bx_base_profile Base Profile
  583. * @subsection bx_base_profile-browse Browse
  584. * @subsubsection bx_base_profile-browse_familiar_profiles browse_familiar_profiles
  585. *
  586. * @code bx_srv('bx_persons', 'browse_familiar_profiles', [...]); @endcode
  587. *
  588. * Browse profiles you might be familiar with. By default using 'Profile Friends' connection.
  589. * @param $bEmptyMessage optional, display or not "empty" message when there is no content
  590. * @param $bAjaxPaginate optional, use AJAX paginate or not
  591. *
  592. * @see BxBaseModProfileModule::serviceBrowseFamiliarProfiles
  593. */
  594. /**
  595. * @ref bx_base_profile-browse_familiar_profiles "browse_familiar_profiles"
  596. */
  597. public function serviceBrowseFamiliarProfiles ($sConnection = '', $sUnitView = false, $bEmptyMessage = false, $bAjaxPaginate = false)
  598. {
  599. $aParams = [
  600. 'object' => 'sys_profiles_friends',
  601. 'profile' => bx_get_logged_profile_id(),
  602. ];
  603. if(!empty($sConnection)) {
  604. if(is_string($sConnection))
  605. $aParams['object'] = $sConnection;
  606. else if(is_array($sConnection))
  607. $aParams = array_merge($aParams, $sConnection);
  608. }
  609. if($sUnitView)
  610. $aParams['unit_view'] = $sUnitView;
  611. return $this->_serviceBrowse ('familiar', $aParams, BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  612. }
  613. /**
  614. * @page service Service Calls
  615. * @section bx_base_profile Base Profile
  616. * @subsection bx_base_profile-browse Browse
  617. * @subsubsection bx_base_profile-browse_top_profiles browse_top_profiles
  618. *
  619. * @code bx_srv('bx_persons', 'browse_top_profiles', [...]); @endcode
  620. *
  621. * Browse top profiles
  622. * @param $bEmptyMessage optional, display or not "empty" message when there is no content
  623. * @param $bAjaxPaginate optional, use AJAX paginate or not
  624. *
  625. * @see BxBaseModProfileModule::serviceBrowseTopProfiles
  626. */
  627. /**
  628. * @ref bx_base_profile-browse_top_profiles "browse_top_profiles"
  629. */
  630. public function serviceBrowseTopProfiles ($bDisplayEmptyMsg = false, $bAjaxPaginate = false)
  631. {
  632. return $this->_serviceBrowse ('top', false, BX_DB_PADDING_DEF, $bDisplayEmptyMsg, $bAjaxPaginate);
  633. }
  634. /**
  635. * @page service Service Calls
  636. * @section bx_base_profile Base Profile
  637. * @subsection bx_base_profile-browse Browse
  638. * @subsubsection bx_base_profile-browse_online_profiles browse_online_profiles
  639. *
  640. * @code bx_srv('bx_persons', 'browse_online_profiles', [...]); @endcode
  641. *
  642. * Browse online profiles
  643. * @param $bEmptyMessage optional, display or not "empty" message when there is no content
  644. * @param $bAjaxPaginate optional, use AJAX paginate or not
  645. *
  646. * @see BxBaseModProfileModule::serviceBrowseOnlineProfiles
  647. */
  648. /**
  649. * @ref bx_base_profile-browse_online_profiles "browse_online_profiles"
  650. */
  651. public function serviceBrowseOnlineProfiles ($bDisplayEmptyMsg = false, $bAjaxPaginate = false)
  652. {
  653. return $this->_serviceBrowse ('online', false, BX_DB_PADDING_DEF, $bDisplayEmptyMsg, $bAjaxPaginate);
  654. }
  655. public function serviceBrowseConnections ($iProfileId, $sObjectConnections = 'sys_profiles_friends', $sConnectionsType = 'content', $iMutual = false, $iDesignBox = BX_DB_PADDING_DEF, $iProfileId2 = 0)
  656. {
  657. return $this->_serviceBrowse (
  658. 'connections',
  659. array(
  660. 'object' => $sObjectConnections,
  661. 'type' => $sConnectionsType,
  662. 'mutual' => $iMutual,
  663. 'profile' => (int)$iProfileId,
  664. 'profile2' => (int)$iProfileId2),
  665. $iDesignBox
  666. );
  667. }
  668. public function serviceBrowseRelationsQuick ($iProfileId, $sObjectConnections = 'sys_profiles_friends', $sConnectionsType = 'content', $iMutual = false, $iProfileId2 = 0)
  669. {
  670. // get connections object
  671. $oConnection = BxDolConnection::getObjectInstance($sObjectConnections);
  672. if (!$oConnection)
  673. return '';
  674. // set some vars
  675. $iStart = (int)bx_get('start');
  676. $iLimit = empty($this->_oConfig->CNF['PARAM_NUM_CONNECTIONS_QUICK']) ? 4 : getParam($this->_oConfig->CNF['PARAM_NUM_CONNECTIONS_QUICK']);
  677. if (!$iLimit)
  678. $iLimit = 4;
  679. // get connections array
  680. bx_import('BxDolConnection');
  681. $aConnections = $oConnection->getConnectionsAsArrayExt($sConnectionsType, $iProfileId, $iProfileId2, $iMutual, $iStart, $iLimit + 1, BX_CONNECTIONS_ORDER_ADDED_DESC);
  682. if(empty($aConnections) || !is_array($aConnections))
  683. return '';
  684. $aResult = array();
  685. foreach($aConnections as $iProfile => $aConnection)
  686. $aResult[] = array(
  687. 'id' => $iProfile,
  688. 'info' => array(
  689. 'addon' => $oConnection->getRelationTranslation($aConnection['relation'])
  690. )
  691. );
  692. return $this->_serviceBrowseQuick($aResult, $iStart, $iLimit);
  693. }
  694. public function serviceBrowseConnectionsQuick ($iProfileId, $sObjectConnections = 'sys_profiles_friends', $sConnectionsType = 'content', $iMutual = false, $iProfileId2 = 0)
  695. {
  696. // get connections object
  697. $oConnection = BxDolConnection::getObjectInstance($sObjectConnections);
  698. if (!$oConnection)
  699. return '';
  700. // set some vars
  701. $iLimit = empty($this->_oConfig->CNF['PARAM_NUM_CONNECTIONS_QUICK']) ? 4 : getParam($this->_oConfig->CNF['PARAM_NUM_CONNECTIONS_QUICK']);
  702. if (!$iLimit)
  703. $iLimit = 4;
  704. $iStart = (int)bx_get('start');
  705. // get connections array
  706. bx_import('BxDolConnection');
  707. $a = $oConnection->getConnectionsAsArray ($sConnectionsType, $iProfileId, $iProfileId2, $iMutual, (int)bx_get('start'), $iLimit + 1, BX_CONNECTIONS_ORDER_ADDED_DESC);
  708. if (!$a)
  709. return '';
  710. return $this->_serviceBrowseQuick($a, $iStart, $iLimit);
  711. }
  712. public function serviceBrowseConnectionsByType ($aParamsCnn, $aParamsBrs = array())
  713. {
  714. $sAll = 'all';
  715. $aParamsCnn['object'] = !empty($aParamsCnn['object']) ? $aParamsCnn['object'] : 'sys_profiles_friends';
  716. $aParamsCnn['type'] = !empty($aParamsCnn['type']) ? $aParamsCnn['type'] : 'content';
  717. $aParamsCnn['profile_id2'] = !empty($aParamsCnn['profile_id2']) ? (int)$aParamsCnn['profile_id2'] : 0;
  718. $aParamsCnn['mutual'] = isset($aParamsCnn['mutual']) ? $aParamsCnn['mutual'] : false;
  719. $oConnection = BxDolConnection::getObjectInstance($aParamsCnn['object']);
  720. if(!$oConnection)
  721. return '';
  722. $aSQLParts = $oConnection->getConnectionsAsSQLParts ($aParamsCnn['type'], 'sys_profiles', 'id', $aParamsCnn['profile_id'], $aParamsCnn['profile_id2'], $aParamsCnn['mutual']);
  723. $sType = !empty($aParamsBrs['type']) ? $aParamsBrs['type'] : $sAll;
  724. if(bx_get('type') !== false)
  725. $sType = bx_process_input(bx_get('type'));
  726. $iStart = (int)bx_get('start');
  727. $iLimitDefault = 4;
  728. $iLimit = !empty($this->_oConfig->CNF['PARAM_NUM_CONNECTIONS_QUICK']) ? getParam($this->_oConfig->CNF['PARAM_NUM_CONNECTIONS_QUICK']) : $iLimitDefault;
  729. if(!empty($aParamsBrs['per_page']))
  730. $iLimit = (int)$aParamsBrs['per_page'];
  731. if(!$iLimit)
  732. $iLimit = $iLimitDefault;
  733. $aProfiles = BxDolProfileQuery::getInstance()->getConnectedProfilesByType($aSQLParts, ($sType != $sAll ? $sType : ''), $iStart, $iLimit + 1);
  734. $mixedMenu = '';
  735. if(!isset($aParamsBrs['filter_menu']) || $aParamsBrs['filter_menu'] === true) {
  736. $aModules = array(
  737. array('name' => $sAll)
  738. );
  739. $aModules = array_merge($aModules, BxDolModuleQuery::getInstance()->getModulesBy(array('type' => 'modules', 'active' => 1)));
  740. $aMenuItems = array();
  741. foreach($aModules as $aModule)
  742. if($aModule['name'] == $sAll || BxDolRequest::serviceExists($aModule['name'], 'act_as_profile'))
  743. $aMenuItems[] = array(
  744. 'id' => $aModule['name'],
  745. 'name' => $aModule['name'],
  746. 'class' => '',
  747. 'link' => 'javascript:void(0)',
  748. 'onclick' => "return !loadDynamicBlockAutoPaginate(this, " . $iStart . ", " . $iLimit . ", " . bx_js_string(json_encode(array('type' => $aModule['name']))) . ");",
  749. 'target' => '_self',
  750. 'title' => _t('_' . $aModule['name']),
  751. 'active' => 1
  752. );
  753. if(!empty($aMenuItems)) {
  754. $mixedMenu = new BxTemplMenu(array('template' => 'menu_vertical.html', 'menu_id'=> $this->_oConfig->getName() . '-connections-by-type', 'menu_items' => $aMenuItems));
  755. $mixedMenu->setSelected('', $sType);
  756. }
  757. }
  758. return array(
  759. 'menu' => $mixedMenu,
  760. 'content' => $this->_serviceBrowseQuick(array_keys($aProfiles), $iStart, $iLimit, array('type' => $sType))
  761. );
  762. }
  763. /**
  764. * @page service Service Calls
  765. * @section bx_base_profile Base Profile
  766. * @subsection bx_base_profile-browse Browse
  767. * @subsubsection bx_base_profile-browse_by_acl browse_by_acl
  768. *
  769. * @code bx_srv('bx_persons', 'browse_by_acl', [...]); @endcode
  770. *
  771. * Browse profiles by membership(ACL) level
  772. * @param $mixedLevelId membership level, or array of membership levels
  773. * @param $iDesignBox optional, design box identifier
  774. *
  775. * @see BxBaseModProfileModule::serviceBrowseByAcl
  776. */
  777. /**
  778. * @ref bx_base_profile-browse_by_acl "browse_by_acl"
  779. */
  780. public function serviceBrowseByAcl ($mixedLevelId, $iDesignBox = BX_DB_PADDING_DEF)
  781. {
  782. return $this->_serviceBrowse (
  783. 'acl',
  784. array(
  785. 'level' => $mixedLevelId,
  786. ),
  787. $iDesignBox,
  788. true
  789. );
  790. }
  791. public function serviceEntityEditCover ($iContentId = 0)
  792. {
  793. return $this->_serviceEntityForm ('editDataForm', $iContentId, $this->_oConfig->CNF['OBJECT_FORM_ENTRY_DISPLAY_EDIT_COVER']);
  794. }
  795. /**
  796. * @page service Service Calls
  797. * @section bx_base_profile Base Profile
  798. * @subsection bx_base_profile-page_blocks Page Blocks
  799. * @subsubsection bx_base_profile-entity_cover entity_cover
  800. *
  801. * @code bx_srv('bx_persons', 'entity_cover', [...]); @endcode
  802. *
  803. * Get cover
  804. * @param $iContentId content ID
  805. *
  806. * @see BxBaseModProfileModule::serviceEntityCover
  807. */
  808. /**
  809. * @ref bx_base_general-entity_cover "entity_cover"
  810. */
  811. public function serviceEntityCover ($iContentId = 0, $aParams = [])
  812. {
  813. $mixedContent = $this->_getContent($iContentId);
  814. if($mixedContent === false)
  815. return false;
  816. list($iContentId, $aContentInfo) = $mixedContent;
  817. return $this->_oTemplate->getBlockCover($aContentInfo, $aParams);
  818. }
  819. /**
  820. * Entry comments
  821. */
  822. public function serviceEntityCommentsByProfile ($iProfileId)
  823. {
  824. $CNF = &$this->_oConfig->CNF;
  825. if(empty($CNF['OBJECT_COMMENTS']))
  826. return '';
  827. $oProfile = BxDolProfile::getInstance($iProfileId);
  828. if(!$oProfile)
  829. return '';
  830. return $this->_entityComments($CNF['OBJECT_COMMENTS'], $oProfile->getContentId());
  831. }
  832. /**
  833. * Entry social sharing block
  834. */
  835. public function serviceEntitySocialSharing ($mixedContent = false, $aParams = array())
  836. {
  837. if(!empty($mixedContent)) {
  838. if(!is_array($mixedContent))
  839. $mixedContent = array((int)$mixedContent, array());
  840. }
  841. else {
  842. $mixedContent = $this->_getContent();
  843. if($mixedContent === false)
  844. return false;
  845. }
  846. list($iContentId, $aContentInfo) = $mixedContent;
  847. return parent::serviceEntitySocialSharing(array($iContentId, $aContentInfo), array(
  848. 'id_thumb' => !empty($CNF['FIELD_PICTURE']) && !empty($aContentInfo[$CNF['FIELD_PICTURE']]) ? $aContentInfo[$CNF['FIELD_PICTURE']] : 0,
  849. ));
  850. }
  851. public function serviceProfileMembership ($iContentId = 0)
  852. {
  853. $mixedContent = $this->_getContent($iContentId);
  854. if($mixedContent === false)
  855. return false;
  856. list($iContentId, $aContentInfo) = $mixedContent;
  857. return BxDolAcl::getInstance()->getProfileMembership($aContentInfo['profile_id']);
  858. }
  859. public function serviceProfileFriends ($iContentId = 0)
  860. {
  861. $mixedContent = $this->_getContent($iContentId);
  862. if($mixedContent === false)
  863. return false;
  864. list($iContentId, $aContentInfo) = $mixedContent;
  865. bx_import('BxDolConnection');
  866. $s = $this->serviceBrowseConnectionsQuick ($aContentInfo['profile_id'], 'sys_profiles_friends', BX_CONNECTIONS_CONTENT_TYPE_CONTENT, true);
  867. if (!$s)
  868. return MsgBox(_t('_sys_txt_empty'));
  869. return $s;
  870. }
  871. public function serviceProfileFriendsMutual ($iContentId = 0)
  872. {
  873. $mixedContent = $this->_getContent($iContentId);
  874. if($mixedContent === false)
  875. return false;
  876. list($iContentId, $aContentInfo) = $mixedContent;
  877. $iViewer = bx_get_logged_profile_id();
  878. $iOwner = (int)$aContentInfo['profile_id'];
  879. if($iViewer == $iOwner)
  880. return false;
  881. bx_import('BxDolConnection');
  882. $s = $this->serviceBrowseConnectionsQuick ($iOwner, 'sys_profiles_friends', BX_CONNECTIONS_CONTENT_TYPE_COMMON, true, $iViewer);
  883. if(!$s)
  884. return MsgBox(_t('_sys_txt_empty'));
  885. return $s;
  886. }
  887. public function serviceProfileSubscriptions ($iContentId = 0, $aParams = array())
  888. {
  889. $mixedContent = $this->_getContent($iContentId);
  890. if($mixedContent === false)
  891. return false;
  892. list($iContentId, $aContentInfo) = $mixedContent;
  893. bx_import('BxDolConnection');
  894. $aResult = $this->serviceBrowseConnectionsByType(array(
  895. 'profile_id' => $aContentInfo['profile_id'],
  896. 'object' => 'sys_profiles_subscriptions',
  897. 'type' => BX_CONNECTIONS_CONTENT_TYPE_CONTENT
  898. ), array(
  899. 'type' => isset($aParams['type']) ? $aParams['type'] : '',
  900. 'filter_menu' => isset($aParams['filter_menu']) ? $aParams['filter_menu'] : true,
  901. ));
  902. if(empty($aResult['content']))
  903. $aResult['content'] = MsgBox(_t('_sys_txt_empty'));
  904. return $aResult;
  905. }
  906. public function serviceProfileSubscribedMe ($iContentId = 0)
  907. {
  908. $mixedContent = $this->_getContent($iContentId);
  909. if($mixedContent === false)
  910. return false;
  911. list($iContentId, $aContentInfo) = $mixedContent;
  912. bx_import('BxDolConnection');
  913. $s = $this->serviceBrowseConnectionsQuick ($aContentInfo['profile_id'], 'sys_profiles_subscriptions', BX_CONNECTIONS_CONTENT_TYPE_INITIATORS);
  914. if (!$s)
  915. return MsgBox(_t('_sys_txt_empty'));
  916. return $s;
  917. }
  918. public function serviceProfileRelations ($iContentId = 0, $aParams = array())
  919. {
  920. $mixedContent = $this->_getContent($iContentId);
  921. if($mixedContent === false)
  922. return false;
  923. list($iContentId, $aContentInfo) = $mixedContent;
  924. bx_import('BxDolConnection');
  925. $s = $this->serviceBrowseRelationsQuick ($aContentInfo['profile_id'], 'sys_profiles_relations', BX_CONNECTIONS_CONTENT_TYPE_CONTENT, 1);
  926. if (!$s)
  927. return MsgBox(_t('_sys_txt_empty'));
  928. return $s;
  929. }
  930. public function serviceProfileRelatedMe ($iContentId = 0)
  931. {
  932. $mixedContent = $this->_getContent($iContentId);
  933. if($mixedContent === false)
  934. return false;
  935. list($iContentId, $aContentInfo) = $mixedContent;
  936. bx_import('BxDolConnection');
  937. $s = $this->serviceBrowseRelationsQuick ($aContentInfo['profile_id'], 'sys_profiles_relations', BX_CONNECTIONS_CONTENT_TYPE_INITIATORS, 1);
  938. if (!$s)
  939. return MsgBox(_t('_sys_txt_empty'));
  940. return $s;
  941. }
  942. /**
  943. * check enabled profile activation letter
  944. */
  945. public function serviceIsEnableProfileActivationLetter()
  946. {
  947. $CNF = &$this->_oConfig->CNF;
  948. return isset($CNF['PARAM_ENABLE_ACTIVATION_LETTER']) ? (bool)getParam($CNF['PARAM_ENABLE_ACTIVATION_LETTER']) : true;
  949. }
  950. public function serviceIsEnableRelations()
  951. {
  952. $sModule = $this->_oConfig->getName();
  953. $oRelations = BxDolConnection::getObjectInstance('sys_profiles_relations');
  954. return $oRelations->isRelationAvailableWithProfile($sModule) || $oRelations->isRelationAvailableFromProfile($sModule);
  955. }
  956. /**
  957. * For internal usage only.
  958. */
  959. public function serviceDeleteEntityService ($iContentId, $bDeleteWithContent = false)
  960. {
  961. return parent::serviceDeleteEntity ($iContentId, 'deleteDataService');
  962. }
  963. /**
  964. * Data for Notifications module
  965. */
  966. public function serviceGetNotificationsData()
  967. {
  968. $a = parent::serviceGetNotificationsData();
  969. $sModule = $this->_aModule['name'];
  970. $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');
  971. $a['settings'][] = array('group' => 'timeline_post', 'unit' => $sModule, 'action' => 'timeline_post_common', 'types' => array('follow_member'));
  972. $a['alerts'][] = array('unit' => $sModule, 'action' => 'timeline_post_common');
  973. return $a;
  974. }
  975. public function serviceGetNotificationsPost($aEvent)
  976. {
  977. $aResult = parent::serviceGetNotificationsVote($aEvent);
  978. if(empty($aResult) || !is_array($aResult) || !$this->serviceActAsProfile())
  979. return $aResult;
  980. $oProfile = BxDolProfile::getInstanceByContentAndType((int)$aEvent['object_id'], $this->_oConfig->getName());
  981. if($oProfile !== false)
  982. $aResult['entry_author'] = $oProfile->id();
  983. return $aResult;
  984. }
  985. public function serviceGetNotificationsVote($aEvent)
  986. {
  987. $aResult = parent::serviceGetNotificationsVote($aEvent);
  988. if(empty($aResult) || !is_array($aResult) || !$this->serviceActAsProfile())
  989. return $aResult;
  990. $oProfile = BxDolProfile::getInstanceByContentAndType((int)$aEvent['object_id'], $this->_oConfig->getName());
  991. if($oProfile !== false)
  992. $aResult['entry_author'] = $oProfile->id();
  993. return $aResult;
  994. }
  995. /**
  996. * Notification about new member requst in the group
  997. */
  998. public function serviceGetNotificationsTimelinePostCommon($aEvent)
  999. {
  1000. $CNF = &$this->_oConfig->CNF;
  1001. $iContentId = (int)$aEvent['object_id'];
  1002. $oGroupProfile = BxDolProfile::getInstanceByContentAndType((int)$iContentId, $this->getName());
  1003. if(!$oGroupProfile)
  1004. return array();
  1005. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  1006. if(empty($aContentInfo) || !is_array($aContentInfo))
  1007. return array();
  1008. $aSubcontentInfo = BxDolService::call('bx_timeline', 'get_info', array((int)$aEvent['subobject_id'], false));
  1009. if(empty($aSubcontentInfo) || !is_array($aSubcontentInfo))
  1010. return array();
  1011. $sSubentryUrl = BxDolService::call('bx_timeline', 'get_link', array((int)$aEvent['subobject_id']));
  1012. $sSubentrySample = $aSubcontentInfo['title'];
  1013. if(empty($sSubentrySample))
  1014. $sSubentrySample = strmaxtextlen($aSubcontentInfo['description'], 20, '...');
  1015. return array(
  1016. 'entry_sample' => $CNF['T']['txt_sample_single'],
  1017. 'entry_url' => $oGroupProfile->getUrl(),
  1018. 'entry_caption' => $oGroupProfile->getDisplayName(),
  1019. 'entry_author' => $oGroupProfile->id(),
  1020. 'subentry_sample' => $sSubentrySample,
  1021. 'subentry_url' => $sSubentryUrl,
  1022. 'lang_key' => $CNF['T']['txt_ntfs_timeline_post_common'],
  1023. );
  1024. }
  1025. /**
  1026. * Data for Timeline module
  1027. */
  1028. public function serviceGetTimelineData()
  1029. {
  1030. $CNF = &$this->_oConfig->CNF;
  1031. $sModule = $this->_aModule['name'];
  1032. $aAlerts = array();
  1033. $aHandlers = array();
  1034. if(!empty($CNF['FIELD_PICTURE'])) {
  1035. $aAlerts = array_merge($aAlerts, array(
  1036. array('unit' => $sModule, 'action' => 'profile_picture_changed'),
  1037. array('unit' => $sModule, 'action' => 'profile_picture_deleted')
  1038. ));
  1039. $aHandlers = array_merge($aHandlers, array(
  1040. 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' => ''),
  1041. array('group' => $sModule . '_profile_picture', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'profile_picture_deleted')
  1042. ));
  1043. }
  1044. if(!empty($CNF['FIELD_COVER'])) {
  1045. $aAlerts = array_merge($aAlerts, array(
  1046. array('unit' => $sModule, 'action' => 'profile_cover_changed'),
  1047. array('unit' => $sModule, 'action' => 'profile_cover_deleted')
  1048. ));
  1049. $aHandlers = array_merge($aHandlers, array(
  1050. 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' => ''),
  1051. array('group' => $sModule . '_profile_cover', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'profile_cover_deleted')
  1052. ));
  1053. }
  1054. $aResult = array();
  1055. if(!empty($aAlerts) && !empty($aHandlers))
  1056. $aResult = array(
  1057. 'handlers' => $aHandlers,
  1058. 'alerts' => $aAlerts
  1059. );
  1060. return $aResult;
  1061. }
  1062. /**
  1063. * Entry post for Timeline module
  1064. */
  1065. public function serviceGetTimelineProfilePicture($aEvent, $aBrowseParams = [])
  1066. {
  1067. $aResult = $this->_serviceGetTimelineProfileImage($aEvent, $aBrowseParams, [
  1068. 'stg' => 'OBJECT_STORAGE',
  1069. 'trans' => ['OBJECT_IMAGES_TRANSCODER_GALLERY', 'OBJECT_IMAGES_TRANSCODER_AVATAR'],
  1070. 'trans_orig' => ['OBJECT_IMAGES_TRANSCODER_PICTURE', 'OBJECT_IMAGES_TRANSCODER_GALLERY'],
  1071. 'txt_ss' => 'txt_sample_pp_single',
  1072. 'txt_sswa' => 'txt_sample_pp_single_with_article',
  1073. 'txt_sa' => 'txt_sample_pi_action',
  1074. 'txt_sau' => 'txt_sample_pi_action_user'
  1075. ]);
  1076. if($aResult !== false)
  1077. $aResult['allowed_view'] = ['module' => $this->_oConfig->getName(), 'method' => 'get_timeline_profile_picture_allowed_view'];
  1078. return $aResult;
  1079. }
  1080. public function serviceGetTimelineProfilePictureAllowedView($aEvent)
  1081. {
  1082. return $this->_serviceGetTimelineProfileImageAllowedView($aEvent);
  1083. }
  1084. public function serviceGetTimelineProfileCover($aEvent, $aBrowseParams = [])
  1085. {
  1086. $aResult = $this->_serviceGetTimelineProfileImage($aEvent, $aBrowseParams, [
  1087. 'stg' => 'OBJECT_STORAGE_COVER',
  1088. 'trans' => ['OBJECT_IMAGES_TRANSCODER_GALLERY', 'OBJECT_IMAGES_TRANSCODER_COVER_THUMB'],
  1089. 'trans_orig' => ['OBJECT_IMAGES_TRANSCODER_COVER', 'OBJECT_IMAGES_TRANSCODER_GALLERY'],
  1090. 'txt_ss' => 'txt_sample_pc_single',
  1091. 'txt_sswa' => 'txt_sample_pc_single_with_article',
  1092. 'txt_sa' => 'txt_sample_pi_action',
  1093. 'txt_sau' => 'txt_sample_pi_action_user'
  1094. ]);
  1095. if($aResult !== false)
  1096. $aResult['allowed_view'] = ['module' => $this->_oConfig->getName(), 'method' => 'get_timeline_profile_cover_allowed_view'];
  1097. return $aResult;
  1098. }
  1099. public function serviceGetTimelineProfileCoverAllowedView($aEvent)
  1100. {
  1101. return $this->_serviceGetTimelineProfileImageAllowedView($aEvent);
  1102. }
  1103. public function serviceGetConnectionButtonsTitles($iProfileId, $sConnectionsObject = 'sys_profiles_friends')
  1104. {
  1105. if (!isLogged())
  1106. return array();
  1107. if (!($oConn = BxDolConnection::getObjectInstance($sConnectionsObject)))
  1108. return array();
  1109. $CNF = $this->_oConfig->CNF;
  1110. if ($oConn->isConnectedNotMutual(bx_get_logged_profile_id(), $iProfileId)) {
  1111. return array(
  1112. 'add' => _t($CNF['T']['menu_item_title_befriend_sent']),
  1113. 'remove' => _t($CNF['T']['menu_item_title_unfriend_cancel_request']),
  1114. );
  1115. } elseif ($oConn->isConnectedNotMutual($iProfileId, bx_get_logged_profile_id())) {
  1116. return array(
  1117. 'add' => _t($CNF['T']['menu_item_title_befriend_confirm']),
  1118. 'remove' => _t($CNF['T']['menu_item_title_unfriend_reject_request']),
  1119. );
  1120. } elseif ($oConn->isConnected($iProfileId, bx_get_logged_profile_id(), true)) {
  1121. return array(
  1122. 'add' => '',
  1123. 'remove' => _t($CNF['T']['menu_item_title_unfriend']),
  1124. );
  1125. } else {
  1126. return array(
  1127. 'add' => _t($CNF['T']['menu_item_title_befriend']),
  1128. 'remove' => '',
  1129. );
  1130. }
  1131. }
  1132. // ====== PERMISSION METHODS
  1133. /**
  1134. * @see iBxDolProfileService::serviceCheckAllowedProfileView
  1135. */
  1136. public function serviceCheckAllowedProfileView($iContentId)
  1137. {
  1138. return $this->serviceCheckAllowedWithContent('View', $iContentId);
  1139. }
  1140. /**
  1141. * @see iBxDolProfileService::serviceCheckAllowedProfileContact
  1142. */
  1143. public function serviceCheckAllowedProfileContact($iContentId)
  1144. {
  1145. return $this->serviceCheckAllowedWithContent('Contact', $iContentId);
  1146. }
  1147. /**
  1148. * @see iBxDolProfileService::serviceCheckAllowedPostInProfile
  1149. */
  1150. public function serviceCheckAllowedPostInProfile($iContentId, $sPostModule = '')
  1151. {
  1152. // for groups based profiles we do have a Role permissions which have a higher priority than the site-wide permissions.
  1153. if (method_exists($this, 'isAllowedModuleActionByProfile')) {
  1154. $bResult = $this->isAllowedModuleActionByProfile($iContentId, $sPostModule, 'post');
  1155. // if a profile is having a role and a role is having permissions set then it overrides the site-wide setting.
  1156. if ($bResult !== NULL) return $bResult;
  1157. }
  1158. return $this->serviceCheckAllowedWithContent('Post', $iContentId);
  1159. }
  1160. /**
  1161. * @see iBxDolProfileService::serviceCheckAllowedModuleActionInProfile
  1162. */
  1163. public function serviceCheckAllowedModuleActionInProfile($iContentId, $sPostModule, $sActionName)
  1164. {
  1165. if (method_exists($this, 'isAllowedModuleActionByProfile')) {
  1166. $bResult = $this->isAllowedModuleActionByProfile($iContentId, $sPostModule, $sActionName);
  1167. if ($bResult !== NULL) return $bResult;
  1168. }
  1169. return _t('_Access denied');
  1170. }
  1171. /**
  1172. * @see iBxDolProfileService::serviceCheckSpacePrivacy
  1173. */
  1174. public function serviceCheckSpacePrivacy($iContentId)
  1175. {
  1176. return $this->serviceCheckAllowedProfileView($iContentId);
  1177. }
  1178. /**
  1179. * Check if the profile can be viewed.
  1180. *
  1181. * NOTE. This service should be used if it's needed to pass some specific values in
  1182. * $isPerformAction and $iProfileId parameters, otherwise it's recommended to use
  1183. * BxBaseModProfileModule::serviceCheckAllowedProfileView service method or
  1184. * BxDolProfile::checkAllowedProfileView method.
  1185. *
  1186. * @param type $aDataEntry - entry which the action will be performed for
  1187. * @param type $isPerformAction - perform or just check the action
  1188. * @param type $iProfileId - performer's profile ID
  1189. * @return integer - one of CHECK_ACTION_RESULT_XXX constants.
  1190. */
  1191. public function serviceCheckAllowedViewForProfile ($aDataEntry, $isPerformAction = false, $iProfileId = false)
  1192. {
  1193. if (!$iProfileId)
  1194. $iProfileId = $this->_iProfileId;
  1195. if(empty($aDataEntry) || !is_array($aDataEntry))
  1196. return _t('_sys_txt_not_found');
  1197. $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$this->_oConfig->CNF['FIELD_ID']], $this->getName());
  1198. if ($oProfile && $oProfile->id() == $iProfileId)
  1199. return CHECK_ACTION_RESULT_ALLOWED;
  1200. return parent::serviceCheckAllowedViewForProfile ($aDataEntry, $isPerformAction, $iProfileId);
  1201. }
  1202. /**
  1203. * Check if posting (comment, post in Timeline) is available.
  1204. *
  1205. * NOTE. This service should be used if it's needed to pass some specific values in
  1206. * $isPerformAction and $iProfileId parameters, otherwise it's recommended to use
  1207. * BxBaseModProfileModule::serviceCheckAllowedPostInProfile service method or
  1208. * BxDolProfile::checkAllowedPostInProfile method.
  1209. *
  1210. * @param type $aDataEntry - entry which the action will be performed for
  1211. * @param type $isPerformAction - perform or just check the action
  1212. * @param type $iProfileId - performer's profile ID
  1213. * @return integer - one of CHECK_ACTION_RESULT_XXX constants.
  1214. */
  1215. public function serviceCheckAllowedPostForProfile ($aDataEntry, $isPerformAction = false, $iProfileId = false)
  1216. {
  1217. $CNF = &$this->_oConfig->CNF;
  1218. if(!$iProfileId)
  1219. $iProfileId = $this->_iProfileId;
  1220. // check is view allowed
  1221. if(($mixedResult = $this->serviceCheckAllowedViewForProfile($aDataEntry, $isPerformAction, $iProfileId)) !== CHECK_ACTION_RESULT_ALLOWED)
  1222. return $mixedResult;
  1223. // moderator and owner always have access
  1224. $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$CNF['FIELD_ID']], $this->getName());
  1225. if(($oProfile && $oProfile->id() == $iProfileId) || $this->_isModerator($isPerformAction))
  1226. return CHECK_ACTION_RESULT_ALLOWED;
  1227. // check privacy
  1228. if(!empty($CNF['OBJECT_PRIVACY_POST'])) {
  1229. $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_POST']);
  1230. if($oPrivacy && !$oPrivacy->check($aDataEntry[$CNF['FIELD_ID']], $iProfileId))
  1231. return _t('_sys_access_denied_to_private_content');
  1232. }
  1233. // check alert to allow custom checks
  1234. $mixedResult = null;
  1235. bx_alert('system', 'check_allowed_post', 0, 0, array('module' => $this->getName(), 'content_info' => $aDataEntry, 'profile_id' => $iProfileId, 'override_result' => &$mixedResult));
  1236. if($mixedResult !== null)
  1237. return $mixedResult;
  1238. return CHECK_ACTION_RESULT_ALLOWED;
  1239. }
  1240. /**
  1241. * Check if profile can be contacted.
  1242. *
  1243. * NOTE. This service should be used if it's needed to pass some specific values in
  1244. * $isPerformAction and $iProfileId parameters, otherwise it's recommended to use
  1245. * BxBaseModProfileModule::serviceCheckAllowedProfileContact service method or
  1246. * BxDolProfile::checkAllowedProfileContact method.
  1247. *
  1248. * @param type $aDataEntry - entry which the action will be performed for
  1249. * @param type $isPerformAction - perform or just check the action
  1250. * @param type $iProfileId - performer's profile ID
  1251. * @return integer - one of CHECK_ACTION_RESULT_XXX constants.
  1252. */
  1253. public function serviceCheckAllowedContactForProfile ($aDataEntry, $isPerformAction = false, $iProfileId = false)
  1254. {
  1255. $mixedResult = $this->_serviceCheckAllowedContactForProfile($aDataEntry, $isPerformAction, $iProfileId);
  1256. // call alert to allow custom checks
  1257. bx_alert('system', 'check_allowed_contact', 0, 0, array(
  1258. 'module' => $this->getName(),
  1259. 'content_info' => $aDataEntry,
  1260. 'profile_id' => $iProfileId,
  1261. 'override_result' => &$mixedResult
  1262. ));
  1263. return $mixedResult;
  1264. }
  1265. public function serviceSetViewProfileCover($oPage, $aProfileInfo)
  1266. {
  1267. $this->_oTemplate->setCover($oPage,$aProfileInfo);
  1268. }
  1269. /**
  1270. * Returns list of members by mode with limited number of records for React Jot
  1271. * @param string $sMode
  1272. * @param int $iStart
  1273. * @param int $iPerPage
  1274. * @return mixed
  1275. */
  1276. public function serviceGetMembers($sMode = 'active', $iStart = 0, $iPerPage = 10){
  1277. bx_import('SearchResult', $this->_aModule);
  1278. $sClass = $this->_aModule['class_prefix'] . 'SearchResult';
  1279. $o = new $sClass($sMode);
  1280. $o -> aCurrent['paginate'] = array('perPage' => $iPerPage, 'forceStart' => $iStart);
  1281. return $o -> getSearchData();
  1282. }
  1283. /**
  1284. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
  1285. */
  1286. public function checkAllowedAdd ($isPerformAction = false)
  1287. {
  1288. $oAccount = BxDolAccount::getInstance();
  1289. if (!$oAccount || ($this->serviceActAsProfile() && $oAccount->isProfilesLimitReached()))
  1290. return _t('_sys_txt_access_denied');
  1291. return parent::checkAllowedAdd ($isPerformAction);
  1292. }
  1293. /**
  1294. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
  1295. */
  1296. public function checkAllowedView ($aDataEntry, $isPerformAction = false)
  1297. {
  1298. return $this->serviceCheckAllowedViewForProfile ($aDataEntry, $isPerformAction);
  1299. }
  1300. /**
  1301. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  1302. */
  1303. public function checkAllowedViewProfileImage ($aDataEntry, $isPerformAction = false)
  1304. {
  1305. $CNF = &$this->_oConfig->CNF;
  1306. // check privacy
  1307. if (empty($CNF['OBJECT_PRIVACY_VIEW']))
  1308. return CHECK_ACTION_RESULT_ALLOWED;
  1309. $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']);
  1310. if ($oPrivacy && !$oPrivacy->check($aDataEntry[$CNF['FIELD_ID']]) && !$oPrivacy->isPartiallyVisible($aDataEntry[$CNF['FIELD_ALLOW_VIEW_TO']]))
  1311. return _t('_sys_access_denied_to_private_content');
  1312. return CHECK_ACTION_RESULT_ALLOWED;
  1313. }
  1314. /**
  1315. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  1316. */
  1317. public function checkAllowedViewCoverImage ($aDataEntry, $isPerformAction = false)
  1318. {
  1319. return $this->checkAllowedViewProfileImage($aDataEntry);
  1320. }
  1321. /**
  1322. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  1323. */
  1324. public function checkAllowedPost ($aDataEntry, $isPerformAction = false)
  1325. {
  1326. return $this->serviceCheckAllowedPostForProfile ($aDataEntry, $isPerformAction);
  1327. }
  1328. /**
  1329. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  1330. */
  1331. public function checkAllowedContact ($aDataEntry, $isPerformAction = false)
  1332. {
  1333. return $this->serviceCheckAllowedContactForProfile ($aDataEntry, $isPerformAction);
  1334. }
  1335. /**
  1336. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  1337. */
  1338. public function checkAllowedEdit ($aDataEntry, $isPerformAction = false)
  1339. {
  1340. if(empty($aDataEntry) || !is_array($aDataEntry))
  1341. return _t('_sys_txt_not_found');
  1342. // moderator always has access
  1343. if ($this->_isModerator($isPerformAction))
  1344. return CHECK_ACTION_RESULT_ALLOWED;
  1345. // owner (checked by account instead of author!) always have access
  1346. $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$this->_oConfig->CNF['FIELD_ID']], $this->_aModule['name']);
  1347. if (!$oProfile)
  1348. return _t('_sys_txt_error_occured');
  1349. if ($oProfile->id() == $this->_iProfileId || $oProfile->getAccountId() == $this->_iAccountId)
  1350. return CHECK_ACTION_RESULT_ALLOWED;
  1351. return _t('_sys_txt_access_denied');
  1352. }
  1353. /**
  1354. * Check if user can change cover image
  1355. */
  1356. public function checkAllowedChangeCover ($aDataEntry, $isPerformAction = false)
  1357. {
  1358. // moderator always has access
  1359. if ($this->_isModerator($isPerformAction))
  1360. return CHECK_ACTION_RESULT_ALLOWED;
  1361. // owner (checked by account instead of author!) always have access
  1362. $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$this->_oConfig->CNF['FIELD_ID']], $this->_aModule['name']);
  1363. if (!$oProfile)
  1364. return _t('_sys_txt_error_occured');
  1365. if ($oProfile->id() == $this->_iProfileId || $oProfile->getAccountId() == $this->_iAccountId)
  1366. return CHECK_ACTION_RESULT_ALLOWED;
  1367. return _t('_sys_txt_access_denied');
  1368. }
  1369. /**
  1370. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  1371. */
  1372. public function checkAllowedDelete (&$aDataEntry, $isPerformAction = false)
  1373. {
  1374. // moderator always has access
  1375. if ($this->_isModerator($isPerformAction))
  1376. return CHECK_ACTION_RESULT_ALLOWED;
  1377. // owner (checked by account instead of author!) always have access
  1378. $aCheck = checkActionModule($this->_iProfileId, 'delete entry', $this->getName(), $isPerformAction);
  1379. $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$this->_oConfig->CNF['FIELD_ID']], $this->_aModule['name'], $isPerformAction);
  1380. if (!$oProfile)
  1381. return _t('_sys_txt_error_occured');
  1382. if (($oProfile->id() == $this->_iProfileId || $oProfile->getAccountId() == $this->_iAccountId) && $aCheck[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
  1383. return CHECK_ACTION_RESULT_ALLOWED;
  1384. return _t('_sys_txt_access_denied');
  1385. }
  1386. /**
  1387. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  1388. */
  1389. public function checkAllowedViewMoreMenu (&$aDataEntry, $isPerformAction = false)
  1390. {
  1391. $oMenu = BxTemplMenu::getObjectInstance($this->_oConfig->CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY_MORE']);
  1392. if (!$oMenu || !$oMenu->getCode())
  1393. return _t('_sys_txt_access_denied');
  1394. return CHECK_ACTION_RESULT_ALLOWED;
  1395. }
  1396. /**
  1397. * Compose differs from Contact. For example, a user should NOT be able to start conversation (compose)
  1398. * with himself but he should be able to view conversation page where he is one of the participants.
  1399. *
  1400. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  1401. */
  1402. public function checkAllowedCompose(&$aDataEntry, $isPerformAction = false)
  1403. {
  1404. $CNF = &$this->_oConfig->CNF;
  1405. $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$CNF['FIELD_ID']], $this->getName());
  1406. if($oProfile && $oProfile->id() == $this->_iProfileId)
  1407. return _t('_sys_txt_access_denied');
  1408. return $this->checkAllowedContact($aDataEntry, $isPerformAction);
  1409. }
  1410. /**
  1411. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  1412. */
  1413. public function checkAllowedFriendAdd (&$aDataEntry, $isPerformAction = false)
  1414. {
  1415. return $this->_checkAllowedConnect ($aDataEntry, $isPerformAction, 'sys_profiles_friends', true, false);
  1416. }
  1417. /**
  1418. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  1419. */
  1420. public function checkAllowedFriendRemove (&$aDataEntry, $isPerformAction = false)
  1421. {
  1422. if (CHECK_ACTION_RESULT_ALLOWED === $this->_checkAllowedConnect ($aDataEntry, $isPerformAction, 'sys_profiles_friends', false, true, true))
  1423. return CHECK_ACTION_RESULT_ALLOWED;
  1424. return $this->_checkAllowedConnect ($aDataEntry, $isPerformAction, 'sys_profiles_friends', false, true, false);
  1425. }
  1426. /**
  1427. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  1428. */
  1429. public function checkAllowedRelationAdd (&$aDataEntry, $isPerformAction = false)
  1430. {
  1431. if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->checkAllowedView($aDataEntry)))
  1432. return $sMsg;
  1433. return $this->_checkAllowedConnect ($aDataEntry, $isPerformAction, 'sys_profiles_relations', false, false);
  1434. }
  1435. /**
  1436. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  1437. */
  1438. public function checkAllowedRelationRemove (&$aDataEntry, $isPerformAction = false)
  1439. {
  1440. return $this->_checkAllowedConnect ($aDataEntry, $isPerformAction, 'sys_profiles_relations', false, true);
  1441. }
  1442. public function checkAllowedRelationsView (&$aDataEntry, $isPerformAction = false)
  1443. {
  1444. $sResult = _t('_sys_txt_access_denied');
  1445. $sModule = $this->_oConfig->getName();
  1446. $oRelations = BxDolConnection::getObjectInstance('sys_profiles_relations');
  1447. if(!$oRelations->isRelationAvailableWithProfile($sModule) && !$oRelations->isRelationAvailableFromProfile($sModule))
  1448. return $sResult;
  1449. if(empty($aDataEntry) || !is_array($aDataEntry))
  1450. return $sResult;
  1451. return CHECK_ACTION_RESULT_ALLOWED;
  1452. }
  1453. /**
  1454. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  1455. */
  1456. public function checkAllowedSubscribeAdd(&$aDataEntry, $isPerformAction = false)
  1457. {
  1458. $mixedResult = $this->_modProfileCheckAllowedSubscribeAdd($aDataEntry, $isPerformAction);
  1459. // call alert to allow custom checks
  1460. bx_alert('system', 'check_allowed_subscribe_add', 0, 0, array(
  1461. 'module' => $this->getName(),
  1462. 'content_info' => $aDataEntry,
  1463. 'profile_id' => bx_get_logged_profile_id(),
  1464. 'override_result' => &$mixedResult
  1465. ));
  1466. return $mixedResult;
  1467. }
  1468. /**
  1469. * Note. Is mainly needed for internal usage. Access level is 'public' to allow outer calls from alerts.
  1470. */
  1471. public function _modProfileCheckAllowedSubscribeAdd(&$aDataEntry, $isPerformAction = false)
  1472. {
  1473. if(($sMsg = $this->checkAllowedView($aDataEntry)) !== CHECK_ACTION_RESULT_ALLOWED)
  1474. return $sMsg;
  1475. return $this->_checkAllowedConnect($aDataEntry, $isPerformAction, 'sys_profiles_subscriptions', false, false);
  1476. }
  1477. /**
  1478. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  1479. */
  1480. public function checkAllowedSubscribeRemove (&$aDataEntry, $isPerformAction = false)
  1481. {
  1482. return $this->_checkAllowedConnect ($aDataEntry, $isPerformAction, 'sys_profiles_subscriptions', false, true);
  1483. }
  1484. public function checkAllowedSubscriptionsView (&$aDataEntry, $isPerformAction = false)
  1485. {
  1486. $CNF = &$this->_oConfig->CNF;
  1487. $sResult = _t('_sys_txt_access_denied');
  1488. if(empty($aDataEntry) || !is_array($aDataEntry))
  1489. return $sResult;
  1490. $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$CNF['FIELD_ID']], $this->_aModule['name']);
  1491. if(!$oProfile || ($oProfile->id() != $this->_iProfileId && $this->_oDb->getParam($CNF['PARAM_PUBLIC_SBSN']) != 'on' && $this->_oDb->getParam($CNF['PARAM_PUBLIC_SBSD']) != 'on'))
  1492. return $sResult;
  1493. return CHECK_ACTION_RESULT_ALLOWED;
  1494. }
  1495. public function checkMyself($iContentId)
  1496. {
  1497. $iLogged = (int)bx_get_logged_profile_id();
  1498. if(empty($iLogged))
  1499. return false;
  1500. $oProfile = BxDolProfile::getInstanceByContentAndType((int)$iContentId, $this->_oConfig->getName());
  1501. if(!$oProfile)
  1502. return false;
  1503. return $oProfile->id() == $iLogged;
  1504. }
  1505. public function isAllowDeleteOrDisable($iActorProfileId, $iTargetProfileId)
  1506. {
  1507. if (BxDolAcl::getInstance()->isMemberLevelInSet(array(MEMBERSHIP_ID_MODERATOR), $iActorProfileId) && BxDolAcl::getInstance()->isMemberLevelInSet(array(MEMBERSHIP_ID_MODERATOR, MEMBERSHIP_ID_ADMINISTRATOR), $iTargetProfileId))
  1508. return false;
  1509. return true;
  1510. }
  1511. public function getProfileObject($iContentId)
  1512. {
  1513. $oProfile = BxDolProfile::getInstanceByContentAndType((int)$iContentId, $this->_oConfig->getName());
  1514. if (!$oProfile)
  1515. $oProfile = BxDolProfileUndefined::getInstance();
  1516. return $oProfile;
  1517. }
  1518. protected function _serviceCheckAllowedContactForProfile($aDataEntry, $isPerformAction = false, $iProfileId = false)
  1519. {
  1520. $CNF = &$this->_oConfig->CNF;
  1521. if(!$iProfileId)
  1522. $iProfileId = $this->_iProfileId;
  1523. /*
  1524. * allow to 'contact myself'. It's needed to allow a user to view conversation page
  1525. * where he is one of the participants.
  1526. */
  1527. $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$CNF['FIELD_ID']], $this->getName());
  1528. if($oProfile && $oProfile->id() == $iProfileId)
  1529. return CHECK_ACTION_RESULT_ALLOWED;
  1530. // moderator always has access
  1531. if($this->_isModeratorForProfile($isPerformAction, $iProfileId))
  1532. return CHECK_ACTION_RESULT_ALLOWED;
  1533. // check privacy
  1534. if(!empty($CNF['OBJECT_PRIVACY_CONTACT'])) {
  1535. $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_CONTACT']);
  1536. if($oPrivacy && !$oPrivacy->check($aDataEntry[$CNF['FIELD_ID']], $iProfileId))
  1537. return _t('_sys_access_denied_to_private_content');
  1538. }
  1539. return CHECK_ACTION_RESULT_ALLOWED;
  1540. }
  1541. // ====== COMMON METHODS
  1542. protected function _alertParams($aContentInfo)
  1543. {
  1544. $aParams = parent::_alertParams($aContentInfo);
  1545. $CNF = &$this->_oConfig->CNF;
  1546. if(!empty($CNF['FIELD_ALLOW_VIEW_TO']) && isset($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]))
  1547. $aParams['privacy_view'] = $aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']];
  1548. return $aParams;
  1549. }
  1550. public function alertAfterAdd($aContentInfo)
  1551. {
  1552. $CNF = &$this->_oConfig->CNF;
  1553. $iContentId = (int)$aContentInfo[$CNF['FIELD_ID']];
  1554. $aParams = $this->_alertParams($aContentInfo);
  1555. bx_alert($this->getName(), 'added', $iContentId, false, $aParams);
  1556. }
  1557. public function alertAfterEdit($aContentInfo)
  1558. {
  1559. $CNF = &$this->_oConfig->CNF;
  1560. $sModule = $this->getName();
  1561. $iContentId = (int)$aContentInfo[$CNF['FIELD_ID']];
  1562. $aParams = $this->_alertParams($aContentInfo);
  1563. bx_alert($sModule, 'edited', $iContentId, false, $aParams);
  1564. $oProfile = BxDolProfile::getInstanceByContentAndType($iContentId, $sModule);
  1565. bx_alert('profile', 'edit', $oProfile->id(), 0, array('content' => $iContentId, 'module' => $sModule));
  1566. }
  1567. public function getProfileByCurrentUrl ()
  1568. {
  1569. $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
  1570. if ($iProfileId)
  1571. return BxDolProfile::getInstance($iProfileId);
  1572. $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  1573. if ($iContentId)
  1574. return BxDolProfile::getInstanceByContentAndType($iContentId, $this->getName());
  1575. return false;
  1576. }
  1577. public function getEntryImageData($aContentInfo, $sField = 'FIELD_PICTURE', $aTranscoders = array())
  1578. {
  1579. return parent::getEntryImageData($aContentInfo, $sField, $aTranscoders);
  1580. }
  1581. public function getProfileName ($aContentInfo)
  1582. {
  1583. return bx_process_output($aContentInfo[$this->_oConfig->CNF['FIELD_NAME']]);
  1584. }
  1585. // ====== PROTECTED METHODS
  1586. protected function _checkAllowedConnect (&$aDataEntry, $isPerformAction, $sObjConnection, $isMutual, $isInvertResult, $isSwap = false)
  1587. {
  1588. if (!$this->_iProfileId)
  1589. return _t('_sys_txt_access_denied');
  1590. $CNF = &$this->_oConfig->CNF;
  1591. $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$CNF['FIELD_ID']], $this->_aModule['name']);
  1592. if (!$oProfile || $oProfile->id() == $this->_iProfileId)
  1593. return _t('_sys_txt_access_denied');
  1594. return BxDolConnection::getObjectInstance($sObjConnection)->checkAllowedConnect ($this->_iProfileId, $oProfile->id(), $isPerformAction, $isMutual, $isInvertResult, $isSwap);
  1595. }
  1596. protected function _buildRssParams($sMode, $aArgs)
  1597. {
  1598. $aParams = array ();
  1599. $sMode = bx_process_input($sMode);
  1600. switch ($sMode) {
  1601. case 'connections':
  1602. $aParams = array(
  1603. 'object' => isset($aArgs[0]) ? $aArgs[0] : '',
  1604. 'type' => isset($aArgs[1]) ? $aArgs[1] : '',
  1605. 'profile' => isset($aArgs[2]) ? (int)$aArgs[2] : 0,
  1606. 'mutual' => isset($aArgs[3]) ? (int)$aArgs[3] : 0,
  1607. 'profile2' => isset($aArgs[4]) ? (int)$aArgs[4] : 0,
  1608. );
  1609. break;
  1610. }
  1611. return $aParams;
  1612. }
  1613. protected function _serviceGetTimelineProfileImage($aEvent, $aBrowseParams, $aBuildParams)
  1614. {
  1615. $CNF = &$this->_oConfig->CNF;
  1616. $aFileInfo = BxDolStorage::getObjectInstance($CNF[$aBuildParams['stg']])->getFile((int)$aEvent['object_id']);
  1617. if(empty($aFileInfo) || !is_array($aFileInfo))
  1618. return false;
  1619. $aEventContent = unserialize($aEvent['content']);
  1620. if(!is_array($aEventContent) || empty($aEventContent['content']))
  1621. return false;
  1622. $aContentInfo = $this->_oDb->getContentInfoById($aEventContent['content']);
  1623. if(empty($aContentInfo) || !is_array($aContentInfo))
  1624. return false;
  1625. $oProfile = BxDolProfile::getInstanceMagic($aContentInfo['profile_id']);
  1626. if (!$oProfile->isActive())
  1627. return false;
  1628. $sUserName = $oProfile->getDisplayName();
  1629. $sSample = isset($CNF['T'][$aBuildParams['txt_sswa']]) ? $CNF['T'][$aBuildParams['txt_sswa']] : $CNF['T'][$aBuildParams['txt_ss']];
  1630. //--- Title & Description
  1631. $sTitle = !empty($aContentInfo[$CNF['FIELD_TITLE']]) ? $aContentInfo[$CNF['FIELD_TITLE']] : '';
  1632. if(empty($sTitle) && !empty($aContentInfo[$CNF['FIELD_TEXT']]))
  1633. $sTitle = $aContentInfo[$CNF['FIELD_TEXT']];
  1634. $sDescription = _t($CNF['T'][$aBuildParams['txt_sau']], $sUserName, _t($sSample));
  1635. return array(
  1636. 'owner_id' => $aEvent['owner_id'],
  1637. 'object_owner_id' => $aContentInfo['profile_id'],
  1638. 'icon' => !empty($CNF['ICON']) ? $CNF['ICON'] : '',
  1639. 'sample' => $sSample,
  1640. 'sample_wo_article' => $CNF['T'][$aBuildParams['txt_ss']],
  1641. 'sample_action' => isset($CNF['T'][$aBuildParams['txt_sa']]) ? $CNF['T'][$aBuildParams['txt_sa']] : '',
  1642. 'url' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]),
  1643. 'content' => $this->_getContentForTimelineProfileImage($aEvent, $aBrowseParams, $aBuildParams, $aContentInfo, $aFileInfo), //a string to display or array to parse default template before displaying.
  1644. 'date' => $aContentInfo[$CNF['FIELD_ADDED']],
  1645. 'views' => '',
  1646. 'votes' => '',
  1647. 'scores' => '',
  1648. 'reports' => '',
  1649. 'comments' => '',
  1650. 'title' => $sTitle, //may be empty.
  1651. 'description' => $sDescription //may be empty.
  1652. );
  1653. }
  1654. protected function _serviceGetTimelineProfileImageAllowedView($aEvent)
  1655. {
  1656. $sError = _t('_sys_access_denied_to_private_content');
  1657. if(empty($aEvent['content']) || !is_array($aEvent['content']) || empty($aEvent['content']['id']))
  1658. return $sError;
  1659. $aContentInfo = $this->_oDb->getContentInfoById($aEvent['content']['id']);
  1660. if(empty($aContentInfo) || !is_array($aContentInfo))
  1661. return $sError;
  1662. return $this->serviceCheckAllowedViewForProfile($aContentInfo);
  1663. }
  1664. protected function _getContentForTimelineProfileImage($aEvent, $aBrowseParams, $aBuildParams, $aContentInfo, $aFileInfo)
  1665. {
  1666. $CNF = &$this->_oConfig->CNF;
  1667. $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
  1668. //--- Image(s)
  1669. $sImage = $this->_oConfig->getImageUrl($aFileInfo['id'], $aBuildParams['trans']);
  1670. $sImageOrig = $this->_oConfig->getImageUrl($aFileInfo['id'], $aBuildParams['trans_orig']);
  1671. if(!empty($sImage)) {
  1672. if(empty($sImageOrig))
  1673. $sImageOrig = $sImage;
  1674. $a = array('id' => $aFileInfo['id'], 'url' => $sUrl, 'src' => $sImage);
  1675. if (CHECK_ACTION_RESULT_ALLOWED === $this->checkAllowedView($aContentInfo))
  1676. $a['src_orig'] = $sImageOrig;
  1677. $aImages = array($a);
  1678. }
  1679. return array(
  1680. 'sample' => isset($CNF['T'][$aBuildParams['txt_sswa']]) ? $CNF['T'][$aBuildParams['txt_sswa']] : $CNF['T'][$aBuildParams['txt_ss']],
  1681. 'sample_wo_article' => $CNF['T'][$aBuildParams['txt_ss']],
  1682. 'sample_action' => isset($CNF['T'][$aBuildParams['txt_sa']]) ? $CNF['T'][$aBuildParams['txt_sa']] : '',
  1683. 'id' => $aContentInfo[$CNF['FIELD_ID']],
  1684. 'url' => $sUrl,
  1685. 'title' => '',
  1686. 'text' => '',
  1687. 'images' => $aImages,
  1688. 'videos' => array()
  1689. );
  1690. }
  1691. protected function _entityComments($sObject, $iId = 0)
  1692. {
  1693. if(!$iId)
  1694. $iId = bx_process_input(bx_get('id'), BX_DATA_INT);
  1695. if(!$iId)
  1696. $iId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
  1697. if(!$iId)
  1698. return false;
  1699. $oCmts = BxDolCmts::getObjectInstance($sObject, $iId);
  1700. if(!$oCmts || !$oCmts->isEnabled())
  1701. return false;
  1702. return $oCmts->getCommentsBlock(array(), array('in_designbox' => false));
  1703. }
  1704. protected function _getContent($iContentId = 0, $sFuncGetContent = 'getContentInfoById')
  1705. {
  1706. if(!$iContentId && bx_get('id') === false && bx_get('profile_id') !== false) {
  1707. $oProfile = BxDolProfile::getInstance((int)bx_get('profile_id'));
  1708. if($oProfile)
  1709. $iContentId = $oProfile->getContentId();
  1710. }
  1711. return parent::_getContent($iContentId, $sFuncGetContent);
  1712. }
  1713. }
  1714. /** @} */