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()); } }
/** * 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); }