This commit is contained in:
Manish Verma
2016-12-13 18:18:25 +05:30
parent fc98add11c
commit 2d8e640e9b
2314 changed files with 97798 additions and 75664 deletions

View File

@@ -2,21 +2,23 @@
namespace App\Http\Controllers\Common;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Excel;
use Exception;
class ExcelController extends Controller
{
public function export($filename, $data)
{
if (count($data) == 0) {
class ExcelController extends Controller {
public function export($filename, $data) {
if(count($data)==0){
throw new Exception('No data');
}
Excel::create($filename, function ($excel) use ($data) {
$excel->sheet('sheet', function ($sheet) use ($data) {
Excel::create($filename, function($excel) use($data){
$excel->sheet('sheet', function($sheet) use($data) {
$sheet->fromArray($data);
});
})->export('xls');
}
}

View File

@@ -4,10 +4,9 @@ namespace App\Http\Controllers\Common;
use App\Http\Controllers\Controller;
class FileuploadController extends Controller
{
public function __construct()
{
class FileuploadController extends Controller {
public function __construct() {
// checking authentication
$this->middleware('auth');
// checking if role is agent
@@ -16,8 +15,7 @@ class FileuploadController extends Controller
// Returns a file size limit in bytes based on the PHP upload_max_filesize
// and post_max_size
public function file_upload_max_size()
{
function file_upload_max_size() {
static $max_size = -1;
if ($max_size < 0) {
@@ -33,13 +31,11 @@ class FileuploadController extends Controller
$max_size_in_actual = ini_get('upload_max_filesize');
}
}
return ['0' => $max_size_in_bytes, '1' => $max_size_in_actual];
// return $max_size_in_bytes;
}
public function parse_size($size)
{
function parse_size($size) {
$unit = preg_replace('/[^bkmgtpezy]/i', '', $size); // Remove the non-unit characters from the size.
$size = preg_replace('/[^0-9\.]/', '', $size); // Remove the non-numeric characters from the size.
if ($unit) {
@@ -49,4 +45,5 @@ class FileuploadController extends Controller
return round($size);
}
}
}

View File

@@ -4,32 +4,33 @@ namespace App\Http\Controllers\Common;
use App\Http\Controllers\Controller;
use App\Model\helpdesk\Notification\Notification;
use App\Model\helpdesk\Notification\NotificationType;
use App\Model\helpdesk\Notification\UserNotification;
use App\Model\helpdesk\Ticket\Tickets;
use App\Model\helpdesk\Ticket\Ticket_Thread;
use App\User;
use App\Model\helpdesk\Notification\NotificationType;
class NotificationController extends Controller {
class NotificationController extends Controller
{
/**
*********************************************
* ********************************************
* Class Notification Controller
*********************************************
* ********************************************
* This controller is used to generate in app notification
* under the folling occurrence
* under the folling occurrence
* 1. Ticket Creation
* 2. Ticket Reply
* 3. User Creation.
*
* 3. User Creation
*
* @author Ladybird <info@ladybirdweb.com>
*/
public $user;
/**
* Constructor.
* Constructor
*/
public function __construct()
{
public function __construct() {
$user = new User();
$this->user = $user;
// checking authentication
@@ -40,7 +41,6 @@ class NotificationController extends Controller
/**
* This function is used to create in app notifications.
*
* @param type $model_id
* @param type $userid_created
* @param type $type_id
@@ -68,62 +68,49 @@ class NotificationController extends Controller
}
/**
* This function is to mark all ticket to read status.
*
* This function is to mark all ticket to read status
* @param type $id
*
* @return int
*/
public function markAllRead($id)
{
public function markAllRead($id) {
$markasread = UserNotification::where('user_id', '=', \Auth::user()->id)->where('is_read', '=', '0')->get();
foreach ($markasread as $mark) {
$mark->is_read = '1';
$mark->save();
}
return 1;
}
/**
* This function to mark read.
*
* This function to mark read
* @param type $id
*
* @return int
*/
public function markRead($id)
{
public function markRead($id) {
$markasread = UserNotification::where('notification_id', '=', $id)->where('user_id', '=', \Auth::user()->id)->where('is_read', '=', '0')->get();
foreach ($markasread as $mark) {
$mark->is_read = '1';
$mark->save();
}
return 1;
}
/**
* function to show all the notifications.
*
* function to show all the notifications
* @return type
*/
public function show()
{
public function show() {
$notifications = $this->getNotifications();
//dd($notifications);
return view('notifications-all', compact('notifications'));
}
/**
* function to delete notifications.
*
* function to delete notifications
* @param type $id
*
* @return int
*/
public function delete($id)
{
public function delete($id) {
$markasread = UserNotification::where('notification_id', '=', $id)->where('user_id', '=', \Auth::user()->id)->get();
foreach ($markasread as $mark) {
$mark->delete();
@@ -132,25 +119,36 @@ class NotificationController extends Controller
return 1;
}
public function deleteAll() {
try{
$notifications = new Notification();
if ($notifications->count()>0) {
foreach ($notifications->get() as $notification) {
$notification->delete();
}
}
$notifications->dummyDelete();
return redirect()->back()->with('success', 'deleted');
} catch (\Exception $ex){
return redirect()->back()->with('fails',$ex->getMessage());
}
}
/**
* get the page to list the notifications.
*
* @return response
*/
public static function getNotifications()
{
$notifications = UserNotification::join('notifications', 'user_notification.notification_id', '=', 'notifications.id')
->join('notification_types', 'notifications.type_id', '=', 'notification_types.id')
->where('user_notification.user_id', '=', \Auth::user()->id)
->select('notification_types.id as id', 'notifications.id as notification_id',
'user_notification.user_id as user_id', 'user_notification.is_read as is_read',
'user_notification.created_at as created_at', 'user_notification.updated_at as updated_at', 'notifications.model_id as model_id',
'notifications.userid_created as userid_created',
'notifications.type_id as type_id', 'notification_types.message as message',
'notification_types.type as type', 'notification_types.icon_class as icon_class')
->orderBy('user_notification.created_at', 'desc')
->paginate(10);
public static function getNotifications() {
$notifications = UserNotification::with([
'notification.type' => function($query) {
$query->select('id', 'message', 'type');
}, 'users' => function($query) {
$query->select('id', 'email', 'profile_pic');
}, 'notification.model' => function($query) {
$query->select('id', 'ticket_number');
},
]);
return $notifications;
}
}

View File

@@ -10,16 +10,14 @@ use App\Model\helpdesk\Settings\Company;
use App\Model\helpdesk\Settings\Email;
use App\User;
use Auth;
use Mail;
use Exception;
use Lang;
use Mail;
class PhpMailController extends Controller
{
public function fetch_smtp_details($id)
{
class PhpMailController extends Controller {
public function fetch_smtp_details($id) {
$emails = Emails::where('id', '=', $id)->first();
return $emails;
}
@@ -28,8 +26,7 @@ class PhpMailController extends Controller
*
* @return type
*/
public function company()
{
public function company() {
$company = Company::Where('id', '=', '1')->first();
if ($company->company_name == null) {
$company = 'Support Center';
@@ -48,32 +45,27 @@ class PhpMailController extends Controller
*
* @return type integer
*/
public function mailfrom($reg, $dept_id)
{
$email = Email::where('id', '=', '1')->first();
if ($reg == 1) {
return $email->sys_email;
} elseif ($dept_id > 0) {
$department = Department::where('id', '=', $dept_id)->first();
if ($department->outgoing_email) {
return $department->outgoing_email;
} else {
return $email->sys_email;
}
public function mailfrom($reg, $dept_id) {
$email_id = "";
$emails = Emails::where('department', '=', $dept_id)->first();
$email = Email::find(1);
if ($emails && $emails->sending_status) {
$email_id = $emails->id;
} else {
$email_id = $email->sys_email;
}
return $email_id;
}
public function sendmail($from, $to, $message, $template_variables)
{
public function sendmail($from, $to, $message, $template_variables) {
$this->setQueue();
$job = new \App\Jobs\SendEmail($from, $to, $message, $template_variables);
$dispatch = $this->dispatch($job);
return $dispatch;
$this->dispatch($job);
}
public function sendEmail($from, $to, $message, $template_variables)
{
public function sendEmail($from, $to, $message, $template_variables) {
$from_address = $this->fetch_smtp_details($from);
if ($from_address == null) {
throw new Exception(Lang::get('lang.system-email-not-configured'));
@@ -104,11 +96,11 @@ class PhpMailController extends Controller
$ticket_link_with_number = $this->checkElement('ticket_link_with_number', $template_variables);
$system_from = $this->checkElement('system_from', $template_variables);
if ($system_from === '') {
if ($system_from === "") {
$system_from = $this->company();
}
$system_link = $this->checkElement('system_link', $template_variables);
if ($system_link === '') {
if ($system_link === "") {
$system_link = \Config::get('app.url');
}
$ticket_link = $this->checkElement('ticket_link', $template_variables);
@@ -121,6 +113,7 @@ class PhpMailController extends Controller
$email_address = $this->checkElement('email_address', $template_variables);
$user = $this->checkElement('user', $template_variables);
$status = \DB::table('settings_email')->first();
$template = TemplateType::where('name', '=', $template_type)->first();
@@ -134,7 +127,7 @@ class PhpMailController extends Controller
if ($template_data->subject) {
$subject = $template_data->subject;
if ($ticket_number != null) {
$subject = $subject.' [#'.$ticket_number.']';
$subject = $subject . ' [#' . $ticket_number . ']';
}
} else {
$subject = $message['subject'];
@@ -147,6 +140,7 @@ class PhpMailController extends Controller
$subject = null;
}
$variables = ['{!!$user!!}', '{!!$agent!!}', '{!!$ticket_number!!}', '{!!$content!!}', '{!!$from!!}', '{!!$ticket_agent_name!!}', '{!!$ticket_client_name!!}', '{!!$ticket_client_email!!}', '{!!$ticket_body!!}', '{!!$ticket_assigner!!}', '{!!$ticket_link_with_number!!}', '{!!$system_error!!}', '{!!$agent_sign!!}', '{!!$department_sign!!}', '{!!$password_reset_link!!}', '{!!$email_address!!}', '{!!$user_password!!}', '{!!$system_from!!}', '{!!$system_link!!}', '{!!$ticket_link!!}'];
$data = [$user, $agent, $ticket_number, $content, $from, $ticket_agent_name, $ticket_client_name, $ticket_client_email, $ticket_body, $ticket_assigner, $ticket_link_with_number, $system_error, $agent_sign, $department_sign, $password_reset_link, $email_address, $user_password, $system_from, $system_link, $ticket_link];
@@ -156,20 +150,20 @@ class PhpMailController extends Controller
$contents = $messagebody;
}
if ($template_type == 'ticket-reply-agent') {
$line = '---Reply above this line--- <br/><br/>';
$content = $line.$messagebody;
$content = $line . $messagebody;
} else {
$content = $messagebody;
}
}
$send = $this->laravelMail($recipants, $recipantname, $subject, $content, $cc, $attachment);
return $send;
}
public function setMailConfig($from_address)
{
public function setMailConfig($from_address) {
$username = $from_address->email_address;
$fromname = $from_address->email_name;
$password = $from_address->password;
@@ -186,94 +180,88 @@ class PhpMailController extends Controller
$port = '';
}
$configs = [
'username' => $username,
'from' => ['address' => $username, 'name' => $fromname],
'password' => $password,
'username' => $username,
'from' => ['address' => $username, 'name' => $fromname,],
'password' => $password,
'encryption' => $smtpsecure,
'host' => $host,
'port' => $port,
'driver' => $protocol,
'host' => $host,
'port' => $port,
'driver' => $protocol,
];
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 setServices($emailid, $protocol)
{
public function setServices($emailid, $protocol) {
$service = new \App\Model\MailJob\FaveoMail();
$services = $service->where('email_id', $emailid)->lists('value', 'key')->toArray();
$controller = new \App\Http\Controllers\Admin\helpdesk\EmailsController();
$controller->setServiceConfig($protocol, $services);
}
public function checkElement($element, $array)
{
$value = '';
public function checkElement($element, $array) {
$value = "";
if (is_array($array)) {
if (array_key_exists($element, $array)) {
if (key_exists($element, $array)) {
$value = $array[$element];
}
}
return $value;
}
public function laravelMail($to, $toname, $subject, $data, $cc, $attach)
{
public function laravelMail($to, $toname, $subject, $data, $cc, $attach) {
//dd($to, $toname, $subject, $data, $cc, $attach);
//dd(\Config::get('mail'));
//dd($attach);
$mail = Mail::send('emails.mail', ['data' => $data], function ($m) use ($to, $subject, $toname, $cc, $attach) {
$m->to($to, $toname)->subject($subject);
$m->to($to, $toname)->subject($subject);
if ($cc != null) {
foreach ($cc as $collaborator) {
//mail to collaborators
if ($cc != null) {
foreach ($cc as $collaborator) {
//mail to collaborators
$collab_user_id = $collaborator->user_id;
$user_id_collab = User::where('id', '=', $collab_user_id)->first();
$collab_email = $user_id_collab->email;
$m->cc($collab_email);
}
}
$user_id_collab = User::where('id', '=', $collab_user_id)->first();
$collab_email = $user_id_collab->email;
$m->cc($collab_email);
}
}
// $mail->addBCC($bc);
$size = count($attach);
if ($size > 0) {
for ($i = 0; $i < $size; $i++) {
if (is_array($attach) && array_key_exists($i, $attach)) {
$mode = 'normal';
if (is_array($attach[$i]) && array_key_exists('mode', $attach[$i])) {
$mode = $attach[$i]['mode'];
if ($size > 0) {
for ($i = 0; $i < $size; $i++) {
if (is_array($attach) && array_key_exists($i, $attach)) {
$mode = 'normal';
if (is_array($attach[$i]) && array_key_exists('mode', $attach[$i])) {
$mode = $attach[$i]['mode'];
}
$file = $attach[$i]['file_path'];
$name = $attach[$i]['file_name'];
$mime = $attach[$i]['mime'];
$this->attachmentMode($m, $file, $name, $mime, $mode);
}
}
$file = $attach[$i]['file_path'];
$name = $attach[$i]['file_name'];
$mime = $attach[$i]['mime'];
$this->attachmentMode($m, $file, $name, $mime, $mode);
}
}
}
});
});
if (is_object($mail) || (is_object($mail) && $mail->getStatusCode() == 200)) {
$mail = 1;
}
return $mail;
}
public function setQueue()
{
public function setQueue() {
$short = 'database';
$field = [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'table' => 'jobs',
'queue' => 'default',
'expire' => 60,
];
$queue = new \App\Model\MailJob\QueueService();
@@ -286,20 +274,18 @@ class PhpMailController extends Controller
$this->setQueueConfig($short, $field);
}
public function setQueueConfig($short, $field)
{
public function setQueueConfig($short, $field) {
\Config::set('queue.default', $short);
foreach ($field as $key => $value) {
\Config::set("queue.connections.$short.$key", $value);
}
}
public function attachmentMode($message, $file, $name, $mime, $mode)
{
public function attachmentMode($message, $file, $name, $mime, $mode) {
if ($mode == 'data') {
return $message->attachData(base64_decode($file, true), $name, ['mime' => $mime]);
}
return $message->attach($file, ['as' => $name, 'mime' => $mime]);
}
}

View File

@@ -11,6 +11,7 @@ use App\Model\helpdesk\Email\Smtp;
// models
use App\Model\helpdesk\Settings\Plugin;
use App\Model\helpdesk\Theme\Widgets;
use App\Model\helpdesk\Utility\Version_Check;
use Config;
// classes
use Crypt;
@@ -26,15 +27,14 @@ use Lang;
* ***************************
* Controller to keep smtp details and fetch where ever needed.
*/
class SettingsController extends Controller
{
class SettingsController extends Controller {
/**
* Create a new controller instance.
*
* @return type void
*/
public function __construct()
{
public function __construct() {
$this->middleware('auth');
$this->middleware('roles');
}
@@ -44,8 +44,7 @@ class SettingsController extends Controller
*
* @return response
*/
public function widgets()
{
public function widgets() {
return view('themes.default1.admin.helpdesk.theme.widgets');
}
@@ -54,8 +53,7 @@ class SettingsController extends Controller
*
* @return response
*/
public function list_widget()
{
public function list_widget() {
return \Datatable::collection(Widgets::where('id', '<', '7')->get())
->searchColumns('name')
->orderColumns('name', 'title', 'value')
@@ -69,33 +67,33 @@ class SettingsController extends Controller
return $model->value;
})
->addColumn('Actions', function ($model) {
return '<span data-toggle="modal" data-target="#edit_widget'.$model->id.'"><a class="btn btn-warning btn-xs">'.\Lang::get('lang.edit').'</a></span>
<div class="modal fade" id="edit_widget'.$model->id.'">
return '<span data-toggle="modal" data-target="#edit_widget' . $model->id . '"><a class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a></span>
<div class="modal fade" id="edit_widget' . $model->id . '">
<div class="modal-dialog">
<div class="modal-content">
<form action="'.url('edit-widget/'.$model->id).'" method="POST">
<form action="' . url('edit-widget/' . $model->id) . '" method="POST">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">'.strtoupper($model->name).' </h4>
<h4 class="modal-title">' . strtoupper($model->name) . ' </h4>
</div>
<div class="modal-body">
<div class="form-group" style="width:100%">
<label>'.\Lang::get('lang.title').'</label><br/>
<input type="text" name="title" value="'.$model->title.'" class="form-control" style="width:100%">
<label>' . \Lang::get('lang.title') . '</label><br/>
<input type="text" name="title" value="' . $model->title . '" class="form-control" style="width:100%">
</div>
<br/>
<div class="form-group" style="width:100%">
<label>'.\Lang::get('lang.content').'</label><br/>
<textarea name="content" class="form-control" style="width:100%" id="Content'.$model->id.'">'.$model->value.'</textarea>
<label>' . \Lang::get('lang.content') . '</label><br/>
<textarea name="content" class="form-control" style="width:100%" id="Content' . $model->id . '">' . $model->value . '</textarea>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">'.\Lang::get('lang.close').'</button>
<input type="submit" class="btn btn-primary" value="'.\Lang::get('lang.update').'">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">' . \Lang::get('lang.close') . '</button>
<input type="submit" class="btn btn-primary" value="' . \Lang::get('lang.update') . '">
</div>
<script>
$(function () {
$("#Content'.$model->id.'").wysihtml5();
$("#Content' . $model->id . '").wysihtml5();
});
</script>
</form>
@@ -114,15 +112,13 @@ class SettingsController extends Controller
*
* @return type response
*/
public function edit_widget($id, Widgets $widgets, Request $request)
{
public function edit_widget($id, Widgets $widgets, Request $request) {
$widget = $widgets->where('id', '=', $id)->first();
$widget->title = $request->title;
$widget->value = $request->content;
try {
$widget->save();
return redirect()->back()->with('success', $widget->name.Lang::get('lang.saved_successfully'));
return redirect()->back()->with('success', $widget->name . Lang::get('lang.saved_successfully'));
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->getMessage());
}
@@ -133,8 +129,7 @@ class SettingsController extends Controller
*
* @return response
*/
public function social_buttons()
{
public function social_buttons() {
return view('themes.default1.admin.helpdesk.theme.social');
}
@@ -143,8 +138,7 @@ class SettingsController extends Controller
*
* @return response
*/
public function list_social_buttons()
{
public function list_social_buttons() {
return \Datatable::collection(Widgets::where('id', '>', '6')->get())
->searchColumns('name')
->orderColumns('name', 'value')
@@ -155,25 +149,25 @@ class SettingsController extends Controller
return $model->value;
})
->addColumn('Actions', function ($model) {
return '<span data-toggle="modal" data-target="#edit_widget'.$model->id.'"><a class="btn btn-warning btn-xs">'.\Lang::get('lang.edit').'</a></span>
<div class="modal fade" id="edit_widget'.$model->id.'">
return '<span data-toggle="modal" data-target="#edit_widget' . $model->id . '"><a class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a></span>
<div class="modal fade" id="edit_widget' . $model->id . '">
<div class="modal-dialog">
<div class="modal-content">
<form action="'.url('edit-widget/'.$model->id).'" method="POST">
<form action="' . url('edit-widget/' . $model->id) . '" method="POST">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">'.strtoupper($model->name).' </h4>
<h4 class="modal-title">' . strtoupper($model->name) . ' </h4>
</div>
<div class="modal-body">
<br/>
<div class="form-group" style="width:100%">
<label>'.\Lang::get('lang.link').'</label><br/>
<input type="url" name="content" class="form-control" style="width:100%" value="'.$model->value.'">
<label>' . \Lang::get('lang.link') . '</label><br/>
<input type="url" name="content" class="form-control" style="width:100%" value="' . $model->value . '">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">'.\Lang::get('lang.close').'</button>
<input type="submit" class="btn btn-primary" value="'.\Lang::get('lang.update').'">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">' . \Lang::get('lang.close') . '</button>
<input type="submit" class="btn btn-primary" value="' . \Lang::get('lang.update') . '">
</div>
</form>
</div>
@@ -191,15 +185,14 @@ class SettingsController extends Controller
*
* @return type response
*/
public function edit_social_buttons($id, Widgets $widgets, Request $request)
{
public function edit_social_buttons($id, Widgets $widgets, Request $request) {
$widget = $widgets->where('id', '=', $id)->first();
$widget->title = $request->title;
$widget->value = $request->content;
try {
$widget->save();
return redirect()->back()->with('success', $widget->name.' Saved Successfully');
return redirect()->back()->with('success', $widget->name . ' Saved Successfully');
} catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]);
}
@@ -210,10 +203,8 @@ class SettingsController extends Controller
*
* @return type view
*/
public function getsmtp()
{
public function getsmtp() {
$settings = Smtp::where('id', '=', '1')->first();
return view('themes.default1.admin.helpdesk.emails.smtp', compact('settings'));
}
@@ -222,8 +213,7 @@ class SettingsController extends Controller
*
* @return type view
*/
public function postsmtp(SmtpRequest $request)
{
public function postsmtp(SmtpRequest $request) {
$data = Smtp::where('id', '=', 1)->first();
$data->driver = $request->input('driver');
$data->host = $request->input('host');
@@ -234,7 +224,6 @@ class SettingsController extends Controller
$data->password = Crypt::encrypt($request->input('password'));
try {
$data->save();
return \Redirect::route('getsmtp')->with('success', 'success');
} catch (Exception $e) {
return \Redirect::route('getsmtp')->with('fails', $e->errorInfo[2]);
@@ -249,8 +238,7 @@ class SettingsController extends Controller
*
* @return type view
*/
public function PostSettings(Settings $set, Request $request)
{
public function PostSettings(Settings $set, Request $request) {
$settings = $set->where('id', '1')->first();
$pass = $request->input('password');
$password = Crypt::encrypt($pass);
@@ -263,7 +251,7 @@ class SettingsController extends Controller
if (Input::file('logo')) {
$name = Input::file('logo')->getClientOriginalName();
$destinationPath = 'dist/logo';
$fileName = rand(0000, 9999).'.'.$name;
$fileName = rand(0000, 9999) . '.' . $name;
Input::file('logo')->move($destinationPath, $fileName);
$settings->logo = $fileName;
$settings->save();
@@ -277,13 +265,11 @@ class SettingsController extends Controller
}
}
public function Plugins()
{
return view('themes.default1.admin.helpdesk.settings.plugins', ['info' => 1]);
public function Plugins() {
return view('themes.default1.admin.helpdesk.settings.plugins');
}
public function GetPlugin()
{
public function GetPlugin() {
$plugins = $this->fetchConfig();
return \Datatable::collection(new Collection($plugins))
@@ -291,15 +277,15 @@ class SettingsController extends Controller
->addColumn('name', function ($model) {
if (array_has($model, 'path')) {
if ($model['status'] == 0) {
$activate = '<a href='.url('plugin/status/'.$model['path']).'>Activate</a>';
$activate = '<a href=' . url('plugin/status/' . $model['path']) . '>Activate</a>';
$settings = ' ';
} else {
$settings = '<a href='.url($model['settings']).'>Settings</a> | ';
$activate = '<a href='.url('plugin/status/'.$model['path']).'>Deactivate</a>';
$settings = '<a href=' . url($model['settings']) . '>Settings</a> | ';
$activate = '<a href=' . url('plugin/status/' . $model['path']) . '>Deactivate</a>';
}
$delete = '<a href="#" id=delete'.$model['path'].' data-toggle=modal data-target=#del'.$model['path']."><span style='color:red'>Delete</span></a>"
."<div class='modal fade' id=del".$model['path'].">
$delete = '<a href="#" id=delete' . $model['path'] . ' data-toggle=modal data-target=#del' . $model['path'] . "><span style='color:red'>Delete</span></a>"
. "<div class='modal fade' id=del" . $model['path'] . ">
<div class='modal-dialog'>
<div class=modal-content>
<div class=modal-header>
@@ -308,8 +294,8 @@ class SettingsController extends Controller
<div class=modal-body>
<p>Are you Sure ?</p>
<div class=modal-footer>
<button type=button class='btn btn-default pull-left' data-dismiss=modal id=dismis>".\Lang::get('lang.close').'</button>
<a href='.url('plugin/delete/'.$model['path'])."><button class='btn btn-danger'>Delete</button></a>
<button type=button class='btn btn-default pull-left' data-dismiss=modal id=dismis>" . \Lang::get('lang.close') . '</button>
<a href=' . url('plugin/delete/' . $model['path']) . "><button class='btn btn-danger'>Delete</button></a>
</div>
@@ -317,12 +303,12 @@ class SettingsController extends Controller
</div>
</div>
</div>";
$action = '<br><br>'.$delete.' | '.$settings.$activate;
$action = '<br><br>' . $delete . ' | ' . $settings . $activate;
} else {
$action = '';
}
return ucfirst($model['name']).$action;
return ucfirst($model['name']) . $action;
})
->addColumn('description', function ($model) {
return ucfirst($model['description']);
@@ -331,7 +317,7 @@ class SettingsController extends Controller
return ucfirst($model['author']);
})
->addColumn('website', function ($model) {
return '<a href='.$model['website'].' target=_blank>'.$model['website'].'</a>';
return '<a href=' . $model['website'] . ' target=_blank>' . $model['website'] . '</a>';
})
->addColumn('version', function ($model) {
return $model['version'];
@@ -344,9 +330,8 @@ class SettingsController extends Controller
*
* @return type
*/
public function ReadPlugins()
{
$dir = app_path().DIRECTORY_SEPARATOR.'Plugins';
public function ReadPlugins() {
$dir = app_path() . DIRECTORY_SEPARATOR . 'Plugins';
$plugins = array_diff(scandir($dir), ['.', '..']);
return $plugins;
@@ -359,16 +344,15 @@ class SettingsController extends Controller
*
* @return type
*/
public function PostPlugins(Request $request)
{
public function PostPlugins(Request $request) {
$this->validate($request, ['plugin' => 'required|mimes:application/zip,zip,Zip']);
try {
if (!extension_loaded('zip')) {
if (!extension_loaded('zip')){
throw new Exception('Please enable zip extension in your php');
}
$plug = new Plugin();
$file = $request->file('plugin');
$destination = app_path().DIRECTORY_SEPARATOR.'Plugins';
$destination = app_path() . DIRECTORY_SEPARATOR . 'Plugins';
$zipfile = $file->getRealPath();
/*
* get the file name and remove .zip
@@ -381,32 +365,32 @@ class SettingsController extends Controller
if (in_array($filename, $dir_check)) {
return redirect()->back()->with('fails', Lang::get('lang.plugin-exists'));
}
mkdir($destination.DIRECTORY_SEPARATOR.$filename);
mkdir($destination . DIRECTORY_SEPARATOR . $filename);
/*
* extract the zip file using zipper
*/
\Zipper::make($zipfile)->folder($filename2)->extractTo($destination.DIRECTORY_SEPARATOR.$filename);
\Zipper::make($zipfile)->folder($filename2)->extractTo($destination . DIRECTORY_SEPARATOR . $filename);
$file = app_path().DIRECTORY_SEPARATOR.'Plugins'.DIRECTORY_SEPARATOR.$filename; // Plugin file path
$file = app_path() . DIRECTORY_SEPARATOR . 'Plugins' . DIRECTORY_SEPARATOR . $filename; // Plugin file path
if (file_exists($file)) {
$seviceporvider = $file.DIRECTORY_SEPARATOR.'ServiceProvider.php';
$config = $file.DIRECTORY_SEPARATOR.'config.php';
$seviceporvider = $file . DIRECTORY_SEPARATOR . 'ServiceProvider.php';
$config = $file . DIRECTORY_SEPARATOR . 'config.php';
if (file_exists($seviceporvider) && file_exists($config)) {
/*
* move to faveo config
*/
$faveoconfig = config_path().DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$filename.'.php';
$faveoconfig = config_path() . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $filename . '.php';
if ($faveoconfig) {
//copy($config, $faveoconfig);
/*
* write provider list in app.php line 128
*/
$app = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
$app = base_path() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'app.php';
chmod($app, 0644);
$str = "\n\n\t\t\t'App\\Plugins\\$filename"."\\ServiceProvider',";
$line_i_am_looking_for = 187;
$str = "\n\n\t\t\t'App\\Plugins\\$filename" . "\\ServiceProvider',";
$line_i_am_looking_for = 194;
$lines = file($app, FILE_IGNORE_NEW_LINES);
$lines[$line_i_am_looking_for] = $str;
file_put_contents($app, implode("\n", $lines));
@@ -419,7 +403,7 @@ class SettingsController extends Controller
*/
$this->deleteDirectory($file);
return redirect()->back()->with('fails', Lang::get('no-plugin-file').$file);
return redirect()->back()->with('fails', Lang::get('no-plugin-file') . $file);
}
} else {
/*
@@ -427,7 +411,7 @@ class SettingsController extends Controller
*/
$this->deleteDirectory($file);
return redirect()->back()->with('fails', Lang::get('plugin-config-missing').$file);
return redirect()->back()->with('fails', Lang::get('plugin-config-missing') . $file);
}
} else {
/*
@@ -435,7 +419,7 @@ class SettingsController extends Controller
*/
$this->deleteDirectory($file);
return redirect()->back()->with('fails', '<b>'.Lang::get('lang.plugin-path-missing').'</b> '.$file);
return redirect()->back()->with('fails', '<b>' . Lang::get('lang.plugin-path-missing') . '</b> ' . $file);
}
} catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage());
@@ -449,8 +433,7 @@ class SettingsController extends Controller
*
* @return bool
*/
public function deleteDirectory($dir)
{
public function deleteDirectory($dir) {
if (!file_exists($dir)) {
return true;
}
@@ -461,8 +444,8 @@ class SettingsController extends Controller
if ($item == '.' || $item == '..') {
continue;
}
chmod($dir.DIRECTORY_SEPARATOR.$item, 0777);
if (!$this->deleteDirectory($dir.DIRECTORY_SEPARATOR.$item)) {
chmod($dir . DIRECTORY_SEPARATOR . $item, 0777);
if (!$this->deleteDirectory($dir . DIRECTORY_SEPARATOR . $item)) {
return false;
}
}
@@ -471,9 +454,8 @@ class SettingsController extends Controller
return rmdir($dir);
}
public function ReadConfigs()
{
$dir = app_path().DIRECTORY_SEPARATOR.'Plugins'.DIRECTORY_SEPARATOR;
public function ReadConfigs() {
$dir = app_path() . DIRECTORY_SEPARATOR . 'Plugins' . DIRECTORY_SEPARATOR;
$directories = scandir($dir);
$files = [];
foreach ($directories as $key => $file) {
@@ -481,7 +463,7 @@ class SettingsController extends Controller
continue;
}
if (is_dir($dir.DIRECTORY_SEPARATOR.$file)) {
if (is_dir($dir . DIRECTORY_SEPARATOR . $file)) {
$files[$key] = $file;
}
}
@@ -490,7 +472,7 @@ class SettingsController extends Controller
$plugins = [];
if (count($files) > 0) {
foreach ($files as $key => $file) {
$plugin = $dir.$file;
$plugin = $dir . $file;
$plugins[$key] = array_diff(scandir($plugin), ['.', '..', 'ServiceProvider.php']);
$plugins[$key]['file'] = $plugin;
}
@@ -500,7 +482,7 @@ class SettingsController extends Controller
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if ($file == 'config.php') {
$config[] = $dir.DIRECTORY_SEPARATOR.$file;
$config[] = $dir . DIRECTORY_SEPARATOR . $file;
}
}
closedir($dh);
@@ -513,8 +495,7 @@ class SettingsController extends Controller
}
}
public function fetchConfig()
{
public function fetchConfig() {
$configs = $this->ReadConfigs();
//dd($configs);
$plugs = new Plugin();
@@ -550,15 +531,14 @@ class SettingsController extends Controller
return $attributes;
}
public function DeletePlugin($slug)
{
$dir = app_path().DIRECTORY_SEPARATOR.'Plugins'.DIRECTORY_SEPARATOR.$slug;
public function DeletePlugin($slug) {
$dir = app_path() . DIRECTORY_SEPARATOR . 'Plugins' . DIRECTORY_SEPARATOR . $slug;
$this->deleteDirectory($dir);
/*
* remove service provider from app.php
*/
$str = "'App\\Plugins\\$slug"."\\ServiceProvider',";
$path_to_file = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
$str = "'App\\Plugins\\$slug" . "\\ServiceProvider',";
$path_to_file = base_path() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'app.php';
$file_contents = file_get_contents($path_to_file);
$file_contents = str_replace($str, '//', $file_contents);
file_put_contents($path_to_file, $file_contents);
@@ -571,14 +551,13 @@ class SettingsController extends Controller
return redirect()->back()->with('success', 'Deleted Successfully');
}
public function StatusPlugin($slug)
{
public function StatusPlugin($slug) {
$plugs = new Plugin();
$plug = $plugs->where('name', $slug)->first();
if (!$plug) {
$app = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
$str = "\n'App\\Plugins\\$slug"."\\ServiceProvider',";
$line_i_am_looking_for = 187;
$app = base_path() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'app.php';
$str = "\n'App\\Plugins\\$slug" . "\\ServiceProvider',";
$line_i_am_looking_for = 194;
$lines = file($app, FILE_IGNORE_NEW_LINES);
$lines[$line_i_am_looking_for] = $str;
file_put_contents($app, implode("\n", $lines));
@@ -590,9 +569,9 @@ class SettingsController extends Controller
if ($status == 0) {
$plug->status = 1;
$app = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
$str = "\n'App\\Plugins\\$slug"."\\ServiceProvider',";
$line_i_am_looking_for = 187;
$app = base_path() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'app.php';
$str = "\n'App\\Plugins\\$slug" . "\\ServiceProvider',";
$line_i_am_looking_for = 194;
$lines = file($app, FILE_IGNORE_NEW_LINES);
$lines[$line_i_am_looking_for] = $str;
file_put_contents($app, implode("\n", $lines));
@@ -602,8 +581,8 @@ class SettingsController extends Controller
/*
* remove service provider from app.php
*/
$str = "\n'App\\Plugins\\$slug"."\\ServiceProvider',";
$path_to_file = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
$str = "\n'App\\Plugins\\$slug" . "\\ServiceProvider',";
$path_to_file = base_path() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'app.php';
$file_contents = file_get_contents($path_to_file);
$file_contents = str_replace($str, '//', $file_contents);

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Http\Controllers\Common;
namespace App\Http\Controllers\Common;
use Socialite;
class Socialite extends Socialite
{
class Socialite extends Socialite{
}

View File

@@ -6,9 +6,9 @@ use App\Http\Controllers\Controller;
use App\Http\Requests\helpdesk\TemplateSetRequest;
use App\Model\Common\Template;
use App\Model\Common\TemplateSet;
use Exception;
use Illuminate\Http\Request;
use Lang;
use Exception;
class TemplateSetController extends Controller
{