BxBaseServiceProfiles.php 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192
  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 UnaBaseView UNA Base Representation Classes
  7. * @{
  8. */
  9. /**
  10. * System service for profiles handling functionality.
  11. */
  12. class BxBaseServiceProfiles extends BxDol
  13. {
  14. protected $_bIsApi;
  15. public function __construct()
  16. {
  17. parent::__construct();
  18. $this->_bIsApi = bx_is_api();
  19. }
  20. public function serviceGetProfileTypes()
  21. {
  22. $aTypes = array(
  23. '' => _t('_Select_one')
  24. );
  25. $aModules = $this->_getProfilesModules();
  26. foreach($aModules as $aModule) {
  27. if(empty($aModule) || !is_array($aModule))
  28. continue;
  29. $sTitleKey = '_' . $aModule['name'];
  30. $sTitle = _t($sTitleKey);
  31. $aTypes[$aModule['name']] = !empty($sTitle) && $sTitle != $sTitleKey ? $sTitle : $aModule['title'];
  32. }
  33. return $aTypes;
  34. }
  35. public function serviceProfileAvatar ($iProfileId = 0)
  36. {
  37. if (!$iProfileId && !($iProfileId = bx_get_logged_profile_id()))
  38. return '';
  39. $oProfile = BxDolProfile::getInstance($iProfileId);
  40. if(!$oProfile)
  41. return '';
  42. if(bx_is_api())
  43. return [
  44. bx_api_get_block ('profile_avatar', $oProfile->getData())
  45. ];
  46. $oTemplate = BxDolTemplate::getInstance();
  47. $sSwitcher = '';
  48. $aSwitcher = bx_srv('system', 'account_profile_switcher', array(false, null, '', true), 'TemplServiceProfiles');
  49. if($aSwitcher !== false)
  50. $sSwitcher = BxTemplFunctions::getInstance()->popupBox('bx-profile-switcher', _t('_sys_txt_switch_profiles'), $oTemplate->parseHtmlByName('profile_avatar_switcher.html', array(
  51. 'profile_switcher' => $aSwitcher['content'],
  52. 'bx_if:multiple_profiles_mode' => array(
  53. 'condition' => empty($aSwitcher['content']) || BxDolAccount::isAllowedCreateMultiple($oProfile->id()),
  54. 'content' => array(
  55. 'url_switch_profile' => BxDolPermalinks::getInstance()->permalink('page.php?i=account-profile-switcher')
  56. )
  57. )
  58. )), true);
  59. $bSwitcher = !empty($sSwitcher);
  60. $sSwitcherUrl = $bSwitcher ? 'javascript:void(0)' : $sUrl;
  61. $sSwitcherOnclick = $bSwitcher ? "javascript:$('#bx-profile-switcher').dolPopup({});" : "";
  62. $sDisplayName = $oProfile->getDisplayName();
  63. $sUrl = $oProfile->getUrl();
  64. $oAcl = BxDolAcl::getInstance();
  65. $aAcl = $oAcl->getMemberMembershipInfo($iProfileId);
  66. $aAclInfo = $oAcl->getMembershipInfo($aAcl['id']);
  67. list($sIcon, $sIconUrl, $sIconA, $sIconHtml) = $this->_getIcon($aAclInfo['icon']);
  68. $aVars = array(
  69. 'profile_id' => $oProfile->id(),
  70. 'profile_url' => $sUrl,
  71. 'profile_edit_url' => $oProfile->getEditUrl(),
  72. 'profile_title' => $sDisplayName,
  73. 'profile_title_attr' => bx_html_attribute($sDisplayName),
  74. 'profile_ava_url' => $oProfile->getAvatar(),
  75. 'profile_unit' => $oProfile->getUnit(0, array('template' => array(
  76. 'name' => 'unit_wo_info_links',
  77. 'size' => 'thumb'
  78. ))),
  79. 'profile_acl_title' => _t($aAclInfo['name']),
  80. 'bx_if:image' => array (
  81. 'condition' => (bool)$sIconUrl,
  82. 'content' => array('icon_url' => $sIconUrl),
  83. ),
  84. 'bx_if:image_inline' => array (
  85. 'condition' => false,
  86. 'content' => array('image' => ''),
  87. ),
  88. 'bx_if:icon' => array (
  89. 'condition' => (bool)$sIcon,
  90. 'content' => array('icon' => $sIcon),
  91. ),
  92. 'bx_if:icon-a' => array (
  93. 'condition' => (bool)$sIconA,
  94. 'content' => array('icon-a' => $sIconA),
  95. ),
  96. 'bx_if:icon-html' => array (
  97. 'condition' => (bool)$sIconHtml,
  98. 'content' => array('icon' => $sIconHtml),
  99. ),
  100. 'switcher_url' => $sSwitcherUrl,
  101. 'switcher_onclick' => $sSwitcherOnclick,
  102. 'bx_if:show_switcher_icon' => array(
  103. 'condition' => $bSwitcher,
  104. 'content' => array(
  105. 'switcher_url' => $sSwitcherUrl,
  106. 'switcher_onclick' => $bSwitcher ? "javascript:$('#bx-profile-switcher').dolPopup({});" : "",
  107. )
  108. ),
  109. 'switcher' => $sSwitcher
  110. );
  111. return $oTemplate->parseHtmlByName('profile_avatar.html', $aVars);
  112. }
  113. public function serviceProfileMenu ($iProfileId = 0)
  114. {
  115. if(($oMenu = BxDolMenu::getObjectInstance('sys_profile_stats')) !== false) {
  116. if(bx_is_api())
  117. return [
  118. bx_api_get_block ('profile_menu', $oMenu->getCodeAPI())
  119. ];
  120. return $oMenu->getCode();
  121. }
  122. else
  123. return '';
  124. }
  125. public function serviceProfileFollowings ($iProfileId = 0)
  126. {
  127. if(($oMenu = BxDolMenu::getObjectInstance('sys_profile_followings')) !== false)
  128. return $oMenu->getCode();
  129. else
  130. return '';
  131. }
  132. public function serviceBefriend ($sParams)
  133. {
  134. $aParams = json_decode($sParams, true);
  135. $iProfileId = $aParams['profile_id'];
  136. $oConnection = BxDolConnection::getObjectInstance('sys_profiles_friends');
  137. $oProfile = BxDolProfile::getInstance($iProfileId);
  138. if ($aParams['action'] == 'info'){
  139. return ['profile' => BxDolProfile::getData($iProfileId), 'result' => $oConnection->isConnected((int)bx_get_logged_profile_id(), $iProfileId, true)];
  140. }
  141. if ($oProfile && $oConnection){
  142. if ($oConnection->isConnected((int)bx_get_logged_profile_id(), $iProfileId, true)){
  143. return ['profile' => BxDolProfile::getData($iProfileId), 'result' => false];
  144. }
  145. else{
  146. $oConnection->addConnection((int)bx_get_logged_profile_id(), $iProfileId);
  147. $oConnection->addConnection($iProfileId, (int)bx_get_logged_profile_id());
  148. $oProfile = BxDolProfile::getInstance($iProfileId);
  149. return ['profile' => BxDolProfile::getData($iProfileId), 'result' => true];
  150. }
  151. }
  152. }
  153. public function serviceProfileStats ($iProfileId = 0)
  154. {
  155. if (!$iProfileId && !($iProfileId = bx_get_logged_profile_id()))
  156. return '';
  157. $oProfile = BxDolProfile::getInstance($iProfileId);
  158. if(!$oProfile)
  159. return '';
  160. $oMenu = BxDolMenu::getObjectInstance('sys_profile_stats');
  161. if(!$oMenu)
  162. return '';
  163. if(bx_is_api())
  164. return [
  165. bx_api_get_block ('profile_avatar', $oProfile->getData(), ['id' => 1]),
  166. bx_api_get_block ('profile_menu', $oMenu->getCodeAPI(), ['id' => 2])
  167. ];
  168. $oAcl = BxDolAcl::getInstance();
  169. $aAcl = $oAcl->getMemberMembershipInfo($iProfileId);
  170. $aAclInfo = $oAcl->getMembershipInfo($aAcl['id']);
  171. list ($sIcon, $sIconUrl, $sIconA, $sIconHtml) = $this->_getIcon($aAclInfo['icon']);
  172. $aVars = array(
  173. 'profile_id' => $oProfile->id(),
  174. 'profile_url' => $oProfile->getUrl(),
  175. 'profile_edit_url' => $oProfile->getEditUrl(),
  176. 'profile_title' => $oProfile->getDisplayName(),
  177. 'profile_title_attr' => bx_html_attribute($oProfile->getDisplayName()),
  178. 'profile_ava_url' => $oProfile->getAvatar(),
  179. 'profile_unit' => $oProfile->getUnit(0, array('template' => array(
  180. 'name' => 'unit_wo_info',
  181. 'size' => 'ava'
  182. ))),
  183. 'profile_acl_title' => _t($aAclInfo['name']),
  184. 'menu' => $oMenu->getCode(),
  185. );
  186. $aVars['bx_if:image'] = array (
  187. 'condition' => (bool)$sIconUrl,
  188. 'content' => array('icon_url' => $sIconUrl),
  189. );
  190. $aVars['bx_if:image_inline'] = array (
  191. 'condition' => false,
  192. 'content' => array('image' => ''),
  193. );
  194. $aVars['bx_if:icon'] = array (
  195. 'condition' => (bool)$sIcon,
  196. 'content' => array('icon' => $sIcon),
  197. );
  198. $aVars['bx_if:icon-html'] = array (
  199. 'condition' => (bool)$sIconHtml,
  200. 'content' => array('icon' => $sIconHtml),
  201. );
  202. $aVars['bx_if:icon-a'] = array (
  203. 'condition' => (bool)$sIconA,
  204. 'content' => array('icon-a' => $sIconA),
  205. );
  206. return BxDolTemplate::getInstance()->parseHtmlByName('profile_stats.html', $aVars);
  207. }
  208. public function serviceGetMenuAddonProfileEdit($iProfileId = 0, $sCaption = '')
  209. {
  210. /**
  211. * Disabled.
  212. */
  213. return '';
  214. if(empty($sCaption))
  215. $sCaption = _t('_Edit');
  216. $oProfile = BxDolProfile::getInstance($iProfileId);
  217. if(!$oProfile)
  218. return '';
  219. $sModule = $oProfile->getModule();
  220. $sMethod = 'profile_edit_url';
  221. if(!BxDolRequest::serviceExists($sModule, $sMethod))
  222. return '';
  223. return BxDolTemplate::getInstance()->parseLink(BxDolService::call($sModule, $sMethod, array($oProfile->getContentId())), $sCaption);
  224. }
  225. public function serviceGetMenuAddonProfileConnections($iProfileId = 0)
  226. {
  227. $oProfile = BxDolProfile::getInstance($iProfileId);
  228. if(!$oProfile)
  229. return '';
  230. $iCount = 0;
  231. //--- Add friend requests.
  232. $iCount += (int)bx_srv('system', 'get_unconfirmed_connections_num', ['sys_profiles_friends'], 'TemplServiceConnections');
  233. //--- Add subscriptions.
  234. $iCount += (int)bx_srv('system', 'get_connected_content_num', ['sys_profiles_subscriptions'], 'TemplServiceConnections');
  235. //--- Add subscribed me.
  236. $iCount += (int)bx_srv('system', 'get_connected_initiators_num', ['sys_profiles_subscriptions'], 'TemplServiceConnections');
  237. return $iCount > 0 ? $iCount : '';
  238. }
  239. /**
  240. * @page service Service Calls
  241. * @section bx_system_general System Services
  242. * @subsection bx_system_general-profiles Profiles
  243. * @subsubsection bx_system_general-profile_membership profile_membership
  244. *
  245. * @code bx_srv('system', 'profile_membership', [2], 'TemplServiceProfiles'); @endcode
  246. * @code {{~system:profile_membership:TemplServiceProfiles[2]~}} @endcode
  247. *
  248. * Get membership level for specified profile.
  249. * @param $iProfileId profile ID
  250. *
  251. * @see BxBaseServiceProfiles::serviceProfileMembership
  252. */
  253. /**
  254. * @ref bx_system_general-profile_membership "profile_membership"
  255. */
  256. public function serviceProfileMembership ($iProfileId = 0)
  257. {
  258. if (!$iProfileId)
  259. $iProfileId = bx_get_logged_profile_id();
  260. return BxDolAcl::getInstance()->getProfileMembership($iProfileId);
  261. }
  262. public function serviceProfileMembershipStats ($iProfileId = 0)
  263. {
  264. if(!$iProfileId)
  265. $iProfileId = bx_get_logged_profile_id();
  266. $sTxtUnlimited = _t('_unlimited');
  267. $sTxtFiles = _t('_sys_storage_files');
  268. $aQuota = BxDolProfileQuery::getInstance()->getProfileQuota($iProfileId);
  269. $aTmplVarsStats = array();
  270. if(!empty($aQuota['quota_size'])) {
  271. $iWidth = (int)round(100 * $aQuota['current_size']/$aQuota['quota_size']);
  272. $sPercent = $iWidth . '%';
  273. }
  274. else {
  275. $iWidth = 0;
  276. $sPercent = $sTxtUnlimited;
  277. }
  278. $aTmplVarsStats[] = array('title' => _t('_sys_profile_storage_quota_size'), 'width' => $iWidth, 'value' => _t_format_size($aQuota['current_size']), 'percent' => $sPercent);
  279. if(!empty($aQuota['quota_number'])) {
  280. $iWidth = (int)round(100 * $aQuota['current_number']/$aQuota['quota_number']);
  281. $sPercent = $iWidth . '%';
  282. }
  283. else {
  284. $iWidth = 0;
  285. $sPercent = $sTxtUnlimited;
  286. }
  287. $aTmplVarsStats[] = array('title' => _t('_sys_profile_storage_quota_number'), 'width' => $iWidth, 'value' => $aQuota['current_number'] . ' ' . $sTxtFiles, 'percent' => $sPercent);
  288. return BxDolTemplate::getInstance()->parseHtmlByName('profile_membership_stats.html', array(
  289. 'membership' => BxDolAcl::getInstance()->getProfileMembership($iProfileId),
  290. 'bx_repeat:stat_items' => $aTmplVarsStats
  291. ));
  292. }
  293. /**
  294. * @page service Service Calls
  295. * @section bx_system_general System Services
  296. * @subsection bx_system_general-profiles Profiles
  297. * @subsubsection bx_system_general-profile_notifications profile_notifications
  298. *
  299. * @code bx_srv('system', 'profile_notifications', [], 'TemplServiceProfiles'); @endcode
  300. * @code {{~system:profile_notifications:TemplServiceProfiles~}} @endcode
  301. *
  302. * Get number of unread notifications for logged in profile
  303. *
  304. * @see BxBaseServiceProfiles::serviceProfileNotifications
  305. */
  306. /**
  307. * @ref bx_system_general-profile_notifications "profile_notifications"
  308. */
  309. public function serviceProfileNotifications ($iProfileId = 0)
  310. {
  311. if (!$iProfileId)
  312. $iProfileId = bx_get_logged_profile_id();
  313. $oMenu = BxDolMenu::getObjectInstance('sys_account_notifications');
  314. if(!$oMenu)
  315. return 0;
  316. $iNum = 0;
  317. $aMenuItems = $oMenu->getMenuItems ();
  318. foreach ($aMenuItems as $r) {
  319. if (isset($r['bx_if:addon']) && $r['bx_if:addon']['condition'])
  320. $iNum += $r['bx_if:addon']['content']['addon'];
  321. }
  322. return $iNum;
  323. }
  324. /**
  325. * @page service Service Calls
  326. * @section bx_system_general System Services
  327. * @subsection bx_system_general-profiles Profiles
  328. * @subsubsection bx_system_general-get_count_online_profiles get_count_online_profiles
  329. *
  330. * @code bx_srv('system', 'get_count_online_profiles', [], 'TemplServiceProfiles'); @endcode
  331. * @code {{~system:get_count_online_profiles:TemplServiceProfiles~}} @endcode
  332. *
  333. * Get number of online profiles
  334. *
  335. * @see BxBaseServiceProfiles::serviceGetCountOnlineProfiles
  336. */
  337. /**
  338. * @ref bx_system_general-get_count_online_profiles "get_count_online_profiles"
  339. */
  340. public function serviceGetCountOnlineProfiles ()
  341. {
  342. $oProfilesQuery = BxDolProfileQuery::getInstance();
  343. return $oProfilesQuery->getOnlineCount();
  344. }
  345. public function serviceGetProfilesModules ($bForceActAsProfile = true)
  346. {
  347. if (getParam('sys_db_cache_enable')) { // get list of profiles modules from db cache, cache is invalidated when new module is installed
  348. $oDb = BxDolDb::getInstance();
  349. $oCache = $oDb->getDbCacheObject ();
  350. $sKey = $oDb->genDbCacheKey('profiles_' . (!$bForceActAsProfile ? 'all_' : '') . 'modules_array');
  351. $sKeyTs = $oDb->genDbCacheKey('profiles_modules_ts');
  352. $mixedRetTs = $oCache->getData($sKeyTs);
  353. $mixedRet = $oCache->getData($sKey);
  354. $iNewestModuleTs = $this->_getLatestModuleTimestamp ();
  355. if ($mixedRetTs != null && $mixedRet !== null && $mixedRetTs == $iNewestModuleTs) {
  356. $aModulesArray = $mixedRet;
  357. } else {
  358. $aModulesArray = $this->_getProfilesModules ($bForceActAsProfile);
  359. $oCache->setData($sKey, $aModulesArray);
  360. $oCache->setData($sKeyTs, $iNewestModuleTs);
  361. }
  362. } else {
  363. $aModulesArray = $this->_getProfilesModules ($bForceActAsProfile);
  364. }
  365. return $aModulesArray;
  366. }
  367. public function serviceProfilesFriends ($iLimit = 20)
  368. {
  369. if (!($iProfileId = bx_get_logged_profile_id()))
  370. return array();
  371. $oConnection = BxDolConnection::getObjectInstance('sys_profiles_friends');
  372. if (!$oConnection)
  373. return array();
  374. if (!($a = $oConnection->getConnectedContent ($iProfileId, true, 0, $iLimit)))
  375. return array();
  376. $aRet = array();
  377. foreach ($a as $iId) {
  378. $oProfile = BxDolProfile::getInstance($iId);
  379. $aRet[] = array (
  380. 'label' => $oProfile->getDisplayName(),
  381. 'value' => $iId,
  382. 'url' => $oProfile->getUrl(),
  383. 'thumb' => $oProfile->getThumb(),
  384. 'unit' => $oProfile->getUnit(0, array('template' => 'unit_wo_info'))
  385. );
  386. }
  387. return $aRet;
  388. }
  389. public function serviceProfilesSearch ($sTerm, $mixedParems = [])
  390. {
  391. $iLimit = (int)getParam('sys_profiles_search_limit');
  392. if(is_int($mixedParems))
  393. $iLimit = (int)$mixedParems;
  394. else if(is_array($mixedParems) && isset($mixedParems['limit']))
  395. $iLimit = (int)$mixedParems['limit'];
  396. // display friends by default
  397. if (!$sTerm)
  398. return $this->serviceProfilesFriends($iLimit);
  399. // get list of "profiles" modules
  400. $aModules = $this->serviceGetProfilesModules();
  401. // search in each module
  402. $a = array();
  403. foreach ($aModules as $aModule) {
  404. if (!BxDolService::call($aModule['name'], 'act_as_profile'))
  405. continue;
  406. $a = array_merge($a, BxDolService::call($aModule['name'], 'profiles_search', array($sTerm, getParam('sys_per_page_search_keyword_single'))));
  407. }
  408. // sort result
  409. usort($a, function($r1, $r2) {
  410. return strcmp($r1['label'], $r2['label']);
  411. });
  412. bx_alert('system', 'profiles_search', 0, 0, array(
  413. 'module' => is_array($mixedParems) && isset($mixedParems['module']) ? $mixedParems['module'] : '',
  414. 'term' => $sTerm,
  415. 'result' => &$a
  416. ));
  417. // return as array
  418. return array_slice($a, 0, $iLimit);
  419. }
  420. public function serviceProfilesSearchByLocation ($aLocation, $iRadius, $mixedParems = [])
  421. {
  422. $sModule = !empty($mixedParems['module']) ? $mixedParems['module'] : '';
  423. $aModules = !empty($sModule) ? [BxDolModuleDb::getInstance()->getModuleByName($sModule)] : $this->serviceGetProfilesModules();
  424. $iStart = 0;
  425. $iLimit = 20;
  426. if(is_int($mixedParems))
  427. $iLimit = (int)$mixedParems;
  428. else if(is_array($mixedParems) && isset($mixedParems['limit']))
  429. $iLimit = (int)$mixedParems['limit'];
  430. $aLocation[] = $iRadius;
  431. $oProfileQuery = BxDolProfileQuery::getInstance();
  432. $aResult = [];
  433. foreach($aModules as $aModule) {
  434. if(!bx_srv($aModule['name'], 'act_as_profile'))
  435. continue;
  436. $aContentIds = bx_srv($aModule['name'], 'get_search_result_extended', [[
  437. 'location' => ['type' => 'location_radius', 'operator' => 'locate', 'value' => [
  438. 'array' => $aLocation
  439. ]]
  440. ], $iStart, $iLimit]);
  441. $aResult = array_merge($aResult, $oProfileQuery->getProfiles(['type' => 'id_by_module_content_id', 'module' => $aModule['name'], 'content_id' => $aContentIds]));
  442. }
  443. bx_alert('system', 'profiles_search_by_location', 0, 0, [
  444. 'module' => $sModule,
  445. 'location' => $aLocation,
  446. 'radius' => $iRadius,
  447. 'result' => &$aResult
  448. ]);
  449. return array_slice($aResult, 0, $iLimit);
  450. }
  451. public function serviceProfilesList ($iAccountId = 0)
  452. {
  453. $oProfilesQuery = BxDolProfileQuery::getInstance();
  454. $aProfiles = $oProfilesQuery->getProfilesByAccount($iAccountId ? $iAccountId : getLoggedId());
  455. if (!$aProfiles)
  456. return false;
  457. $s = '';
  458. foreach ($aProfiles as $aProfile)
  459. if ($aProfile['type'] != 'system')
  460. $s .= BxDolService::call($aProfile['type'], 'profile_unit', array($aProfile['content_id']));
  461. if (!$s)
  462. $s = MsgBox(_t('_sys_txt_empty'));
  463. return $s . '<div class="bx-clear"></div>';
  464. }
  465. public function serviceBrowseFriends ($iProfileId = 0, $aParams = [])
  466. {
  467. if($this->_bIsApi)
  468. $aParams = bx_api_get_browse_params($aParams);
  469. if(!$iProfileId)
  470. $iProfileId = bx_get_logged_profile_id();
  471. if(!$iProfileId)
  472. return '';
  473. $aParams = array_merge([
  474. 'params' => false,
  475. 'design_box' => BX_DB_PADDING_DEF,
  476. 'empty_message' => false,
  477. 'ajax_paginate' => true,
  478. ], $aParams);
  479. $aParamsBrowse = ['profile' => $iProfileId];
  480. if(!empty($aParams['params']) && is_array($aParams['params']))
  481. $aParamsBrowse = array_merge($aParamsBrowse, $aParams['params']);
  482. return $this->_serviceBrowseConnections('friends', $aParamsBrowse, $aParams['design_box'], $aParams['empty_message'], $aParams['ajax_paginate']);
  483. }
  484. public function serviceProfileFriendsRequestsCount ($iProfileId = 0)
  485. {
  486. if(!$iProfileId)
  487. $iProfileId = bx_get_logged_profile_id();
  488. if(!$iProfileId)
  489. return '';
  490. $oConnection = BxDolConnection::getObjectInstance('sys_profiles_friends');
  491. if(!$oConnection)
  492. return false;
  493. return $oConnection->getConnectedInitiatorsCount($iProfileId, false) - $oConnection->getConnectedInitiatorsCount($iProfileId, true);
  494. }
  495. public function serviceProfileSentFriendsRequestsCount ($iProfileId = 0)
  496. {
  497. if(!$iProfileId)
  498. $iProfileId = bx_get_logged_profile_id();
  499. if(!$iProfileId)
  500. return '';
  501. $oConnection = BxDolConnection::getObjectInstance('sys_profiles_friends');
  502. if(!$oConnection)
  503. return false;
  504. return $oConnection->getConnectedContentCount($iProfileId, false) - $oConnection->getConnectedContentCount($iProfileId, true);
  505. }
  506. public function serviceProfileFriendsCount ($iProfileId = 0)
  507. {
  508. if(!$iProfileId)
  509. $iProfileId = bx_get_logged_profile_id();
  510. if(!$iProfileId)
  511. return '';
  512. $oConnection = BxDolConnection::getObjectInstance('sys_profiles_friends');
  513. if(!$oConnection)
  514. return false;
  515. return $oConnection->getConnectedInitiatorsCount($iProfileId, true);
  516. }
  517. public function serviceProfileFollowersCount ($iProfileId = 0)
  518. {
  519. if(!$iProfileId)
  520. $iProfileId = bx_get_logged_profile_id();
  521. if(!$iProfileId)
  522. return '';
  523. $oConnection = BxDolConnection::getObjectInstance('sys_profiles_subscriptions');
  524. if(!$oConnection)
  525. return false;
  526. return $oConnection->getConnectedInitiatorsCount($iProfileId);
  527. }
  528. public function serviceProfileFollowingCount ($iProfileId = 0, $bProfilesOnly = false)
  529. {
  530. if(!$iProfileId)
  531. $iProfileId = bx_get_logged_profile_id();
  532. if(!$iProfileId)
  533. return '';
  534. $oConnection = BxDolConnection::getObjectInstance('sys_profiles_subscriptions');
  535. if(!$oConnection)
  536. return false;
  537. if(!$bProfilesOnly)
  538. return $oConnection->getConnectedContentCount($iProfileId);
  539. $aProfileModules = bx_srv('system', 'get_modules_by_type', ['profile']);
  540. $aProfileModulesNames = array_map(function($item) {
  541. return $item['name'];
  542. }, $aProfileModules);
  543. return $oConnection->getConnectedContentCountExt($iProfileId, false, ['by_type' => $aProfileModulesNames]);
  544. }
  545. public function serviceProfileRecommendationFollowingCount ($iProfileId = 0, $aParams = [])
  546. {
  547. if(!$iProfileId)
  548. $iProfileId = bx_get_logged_profile_id();
  549. if(!$iProfileId)
  550. return '';
  551. $oRecommendation = BxDolRecommendation::getObjectInstance('sys_subscriptions');
  552. if(!$oRecommendation)
  553. return false;
  554. $aModules = bx_srv('system', 'get_modules_by_type', ['profile', ['name_as_key' => true]]);
  555. return $oRecommendation->getCount($iProfileId, array_merge([
  556. 'type' => !empty($aModules) && is_array($aModules) ? array_keys($aModules) : '',
  557. ], $aParams));
  558. }
  559. public function serviceProfileRecommendationFriendsCount ($iProfileId = 0, $aParams = [])
  560. {
  561. if(!$iProfileId)
  562. $iProfileId = bx_get_logged_profile_id();
  563. if(!$iProfileId)
  564. return '';
  565. $oRecommendation = BxDolRecommendation::getObjectInstance('sys_friends');
  566. if(!$oRecommendation)
  567. return false;
  568. return $oRecommendation->getCount($iProfileId, $aParams);
  569. }
  570. public function serviceBrowseFriendRequests ($iProfileId = 0, $aParams = [])
  571. {
  572. if($this->_bIsApi)
  573. $aParams = bx_api_get_browse_params($aParams);
  574. if(!$iProfileId)
  575. $iProfileId = bx_get_logged_profile_id();
  576. if(!$iProfileId)
  577. return '';
  578. $aParams = array_merge([
  579. 'params' => false,
  580. 'design_box' => BX_DB_PADDING_DEF,
  581. 'empty_message' => false,
  582. 'ajax_paginate' => true,
  583. ], $aParams);
  584. $aParamsBrowse = ['profile' => $iProfileId];
  585. if(!empty($aParams['params']) && is_array($aParams['params']))
  586. $aParamsBrowse = array_merge($aParamsBrowse, $aParams['params']);
  587. return $this->_serviceBrowseConnections('friend_requests', $aParamsBrowse, $aParams['design_box'], $aParams['empty_message'], $aParams['ajax_paginate']);
  588. }
  589. public function serviceBrowseFriendRequested ($iProfileId = 0, $aParams = [])
  590. {
  591. if($this->_bIsApi)
  592. $aParams = bx_api_get_browse_params($aParams);
  593. if(!$iProfileId)
  594. $iProfileId = bx_get_logged_profile_id();
  595. if(!$iProfileId)
  596. return '';
  597. $aParams = array_merge([
  598. 'params' => false,
  599. 'design_box' => BX_DB_PADDING_DEF,
  600. 'empty_message' => false,
  601. 'ajax_paginate' => true,
  602. ], $aParams);
  603. $aParamsBrowse = ['profile' => $iProfileId];
  604. if(!empty($aParams['params']) && is_array($aParams['params']))
  605. $aParamsBrowse = array_merge($aParamsBrowse, $aParams['params']);
  606. return $this->_serviceBrowseConnections('friend_requested', $aParamsBrowse, $aParams['design_box'], $aParams['empty_message'], $aParams['ajax_paginate']);
  607. }
  608. public function serviceBrowseSubscriptions ($iProfileId = 0, $aParams = [])
  609. {
  610. if($this->_bIsApi)
  611. $aParams = bx_api_get_browse_params($aParams);
  612. if(!$iProfileId)
  613. $iProfileId = bx_get_logged_profile_id();
  614. if(!$iProfileId)
  615. return '';
  616. $aParams = array_merge([
  617. 'params' => false,
  618. 'design_box' => BX_DB_PADDING_DEF,
  619. 'empty_message' => false,
  620. 'ajax_paginate' => true,
  621. ], $aParams);
  622. $aParamsBrowse = ['profile' => $iProfileId];
  623. if(!empty($aParams['params']) && is_array($aParams['params']))
  624. $aParamsBrowse = array_merge($aParamsBrowse, $aParams['params']);
  625. return $this->_serviceBrowseConnections('subscriptions', $aParamsBrowse, $aParams['design_box'], $aParams['empty_message'], $aParams['ajax_paginate']);
  626. }
  627. public function serviceBrowseSubscribedMe ($iProfileId = 0, $aParams = [])
  628. {
  629. if($this->_bIsApi)
  630. $aParams = bx_api_get_browse_params($aParams);
  631. if(!$iProfileId)
  632. $iProfileId = bx_get_logged_profile_id();
  633. if(!$iProfileId)
  634. return '';
  635. $aParams = array_merge([
  636. 'params' => false,
  637. 'design_box' => BX_DB_PADDING_DEF,
  638. 'empty_message' => false,
  639. 'ajax_paginate' => true,
  640. ], $aParams);
  641. $aParamsBrowse = ['profile' => $iProfileId];
  642. if(!empty($aParams['params']) && is_array($aParams['params']))
  643. $aParamsBrowse = array_merge($aParamsBrowse, $aParams['params']);
  644. return $this->_serviceBrowseConnections('subscribed_me', $aParamsBrowse, $aParams['design_box'], $aParams['empty_message'], $aParams['ajax_paginate']);
  645. }
  646. public function serviceBrowseMembers($iProfileId, $sObject, $aParams = [])
  647. {
  648. if($this->_bIsApi)
  649. $aParams = bx_api_get_browse_params($aParams);
  650. if(!$iProfileId)
  651. $iProfileId = bx_get_logged_profile_id();
  652. if(!$iProfileId)
  653. return '';
  654. $aParams = array_merge([
  655. 'params' => false,
  656. 'design_box' => BX_DB_PADDING_DEF,
  657. 'empty_message' => false,
  658. 'ajax_paginate' => true,
  659. ], $aParams);
  660. $aParamsBrowse = [
  661. 'profile' => $iProfileId,
  662. 'object' => $sObject
  663. ];
  664. if(!empty($aParams['params']) && is_array($aParams['params']))
  665. $aParamsBrowse = array_merge($aParamsBrowse, $aParams['params']);
  666. return $this->_serviceBrowseConnections('members', $aParamsBrowse, $aParams['design_box'], $aParams['empty_message'], $aParams['ajax_paginate']);
  667. }
  668. public function serviceBrowseConnections ($iProfileId = 0, $aParams = [])
  669. {
  670. if($this->_bIsApi)
  671. $aParams = bx_api_get_browse_params($aParams);
  672. if(!$iProfileId)
  673. $iProfileId = bx_get_logged_profile_id();
  674. if(!$iProfileId)
  675. return '';
  676. $aParams = array_merge([
  677. 'params' => false,
  678. 'design_box' => BX_DB_PADDING_DEF,
  679. 'empty_message' => false,
  680. 'ajax_paginate' => true,
  681. ], $aParams);
  682. $aParamsBrowse = [
  683. 'profile' => $iProfileId,
  684. 'object' => 'sys_profiles_friends',
  685. 'type' => 'content',
  686. 'mutual' => false,
  687. 'profile2' => 0
  688. ];
  689. if(!empty($aParams['params']) && is_array($aParams['params']))
  690. $aParamsBrowse = array_merge($aParamsBrowse, $aParams['params']);
  691. return $this->_serviceBrowseConnections('connections', $aParamsBrowse, $aParams['design_box'], $aParams['empty_message'], $aParams['ajax_paginate']);
  692. }
  693. public function serviceBrowseRecommendationsFriends ($iProfileId = 0, $aParams = [])
  694. {
  695. if($this->_bIsApi)
  696. $aParams = bx_api_get_browse_params($aParams, true);
  697. if(!$iProfileId)
  698. $iProfileId = bx_get_logged_profile_id();
  699. if(!$iProfileId)
  700. return '';
  701. $aParams = array_merge([
  702. 'empty_message' => false,
  703. 'start' => 0,
  704. 'per_page' => 0
  705. ], $aParams);
  706. if(($iStartGet = bx_get('start')) !== false)
  707. $aParams['start'] = (int)$iStartGet;
  708. if(($iPerPageGet = bx_get('per_page')) !== false)
  709. $aParams['per_page'] = (int)$iPerPageGet;
  710. $oRecommendation = BxDolRecommendation::getObjectInstance('sys_friends');
  711. if(!$oRecommendation)
  712. return false;
  713. if(bx_is_api()) {
  714. $aData = $oRecommendation->getCodeAPI($iProfileId, $aParams);
  715. $aData = array_merge($aData, [
  716. 'module' => 'system',
  717. 'unit' => 'mixed',
  718. 'request_url' => '/api.php?r=system/browse_recommendations_friends/TemplServiceProfiles&params[]=' . $iProfileId . '&params[]='
  719. ]);
  720. return [bx_api_get_block('browse', $aData)];
  721. }
  722. $sCode = $oRecommendation->getCode($iProfileId, $aParams);
  723. if(!$sCode && $aParams['empty_message'])
  724. $sCode = MsgBox(_t('_Empty'));
  725. return $sCode;
  726. }
  727. public function serviceBrowseRecommendationsSubscriptions ($iProfileId = 0, $aParams = [])
  728. {
  729. if($this->_bIsApi)
  730. $aParams = bx_api_get_browse_params($aParams, true);
  731. if(!$iProfileId)
  732. $iProfileId = bx_get_logged_profile_id();
  733. if(!$iProfileId)
  734. return '';
  735. $aModules = bx_srv('system', 'get_modules_by_type', ['profile', ['name_as_key' => true]]);
  736. $aParams = array_merge([
  737. 'empty_message' => false,
  738. 'type' => !empty($aModules) && is_array($aModules) ? array_keys($aModules) : '',
  739. 'start' => 0,
  740. 'per_page' => 0
  741. ], $aParams);
  742. if(($iStartGet = bx_get('start')) !== false)
  743. $aParams['start'] = (int)$iStartGet;
  744. if(($iPerPageGet = bx_get('per_page')) !== false)
  745. $aParams['per_page'] = (int)$iPerPageGet;
  746. $oRecommendation = BxDolRecommendation::getObjectInstance('sys_subscriptions');
  747. if(!$oRecommendation)
  748. return false;
  749. if(bx_is_api()) {
  750. $aData = $oRecommendation->getCodeAPI($iProfileId, $aParams);
  751. $aData = array_merge($aData, [
  752. 'module' => 'system',
  753. 'unit' => 'mixed',
  754. 'request_url' => '/api.php?r=system/browse_recommendations_subscriptions/TemplServiceProfiles&params[]=' . $iProfileId . '&params[]='
  755. ]);
  756. return [bx_api_get_block('browse', $aData)];
  757. }
  758. $sCode = $oRecommendation->getCode($iProfileId, $aParams);
  759. if(!$sCode && $aParams['empty_message'])
  760. $sCode = MsgBox(_t('_Empty'));
  761. return $sCode;
  762. }
  763. public function serviceAccountProfileSwitcher ($iAccountId = false, $iActiveProfileId = null, $sUrlProfileAction = '', $bShowAll = 0, $sButtonTitle = '', $sProfileTemplate = '')
  764. {
  765. $oTemplate = BxDolTemplate::getInstance();
  766. $oProfilesQuery = BxDolProfileQuery::getInstance();
  767. $aProfiles = $oProfilesQuery->getProfilesByAccount($iAccountId ? $iAccountId : getLoggedId());
  768. if (!$aProfiles)
  769. return false;
  770. if (null === $iActiveProfileId)
  771. $iActiveProfileId = bx_get_logged_profile_id();
  772. $oModuleDb = BxDolModuleQuery::getInstance();
  773. $aVars = array (
  774. 'bx_repeat:row' => array(),
  775. );
  776. bx_alert('system', 'account_profile_switcher', 0, false, array(
  777. 'account_id' => $iAccountId,
  778. 'active_profile_id' => &$iActiveProfileId,
  779. 'url_profile_action' => &$sUrlProfileAction,
  780. 'show_all' => &$bShowAll,
  781. 'button_title' => &$sButtonTitle,
  782. 'profile_template' => &$sProfileTemplate,
  783. 'profiles' => &$aProfiles
  784. ));
  785. foreach ($aProfiles as $aProfile) {
  786. if (!$bShowAll && $iActiveProfileId == $aProfile['id'])
  787. continue;
  788. if(!$oModuleDb->isEnabledByName($aProfile['type']))
  789. continue;
  790. if (!BxDolService::call($aProfile['type'], 'act_as_profile'))
  791. continue;
  792. if($this->_bIsApi){
  793. $o = BxDolProfile::getInstance($aProfile['id']);
  794. $aProfilesData[] = [
  795. 'id' => $o->id(),
  796. 'display_name' => $o->getDisplayName(),
  797. 'url' => bx_api_get_relative_url($o->getUrl()),
  798. 'avatar' => $o->getAvatar()
  799. ];
  800. }
  801. $aVars['bx_repeat:row'][] = array (
  802. 'class' => $iActiveProfileId == $aProfile['id'] ? '' : 'bx-def-color-bg-box',
  803. 'bx_if:active' => array (
  804. 'condition' => $iActiveProfileId == $aProfile['id'],
  805. 'content' => array('id' => $aProfile['id']),
  806. ),
  807. 'bx_if:inactive' => array (
  808. 'condition' => $iActiveProfileId != $aProfile['id'],
  809. 'content' => array(
  810. 'id' => $aProfile['id'],
  811. 'button_title' => $sButtonTitle ? $sButtonTitle : _t('_sys_txt_switch_profile_context'),
  812. 'url_switch' => $sUrlProfileAction ? str_replace('{profile_id}', $aProfile['id'], $sUrlProfileAction) : BxDolProfile::getSwitchToProfileRedirectUrl($aProfile['id'])
  813. ),
  814. ),
  815. 'unit' => BxDolService::call($aProfile['type'], 'profile_unit', array($aProfile['content_id'], array('template' => $sProfileTemplate))),
  816. );
  817. }
  818. if($this->_bIsApi){
  819. return [bx_api_get_block ('profile_switcher', ['active_profile_id' => $iActiveProfileId, 'profiles' => $aProfilesData])];
  820. }
  821. $oTemplate->addCss('account.css');
  822. return array(
  823. 'content' => $oTemplate->parseHtmlByName('profile_switch_row.html', $aVars),
  824. );
  825. }
  826. public function serviceAccountProfileSwitcherAll ($iAccountId = false, $iActiveProfileId = null, $sUrlProfileAction = '', $bShowAll = true, $sButtonTitle = '', $sProfileTemplate = '')
  827. {
  828. return $this->serviceAccountProfileSwitcher($iAccountId, $iActiveProfileId, $sUrlProfileAction, $bShowAll, $sButtonTitle, $sProfileTemplate);
  829. }
  830. public function serviceProfileSettingsCfilter($iProfileId = false)
  831. {
  832. if(!BxDolContentFilter::getInstance()->isEnabled()) {
  833. BxDolTemplate::getInstance()->displayPageNotFound();
  834. exit;
  835. }
  836. // set settings submenu
  837. $oMenuSubmenu = BxDolMenu::getObjectInstance('sys_site_submenu');
  838. if ($oMenuSubmenu) {
  839. $oMenuSubmenu->setObjectSubmenu('sys_account_settings_submenu', array (
  840. 'title' => _t('_sys_menu_item_title_account_settings'),
  841. 'link' => BX_DOL_URL_ROOT . 'member.php',
  842. 'icon' => '',
  843. ));
  844. }
  845. if($iProfileId === false)
  846. $iProfileId = bx_get_logged_profile_id();
  847. $oProfile = BxDolProfile::getInstance($iProfileId);
  848. $aProfileInfo = $oProfile ? $oProfile->getInfo() : false;
  849. if(empty($aProfileInfo) || !is_array($aProfileInfo))
  850. return MsgBox(_t('_sys_txt_error_profile_is_not_defined'));
  851. $sForm = 'sys_profile';
  852. $sFormDisplay = 'sys_profile_cf_set';
  853. $oForm = BxDolForm::getObjectInstance($sForm, $sFormDisplay);
  854. if(!$oForm)
  855. return MsgBox(_t('_sys_txt_error_occured'));
  856. $oForm->initChecker($aProfileInfo);
  857. if(!$oForm->isSubmittedAndValid())
  858. return $sCode = $oForm->getCode();
  859. if(!$oForm->update($iProfileId)) {
  860. if (!$oForm->isValid())
  861. return $oForm->getCode();
  862. else
  863. return MsgBox(_t('_sys_txt_error_profile_update'));
  864. }
  865. // display result message
  866. $sMsg = MsgBox(_t('_' . $sFormDisplay . '_successfully_submitted'));
  867. return $sMsg . $oForm->getCode();
  868. }
  869. public function serviceIsAllowedCfilter($sAction, $iValue, $aProfileInfo)
  870. {
  871. if(!in_array($sAction, ['watch', 'use']) || !isset($aProfileInfo['birthday']))
  872. return false;
  873. $iAge = 0;
  874. if(!empty($aProfileInfo['birthday']) && !in_array($aProfileInfo['birthday'], array('0000-00-00', '0000-00-00 00:00:00')))
  875. $iAge = bx_birthday2age($aProfileInfo['birthday']);
  876. $iResult = 0;
  877. switch($iValue) {
  878. case 1:
  879. $iResult = $iValue;
  880. break;
  881. case 2:
  882. if($iAge >= 6)
  883. $iResult = $iValue;
  884. break;
  885. case 3:
  886. if($iAge >= 13)
  887. $iResult = $iValue;
  888. break;
  889. case 4:
  890. if($iAge >= 17)
  891. $iResult = $iValue;
  892. break;
  893. case 5:
  894. if($iAge >= 21)
  895. $iResult = $iValue;
  896. break;
  897. }
  898. if($iResult != 0)
  899. $iResult = 1 << ($iResult - 1);
  900. return $iResult;
  901. }
  902. public function serviceIsEnabledCfilter()
  903. {
  904. return BxDolContentFilter::getInstance()->isEnabled();
  905. }
  906. public function serviceUpdateSettings($iProfileId = false, $sSettings = '')
  907. {
  908. $oProfile = BxDolProfile::getInstance($iProfileId);
  909. if(!$oProfile)
  910. return '';
  911. $sModule = $oProfile->getModule();
  912. $sMethod = 'profile_settings_set';
  913. if(!BxDolRequest::serviceExists($sModule, $sMethod))
  914. return '';
  915. BxDolService::call($sModule, $sMethod, [$oProfile->getContentId(), json_decode($sSettings)]);
  916. }
  917. protected function _getIcon ($sIcon)
  918. {
  919. return BxTemplFunctions::getInstance()->getIcon($sIcon);
  920. }
  921. protected function _getLatestModuleTimestamp ()
  922. {
  923. $aModules = BxDolModuleQuery::getInstance()->getModulesBy(array('type' => 'modules', 'active' => 1, 'order_by' => '`date` ASC'));
  924. if (empty($aModules))
  925. return 0;
  926. $aModuleNewest = array_pop($aModules);
  927. return $aModuleNewest['date'];
  928. }
  929. protected function _getProfilesModules($bForceActAsProfile = true)
  930. {
  931. $aRet = array();
  932. $aModules = BxDolModuleQuery::getInstance()->getModulesBy(array('type' => 'modules', 'active' => 1));
  933. foreach($aModules as $aModule) {
  934. $oModule = BxDolModule::getInstance($aModule['name']);
  935. if(!($oModule instanceof iBxDolProfileService))
  936. continue;
  937. if($bForceActAsProfile && !$oModule->serviceActAsProfile())
  938. continue;
  939. $aRet[] = $aModule;
  940. }
  941. return $aRet;
  942. }
  943. protected function _serviceBrowseConnections ($sMode, $aParams = [], $iDesignBox = BX_DB_PADDING_DEF, $bDisplayEmptyMsg = false, $bAjaxPaginate = true)
  944. {
  945. $sClass = 'BxTemplProfileSearchResult';
  946. bx_import($sClass);
  947. $o = new $sClass($sMode, $aParams);
  948. $o->setDesignBoxTemplateId($iDesignBox);
  949. $o->setDisplayEmptyMsg($bDisplayEmptyMsg);
  950. $o->setAjaxPaginate($bAjaxPaginate);
  951. $o->setUnitParams(['context' => $sMode]);
  952. if ($o->isError)
  953. return '';
  954. if ($s = $o->processing()) {
  955. if(!bx_is_api())
  956. return $s;
  957. return [bx_api_get_block('browse', $s)];
  958. }
  959. else
  960. return '';
  961. }
  962. }
  963. /** @} */