1
0

BxDolProfile.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  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 UnaCore UNA Core
  7. * @{
  8. */
  9. define('BX_PROFILE_ACTION_AUTO', 0); ///< automatic action without any checking
  10. define('BX_PROFILE_ACTION_MANUAL', 1); ///< manual action performed by human
  11. define('BX_PROFILE_ACTION_ROBOT', 2); ///< action peformed by some robot based on some conditions
  12. define('BX_PROFILE_ACTION_EXTERNAL', 2); ///< action peformed by external service, like join using OAuth
  13. class BxDolProfile extends BxDolFactory implements iBxDolProfile
  14. {
  15. protected $_iProfileID;
  16. protected $_aProfile;
  17. protected $_oQuery;
  18. /**
  19. * Constructor
  20. */
  21. protected function __construct ($iProfileId)
  22. {
  23. $iProfileId = (int)$iProfileId;
  24. $sClass = get_class($this) . '_' . $iProfileId;
  25. if (isset($GLOBALS['bxDolClasses'][$sClass]))
  26. trigger_error ('Multiple instances are not allowed for the class: ' . get_class($this), E_USER_ERROR);
  27. parent::__construct();
  28. $this->_iProfileID = $iProfileId; // since constructor is protected $iProfileId is always valid
  29. $this->_oQuery = BxDolProfileQuery::getInstance();
  30. }
  31. /**
  32. * Prevent cloning the instance
  33. */
  34. public function __clone()
  35. {
  36. $sClass = get_class($this) . '_' . $this->_iProfileID;
  37. if (isset($GLOBALS['bxDolClasses'][$sClass]))
  38. trigger_error('Clone is not allowed for the class: ' . get_class($this), E_USER_ERROR);
  39. }
  40. /**
  41. * Get singleton instance of Account Profile by account id
  42. */
  43. public static function getInstanceAccountProfile($iAccountId = false, $bClearCache = false)
  44. {
  45. if (!$iAccountId)
  46. $iAccountId = getLoggedId();
  47. $oQuery = BxDolProfileQuery::getInstance();
  48. $aProfile = $oQuery->getProfileByContentTypeAccount($iAccountId, 'system', $iAccountId);
  49. if (!$aProfile)
  50. return false;
  51. return self::getInstance($aProfile['id'], $bClearCache);
  52. }
  53. /**
  54. * Get singleton instance of Profile by account id, content id and type
  55. */
  56. public static function getInstanceByContentTypeAccount($iContent, $sType, $iAccountId = false)
  57. {
  58. if (!$iAccountId)
  59. $iAccountId = getLoggedId();
  60. $oQuery = BxDolProfileQuery::getInstance();
  61. $aProfile = $oQuery->getProfileByContentTypeAccount($iContent, $sType, $iAccountId);
  62. if (!$aProfile)
  63. return false;
  64. return self::getInstance($aProfile['id']);
  65. }
  66. /**
  67. * Get singleton instance of Profile by content id and type
  68. */
  69. public static function getInstanceByContentAndType($iContent, $sType, $bClearCache = false)
  70. {
  71. $oQuery = BxDolProfileQuery::getInstance();
  72. $aProfile = $oQuery->getProfileByContentAndType($iContent, $sType, $bClearCache);
  73. if (!$aProfile)
  74. return false;
  75. return self::getInstance($aProfile['id']);
  76. }
  77. /**
  78. * Get singleton instance of Profile by Account id (currently active profile is returned)
  79. */
  80. public static function getInstanceByAccount($iAccountId = false, $bClearCache = false)
  81. {
  82. $oQuery = BxDolProfileQuery::getInstance();
  83. $mixedProfileId = $oQuery->getCurrentProfileByAccount($iAccountId, $bClearCache);
  84. return self::getInstance($mixedProfileId);
  85. }
  86. /**
  87. * Get singleton instance of Profile by profile id, if profile isn't found it returns instance of BxDolProfileAnonymous or BxDolProfileUndefined
  88. */
  89. public static function getInstanceMagic($mixedProfileId = false, $bClearCache = false)
  90. {
  91. if ($mixedProfileId < 0)
  92. return BxDolProfileAnonymous::getInstance($mixedProfileId);
  93. if (0 === $mixedProfileId || !($oProfile = self::getInstance($mixedProfileId, $bClearCache)))
  94. return BxDolProfileUndefined::getInstance();
  95. return $oProfile;
  96. }
  97. /**
  98. * Get singleton instance of Profile by profile id
  99. */
  100. public static function getInstance($mixedProfileId = false, $bClearCache = false)
  101. {
  102. $oQuery = BxDolProfileQuery::getInstance();
  103. if (!$mixedProfileId)
  104. $mixedProfileId = $oQuery->getCurrentProfileByAccount(getLoggedId(), $bClearCache);
  105. $aProfileInfo = $oQuery->getInfoById($mixedProfileId);
  106. if (empty($aProfileInfo['id']) || !BxDolModuleDb::getInstance()->isEnabledByName($aProfileInfo['type']))
  107. return false;
  108. $sClass = __CLASS__ . '_' . $aProfileInfo['id'];
  109. if (!isset($GLOBALS['bxDolClasses'][$sClass]))
  110. $GLOBALS['bxDolClasses'][$sClass] = new BxDolProfile($aProfileInfo['id']);
  111. return $GLOBALS['bxDolClasses'][$sClass];
  112. }
  113. /**
  114. * Get profile id
  115. */
  116. public function id()
  117. {
  118. $aProfile = $this->getInfo($this->_iProfileID);
  119. return isset($aProfile['id']) ? $aProfile['id'] : false;
  120. }
  121. /**
  122. * Get account id associated with the profile
  123. */
  124. public function getAccountId()
  125. {
  126. $aInfo = $this->getInfo();
  127. return $aInfo['account_id'];
  128. }
  129. /**
  130. * Get account object associated with the profile
  131. */
  132. public function getAccountObject()
  133. {
  134. return BxDolAccount::getInstance($this->getAccountId());
  135. }
  136. /**
  137. * Get content id associated with the profile
  138. */
  139. public function getContentId()
  140. {
  141. $aInfo = $this->getInfo();
  142. return $aInfo['content_id'];
  143. }
  144. /**
  145. * Check if profile status is active
  146. */
  147. public function isActive($iProfileId = false)
  148. {
  149. if($this->getStatus($iProfileId) != BX_PROFILE_STATUS_ACTIVE)
  150. return false;
  151. return (($oAccount = $this->getAccountObject()) !== false && $oAccount->isConfirmed()) || !getParam('sys_account_hide_unconfirmed_accounts');
  152. }
  153. /**
  154. * Is profile online
  155. */
  156. public function isOnline($iProfileId = false)
  157. {
  158. $iProfileId = (int)$iProfileId ? $iProfileId : $this->_iProfileID;
  159. return $this->_oQuery->isOnline($iProfileId);
  160. }
  161. /**
  162. * Is profile can 'Act as Profile'
  163. */
  164. public function isActAsProfile($iProfileId = false)
  165. {
  166. $aInfo = $this->_oQuery->getInfoById((int)$iProfileId ? $iProfileId : $this->_iProfileID);
  167. return BxDolService::call($aInfo['type'], 'act_as_profile');
  168. }
  169. /**
  170. * Get profile status
  171. */
  172. public function getStatus($iProfileId = false)
  173. {
  174. $aInfo = $this->_oQuery->getInfoById((int)$iProfileId ? $iProfileId : $this->_iProfileID);
  175. return $aInfo['status'];
  176. }
  177. /**
  178. * Get profile module name
  179. */
  180. public function getModule($iProfileId = false)
  181. {
  182. $aInfo = $this->_oQuery->getInfoById((int)$iProfileId ? $iProfileId : $this->_iProfileID);
  183. return $aInfo['type'];
  184. }
  185. /**
  186. * Get profile info
  187. */
  188. public function getInfo($iProfileId = 0)
  189. {
  190. if ($iProfileId && $iProfileId != $this->_iProfileID)
  191. return $this->_oQuery->getInfoById((int)$iProfileId ? $iProfileId : $this->_iProfileID);
  192. if ($this->_aProfile)
  193. return $this->_aProfile;
  194. $this->_aProfile = $this->_oQuery->getInfoById((int)$iProfileId ? $iProfileId : $this->_iProfileID);
  195. return $this->_aProfile;
  196. }
  197. /**
  198. * Validate profile id.
  199. * @param $s - profile id
  200. * @return profile id or false if profile was not found
  201. */
  202. static public function getID($s)
  203. {
  204. $iId = BxDolProfileQuery::getInstance()->getIdById((int)$s);
  205. return $iId ? $iId : false;
  206. }
  207. /**
  208. * Get name to display in thumbnail
  209. */
  210. public function getDisplayName($iProfileId = 0)
  211. {
  212. $aInfo = $this->getInfo($iProfileId);
  213. $sDisplayName = BxDolService::call($aInfo['type'], 'profile_name', array($aInfo['content_id']));
  214. bx_alert('profile', 'profile_name', $iProfileId, 0, array('info' => $aInfo, 'display_name' => &$sDisplayName));
  215. return $sDisplayName;
  216. }
  217. /**
  218. * Get profile url
  219. */
  220. public function getUrl($iProfileId = 0)
  221. {
  222. $aInfo = $this->getInfo($iProfileId);
  223. return BxDolService::call($aInfo['type'], 'profile_url', array($aInfo['content_id']));
  224. }
  225. /**
  226. * Get profile unit
  227. */
  228. public function getUnit($iProfileId = 0, $aParams = array())
  229. {
  230. $aInfo = $this->getInfo($iProfileId);
  231. return BxDolService::call($aInfo['type'], 'profile_unit', array($aInfo['content_id'], $aParams));
  232. }
  233. /**
  234. * Get badges
  235. */
  236. public function getBadges($iProfileId = 0)
  237. {
  238. $aInfo = $this->getInfo($iProfileId);
  239. return BxDolService::call($aInfo['type'], 'get_badges', array($aInfo['content_id'], false, true));
  240. }
  241. /**
  242. * Check whether a profile has real image uploaded by user.
  243. */
  244. public function hasImage($iProfileId = 0)
  245. {
  246. $aInfo = $this->getInfo($iProfileId);
  247. return BxDolService::call($aInfo['type'], 'has_image', array($aInfo['content_id']));
  248. }
  249. /**
  250. * Get picture url
  251. */
  252. public function getPicture($iProfileId = 0)
  253. {
  254. $aInfo = $this->getInfo($iProfileId);
  255. return BxDolService::call($aInfo['type'], 'profile_picture', array($aInfo['content_id']));
  256. }
  257. /**
  258. * Get avatar url
  259. */
  260. public function getAvatar($iProfileId = 0)
  261. {
  262. $aInfo = $this->getInfo($iProfileId);
  263. return BxDolService::call($aInfo['type'], 'profile_avatar', array($aInfo['content_id']));
  264. }
  265. /**
  266. * Get big (2x) avatar url
  267. */
  268. public function getAvatarBig($iProfileId = 0)
  269. {
  270. $aInfo = $this->getInfo($iProfileId);
  271. return BxDolService::call($aInfo['type'], 'profile_avatar_big', array($aInfo['content_id']));
  272. }
  273. /**
  274. * Get cover url
  275. */
  276. public function getCover($iProfileId = 0)
  277. {
  278. $aInfo = $this->getInfo($iProfileId);
  279. return BxDolService::call($aInfo['type'], 'profile_cover', array($aInfo['content_id']));
  280. }
  281. /**
  282. * Get unit cover url
  283. */
  284. public function getUnitCover($iProfileId = 0)
  285. {
  286. $aInfo = $this->getInfo($iProfileId);
  287. return BxDolService::call($aInfo['type'], 'profile_unit_cover', array($aInfo['content_id']));
  288. }
  289. /**
  290. * Get thumbnail url
  291. */
  292. public function getThumb($iProfileId = 0)
  293. {
  294. $aInfo = $this->getInfo($iProfileId);
  295. return BxDolService::call($aInfo['type'], 'profile_thumb', array($aInfo['content_id']));
  296. }
  297. /**
  298. * Get icon url
  299. */
  300. public function getIcon($iProfileId = 0)
  301. {
  302. $aInfo = $this->getInfo($iProfileId);
  303. return BxDolService::call($aInfo['type'], 'profile_icon', array($aInfo['content_id']));
  304. }
  305. /**
  306. * Get module icon
  307. */
  308. public function getIconModule($iProfileId = 0)
  309. {
  310. $aInfo = $this->getInfo($iProfileId);
  311. return BxDolService::call($aInfo['type'], 'module_icon');
  312. }
  313. /**
  314. * get profile edit page url
  315. */
  316. public function getEditUrl($iProfileId = 0)
  317. {
  318. $aInfo = $this->getInfo($iProfileId);
  319. return BxDolService::call($aInfo['type'], 'profile_edit_url', array($aInfo['content_id']));
  320. }
  321. /**
  322. * @see iBxDolProfile::checkAllowedProfileView
  323. */
  324. public function checkAllowedProfileView($iProfileId = 0)
  325. {
  326. $aInfo = $this->getInfo($iProfileId);
  327. return BxDolService::call($aInfo['type'], 'check_allowed_profile_view', array($aInfo['content_id']));
  328. }
  329. /**
  330. * @see iBxDolProfile::checkAllowedProfileContact
  331. */
  332. public function checkAllowedProfileContact($iProfileId = 0)
  333. {
  334. $aInfo = $this->getInfo($iProfileId);
  335. return BxDolService::call($aInfo['type'], 'check_allowed_profile_contact', array($aInfo['content_id']));
  336. }
  337. /**
  338. * @see iBxDolProfile::checkAllowedPostInProfile
  339. */
  340. public function checkAllowedPostInProfile($iProfileId = 0, $sPostModule = '')
  341. {
  342. $aInfo = $this->getInfo($iProfileId);
  343. return BxDolService::call($aInfo['type'], 'check_allowed_post_in_profile', array($aInfo['content_id'], $sPostModule));
  344. }
  345. /**
  346. * Delete profile.
  347. * @param $ID - optional profile id to delete
  348. * @param $bDeleteWithContent - delete profile with all its contents
  349. * @param $bForceDelete - force deletetion is case of account profile deletion
  350. * @return false on error, or true on success
  351. */
  352. function delete($ID = false, $bDeleteWithContent = false, $bForceDelete = false)
  353. {
  354. $ID = (int)$ID;
  355. if (!$ID)
  356. $ID = $this->_iProfileID;
  357. $aProfileInfo = $this->_oQuery->getInfoById($ID);
  358. if (!$aProfileInfo)
  359. return false;
  360. // delete system profiles (accounts) is not allowed, instead - delete whole account
  361. if (!$bForceDelete && 'system' == $aProfileInfo['type'])
  362. return false;
  363. // delete actual profile
  364. if ($sErrorMsg = BxDolService::call($aProfileInfo['type'] , 'delete_entity_service', array($aProfileInfo['content_id'], $bDeleteWithContent)))
  365. return false;
  366. // switch profile context if deleted profile is active profile context
  367. $oAccount = BxDolAccount::getInstance ($aProfileInfo['account_id']);
  368. $aAccountInfo = $oAccount->getInfo();
  369. if (!$bForceDelete && $ID == $aAccountInfo['profile_id'])
  370. $oAccount->updateProfileContextAuto($ID);
  371. // create system event before deletion
  372. $isStopDeletion = false;
  373. bx_alert('profile', 'before_delete', $ID, 0, array('delete_with_content' => $bDeleteWithContent, 'stop_deletion' => &$isStopDeletion, 'type' => $aProfileInfo['type']));
  374. if ($isStopDeletion)
  375. return false;
  376. // delete associated content
  377. if($bDeleteWithContent) {
  378. BxDolCmts::onAuthorDelete($ID);
  379. BxDolReport::onAuthorDelete($ID);
  380. BxDolVote::onAuthorDelete($ID);
  381. BxDolFavorite::onAuthorDelete($ID);
  382. BxDolView::onAuthorDelete($ID);
  383. }
  384. // delete connections
  385. $oConn = BxDolConnection::getObjectInstance('sys_profiles_friends');
  386. $oConn->onDeleteInitiatorAndContent($ID);
  387. $oConn = BxDolConnection::getObjectInstance('sys_profiles_subscriptions');
  388. $oConn->onDeleteInitiatorAndContent($ID);
  389. // delete profile's acl levels
  390. BxDolAcl::getInstance()->onProfileDelete($ID);
  391. // delete SEO links
  392. BxDolPage::deleteSeoLinkByParam ('profile_id', $ID);
  393. // delete profile
  394. if (!$this->_oQuery->delete($ID))
  395. return false;
  396. // create system event
  397. bx_alert('profile', 'delete', $ID, 0, array('delete_with_content' => $bDeleteWithContent, 'type' => $aProfileInfo['type']));
  398. // unset class instance to prevent creating the instance again
  399. $this->_iProfileID = 0;
  400. $sClass = get_class($this) . '_' . $ID;
  401. unset($GLOBALS['bxDolClasses'][$sClass]);
  402. return true;
  403. }
  404. /**
  405. * Insert account and content id association. Also if currect profile id is not defined - it updates current profile id in account.
  406. * @param $iAccountId account id
  407. * @param $iContentId content id
  408. * @param $sStatus profile status
  409. * @param $sType profile content type
  410. * @return inserted profile's id
  411. */
  412. static public function add ($iAction, $iAccountId, $iContentId, $sStatus, $sType = 'system')
  413. {
  414. $oQuery = BxDolProfileQuery::getInstance();
  415. if (!($iProfileId = $oQuery->insertProfile ($iAccountId, $iContentId, $sStatus, $sType)))
  416. return false;
  417. bx_alert('profile', 'add', $iProfileId, 0, array('module' => $sType, 'content' => $iContentId, 'account' => $iAccountId, 'status' => $sStatus, 'action' => $iAction, 'profile_id' => &$iProfileId));
  418. return $iProfileId;
  419. }
  420. /**
  421. * Change profile status to 'Active'
  422. */
  423. public function activate($iAction, $iProfileId = 0, $bSendEmailNotification = true)
  424. {
  425. $sStatus = $this->getStatus($iProfileId);
  426. return $this->changeStatus(BX_PROFILE_STATUS_ACTIVE, BX_PROFILE_STATUS_PENDING == $sStatus ? 'approve' : 'activate', $iAction, $iProfileId, $bSendEmailNotification);
  427. }
  428. /**
  429. * Change profile status from 'Pending' to the next level - 'Active'
  430. */
  431. public function approve($iAction, $iProfileId = 0, $bSendEmailNotification = true)
  432. {
  433. return $this->changeStatus(BX_PROFILE_STATUS_ACTIVE, 'approve', $iAction, $iProfileId, $bSendEmailNotification);
  434. }
  435. /**
  436. * Change profile status to 'Pending'
  437. */
  438. public function disapprove($iAction, $iProfileId = 0, $bSendEmailNotification = true)
  439. {
  440. return $this->changeStatus(BX_PROFILE_STATUS_PENDING, 'disapprove', $iAction, $iProfileId, $bSendEmailNotification);
  441. }
  442. public function doAudit($sAction, $aData = array())
  443. {
  444. bx_audit(
  445. $this->getContentId(),
  446. $this->getModule(),
  447. $sAction,
  448. array('content_title' => $this->getDisplayName(), 'data' => $aData)
  449. );
  450. }
  451. /**
  452. * Change profile status to 'Suspended'
  453. */
  454. public function suspend($iAction, $iProfileId = 0, $bSendEmailNotification = true)
  455. {
  456. if (!$iProfileId)
  457. $iProfileId = $this->_iProfileID;
  458. //moderators shouldn't be able to suspend other moderators and admins
  459. if (BxDolAcl::getInstance()->isMemberLevelInSet(array(MEMBERSHIP_ID_MODERATOR), bx_get_logged_profile_id()) && BxDolAcl::getInstance()->isMemberLevelInSet(array(MEMBERSHIP_ID_MODERATOR, MEMBERSHIP_ID_ADMINISTRATOR), $iProfileId))
  460. return false;
  461. return $this->changeStatus(BX_PROFILE_STATUS_SUSPENDED, 'suspend', $iAction, $iProfileId, $bSendEmailNotification);
  462. }
  463. protected function changeStatus($sStatus, $sAlertActionName, $iAction, $iProfileId = 0, $bSendEmailNotification = true)
  464. {
  465. if (!$iProfileId)
  466. $iProfileId = $this->_iProfileID;
  467. // get account and profile objects
  468. $oProfile = BxDolProfile::getInstance($iProfileId);
  469. $oAccount = $oProfile->getAccountObject();
  470. if (!$oProfile || !$oAccount)
  471. return false;
  472. // change status
  473. if (!$this->_oQuery->changeStatus($iProfileId, $sStatus))
  474. return false;
  475. $this->_aProfile = array();
  476. // alert about status changing
  477. bx_alert('profile', $sAlertActionName, $iProfileId, false, array('action' => $iAction, 'status' => &$sStatus, 'send_email_notification' => &$bSendEmailNotification));
  478. $this->doAudit('_sys_audit_action_set_status_' . $sStatus);
  479. // send email to member about status change
  480. if ($bSendEmailNotification)
  481. sendMailTemplate('t_ChangeStatus' . ucfirst($sStatus), $oAccount->id(), $iProfileId, array('status' => $sStatus), BX_EMAIL_SYSTEM);
  482. return true;
  483. }
  484. /**
  485. * Display informer message if it is possible to switch to this profile
  486. */
  487. public function checkSwitchToProfile($oTemplate = null, $iViewerAccountId = false, $iViewerProfileId = false)
  488. {
  489. if (false === $iViewerAccountId)
  490. $iViewerAccountId = getLoggedId();
  491. if (false === $iViewerProfileId)
  492. $iViewerProfileId = bx_get_logged_profile_id();
  493. if (!$iViewerAccountId || !$iViewerProfileId)
  494. return;
  495. $aCheck = checkActionModule($iViewerProfileId, 'switch to any profile', 'system', false);
  496. $bAllowSwitchToAnyProfile = $aCheck[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED;
  497. $iSwitchToAccountId = $this->getAccountId();
  498. $iSwitchToProfileId = $this->id();
  499. $bCanSwitch = ($iSwitchToAccountId == $iViewerAccountId || $bAllowSwitchToAnyProfile);
  500. bx_alert('account', 'check_switch_context', $iSwitchToAccountId, $iViewerProfileId, array('switch_to_profile' => $iSwitchToProfileId, 'viewer_account' => $iViewerAccountId, 'override_result' => &$bCanSwitch));
  501. if (!$bCanSwitch || $iViewerProfileId == $iSwitchToProfileId)
  502. return;
  503. $oInformer = BxDolInformer::getInstance($oTemplate);
  504. if ($oInformer){
  505. if ($iSwitchToAccountId == $iViewerAccountId){
  506. $oInformer->add('sys-switch-profile-context', _t('_sys_txt_account_profile_context_change_suggestion', BxDolPermalinks::getInstance()->permalink('page.php?i=account-profile-switcher', array('switch_to_profile' => $this->id(), 'redirect_back' => 1))), BX_INFORMER_INFO);
  507. }
  508. else{
  509. $oInformer->add('sys-switch-profile-context', _t('_sys_txt_account_profile_context_change_to_another_suggestion', BxDolPermalinks::getInstance()->permalink('page.php?i=account-profile-switcher', array('switch_to_profile' => $this->id(), 'redirect_back' => 1))), BX_INFORMER_INFO);
  510. }
  511. }
  512. }
  513. /**
  514. * Add permament messages.
  515. */
  516. public function addInformerPermanentMessages ($oInformer)
  517. {
  518. $aInfo = $this->getInfo();
  519. $aProfiles = $this->_oQuery->getProfilesByAccount($aInfo['account_id']);
  520. if ($aInfo['type'] == 'system' && count($aProfiles) == 1) {
  521. $sUrl = BxDolPermalinks::getInstance()->permalink('page.php?i=account-profile-switcher');
  522. $oInformer->add('sys-account-profile-system', _t('_sys_txt_account_profile_system', $sUrl), BX_INFORMER_ALERT);
  523. }
  524. }
  525. }
  526. /** @} */