diff options
author | Mario <mario@mariovavti.com> | 2021-03-15 12:45:39 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2021-03-15 12:45:39 +0000 |
commit | bd24224b761d8471767b8a5b7bd5e626583485f6 (patch) | |
tree | 6699205f3cc49d236f7e0e2b695dfe1516a8928c | |
parent | a5ac3888898d709bdd63900dff79b21823477d85 (diff) | |
download | volse-hubzilla-bd24224b761d8471767b8a5b7bd5e626583485f6.tar.gz volse-hubzilla-bd24224b761d8471767b8a5b7bd5e626583485f6.tar.bz2 volse-hubzilla-bd24224b761d8471767b8a5b7bd5e626583485f6.zip |
air: fix register notifications
-rw-r--r-- | Zotlabs/Lib/Enotify.php | 8 | ||||
-rw-r--r-- | Zotlabs/Module/Admin/Accounts.php | 65 | ||||
-rw-r--r-- | Zotlabs/Module/Sse_bs.php | 5 | ||||
-rw-r--r-- | include/account.php | 86 | ||||
-rw-r--r-- | view/tpl/register.tpl | 2 |
5 files changed, 85 insertions, 81 deletions
diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index d2a0f0abc..b64ab2cc5 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -978,12 +978,12 @@ class Enotify { $x = [ 'notify_link' => z_root() . '/admin/accounts', - 'name' => $rr['account_email'], - //'addr' => $rr['account_email'], + 'name' => (($rr['reg_email']) ? $rr['reg_email'] : $rr['reg_did2']), + //'addr' => '', 'photo' => z_root() . '/' . get_default_profile_photo(48), - 'when' => datetime_convert('UTC', date_default_timezone_get(),$rr['account_created']), + 'when' => datetime_convert('UTC', date_default_timezone_get(),$rr['reg_created']), 'hclass' => ('notify-unseen'), - 'message' => t('requires approval') + 'message' => (($rr['reg_vfd'] === '× not yet') ? t('not yet verified') : t('verified')) . ', ' . t('requires approval') ]; return $x; diff --git a/Zotlabs/Module/Admin/Accounts.php b/Zotlabs/Module/Admin/Accounts.php index 7073f026a..3a2fd1dcc 100644 --- a/Zotlabs/Module/Admin/Accounts.php +++ b/Zotlabs/Module/Admin/Accounts.php @@ -5,7 +5,7 @@ namespace Zotlabs\Module\Admin; class Accounts { - + /** * @brief Handle POST actions on accounts admin page. * @@ -23,9 +23,9 @@ class Accounts { $pending = ( x($_POST, 'pending') ? $_POST['pending'] : array() ); $users = ( x($_POST, 'user') ? $_POST['user'] : array() ); $blocked = ( x($_POST, 'blocked') ? $_POST['blocked'] : array() ); - + check_form_security_token_redirectOnErr('/admin/accounts', 'admin_accounts'); - + $isajax = is_ajax(); $rc = 0; @@ -40,7 +40,7 @@ class Accounts { if ($isajax) { //$debug = print_r($_SESSION[self::MYP],true); $zarop = (x($_POST['zardo']) && preg_match('/^[ad]{1,1}$/', $_POST['zardo']) ) - ? $_POST['zardo'] : ''; + ? $_POST['zardo'] : ''; // zarat arrives with leading underscore _n $zarat = (x($_POST['zarat']) && preg_match('/^_{1,1}[0-9]{1,6}$/', $_POST['zarat']) ) ? substr($_POST['zarat'],1) : ''; @@ -65,7 +65,7 @@ class Accounts { intval($_SESSION[self::MYP]['i'][$zarat]), dbesc($_SESSION[self::MYP]['h'][$zarat]) ); - $rc = 0; + $rc = 0; $rs = q("SELECT * from register WHERE reg_id = %d ", intval($_SESSION[self::MYP]['i'][$zarat]) ); @@ -120,7 +120,7 @@ class Accounts { account_deny($hash); } } - + goaway(z_root() . '/admin/accounts' ); } @@ -140,21 +140,21 @@ class Accounts { $account = q("SELECT * FROM account WHERE account_id = %d", intval($uid) ); - + if (! $account) { notice( t('Account not found') . EOL); goaway(z_root() . '/admin/accounts' ); } - + check_form_security_token_redirectOnErr('/admin/accounts', 'admin_accounts', 't'); $debug = ''; - + switch (argv(2)){ case 'delete': // delete user account_remove($uid,true,false); - + notice( sprintf(t("Account '%s' deleted"), $account[0]['account_email']) . EOL); break; case 'block': @@ -162,7 +162,7 @@ class Accounts { intval(ACCOUNT_BLOCKED), intval($uid) ); - + notice( sprintf( t("Account '%s' blocked") , $account[0]['account_email']) . EOL); break; case 'unblock': @@ -170,14 +170,14 @@ class Accounts { intval(ACCOUNT_BLOCKED), intval($uid) ); - + notice( sprintf( t("Account '%s' unblocked"), $account[0]['account_email']) . EOL); break; } - + goaway(z_root() . '/admin/accounts' ); } - + /* get pending */ // [hilmar -> /* @@ -188,14 +188,7 @@ class Accounts { $tao = 'tao.zar.zarax = ' . "'" . '<img src="' . z_root() . '/images/zapax16.gif">' . "';\n"; // better useability at the moment to tell all (ACCOUNT_PENDING >= 0) instead of (> 0 for those need approval) - $pending = q("SELECT @i:=@i+1 AS reg_n, @i MOD 2 AS reg_z, " - ." reg_did2, reg_created, reg_startup, reg_expires, reg_email, reg_atip, reg_hash, reg_id, " - ." CASE (reg_flags & %d) WHEN 0 THEN '✔ verified' WHEN 1 THEN '× not yet' END AS reg_vfd " - ." FROM register, (SELECT @i:=0) AS i " - ." WHERE reg_vital = 1 AND (reg_flags & %d) >= 0 ", - intval(ACCOUNT_UNVERIFIED), - intval(ACCOUNT_PENDING) - ); + $pending = get_pending_accounts(); unset($_SESSION[self::MYP]); if ($pending) { @@ -218,15 +211,15 @@ class Accounts { $tao = rtrim($tao,',') . '};' . "\n"; } // <- hilmar] - + /* get accounts */ - + $total = q("SELECT count(*) as total FROM account"); if (count($total)) { \App::set_pager_total($total[0]['total']); \App::set_pager_itemspage(100); } - + $serviceclass = (($_REQUEST['class']) ? " and account_service_class = '" . dbesc($_REQUEST['class']) . "' " : ''); $key = (($_REQUEST['key']) ? dbesc($_REQUEST['key']) : 'account_id'); @@ -237,8 +230,8 @@ class Accounts { $base = z_root() . '/admin/accounts?f='; $odir = (($dir === 'asc') ? '0' : '1'); - $users = q("SELECT account_id , account_email, account_lastlog, account_created, account_expires, account_service_class, ( account_flags & %d ) > 0 as blocked, - (SELECT %s FROM channel as ch WHERE ch.channel_account_id = ac.account_id and ch.channel_removed = 0 ) as channels FROM account as ac + $users = q("SELECT account_id , account_email, account_lastlog, account_created, account_expires, account_service_class, ( account_flags & %d ) > 0 as blocked, + (SELECT %s FROM channel as ch WHERE ch.channel_account_id = ac.account_id and ch.channel_removed = 0 ) as channels FROM account as ac where true $serviceclass and account_flags != %d order by $key $dir limit %d offset %d ", intval(ACCOUNT_BLOCKED), db_concat('ch.channel_address', ' '), @@ -249,12 +242,12 @@ class Accounts { // function _setup_users($e){ // $accounts = Array( - // t('Normal Account'), + // t('Normal Account'), // t('Soapbox Account'), // t('Community/Celebrity Account'), // t('Automatic Friend Account') // ); - + // $e['page_flags'] = $accounts[$e['page-flags']]; // $e['register_date'] = relative_date($e['register_date']); // $e['login_date'] = relative_date($e['login_date']); @@ -262,7 +255,7 @@ class Accounts { // return $e; // } // $users = array_map("_setup_users", $users); - + $t = get_markup_template('admin_accounts.tpl'); $o = replace_macros($t, array( // strings // @@ -285,7 +278,7 @@ class Accounts { '$odir' => $odir, '$base' => $base, '$h_users' => t('Accounts'), - '$th_users' => array( + '$th_users' => array( [ t('ID'), 'account_id' ], [ t('Email'), 'account_email' ], [ t('All Channels'), 'channels' ], @@ -293,12 +286,12 @@ class Accounts { [ t('Last login'), 'account_lastlog' ], [ t('Expires'), 'account_expires' ], [ t('Service Class'), 'account_service_class'] ), - + '$confirm_delete_multi' => p2j(t('Selected accounts will be deleted!\n\nEverything these accounts had posted on this site will be permanently deleted!\n\nAre you sure?')), '$confirm_delete' => p2j(t('The account {0} will be deleted!\n\nEverything this account has posted on this site will be permanently deleted!\n\nAre you sure?')), - + '$form_security_token' => get_form_security_token("admin_accounts"), - + // values // '$now' => date('Y-m-d H:i:s'), '$baseurl' => z_root(), @@ -307,9 +300,9 @@ class Accounts { '$users' => $users, )); $o .= paginate($a); - + return $o; } - + } diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php index 3b39d5b49..237becc09 100644 --- a/Zotlabs/Module/Sse_bs.php +++ b/Zotlabs/Module/Sse_bs.php @@ -689,9 +689,8 @@ class Sse_bs extends Controller { if(! (self::$vnotify & VNOTIFY_REGISTER)) return $result; - $r = q("SELECT account_email, account_created from account where (account_flags & %d) > 0", - intval(ACCOUNT_PENDING) - ); + $r = get_pending_accounts(); + if($r) { foreach($r as $rr) { $result['register']['notifications'][] = Enotify::format_register($rr); diff --git a/include/account.php b/include/account.php index 7e5510b53..b928a603e 100644 --- a/include/account.php +++ b/include/account.php @@ -79,7 +79,7 @@ function check_account_invite($invite_code) { if(! $invite_code) { - $result['message'] + $result['message'] .= 'ZAR0510E,' . t('An invitation is required.') . EOL; } else { @@ -88,7 +88,7 @@ function check_account_invite($invite_code) { $r = q("SELECT * FROM register WHERE reg_hash = '%s' AND reg_vital = 1 LIMIT 1", dbesc($invite_code)); if(! $r) { - $result['message'] + $result['message'] .= 'ZAR0511E,' . t('Invitation could not be verified.') . EOL; } } @@ -285,10 +285,10 @@ function create_account_IS_OBSOLETE($arr) { * create_account_from_register * @author hilmar runge * @since 2020-02-20 - * + * * Account creation only happens via table register. * This function creates the account when all conditions are solved. - * + * */ function create_account_from_register($arr) { @@ -418,8 +418,8 @@ function verify_email_address($arr) { ); $res = z_mail( - [ - 'toEmail' => $arr['email'], + [ + 'toEmail' => $arr['email'], 'messageSubject' => sprintf( t('Registration confirmation for %s'), get_config('system','sitename')), 'textVersion' => $email_msg, ] @@ -486,8 +486,8 @@ function verify_email_addressNOP($arr) { ); $res = z_mail( - [ - 'toEmail' => $arr['email'], + [ + 'toEmail' => $arr['email'], 'messageSubject' => sprintf( t('Registration confirmation for %s'), get_config('system','sitename')), 'textVersion' => $email_msg, ] @@ -561,8 +561,8 @@ function send_reg_approval_email($arr) { )); $res = z_mail( - [ - 'toEmail' => $admin['email'], + [ + 'toEmail' => $admin['email'], 'messageSubject' => sprintf( t('Registration request at %s'), get_config('system','sitename')), 'textVersion' => $email_msg, ] @@ -589,7 +589,7 @@ 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, @@ -643,7 +643,7 @@ function account_allow($hash) { intval(ACCOUNT_BLOCKED), intval($register[0]['reg_uid']) ); - + // unpend q("UPDATE account SET account_flags = (account_flags & ~%d) " . " WHERE (account_flags & %d)>0 AND account_id = %d", @@ -655,11 +655,11 @@ function account_allow($hash) { */ // together unblock and unpend $r2 = q("UPDATE account SET account_flags = %d WHERE account_id = %d", - intval($account['account_flags'] + intval($account['account_flags'] &= $account['account_flags'] ^ (ACCOUNT_BLOCKED | ACCOUNT_PENDING)), intval($register[0]['reg_uid']) ); - + if($r1 && $r2) { q("COMMIT"); @@ -678,7 +678,7 @@ function account_allow($hash) { )); $res = z_mail( - [ + [ 'toEmail' => $account[0]['account_email'], 'messageSubject' => sprintf( t('Registration details for %s'), get_config('system','sitename')), 'textVersion' => $email_msg, @@ -695,7 +695,7 @@ function account_allow($hash) { return true; } - // [hilmar -> + // [hilmar -> } else { q("ROLLBACK"); } @@ -747,14 +747,14 @@ function account_deny($hash) { if($r1 && $r2) { q("COMMIT"); - notice( 'ZAR0512I,' . sprintf( t('Registration revoked for %s'), + notice( 'ZAR0512I,' . sprintf( t('Registration revoked for %s'), $account[0]['account_email']) . EOL); return true; } else { - q("ROLLBACK"); - notice( 'ZAR0513F,' . sprintf( t('Could not revoke registration for %s'), + q("ROLLBACK"); + notice( 'ZAR0513F,' . sprintf( t('Could not revoke registration for %s'), $account[0]['account_email']) . EOL); return false; } @@ -799,13 +799,13 @@ function account_approve($hash) { intval(ACCOUNT_BLOCKED), intval($register[0]['reg_uid']) ); - + q("update account set account_flags = (account_flags & ~%d) where (account_flags & %d)>0 and account_id = %d", intval(ACCOUNT_PENDING), intval(ACCOUNT_PENDING), intval($register[0]['reg_uid']) ); - + q("update account set account_flags = (account_flags & ~%d) where (account_flags & %d)>0 and account_id = %d", intval(ACCOUNT_UNVERIFIED), intval(ACCOUNT_UNVERIFIED), @@ -815,8 +815,8 @@ function account_approve($hash) { /* // together unblock unpend and verified q("UPDATE account SET account_flags = %d WHERE account_id = %d", - intval($account['account_flags'] - &= $account['account_flags'] + intval($account['account_flags'] + &= $account['account_flags'] ^ (ACCOUNT_BLOCKED | ACCOUNT_PENDING | ACCOUNT_UNVERIFIED)), intval($register[0]['reg_uid']) ); @@ -837,7 +837,7 @@ function account_approve($hash) { else { $_SESSION['login_return_url'] = 'new_channel'; authenticate_success($account[0],null,true,true,false,true); - } + } return true; } @@ -856,7 +856,7 @@ function verify_register_scheme() { $r1 = q("ALTER TABLE register RENAME TO register100;"); $r2 = q("CREATE TABLE register (" - . "reg_id serial NOT NULL," + . "reg_id serial NOT NULL," . "reg_vital int DEFAULT 1 NOT NULL," . "reg_flags bigint DEFAULT 0 NOT NULL," . "reg_didx char(1) DEFAULT '' NOT NULL," @@ -892,7 +892,7 @@ function verify_register_scheme() { $r4 = q("DROP TABLE register100"); - } + } else { $r1 = q("RENAME TABLE register TO register100;"); @@ -946,7 +946,7 @@ function verify_register_scheme() { q("ROLLBACK"); return UPDATE_FAILED; - } + } elseif ( count($dbc) != 16 ) { // ffu // fields in v2.0.0 = 16 @@ -958,14 +958,14 @@ function verify_register_scheme() { /** * @brief Checks for accounts that have past their expiration date. * - * If the account has a service class which is not the site default, + * If the account has a service class which is not the site default, * the service class is reset to the site default and expiration reset to never. * If the account has no service class it is expired and subsequently disabled. * called from include/poller.php as a scheduled task. * * Reclaiming resources which are no longer within the service class limits is - * not the job of this function, but this can be implemented by plugin if desired. - * Default behaviour is to stop allowing additional resources to be consumed. + * not the job of this function, but this can be implemented by plugin if desired. + * Default behaviour is to stop allowing additional resources to be consumed. */ function downgrade_accounts() { @@ -1202,7 +1202,7 @@ function zar_log($msg='') { function zar_reg_mail($reonar=false) { if ($reonar) { $zem = z_mail( - [ + [ 'toEmail' => $reonar['to'], 'fromName' => ' ', 'fromEmail' => $reonar['from'], @@ -1226,7 +1226,7 @@ function zar_reg_mail($reonar=false) { * */ function zar_register_dutystate( $now=NULL, $day=NULL ) { - + is_null($now) ? $now = date('Hi') : ''; is_null($day) ? $day = date('N') : ''; @@ -1239,19 +1239,31 @@ function zar_register_dutystate( $now=NULL, $day=NULL ) { $dutyis = $isduty ? t('open') : t('closed'); $atform = $isduty ? '' : 'disabled'; - $nowfmt = t('Registration is currently') + $nowfmt = t('Registration is currently') . ' ('.substr($now,0,2) . ':' . substr($now,-2) . ') ' . ' ' . $dutyis; if (!$isduty) { $pernext = zarIsDuty($day, $now, 'nextOpen'); - - if (is_array($pernext)) - $nowfmt .= '. ' . t('Next opens') . ' ' - . ucfirst( array('','mo','tu','we','th','fr','sa','so')[$pernext[0]]) . ' ' + + if (is_array($pernext)) + $nowfmt .= '. ' . t('Next opens') . ' ' + . ucfirst( array('','mo','tu','we','th','fr','sa','so')[$pernext[0]]) . ' ' . substr($pernext[1],0,2) . ':' . substr($pernext[1],-2); } return array( 'isduty' => $isduty, 'nowfmt' => $nowfmt, 'atform' => $atform); } +function get_pending_accounts() { + $r = q("SELECT @i:=@i+1 AS reg_n, @i MOD 2 AS reg_z, " + ." reg_did2, reg_created, reg_startup, reg_expires, reg_email, reg_atip, reg_hash, reg_id, " + ." CASE (reg_flags & %d) WHEN 0 THEN '✔ verified' WHEN 1 THEN '× not yet' END AS reg_vfd " + ." FROM register, (SELECT @i:=0) AS i " + ." WHERE reg_vital = 1 AND (reg_flags & %d) >= 0 ", + intval(ACCOUNT_UNVERIFIED), + intval(ACCOUNT_PENDING) + ); + + return $r; +} diff --git a/view/tpl/register.tpl b/view/tpl/register.tpl index 9a81198c7..c380b5c87 100644 --- a/view/tpl/register.tpl +++ b/view/tpl/register.tpl @@ -19,7 +19,7 @@ </div> {{/if}} - <div style="text-align: center;"> + <div> {{if $invitations}} <a id="zar014" href="javascript:;" style="display: inline-block;">{{$haveivc}}</a> <div id="zar015" style="display: none;"> |