diff options
author | Mario Vavti <mario@mariovavti.com> | 2016-10-12 12:13:44 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2016-10-12 12:13:44 +0200 |
commit | cf547be1d6900d12719a9372cbc1a5d433d31863 (patch) | |
tree | 03a525cf40905adafc21b0c4146e467bad288437 /include/account.php | |
parent | 29617737ca2c03c800ebbe4701dc21cf9f25ce22 (diff) | |
parent | 16da1a4e810889448eecbd13d68183a820bcebe2 (diff) | |
download | volse-hubzilla-cf547be1d6900d12719a9372cbc1a5d433d31863.tar.gz volse-hubzilla-cf547be1d6900d12719a9372cbc1a5d433d31863.tar.bz2 volse-hubzilla-cf547be1d6900d12719a9372cbc1a5d433d31863.zip |
Merge branch '1.14RC'
Diffstat (limited to 'include/account.php')
-rw-r--r-- | include/account.php | 93 |
1 files changed, 65 insertions, 28 deletions
diff --git a/include/account.php b/include/account.php index 5c44f13ca..b78c3e56d 100644 --- a/include/account.php +++ b/include/account.php @@ -14,6 +14,13 @@ require_once('include/crypto.php'); require_once('include/channel.php'); +function get_account_by_id($account_id) { + $r = q("select * from account where account_id = %d", + intval($account_id) + ); + return (($r) ? $r[0] : false); +} + function check_account_email($email) { $result = array('error' => false, 'message' => ''); @@ -112,6 +119,7 @@ function create_account($arr) { $flags = ((x($arr,'account_flags')) ? intval($arr['account_flags']) : ACCOUNT_OK); $roles = ((x($arr,'account_roles')) ? intval($arr['account_roles']) : 0 ); $expires = ((x($arr,'expires')) ? intval($arr['expires']) : NULL_DATE); + $techlevel = ((array_key_exists('techlevel',$arr)) ? intval($arr['techlevel']) : intval(get_config('system','techlevel'))); $default_service_class = get_config('system','default_service_class'); @@ -171,16 +179,17 @@ function create_account($arr) { $r = q("INSERT INTO account ( account_parent, account_salt, account_password, account_email, account_language, - account_created, account_flags, account_roles, account_expires, account_service_class ) - VALUES ( %d, '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s' )", + 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()), - dbesc($flags), - dbesc($roles), + intval($flags), + intval($roles), + intval($techlevel), dbesc($expires), dbesc($default_service_class) ); @@ -237,20 +246,23 @@ function verify_email_address($arr) { dbesc($arr['account']['account_language']) ); +//@fixme - get correct language template + $email_msg = replace_macros(get_intltext_template('register_verify_member.tpl'), array( '$sitename' => get_config('system','sitename'), - '$siteurl' => z_root(), + '$siteurl' => z_root(), '$email' => $arr['email'], '$uid' => $arr['account']['account_id'], '$hash' => $hash, '$details' => $details )); - $res = mail($arr['email'], email_header_encode(sprintf( t('Registration confirmation for %s'), get_config('system','sitename'))), - $email_msg, - 'From: ' . 'Administrator' . '@' . App::get_hostname() . "\n" - . 'Content-type: text/plain; charset=UTF-8' . "\n" - . 'Content-transfer-encoding: 8bit' + $res = z_mail( + [ + 'toEmail' => $arr['email'], + 'messageSubject' => sprintf( t('Registration confirmation for %s'), get_config('system','sitename')), + 'textVersion' => $email_msg, + ] ); if($res) @@ -312,11 +324,12 @@ function send_reg_approval_email($arr) { '$details' => $details )); - $res = mail($admin['email'], sprintf( t('Registration request at %s'), get_config('system','sitename')), - $email_msg, - 'From: ' . t('Administrator') . '@' . App::get_hostname() . "\n" - . 'Content-type: text/plain; charset=UTF-8' . "\n" - . 'Content-transfer-encoding: 8bit' + $res = z_mail( + [ + 'toEmail' => $admin['email'], + 'messageSubject' => sprintf( t('Registration request at %s'), get_config('system','sitename')), + 'textVersion' => $email_msg, + ] ); if($res) @@ -339,12 +352,14 @@ function send_register_success_email($email,$password) { '$password' => t('your registration password'), )); - $res = mail($email, sprintf( t('Registration details for %s'), get_config('system','sitename')), - $email_msg, - 'From: ' . t('Administrator') . '@' . App::get_hostname() . "\n" - . 'Content-type: text/plain; charset=UTF-8' . "\n" - . 'Content-transfer-encoding: 8bit' + $res = z_mail( + [ + 'toEmail' => $email, + 'messageSubject' => sprintf( t('Registration details for %s'), get_config('system','sitename')), + 'textVersion' => $email_msg, + ] ); + return($res ? true : false); } @@ -390,7 +405,7 @@ function account_allow($hash) { push_lang($register[0]['lang']); $email_tpl = get_intltext_template("register_open_eml.tpl"); - $email_tpl = replace_macros($email_tpl, array( + $email_msg = replace_macros($email_tpl, array( '$sitename' => get_config('system','sitename'), '$siteurl' => z_root(), '$username' => $account[0]['account_email'], @@ -399,11 +414,13 @@ function account_allow($hash) { '$uid' => $account[0]['account_id'] )); - $res = mail($account[0]['account_email'], sprintf( t('Registration details for %s'), get_config('system','sitename')), - $email_tpl, - 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n" - . 'Content-type: text/plain; charset=UTF-8' . "\n" - . 'Content-transfer-encoding: 8bit' ); + $res = z_mail( + [ + 'toEmail' => $account[0]['account_email'], + 'messageSubject' => sprintf( t('Registration details for %s'), get_config('system','sitename')), + 'textVersion' => $email_msg, + ] + ); pop_lang(); @@ -539,8 +556,8 @@ function account_approve($hash) { */ function downgrade_accounts() { - $r = q("select * from account where not ( account_flags & %d )>0 - and account_expires != '%s' + $r = q("select * from account where not ( account_flags & %d ) > 0 + and account_expires > '%s' and account_expires < %s ", intval(ACCOUNT_EXPIRED), dbesc(NULL_DATE), @@ -751,3 +768,23 @@ function upgrade_bool_message($bbcode = false) { $x = upgrade_link($bbcode); return t('This action is not available under your subscription plan.') . (($x) ? ' ' . $x : '') ; } + + +function get_account_techlevel($account_id = 0) { + + $role = \Zotlabs\Lib\System::get_server_role(); + if($role == 'basic') + return 0; + if($role == 'standard') + return 5; + + if(! $account_id) { + $x = \App::get_account(); + } + else { + $x = get_account_by_id($account_id); + } + + return (($x) ? intval($x['account_level']) : 0); + +}
\ No newline at end of file |