Update v1.0.7.2

This commit is contained in:
Sujit Prasad
2016-04-21 15:17:45 +05:30
parent fd99de01fd
commit 98c2a1d98d
3 changed files with 171 additions and 184 deletions

View File

@@ -666,9 +666,11 @@ class TicketController extends Controller
} }
$emails_to_be_sent = array_unique($set_mails, SORT_REGULAR); $emails_to_be_sent = array_unique($set_mails, SORT_REGULAR);
foreach ($emails_to_be_sent as $email_data) { foreach ($emails_to_be_sent as $email_data) {
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $ticketdata->dept_id), $to = ['user' => $email_data['to_user'], 'email' => $email_data['to_email']], $message = ['subject' => $updated_subject, 'body' => $body, 'scenario' => $mail], $template_variables = ['ticket_agent_name' => $email_data['to_user_name'], 'ticket_client_name' => $username, 'ticket_client_email' => $emailadd, 'user' => $email_data['to_user_name'], 'ticket_number' => $ticket_number2, 'email_address' => $emailadd, 'name' => $ticket_creator]); try {
$this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('0', $ticketdata->dept_id), $to = ['user' => $email_data['to_user'], 'email' => $email_data['to_email']], $message = ['subject' => $updated_subject, 'body' => $body, 'scenario' => $mail], $template_variables = ['ticket_agent_name' => $email_data['to_user_name'], 'ticket_client_name' => $username, 'ticket_client_email' => $emailadd, 'user' => $email_data['to_user_name'], 'ticket_number' => $ticket_number2, 'email_address' => $emailadd, 'name' => $ticket_creator]);
} catch (\Exception $e) {
}
} }
return ['0' => $ticket_number2, '1' => true]; return ['0' => $ticket_number2, '1' => true];
} }
} }

View File

@@ -26,25 +26,24 @@ use Input;
* *************************** * ***************************
* Controller to keep smtp details and fetch where ever needed. * Controller to keep smtp details and fetch where ever needed.
*/ */
class SettingsController extends Controller class SettingsController extends Controller {
{
/** /**
* Create a new controller instance. * Create a new controller instance.
* *
* @return type void * @return type void
*/ */
public function __construct() public function __construct() {
{
// $this->smtp(); // $this->smtp();
$this->middleware('auth'); $this->middleware('auth');
$this->middleware('roles'); $this->middleware('roles');
self::driver(); // self::driver();
self::host(); // self::host();
self::port(); // self::port();
self::from(); // self::from();
self::encryption(); // self::encryption();
self::username(); // self::username();
self::password(); // self::password();
} }
/** /**
@@ -52,8 +51,7 @@ class SettingsController extends Controller
* *
* @return response * @return response
*/ */
public function widgets() public function widgets() {
{
return view('themes.default1.admin.helpdesk.theme.widgets'); return view('themes.default1.admin.helpdesk.theme.widgets');
} }
@@ -62,8 +60,7 @@ class SettingsController extends Controller
* *
* @return response * @return response
*/ */
public function list_widget() public function list_widget() {
{
return \Datatable::collection(Widgets::where('id', '<', '7')->get()) return \Datatable::collection(Widgets::where('id', '<', '7')->get())
->searchColumns('name') ->searchColumns('name')
->orderColumns('name', 'title', 'value') ->orderColumns('name', 'title', 'value')
@@ -77,33 +74,33 @@ class SettingsController extends Controller
return $model->value; return $model->value;
}) })
->addColumn('Actions', function ($model) { ->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> 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 fade" id="edit_widget' . $model->id . '">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <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"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <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>
<div class="modal-body"> <div class="modal-body">
<div class="form-group" style="width:100%"> <div class="form-group" style="width:100%">
<label>'.\Lang::get('lang.title').'</label><br/> <label>' . \Lang::get('lang.title') . '</label><br/>
<input type="text" name="title" value="'.$model->title.'" class="form-control" style="width:100%"> <input type="text" name="title" value="' . $model->title . '" class="form-control" style="width:100%">
</div> </div>
<br/> <br/>
<div class="form-group" style="width:100%"> <div class="form-group" style="width:100%">
<label>'.\Lang::get('lang.content').'</label><br/> <label>' . \Lang::get('lang.content') . '</label><br/>
<textarea name="content" class="form-control" style="width:100%" id="Content'.$model->id.'">'.$model->value.'</textarea> <textarea name="content" class="form-control" style="width:100%" id="Content' . $model->id . '">' . $model->value . '</textarea>
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">'.\Lang::get('lang.close').'</button> <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').'"> <input type="submit" class="btn btn-primary" value="' . \Lang::get('lang.update') . '">
</div> </div>
<script> <script>
$(function () { $(function () {
$("#Content'.$model->id.'").wysihtml5(); $("#Content' . $model->id . '").wysihtml5();
}); });
</script> </script>
</form> </form>
@@ -122,15 +119,14 @@ class SettingsController extends Controller
* *
* @return type response * @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 = $widgets->where('id', '=', $id)->first();
$widget->title = $request->title; $widget->title = $request->title;
$widget->value = $request->content; $widget->value = $request->content;
try { try {
$widget->save(); $widget->save();
return redirect()->back()->with('success', $widget->name.' Saved Successfully'); return redirect()->back()->with('success', $widget->name . ' Saved Successfully');
} catch (Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]); return redirect()->back()->with('fails', $e->errorInfo[2]);
} }
@@ -141,8 +137,7 @@ class SettingsController extends Controller
* *
* @return response * @return response
*/ */
public function social_buttons() public function social_buttons() {
{
return view('themes.default1.admin.helpdesk.theme.social'); return view('themes.default1.admin.helpdesk.theme.social');
} }
@@ -151,8 +146,7 @@ class SettingsController extends Controller
* *
* @return response * @return response
*/ */
public function list_social_buttons() public function list_social_buttons() {
{
return \Datatable::collection(Widgets::where('id', '>', '6')->get()) return \Datatable::collection(Widgets::where('id', '>', '6')->get())
->searchColumns('name') ->searchColumns('name')
->orderColumns('name', 'value') ->orderColumns('name', 'value')
@@ -163,25 +157,25 @@ class SettingsController extends Controller
return $model->value; return $model->value;
}) })
->addColumn('Actions', function ($model) { ->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> 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 fade" id="edit_widget' . $model->id . '">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <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"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <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>
<div class="modal-body"> <div class="modal-body">
<br/> <br/>
<div class="form-group" style="width:100%"> <div class="form-group" style="width:100%">
<label>'.\Lang::get('lang.link').'</label><br/> <label>' . \Lang::get('lang.link') . '</label><br/>
<input type="url" name="content" class="form-control" style="width:100%" value="'.$model->value.'"> <input type="url" name="content" class="form-control" style="width:100%" value="' . $model->value . '">
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">'.\Lang::get('lang.close').'</button> <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').'"> <input type="submit" class="btn btn-primary" value="' . \Lang::get('lang.update') . '">
</div> </div>
</form> </form>
</div> </div>
@@ -199,15 +193,14 @@ class SettingsController extends Controller
* *
* @return type response * @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 = $widgets->where('id', '=', $id)->first();
$widget->title = $request->title; $widget->title = $request->title;
$widget->value = $request->content; $widget->value = $request->content;
try { try {
$widget->save(); $widget->save();
return redirect()->back()->with('success', $widget->name.' Saved Successfully'); return redirect()->back()->with('success', $widget->name . ' Saved Successfully');
} catch (Exception $e) { } catch (Exception $e) {
return redirect()->back()->with('fails', $e->errorInfo[2]); return redirect()->back()->with('fails', $e->errorInfo[2]);
} }
@@ -218,8 +211,7 @@ class SettingsController extends Controller
* *
* @return type void * @return type void
*/ */
public static function driver() public static function driver() {
{
$set = new Smtp(); $set = new Smtp();
$settings = Smtp::where('id', '=', '1')->first(); $settings = Smtp::where('id', '=', '1')->first();
Config::set('mail.host', $settings->driver); Config::set('mail.host', $settings->driver);
@@ -230,8 +222,7 @@ class SettingsController extends Controller
* *
* @return type void * @return type void
*/ */
public static function host() public static function host() {
{
$set = new Smtp(); $set = new Smtp();
$settings = Smtp::where('id', '=', '1')->first(); $settings = Smtp::where('id', '=', '1')->first();
Config::set('mail.host', $settings->host); Config::set('mail.host', $settings->host);
@@ -242,8 +233,7 @@ class SettingsController extends Controller
* *
* @return type void * @return type void
*/ */
public static function port() public static function port() {
{
$set = new Smtp(); $set = new Smtp();
$settings = Smtp::where('id', '=', '1')->first(); $settings = Smtp::where('id', '=', '1')->first();
Config::set('mail.port', intval($settings->port)); Config::set('mail.port', intval($settings->port));
@@ -254,8 +244,7 @@ class SettingsController extends Controller
* *
* @return type void * @return type void
*/ */
public static function from() public static function from() {
{
$set = new Smtp(); $set = new Smtp();
$settings = Smtp::where('id', '=', '1')->first(); $settings = Smtp::where('id', '=', '1')->first();
Config::set('mail.from', ['address' => $settings->email, 'name' => $settings->company_name]); Config::set('mail.from', ['address' => $settings->email, 'name' => $settings->company_name]);
@@ -266,8 +255,7 @@ class SettingsController extends Controller
* *
* @return type void * @return type void
*/ */
public static function encryption() public static function encryption() {
{
$set = new Smtp(); $set = new Smtp();
$settings = Smtp::where('id', '=', '1')->first(); $settings = Smtp::where('id', '=', '1')->first();
Config::set('mail.encryption', $settings->encryption); Config::set('mail.encryption', $settings->encryption);
@@ -278,8 +266,7 @@ class SettingsController extends Controller
* *
* @return type void * @return type void
*/ */
public static function username() public static function username() {
{
$set = new Smtp(); $set = new Smtp();
$settings = Smtp::where('id', '=', '1')->first(); $settings = Smtp::where('id', '=', '1')->first();
Config::set('mail.username', $settings->email); Config::set('mail.username', $settings->email);
@@ -290,8 +277,7 @@ class SettingsController extends Controller
* *
* @return type void * @return type void
*/ */
public static function password() public static function password() {
{
$settings = Smtp::first(); $settings = Smtp::first();
if ($settings->password) { if ($settings->password) {
$pass = $settings->password; $pass = $settings->password;
@@ -305,8 +291,7 @@ class SettingsController extends Controller
* *
* @return type view * @return type view
*/ */
public function getsmtp() public function getsmtp() {
{
$settings = Smtp::where('id', '=', '1')->first(); $settings = Smtp::where('id', '=', '1')->first();
return view('themes.default1.admin.helpdesk.emails.smtp', compact('settings')); return view('themes.default1.admin.helpdesk.emails.smtp', compact('settings'));
@@ -317,8 +302,7 @@ class SettingsController extends Controller
* *
* @return type view * @return type view
*/ */
public function postsmtp(SmtpRequest $request) public function postsmtp(SmtpRequest $request) {
{
$data = Smtp::where('id', '=', 1)->first(); $data = Smtp::where('id', '=', 1)->first();
$data->driver = $request->input('driver'); $data->driver = $request->input('driver');
$data->host = $request->input('host'); $data->host = $request->input('host');
@@ -341,8 +325,7 @@ class SettingsController extends Controller
* *
* @return type void * @return type void
*/ */
public static function smtp() public static function smtp() {
{
$settings = Smtp::where('id', '=', '1')->first(); $settings = Smtp::where('id', '=', '1')->first();
if ($settings->password) { if ($settings->password) {
$password = Crypt::decrypt($settings->password); $password = Crypt::decrypt($settings->password);
@@ -363,8 +346,7 @@ class SettingsController extends Controller
* *
* @return type view\ * @return type view\
*/ */
public function settings(Smtp $set) public function settings(Smtp $set) {
{
$settings = $set->where('id', '1')->first(); $settings = $set->where('id', '1')->first();
return view('themes.default1.admin.settings', compact('settings')); return view('themes.default1.admin.settings', compact('settings'));
@@ -378,8 +360,7 @@ class SettingsController extends Controller
* *
* @return type view * @return type view
*/ */
public function PostSettings(Settings $set, Request $request) public function PostSettings(Settings $set, Request $request) {
{
$settings = $set->where('id', '1')->first(); $settings = $set->where('id', '1')->first();
$pass = $request->input('password'); $pass = $request->input('password');
$password = Crypt::encrypt($pass); $password = Crypt::encrypt($pass);
@@ -392,7 +373,7 @@ class SettingsController extends Controller
if (Input::file('logo')) { if (Input::file('logo')) {
$name = Input::file('logo')->getClientOriginalName(); $name = Input::file('logo')->getClientOriginalName();
$destinationPath = 'dist/logo'; $destinationPath = 'dist/logo';
$fileName = rand(0000, 9999).'.'.$name; $fileName = rand(0000, 9999) . '.' . $name;
Input::file('logo')->move($destinationPath, $fileName); Input::file('logo')->move($destinationPath, $fileName);
$settings->logo = $fileName; $settings->logo = $fileName;
$settings->save(); $settings->save();
@@ -411,14 +392,13 @@ class SettingsController extends Controller
* *
* @return type * @return type
*/ */
public function version_check() public function version_check() {
{
$response_url = \URL::route('post-version-check'); $response_url = \URL::route('post-version-check');
echo "<form action='http://www.faveohelpdesk.com/billing/version' method='post' name='redirect'>"; echo "<form action='http://www.faveohelpdesk.com/bill/version' method='post' name='redirect'>";
echo "<input type='hidden' name='_token' value='csrf_token()'/>"; echo "<input type='hidden' name='_token' value='csrf_token()'/>";
echo "<input type='hidden' name='title' value='helpdeskcommunityedition'/>"; echo "<input type='hidden' name='title' value='helpdeskcommunityedition'/>";
echo "<input type='hidden' name='id' value='19'/>"; echo "<input type='hidden' name='id' value='19'/>";
echo "<input type='hidden' name='response_url' value='".$response_url."' />"; echo "<input type='hidden' name='response_url' value='" . $response_url . "' />";
echo '</form>'; echo '</form>';
echo "<script language='javascript'>document.redirect.submit();</script>"; echo "<script language='javascript'>document.redirect.submit();</script>";
} }
@@ -428,8 +408,7 @@ class SettingsController extends Controller
* *
* @return type * @return type
*/ */
public function post_version_check(Request $request) public function post_version_check(Request $request) {
{
$current_version = \Config::get('app.version'); $current_version = \Config::get('app.version');
$new_version = $request->value; $new_version = $request->value;
if ($current_version == $new_version) { if ($current_version == $new_version) {
@@ -441,41 +420,39 @@ class SettingsController extends Controller
$version->new_version = $new_version; $version->new_version = $new_version;
$version->save(); $version->save();
// echo "Version " . $new_version . " is Available"; // echo "Version " . $new_version . " is Available";
return redirect()->route('checkupdate')->with('info', ' Version '.$new_version.' is Available'); return redirect()->route('checkupdate')->with('info', ' Version ' . $new_version . ' is Available');
} else { } else {
// echo "Error Checking Version"; // echo "Error Checking Version";
return redirect()->route('checkupdate')->with('info', ' Error Checking Version'); return redirect()->route('checkupdate')->with('info', ' Error Checking Version');
} }
} }
public function getupdate() public function getupdate() {
{
return \View::make('themes.default1.admin.helpdesk.settings.checkupdate'); return \View::make('themes.default1.admin.helpdesk.settings.checkupdate');
} }
public function Plugins() public function Plugins() {
{
return view('themes.default1.admin.helpdesk.settings.plugins'); return view('themes.default1.admin.helpdesk.settings.plugins');
} }
public function GetPlugin() public function GetPlugin() {
{
$plugins = $this->fetchConfig(); $plugins = $this->fetchConfig();
//dd($plugins);
return \Datatable::collection(new Collection($plugins)) return \Datatable::collection(new Collection($plugins))
->searchColumns('name') ->searchColumns('name')
->addColumn('name', function ($model) { ->addColumn('name', function($model) {
if (array_has($model, 'path')) { if (array_has($model, 'path')) {
if ($model['status'] == 0) { 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 = ' '; $settings = " ";
} else { } else {
$settings = '<a href='.url($model['settings']).'>Settings</a> | '; $settings = "<a href=" . url($model['settings']) . ">Settings</a> | ";
$activate = '<a href='.url('plugin/status/'.$model['path']).'>Deactivate</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>" $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 fade' id=del" . $model['path'] . ">
<div class='modal-dialog'> <div class='modal-dialog'>
<div class=modal-content> <div class=modal-content>
<div class=modal-header> <div class=modal-header>
@@ -484,8 +461,8 @@ class SettingsController extends Controller
<div class=modal-body> <div class=modal-body>
<p>Are you Sure ?</p> <p>Are you Sure ?</p>
<div class=modal-footer> <div class=modal-footer>
<button type=button class='btn btn-default pull-left' data-dismiss=modal id=dismis>".\Lang::get('lang.close').'</button> <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> <a href=" . url('plugin/delete/' . $model['path']) . "><button class='btn btn-danger'>Delete</button></a>
</div> </div>
@@ -493,129 +470,117 @@ class SettingsController extends Controller
</div> </div>
</div> </div>
</div>"; </div>";
$action = '<br><br>'.$delete.' | '.$settings.$activate; $action = "<br><br>" . $delete . " | " . $settings . $activate;
} else { } else {
$action = ''; $action = '';
} }
return ucfirst($model['name']) . $action;
return ucfirst($model['name']).$action;
}) })
->addColumn('description', function ($model) { ->addColumn('description', function($model) {
return ucfirst($model['description']); return ucfirst($model['description']);
}) })
->addColumn('author', function ($model) { ->addColumn('author', function($model) {
return ucfirst($model['author']); return ucfirst($model['author']);
}) })
->addColumn('website', function ($model) { ->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) { ->addColumn('version', function($model) {
return $model['version']; return $model['version'];
}) })
->make(); ->make();
} }
/** /**
* Reading the Filedirectory. * Reading the Filedirectory
*
* @return type * @return type
*/ */
public function ReadPlugins() public function ReadPlugins() {
{ $dir = app_path() .DIRECTORY_SEPARATOR.'Plugins';
$dir = app_path().'/Plugins'; $plugins = array_diff(scandir($dir), array('.', '..'));
$plugins = array_diff(scandir($dir), ['.', '..']);
return $plugins; return $plugins;
} }
/** /**
* After plugin post. * After plugin post
*
* @param Request $request * @param Request $request
*
* @return type * @return type
*/ */
public function PostPlugins(Request $request) public function PostPlugins(Request $request) {
{
$v = $this->validate($request, ['plugin' => 'required|mimes:application/zip,zip,Zip']); $v = $this->validate($request, ['plugin' => 'required|mimes:application/zip,zip,Zip']);
$plug = new Plugin(); $plug = new Plugin();
$file = $request->file('plugin'); $file = $request->file('plugin');
//dd($file); //dd($file);
$destination = app_path().'/Plugins'; $destination = app_path() .DIRECTORY_SEPARATOR.'Plugins';
$zipfile = $file->getRealPath(); $zipfile = $file->getRealPath();
/* /**
* get the file name and remove .zip * get the file name and remove .zip
*/ */
$filename2 = $file->getClientOriginalName(); $filename2 = $file->getClientOriginalName();
$filename2 = str_replace('.zip', '', $filename2); $filename2 = str_replace('.zip', '', $filename2);
$filename1 = ucfirst($file->getClientOriginalName()); $filename1 = ucfirst($file->getClientOriginalName());
$filename = str_replace('.zip', '', $filename1); $filename = str_replace('.zip', '', $filename1);
mkdir($destination.'/'.$filename); mkdir($destination . DIRECTORY_SEPARATOR . $filename);
/* /**
* extract the zip file using zipper * extract the zip file using zipper
*/ */
\Zipper::make($zipfile)->folder($filename2)->extractTo($destination.'/'.$filename); \Zipper::make($zipfile)->folder($filename2)->extractTo($destination .DIRECTORY_SEPARATOR. $filename);
$file = app_path().'/Plugins/'.$filename; // Plugin file path $file = app_path() .DIRECTORY_SEPARATOR.'Plugins'.DIRECTORY_SEPARATOR. $filename; // Plugin file path
if (file_exists($file)) { if (file_exists($file)) {
$seviceporvider = $file.'/ServiceProvider.php';
$config = $file.'/config.php'; $seviceporvider = $file .DIRECTORY_SEPARATOR.'ServiceProvider.php';
$config = $file .DIRECTORY_SEPARATOR.'config.php';
if (file_exists($seviceporvider) && file_exists($config)) { if (file_exists($seviceporvider) && file_exists($config)) {
/* /**
* move to faveo config * move to faveo config
*/ */
$faveoconfig = config_path().'/plugins/'.$filename.'.php'; $faveoconfig = config_path() .DIRECTORY_SEPARATOR.'plugins' .DIRECTORY_SEPARATOR.$filename . '.php';
if ($faveoconfig) { if ($faveoconfig) {
//copy($config, $faveoconfig); //copy($config, $faveoconfig);
/* /**
* write provider list in app.php line 128 * write provider list in app.php line 128
*/ */
$app = base_path().'/config/app.php'; $app = base_path() .DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
$str = "\n\t\t'App\\Plugins\\$filename"."\\ServiceProvider',"; $str = "\n\n\t\t\t'App\\Plugins\\$filename" . "\\ServiceProvider',";
$line_i_am_looking_for = 140; $line_i_am_looking_for = 144;
$lines = file($app, FILE_IGNORE_NEW_LINES); $lines = file($app, FILE_IGNORE_NEW_LINES);
$lines[$line_i_am_looking_for] = $str; $lines[$line_i_am_looking_for] = $str;
file_put_contents($app, implode("\n", $lines)); file_put_contents($app, implode("\n", $lines));
$plug->create(['name' => $filename, 'path' => $filename, 'status' => 1]); $plug->create(['name' => $filename, 'path' => $filename, 'status' => 1]);
return redirect()->back()->with('success', 'Installed SuccessFully'); return redirect()->back()->with('success', 'Installed SuccessFully');
} else { } else {
/* /**
* delete if the plugin hasn't config.php and ServiceProvider.php * delete if the plugin hasn't config.php and ServiceProvider.php
*/ */
$this->deleteDirectory($file); $this->deleteDirectory($file);
return redirect()->back()->with('fails', 'Their is no ' . $file);
return redirect()->back()->with('fails', 'Their is no '.$file);
} }
} else { } else {
/* /**
* delete if the plugin hasn't config.php and ServiceProvider.php * delete if the plugin hasn't config.php and ServiceProvider.php
*/ */
$this->deleteDirectory($file); $this->deleteDirectory($file);
return redirect()->back()->with('fails', 'Their is no <b>config.php or ServiceProvider.php</b> ' . $file);
return redirect()->back()->with('fails', 'Their is no <b>config.php or ServiceProvider.php</b> '.$file);
} }
} else { } else {
/* /**
* delete if the plugin Name is not equal to the folder name * delete if the plugin Name is not equal to the folder name
*/ */
$this->deleteDirectory($file); $this->deleteDirectory($file);
return redirect()->back()->with('fails', '<b>Plugin File Path is not exist</b> ' . $file);
return redirect()->back()->with('fails', '<b>Plugin File Path is not exist</b> '.$file);
} }
} }
/** /**
* Delete the directory. * Delete the directory
*
* @param type $dir * @param type $dir
* * @return boolean
* @return bool
*/ */
public function deleteDirectory($dir) public function deleteDirectory($dir) {
{
if (!file_exists($dir)) { if (!file_exists($dir)) {
return true; return true;
} }
@@ -626,23 +591,34 @@ class SettingsController extends Controller
if ($item == '.' || $item == '..') { if ($item == '.' || $item == '..') {
continue; continue;
} }
if (!$this->deleteDirectory($dir.DIRECTORY_SEPARATOR.$item)) { chmod($dir . DIRECTORY_SEPARATOR . $item,0777);
if (!$this->deleteDirectory($dir . DIRECTORY_SEPARATOR . $item)) {
return false; return false;
} }
} }
chmod($dir, 0777);
return rmdir($dir); return rmdir($dir);
} }
public function ReadConfigs() public function ReadConfigs() {
{ $dir = app_path() .DIRECTORY_SEPARATOR.'Plugins'.DIRECTORY_SEPARATOR;
$dir = app_path().'/Plugins/'; $directories = scandir($dir);
$files = array_diff(scandir($dir), ['.', '..', 'ServiceProvider.php']); $files = [];
$plugins = []; foreach ($directories as $key => $file) {
if ($files) { if ($file === '.' or $file === '..')
continue;
if (is_dir($dir .DIRECTORY_SEPARATOR. $file)) {
$files[$key] = $file;
}
}
//dd($files);
$config=[];
$plugins = array();
if (count($files) > 0) {
foreach ($files as $key => $file) { foreach ($files as $key => $file) {
$plugin = $dir.$file; $plugin = $dir . $file;
$plugins[$key] = array_diff(scandir($plugin), ['.', '..', 'ServiceProvider.php']); $plugins[$key] = array_diff(scandir($plugin), array('.', '..', 'ServiceProvider.php'));
$plugins[$key]['file'] = $plugin; $plugins[$key]['file'] = $plugin;
} }
foreach ($plugins as $plugin) { foreach ($plugins as $plugin) {
@@ -651,89 +627,98 @@ class SettingsController extends Controller
if ($dh = opendir($dir)) { if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) { while (($file = readdir($dh)) !== false) {
if ($file == 'config.php') { if ($file == 'config.php') {
$config[] = $dir.'/'.$file; $config[] = $dir .DIRECTORY_SEPARATOR. $file;
} }
} }
closedir($dh); closedir($dh);
} }
} }
return $config; return $config;
} else { } else {
return 'null'; return 'null';
} }
} }
public function fetchConfig() public function fetchConfig() {
{
$configs = $this->ReadConfigs(); $configs = $this->ReadConfigs();
//dd($configs); //dd($configs);
$plug = new Plugin(); $plug = new Plugin;
$plug = $plug->select('path', 'status')->orderBy('name')->get()->toArray(); $plug = $plug->select('path', 'status')->orderBy('name')->get()->toArray();
//dd($plug[0]['path']); //$fields = [];
if ($configs !== 'null') { if ($configs !== 'null') {
foreach ($configs as $key => $config) { foreach ($configs as $key => $config) {
$fields[$key] = include $config; $fields[$key] = include $config;
if ($plug != null) { if ($plug != null) {
$fields[$key]['path'] = $plug[$key]['path']; $fields[$key]['path'] = $plug[$key]['path'];
$fields[$key]['status'] = $plug[$key]['status']; $fields[$key]['status'] = $plug[$key]['status'];
} else {
$fields[$key]['path'] = $fields[$key]['name'];
$fields[$key]['status'] = 0;
} }
} }
return $fields; return $fields;
} else {
return [];
} }
} }
public function DeletePlugin($slug) public function DeletePlugin($slug) {
{ $dir = app_path() . DIRECTORY_SEPARATOR . 'Plugins' . DIRECTORY_SEPARATOR . $slug;
$dir = app_path().'/Plugins/'.$slug;
$this->deleteDirectory($dir); $this->deleteDirectory($dir);
/* /**
* remove service provider from app.php * remove service provider from app.php
*/ */
$str = "'App\\Plugins\\$slug"."\\ServiceProvider',"; $str = "'App\\Plugins\\$slug" . "\\ServiceProvider',";
$path_to_file = base_path().'/config/app.php'; $path_to_file = base_path() .DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
$file_contents = file_get_contents($path_to_file); $file_contents = file_get_contents($path_to_file);
$file_contents = str_replace($str, '', $file_contents); $file_contents = str_replace($str, "//", $file_contents);
file_put_contents($path_to_file, $file_contents); file_put_contents($path_to_file, $file_contents);
$plugin = new Plugin(); $plugin = new Plugin();
$plugin = $plugin->where('path', $slug)->first(); $plugin = $plugin->where('path', $slug)->first();
$plugin->delete(); if ($plugin) {
$plugin->delete();
}
return redirect()->back()->with('success', 'Deleted Successfully'); return redirect()->back()->with('success', 'Deleted Successfully');
} }
public function StatusPlugin($slug) public function StatusPlugin($slug) {
{ $plugs = new Plugin;
$plug = new Plugin(); $plug = $plugs->where('name', $slug)->first();
$plug = $plug->where('name', $slug)->first(); if (!$plug) {
$app = base_path() .DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
$str = "'App\\Plugins\\$slug" . "\\ServiceProvider',";
$line_i_am_looking_for = 144;
$lines = file($app, FILE_IGNORE_NEW_LINES);
$lines[$line_i_am_looking_for] = $str;
file_put_contents($app, implode("\n", $lines));
$plugs->create(['name' => $slug, 'path' => $slug, 'status' => 1]);
return redirect()->back()->with('success', 'Status has changed');
}
$status = $plug->status; $status = $plug->status;
if ($status == 0) { if ($status == 0) {
$plug->status = 1; $plug->status = 1;
$app = base_path().'/config/app.php'; $app = base_path() .DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
$str = "\n\t\t'App\\Plugins\\$slug"."\\ServiceProvider',"; $str = "'App\\Plugins\\$slug" . "\\ServiceProvider',";
$line_i_am_looking_for = 140; $line_i_am_looking_for = 144;
$lines = file($app, FILE_IGNORE_NEW_LINES); $lines = file($app, FILE_IGNORE_NEW_LINES);
$lines[$line_i_am_looking_for] = $str; $lines[$line_i_am_looking_for] = $str;
file_put_contents($app, implode("\n", $lines)); file_put_contents($app, implode("\n", $lines));
} }
if ($status == 1) { if ($status == 1) {
$plug->status = 0; $plug->status = 0;
/* /**
* remove service provider from app.php * remove service provider from app.php
*/ */
$str = "'App\\Plugins\\$slug"."\\ServiceProvider',"; $str = "'App\\Plugins\\$slug" . "\\ServiceProvider',";
$path_to_file = base_path().'/config/app.php'; $path_to_file = base_path() .DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
$file_contents = file_get_contents($path_to_file); $file_contents = file_get_contents($path_to_file);
$file_contents = str_replace($str, '', $file_contents); $file_contents = str_replace($str, "//", $file_contents);
file_put_contents($path_to_file, $file_contents); file_put_contents($path_to_file, $file_contents);
} }
$plug->save(); $plug->save();
return redirect()->back()->with('success', 'Status has changed'); return redirect()->back()->with('success', 'Status has changed');
} }
} }

View File

@@ -38,7 +38,7 @@ return [
| |
*/ */
'version' => 'Community 1.0.7.1', 'version' => 'Community 1.0.7.2',
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------