Applied fixes from StyleCI

This commit is contained in:
Sujit Prasad
2016-08-05 09:24:12 -04:00
committed by StyleCI Bot
parent 09bf25b5e2
commit e2390f67d4
53 changed files with 1397 additions and 1105 deletions

View File

@@ -27,15 +27,16 @@ use PhpImap\Mailbox as ImapMailbox;
*
* @author Ladybird <info@ladybirdweb.com>
*/
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,20 +91,20 @@ 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);
try {
$mailbox = new ImapMailbox($imap_config, $e_mail->email_address, $password, __DIR__);
} catch (\PhpImap\Exception $e) {
echo "Connection error";
echo 'Connection error';
}
$mails = [];
try {
$mailsIds = $mailbox->searchMailBox('SINCE ' . date('d-M-Y', strtotime('-1 day')));
$mailsIds = $mailbox->searchMailBox('SINCE '.date('d-M-Y', strtotime('-1 day')));
} catch (\PhpImap\Exception $e) {
echo "Connection error";
echo 'Connection error';
}
if (!$mailsIds) {
die('Mailbox is empty');
@@ -119,7 +121,7 @@ class MailController extends Controller {
try {
$mail = $mailbox->getMail($mailId);
} catch (\PhpImap\Exception $e) {
echo "Connection error";
echo 'Connection error';
}
if ($settings_email->first()->email_collaborator == 1) {
$collaborator = $mail->cc;
@@ -137,11 +139,11 @@ class MailController extends Controller {
if ($body == null) {
$attach = $mail->getAttachments();
if (is_array($attach)) {
if (key_exists('html-body', $attach)) {
if (array_key_exists('html-body', $attach)) {
$path = $attach['html-body']->filePath;
}
if ($path == null) {
if (key_exists('text-body', $attach)) {
if (array_key_exists('text-body', $attach)) {
$path = $attach['text-body']->filePath;
}
}
@@ -151,7 +153,7 @@ class MailController extends Controller {
if ($body) {
$body = self::trimTableTag($body);
} else {
$body = "";
$body = '';
}
}
}
@@ -162,7 +164,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;
@@ -193,10 +195,10 @@ class MailController extends Controller {
$dir_img_paths = __DIR__;
$dir_img_path = explode('/code', $dir_img_paths);
$filepath = explode('..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'public', $attachment->filePath);
$filepath = explode('..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'public', $attachment->filePath);
if ($filepath[1]) {
$path = public_path() . $filepath[1];
$path = public_path().$filepath[1];
$filesize = filesize($path);
$file_data = file_get_contents($path);
@@ -205,7 +207,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) {
@@ -251,7 +253,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];
@@ -265,7 +268,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) {
@@ -280,7 +284,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);
@@ -288,8 +293,8 @@ class MailController extends Controller {
imagejpeg($image, null, 80);
$data = ob_get_contents();
ob_end_clean();
$var = '<a href="" target="_blank"><img src="data:image/jpg;base64,' . base64_encode($data) . '"/></a>';
echo '<br/><span class="mailbox-attachment-icon has-img">' . $var . '</span>';
$var = '<a href="" target="_blank"><img src="data:image/jpg;base64,'.base64_encode($data).'"/></a>';
echo '<br/><span class="mailbox-attachment-icon has-img">'.$var.'</span>';
}
}
@@ -300,17 +305,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('<table>', $html) != false) {
$first_pos = strpos($html, '<table');
$fist_string = substr_replace($html, '', 0, $first_pos);
@@ -326,13 +333,15 @@ class MailController extends Controller {
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 = ['<script>', '</script>', '<style>', '</style>', '<?php', '?>']) {
public static function trimInjections($html, $tags = ['<script>', '</script>', '<style>', '</style>', '<?php', '?>'])
{
$replace = [];
foreach ($tags as $key => $tag) {
$replace[$key] = htmlspecialchars($tag);
@@ -341,5 +350,4 @@ class MailController extends Controller {
return $body;
}
}

View File

@@ -22,16 +22,18 @@ use View;
*
* @author Ladybird <info@ladybirdweb.com>
*/
class NotificationController extends Controller {
public function __construct(PhpMailController $PhpMailController) {
class NotificationController extends Controller
{
public function __construct(PhpMailController $PhpMailController)
{
$this->PhpMailController = $PhpMailController;
}
/**
* This function is for sending daily report/notification about the system.
* */
public function send_notification() {
public function send_notification()
{
//fetching email settings
$email = Email::where('id', '=', '1')->first();
// checking if the daily notification is enabled or not
@@ -40,7 +42,6 @@ class NotificationController extends Controller {
$notification = Log_notification::where('log', '=', 'NOT-1')->orderBy('id', 'DESC')->first();
$date = explode(' ', $notification->created_at);
if (date('Y-m-d') == $date[0]) {
} else {
// creating a daily notification log
Log_notification::create(['log' => 'NOT-1']);
@@ -64,24 +65,25 @@ class NotificationController extends Controller {
*
* @return mail
* */
public function send_notification_to_admin($company) {
public function send_notification_to_admin($company)
{
// get all admin users
$users = User::where('role', '=', 'admin')->get();
foreach ($users as $user) {
// Send notification details to admin
$email = $user->email;
$user_name = $user->first_name . ' ' . $user->last_name;
$user_name = $user->first_name.' '.$user->last_name;
$view = View::make('emails.notifications.admin', ['company' => $company, 'name' => $user_name]);
$contents = $view->render();
$from = $this->PhpMailController->mailfrom('1', '0');
$to = [
'name' => $user_name,
'email' => $email
'name' => $user_name,
'email' => $email,
];
$message = [
'subject' => 'Daily Report',
'subject' => 'Daily Report',
'scenario' => null,
'body' => $contents
'body' => $contents,
];
$this->dispatch((new \App\Jobs\SendEmail($from, $to, $message))->onQueue('emails'));
//$this->PhpMailController->sendEmail($from,$to,$message);
@@ -93,7 +95,8 @@ class NotificationController extends Controller {
*
* @return mail
* */
public function send_notification_to_manager($company) {
public function send_notification_to_manager($company)
{
// get all department managers
$depts = Department::all();
foreach ($depts as $dept) {
@@ -103,7 +106,7 @@ class NotificationController extends Controller {
foreach ($users as $user) {
// Send notification details to manager of a department
$email = $user->email;
$user_name = $user->first_name . ' ' . $user->last_name;
$user_name = $user->first_name.' '.$user->last_name;
$view = View::make('emails.notifications.manager', ['company' => $company, 'name' => $user_name]);
$contents = $view->render();
$this->PhpMailController->sendEmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user_name, 'email' => $email], $message = ['subject' => 'Daily Report', 'scenario' => null, 'body' => $contents]);
@@ -117,7 +120,8 @@ class NotificationController extends Controller {
*
* @return mail
* */
public function send_notification_to_team_lead($company) {
public function send_notification_to_team_lead($company)
{
// get all Team leads
$teams = Teams::all();
foreach ($teams as $team) {
@@ -127,7 +131,7 @@ class NotificationController extends Controller {
foreach ($users as $user) {
// Send notification details to team lead
$email = $user->email;
$user_name = $user->first_name . ' ' . $user->last_name;
$user_name = $user->first_name.' '.$user->last_name;
$view = View::make('emails.notifications.lead', ['company' => $company, 'name' => $user_name, 'team_id' => $team->id]);
$contents = $view->render();
$this->PhpMailController->sendEmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user_name, 'email' => $email], $message = ['subject' => 'Daily Report', 'scenario' => null, 'body' => $contents]);
@@ -141,13 +145,14 @@ class NotificationController extends Controller {
*
* @return mail
* */
public function send_notification_to_agent($company) {
public function send_notification_to_agent($company)
{
// get all agents users
$users = User::where('role', '=', 'agent')->get();
foreach ($users as $user) {
// Send notification details to all the agents
$email = $user->email;
$user_name = $user->first_name . ' ' . $user->last_name;
$user_name = $user->first_name.' '.$user->last_name;
$view = View::make('emails.notifications.agent', ['company' => $company, 'name' => $user_name, 'user_id' => $user->id]);
$contents = $view->render();
$this->PhpMailController->sendEmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $user_name, 'email' => $email], $message = ['subject' => 'Daily Report', 'scenario' => null, 'body' => $contents]);
@@ -159,7 +164,8 @@ class NotificationController extends Controller {
*
* @return type variable
*/
public function company() {
public function company()
{
// fetching comapny model
$company = Company::Where('id', '=', '1')->first();
// fetching company name
@@ -171,5 +177,4 @@ class NotificationController extends Controller {
return $company;
}
}

View File

@@ -3,7 +3,6 @@
namespace App\Http\Controllers\Agent\helpdesk;
// controllers
use App\Http\Controllers\Common\SettingsController;
use App\Http\Controllers\Controller;
// requests
// models
@@ -51,8 +50,10 @@ class Ticket2Controller extends Controller
}
/**
* this function returns the list of open tickets of a particular department
* this function returns the list of open tickets of a particular department.
*
* @param type $id
*
* @return type
*/
public function getOpenTickets($id)
@@ -63,6 +64,7 @@ class Ticket2Controller extends Controller
$dept = Department::where('id', '=', Auth::user()->primary_dpt)->first();
$tickets = Tickets::where('status', '=', 1)->where('isanswered', '=', 0)->where('dept_id', '=', $dept->id)->get();
}
return Ttable::getTable($tickets);
}
@@ -84,10 +86,12 @@ class Ticket2Controller extends Controller
return view('themes.default1.agent.helpdesk.dept-ticket.closed', compact('id'));
}
}
/**
* this function returns the list of close tickets of a particular department
* this function returns the list of close tickets of a particular department.
*
* @param type $id
*
* @return type
*/
public function getCloseTickets($id)
@@ -98,12 +102,15 @@ class Ticket2Controller extends Controller
$dept = Department::where('id', '=', Auth::user()->primary_dpt)->first();
$tickets = Tickets::where('status', '=', '2')->where('status', '=', '3')->where('dept_id', '=', $dept->id)->get();
}
return Ttable::getTable($tickets);
}
/**
* this function returns the list of close tickets of a particular department
* this function returns the list of close tickets of a particular department.
*
* @param type $id
*
* @return type
*/
public function deptinprogress($id)
@@ -136,5 +143,4 @@ class Ticket2Controller extends Controller
return Ttable::getTable($tickets);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -350,6 +350,7 @@ class TicketWorkflowController extends Controller
$ticket_settings_details = $this->changeStatus($workflow_action, $ticket_settings_details);
}
}
return $ticket_settings_details;
}

View File

@@ -3,8 +3,8 @@
namespace App\Http\Controllers\Agent\helpdesk;
// controllers
use App\Http\Controllers\Controller;
use App\Http\Controllers\Common\PhpMailController;
use App\Http\Controllers\Controller;
// requests
/* Include Sys_user Model */
use App\Http\Requests\helpdesk\ProfilePassword;
@@ -79,7 +79,7 @@ class UserController extends Controller
public function user_list()
{
// displaying list of users with chumper datatables
return \Datatable::collection(User::where('role',"=","user")->get())
return \Datatable::collection(User::where('role', '=', 'user')->get())
/* searchable column username and email */
->searchColumns('user_name', 'email', 'phone')
/* order column username and email */
@@ -207,7 +207,7 @@ class UserController extends Controller
// fetch user credentails to send mail
$name = $user->first_name;
$email = $user->email;
if($request->input('send_email')) {
if ($request->input('send_email')) {
try {
// send mail on registration
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $name, 'email' => $email], $message = ['subject' => null, 'scenario' => 'registration-notification'], $template_variables = ['user' => $name, 'email_address' => $email, 'user_password' => $password]);
@@ -283,7 +283,7 @@ class UserController extends Controller
*/
public function update($id, Sys_userUpdate $request)
{
// dd($request);
// dd($request);
$user = new User();
/* select the field where id = $id(request Id) */
$users = $user->whereId($id)->first();
@@ -510,8 +510,7 @@ class UserController extends Controller
return 0;
}
}
/**
* Generate a random string for password.
*
@@ -534,5 +533,4 @@ class UserController extends Controller
// return random string
return $randomString;
}
}

View File

@@ -65,7 +65,7 @@ class ArticleController extends Controller
$article = new Article();
$articles = $article
->select('id', 'name', 'description', 'publish_time', 'slug')
->orderBy('publish_time','desc')
->orderBy('publish_time', 'desc')
->get();
// returns chumper datatable
return Datatable::Collection($articles)

View File

@@ -77,6 +77,7 @@ class CategoryController extends Controller
/* add column name */
->addColumn('name', function ($model) {
$string = strip_tags($model->name);
return str_limit($string, 20);
})
/* add column Created */
@@ -120,7 +121,7 @@ class CategoryController extends Controller
public function create(Category $category)
{
/* Get the all attributes in the category model */
$category = $category->lists('name','id')->toArray();
$category = $category->lists('name', 'id')->toArray();
/* get the view page to create new category with all attributes
of category model */
try {
@@ -147,6 +148,7 @@ class CategoryController extends Controller
// send success message to index page
try {
$category->fill($request->input())->save();
return Redirect::back()->with('success', Lang::get('lang.category_inserted_successfully'));
} catch (Exception $e) {
return Redirect::back()->with('fails', Lang::get('lang.category_not_inserted').'<li>'.$e->getMessage().'</li>');
@@ -165,9 +167,9 @@ class CategoryController extends Controller
{
/* get the atributes of the category model whose id == $id */
$category = Category::whereId($id)->first();
$categories = Category::lists('name','id')->toArray();
$categories = Category::lists('name', 'id')->toArray();
/* get the Edit page the selected category via id */
return view('themes.default1.agent.kb.category.edit', compact('category','categories'));
return view('themes.default1.agent.kb.category.edit', compact('category', 'categories'));
}
/**
@@ -191,6 +193,7 @@ class CategoryController extends Controller
try {
$category->slug = $slug;
$category->fill($request->input())->save();
return redirect('category')->with('success', Lang::get('lang.category_updated_successfully'));
} catch (Exception $e) {
//redirect to index with fails message