本文整理汇总了PHP中BxDolProfile::add方法的典型用法代码示例。如果您正苦于以下问题:PHP BxDolProfile::add方法的具体用法?PHP BxDolProfile::add怎么用?PHP BxDolProfile::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BxDolProfile
的用法示例。
在下文中一共展示了BxDolProfile::add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createAccountForm
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));
}
示例2: onDataAddAfter
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
$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();
$oAccount->updateProfileContext($iProfileId);
return '';
}
示例3: onAccountCreated
public function onAccountCreated($iAccountId, $isSetPendingApproval, $iAction = BX_PROFILE_ACTION_MANUAL)
{
// 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
$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 = !$isSetPendingApproval;
if ($sStatus == BX_PROFILE_STATUS_PENDING && $isAutoApprove) {
$oProfile->approve(BX_PROFILE_ACTION_AUTO);
}
// alert
bx_alert('account', 'added', $iAccountId);
// login to the created account automatically
bx_login($iAccountId);
return $iProfileId;
}