aboutsummaryrefslogtreecommitdiffstats
path: root/include/account.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-05-29 21:46:38 -0700
committerzotlabs <mike@macgirvin.com>2017-05-29 21:46:38 -0700
commit6962bc5147bed48a0fd6ab31580ba9a0f8f75bf7 (patch)
tree2783bbd574bcf8d78672143c2efa145a970f851f /include/account.php
parent321957781e047b8da55e2d8b5510bc595c0d2cf9 (diff)
downloadvolse-hubzilla-6962bc5147bed48a0fd6ab31580ba9a0f8f75bf7.tar.gz
volse-hubzilla-6962bc5147bed48a0fd6ab31580ba9a0f8f75bf7.tar.bz2
volse-hubzilla-6962bc5147bed48a0fd6ab31580ba9a0f8f75bf7.zip
create account_store_lowlevel()
Diffstat (limited to 'include/account.php')
-rw-r--r--include/account.php92
1 files changed, 58 insertions, 34 deletions
diff --git a/include/account.php b/include/account.php
index 499f7303a..6c6fdece4 100644
--- a/include/account.php
+++ b/include/account.php
@@ -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) {
// Required: { email, password }
@@ -177,21 +204,20 @@ function create_account($arr) {
$salt = random_string(32);
$password_encoded = hash('whirlpool', $salt . $password);
- $r = q("INSERT INTO account
- ( account_parent, account_salt, account_password, account_email, account_language,
- account_created, account_flags, account_roles, account_level, account_expires, account_service_class )
- VALUES ( %d, '%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s', '%s' )",
- intval($parent),
- dbesc($salt),
- dbesc($password_encoded),
- dbesc($email),
- dbesc(get_best_language()),
- dbesc(datetime_convert()),
- intval($flags),
- intval($roles),
- intval($techlevel),
- dbesc($expires),
- dbesc($default_service_class)
+ $r = account_store_lowlevel(
+ [
+ 'account_parent' => intval($parent),
+ 'account_salt' => $salt,
+ 'account_password' => $password_encoded,
+ 'account_email' => $email,
+ 'account_language' => get_best_language(),
+ 'account_created' => datetime_convert(),
+ 'account_flags' => intval($flags),
+ 'account_roles' => intval($roles),
+ 'account_level' => intval($techlevel),
+ 'account_expires' => $expires,
+ 'account_service_class' => $default_service_class
+ ]
);
if(! $r) {
logger('create_account: DB INSERT failed.');
@@ -246,16 +272,18 @@ function verify_email_address($arr) {
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(
- '$sitename' => get_config('system','sitename'),
- '$siteurl' => z_root(),
- '$email' => $arr['email'],
- '$uid' => $arr['account']['account_id'],
- '$hash' => $hash,
- '$details' => $details
- ));
+ $email_msg = replace_macros(get_intltext_template('register_verify_member.tpl'),
+ [
+ '$sitename' => get_config('system','sitename'),
+ '$siteurl' => z_root(),
+ '$email' => $arr['email'],
+ '$uid' => $arr['account']['account_id'],
+ '$hash' => $hash,
+ '$details' => $details
+ ]
+ );
$res = z_mail(
[
@@ -265,10 +293,12 @@ function verify_email_address($arr) {
]
);
+ pop_lang();
+
if($res)
$delivered ++;
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;
}
@@ -354,9 +384,9 @@ function send_register_success_email($email,$password) {
$res = z_mail(
[
- 'toEmail' => $email,
- 'messageSubject' => sprintf( t('Registration details for %s'), get_config('system','sitename')),
- 'textVersion' => $email_msg,
+ 'toEmail' => $email,
+ 'messageSubject' => sprintf( t('Registration details for %s'), get_config('system','sitename')),
+ 'textVersion' => $email_msg,
]
);
@@ -525,9 +555,6 @@ function account_approve($hash) {
if(! $account)
return $ret;
-
-
-
if(get_config('system','auto_channel_create'))
auto_channel_create($register[0]['uid']);
else {
@@ -535,9 +562,6 @@ function account_approve($hash) {
authenticate_success($account[0],null,true,true,false,true);
}
-
- // info( t('Account verified. Please login.') . EOL );
-
return true;
}