mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-12-04 22:24:42 +09:00
add send email to one staff account.
This commit is contained in:
1 parent
ff29b69581
commit
6bd52065d8
5 files changed
+24
-13
No files matched your search
@@ -32,12 +32,12 @@ class Service implements \Box\InjectionAwareInterface
|
||||
|
||||
public function getSettingsRoutes()
|
||||
{
|
||||
return array(
|
||||
'history' => array(
|
||||
return [
|
||||
'history' => [
|
||||
'path' => 'email/history',
|
||||
'label' => 'Email history',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function getSearchQuery($data)
|
||||
@@ -145,11 +145,11 @@ class Service implements \Box\InjectionAwareInterface
|
||||
];
|
||||
$this->di['validator']->checkRequiredParamsForArray($required, $data);
|
||||
|
||||
if (!isset($data['to']) && !isset($data['to_staff']) && !isset($data['to_client'])) {
|
||||
throw new \Box_Exception('Receiver is not defined. Define to or to_client or to_staff parameter');
|
||||
if (!isset($data['to']) && !isset($data['to_staff']) && !isset($data['to_client']) && !isset($data['to_admin'])) {
|
||||
throw new \Box_Exception('Receiver is not defined. Define to or to_client or to_staff or to_admin parameter');
|
||||
}
|
||||
$vars = $data;
|
||||
unset($vars['to'], $vars['to_client'], $vars['to_staff'], $vars['to_name'], $vars['from'], $vars['from_name']);
|
||||
unset($vars['to'], $vars['to_client'], $vars['to_staff'], $vars['to_name'], $vars['from'], $vars['from_name'], $vars['to_admin']);
|
||||
unset($vars['default_description'], $vars['default_subject'], $vars['default_template'], $vars['code']);
|
||||
|
||||
// add additional variables to template
|
||||
@@ -167,6 +167,12 @@ class Service implements \Box\InjectionAwareInterface
|
||||
$vars['c'] = $customer;
|
||||
}
|
||||
|
||||
// send email to admins
|
||||
if (isset($data['to_admin']) && $data['to_admin'] > 0) {
|
||||
$oneStaff = $this->di['db']->findOne('Admin', 'id=?', [$data['to_admin']]);
|
||||
$vars['c'] = $oneStaff;
|
||||
}
|
||||
|
||||
$db = $this->di['db'];
|
||||
|
||||
$t = $db->findOne('EmailTemplate', 'action_code = :action', [':action' => $data['code']]);
|
||||
@@ -206,6 +212,10 @@ class Service implements \Box\InjectionAwareInterface
|
||||
$to_name = $staff['name'];
|
||||
$sent = $this->sendMail($to, $from, $subject, $content, $to_name, $from_name, null, $staff['id']);
|
||||
}
|
||||
} elseif (isset($oneStaff)) {
|
||||
$to = $oneStaff->email;
|
||||
$to_name = $oneStaff->name;
|
||||
$sent = $this->sendMail($to, $from, $subject, $content, $to_name, $from_name, $oneStaff->id);
|
||||
} elseif (isset($customer)) {
|
||||
$to = $customer['email'];
|
||||
$to_name = $customer['first_name'] . ' ' . $customer['last_name'];
|
||||
@@ -604,12 +614,13 @@ class Service implements \Box\InjectionAwareInterface
|
||||
error_log($message);
|
||||
|
||||
// Prevent mass retries of emails if one of them is "invalid"
|
||||
if(strpos($message, 'Invalid address:') !== false) {
|
||||
if (false !== strpos($message, 'Invalid address:')) {
|
||||
try {
|
||||
$this->di['db']->trash($queue);
|
||||
} catch (\Exception $e) {
|
||||
error_log($e->getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -620,7 +631,7 @@ class Service implements \Box\InjectionAwareInterface
|
||||
++$queue->tries;
|
||||
$queue->updated_at = date('Y-m-d H:i:s');
|
||||
$this->di['db']->store($queue);
|
||||
$maxTries = ( isset($settings['cancel_after']) ) ? $settings['cancel_after'] : 5;
|
||||
$maxTries = (isset($settings['cancel_after'])) ? $settings['cancel_after'] : 5;
|
||||
if ($queue->tries > $maxTries) {
|
||||
$this->di['db']->trash($queue);
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ class Guest extends \Api_Abstract
|
||||
|
||||
// send email
|
||||
$email = [];
|
||||
$email['to_client'] = $reset->admin_id;
|
||||
$email['to_admin'] = $c->id;
|
||||
$email['code'] = 'mod_staff_password_reset_request';
|
||||
$email['hash'] = $hash;
|
||||
$emailService = $this->di['mod_service']('email');
|
||||
|
||||
@@ -709,7 +709,7 @@ class Service implements InjectionAwareInterface
|
||||
|
||||
// send email
|
||||
$email = [];
|
||||
$email['to_client'] = $reset->admin_id;
|
||||
$email['to_admin'] = $c->id;
|
||||
$email['code'] = 'mod_staff_password_reset_approve';
|
||||
$email['password'] = $new_pass;
|
||||
$emailService = $this->di['mod_service']('email');
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% block content %}
|
||||
{% apply markdown %}
|
||||
|
||||
Hello {{ c.first_name }} {{ c.last_name }},
|
||||
Hello {{ c.name }},
|
||||
|
||||
As you requested, your password for our staff area has now been reset.
|
||||
Your new login details are as follows:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% block content %}
|
||||
{% apply markdown %}
|
||||
|
||||
Hello {{ c.first_name }} {{ c.last_name }},
|
||||
Hello {{ c.name }},
|
||||
|
||||
Recently a request was submitted to reset your password for the staff area.
|
||||
If you did not request this, please ignore this email. It will expire and will not work in 2 hours time.
|
||||
|
||||
Reference in new issue
Block a user