Apply fixes from StyleCI
This commit is contained in:

committed by
StyleCI Bot

parent
857d3004eb
commit
88f3df2180
@@ -3,21 +3,21 @@
|
||||
namespace App\Http\Controllers\Admin\helpdesk;
|
||||
|
||||
// controllers
|
||||
use App\Http\Controllers\Admin\MailFetch as Fetch;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\helpdesk\EmailsRequest;
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
// model
|
||||
use App\Http\Requests\helpdesk\Mail\MailRequest;
|
||||
use App\Model\helpdesk\Agent\Department;
|
||||
use App\Model\helpdesk\Email\Emails;
|
||||
use App\Model\helpdesk\Manage\Help_topic;
|
||||
use App\Model\helpdesk\Settings\Email;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Priority;
|
||||
// classes
|
||||
use App\Model\helpdesk\Utility\MailboxProtocol;
|
||||
use Crypt;
|
||||
// classes
|
||||
use Exception;
|
||||
use Lang;
|
||||
use App\Http\Requests\helpdesk\Mail\MailRequest;
|
||||
use App\Http\Controllers\Admin\MailFetch as Fetch;
|
||||
|
||||
/**
|
||||
* ======================================
|
||||
@@ -27,14 +27,15 @@ use App\Http\Controllers\Admin\MailFetch as Fetch;
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class EmailsController extends Controller {
|
||||
|
||||
class EmailsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Defining constructor variables.
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->middleware('roles');
|
||||
}
|
||||
@@ -46,7 +47,8 @@ class EmailsController extends Controller {
|
||||
*
|
||||
* @return type view
|
||||
*/
|
||||
public function index(Emails $email) {
|
||||
public function index(Emails $email)
|
||||
{
|
||||
try {
|
||||
// fetch all the emails from emails table
|
||||
$emails = $email->get();
|
||||
@@ -67,7 +69,8 @@ class EmailsController extends Controller {
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function create(Department $department, Help_topic $help, Ticket_Priority $ticket_priority, MailboxProtocol $mailbox_protocol) {
|
||||
public function create(Department $department, Help_topic $help, Ticket_Priority $ticket_priority, MailboxProtocol $mailbox_protocol)
|
||||
{
|
||||
try {
|
||||
// fetch all the departments from the department table
|
||||
$departments = $department->get();
|
||||
@@ -96,7 +99,8 @@ class EmailsController extends Controller {
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function validatingEmailSettings(MailRequest $request, $id = "") {
|
||||
public function validatingEmailSettings(MailRequest $request, $id = '')
|
||||
{
|
||||
//dd($request->all());
|
||||
try {
|
||||
$service_request = $request->except('sending_status', '_token', 'email_address', 'email_name', 'password', 'department', 'priority', 'help_topic', 'fetching_protocol', 'fetching_host', 'fetching_port', 'fetching_encryption', 'imap_authentication', 'sending_protocol', 'sending_host', 'sending_port', 'sending_encryption', 'smtp_authentication', 'internal_notes', '_wysihtml5_mode', 'code');
|
||||
@@ -114,8 +118,10 @@ class EmailsController extends Controller {
|
||||
}
|
||||
if ($send == 1 && $fetch == 1) {
|
||||
$this->store($request, $service_request, $id);
|
||||
|
||||
return $this->jsonResponse('success', Lang::get('lang.success'));
|
||||
}
|
||||
|
||||
return $this->validateEmailError($send, $fetch);
|
||||
} catch (Exception $ex) {
|
||||
$message = $ex->getMessage();
|
||||
@@ -123,11 +129,13 @@ class EmailsController extends Controller {
|
||||
$message = imap_last_error();
|
||||
}
|
||||
loging('mail-config', $message);
|
||||
|
||||
return $this->jsonResponse('fails', $message);
|
||||
}
|
||||
}
|
||||
|
||||
public function validateEmailError($out, $in) {
|
||||
public function validateEmailError($out, $in)
|
||||
{
|
||||
if ($out !== 1) {
|
||||
return $this->jsonResponse('fails', Lang::get('lang.outgoing_email_connection_failed'));
|
||||
}
|
||||
@@ -136,13 +144,15 @@ class EmailsController extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
public function jsonResponse($type, $message) {
|
||||
public function jsonResponse($type, $message)
|
||||
{
|
||||
if ($type == 'fails') {
|
||||
$result = ['fails' => $message];
|
||||
}
|
||||
if ($type == 'success') {
|
||||
$result = ['success' => $message];
|
||||
}
|
||||
|
||||
return response()->json(compact('result'));
|
||||
}
|
||||
|
||||
@@ -154,9 +164,10 @@ class EmailsController extends Controller {
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function store($request, $service_request = [], $id = "") {
|
||||
public function store($request, $service_request = [], $id = '')
|
||||
{
|
||||
$email = new Emails();
|
||||
if ($id !== "") {
|
||||
if ($id !== '') {
|
||||
$email = $email->find($id);
|
||||
}
|
||||
|
||||
@@ -208,7 +219,7 @@ class EmailsController extends Controller {
|
||||
if ($request->input('fetching_status')) {
|
||||
$this->fetch($email);
|
||||
}
|
||||
if ($id === "") {
|
||||
if ($id === '') {
|
||||
// Creating a default system email as the first email is inserted to the system
|
||||
$email_settings = Email::where('id', '=', '1')->first();
|
||||
$email_settings->sys_email = $email->id;
|
||||
@@ -222,10 +233,12 @@ class EmailsController extends Controller {
|
||||
if ($request->input('fetching_status')) {
|
||||
$this->fetch($email);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function checkMail($request) {
|
||||
public function checkMail($request)
|
||||
{
|
||||
$mailservice_id = $request->input('sending_protocol');
|
||||
$driver = $this->getDriver($mailservice_id);
|
||||
$username = $request->input('email_address');
|
||||
@@ -243,10 +256,12 @@ class EmailsController extends Controller {
|
||||
$transport->setPassword($password);
|
||||
$mailer = \Swift_Mailer::newInstance($transport);
|
||||
$mailer->getTransport()->start();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function sendDiagnoEmail($request) {
|
||||
public function sendDiagnoEmail($request)
|
||||
{
|
||||
$mailservice_id = $request->input('sending_protocol');
|
||||
$driver = $this->getDriver($mailservice_id);
|
||||
$username = $request->input('email_address');
|
||||
@@ -260,41 +275,45 @@ class EmailsController extends Controller {
|
||||
$this->emailService($driver, $service_request);
|
||||
$this->setMailConfig($driver, $username, $name, $password, $enc, $host, $port);
|
||||
$controller = new \App\Http\Controllers\Common\PhpMailController();
|
||||
$subject = "test";
|
||||
$data = "test";
|
||||
$subject = 'test';
|
||||
$data = 'test';
|
||||
//dd(\Config::get('mail'),\Config::get('services'));
|
||||
$send = $controller->laravelMail($username, $name, $subject, $data, [], []);
|
||||
|
||||
return $send;
|
||||
}
|
||||
|
||||
public function setMailConfig($driver, $username, $name, $password, $enc, $host, $port) {
|
||||
public function setMailConfig($driver, $username, $name, $password, $enc, $host, $port)
|
||||
{
|
||||
$configs = [
|
||||
'username' => $username,
|
||||
'from' => ['address' => $username, 'name' => $name,],
|
||||
'password' => $password,
|
||||
'username' => $username,
|
||||
'from' => ['address' => $username, 'name' => $name],
|
||||
'password' => $password,
|
||||
'encryption' => $enc,
|
||||
'host' => $host,
|
||||
'port' => $port,
|
||||
'driver' => $driver,
|
||||
'host' => $host,
|
||||
'port' => $port,
|
||||
'driver' => $driver,
|
||||
];
|
||||
foreach ($configs as $key => $config) {
|
||||
if (is_array($config)) {
|
||||
foreach ($config as $from) {
|
||||
\Config::set('mail.' . $key, $config);
|
||||
\Config::set('mail.'.$key, $config);
|
||||
}
|
||||
} else {
|
||||
\Config::set('mail.' . $key, $config);
|
||||
\Config::set('mail.'.$key, $config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getDriver($driver_id) {
|
||||
$short = "";
|
||||
public function getDriver($driver_id)
|
||||
{
|
||||
$short = '';
|
||||
$email_drivers = new \App\Model\MailJob\MailService();
|
||||
$email_driver = $email_drivers->find($driver_id);
|
||||
if ($email_driver) {
|
||||
$short = $email_driver->short_name;
|
||||
}
|
||||
|
||||
return $short;
|
||||
}
|
||||
|
||||
@@ -310,7 +329,8 @@ class EmailsController extends Controller {
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function edit($id, Department $department, Help_topic $help, Emails $email, Ticket_Priority $ticket_priority, MailboxProtocol $mailbox_protocol) {
|
||||
public function edit($id, Department $department, Help_topic $help, Emails $email, Ticket_Priority $ticket_priority, MailboxProtocol $mailbox_protocol)
|
||||
{
|
||||
try {
|
||||
$sys_email = \DB::table('settings_email')->select('sys_email')->where('id', '=', 1)->first();
|
||||
// dd($sys_email);
|
||||
@@ -345,7 +365,8 @@ class EmailsController extends Controller {
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function validatingEmailSettingsUpdate($id, MailRequest $request) {
|
||||
public function validatingEmailSettingsUpdate($id, MailRequest $request)
|
||||
{
|
||||
try {
|
||||
return $this->validatingEmailSettings($request, $id);
|
||||
} catch (Exception $ex) {
|
||||
@@ -369,9 +390,9 @@ class EmailsController extends Controller {
|
||||
*
|
||||
* @return type Response
|
||||
*/
|
||||
public function update($id, $request) {
|
||||
public function update($id, $request)
|
||||
{
|
||||
try {
|
||||
|
||||
if ($request->sys_email == 'on') {
|
||||
$system = \DB::table('settings_email')
|
||||
->where('id', '=', 1)
|
||||
@@ -397,7 +418,8 @@ class EmailsController extends Controller {
|
||||
*
|
||||
* @return type Redirect
|
||||
*/
|
||||
public function destroy($id, Emails $email) {
|
||||
public function destroy($id, Emails $email)
|
||||
{
|
||||
// fetching the details on the basis of the $id passed to the function
|
||||
$default_system_email = Email::where('id', '=', '1')->first();
|
||||
if ($default_system_email->sys_email) {
|
||||
@@ -411,6 +433,7 @@ class EmailsController extends Controller {
|
||||
$emails = $email->whereId($id)->first();
|
||||
// checking if deleting the email is success or if it's carrying any dependencies
|
||||
$emails->delete();
|
||||
|
||||
return redirect('emails')->with('success', Lang::get('lang.email_deleted_sucessfully'));
|
||||
} catch (Exception $e) {
|
||||
// returns if the try fails
|
||||
@@ -425,7 +448,8 @@ class EmailsController extends Controller {
|
||||
*
|
||||
* @return type int
|
||||
*/
|
||||
public function getImapStream($request) {
|
||||
public function getImapStream($request)
|
||||
{
|
||||
$host = $request->input('fetching_host');
|
||||
$port = $request->input('fetching_port');
|
||||
$service = $request->input('fetching_protocol');
|
||||
@@ -435,7 +459,7 @@ class EmailsController extends Controller {
|
||||
$password = $request->input('password');
|
||||
$server = new Fetch($host, $port, $service);
|
||||
//$server->setFlag('novalidate-cert');
|
||||
if ($encryption != "") {
|
||||
if ($encryption != '') {
|
||||
$server->setFlag($encryption);
|
||||
}
|
||||
if (!$validate) {
|
||||
@@ -446,6 +470,7 @@ class EmailsController extends Controller {
|
||||
|
||||
$server->setAuthentication($username, $password);
|
||||
$server->getImapStream();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -456,7 +481,8 @@ class EmailsController extends Controller {
|
||||
*
|
||||
* @return type int
|
||||
*/
|
||||
public function checkImapStream($imap_stream) {
|
||||
public function checkImapStream($imap_stream)
|
||||
{
|
||||
$check_imap_stream = imap_check($imap_stream);
|
||||
if ($check_imap_stream) {
|
||||
$imap_stream = 1;
|
||||
@@ -474,7 +500,8 @@ class EmailsController extends Controller {
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSmtp($request) {
|
||||
public function getSmtp($request)
|
||||
{
|
||||
$sending_status = $request->input('sending_status');
|
||||
// cheking for the sending protocol
|
||||
if ($request->input('sending_protocol') == 'smtp') {
|
||||
@@ -490,8 +517,8 @@ class EmailsController extends Controller {
|
||||
$mail->SMTPAuth = true; // Enable SMTP authentication
|
||||
$mail->SMTPOptions = [
|
||||
'ssl' => [
|
||||
'verify_peer' => false,
|
||||
'verify_peer_name' => false,
|
||||
'verify_peer' => false,
|
||||
'verify_peer_name' => false,
|
||||
'allow_self_signed' => true,
|
||||
],
|
||||
];
|
||||
@@ -523,7 +550,8 @@ class EmailsController extends Controller {
|
||||
*
|
||||
* @return type string or null
|
||||
*/
|
||||
public function departmentValue($dept) {
|
||||
public function departmentValue($dept)
|
||||
{
|
||||
if ($dept) {
|
||||
$email_department = $dept;
|
||||
} else {
|
||||
@@ -540,7 +568,8 @@ class EmailsController extends Controller {
|
||||
*
|
||||
* @return type string or null
|
||||
*/
|
||||
public function priorityValue($priority) {
|
||||
public function priorityValue($priority)
|
||||
{
|
||||
if ($priority) {
|
||||
$email_priority = $priority;
|
||||
} else {
|
||||
@@ -557,7 +586,8 @@ class EmailsController extends Controller {
|
||||
*
|
||||
* @return type string or null
|
||||
*/
|
||||
public function helpTopicValue($help_topic) {
|
||||
public function helpTopicValue($help_topic)
|
||||
{
|
||||
if ($help_topic) {
|
||||
$email_help_topic = $help_topic;
|
||||
} else {
|
||||
@@ -567,18 +597,20 @@ class EmailsController extends Controller {
|
||||
return $email_help_topic;
|
||||
}
|
||||
|
||||
public function emailService($service, $value = []) {
|
||||
public function emailService($service, $value = [])
|
||||
{
|
||||
switch ($service) {
|
||||
case "mailgun":
|
||||
case 'mailgun':
|
||||
$this->setServiceConfig($service, $value);
|
||||
case "mandrill":
|
||||
case 'mandrill':
|
||||
$this->setServiceConfig($service, $value);
|
||||
case "ses":
|
||||
case 'ses':
|
||||
$this->setServiceConfig($service, $value);
|
||||
}
|
||||
}
|
||||
|
||||
public function setServiceConfig($service, $value) {
|
||||
public function setServiceConfig($service, $value)
|
||||
{
|
||||
//dd($service);
|
||||
if (count($value) > 0) {
|
||||
foreach ($value as $k => $v) {
|
||||
@@ -587,7 +619,8 @@ class EmailsController extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
public function saveMailService($emailid, $request, $driver) {
|
||||
public function saveMailService($emailid, $request, $driver)
|
||||
{
|
||||
$mail_service = new \App\Model\MailJob\FaveoMail();
|
||||
$mails = $mail_service->where('email_id', $emailid)->get();
|
||||
if (count($request) > 0) {
|
||||
@@ -596,16 +629,17 @@ class EmailsController extends Controller {
|
||||
}
|
||||
foreach ($request as $key => $value) {
|
||||
$mail_service->create([
|
||||
'drive' => $driver,
|
||||
'key' => $key,
|
||||
'value' => $value,
|
||||
'drive' => $driver,
|
||||
'key' => $key,
|
||||
'value' => $value,
|
||||
'email_id' => $emailid,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function readMails() {
|
||||
public function readMails()
|
||||
{
|
||||
$PhpMailController = new \App\Http\Controllers\Common\PhpMailController();
|
||||
$NotificationController = new \App\Http\Controllers\Common\NotificationController();
|
||||
$TicketController = new \App\Http\Controllers\Agent\helpdesk\TicketController($PhpMailController, $NotificationController);
|
||||
@@ -618,7 +652,8 @@ class EmailsController extends Controller {
|
||||
$controller->readmails($emails, $settings_email, $system, $ticket);
|
||||
}
|
||||
|
||||
public function fetch($email) {
|
||||
public function fetch($email)
|
||||
{
|
||||
$PhpMailController = new \App\Http\Controllers\Common\PhpMailController();
|
||||
$NotificationController = new \App\Http\Controllers\Common\NotificationController();
|
||||
$TicketController = new \App\Http\Controllers\Agent\helpdesk\TicketController($PhpMailController, $NotificationController);
|
||||
@@ -626,5 +661,4 @@ class EmailsController extends Controller {
|
||||
$controller = new \App\Http\Controllers\Agent\helpdesk\MailController($TicketWorkflowController);
|
||||
$controller->fetch($email);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user