/** * page code function */ function PageCompMainCode() { ob_start(); $oAccount = BxDolAccount::getInstance(); $aAccountInfo = $oAccount ? $oAccount->getInfo() : false; if (!$aAccountInfo) { return DesignBoxContent("Send Email example", 'Please login first', BX_DB_PADDING_DEF); } echo "<h2>Account info</h2>"; echo "Email: " . $aAccountInfo['email'] . '<br />'; echo "Email Confirmed: " . ($aAccountInfo['email_confirmed'] ? 'yes' : 'no') . '<br />'; echo "Receive site updates: " . ($aAccountInfo['receive_updates'] ? 'yes' : 'no') . '<br />'; echo "Receive site newsletters: " . ($aAccountInfo['receive_news'] ? 'yes' : 'no') . '<br />'; echo "Site emails are sent from: " . getParam('site_email_notify') . '<br />'; $a = array('sys' => array('title' => "Send me system email", 'type' => BX_EMAIL_SYSTEM, 'subj' => 'System Email', 'body' => 'This is system email <br /> {unsubscribe}'), 'notif' => array('title' => "Send me notification", 'type' => BX_EMAIL_NOTIFY, 'subj' => 'Notification Email', 'body' => 'This is notification email<br /> {unsubscribe}'), 'mass' => array('title' => "Send me bulk email", 'type' => BX_EMAIL_MASS, 'subj' => 'Bulk Email', 'body' => 'This is bulk email<br /> {unsubscribe}')); $sSendMail = bx_get('send'); if ($sSendMail && isset($a[$sSendMail])) { echo "<h2>Send Email Result</h2>"; $r = $a[$sSendMail]; if (sendMail($aAccountInfo['email'], $r['subj'], $r['body'], 0, array(), $r['type'])) { echo MsgBox($r['subj'] . ' - successfully sent'); } else { echo MsgBox($r['subj'] . ' - sent failed'); } } echo "<h2>Send email</h2>"; foreach ($a as $k => $r) { echo '<a href="samples/email.php?send=' . $k . '">' . $r['title'] . '</a><br />'; } return DesignBoxContent("Send Email Example", ob_get_clean(), BX_DB_PADDING_DEF); }
public function _serviceProfileFunc($sFunc, $iContentId) { if (!$iContentId) { return false; } if (!($oAccount = BxDolAccount::getInstance($iContentId))) { return false; } return $oAccount->{$sFunc}(); }
public function __construct($iAccoutId = 0) { parent::__construct(); $sKey = getParam('bx_antispam_akismet_api_key'); if ($sKey && ($oAccount = BxDolAccount::getInstance((int) $iAccoutId))) { require_once BX_DIRECTORY_PATH_PLUGINS . 'akismet/Akismet.class.php'; $this->oAkismet = new Akismet(BX_DOL_URL_ROOT, $sKey); $oProfile = BxDolProfile::getInstanceByAccount((int) $iAccoutId); $this->oAkismet->setCommentAuthorEmail($oAccount->getEmail()); $this->oAkismet->setCommentAuthor($oProfile->getDisplayName()); $this->oAkismet->setCommentAuthorURL($oProfile->getUrl()); } }
/** * Check if email is uniq. */ function checkEmailUniq($s) { if (!$this->checkEmail($s)) { return false; } $oAccount = BxDolAccount::getInstance(); if ($oAccount) { // user is logged in $aAccountInfo = $oAccount->getInfo(); if ($s == $aAccountInfo['email']) { // don't check email for uniq, if it wasn't changed return true; } return BxDolAccountQuery::getInstance()->getIdByEmail($s) ? _t('_sys_form_account_input_email_uniq_error_loggedin') : true; } return BxDolAccountQuery::getInstance()->getIdByEmail($s) ? _t('_sys_form_account_input_email_uniq_error', BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=forgot-password')) : true; }
public function __construct($aObject, $oTemplate) { parent::__construct($aObject, $oTemplate); bx_import('BxDolProfile'); $oProfile = BxDolProfile::getInstance(); $aProfileInfo = $oProfile ? $oProfile->getInfo() : false; $this->addMarkers(array('account_id' => $aProfileInfo ? $aProfileInfo['account_id'] : 0, 'profile_id' => $aProfileInfo ? $aProfileInfo['id'] : 0, 'profile_type' => $aProfileInfo ? $aProfileInfo['type'] : 0, 'profile_content_id' => $aProfileInfo ? $aProfileInfo['content_id'] : 0)); // set settings submenu bx_import('BxDolMenu'); $oMenuSubmenu = BxDolMenu::getObjectInstance('sys_site_submenu'); if ($oMenuSubmenu) { $oMenuSubmenu->setObjectSubmenu('sys_account_settings_submenu', array('title' => _t('_sys_menu_item_title_account_settings'), 'link' => BX_DOL_URL_ROOT . 'member.php', 'icon' => '')); } // display message if profile isn't active if ($oProfile) { $sStatus = $oProfile->getStatus(); if (isset($this->_aMapStatus2LangKey[$sStatus])) { bx_import('BxDolInformer'); $oInformer = BxDolInformer::getInstance($this->_oTemplate); if ($oInformer) { $oInformer->add('sys-account-status-not-active', _t($this->_aMapStatus2LangKey[$sStatus]), BX_INFORMER_ALERT); } } } // switch profile context if ($iSwitchToProfileId = (int) bx_get('switch_to_profile')) { bx_import('BxDolInformer'); $oInformer = BxDolInformer::getInstance($this->_oTemplate); $oProfile = BxDolProfile::getInstance($iSwitchToProfileId); $sInformerMsg = ''; if ($oProfile && $oProfile->getAccountId() == getLoggedId()) { bx_import('BxDolProfile'); $oAccount = BxDolAccount::getInstance(); if ($oAccount->updateProfileContext($iSwitchToProfileId)) { $sInformerMsg = _t('_sys_txt_account_profile_context_changed_success', $oProfile->getDisplayName()); } } if ($oInformer) { $oInformer->add('sys-account-profile-context-change-result', $sInformerMsg ? $sInformerMsg : _t('_error occured'), $sInformerMsg ? BX_INFORMER_INFO : BX_INFORMER_ERROR); } } }
protected function _editAccountForm($iAccountId, $sDisplayName) { $oAccount = BxDolAccount::getInstance($iAccountId); $aAccountInfo = $oAccount ? $oAccount->getInfo() : false; if (!$aAccountInfo) { return MsgBox(_t('_sys_txt_error_account_is_not_defined')); } // check access if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = BxDolAccount::isAllowedEdit($this->_iProfileId, $aAccountInfo))) { return MsgBox($sMsg); } // check and display form $oForm = BxDolForm::getObjectInstance('sys_account', $sDisplayName); if (!$oForm) { return MsgBox(_t('_sys_txt_error_occured')); } if (!$oForm->isSubmitted()) { unset($aAccountInfo['password']); } $oForm->initChecker($aAccountInfo); if (!$oForm->isSubmittedAndValid()) { return $oForm->getCode(); } $aTrackTextFieldsChanges = array(); // track text fields changes, not-null(for example empty array) - means track, null - means don't track // update email and email setting in DB if (!$oForm->update($aAccountInfo['id'], array(), $aTrackTextFieldsChanges)) { if (!$oForm->isValid()) { return $oForm->getCode(); } else { return MsgBox(_t('_sys_txt_error_account_update')); } } // check if email was changed if (!empty($aTrackTextFieldsChanges['changed_fields']) && in_array('email', $aTrackTextFieldsChanges['changed_fields'])) { $oAccount->updateEmailConfirmed(false); } // mark email as unconfirmed // check if password was changed if ($oForm->getCleanValue('password')) { // relogin with new password bx_logout(); bx_login($aAccountInfo['id']); } // check if other text info was changed - if auto-appproval is off $isAutoApprove = $oForm->isSetPendingApproval() ? false : true; if (!$isAutoApprove) { bx_import('BxDolProfile'); $oProfile = BxDolProfile::getInstanceAccountProfile($aAccountInfo['id']); // get profile associated with account, not current porfile $aProfileInfo = $oProfile->getInfo(); unset($aTrackTextFieldsChanges['changed_fields']['email']); // email confirmation is automatic and separate, don't need to deactivate whole profile if email is changed if (BX_PROFILE_STATUS_ACTIVE == $aProfileInfo['status'] && !empty($aTrackTextFieldsChanges['changed_fields'])) { $oProfile->disapprove(BX_PROFILE_ACTION_AUTO); } // change profile to 'pending' only if some text fields were changed and profile is active } // create an alert bx_alert('account', 'edited', $aAccountInfo['id'], $aAccountInfo['id'], array('display' => $sDisplayName)); // display result message $sMsg = MsgBox(_t('_sys_txt_data_successfully_submitted')); return $sMsg . $oForm->getCode(); }
protected function _doDelete($iId, $aParams = array()) { return BxDolAccount::getInstance($iId)->delete(isset($aParams['with_content']) && $aParams['with_content'] === true); }
protected function getMemberMembershipInfoCurrent($iProfileId, $iTime = 0) { $aMemLevel = false; // get profile status $oProfile = BxDolProfile::getInstance($iProfileId); $aProfileInfo = $oProfile ? $oProfile->getInfo() : false; $sProfileStatus = $aProfileInfo ? $aProfileInfo['status'] : false; $sProfileType = $aProfileInfo ? $aProfileInfo['type'] : false; // account profile if ($sProfileType == 'system') { $aMemLevel = $this->oDb->getLevelByIdCached(MEMBERSHIP_ID_ACCOUNT); if (!$aMemLevel) { trigger_error('Standard member level is missing: ' . MEMBERSHIP_ID_ACCOUNT, E_USER_ERROR); } return $aMemLevel; } // profile is not active, so return standard memberships according to profile status if (BX_PROFILE_STATUS_ACTIVE != $sProfileStatus) { $oAccount = $aProfileInfo ? BxDolAccount::getInstance($aProfileInfo['account_id']) : false; if ($oAccount && !$oAccount->isConfirmed()) { $iLevelId = MEMBERSHIP_ID_UNCONFIRMED; } elseif (!isset($this->_aProfileStatus2LevelMap[$sProfileStatus])) { $iLevelId = MEMBERSHIP_ID_NON_MEMBER; } else { $iLevelId = $this->_aProfileStatus2LevelMap[$sProfileStatus]; } // get member level id which associated with every non-active status $aMemLevel = $this->oDb->getLevelByIdCached($iLevelId); if (!$aMemLevel) { trigger_error('Standard member level is missing: ' . $iLevelId, E_USER_ERROR); } return $aMemLevel; } // profile is active get memebr level from profile $aMemLevel = $this->oDb->getLevelCurrent((int) $iProfileId, $iTime); // There are no purchased/assigned memberships for the profile or all of them have expired. // In this case the profile is assumed to have Standard membership. if (!$aMemLevel || is_null($aMemLevel['id'])) { $aMemLevel = $this->oDb->getLevelByIdCached(MEMBERSHIP_ID_STANDARD); if (!$aMemLevel) { trigger_error('Standard member level is missing: ' . MEMBERSHIP_ID_NON_MEMBER, E_USER_ERROR); } } return $aMemLevel; }
/** * Check encrypted password (ex., from Cookie) * @return empty string on success or error string on error */ function bx_check_login($iID, $sPassword, $iRole = BX_DOL_ROLE_MEMBER) { bx_import('BxDolAccount'); $oAccount = BxDolAccount::getInstance((int) $iID); // If no such account available if (!$oAccount) { bx_import('BxDolLanguages'); return _t("_sys_txt_login_error"); } $aAccountInfo = $oAccount->getInfo(); // If password is incorrect if (strcmp($aAccountInfo['password'], $sPassword) != 0) { bx_import('BxDolLanguages'); return _t("_sys_txt_login_error"); } // If wrong account role if (!((int) $aAccountInfo['role'] & $iRole)) { bx_import('BxDolLanguages'); return _t("_sys_txt_login_invalid_role"); } return ''; }
if (isset($_POST['ID'])) { // login form is submitted bx_import('BxDolForm'); $oForm = BxDolForm::getObjectInstance('sys_login', 'sys_login'); bx_alert('account', 'before_login', 0, 0, array('form' => $oForm)); $oForm->initChecker(); $oForm->setRole(bx_get('role')); $bLoginSuccess = $oForm->isSubmittedAndValid(); $bAjxMode = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ? true : false; if ($bAjxMode) { header('Content-type: text/html; charset=utf-8'); echo $bLoginSuccess ? 'OK' : $oForm->getLoginError(); exit; } elseif ($bLoginSuccess) { bx_import('BxDolAccount'); $oAccount = BxDolAccount::getInstance($oForm->getCleanValue('ID')); $aAccount = bx_login($oAccount->id(), $oForm->getCleanValue('rememberMe') ? true : false); $sUrlRelocate = $oForm->getCleanValue('relocate'); if (!$sUrlRelocate || 0 != strncmp($sUrlRelocate, BX_DOL_URL_ROOT, strlen(BX_DOL_URL_ROOT))) { $sUrlRelocate = BX_DOL_ROLE_ADMIN == $oForm->getRole() ? BX_DOL_URL_STUDIO . 'launcher.php' : BX_DOL_URL_ROOT . 'member.php'; } bx_import('BxDolTemplate'); BxDolTemplate::getInstance()->setPageNameIndex(BX_PAGE_TRANSITION); BxDolTemplate::getInstance()->setPageHeader(_t('_Please Wait')); BxDolTemplate::getInstance()->setPageContent('page_main_code', MsgBox(_t('_Please Wait'))); BxDolTemplate::getInstance()->setPageContent('url_relocate', bx_html_attribute($sUrlRelocate, BX_ESCAPE_STR_QUOTE)); BxDolTemplate::getInstance()->getPageCode(); exit; } } bx_require_authentication();
public function processModules($a) { $aTypes = array(BX_DOL_MODULE_TYPE_LANGUAGE, BX_DOL_MODULE_TYPE_TEMPLATE, BX_DOL_MODULE_TYPE_MODULE); foreach ($aTypes as $sModuleType) { if (empty($a[$sModuleType])) { continue; } $sErrorMessage = $this->processModuleByUri($a[$sModuleType], array('install', 'enable'), $sModuleType); if ($sErrorMessage) { return array(BX_INSTALL_ERR_GENERAL => $sErrorMessage); } } bx_import('BxDolAccount'); $oAccount = BxDolAccount::getInstance($a['admin_email']); if (!$oAccount) { return array(BX_INSTALL_ERR_GENERAL => _t('_sys_inst_msg_admin_account_not_found', $a['admin_email'])); } if ($this->_isAutologin) { bx_login($oAccount->id()); } return array(); }
function actionAuth() { $oRequest = OAuth2\Request::createFromGlobals(); $oResponse = new OAuth2\Response(); // validate the authorize request if (!$this->_oServer->validateAuthorizeRequest($oRequest, $oResponse)) { require_once BX_DIRECTORY_PATH_INC . 'design.inc.php'; $o = json_decode($oResponse->getResponseBody()); $this->_oTemplate->getPage(false, MsgBox($o->error_description)); } if (!isLogged()) { require_once BX_DIRECTORY_PATH_INC . 'design.inc.php'; $sForceRelocate = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'auth/?client_id=' . bx_get('client_id') . '&response_type=' . bx_get('response_type') . '&state=' . bx_get('state') . '&redirect_uri=' . bx_get('redirect_uri'); bx_login_form(false, false, $sForceRelocate); return; } $aProfiles = BxDolAccount::getInstance()->getProfiles(); if (!($iProfileId = $this->_oDb->getSavedProfile($aProfiles)) && empty($_POST)) { $oPage = BxDolPage::getObjectInstanceByURI('oauth-authorization'); $this->_oTemplate->getPage(false, $oPage->getCode()); return; } if (!$iProfileId) { $iProfileId = bx_get('profile_id'); } $this->_oServer->handleAuthorizeRequest($oRequest, $oResponse, (bool) $iProfileId, $iProfileId); $oResponse->send(); }
protected function onDataAddAfter($iContentId) { $CNF =& $this->_oModule->_oConfig->CNF; // add account and content association $iProfileId = BxDolProfile::add(BX_PROFILE_ACTION_MANUAL, getLoggedId(), $iContentId, BX_PROFILE_STATUS_PENDING, $this->_oModule->getName()); $oProfile = BxDolProfile::getInstance($iProfileId); // approve profile if auto-approval is enabled and profile status is 'pending' $sStatus = $oProfile->getStatus(); $isAutoApprove = getParam($CNF['PARAM_AUTOAPPROVAL']) ? true : false; if ($sStatus == BX_PROFILE_STATUS_PENDING && $isAutoApprove) { $oProfile->approve(BX_PROFILE_ACTION_AUTO); } // set created profile some default membership bx_import('BxDolAcl'); $iAclLevel = getParam($CNF['PARAM_DEFAULT_ACL_LEVEL']); BxDolAcl::getInstance()->setMembership($iProfileId, $iAclLevel, 0, true); // alert bx_alert($this->_oModule->getName(), 'added', $iContentId); // switch context to the created profile bx_import('BxDolAccount'); $oAccount = BxDolAccount::getInstance(); $oAccount->updateProfileContext($iProfileId); return ''; }
/** * Create new profile; * * @param : $aProfileInfo (array) - remote profile's information; * * @param : $sAlternativeName (string) - profiles alternative nickname; * @return : error string or error or request invite form or profile info array on success */ function _createProfileRaw($aProfileInfo, $sAlternativeName = '', $isAutoFriends = true, $isSetLoggedIn = true) { // join by invite only if (BxDolRequest::serviceExists('bx_invites', 'account_add_form_check') && ($sCode = BxDolService::call('bx_invites', 'account_add_form_check'))) { return $sCode; } // convert fields to unique format $aFieldsProfile = $aFieldsAccount = $this->_convertRemoteFields($aProfileInfo, $sAlternativeName); if (empty($aFieldsProfile['email'])) { return _t('_Incorrect Email'); } // prepare fields for particular module $aFieldsAccount = BxDolService::call('system', 'prepare_fields', array($aFieldsAccount)); $aFieldsProfile = BxDolService::call($this->_oConfig->sProfilesModule, 'prepare_fields', array($aFieldsProfile)); // check fields existence in Account $oFormHelperAccount = BxDolService::call('system', 'forms_helper'); $oFormAccount = $oFormHelperAccount->getObjectFormAdd(); foreach ($aFieldsAccount as $sKey => $mValue) { if (!$oFormAccount->isFieldExist($sKey)) { unset($aFieldsAccount[$sKey]); } } // check fields existence in Profile if ('system' != $this->_oConfig->sProfilesModule && ($oFormHelperProfile = BxDolService::call($this->_oConfig->sProfilesModule, 'forms_helper'))) { $oFormProfile = $oFormHelperProfile->getObjectFormAdd(); foreach ($aFieldsProfile as $sKey => $mValue) { if (!$oFormProfile->isFieldExist($sKey)) { unset($aFieldsProfile[$sKey]); } } } // antispam check $sErrorMsg = ''; $bSetPendingApproval = false; bx_alert('account', 'check_join', 0, false, array('error_msg' => &$sErrorMsg, 'email' => $aFieldsAccount['email'], 'approve' => &$bSetPendingApproval)); if ($sErrorMsg) { return $sErrorMsg; } // check if user with the same email already exists $oExistingAccount = BxDolAccount::getInstance($aFieldsAccount['email']); // check redirect page if ('join' == $this->_oConfig->sRedirectPage && !$oExistingAccount) { return array('remote_profile_info' => $aProfileInfo, 'profile_fields' => $aFieldsAccount, 'join_page_redirect' => true); } // create new profile if ($oExistingAccount) { if (!($oExistingProfile = BxDolProfile::getInstanceByAccount($oExistingAccount->id()))) { return _t('_sys_txt_error_account_creation'); } $iProfileId = $oExistingProfile->id(); $this->setLogged($iProfileId); } else { // create account $aFieldsAccount['password'] = genRndPwd(); $aFieldsAccount['email_confirmed'] = $this->_oConfig->isAlwaysConfirmEmail; if (!($iAccountId = $oFormAccount->insert($aFieldsAccount))) { return _t('_sys_txt_error_account_creation'); } $isSetPendingApproval = $this->_oConfig->isAlwaysAutoApprove ? false : !(bool) getParam('sys_account_autoapproval'); $iAccountProfileId = $oFormHelperAccount->onAccountCreated($iAccountId, $isSetPendingApproval, BX_PROFILE_ACTION_EXTERNAL); // create profile if (isset($oFormProfile) && $oFormProfile) { $aFieldsProfile['picture'] = $this->_processImage($aFieldsProfile, $iAccountProfileId, $oFormHelperProfile); if (!($iContentId = $oFormProfile->insert($aFieldsProfile))) { return _t('_sys_txt_error_account_creation'); } $oFormHelperProfile->setAutoApproval($oFormHelperProfile->isAutoApproval() ? true : $this->_oConfig->isAlwaysAutoApprove); if ($sErrorMsg = $oFormHelperProfile->onDataAddAfter($iAccountId, $iContentId)) { return $sErrorMsg; } $oProfile = BxDolProfile::getInstanceByAccount($iAccountId); $iProfileId = $oProfile->id(); } else { $iProfileId = $iAccountProfileId; } // send email with password sendMailTemplate($this->_oConfig->sEmailTemplatePasswordGenerated, $iAccountId, $iProfileId, array('password' => $aFieldsAccount['password']), BX_EMAIL_SYSTEM); } // remember remote profile id for created member $this->_oDb->saveRemoteId($iProfileId, $aProfileInfo['id']); // auto-friend members if they are already friends on remote site if ($isAutoFriends && method_exists($this, '_makeFriends')) { $this->_makeFriends($iProfileId); } return array('remote_profile_info' => $aProfileInfo, 'profile_id' => $iProfileId, 'existing_profile' => $oExistingAccount ? true : false); }
bx_import('BxDolLanguages'); if (isset($_POST['ID'])) { // login form is submitted $oForm = BxDolForm::getObjectInstance('sys_login', 'sys_login'); bx_alert('account', 'before_login', 0, 0, array('form' => $oForm)); $oForm->initChecker(); $oForm->setRole(bx_get('role')); $bLoginSuccess = $oForm->isSubmittedAndValid(); $bAjxMode = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ? true : false; if ($bAjxMode) { header('Content-type: text/html; charset=utf-8'); echo $bLoginSuccess ? 'OK' : $oForm->getLoginError(); exit; } elseif ($bLoginSuccess) { $sId = trim($oForm->getCleanValue('ID')); $oAccount = BxDolAccount::getInstance($sId); $aAccount = bx_login($oAccount->id(), $oForm->getCleanValue('rememberMe') ? true : false); $sUrlRelocate = $oForm->getCleanValue('relocate'); if (!$sUrlRelocate || 0 != strncmp($sUrlRelocate, BX_DOL_URL_ROOT, strlen(BX_DOL_URL_ROOT))) { $sUrlRelocate = BX_DOL_ROLE_ADMIN == $oForm->getRole() ? BX_DOL_URL_STUDIO . 'launcher.php' : BX_DOL_URL_ROOT . 'member.php'; } BxDolTemplate::getInstance()->setPageNameIndex(BX_PAGE_TRANSITION); BxDolTemplate::getInstance()->setPageHeader(_t('_Please Wait')); BxDolTemplate::getInstance()->setPageContent('page_main_code', MsgBox(_t('_Please Wait'))); BxDolTemplate::getInstance()->setPageContent('url_relocate', bx_html_attribute($sUrlRelocate, BX_ESCAPE_STR_QUOTE)); BxDolTemplate::getInstance()->getPageCode(); exit; } } bx_require_authentication(); header('Location: ' . BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=account-profile-switcher'));
function parseContent($sContent, $aKeys, $iAccountId = 0, $iProfileId = 0) { $aResultKeys = $this->aDefaultKeys; if ($iAccountId) { bx_import('BxDolAccount'); $oAccount = BxDolAccount::getInstance($iAccountId); if ($oAccount && ($aAccountInfo = $oAccount->getInfo())) { $aResultKeys = array_merge($aResultKeys, array('account_id' => $aAccountInfo['id'], 'account_name' => $aAccountInfo['name'], 'account_email' => $aAccountInfo['email'])); } } if ($iProfileId) { bx_import('BxDolProfile'); $oProfile = BxDolProfile::getInstance($iProfileId); if ($oProfile && ($aProfileInfo = $oProfile->getInfo())) { $aResultKeys = array_merge($aResultKeys, array('profile_name' => $oProfile->getDisplayName(), 'profile_url' => $oProfile->getUrl(), 'profile_thumb' => $oProfile->getThumb(), 'profile_icon' => $oProfile->getIcon(), 'profile_id' => $aProfileInfo['id'], 'profile_status' => $aProfileInfo['status'], 'profile_type' => $aProfileInfo['type'], 'profile_content_id' => $aProfileInfo['content_id'])); } } if (is_array($aKeys)) { $aResultKeys = array_merge($aResultKeys, $aKeys); } bx_import('BxDolTemplate'); return BxDolTemplate::getInstance()->parseHtmlByContent($sContent, $aResultKeys, array('{', '}')); }
/** * Delete profile. * @param $ID - optional profile id to delete * @param $bForceDelete - force deletetion is case of account profile deletion * @return false on error, or true on success */ function delete($ID = false, $bForceDelete = false) { $ID = (int) $ID; if (!$ID) { $ID = $this->_iProfileID; } $aProfileInfo = $this->_oQuery->getInfoById($ID); if (!$aProfileInfo) { return false; } // delete system profiles (accounts) is not allowed, instead - delete whole account if (!$bForceDelete && 'system' == $aProfileInfo['type']) { return false; } // switch profile context if deleted profile is active profile context bx_import('BxDolAccount'); $oAccount = BxDolAccount::getInstance($aProfileInfo['account_id']); $aAccountInfo = $oAccount->getInfo(); if (!$bForceDelete && $ID == $aAccountInfo['profile_id']) { $oProfileAccount = BxDolProfile::getInstanceAccountProfile($aProfileInfo['account_id']); $oAccount->updateProfileContext($oProfileAccount->id()); } // create system event before deletion $isStopDeletion = false; bx_alert('profile', 'before_delete', $ID, 0, array('stop_deletion' => &$isStopDeletion)); if ($isStopDeletion) { return false; } // delete associated comments bx_import('BxDolCmts'); BxDolCmts::onAuthorDelete($ID); // delete connections bx_import('BxDolConnection'); $oConn = BxDolConnection::getObjectInstance('sys_profiles_friends'); $oConn->onDeleteInitiatorAndContent($ID); $oConn = BxDolConnection::getObjectInstance('sys_profiles_subscriptions'); $oConn->onDeleteInitiatorAndContent($ID); // delete profile's acl levels bx_import('BxDolAcl'); BxDolAcl::getInstance()->onProfileDelete($ID); // delete profile if (!$this->_oQuery->delete($ID)) { return false; } // create system event bx_alert('profile', 'delete', $ID); // unset class instance to prevent creating the instance again $this->_iProfileID = 0; $sClass = get_class($this) . '_' . $ID; unset($GLOBALS['bxDolClasses'][$sClass]); return true; }
public function onDataAddAfter($iAccountId, $iContentId) { if ($s = parent::onDataAddAfter($iAccountId, $iContentId)) { return $s; } $CNF =& $this->_oModule->_oConfig->CNF; // add account and content association $iProfileId = BxDolProfile::add(BX_PROFILE_ACTION_MANUAL, $iAccountId, $iContentId, BX_PROFILE_STATUS_PENDING, $this->_oModule->getName()); $oProfile = BxDolProfile::getInstance($iProfileId); // approve profile if auto-approval is enabled and profile status is 'pending' $sStatus = $oProfile->getStatus(); if ($sStatus == BX_PROFILE_STATUS_PENDING && $this->isAutoApproval()) { $oProfile->approve(BX_PROFILE_ACTION_AUTO); } // set created profile some default membership $iAclLevel = isAdmin() ? MEMBERSHIP_ID_ADMINISTRATOR : getParam($CNF['PARAM_DEFAULT_ACL_LEVEL']); BxDolAcl::getInstance()->setMembership($iProfileId, $iAclLevel, 0, true); // alert bx_alert($this->_oModule->getName(), 'added', $iContentId); // switch context to the created profile $oAccount = BxDolAccount::getInstance($iAccountId); $oAccount->updateProfileContext($iProfileId); return ''; }
/** * Perform email confirmation */ public function confirmEmail($sKey) { // check if key exists $oKey = BxDolKey::getInstance(); if (!$oKey || !$oKey->isKeyExists($sKey)) { return MsgBox(_t("_sys_txt_confirm_email_error_occured")); } // check if key data exists $aData = $oKey->getKeyData($sKey); if (!isset($aData['account_id'])) { return MsgBox(_t("_sys_txt_confirm_email_error_occured")); } // check if account exists $oAccount = BxDolAccount::getInstance($aData['account_id']); if (!$oAccount) { return MsgBox(_t("_sys_txt_confirm_email_error_occured")); } // remove key $oKey->removeKey($sKey); // confirm email if (!$oAccount->updateEmailConfirmed(true)) { return MsgBox(_t("_sys_txt_confirm_email_error_occured")); } // login to user's account automatically bx_login($aData['account_id']); // redirect with success message $oTemplate = BxDolTemplate::getInstance(); $oTemplate->setPageNameIndex(BX_PAGE_TRANSITION); $oTemplate->setPageHeader(_t('_sys_txt_confirm_email_success')); $oTemplate->setPageContent('page_main_code', MsgBox(_t('_sys_txt_confirm_email_success'))); $oTemplate->setPageContent('url_relocate', BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=account-settings-info')); BxDolTemplate::getInstance()->getPageCode(); exit; }
/** * Add permanent messages which are displayed on every page. */ protected function _addPermanentMessages() { // add account & profile related permament messages if (isLogged()) { $oAccount = BxDolAccount::getInstance(); if ($oAccount) { $oAccount->addInformerPermanentMessages($this); } $oProfile = BxDolProfile::getInstance(); if ($oProfile) { $oProfile->addInformerPermanentMessages($this); } } // add permament messages from modules bx_alert('system', 'informer_permament_messages', 0, false, array('informer' => $this)); }
protected function _sendNotificationEmail($iCmtId, $iCmtParentId) { $aCmt = $this->getCommentRow($iCmtId); $aCmtParent = $this->getCommentRow($iCmtParentId); if (empty($aCmt) || !is_array($aCmt) || empty($aCmtParent) || !is_array($aCmtParent) || (int) $aCmt['cmt_author_id'] == (int) $aCmtParent['cmt_author_id']) { return; } $oProfile = $this->_getAuthorObject($aCmtParent['cmt_author_id']); if ($oProfile instanceof BxDolProfileUndefined) { return; } $iAccount = $oProfile->getAccountId(); $aAccount = BxDolAccount::getInstance($iAccount)->getInfo(); $aPlus = array(); $aPlus['reply_text'] = bx_process_output($aCmt['cmt_text']); $aPlus['comment_url'] = sprintf('%scmts.php?sys=%s&id=%d&cmt_id=%d', BX_DOL_URL_ROOT, $this->_sSystem, $this->_iId, $iCmtParentId); $aTemplate = BxDolEmailTemplates::getInstance()->parseTemplate('t_CommentReplied', $aPlus); return $aTemplate && sendMail($aAccount['email'], $aTemplate['Subject'], $aTemplate['Body']); }
/** * Send email function * * @param $sRecipientEmail - Email where email should be send * @param $sMailSubject - subject of the message * @param $sMailBody - Body of the message * @param $iRecipientID - ID of recipient profile * @param $aPlus - Array of additional information * @param $iEmailType - email message type: BX_EMAIL_SYSTEM, BX_EMAIL_NOTIFY or BX_EMAIL_MASS * @return true if message was send or false otherwise */ function sendMail($sRecipientEmail, $sMailSubject, $sMailBody, $iRecipientID = 0, $aPlus = array(), $iEmailType = BX_EMAIL_NOTIFY, $sEmailFlag = 'html', $isDisableAlert = false) { // make sure that recipient's email is valid and message isn't empty if (!$sMailBody || !$sRecipientEmail || preg_match('/\\(2\\)$/', $sRecipientEmail)) { return false; } // get recipient account bx_import('BxDolAccount'); $oAccount = BxDolAccount::getInstance($sRecipientEmail); $aAccountInfo = $oAccount ? $oAccount->getInfo() : false; // don't send bulk emails if user didn't subscribed to site news or email is unconfirmed if ($aAccountInfo && BX_EMAIL_MASS == $iEmailType && (!$aAccountInfo['email_confirmed'] || !$aAccountInfo['receive_news'])) { return false; } // don't send email notifications if user didn't subscribed to notifications or email is unconfirmed if ($aAccountInfo && BX_EMAIL_NOTIFY == $iEmailType && (!$aAccountInfo['email_confirmed'] || !$aAccountInfo['receive_updates'])) { return false; } // if profile id is provided - get profile's info $aRecipientInfo = false; if ($iRecipientID) { bx_import('BxDolProfile'); $oProfile = BxDolProfile::getInstance($iRecipientID); if ($oProfile) { $aRecipientInfo = $oProfile->getInfo(); } } // get site vars $sEmailNotify = getParam('site_email_notify'); $sSiteTitle = getParam('site_title'); // add unsubscribe link if (empty($aPlus['unsubscribe'])) { $aPlus['unsubscribe'] = ''; if ($oAccount && (BX_EMAIL_MASS == $iEmailType || BX_EMAIL_NOTIFY == $iEmailType)) { $aPlus['unsubscribe'] = ($sLink = $oAccount->getUnsubscribeLink($iEmailType)) ? '<a href="' . BX_DOL_URL_ROOT . $sLink . '">' . _t('_sys_et_txt_unsubscribe') . '</a>' : ''; } } // parse template if ($aPlus || $iRecipientID) { if (!is_array($aPlus)) { $aPlus = array(); } bx_import('BxDolEmailTemplates'); $oEmailTemplates = BxDolEmailTemplates::getInstance(); $sMailSubject = $oEmailTemplates->parseContent($sMailSubject, $aPlus, $iRecipientID); $sMailBody = $oEmailTemplates->parseContent($sMailBody, $aPlus, $iRecipientID); } // email message headers $sMailHeader = "From: =?UTF-8?B?" . base64_encode($sSiteTitle) . "?= <{$sEmailNotify}>"; $sMailParameters = "-f{$sEmailNotify}"; $sMailSubject = '=?UTF-8?B?' . base64_encode($sMailSubject) . '?='; $sMailHeader = "MIME-Version: 1.0\r\n" . $sMailHeader; // build data for alert handler $bResult = null; $aAlert = array('email' => $sRecipientEmail, 'subject' => $sMailSubject, 'body' => $sMailBody, 'header' => $sMailHeader, 'params' => $sMailParameters, 'recipient' => $aRecipientInfo, 'html' => 'html' == $sEmailFlag ? true : false, 'override_result' => &$bResult); // system alert if (!$isDisableAlert) { bx_alert('system', 'before_send_mail', isset($aRecipientInfo['ID']) ? $aRecipientInfo['ID'] : 0, '', $aAlert); if ($bResult !== null) { return $bResult; } unset($aAlert['override_result']); } // send mail if ('html' == $sEmailFlag) { $sMailHeader = "Content-type: text/html; charset=UTF-8\r\n" . $sMailHeader; $iSendingResult = mail($sRecipientEmail, $sMailSubject, $sMailBody, $sMailHeader, $sMailParameters); } else { $sMailHeader = "Content-type: text/plain; charset=UTF-8\r\n" . $sMailHeader; $sMailBody = html2txt($sMailBody); $iSendingResult = mail($sRecipientEmail, $sMailSubject, html2txt($sMailBody), $sMailHeader, $sMailParameters); } // system alert if (!$isDisableAlert) { bx_alert('system', 'send_mail', isset($aRecipientInfo['ID']) ? $aRecipientInfo['ID'] : 0, '', $aAlert); } return $iSendingResult; }