mirror of
https://framagit.org/hubzilla/core.git
synced 2026-06-21 00:52:33 -04:00
Add new send_reg_approval_email_from_register function
Current send_reg_approval_email function expects account to already exist, and does not seem to be called anywhere. New function takes necessary information from the register table. Added call to new function in Regate.php after verification is done. Will fail and roll back if the function call fails or if no admin accounts were found to notify (delivered<1).
This commit is contained in:
@@ -311,7 +311,7 @@ function verify_email_address(string $email): bool {
|
||||
pop_lang();
|
||||
|
||||
if(! $res)
|
||||
logger("send_reg_approval_email: failed sending email to: {$email}");
|
||||
logger("send_reg_verification_email: failed sending email to: {$email}");
|
||||
|
||||
return $res;
|
||||
}
|
||||
@@ -392,6 +392,89 @@ function send_reg_approval_email($arr) {
|
||||
return($delivered ? true : false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* send_reg_approval_email_from_register
|
||||
* @author ltning
|
||||
* @since 2026-01-25
|
||||
*
|
||||
* Account approval after verification based on table register.
|
||||
* This function sends email to admin(s).
|
||||
*
|
||||
*/
|
||||
function send_reg_approval_email_from_register($arr) {
|
||||
|
||||
$result = array('success' => false, 'message' => 'rid:' . $arr['reg_id']);
|
||||
$now = datetime_convert();
|
||||
|
||||
$register = q("SELECT * FROM register WHERE reg_id = %d",
|
||||
intval($arr['reg_id'])
|
||||
);
|
||||
|
||||
if(! ($register && count($register))) {
|
||||
logger('send_reg_approval_email: could not find data for reg_id ' . $arr['reg_id']);
|
||||
return $result;
|
||||
}
|
||||
|
||||
$r = q("select * from account where (account_roles & %d) >= 4096",
|
||||
intval(ACCOUNT_ROLE_ADMIN)
|
||||
);
|
||||
|
||||
$admins = array();
|
||||
|
||||
foreach($r as $rr) {
|
||||
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']);
|
||||
return $result;
|
||||
}
|
||||
|
||||
$delivered = 0;
|
||||
|
||||
foreach($admins as $admin) {
|
||||
if(strlen($admin['lang']))
|
||||
push_lang($admin['lang']);
|
||||
else
|
||||
push_lang('en');
|
||||
|
||||
$email_msg = replace_macros(get_intltext_template('register_verify_eml.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(
|
||||
[
|
||||
'toEmail' => $admin['email'],
|
||||
'messageSubject' => sprintf( t('Registration request at %s'), Config::Get('system','sitename')),
|
||||
'textVersion' => $email_msg,
|
||||
]
|
||||
);
|
||||
|
||||
if($res) {
|
||||
$delivered ++;
|
||||
} else {
|
||||
logger('send_reg_approval_email: failed to ' . $admin['email'] . 'reg_email: ' . $register[0]['reg_email']);
|
||||
}
|
||||
|
||||
pop_lang();
|
||||
}
|
||||
|
||||
$result['delivered'] = $delivered;
|
||||
if($delivered > 0) {
|
||||
$result['success'] = true;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
function send_register_success_email($email,$password) {
|
||||
|
||||
$email_msg = replace_macros(get_intltext_template('register_open_eml.tpl'), array(
|
||||
|
||||
Reference in New Issue
Block a user