mirror of
https://framagit.org/hubzilla/core.git
synced 2026-06-21 00:52:33 -04:00
Clean up send_reg_approval_email_from_register, new email template
Since there is no easy way to produce direct links to approve/reject registrations, create new email template which simply links to the Accounts admin page. In response to comments: - Add type annotations - Simplify some 'if' statements - add and fix some whitespace - simplify input arguments to the function
This commit is contained in:
@@ -142,7 +142,7 @@ class Regate extends \Zotlabs\Web\Controller {
|
||||
|
||||
if (($flags & ACCOUNT_PENDING ) == ACCOUNT_PENDING) {
|
||||
$nextpage = 'regate/' . bin2hex($did2) . $didx;
|
||||
$approve = send_reg_approval_email_from_register([ 'reg_id' => $r['reg_id'] ]);
|
||||
$approve = send_reg_approval_email_from_register($r['reg_id']);
|
||||
if ($approve['success']) {
|
||||
q("COMMIT");
|
||||
} else {
|
||||
|
||||
@@ -402,17 +402,17 @@ function send_reg_approval_email($arr) {
|
||||
* This function sends email to admin(s).
|
||||
*
|
||||
*/
|
||||
function send_reg_approval_email_from_register($arr) {
|
||||
function send_reg_approval_email_from_register(int $reg_id): array {
|
||||
|
||||
$result = array('success' => false, 'message' => 'rid:' . $arr['reg_id']);
|
||||
$result = array('success' => false, 'message' => 'rid:' . $reg_id);
|
||||
$now = datetime_convert();
|
||||
|
||||
$register = q("SELECT * FROM register WHERE reg_id = %d",
|
||||
intval($arr['reg_id'])
|
||||
intval($reg_id)
|
||||
);
|
||||
|
||||
if(! ($register && count($register))) {
|
||||
logger('send_reg_approval_email: could not find data for reg_id ' . $arr['reg_id']);
|
||||
if (empty($register)) {
|
||||
logger('send_reg_approval_email: could not find data for reg_id ' . $reg_id);
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -423,32 +423,31 @@ function send_reg_approval_email_from_register($arr) {
|
||||
$admins = array();
|
||||
|
||||
foreach($r as $rr) {
|
||||
if(strlen($rr['account_email'])) {
|
||||
if (strlen($rr['account_email'])) {
|
||||
$admins[] = array('email' => $rr['account_email'], 'lang' => $rr['account_lang']);
|
||||
}
|
||||
}
|
||||
|
||||
if(! count($admins)) {
|
||||
logger('send_reg_approval_email: could not find any admins to notify for reg_id ' . $arr['reg_id']);
|
||||
if (empty($admins)) {
|
||||
logger('send_reg_approval_email: could not find any admins to notify for reg_id ' . $reg_id);
|
||||
return $result;
|
||||
}
|
||||
|
||||
$delivered = 0;
|
||||
|
||||
foreach($admins as $admin) {
|
||||
if(strlen($admin['lang']))
|
||||
if (strlen($admin['lang'])) {
|
||||
push_lang($admin['lang']);
|
||||
else
|
||||
} else {
|
||||
push_lang('en');
|
||||
}
|
||||
|
||||
$email_msg = replace_macros(get_intltext_template('register_verify_eml.tpl'), array(
|
||||
$email_msg = replace_macros(get_intltext_template('register_verify_eml_no_links.tpl'), array(
|
||||
'$sitename' => Config::Get('system','sitename'),
|
||||
'$siteurl' => z_root(),
|
||||
'$email' => $register[0]['reg_email'],
|
||||
'$uid' => $arr['reg_id'],
|
||||
'$hash' => $register[0]['reg_hash'],
|
||||
'$details' => $register[0]['reg_atip']
|
||||
));
|
||||
));
|
||||
|
||||
$res = z_mail(
|
||||
[
|
||||
@@ -458,7 +457,7 @@ function send_reg_approval_email_from_register($arr) {
|
||||
]
|
||||
);
|
||||
|
||||
if($res) {
|
||||
if ($res) {
|
||||
$delivered ++;
|
||||
} else {
|
||||
logger('send_reg_approval_email: failed to ' . $admin['email'] . 'reg_email: ' . $register[0]['reg_email']);
|
||||
|
||||
18
view/lang/en/register_verify_eml_no_links.tpl
Normal file
18
view/lang/en/register_verify_eml_no_links.tpl
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
A new user registration request was received at {{$sitename}} which requires
|
||||
your approval.
|
||||
|
||||
|
||||
The login details are as follows:
|
||||
|
||||
Site Location: {{$siteurl}}
|
||||
Login Name: {{$email}}
|
||||
IP Address: {{$details}}
|
||||
|
||||
To approve or deny this request please visit the Accounts page:
|
||||
|
||||
{{$siteurl}}/admin/accounts
|
||||
|
||||
|
||||
Thank you.
|
||||
|
||||
Reference in New Issue
Block a user