public function createAccountForm() { // check access if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = BxDolAccount::isAllowedCreate(0))) { return MsgBox($sMsg); } // check and display form $oForm = $this->getObjectFormAdd(); if (!$oForm) { return MsgBox(_t('_sys_txt_error_occured')); } $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=create-account'); $oForm->initChecker(self::$PROFILE_FIELDS); if (!$oForm->isSubmittedAndValid()) { $sCode = $oForm->getCode(); bx_alert('account', 'add_form', 0, 0, array('form_object' => &$oForm, 'form_code' => &$sCode)); return $sCode; } // insert data into database $aValsToAdd = array('email_confirmed' => 0); $iAccountId = $oForm->insert($aValsToAdd); if (!$iAccountId) { if (!$oForm->isValid()) { return $oForm->getCode(); } else { return MsgBox(_t('_sys_txt_error_account_creation')); } } $iProfileId = $this->onAccountCreated($iAccountId, $oForm->isSetPendingApproval()); // perform action BxDolAccount::isAllowedCreate($iProfileId, true); $this->_iProfileId = bx_get_logged_profile_id(); // redirect $this->_redirectAndExit(getParam('sys_redirect_after_account_added'), true, array('account_id' => $iAccountId, 'profile_id' => $iProfileId)); }
public function createAccountForm() { // check access if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = BxDolAccount::isAllowedCreate(0))) { return MsgBox($sMsg); } // check and display form $oForm = BxDolForm::getObjectInstance('sys_account', 'sys_account_create'); if (!$oForm) { return MsgBox(_t('_sys_txt_error_occured')); } $oForm->initChecker(); if (!$oForm->isSubmittedAndValid()) { $sCode = $oForm->getCode(); bx_alert('account', 'add_form', 0, 0, array('form_object' => &$oForm, 'form_code' => &$sCode)); return $sCode; } // insert data into database $aValsToAdd = array('email_confirmed' => 0); $iAccountId = $oForm->insert($aValsToAdd); if (!$iAccountId) { if (!$oForm->isValid()) { return $oForm->getCode(); } else { return MsgBox(_t('_sys_txt_error_account_creation')); } } // alert bx_alert('account', 'add', $iAccountId, 0); // if email_confirmation procedure is enabled - send email confirmation letter $oAccount = BxDolAccount::getInstance($iAccountId); if (getParam('sys_email_confirmation') && $oAccount && !$oAccount->isConfirmed()) { $oAccount->sendConfirmationEmail($iAccountId); } // add account and content association bx_import('BxDolProfile'); $iProfileId = BxDolProfile::add(BX_PROFILE_ACTION_MANUAL, $iAccountId, $iAccountId, BX_PROFILE_STATUS_PENDING, 'system'); $oProfile = BxDolProfile::getInstance($iProfileId); // approve profile if auto-approval is enabled and profile status is 'pending' $sStatus = $oProfile->getStatus(); $isAutoApprove = $oForm->isSetPendingApproval() ? false : true; if ($sStatus == BX_PROFILE_STATUS_PENDING && $isAutoApprove) { $oProfile->approve(BX_PROFILE_ACTION_AUTO); } // perform action BxDolAccount::isAllowedCreate($iProfileId, true); // alert bx_alert('account', 'added', $iAccountId); // login to the created account automatically bx_login($iAccountId); $this->_iProfileId = bx_get_logged_profile_id(); // redirect $this->_redirectAndExit(getParam('sys_redirect_after_account_added'), true, array('account_id' => $iAccountId, 'profile_id' => $iProfileId)); }