BxBaseServiceProfiles.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  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. public function __construct()
  15. {
  16. parent::__construct();
  17. }
  18. public function serviceGetProfileTypes()
  19. {
  20. $aTypes = array(
  21. '' => _t('_Select_one')
  22. );
  23. $aModules = $this->_getProfilesModules();
  24. foreach($aModules as $aModule) {
  25. if(empty($aModule) || !is_array($aModule))
  26. continue;
  27. $sTitleKey = '_' . $aModule['name'];
  28. $sTitle = _t($sTitleKey);
  29. $aTypes[$aModule['name']] = !empty($sTitle) && $sTitle != $sTitleKey ? $sTitle : $aModule['title'];
  30. }
  31. return $aTypes;
  32. }
  33. public function serviceProfileAvatar ($iProfileId = 0)
  34. {
  35. if (!$iProfileId && !($iProfileId = bx_get_logged_profile_id()))
  36. return '';
  37. $oProfile = BxDolProfile::getInstance($iProfileId);
  38. if(!$oProfile)
  39. return '';
  40. $oTemplate = BxDolTemplate::getInstance();
  41. $sSwitcher = '';
  42. $aSwitcher = bx_srv('system', 'account_profile_switcher', array(false, null, '', true), 'TemplServiceProfiles');
  43. if($aSwitcher !== false)
  44. $sSwitcher = BxTemplFunctions::getInstance()->transBox('bx-profile-switcher', $oTemplate->parseHtmlByName('profile_avatar_switcher.html', array(
  45. 'profile_switcher' => $aSwitcher['content'],
  46. 'bx_if:multiple_profiles_mode' => array(
  47. 'condition' => empty($aSwitcher['content']) || BxDolAccount::isAllowedCreateMultiple($oProfile->id()),
  48. 'content' => array(
  49. 'url_switch_profile' => BxDolPermalinks::getInstance()->permalink('page.php?i=account-profile-switcher')
  50. )
  51. )
  52. )), true);
  53. $bSwitcher = !empty($sSwitcher);
  54. $sSwitcherUrl = $bSwitcher ? 'javascript:void(0)' : $sUrl;
  55. $sSwitcherOnclick = $bSwitcher ? "javascript:$('#bx-profile-switcher').dolPopup({});" : "";
  56. $sDisplayName = $oProfile->getDisplayName();
  57. $sUrl = $oProfile->getUrl();
  58. $oAcl = BxDolAcl::getInstance();
  59. $aAcl = $oAcl->getMemberMembershipInfo($iProfileId);
  60. $aAclInfo = $oAcl->getMembershipInfo($aAcl['id']);
  61. list($sIcon, $sIconUrl, $sIconA, $sIconHtml) = $this->_getIcon($aAclInfo['icon']);
  62. $aVars = array(
  63. 'profile_id' => $oProfile->id(),
  64. 'profile_url' => $sUrl,
  65. 'profile_edit_url' => $oProfile->getEditUrl(),
  66. 'profile_title' => $sDisplayName,
  67. 'profile_title_attr' => bx_html_attribute($sDisplayName),
  68. 'profile_ava_url' => $oProfile->getAvatar(),
  69. 'profile_unit' => $oProfile->getUnit(0, array('template' => array(
  70. 'name' => 'unit_wo_info_links',
  71. 'size' => 'thumb'
  72. ))),
  73. 'profile_acl_title' => _t($aAclInfo['name']),
  74. 'bx_if:image' => array (
  75. 'condition' => (bool)$sIconUrl,
  76. 'content' => array('icon_url' => $sIconUrl),
  77. ),
  78. 'bx_if:image_inline' => array (
  79. 'condition' => false,
  80. 'content' => array('image' => ''),
  81. ),
  82. 'bx_if:icon' => array (
  83. 'condition' => (bool)$sIcon,
  84. 'content' => array('icon' => $sIcon),
  85. ),
  86. 'bx_if:icon-a' => array (
  87. 'condition' => (bool)$sIconA,
  88. 'content' => array('icon-a' => $sIconA),
  89. ),
  90. 'bx_if:icon-html' => array (
  91. 'condition' => (bool)$sIconHtml,
  92. 'content' => array('icon' => $sIconHtml),
  93. ),
  94. 'switcher_url' => $sSwitcherUrl,
  95. 'switcher_onclick' => $sSwitcherOnclick,
  96. 'bx_if:show_switcher_icon' => array(
  97. 'condition' => $bSwitcher,
  98. 'content' => array(
  99. 'switcher_url' => $sSwitcherUrl,
  100. 'switcher_onclick' => $bSwitcher ? "javascript:$('#bx-profile-switcher').dolPopup({});" : "",
  101. )
  102. ),
  103. 'switcher' => $sSwitcher
  104. );
  105. return $oTemplate->parseHtmlByName('profile_avatar.html', $aVars);
  106. }
  107. public function serviceProfileMenu ($iProfileId = 0)
  108. {
  109. return BxDolMenu::getObjectInstance('sys_profile_stats')->getCode();
  110. }
  111. public function serviceProfileFollowings ($iProfileId = 0)
  112. {
  113. return BxDolMenu::getObjectInstance('sys_profile_followings')->getCode();
  114. }
  115. public function serviceProfileStats ($iProfileId = 0)
  116. {
  117. if (!$iProfileId && !($iProfileId = bx_get_logged_profile_id()))
  118. return '';
  119. $oProfile = BxDolProfile::getInstance($iProfileId);
  120. if(!$oProfile)
  121. return '';
  122. $oAcl = BxDolAcl::getInstance();
  123. $aAcl = $oAcl->getMemberMembershipInfo($iProfileId);
  124. $aAclInfo = $oAcl->getMembershipInfo($aAcl['id']);
  125. list ($sIcon, $sIconUrl, $sIconA, $sIconHtml) = $this->_getIcon($aAclInfo['icon']);
  126. $aVars = array(
  127. 'profile_id' => $oProfile->id(),
  128. 'profile_url' => $oProfile->getUrl(),
  129. 'profile_edit_url' => $oProfile->getEditUrl(),
  130. 'profile_title' => $oProfile->getDisplayName(),
  131. 'profile_title_attr' => bx_html_attribute($oProfile->getDisplayName()),
  132. 'profile_ava_url' => $oProfile->getAvatar(),
  133. 'profile_unit' => $oProfile->getUnit(0, array('template' => array(
  134. 'name' => 'unit_wo_info',
  135. 'size' => 'ava'
  136. ))),
  137. 'profile_acl_title' => _t($aAclInfo['name']),
  138. 'menu' => BxDolMenu::getObjectInstance('sys_profile_stats')->getCode(),
  139. );
  140. $aVars['bx_if:image'] = array (
  141. 'condition' => (bool)$sIconUrl,
  142. 'content' => array('icon_url' => $sIconUrl),
  143. );
  144. $aVars['bx_if:image_inline'] = array (
  145. 'condition' => false,
  146. 'content' => array('image' => ''),
  147. );
  148. $aVars['bx_if:icon'] = array (
  149. 'condition' => (bool)$sIcon,
  150. 'content' => array('icon' => $sIcon),
  151. );
  152. $aVars['bx_if:icon-html'] = array (
  153. 'condition' => (bool)$sIconHtml,
  154. 'content' => array('icon' => $sIconHtml),
  155. );
  156. $aVars['bx_if:icon-a'] = array (
  157. 'condition' => (bool)$sIconA,
  158. 'content' => array('icon-a' => $sIconA),
  159. );
  160. return BxDolTemplate::getInstance()->parseHtmlByName('profile_stats.html', $aVars);
  161. }
  162. public function serviceGetMenuAddonProfileEdit($iProfileId = 0, $sCaption = '')
  163. {
  164. /**
  165. * Disabled.
  166. */
  167. return '';
  168. if(empty($sCaption))
  169. $sCaption = _t('_Edit');
  170. $oProfile = BxDolProfile::getInstance($iProfileId);
  171. if(!$oProfile)
  172. return '';
  173. $sModule = $oProfile->getModule();
  174. $sMethod = 'profile_edit_url';
  175. if(!BxDolRequest::serviceExists($sModule, $sMethod))
  176. return '';
  177. return BxDolTemplate::getInstance()->parseLink(BxDolService::call($sModule, $sMethod, array($oProfile->getContentId())), $sCaption);
  178. }
  179. /**
  180. * @page service Service Calls
  181. * @section bx_system_general System Services
  182. * @subsection bx_system_general-profiles Profiles
  183. * @subsubsection bx_system_general-profile_membership profile_membership
  184. *
  185. * @code bx_srv('system', 'profile_membership', [2], 'TemplServiceProfiles'); @endcode
  186. * @code {{~system:profile_membership:TemplServiceProfiles[2]~}} @endcode
  187. *
  188. * Get membership level for specified profile.
  189. * @param $iProfileId profile ID
  190. *
  191. * @see BxBaseServiceProfiles::serviceProfileMembership
  192. */
  193. /**
  194. * @ref bx_system_general-profile_membership "profile_membership"
  195. */
  196. public function serviceProfileMembership ($iProfileId = 0)
  197. {
  198. if (!$iProfileId)
  199. $iProfileId = bx_get_logged_profile_id();
  200. return BxDolAcl::getInstance()->getProfileMembership($iProfileId);
  201. }
  202. public function serviceProfileMembershipStats ($iProfileId = 0)
  203. {
  204. if(!$iProfileId)
  205. $iProfileId = bx_get_logged_profile_id();
  206. $sTxtUnlimited = _t('_unlimited');
  207. $sTxtFiles = _t('_sys_storage_files');
  208. $aQuota = BxDolProfileQuery::getInstance()->getProfileQuota($iProfileId);
  209. $aTmplVarsStats = array();
  210. if(!empty($aQuota['quota_size'])) {
  211. $iWidth = (int)round(100 * $aQuota['current_size']/$aQuota['quota_size']);
  212. $sPercent = $iWidth . '%';
  213. }
  214. else {
  215. $iWidth = 0;
  216. $sPercent = $sTxtUnlimited;
  217. }
  218. $aTmplVarsStats[] = array('title' => _t('_sys_profile_storage_quota_size'), 'width' => $iWidth, 'value' => _t_format_size($aQuota['current_size']), 'percent' => $sPercent);
  219. if(!empty($aQuota['quota_number'])) {
  220. $iWidth = (int)round(100 * $aQuota['current_number']/$aQuota['quota_number']);
  221. $sPercent = $iWidth . '%';
  222. }
  223. else {
  224. $iWidth = 0;
  225. $sPercent = $sTxtUnlimited;
  226. }
  227. $aTmplVarsStats[] = array('title' => _t('_sys_profile_storage_quota_number'), 'width' => $iWidth, 'value' => $aQuota['current_number'] . ' ' . $sTxtFiles, 'percent' => $sPercent);
  228. return BxDolTemplate::getInstance()->parseHtmlByName('profile_membership_stats.html', array(
  229. 'membership' => BxDolAcl::getInstance()->getProfileMembership($iProfileId),
  230. 'bx_repeat:stat_items' => $aTmplVarsStats
  231. ));
  232. }
  233. /**
  234. * @page service Service Calls
  235. * @section bx_system_general System Services
  236. * @subsection bx_system_general-profiles Profiles
  237. * @subsubsection bx_system_general-profile_notifications profile_notifications
  238. *
  239. * @code bx_srv('system', 'profile_notifications', [], 'TemplServiceProfiles'); @endcode
  240. * @code {{~system:profile_notifications:TemplServiceProfiles~}} @endcode
  241. *
  242. * Get number of unread notifications for logged in profile
  243. *
  244. * @see BxBaseServiceProfiles::serviceProfileNotifications
  245. */
  246. /**
  247. * @ref bx_system_general-profile_notifications "profile_notifications"
  248. */
  249. public function serviceProfileNotifications ($iProfileId = 0)
  250. {
  251. if (!$iProfileId)
  252. $iProfileId = bx_get_logged_profile_id();
  253. $oMenu = BxDolMenu::getObjectInstance('sys_account_notifications');
  254. if(!$oMenu)
  255. return 0;
  256. $iNum = 0;
  257. $aMenuItems = $oMenu->getMenuItems ();
  258. foreach ($aMenuItems as $r) {
  259. if (isset($r['bx_if:addon']) && $r['bx_if:addon']['condition'])
  260. $iNum += $r['bx_if:addon']['content']['addon'];
  261. }
  262. return $iNum;
  263. }
  264. /**
  265. * @page service Service Calls
  266. * @section bx_system_general System Services
  267. * @subsection bx_system_general-profiles Profiles
  268. * @subsubsection bx_system_general-get_count_online_profiles get_count_online_profiles
  269. *
  270. * @code bx_srv('system', 'get_count_online_profiles', [], 'TemplServiceProfiles'); @endcode
  271. * @code {{~system:get_count_online_profiles:TemplServiceProfiles~}} @endcode
  272. *
  273. * Get number of online profiles
  274. *
  275. * @see BxBaseServiceProfiles::serviceGetCountOnlineProfiles
  276. */
  277. /**
  278. * @ref bx_system_general-get_count_online_profiles "get_count_online_profiles"
  279. */
  280. public function serviceGetCountOnlineProfiles ()
  281. {
  282. $oProfilesQuery = BxDolProfileQuery::getInstance();
  283. return $oProfilesQuery->getOnlineCount();
  284. }
  285. public function serviceGetProfilesModules ($bForceActAsProfile = true)
  286. {
  287. if (getParam('sys_db_cache_enable')) { // get list of profiles modules from db cache, cache is invalidated when new module is installed
  288. $oDb = BxDolDb::getInstance();
  289. $oCache = $oDb->getDbCacheObject ();
  290. $sKey = $oDb->genDbCacheKey('profiles_' . (!$bForceActAsProfile ? 'all_' : '') . 'modules_array');
  291. $sKeyTs = $oDb->genDbCacheKey('profiles_modules_ts');
  292. $mixedRetTs = $oCache->getData($sKeyTs);
  293. $mixedRet = $oCache->getData($sKey);
  294. $iNewestModuleTs = $this->_getLatestModuleTimestamp ();
  295. if ($mixedRetTs != null && $mixedRet !== null && $mixedRetTs == $iNewestModuleTs) {
  296. $aModulesArray = $mixedRet;
  297. } else {
  298. $aModulesArray = $this->_getProfilesModules ($bForceActAsProfile);
  299. $oCache->setData($sKey, $aModulesArray);
  300. $oCache->setData($sKeyTs, $iNewestModuleTs);
  301. }
  302. } else {
  303. $aModulesArray = $this->_getProfilesModules ($bForceActAsProfile);
  304. }
  305. return $aModulesArray;
  306. }
  307. public function serviceProfilesFriends ($iLimit = 20)
  308. {
  309. if (!($iProfileId = bx_get_logged_profile_id()))
  310. return array();
  311. $oConnection = BxDolConnection::getObjectInstance('sys_profiles_friends');
  312. if (!$oConnection)
  313. return array();
  314. if (!($a = $oConnection->getConnectedContent ($iProfileId, true, 0, $iLimit)))
  315. return array();
  316. $aRet = array();
  317. foreach ($a as $iId) {
  318. $oProfile = BxDolProfile::getInstance($iId);
  319. $aRet[] = array (
  320. 'label' => $oProfile->getDisplayName(),
  321. 'value' => $iId,
  322. 'url' => $oProfile->getUrl(),
  323. 'thumb' => $oProfile->getThumb(),
  324. 'unit' => $oProfile->getUnit(0, array('template' => 'unit_wo_info'))
  325. );
  326. }
  327. return $aRet;
  328. }
  329. public function serviceProfilesSearch ($sTerm, $iLimit = 20)
  330. {
  331. // display friends by default
  332. if (!$sTerm)
  333. return $this->serviceProfilesFriends($iLimit);
  334. // get list of "profiles" modules
  335. $aModules = $this->serviceGetProfilesModules();
  336. // search in each module
  337. $a = array();
  338. foreach ($aModules as $aModule) {
  339. if (!BxDolService::call($aModule['name'], 'act_as_profile'))
  340. continue;
  341. $a = array_merge($a, BxDolService::call($aModule['name'], 'profiles_search', array($sTerm, getParam('sys_per_page_search_keyword_single'))));
  342. }
  343. // sort result
  344. usort($a, function($r1, $r2) {
  345. return strcmp($r1['label'], $r2['label']);
  346. });
  347. bx_alert('system', 'profiles_search', 0, 0, array(
  348. 'term' => $sTerm,
  349. 'result' => &$a
  350. ));
  351. // return as array
  352. return array_slice($a, 0, $iLimit);
  353. }
  354. public function serviceProfilesList ($iAccountId = 0)
  355. {
  356. $oProfilesQuery = BxDolProfileQuery::getInstance();
  357. $aProfiles = $oProfilesQuery->getProfilesByAccount($iAccountId ? $iAccountId : getLoggedId());
  358. if (!$aProfiles)
  359. return false;
  360. $s = '';
  361. foreach ($aProfiles as $aProfile)
  362. if ($aProfile['type'] != 'system')
  363. $s .= BxDolService::call($aProfile['type'], 'profile_unit', array($aProfile['content_id']));
  364. if (!$s)
  365. $s = MsgBox(_t('_sys_txt_empty'));
  366. return $s . '<div class="bx-clear"></div>';
  367. }
  368. public function serviceAccountProfileSwitcher ($iAccountId = false, $iActiveProfileId = null, $sUrlProfileAction = '', $bShowAll = 0, $sButtonTitle = '', $sProfileTemplate = '')
  369. {
  370. $oTemplate = BxDolTemplate::getInstance();
  371. BxDolInformer::getInstance($oTemplate)->setEnabled(false);
  372. $oProfilesQuery = BxDolProfileQuery::getInstance();
  373. $aProfiles = $oProfilesQuery->getProfilesByAccount($iAccountId ? $iAccountId : getLoggedId());
  374. if (!$aProfiles)
  375. return false;
  376. if (null === $iActiveProfileId)
  377. $iActiveProfileId = bx_get_logged_profile_id();
  378. $oModuleDb = BxDolModuleQuery::getInstance();
  379. $aVars = array (
  380. 'bx_repeat:row' => array(),
  381. );
  382. bx_alert('system', 'account_profile_switcher', 0, false, array(
  383. 'account_id' => $iAccountId,
  384. 'active_profile_id' => &$iActiveProfileId,
  385. 'url_profile_action' => &$sUrlProfileAction,
  386. 'show_all' => &$bShowAll,
  387. 'button_title' => &$sButtonTitle,
  388. 'profile_template' => &$sProfileTemplate,
  389. 'profiles' => &$aProfiles
  390. ));
  391. foreach ($aProfiles as $aProfile) {
  392. if (!$bShowAll && $iActiveProfileId == $aProfile['id'])
  393. continue;
  394. if(!$oModuleDb->isEnabledByName($aProfile['type']))
  395. continue;
  396. if (!BxDolService::call($aProfile['type'], 'act_as_profile'))
  397. continue;
  398. $aVars['bx_repeat:row'][] = array (
  399. 'class' => $iActiveProfileId == $aProfile['id'] ? '' : 'bx-def-color-bg-box',
  400. 'bx_if:active' => array (
  401. 'condition' => $iActiveProfileId == $aProfile['id'],
  402. 'content' => array('id' => $aProfile['id']),
  403. ),
  404. 'bx_if:inactive' => array (
  405. 'condition' => $iActiveProfileId != $aProfile['id'],
  406. 'content' => array(
  407. 'id' => $aProfile['id'],
  408. 'button_title' => $sButtonTitle ? $sButtonTitle : _t('_sys_txt_switch_profile_context'),
  409. 'url_switch' => $sUrlProfileAction ? str_replace('{profile_id}', $aProfile['id'], $sUrlProfileAction) : BxDolPermalinks::getInstance()->permalink('page.php?i=account-profile-switcher', array('switch_to_profile' => $aProfile['id'], 'redirect_back' => 1))
  410. ),
  411. ),
  412. 'unit' => BxDolService::call($aProfile['type'], 'profile_unit', array($aProfile['content_id'], array('template' => $sProfileTemplate))),
  413. );
  414. }
  415. $oTemplate->addCss('account.css');
  416. return array(
  417. 'content' => $oTemplate->parseHtmlByName('profile_switch_row.html', $aVars),
  418. );
  419. }
  420. public function serviceProfileSettingsCfilter($iProfileId = false)
  421. {
  422. if(!BxDolContentFilter::getInstance()->isEnabled()) {
  423. BxDolTemplate::getInstance()->displayPageNotFound();
  424. exit;
  425. }
  426. // set settings submenu
  427. $oMenuSubmenu = BxDolMenu::getObjectInstance('sys_site_submenu');
  428. if ($oMenuSubmenu) {
  429. $oMenuSubmenu->setObjectSubmenu('sys_account_settings_submenu', array (
  430. 'title' => _t('_sys_menu_item_title_account_settings'),
  431. 'link' => BX_DOL_URL_ROOT . 'member.php',
  432. 'icon' => '',
  433. ));
  434. }
  435. if($iProfileId === false)
  436. $iProfileId = bx_get_logged_profile_id();
  437. $oProfile = BxDolProfile::getInstance($iProfileId);
  438. $aProfileInfo = $oProfile ? $oProfile->getInfo() : false;
  439. if(empty($aProfileInfo) || !is_array($aProfileInfo))
  440. return MsgBox(_t('_sys_txt_error_profile_is_not_defined'));
  441. $sForm = 'sys_profile';
  442. $sFormDisplay = 'sys_profile_cf_set';
  443. $oForm = BxDolForm::getObjectInstance($sForm, $sFormDisplay);
  444. if(!$oForm)
  445. return MsgBox(_t('_sys_txt_error_occured'));
  446. $oForm->initChecker($aProfileInfo);
  447. if(!$oForm->isSubmittedAndValid())
  448. return $sCode = $oForm->getCode();
  449. if(!$oForm->update($iProfileId)) {
  450. if (!$oForm->isValid())
  451. return $oForm->getCode();
  452. else
  453. return MsgBox(_t('_sys_txt_error_profile_update'));
  454. }
  455. // display result message
  456. $sMsg = MsgBox(_t('_' . $sFormDisplay . '_successfully_submitted'));
  457. return $sMsg . $oForm->getCode();
  458. }
  459. public function serviceIsAllowedCfilter($sAction, $iValue, $aProfileInfo)
  460. {
  461. if(!in_array($sAction, ['watch', 'use']) || !isset($aProfileInfo['birthday']))
  462. return false;
  463. $iResult = 0;
  464. if(empty($aProfileInfo['birthday']) || in_array($aProfileInfo['birthday'], array('0000-00-00', '0000-00-00 00:00:00')))
  465. return $iResult;
  466. $iAge = bx_birthday2age($aProfileInfo['birthday']);
  467. switch($iValue) {
  468. case 1:
  469. $iResult = $iValue;
  470. break;
  471. case 2:
  472. if($iAge >= 6)
  473. $iResult = $iValue;
  474. break;
  475. case 3:
  476. if($iAge >= 13)
  477. $iResult = $iValue;
  478. break;
  479. case 4:
  480. if($iAge >= 17)
  481. $iResult = $iValue;
  482. break;
  483. case 5:
  484. if($iAge >= 21)
  485. $iResult = $iValue;
  486. break;
  487. }
  488. if($iResult != 0)
  489. $iResult = 1 << ($iResult - 1);
  490. return $iResult;
  491. }
  492. public function serviceIsEnabledCfilter()
  493. {
  494. return BxDolContentFilter::getInstance()->isEnabled();
  495. }
  496. protected function _getIcon ($sIcon)
  497. {
  498. return BxTemplFunctions::getInstance()->getIcon($sIcon);
  499. }
  500. protected function _getLatestModuleTimestamp ()
  501. {
  502. $aModules = BxDolModuleQuery::getInstance()->getModulesBy(array('type' => 'modules', 'active' => 1, 'order_by' => '`date` ASC'));
  503. if (empty($aModules))
  504. return 0;
  505. $aModuleNewest = array_pop($aModules);
  506. return $aModuleNewest['date'];
  507. }
  508. protected function _getProfilesModules($bForceActAsProfile = true)
  509. {
  510. $aRet = array();
  511. $aModules = BxDolModuleQuery::getInstance()->getModulesBy(array('type' => 'modules', 'active' => 1));
  512. foreach($aModules as $aModule) {
  513. $oModule = BxDolModule::getInstance($aModule['name']);
  514. if(!($oModule instanceof iBxDolProfileService))
  515. continue;
  516. if($bForceActAsProfile && !$oModule->serviceActAsProfile())
  517. continue;
  518. $aRet[] = $aModule;
  519. }
  520. return $aRet;
  521. }
  522. }
  523. /** @} */