From 1b77330ddea2d253acae536e0d48c457e6416912 Mon Sep 17 00:00:00 2001 From: Bhanu Date: Mon, 13 Jun 2016 11:30:41 -0400 Subject: [PATCH] Applied fixes from StyleCI --- app/Exceptions/Handler.php | 68 +- .../Admin/helpdesk/DepartmentController.php | 3 +- .../Admin/helpdesk/EmailsController.php | 86 +- .../helpdesk/ErrorAndDebuggingController.php | 121 ++- .../Admin/helpdesk/HelptopicController.php | 2 +- .../Admin/helpdesk/SettingsController.php | 2 +- .../Admin/helpdesk/SlaController.php | 4 +- .../Admin/helpdesk/TemplateController.php | 95 +- .../Admin/helpdesk/WorkflowController.php | 2 +- .../Agent/helpdesk/MailController.php | 58 +- .../Agent/helpdesk/UserController.php | 1 + .../Agent/kb/ArticleController.php | 55 +- .../Agent/kb/CategoryController.php | 50 +- .../Controllers/Agent/kb/PageController.php | 37 +- app/Http/Controllers/Auth/AuthController.php | 59 +- .../helpdesk/ClientTicketController.php | 2 +- .../Client/helpdesk/FormController.php | 50 +- .../Client/helpdesk/WelcomepageController.php | 16 +- .../Controllers/Common/PhpMailController.php | 27 +- app/Http/Kernel.php | 2 +- app/Http/Middleware/CheckBoard.php | 23 +- app/Http/Middleware/CheckUpdate.php | 5 +- app/Http/routes.php | 16 +- app/Model/helpdesk/Ticket/Ticket_Thread.php | 11 +- config/app.php | 96 +- config/bugsnag.php | 138 +-- database/seeds/DatabaseSeeder.php | 20 +- resources/lang/de/lang.php | 76 +- resources/lang/de/pagination.php | 2 +- resources/lang/de/passwords.php | 4 +- resources/lang/de/validation.php | 2 +- resources/lang/en/lang.php | 72 +- resources/lang/it/passwords.php | 2 +- resources/lang/ru/lang.php | 994 +++++++++--------- resources/lang/ru/pagination.php | 24 +- resources/lang/ru/passwords.php | 30 +- resources/lang/ru/table.php | 40 +- resources/lang/ru/validation.php | 192 ++-- 38 files changed, 1302 insertions(+), 1185 deletions(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 0496485b6..197d2b548 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -3,20 +3,19 @@ namespace App\Exceptions; // controller -use Exception; +use Bugsnag; //use Illuminate\Validation\ValidationException; -use Illuminate\Foundation\Validation\ValidationException; +use Bugsnag\BugsnagLaravel\BugsnagExceptionHandler as ExceptionHandler; +use Exception; use Illuminate\Auth\Access\AuthorizationException; -use Illuminate\Database\Eloquent\ModelNotFoundException; // use Symfony\Component\HttpKernel\Exception\HttpException; // use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; -use Bugsnag\BugsnagLaravel\BugsnagExceptionHandler as ExceptionHandler; -use Bugsnag; -use Symfony\Component\HttpFoundation\RedirectResponse; +use Illuminate\Database\Eloquent\ModelNotFoundException; +use Illuminate\Foundation\Validation\ValidationException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; -class Handler extends ExceptionHandler { - +class Handler extends ExceptionHandler +{ /** * A list of the exception types that should not be reported. * @@ -53,7 +52,8 @@ class Handler extends ExceptionHandler { * * @return void */ - public function report(Exception $e) { + public function report(Exception $e) + { $debug = \Config::get('app.bugsnag_reporting'); $debug = ($debug) ? 'true' : 'false'; if ($debug == 'false') { @@ -61,6 +61,7 @@ class Handler extends ExceptionHandler { return false; }); } + return parent::report($e); } @@ -88,7 +89,7 @@ class Handler extends ExceptionHandler { // if (\Config::get('database.install') == 1) { // // checking if the error log send to Ladybirdweb is enabled or not // if (\Config::get('app.ErrorLog') == '1') { -// +// // } // } // return response()->view('errors.500', []); @@ -128,66 +129,79 @@ class Handler extends ExceptionHandler { /** * Render an exception into an HTTP response. - * @param type $request + * + * @param type $request * @param Exception $e + * * @return type mixed */ - public function render($request, Exception $e) { - + public function render($request, Exception $e) + { switch ($e) { - case $e instanceof \Illuminate\Http\Exception\HttpResponseException : + case $e instanceof \Illuminate\Http\Exception\HttpResponseException: return parent::render($request, $e); - case $e instanceof \Tymon\JWTAuth\Exceptions\TokenExpiredException : + case $e instanceof \Tymon\JWTAuth\Exceptions\TokenExpiredException: return response()->json(['message' => $e->getMessage(), 'code' => $e->getStatusCode()]); - case $e instanceof \Tymon\JWTAuth\Exceptions\TokenInvalidException : + case $e instanceof \Tymon\JWTAuth\Exceptions\TokenInvalidException: return response()->json(['message' => $e->getMessage(), 'code' => $e->getStatusCode()]); - default : + default: return $this->common($request, $e); } } /** - * Function to render 500 error page + * Function to render 500 error page. + * * @param type $request * @param type $e + * * @return type mixed */ - public function render500($request, $e) { + public function render500($request, $e) + { if (config('app.debug') == true) { return parent::render($request, $e); } + return redirect()->route('error500', []); } /** - * Function to render 404 error page + * Function to render 404 error page. + * * @param type $request * @param type $e + * * @return type mixed */ - public function render404($request, $e) { + public function render404($request, $e) + { if (config('app.debug') == true) { return parent::render($request, $e); } + return redirect()->route('error404', []); } /** - * Common finction to render both types of codes + * Common finction to render both types of codes. + * * @param type $request * @param type $e + * * @return type mixed */ - public function common($request, $e) { + public function common($request, $e) + { switch ($e) { - case $e instanceof HttpException : + case $e instanceof HttpException: return $this->render404($request, $e); - case $e instanceof NotFoundHttpException : + case $e instanceof NotFoundHttpException: return $this->render404($request, $e); - default : + default: return $this->render500($request, $e); } + return parent::render($request, $e); } - } diff --git a/app/Http/Controllers/Admin/helpdesk/DepartmentController.php b/app/Http/Controllers/Admin/helpdesk/DepartmentController.php index 95dadf0a4..07aba16d5 100644 --- a/app/Http/Controllers/Admin/helpdesk/DepartmentController.php +++ b/app/Http/Controllers/Admin/helpdesk/DepartmentController.php @@ -143,7 +143,7 @@ class DepartmentController extends Controller public function edit($id, User $user, Group_assign_department $group_assign_department, Template $template, Teams $team, Department $department, Sla_plan $sla, Emails $email, Groups $group) { try { - $sys_department = \DB::table('settings_system') + $sys_department = \DB::table('settings_system') ->select('department') ->where('id', '=', 1) ->first(); @@ -175,7 +175,6 @@ class DepartmentController extends Controller { // dd($id); try { - $table = $group_assign_department->where('department_id', $id); $table->delete(); $requests = $request->input('group_id'); diff --git a/app/Http/Controllers/Admin/helpdesk/EmailsController.php b/app/Http/Controllers/Admin/helpdesk/EmailsController.php index e4b767aef..fdec69f00 100644 --- a/app/Http/Controllers/Admin/helpdesk/EmailsController.php +++ b/app/Http/Controllers/Admin/helpdesk/EmailsController.php @@ -28,14 +28,15 @@ use Lang; * * @author Ladybird */ -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'); } @@ -47,7 +48,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(); @@ -68,7 +70,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(); @@ -93,16 +96,17 @@ class EmailsController extends Controller { * * @return int */ - public function validatingEmailSettings(Request $request) { + public function validatingEmailSettings(Request $request) + { $validator = \Validator::make( [ 'email_address' => $request->input('email_address'), - 'email_name' => $request->input('email_name'), - 'password' => $request->input('password'), + 'email_name' => $request->input('email_name'), + 'password' => $request->input('password'), ], [ 'email_address' => 'required|email|unique:emails', - 'email_name' => 'required', - 'password' => 'required', + 'email_name' => 'required', + 'password' => 'required', ] ); if ($validator->fails()) { @@ -173,7 +177,8 @@ class EmailsController extends Controller { * * @return type Redirect */ - public function store($request, $imap_check) { + public function store($request, $imap_check) + { $email = new Emails(); try { // saving all the fields to the database @@ -255,7 +260,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); @@ -286,16 +292,17 @@ class EmailsController extends Controller { * * @return int */ - public function validatingEmailSettingsUpdate($id, Request $request) { + public function validatingEmailSettingsUpdate($id, Request $request) + { $validator = \Validator::make( [ 'email_address' => $request->input('email_address'), - 'email_name' => $request->input('email_name'), - 'password' => $request->input('password'), + 'email_name' => $request->input('email_name'), + 'password' => $request->input('password'), ], [ 'email_address' => 'email', - 'email_name' => 'required', - 'password' => 'required', + 'email_name' => 'required', + 'password' => 'required', ] ); if ($validator->fails()) { @@ -368,7 +375,8 @@ class EmailsController extends Controller { * * @return type Response */ - public function update($id, $request, $imap_check) { + public function update($id, $request, $imap_check) + { try { // fetch the selected emails $emails = Emails::whereId($id)->first(); @@ -418,12 +426,12 @@ class EmailsController extends Controller { // $emails->password = Crypt::encrypt($request->input('password')); $emails->save(); //dd($request->sys_email); - if($request->sys_email == 'on') { + if ($request->sys_email == 'on') { $system = \DB::table('settings_email') ->where('id', '=', 1) ->update(['sys_email' => $id]); } elseif ($request->input('count') <= 1 && $request->sys_email == null) { - $system = \DB::table('settings_email') + $system = \DB::table('settings_email') ->where('id', '=', 1) ->update(['sys_email' => null]); } @@ -445,7 +453,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) { @@ -476,25 +485,26 @@ class EmailsController extends Controller { * * @return type int */ - public function getImapStream($request, $validate) { + public function getImapStream($request, $validate) + { $fetching_status = $request->input('fetching_status'); $username = $request->input('email_address'); $password = $request->input('password'); $protocol_id = $request->input('mailbox_protocol'); - $fetching_protocol = '/' . $request->input('fetching_protocol'); - $fetching_encryption = '/' . $request->input('fetching_encryption'); + $fetching_protocol = '/'.$request->input('fetching_protocol'); + $fetching_encryption = '/'.$request->input('fetching_encryption'); if ($fetching_encryption == '/none') { $fetching_encryption2 = '/novalidate-cert'; $mailbox_protocol = $fetching_encryption2; $host = $request->input('fetching_host'); $port = $request->input('fetching_port'); - $mailbox = '{' . $host . ':' . $port . $mailbox_protocol . '}INBOX'; + $mailbox = '{'.$host.':'.$port.$mailbox_protocol.'}INBOX'; } else { - $mailbox_protocol = $fetching_protocol . $fetching_encryption; + $mailbox_protocol = $fetching_protocol.$fetching_encryption; $host = $request->input('fetching_host'); $port = $request->input('fetching_port'); - $mailbox = '{' . $host . ':' . $port . $mailbox_protocol . $validate . '}INBOX'; - $mailbox_protocol = $fetching_encryption . $validate; + $mailbox = '{'.$host.':'.$port.$mailbox_protocol.$validate.'}INBOX'; + $mailbox_protocol = $fetching_encryption.$validate; } try { $imap_stream = imap_open($mailbox, $username, $password); @@ -518,7 +528,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; @@ -536,7 +547,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') { @@ -552,8 +564,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, ], ]; @@ -585,7 +597,8 @@ class EmailsController extends Controller { * * @return type string or null */ - public function departmentValue($dept) { + public function departmentValue($dept) + { if ($dept) { $email_department = $dept; } else { @@ -602,7 +615,8 @@ class EmailsController extends Controller { * * @return type string or null */ - public function priorityValue($priority) { + public function priorityValue($priority) + { if ($priority) { $email_priority = $priority; } else { @@ -619,7 +633,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 { @@ -628,5 +643,4 @@ class EmailsController extends Controller { return $email_help_topic; } - } diff --git a/app/Http/Controllers/Admin/helpdesk/ErrorAndDebuggingController.php b/app/Http/Controllers/Admin/helpdesk/ErrorAndDebuggingController.php index d826cf07c..1900369be 100644 --- a/app/Http/Controllers/Admin/helpdesk/ErrorAndDebuggingController.php +++ b/app/Http/Controllers/Admin/helpdesk/ErrorAndDebuggingController.php @@ -3,22 +3,21 @@ namespace App\Http\Controllers\Admin\helpdesk; // controller -use App\Http\Controllers\Common\PhpMailController; use App\Http\Controllers\Controller; // request use Exception; -use Lang; use File; +use Lang; /** - * ErrorAndDebuggingController + * ErrorAndDebuggingController. * * @author Ladybird */ class ErrorAndDebuggingController extends Controller { - /** + /** * Create a new controller instance. * * @return void @@ -31,68 +30,76 @@ class ErrorAndDebuggingController extends Controller } /** - * function to show error and debugging setting page + * function to show error and debugging setting page. + * * @param void - * @return response + * + * @return response */ - public function showSettings() - { - $debug = \Config::get('app.debug'); - $bugsnag = \Config::get('app.bugsnag_reporting'); - return view('themes.default1.admin.helpdesk.settings.error-and-logs.error-debug')->with(['debug'=> $debug, 'bugsnag' => $bugsnag]); - } + public function showSettings() + { + $debug = \Config::get('app.debug'); + $bugsnag = \Config::get('app.bugsnag_reporting'); - /** - * funtion to update error and debugging settings - * @param void - * @return - */ - public function postSettings() - { - try{ - $debug = \Config::get('app.debug'); - $debug = ($debug) ? 'true' : 'false'; - $bugsnag_debug = \Config::get('app.bugsnag_reporting'); - $bugsnag_debug = ($bugsnag_debug) ? 'true' : 'false'; - if ($debug != \Input::get('debug') || $bugsnag_debug != \Input::get('bugsnag')) { - // dd($request->input()); - $debug_new = base_path() - .DIRECTORY_SEPARATOR. - 'config' - .DIRECTORY_SEPARATOR. - 'app.php'; - $datacontent = File::get($debug_new); - $datacontent = str_replace("'debug' => ".$debug, - "'debug' => ".\Input::get('debug'), - $datacontent); - File::put($debug_new, $datacontent); - - // dd($request->input()); - $bugsnag_debug_new = base_path() - .DIRECTORY_SEPARATOR. - 'config' - .DIRECTORY_SEPARATOR. - 'app.php'; - $datacontent2 = File::get($bugsnag_debug_new); - $datacontent2 = str_replace("'bugsnag_reporting' => ".$bugsnag_debug, - "'bugsnag_reporting' => ".\Input::get('bugsnag'), - $datacontent2); - File::put($bugsnag_debug_new, $datacontent2); - return redirect()->back()->with('success', - Lang::get('lang.error-debug-settings-saved-message')); - } else { - return redirect()->back()->with('fails', - Lang::get('lang.error-debug-settings-error-message')); - } + return view('themes.default1.admin.helpdesk.settings.error-and-logs.error-debug')->with(['debug' => $debug, 'bugsnag' => $bugsnag]); + } + + /** + * funtion to update error and debugging settings. + * + * @param void + * + * @return + */ + public function postSettings() + { + try { + $debug = \Config::get('app.debug'); + $debug = ($debug) ? 'true' : 'false'; + $bugsnag_debug = \Config::get('app.bugsnag_reporting'); + $bugsnag_debug = ($bugsnag_debug) ? 'true' : 'false'; + if ($debug != \Input::get('debug') || $bugsnag_debug != \Input::get('bugsnag')) { + // dd($request->input()); + $debug_new = base_path() + .DIRECTORY_SEPARATOR. + 'config' + .DIRECTORY_SEPARATOR. + 'app.php'; + $datacontent = File::get($debug_new); + $datacontent = str_replace("'debug' => ".$debug, + "'debug' => ".\Input::get('debug'), + $datacontent); + File::put($debug_new, $datacontent); + + // dd($request->input()); + $bugsnag_debug_new = base_path() + .DIRECTORY_SEPARATOR. + 'config' + .DIRECTORY_SEPARATOR. + 'app.php'; + $datacontent2 = File::get($bugsnag_debug_new); + $datacontent2 = str_replace("'bugsnag_reporting' => ".$bugsnag_debug, + "'bugsnag_reporting' => ".\Input::get('bugsnag'), + $datacontent2); + File::put($bugsnag_debug_new, $datacontent2); + + return redirect()->back()->with('success', + Lang::get('lang.error-debug-settings-saved-message')); + } else { + return redirect()->back()->with('fails', + Lang::get('lang.error-debug-settings-error-message')); + } } catch (Exception $e) { /* redirect to Index page with Fails Message */ return redirect()->back()->with('fails', $e->getMessage()); - } - } + } + } /** - * function to show error log table page + * function to show error log table page. + * * @param void + * * @return response view */ public function showErrorLogs() diff --git a/app/Http/Controllers/Admin/helpdesk/HelptopicController.php b/app/Http/Controllers/Admin/helpdesk/HelptopicController.php index f96afb703..4d48ddf8e 100644 --- a/app/Http/Controllers/Admin/helpdesk/HelptopicController.php +++ b/app/Http/Controllers/Admin/helpdesk/HelptopicController.php @@ -152,7 +152,7 @@ class HelptopicController extends Controller $sys_help_topic = \DB::table('settings_ticket') ->select('help_topic') ->where('id', '=', 1)->first(); - + return view('themes.default1.admin.helpdesk.manage.helptopic.edit', compact('priority', 'departments', 'topics', 'forms', 'agents', 'slas', 'sys_help_topic')); } catch (Exception $e) { return redirect('helptopic')->with('fails', '
  • '.$e->getMessage().'
  • '); diff --git a/app/Http/Controllers/Admin/helpdesk/SettingsController.php b/app/Http/Controllers/Admin/helpdesk/SettingsController.php index 1b8d66e41..c7d601b94 100644 --- a/app/Http/Controllers/Admin/helpdesk/SettingsController.php +++ b/app/Http/Controllers/Admin/helpdesk/SettingsController.php @@ -182,7 +182,7 @@ class SettingsController extends Controller /* Check whether function success or not */ $systems->fill($request->input())->save(); /* redirect to Index page with Success Message */ - + // dd($datacontent); //\Config::set('app.debug', $request->input('debug')); return redirect('getsystem')->with('success', Lang::get('lang.system_updated_successfully')); diff --git a/app/Http/Controllers/Admin/helpdesk/SlaController.php b/app/Http/Controllers/Admin/helpdesk/SlaController.php index 8ddab22da..65e3fe7c8 100644 --- a/app/Http/Controllers/Admin/helpdesk/SlaController.php +++ b/app/Http/Controllers/Admin/helpdesk/SlaController.php @@ -104,7 +104,8 @@ class SlaController extends Controller $slas = Sla_plan::whereId($id)->first(); $slas->get(); $sla = \DB::table('settings_ticket')->select('sla')->where('id', '=', 1)->first(); - return view('themes.default1.admin.helpdesk.manage.sla.edit', compact('slas','sla')); + + return view('themes.default1.admin.helpdesk.manage.sla.edit', compact('slas', 'sla')); } catch (Exception $e) { return redirect()->back()->with('fails', $e->getMessage()); } @@ -137,6 +138,7 @@ class SlaController extends Controller ->where('id', '=', 1) ->update(['sla' => $id]); } + return redirect('sla')->with('success', Lang::get('lang.sla_plan_updated_successfully')); } catch (Exception $e) { /* redirect to Index page with Fails Message */ diff --git a/app/Http/Controllers/Admin/helpdesk/TemplateController.php b/app/Http/Controllers/Admin/helpdesk/TemplateController.php index 6b7600cd1..6cb0f522e 100644 --- a/app/Http/Controllers/Admin/helpdesk/TemplateController.php +++ b/app/Http/Controllers/Admin/helpdesk/TemplateController.php @@ -24,14 +24,15 @@ use Lang; * * @author Ladybird */ -class TemplateController extends Controller { - +class TemplateController extends Controller +{ /** * Create a new controller instance. * * @return type void */ - public function __construct(PhpMailController $PhpMailController) { + public function __construct(PhpMailController $PhpMailController) + { $this->PhpMailController = $PhpMailController; $this->middleware('auth'); $this->middleware('roles'); @@ -44,7 +45,8 @@ class TemplateController extends Controller { * * @return type Response */ - public function index(Template $template) { + public function index(Template $template) + { try { $templates = $template->get(); @@ -62,7 +64,8 @@ class TemplateController extends Controller { * * @return type Response */ - public function create(Languages $language, Template $template) { + public function create(Languages $language, Template $template) + { try { $templates = $template->get(); $languages = $language->get(); @@ -81,7 +84,8 @@ class TemplateController extends Controller { * * @return type Response */ - public function store(Template $template, TemplateRequest $request) { + public function store(Template $template, TemplateRequest $request) + { try { /* Check whether function success or not */ if ($template->fill($request->input())->save() == true) { @@ -104,7 +108,8 @@ class TemplateController extends Controller { * * @return Response */ - public function show($id) { + public function show($id) + { // } @@ -117,37 +122,41 @@ class TemplateController extends Controller { * * @return type Response */ - public function listdirectories() { - $path = \Config::get('view.paths')[0] . '/emails/'; + public function listdirectories() + { + $path = \Config::get('view.paths')[0].'/emails/'; $directories = scandir($path); $directory = str_replace('/', '-', $path); return view('themes.default1.admin.helpdesk.emails.template.listdirectories', compact('directories', 'directory')); } - public function listtemplates($template, $path) { + public function listtemplates($template, $path) + { $paths = str_replace('-', '/', $path); - $directory2 = $paths . $template; + $directory2 = $paths.$template; $templates = scandir($directory2); - $directory = str_replace('/', '-', $directory2 . '/'); + $directory = str_replace('/', '-', $directory2.'/'); return view('themes.default1.admin.helpdesk.emails.template.listtemplates', compact('templates', 'directory')); } - public function readtemplate($template, $path) { + public function readtemplate($template, $path) + { $directory = str_replace('-', '/', $path); - $handle = fopen($directory . $template, 'r'); - $contents = fread($handle, filesize($directory . $template)); + $handle = fopen($directory.$template, 'r'); + $contents = fread($handle, filesize($directory.$template)); fclose($handle); return view('themes.default1.admin.helpdesk.emails.template.readtemplates', compact('contents', 'template', 'path')); } - public function createtemplate() { + public function createtemplate() + { $directory = '../resources/views/emails/'; $fname = Input::get('folder_name'); - $filename = $directory . $fname; + $filename = $directory.$fname; // images folder creation using php // $mydir = dirname( __FILE__ )."/html/images"; @@ -159,7 +168,7 @@ class TemplateController extends Controller { if (!file_exists($filename)) { mkdir($filename, 0777); } - $files = array_filter(scandir($directory . 'default')); + $files = array_filter(scandir($directory.'default')); foreach ($files as $file) { if ($file === '.' or $file === '..') { @@ -167,27 +176,29 @@ class TemplateController extends Controller { } if (!is_dir($file)) { // $file_to_go = str_replace("code/resources/views/emails/",'code/resources/views/emails/'.$fname,$file); - $destination = $directory . $fname . '/'; + $destination = $directory.$fname.'/'; - copy($directory . 'default/' . $file, $destination . $file); + copy($directory.'default/'.$file, $destination.$file); } } return \Redirect::back()->with('success', 'Successfully copied'); } - public function writetemplate($template, $path) { + public function writetemplate($template, $path) + { $directory = str_replace('-', '/', $path); $b = Input::get('templatedata'); - file_put_contents($directory . $template, print_r($b, true)); + file_put_contents($directory.$template, print_r($b, true)); return \Redirect::back()->with('success', 'Successfully updated'); } - public function deletetemplate($template, $path) { + public function deletetemplate($template, $path) + { $directory = str_replace('-', '/', $path); - $dir = $directory . $template; + $dir = $directory.$template; $status = \DB::table('settings_email')->first(); if ($template == 'default' or $template == $status->template) { return \Redirect::back()->with('fails', 'You cannot delete a default or active directory!'); @@ -196,7 +207,7 @@ class TemplateController extends Controller { $objects = scandir($dir); foreach ($objects as $object) { if ($object != '.' && $object != '..') { - unlink($dir . '/' . $object); + unlink($dir.'/'.$object); } } rmdir($dir); @@ -207,13 +218,15 @@ class TemplateController extends Controller { return \Redirect::back()->with('success', 'Successfully Deleted'); } - public function activateset($setname) { + public function activateset($setname) + { \DB::table('settings_email')->update(['template' => $setname]); return \Redirect::back()->with('success', 'You have Successfully Activated this Set'); } - public function edit($id, Template $template, Languages $language) { + public function edit($id, Template $template, Languages $language) + { try { $templates = $template->whereId($id)->first(); $languages = $language->get(); @@ -233,7 +246,8 @@ class TemplateController extends Controller { * * @return type Response */ - public function update($id, Template $template, TemplateUdate $request) { + public function update($id, Template $template, TemplateUdate $request) + { try { //TODO validation $templates = $template->whereId($id)->first(); @@ -259,7 +273,8 @@ class TemplateController extends Controller { * * @return type Response */ - public function destroy($id, Template $template) { + public function destroy($id, Template $template) + { try { $templates = $template->whereId($id)->first(); /* Check whether function success or not */ @@ -283,7 +298,8 @@ class TemplateController extends Controller { * * @return type Response */ - public function formDiagno(Emails $email) { + public function formDiagno(Emails $email) + { try { $emails = $email->get(); @@ -300,7 +316,8 @@ class TemplateController extends Controller { * * @return type */ - public function postDiagno(DiagnosRequest $request) { + public function postDiagno(DiagnosRequest $request) + { try { $email_details = Emails::where('id', '=', $request->from)->first(); if ($email_details->sending_protocol == 'mail') { @@ -308,12 +325,12 @@ class TemplateController extends Controller { $mail->IsSendmail(); // telling the class to use SendMail transport $mail->SetFrom($email_details->email_address, $email_details->email_name); // sender details $address = $request->to; // receiver email - $mail->AddAddress($address); + $mail->AddAddress($address); $mail->Subject = $request->subject; // subject of the email $body = $request->message; // body of the email - $mail->MsgHTML($body); - if (!$mail->Send()) { - $return = Lang::get('lang.mailer_error') . ': ' . $mail->ErrorInfo; + $mail->MsgHTML($body); + if (!$mail->Send()) { + $return = Lang::get('lang.mailer_error').': '.$mail->ErrorInfo; } else { $return = Lang::get('lang.message_has_been_sent'); } @@ -323,8 +340,8 @@ class TemplateController extends Controller { if ($email_details->smtp_validate == '1') { $mail->SMTPOptions = [ 'ssl' => [ - 'verify_peer' => false, - 'verify_peer_name' => false, + 'verify_peer' => false, + 'verify_peer_name' => false, 'allow_self_signed' => true, ], ]; @@ -341,15 +358,15 @@ class TemplateController extends Controller { $mail->Subject = $request->subject; $mail->Body = utf8_decode($request->message); if (!$mail->send()) { - $return = Lang::get('lang.mailer_error') . ': ' . $mail->ErrorInfo; + $return = Lang::get('lang.mailer_error').': '.$mail->ErrorInfo; } else { $return = Lang::get('lang.message_has_been_sent'); } } + return redirect()->back()->with('success', $return); } catch (Exception $e) { return redirect()->back()->with('fails', $e->getMessage()); } } - } diff --git a/app/Http/Controllers/Admin/helpdesk/WorkflowController.php b/app/Http/Controllers/Admin/helpdesk/WorkflowController.php index 7583525b4..b5a8a233a 100644 --- a/app/Http/Controllers/Admin/helpdesk/WorkflowController.php +++ b/app/Http/Controllers/Admin/helpdesk/WorkflowController.php @@ -166,7 +166,7 @@ class WorkflowController extends Controller { try { // store a new workflow credentials in to the system - $workflow_name = new WorkflowName; + $workflow_name = new WorkflowName(); $workflow_name->name = $request->name; $workflow_name->status = $request->status; $workflow_name->order = $request->execution_order; diff --git a/app/Http/Controllers/Agent/helpdesk/MailController.php b/app/Http/Controllers/Agent/helpdesk/MailController.php index 1095246ac..deb04c4a4 100644 --- a/app/Http/Controllers/Agent/helpdesk/MailController.php +++ b/app/Http/Controllers/Agent/helpdesk/MailController.php @@ -27,15 +27,16 @@ use PhpImap\Mailbox as ImapMailbox; * * @author Ladybird */ -class MailController extends Controller { - +class MailController extends Controller +{ /** * constructor * Create a new controller instance. * * @param type TicketController $TicketController */ - public function __construct(TicketWorkflowController $TicketWorkflowController) { + public function __construct(TicketWorkflowController $TicketWorkflowController) + { $this->middleware('board'); $this->TicketWorkflowController = $TicketWorkflowController; } @@ -45,7 +46,8 @@ class MailController extends Controller { * * @return type */ - public function readmails(Emails $emails, Email $settings_email, System $system, Ticket $ticket) { + public function readmails(Emails $emails, Email $settings_email, System $system, Ticket $ticket) + { // $path_url = $system->first()->url; if ($settings_email->first()->email_fetching == 1) { if ($settings_email->first()->all_emails == 1) { @@ -80,7 +82,7 @@ class MailController extends Controller { $protocol = $fetching_encryption2; } else { if ($e_mail->fetching_protocol) { - $fetching_protocol = '/' . $e_mail->fetching_protocol; + $fetching_protocol = '/'.$e_mail->fetching_protocol; } else { $fetching_protocol = ''; } @@ -89,13 +91,13 @@ class MailController extends Controller { } else { $fetching_encryption = ''; } - $protocol = $fetching_protocol . $fetching_encryption; + $protocol = $fetching_protocol.$fetching_encryption; } - $imap_config = '{' . $host . ':' . $port . $protocol . '}INBOX'; + $imap_config = '{'.$host.':'.$port.$protocol.'}INBOX'; $password = Crypt::decrypt($e_mail->password); $mailbox = new ImapMailbox($imap_config, $e_mail->email_address, $password, __DIR__); $mails = []; - $mailsIds = $mailbox->searchMailBox('SINCE ' . date('d-M-Y', strtotime('-1 day'))); + $mailsIds = $mailbox->searchMailBox('SINCE '.date('d-M-Y', strtotime('-1 day'))); if (!$mailsIds) { die('Mailbox is empty'); } @@ -135,7 +137,7 @@ class MailController extends Controller { $date = $mail->date; $datetime = $overview[0]->date; $date_time = explode(' ', $datetime); - $date = $date_time[1] . '-' . $date_time[2] . '-' . $date_time[3] . ' ' . $date_time[4]; + $date = $date_time[1].'-'.$date_time[2].'-'.$date_time[3].' '.$date_time[4]; $date = date('Y-m-d H:i:s', strtotime($date)); if (isset($mail->subject)) { $subject = $mail->subject; @@ -170,7 +172,7 @@ class MailController extends Controller { // var_dump($attachment->filePath); // dd($filepath); // $path = $dir_img_path[0]."/code/public/".$filepath[1]; - $path = public_path() . $filepath[1]; + $path = public_path().$filepath[1]; // dd($path); $filesize = filesize($path); $file_data = file_get_contents($path); @@ -179,7 +181,7 @@ class MailController extends Controller { $string = str_replace('-', '', $attachment->name); $filename = explode('src', $attachment->filePath); $filename = str_replace('\\', '', $filename); - $body = str_replace('cid:' . $imageid, $filepath[1], $body); + $body = str_replace('cid:'.$imageid, $filepath[1], $body); $pos = strpos($body, $filepath[1]); if ($pos == false) { if ($settings_email->first()->attachment == 1) { @@ -224,7 +226,8 @@ class MailController extends Controller { * * @return type string */ - public function separate_reply($body) { + public function separate_reply($body) + { $body2 = explode('---Reply above this line---', $body); $body3 = $body2[0]; @@ -238,7 +241,8 @@ class MailController extends Controller { * * @return type string */ - public function decode_imap_text($str) { + public function decode_imap_text($str) + { $result = ''; $decode_header = imap_mime_header_decode($str); foreach ($decode_header as $obj) { @@ -253,7 +257,8 @@ class MailController extends Controller { * * @return type */ - public function fetch_attachments() { + public function fetch_attachments() + { $uploads = Upload::all(); foreach ($uploads as $attachment) { $image = @imagecreatefromstring($attachment->file); @@ -261,8 +266,8 @@ class MailController extends Controller { imagejpeg($image, null, 80); $data = ob_get_contents(); ob_end_clean(); - $var = ''; - echo '
    ' . $var . ''; + $var = ''; + echo '
    '.$var.''; } } @@ -273,17 +278,19 @@ class MailController extends Controller { * * @return type file */ - public function get_data($id) { + public function get_data($id) + { $attachments = App\Model\helpdesk\Ticket\Ticket_attachments::where('id', '=', $id)->get(); foreach ($attachments as $attachment) { - header('Content-type: application/' . $attachment->type . ''); - header('Content-Disposition: inline; filename=' . $attachment->name . ''); + header('Content-type: application/'.$attachment->type.''); + header('Content-Disposition: inline; filename='.$attachment->name.''); header('Content-Transfer-Encoding: binary'); echo $attachment->file; } } - public static function trimTableTag($html) { + public static function trimTableTag($html) + { if (strpos('', $html) != false) { $first_pos = strpos($html, ''); + return $final_str; } + return $html; } - public static function trim3D($html) { + public static function trim3D($html) + { $body = str_replace('=3D', '', $html); + return $body; } - public static function trimInjections($html, $tags = ['', '', '']) { + public static function trimInjections($html, $tags = ['', '', '']) + { $replace = []; foreach ($tags as $key => $tag) { $replace[$key] = htmlspecialchars($tag); } $body = str_replace($tags, $replace, $html); + return $body; } - } diff --git a/app/Http/Controllers/Agent/helpdesk/UserController.php b/app/Http/Controllers/Agent/helpdesk/UserController.php index 46e9b5d18..8beebfb11 100644 --- a/app/Http/Controllers/Agent/helpdesk/UserController.php +++ b/app/Http/Controllers/Agent/helpdesk/UserController.php @@ -91,6 +91,7 @@ class UserController extends Controller } else { $stringCut = $model->user_name; } + return $stringCut; }) /* column email */ diff --git a/app/Http/Controllers/Agent/kb/ArticleController.php b/app/Http/Controllers/Agent/kb/ArticleController.php index c890f8899..12155b093 100644 --- a/app/Http/Controllers/Agent/kb/ArticleController.php +++ b/app/Http/Controllers/Agent/kb/ArticleController.php @@ -29,8 +29,8 @@ use Redirect; * * @author Ladybird */ -class ArticleController extends Controller { - +class ArticleController extends Controller +{ /** * Create a new controller instance. * constructor to check @@ -40,7 +40,8 @@ class ArticleController extends Controller { * * @return void */ - public function __construct() { + public function __construct() + { // checking authentication $this->middleware('auth'); // checking roles @@ -48,7 +49,8 @@ class ArticleController extends Controller { SettingsController::language(); } - public function test() { + public function test() + { //$table = $this->setDatatable(); return view('themes.default1.agent.kb.article.test'); } @@ -58,7 +60,8 @@ class ArticleController extends Controller { * * @return type void */ - public function getData() { + public function getData() + { $article = new Article(); // returns chumper datatable return Datatable::query($article) @@ -68,7 +71,6 @@ class ArticleController extends Controller { ->orderColumns('name', 'description') /* add column name */ ->addColumn('name', function ($model) { - $string = strip_tags($model->name); if (strlen($string) > 40) { // truncate string @@ -76,7 +78,8 @@ class ArticleController extends Controller { } else { $stringCut = $model->name; } - return $stringCut . '...'; + + return $stringCut.'...'; }) /* add column Created */ ->addColumn('publish_time', function ($model) { @@ -87,8 +90,8 @@ class ArticleController extends Controller { /* add column action */ ->addColumn('Actions', function ($model) { /* here are all the action buttons and modal popup to delete articles with confirmations */ - return ' id . '/edit class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . ' slug . ' class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . ' -