create account_store_lowlevel()
This commit is contained in:
parent
321957781e
commit
6962bc5147
@ -105,6 +105,33 @@ function account_total() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function account_store_lowlevel($arr) {
|
||||||
|
|
||||||
|
$store = [
|
||||||
|
'account_parent' => ((array_key_exists('account_parent',$arr)) ? $arr['account_parent'] : '0'),
|
||||||
|
'account_default_channel' => ((array_key_exists('account_default_channel',$arr)) ? $arr['account_default_channel'] : '0'),
|
||||||
|
'account_salt' => ((array_key_exists('account_salt',$arr)) ? $arr['account_salt'] : ''),
|
||||||
|
'account_password' => ((array_key_exists('account_password',$arr)) ? $arr['account_password'] : ''),
|
||||||
|
'account_email' => ((array_key_exists('account_email',$arr)) ? $arr['account_email'] : ''),
|
||||||
|
'account_external' => ((array_key_exists('account_external',$arr)) ? $arr['account_external'] : ''),
|
||||||
|
'account_language' => ((array_key_exists('account_language',$arr)) ? $arr['account_language'] : 'en'),
|
||||||
|
'account_created' => ((array_key_exists('account_created',$arr)) ? $arr['account_created'] : '0001-01-01 00:00:00'),
|
||||||
|
'account_lastlog' => ((array_key_exists('account_lastlog',$arr)) ? $arr['account_lastlog'] : '0001-01-01 00:00:00'),
|
||||||
|
'account_flags' => ((array_key_exists('account_flags',$arr)) ? $arr['account_flags'] : '0'),
|
||||||
|
'account_roles' => ((array_key_exists('account_roles',$arr)) ? $arr['account_roles'] : '0'),
|
||||||
|
'account_reset' => ((array_key_exists('account_reset',$arr)) ? $arr['account_reset'] : ''),
|
||||||
|
'account_expires' => ((array_key_exists('account_expires',$arr)) ? $arr['account_expires'] : '0001-01-01 00:00:00'),
|
||||||
|
'account_expire_notified' => ((array_key_exists('account_expire_notified',$arr)) ? $arr['account_expire_notified'] : '0001-01-01 00:00:00'),
|
||||||
|
'account_service_class' => ((array_key_exists('account_service_class',$arr)) ? $arr['account_service_class'] : ''),
|
||||||
|
'account_level' => ((array_key_exists('account_level',$arr)) ? $arr['account_level'] : '0'),
|
||||||
|
'account_password_changed' => ((array_key_exists('account_password_changed',$arr)) ? $arr['account_password_changed'] : '0001-01-01 00:00:00')
|
||||||
|
];
|
||||||
|
|
||||||
|
return create_table_from_array('account',$store);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function create_account($arr) {
|
function create_account($arr) {
|
||||||
|
|
||||||
// Required: { email, password }
|
// Required: { email, password }
|
||||||
@ -177,21 +204,20 @@ function create_account($arr) {
|
|||||||
$salt = random_string(32);
|
$salt = random_string(32);
|
||||||
$password_encoded = hash('whirlpool', $salt . $password);
|
$password_encoded = hash('whirlpool', $salt . $password);
|
||||||
|
|
||||||
$r = q("INSERT INTO account
|
$r = account_store_lowlevel(
|
||||||
( account_parent, account_salt, account_password, account_email, account_language,
|
[
|
||||||
account_created, account_flags, account_roles, account_level, account_expires, account_service_class )
|
'account_parent' => intval($parent),
|
||||||
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s', '%s' )",
|
'account_salt' => $salt,
|
||||||
intval($parent),
|
'account_password' => $password_encoded,
|
||||||
dbesc($salt),
|
'account_email' => $email,
|
||||||
dbesc($password_encoded),
|
'account_language' => get_best_language(),
|
||||||
dbesc($email),
|
'account_created' => datetime_convert(),
|
||||||
dbesc(get_best_language()),
|
'account_flags' => intval($flags),
|
||||||
dbesc(datetime_convert()),
|
'account_roles' => intval($roles),
|
||||||
intval($flags),
|
'account_level' => intval($techlevel),
|
||||||
intval($roles),
|
'account_expires' => $expires,
|
||||||
intval($techlevel),
|
'account_service_class' => $default_service_class
|
||||||
dbesc($expires),
|
]
|
||||||
dbesc($default_service_class)
|
|
||||||
);
|
);
|
||||||
if(! $r) {
|
if(! $r) {
|
||||||
logger('create_account: DB INSERT failed.');
|
logger('create_account: DB INSERT failed.');
|
||||||
@ -246,16 +272,18 @@ function verify_email_address($arr) {
|
|||||||
dbesc($arr['account']['account_language'])
|
dbesc($arr['account']['account_language'])
|
||||||
);
|
);
|
||||||
|
|
||||||
//@fixme - get correct language template
|
push_lang(($arr['account']['account_language']) ? $arr['account']['account_language'] : 'en');
|
||||||
|
|
||||||
$email_msg = replace_macros(get_intltext_template('register_verify_member.tpl'), array(
|
$email_msg = replace_macros(get_intltext_template('register_verify_member.tpl'),
|
||||||
'$sitename' => get_config('system','sitename'),
|
[
|
||||||
'$siteurl' => z_root(),
|
'$sitename' => get_config('system','sitename'),
|
||||||
'$email' => $arr['email'],
|
'$siteurl' => z_root(),
|
||||||
'$uid' => $arr['account']['account_id'],
|
'$email' => $arr['email'],
|
||||||
'$hash' => $hash,
|
'$uid' => $arr['account']['account_id'],
|
||||||
'$details' => $details
|
'$hash' => $hash,
|
||||||
));
|
'$details' => $details
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
$res = z_mail(
|
$res = z_mail(
|
||||||
[
|
[
|
||||||
@ -265,10 +293,12 @@ function verify_email_address($arr) {
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
pop_lang();
|
||||||
|
|
||||||
if($res)
|
if($res)
|
||||||
$delivered ++;
|
$delivered ++;
|
||||||
else
|
else
|
||||||
logger('send_reg_approval_email: failed to ' . $admin['email'] . 'account_id: ' . $arr['account']['account_id']);
|
logger('send_reg_approval_email: failed to account_id: ' . $arr['account']['account_id']);
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
@ -354,9 +384,9 @@ function send_register_success_email($email,$password) {
|
|||||||
|
|
||||||
$res = z_mail(
|
$res = z_mail(
|
||||||
[
|
[
|
||||||
'toEmail' => $email,
|
'toEmail' => $email,
|
||||||
'messageSubject' => sprintf( t('Registration details for %s'), get_config('system','sitename')),
|
'messageSubject' => sprintf( t('Registration details for %s'), get_config('system','sitename')),
|
||||||
'textVersion' => $email_msg,
|
'textVersion' => $email_msg,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -525,9 +555,6 @@ function account_approve($hash) {
|
|||||||
if(! $account)
|
if(! $account)
|
||||||
return $ret;
|
return $ret;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(get_config('system','auto_channel_create'))
|
if(get_config('system','auto_channel_create'))
|
||||||
auto_channel_create($register[0]['uid']);
|
auto_channel_create($register[0]['uid']);
|
||||||
else {
|
else {
|
||||||
@ -535,9 +562,6 @@ function account_approve($hash) {
|
|||||||
authenticate_success($account[0],null,true,true,false,true);
|
authenticate_success($account[0],null,true,true,false,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// info( t('Account verified. Please login.') . EOL );
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user