Apply fixes from StyleCI

This commit is contained in:
Manish Verma
2017-05-23 10:18:08 +00:00
committed by StyleCI Bot
parent 4ec6000d69
commit 7b8ee415be
8 changed files with 91 additions and 68 deletions

View File

@@ -9,8 +9,8 @@ use App\Model\helpdesk\Ticket\Ticket_Thread;
use Config; use Config;
use Storage; use Storage;
class StorageController extends Controller { class StorageController extends Controller
{
protected $default; protected $default;
protected $driver; protected $driver;
protected $root; protected $root;
@@ -25,7 +25,8 @@ class StorageController extends Controller {
protected $rackspace_endpoint; protected $rackspace_endpoint;
protected $rackspace_url_type; protected $rackspace_url_type;
public function __construct() { public function __construct()
{
$this->default = $this->defaults(); $this->default = $this->defaults();
$this->driver = $this->driver(); $this->driver = $this->driver();
$this->root = $this->root(); $this->root = $this->root();
@@ -40,7 +41,8 @@ class StorageController extends Controller {
$this->rackspace_username = $this->rackspaceUsername(); $this->rackspace_username = $this->rackspaceUsername();
} }
protected function settings($option) { protected function settings($option)
{
$settings = new CommonSettings(); $settings = new CommonSettings();
$setting = $settings->getOptionValue('storage', $option); $setting = $settings->getOptionValue('storage', $option);
$value = ''; $value = '';
@@ -51,7 +53,8 @@ class StorageController extends Controller {
return $value; return $value;
} }
public function defaults() { public function defaults()
{
$default = 'local'; $default = 'local';
if ($this->settings('default')) { if ($this->settings('default')) {
$default = $this->settings('default'); $default = $this->settings('default');
@@ -60,11 +63,13 @@ class StorageController extends Controller {
return $default; return $default;
} }
public function driver() { public function driver()
{
return $this->settings('default'); return $this->settings('default');
} }
public function root() { public function root()
{
$root = storage_path('app'); $root = storage_path('app');
if ($this->settings('root')) { if ($this->settings('root')) {
$root = $this->settings('root'); $root = $this->settings('root');
@@ -73,47 +78,58 @@ class StorageController extends Controller {
return $root; return $root;
} }
public function s3Key() { public function s3Key()
{
return $this->settings('s3_key'); return $this->settings('s3_key');
} }
public function s3Region() { public function s3Region()
{
return $this->settings('s3_region'); return $this->settings('s3_region');
} }
public function s3Secret() { public function s3Secret()
{
return $this->settings('s3_secret'); return $this->settings('s3_secret');
} }
public function s3Bucket() { public function s3Bucket()
{
return $this->settings('s3_bucket'); return $this->settings('s3_bucket');
} }
public function rackspaceKey() { public function rackspaceKey()
{
return $this->settings('root'); return $this->settings('root');
} }
public function rackspaceRegion() { public function rackspaceRegion()
{
return $this->settings('rackspace_region'); return $this->settings('rackspace_region');
} }
public function rackspaceUsername() { public function rackspaceUsername()
{
return $this->settings('rackspace_username'); return $this->settings('rackspace_username');
} }
public function rackspaceContainer() { public function rackspaceContainer()
{
return $this->settings('rackspace_container'); return $this->settings('rackspace_container');
} }
public function rackspaceEndpoint() { public function rackspaceEndpoint()
{
return $this->settings('rackspace_endpoint'); return $this->settings('rackspace_endpoint');
} }
public function rackspaceUrlType() { public function rackspaceUrlType()
{
return $this->settings('rackspace_url_type'); return $this->settings('rackspace_url_type');
} }
protected function setFileSystem() { protected function setFileSystem()
{
$config = $this->config(); $config = $this->config();
//dd($config); //dd($config);
foreach ($config as $key => $con) { foreach ($config as $key => $con) {
@@ -128,40 +144,43 @@ class StorageController extends Controller {
return Config::get('filesystem'); return Config::get('filesystem');
} }
protected function config() { protected function config()
{
return [ return [
'default' => $this->default, 'default' => $this->default,
'cloud' => 's3', 'cloud' => 's3',
'disks' => $this->disks(), 'disks' => $this->disks(),
]; ];
} }
protected function disks() { protected function disks()
{
return [ return [
'local' => [ 'local' => [
'driver' => 'local', 'driver' => 'local',
'root' => $this->root . '/attachments', 'root' => $this->root.'/attachments',
], ],
's3' => [ 's3' => [
'driver' => 's3', 'driver' => 's3',
'key' => $this->s3_key, 'key' => $this->s3_key,
'secret' => $this->s3_secret, 'secret' => $this->s3_secret,
'region' => $this->s3_region, 'region' => $this->s3_region,
'bucket' => $this->s3_bucket, 'bucket' => $this->s3_bucket,
], ],
'rackspace' => [ 'rackspace' => [
'driver' => 'rackspace', 'driver' => 'rackspace',
'username' => $this->rackspace_username, 'username' => $this->rackspace_username,
'key' => $this->rackspace_key, 'key' => $this->rackspace_key,
'container' => $this->rackspace_container, 'container' => $this->rackspace_container,
'endpoint' => $this->rackspace_endpoint, 'endpoint' => $this->rackspace_endpoint,
'region' => $this->rackspace_region, 'region' => $this->rackspace_region,
'url_type' => $this->rackspace_url_type, 'url_type' => $this->rackspace_url_type,
], ],
]; ];
} }
public function upload($data, $filename, $type, $size, $disposition, $thread_id) { public function upload($data, $filename, $type, $size, $disposition, $thread_id)
{
$upload = new Ticket_attachments(); $upload = new Ticket_attachments();
$upload->thread_id = $thread_id; $upload->thread_id = $thread_id;
$upload->name = $filename; $upload->name = $filename;
@@ -169,11 +188,11 @@ class StorageController extends Controller {
$upload->size = $size; $upload->size = $size;
$upload->poster = $disposition; $upload->poster = $disposition;
$upload->driver = $this->default; $upload->driver = $this->default;
$upload->path = $this->root. DIRECTORY_SEPARATOR.'attachments'; $upload->path = $this->root.DIRECTORY_SEPARATOR.'attachments';
if ($this->default !== 'database') { if ($this->default !== 'database') {
$this->setFileSystem(); $this->setFileSystem();
Storage::disk($this->default)->put($filename, $data); Storage::disk($this->default)->put($filename, $data);
$storagePath = Storage::disk($this->default)->getDriver()->getAdapter()->getPathPrefix() . $filename; $storagePath = Storage::disk($this->default)->getDriver()->getAdapter()->getPathPrefix().$filename;
if (mime(\File::mimeType($storagePath)) != 'image' || mime(\File::extension($storagePath)) != 'image') { if (mime(\File::mimeType($storagePath)) != 'image' || mime(\File::extension($storagePath)) != 'image') {
chmod($storagePath, 1204); chmod($storagePath, 1204);
} }
@@ -185,23 +204,23 @@ class StorageController extends Controller {
} }
} }
public function saveAttachments($thread_id, $attachments = []) { public function saveAttachments($thread_id, $attachments = [])
{
$disposition = 'ATTACHMENT'; $disposition = 'ATTACHMENT';
$thread = ''; $thread = '';
foreach ($attachments as $attachment) { foreach ($attachments as $attachment) {
if (is_object($attachment)) { if (is_object($attachment)) {
if (method_exists($attachment, 'getStructure')) { if (method_exists($attachment, 'getStructure')) {
$structure = $attachment->getStructure(); $structure = $attachment->getStructure();
if (isset($structure->disposition)) { if (isset($structure->disposition)) {
$disposition = $structure->disposition; $disposition = $structure->disposition;
} }
$filename = rand(1111, 9999) . "_" . $attachment->getFileName(); $filename = rand(1111, 9999).'_'.$attachment->getFileName();
$type = $attachment->getMimeType(); $type = $attachment->getMimeType();
$size = $attachment->getSize(); $size = $attachment->getSize();
$data = $attachment->getData(); $data = $attachment->getData();
} else { } else {
$filename = rand(1111, 9999) . "_" . $attachment->getClientOriginalName(); $filename = rand(1111, 9999).'_'.$attachment->getClientOriginalName();
$type = $attachment->getMimeType(); $type = $attachment->getMimeType();
$size = $attachment->getSize(); $size = $attachment->getSize();
$data = file_get_contents($attachment->getRealPath()); $data = file_get_contents($attachment->getRealPath());
@@ -210,10 +229,12 @@ class StorageController extends Controller {
$thread = $this->updateBody($attachment, $thread_id, $filename); $thread = $this->updateBody($attachment, $thread_id, $filename);
} }
} }
return $thread; return $thread;
} }
public function updateBody($attachment, $thread_id, $filename) { public function updateBody($attachment, $thread_id, $filename)
{
$threads = new Ticket_Thread(); $threads = new Ticket_Thread();
$thread = $threads->find($thread_id); $thread = $threads->find($thread_id);
$disposition = 'ATTACHMENT'; $disposition = 'ATTACHMENT';
@@ -225,27 +246,29 @@ class StorageController extends Controller {
} }
} }
} }
if ($disposition == 'INLINE' || $disposition == 'inline') { if ($disposition == 'INLINE' || $disposition == 'inline') {
$id = str_replace('>', '', str_replace('<', '', $structure->id)); $id = str_replace('>', '', str_replace('<', '', $structure->id));
$body = $thread->body; $body = $thread->body;
// dd($id,$filename,$body); // dd($id,$filename,$body);
$body = str_replace('cid:' . $id, $filename, $body); $body = str_replace('cid:'.$id, $filename, $body);
// dd($body); // dd($body);
$thread->body = $body; $thread->body = $body;
$thread->save(); $thread->save();
} }
return $thread; return $thread;
} }
public function getFile($drive, $name, $root) { public function getFile($drive, $name, $root)
if ($drive != "database") { {
$root = $root . DIRECTORY_SEPARATOR . $name; if ($drive != 'database') {
$root = $root.DIRECTORY_SEPARATOR.$name;
if (\File::exists($root)) { if (\File::exists($root)) {
chmod($root, 0755); chmod($root, 0755);
return \File::get($root); return \File::get($root);
} }
} }
} }
} }

View File

@@ -37,10 +37,11 @@ use App\Model\helpdesk\Utility\Date_time_format;
use App\Model\helpdesk\Utility\Timezones; use App\Model\helpdesk\Utility\Timezones;
use App\User; use App\User;
use Auth; use Auth;
use Crypt;
use DB; use DB;
use Exception; use Exception;
use GeoIP;
// classes // classes
use GeoIP;
use Hash; use Hash;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\support\Collection; use Illuminate\support\Collection;
@@ -49,7 +50,6 @@ use Lang;
use Mail; use Mail;
use PDF; use PDF;
use UTC; use UTC;
use Crypt;
/** /**
* TicketController. * TicketController.
@@ -541,9 +541,9 @@ class TicketController extends Controller
], ],
$template_variables = [ $template_variables = [
'ticket_number' => $ticket_number, 'ticket_number' => $ticket_number,
'user' => $username, 'user' => $username,
'agent_sign' => $agentsign, 'agent_sign' => $agentsign,
'system_link'=>$link 'system_link' => $link,
] ]
); );
} }
@@ -850,11 +850,11 @@ class TicketController extends Controller
if ($auto_response == 0) { if ($auto_response == 0) {
$encoded_ticketid = Crypt::encrypt($ticketdata->id); $encoded_ticketid = Crypt::encrypt($ticketdata->id);
$link = url('check_ticket/'.$encoded_ticketid); $link = url('check_ticket/'.$encoded_ticketid);
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $ticketdata->dept_id), $to = ['name' => $username, 'email' => $emailadd], $message = ['subject' => $updated_subject, 'scenario' => 'create-ticket-by-agent', 'body' => $body], $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $ticketdata->dept_id), $to = ['name' => $username, 'email' => $emailadd], $message = ['subject' => $updated_subject, 'scenario' => 'create-ticket-by-agent', 'body' => $body],
$template_variables = [ $template_variables = [
'agent_sign' => Auth::user()->agent_sign, 'agent_sign' => Auth::user()->agent_sign,
'ticket_number' => $ticket_number2, 'ticket_number' => $ticket_number2,
'system_link'=>$link, 'system_link' => $link,
]); ]);
} }
} catch (\Exception $e) { } catch (\Exception $e) {
@@ -864,11 +864,11 @@ class TicketController extends Controller
$body2 = null; $body2 = null;
try { try {
if ($auto_response == 0) { if ($auto_response == 0) {
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $ticketdata->dept_id), $to = ['name' => $username, 'email' => $emailadd], $message = ['subject' => $updated_subject, 'scenario' => 'create-ticket'], $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $ticketdata->dept_id), $to = ['name' => $username, 'email' => $emailadd], $message = ['subject' => $updated_subject, 'scenario' => 'create-ticket'],
$template_variables = ['user' => $username, $template_variables = ['user' => $username,
'ticket_number' => $ticket_number2, 'ticket_number' => $ticket_number2,
'department_sign' => '', 'department_sign' => '',
'system_link'=>$link, 'system_link' => $link,
]); ]);
} }
} catch (\Exception $e) { } catch (\Exception $e) {

View File

@@ -769,7 +769,7 @@ class UserController extends Controller
// fetching upload destination path // fetching upload destination path
$destinationPath = 'uploads/profilepic'; $destinationPath = 'uploads/profilepic';
// adding a random value to profile picture filename // adding a random value to profile picture filename
$fileName = rand(0000, 9999).'.'.str_replace(" ", "_", $name); $fileName = rand(0000, 9999).'.'.str_replace(' ', '_', $name);
// moving the picture to a destination folder // moving the picture to a destination folder
Input::file('profile_pic')->move($destinationPath, $fileName); Input::file('profile_pic')->move($destinationPath, $fileName);
// saving filename to database // saving filename to database

View File

@@ -249,6 +249,7 @@ class FormController extends Controller
} }
} catch (\Exception $ex) { } catch (\Exception $ex) {
dd($ex); dd($ex);
return redirect()->back()->with('fails', $ex->getMessage()); return redirect()->back()->with('fails', $ex->getMessage());
} }
// dd($result); // dd($result);

View File

@@ -101,7 +101,7 @@ class GuestController extends Controller
// fetching upload destination path // fetching upload destination path
$destinationPath = 'uploads/profilepic'; $destinationPath = 'uploads/profilepic';
// adding a random value to profile picture filename // adding a random value to profile picture filename
$fileName = rand(0000, 9999).'.'.str_replace(" ", "_", $name); $fileName = rand(0000, 9999).'.'.str_replace(' ', '_', $name);
// moving the picture to a destination folder // moving the picture to a destination folder
Input::file('profile_pic')->move($destinationPath, $fileName); Input::file('profile_pic')->move($destinationPath, $fileName);
// saving filename to database // saving filename to database

View File

@@ -4,21 +4,19 @@ namespace App\Http\Middleware;
use Closure; use Closure;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier; use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
use Lang;
class VerifyCsrfToken extends BaseVerifier class VerifyCsrfToken extends BaseVerifier
{ {
/**
/**
* The URIs that should be excluded from CSRF verification. * The URIs that should be excluded from CSRF verification.
* *
* @var array * @var array
*/ */
protected $except = [ protected $except = [
'CheckSerial', 'CheckSerial',
'api/v1/*' 'api/v1/*',
]; ];
/** /**
* Handle an incoming request. * Handle an incoming request.
* *

View File

@@ -35,7 +35,7 @@ class Ticket_attachments extends Model
if ($content) { if ($content) {
$value = base64_encode($content); $value = base64_encode($content);
if (mime($this->type) != 'image') { if (mime($this->type) != 'image') {
$root = $root . "/" . $name; $root = $root.'/'.$name;
chmod($root, 1204); chmod($root, 1204);
} }
} }

View File

@@ -45,17 +45,18 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
$pic = $this->checkArray('avatar', $info); $pic = $this->checkArray('avatar', $info);
} }
if (!$pic && $value) { if (!$pic && $value) {
$pic = ""; $pic = '';
$file = asset('uploads/profilepic/' . $value); $file = asset('uploads/profilepic/'.$value);
if ($file) { if ($file) {
$type = pathinfo($file, PATHINFO_EXTENSION); $type = pathinfo($file, PATHINFO_EXTENSION);
$data = file_get_contents($file); $data = file_get_contents($file);
$pic = 'data:image/' . $type . ';base64,' . base64_encode($data); $pic = 'data:image/'.$type.';base64,'.base64_encode($data);
} }
} }
if (!$value) { if (!$value) {
$pic = \Gravatar::src($this->attributes['email']); $pic = \Gravatar::src($this->attributes['email']);
} }
return $pic; return $pic;
} }