update v1.0.7.9 R.C.
This is a Release Candidate. We are still testing.
This commit is contained in:
49
app/Http/Controllers/Common/FileuploadController.php
Normal file
49
app/Http/Controllers/Common/FileuploadController.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Common;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class FileuploadController extends Controller {
|
||||
|
||||
public function __construct() {
|
||||
// checking authentication
|
||||
$this->middleware('auth');
|
||||
// checking if role is agent
|
||||
$this->middleware('role.agent');
|
||||
}
|
||||
|
||||
// Returns a file size limit in bytes based on the PHP upload_max_filesize
|
||||
// and post_max_size
|
||||
function file_upload_max_size() {
|
||||
static $max_size = -1;
|
||||
|
||||
if ($max_size < 0) {
|
||||
// Start with post_max_size.
|
||||
$max_size_in_bytes = $this->parse_size(ini_get('post_max_size'));
|
||||
$max_size_in_actual = ini_get('post_max_size');
|
||||
|
||||
// If upload_max_size is less, then reduce. Except if upload_max_size is
|
||||
// zero, which indicates no limit.
|
||||
$upload_max = $this->parse_size(ini_get('upload_max_filesize'));
|
||||
if ($upload_max > 0 && $upload_max < $max_size) {
|
||||
$max_size_in_bytes = $upload_max;
|
||||
$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;
|
||||
}
|
||||
|
||||
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) {
|
||||
// Find the position of the unit in the ordered string which is the power of magnitude to multiply a kilobyte by.
|
||||
return round($size * pow(1024, stripos('bkmgtpezy', $unit[0])));
|
||||
} else {
|
||||
return round($size);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -5,84 +5,110 @@ namespace App\Http\Controllers\Common;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Model\helpdesk\Notification\Notification;
|
||||
use App\Model\helpdesk\Notification\UserNotification;
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
use App\User;
|
||||
use App\Http\Controllers\Api\v1\PushNotificationController;
|
||||
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
|
||||
* 1. Ticket Creation
|
||||
* 2. Ticket Reply
|
||||
* 3. User Creation
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
|
||||
public $user;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct(PushNotificationController $PushNotificationController) {
|
||||
$this->PushNotificationController = $PushNotificationController;
|
||||
$user = new User();
|
||||
$this->user = $user;
|
||||
// checking authentication
|
||||
$this->middleware('auth');
|
||||
// checking if role is agent
|
||||
$this->middleware('role.agent');
|
||||
}
|
||||
|
||||
/**
|
||||
* get the page to list the notifications.
|
||||
*
|
||||
* @return response
|
||||
* This function is used to create in app notifications.
|
||||
* @param type $model_id
|
||||
* @param type $userid_created
|
||||
* @param type $type_id
|
||||
* @param type $forwhome
|
||||
*/
|
||||
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)
|
||||
->paginate(10);
|
||||
|
||||
return $notifications;
|
||||
}
|
||||
|
||||
public function create($model_id, $userid_created, $type_id, $forwhome = [])
|
||||
{
|
||||
public function create($model_id, $userid_created, $type_id, $forwhome = []) {
|
||||
try {
|
||||
if (empty($forwhome)) {
|
||||
$forwhome = $this->user->where('role', '!=', 'user')->get()->toArray();
|
||||
$ticket = Tickets::where('id', '=', $model_id)->first();
|
||||
$forwhome = $this->user->where('role', '=', 'agent')->where('primary_dpt', '=', $ticket->dept_id)->get();
|
||||
$forwhome2 = $this->user->where('role', '=', 'admin')->get();
|
||||
$forwhome = $forwhome->merge($forwhome2);
|
||||
}
|
||||
//dd($forwhome);
|
||||
//system notification
|
||||
$notification = new Notification();
|
||||
$UN = new UserNotification();
|
||||
|
||||
$notify = $notification->create(['model_id' => $model_id, 'userid_created' => $userid_created, 'type_id' => $type_id]);
|
||||
// system notification
|
||||
$notify = Notification::create(['model_id' => $model_id, 'userid_created' => $userid_created, 'type_id' => $type_id]);
|
||||
foreach ($forwhome as $agent) {
|
||||
$user_notify = $UN->create(['notification_id' => $notify->id, 'user_id' => $agent['id'], 'is_read' => 0]);
|
||||
$type_message = NotificationType::where('id', '=', $type_id)->first();
|
||||
UserNotification::create(['notification_id' => $notify->id, 'user_id' => $agent['id'], 'is_read' => 0]);
|
||||
// $this->PushNotificationController->response($agent->fcm_token, $type_message->message . $model_id, $model_id);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('fails', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function markAllRead($id)
|
||||
{
|
||||
/**
|
||||
* This function is to mark all ticket to read status
|
||||
* @param type $id
|
||||
* @return int
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
public function markRead($id)
|
||||
{
|
||||
/**
|
||||
* This function to mark read
|
||||
* @param type $id
|
||||
* @return int
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
public function show()
|
||||
{
|
||||
/**
|
||||
* function to show all the notifications
|
||||
* @return type
|
||||
*/
|
||||
public function show() {
|
||||
$notifications = $this->getNotifications();
|
||||
|
||||
return view('notifications-all', compact('notifications'));
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
/**
|
||||
* function to delete notifications
|
||||
* @param type $id
|
||||
* @return int
|
||||
*/
|
||||
public function delete($id) {
|
||||
$markasread = UserNotification::where('notification_id', '=', $id)->where('user_id', '=', \Auth::user()->id)->get();
|
||||
foreach ($markasread as $mark) {
|
||||
$mark->delete();
|
||||
@@ -90,4 +116,17 @@ class NotificationController extends Controller
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
->paginate(10);
|
||||
return $notifications;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -8,15 +8,14 @@ use App\Model\helpdesk\Agent\Department;
|
||||
use App\Model\helpdesk\Email\Emails;
|
||||
use App\Model\helpdesk\Settings\Company;
|
||||
use App\Model\helpdesk\Settings\Email;
|
||||
use App\Model\helpdesk\Settings\CommonSettings;
|
||||
use App\User;
|
||||
use Auth;
|
||||
|
||||
class PhpMailController extends Controller
|
||||
{
|
||||
public function fetch_smtp_details($id)
|
||||
{
|
||||
$emails = Emails::where('id', '=', $id)->first();
|
||||
class PhpMailController extends Controller {
|
||||
|
||||
public function fetch_smtp_details($id) {
|
||||
$emails = Emails::where('id', '=', $id)->first();
|
||||
return $emails;
|
||||
}
|
||||
|
||||
@@ -25,269 +24,266 @@ class PhpMailController extends Controller
|
||||
*
|
||||
* @return Mail
|
||||
*/
|
||||
public function sendmail($from, $to, $message, $template_variables)
|
||||
{
|
||||
// dd($from);
|
||||
$from_address = $this->fetch_smtp_details($from);
|
||||
if ($from_address == null) {
|
||||
return $from_address;
|
||||
} else {
|
||||
// dd($from_address);
|
||||
$username = $from_address->email_address;
|
||||
$fromname = $from_address->email_name;
|
||||
$password = \Crypt::decrypt($from_address->password);
|
||||
$smtpsecure = $from_address->sending_encryption;
|
||||
$host = $from_address->sending_host;
|
||||
$port = $from_address->sending_port;
|
||||
$protocol = $from_address->sending_protocol;
|
||||
public function sendmail($from, $to, $message, $template_variables) {
|
||||
// try {
|
||||
// dd($from);
|
||||
$from_address = $this->fetch_smtp_details($from);
|
||||
if ($from_address == null) {
|
||||
return $from_address;
|
||||
} else {
|
||||
// dd($from_address);
|
||||
$username = $from_address->email_address;
|
||||
$fromname = $from_address->email_name;
|
||||
$password = \Crypt::decrypt($from_address->password);
|
||||
$smtpsecure = $from_address->sending_encryption;
|
||||
$host = $from_address->sending_host;
|
||||
$port = $from_address->sending_port;
|
||||
$protocol = $from_address->sending_protocol;
|
||||
|
||||
if (isset($to['email'])) {
|
||||
$recipants = $to['email'];
|
||||
} else {
|
||||
$recipants = null;
|
||||
}
|
||||
if (isset($to['name'])) {
|
||||
$recipantname = $to['name'];
|
||||
} else {
|
||||
$recipantname = null;
|
||||
}
|
||||
if (isset($to['cc'])) {
|
||||
$cc = $to['cc'];
|
||||
} else {
|
||||
$cc = null;
|
||||
}
|
||||
if (isset($to['bc'])) {
|
||||
$bc = $to['bc'];
|
||||
} else {
|
||||
$bc = null;
|
||||
}
|
||||
// if (isset($message['subject'])) {
|
||||
// $subject = $message['subject'];
|
||||
// } else {
|
||||
// $subject = null;
|
||||
// }
|
||||
if (isset($message['body'])) {
|
||||
$content = $message['body'];
|
||||
} else {
|
||||
$content = null;
|
||||
}
|
||||
if (isset($message['scenario'])) {
|
||||
$template = $message['scenario'];
|
||||
} else {
|
||||
$template = null;
|
||||
}
|
||||
if (isset($message['attachments'])) {
|
||||
$attachment = $message['attachments'];
|
||||
} else {
|
||||
$attachment = null;
|
||||
}
|
||||
if (isset($to['email'])) {
|
||||
$recipants = $to['email'];
|
||||
} else {
|
||||
$recipants = null;
|
||||
}
|
||||
if (isset($to['name'])) {
|
||||
$recipantname = $to['name'];
|
||||
} else {
|
||||
$recipantname = null;
|
||||
}
|
||||
if (isset($to['cc'])) {
|
||||
$cc = $to['cc'];
|
||||
} else {
|
||||
$cc = null;
|
||||
}
|
||||
if (isset($to['bc'])) {
|
||||
$bc = $to['bc'];
|
||||
} else {
|
||||
$bc = null;
|
||||
}
|
||||
// if (isset($message['subject'])) {
|
||||
// $subject = $message['subject'];
|
||||
// } else {
|
||||
// $subject = null;
|
||||
// }
|
||||
if (isset($message['body'])) {
|
||||
$content = $message['body'];
|
||||
} else {
|
||||
$content = null;
|
||||
}
|
||||
if (isset($message['scenario'])) {
|
||||
$template = $message['scenario'];
|
||||
} else {
|
||||
$template = null;
|
||||
}
|
||||
if (isset($message['attachments'])) {
|
||||
$attachment = $message['attachments'];
|
||||
} else {
|
||||
$attachment = null;
|
||||
}
|
||||
|
||||
// template variables
|
||||
if (Auth::user()) {
|
||||
$agent = Auth::user()->user_name;
|
||||
} else {
|
||||
$agent = null;
|
||||
}
|
||||
if (isset($template_variables['ticket_agent_name'])) {
|
||||
$ticket_agent_name = $template_variables['ticket_agent_name'];
|
||||
} else {
|
||||
$ticket_agent_name = null;
|
||||
}
|
||||
if (isset($template_variables['ticket_number'])) {
|
||||
$ticket_number = $template_variables['ticket_number'];
|
||||
} else {
|
||||
$ticket_number = null;
|
||||
}
|
||||
if (isset($template_variables['ticket_client_name'])) {
|
||||
$ticket_client_name = $template_variables['ticket_client_name'];
|
||||
} else {
|
||||
$ticket_client_name = null;
|
||||
}
|
||||
if (isset($template_variables['ticket_client_email'])) {
|
||||
$ticket_client_email = $template_variables['ticket_client_email'];
|
||||
} else {
|
||||
$ticket_client_email = null;
|
||||
}
|
||||
if (isset($template_variables['ticket_body'])) {
|
||||
$ticket_body = $template_variables['ticket_body'];
|
||||
} else {
|
||||
$ticket_body = null;
|
||||
}
|
||||
if (isset($template_variables['ticket_assigner'])) {
|
||||
$ticket_assigner = $template_variables['ticket_assigner'];
|
||||
} else {
|
||||
$ticket_assigner = null;
|
||||
}
|
||||
if (isset($template_variables['ticket_link_with_number'])) {
|
||||
$ticket_link_with_number = $template_variables['ticket_link_with_number'];
|
||||
} else {
|
||||
$ticket_link_with_number = null;
|
||||
}
|
||||
// if (isset($template_variables['system_from'])) {
|
||||
// $system_from = $template_variables['system_from'];
|
||||
// } else {
|
||||
// $system_from = null;
|
||||
// }
|
||||
if (isset($template_variables['system_link'])) {
|
||||
$system_link = $template_variables['system_link'];
|
||||
} else {
|
||||
$system_link = null;
|
||||
}
|
||||
if (isset($template_variables['system_error'])) {
|
||||
$system_error = $template_variables['system_error'];
|
||||
} else {
|
||||
$system_error = null;
|
||||
}
|
||||
if (isset($template_variables['agent_sign'])) {
|
||||
$agent_sign = $template_variables['agent_sign'];
|
||||
} else {
|
||||
$agent_sign = null;
|
||||
}
|
||||
if (isset($template_variables['department_sign'])) {
|
||||
$department_sign = $template_variables['department_sign'];
|
||||
} else {
|
||||
$department_sign = null;
|
||||
}
|
||||
if (isset($template_variables['password_reset_link'])) {
|
||||
$password_reset_link = $template_variables['password_reset_link'];
|
||||
} else {
|
||||
$password_reset_link = null;
|
||||
}
|
||||
if (isset($template_variables['user_password'])) {
|
||||
$user_password = $template_variables['user_password'];
|
||||
} else {
|
||||
$user_password = null;
|
||||
}
|
||||
if (isset($template_variables['email_address'])) {
|
||||
$email_address = $template_variables['email_address'];
|
||||
} else {
|
||||
$email_address = null;
|
||||
}
|
||||
if (isset($template_variables['user'])) {
|
||||
$user = $template_variables['user'];
|
||||
} else {
|
||||
$user = null;
|
||||
}
|
||||
// template variables
|
||||
if (Auth::user()) {
|
||||
$agent = Auth::user()->user_name;
|
||||
} else {
|
||||
$agent = null;
|
||||
}
|
||||
if (isset($template_variables['ticket_agent_name'])) {
|
||||
$ticket_agent_name = $template_variables['ticket_agent_name'];
|
||||
} else {
|
||||
$ticket_agent_name = null;
|
||||
}
|
||||
if (isset($template_variables['ticket_number'])) {
|
||||
$ticket_number = $template_variables['ticket_number'];
|
||||
} else {
|
||||
$ticket_number = null;
|
||||
}
|
||||
if (isset($template_variables['ticket_client_name'])) {
|
||||
$ticket_client_name = $template_variables['ticket_client_name'];
|
||||
} else {
|
||||
$ticket_client_name = null;
|
||||
}
|
||||
if (isset($template_variables['ticket_client_email'])) {
|
||||
$ticket_client_email = $template_variables['ticket_client_email'];
|
||||
} else {
|
||||
$ticket_client_email = null;
|
||||
}
|
||||
if (isset($template_variables['ticket_body'])) {
|
||||
$ticket_body = $template_variables['ticket_body'];
|
||||
} else {
|
||||
$ticket_body = null;
|
||||
}
|
||||
if (isset($template_variables['ticket_assigner'])) {
|
||||
$ticket_assigner = $template_variables['ticket_assigner'];
|
||||
} else {
|
||||
$ticket_assigner = null;
|
||||
}
|
||||
if (isset($template_variables['ticket_link_with_number'])) {
|
||||
$ticket_link_with_number = $template_variables['ticket_link_with_number'];
|
||||
} else {
|
||||
$ticket_link_with_number = null;
|
||||
}
|
||||
if (isset($template_variables['system_from'])) {
|
||||
$system_from = $template_variables['system_from'];
|
||||
} else {
|
||||
$system_from = $this->company();
|
||||
}
|
||||
if (isset($template_variables['system_link'])) {
|
||||
$system_link = $template_variables['system_link'];
|
||||
} else {
|
||||
$system_link = url('/');
|
||||
}
|
||||
if (isset($template_variables['system_error'])) {
|
||||
$system_error = $template_variables['system_error'];
|
||||
} else {
|
||||
$system_error = null;
|
||||
}
|
||||
if (isset($template_variables['agent_sign'])) {
|
||||
$agent_sign = $template_variables['agent_sign'];
|
||||
} else {
|
||||
$agent_sign = null;
|
||||
}
|
||||
if (isset($template_variables['department_sign'])) {
|
||||
$department_sign = $template_variables['department_sign'];
|
||||
} else {
|
||||
$department_sign = null;
|
||||
}
|
||||
if (isset($template_variables['password_reset_link'])) {
|
||||
$password_reset_link = $template_variables['password_reset_link'];
|
||||
} else {
|
||||
$password_reset_link = null;
|
||||
}
|
||||
if (isset($template_variables['user_password'])) {
|
||||
$user_password = $template_variables['user_password'];
|
||||
} else {
|
||||
$user_password = null;
|
||||
}
|
||||
if (isset($template_variables['email_address'])) {
|
||||
$email_address = $template_variables['email_address'];
|
||||
} else {
|
||||
$email_address = null;
|
||||
}
|
||||
if (isset($template_variables['user'])) {
|
||||
$user = $template_variables['user'];
|
||||
} else {
|
||||
$user = null;
|
||||
}
|
||||
|
||||
$system_link = url('/');
|
||||
// $system_link = url('/');
|
||||
|
||||
$system_from = $this->company();
|
||||
// $system_from = $this->company();
|
||||
|
||||
$mail = new \PHPMailer();
|
||||
$mail = new \PHPMailer();
|
||||
|
||||
$status = \DB::table('settings_email')->first();
|
||||
$status = \DB::table('settings_email')->first();
|
||||
|
||||
$path2 = \Config::get('view.paths');
|
||||
$path2 = \Config::get('view.paths');
|
||||
|
||||
// $directory = $path2[0].DIRECTORY_SEPARATOR.'emails'.DIRECTORY_SEPARATOR.$status->template.DIRECTORY_SEPARATOR;
|
||||
//
|
||||
// $handle = fopen($directory.$template.'.blade.php', 'r');
|
||||
// $contents = fread($handle, filesize($directory.$template.'.blade.php'));
|
||||
// fclose($handle);
|
||||
// $directory = $path2[0].DIRECTORY_SEPARATOR.'emails'.DIRECTORY_SEPARATOR.$status->template.DIRECTORY_SEPARATOR;
|
||||
//
|
||||
// $handle = fopen($directory.$template.'.blade.php', 'r');
|
||||
// $contents = fread($handle, filesize($directory.$template.'.blade.php'));
|
||||
// fclose($handle);
|
||||
|
||||
$template = TemplateType::where('name', '=', $template)->first();
|
||||
$template = TemplateType::where('name', '=', $template)->first();
|
||||
|
||||
$set = \App\Model\Common\TemplateSet::where('name', '=', $status->template)->first();
|
||||
$set = \App\Model\Common\TemplateSet::where('name', '=', $status->template)->first();
|
||||
|
||||
if (isset($set['id'])) {
|
||||
$template_data = \App\Model\Common\Template::where('set_id', '=', $set->id)->where('type', '=', $template->id)->first();
|
||||
$contents = $template_data->message;
|
||||
if ($template_data->variable == 1) {
|
||||
if ($template_data->subject) {
|
||||
$subject = $template_data->subject;
|
||||
if ($ticket_number != null) {
|
||||
$subject = $subject.' [#'.$ticket_number.']';
|
||||
if (isset($set['id'])) {
|
||||
$template_data = \App\Model\Common\Template::where('set_id', '=', $set->id)->where('type', '=', $template->id)->first();
|
||||
$contents = $template_data->message;
|
||||
if ($template_data->variable == 1) {
|
||||
if ($template_data->subject) {
|
||||
$subject = $template_data->subject;
|
||||
if ($ticket_number != null) {
|
||||
$subject = $subject . ' [#' . $ticket_number . ']';
|
||||
}
|
||||
} else {
|
||||
$subject = $message['subject'];
|
||||
}
|
||||
} else {
|
||||
$subject = $message['subject'];
|
||||
}
|
||||
} else {
|
||||
$subject = $message['subject'];
|
||||
$contents = null;
|
||||
$subject = null;
|
||||
}
|
||||
} else {
|
||||
$contents = null;
|
||||
$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!!}'];
|
||||
$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!!}'];
|
||||
|
||||
$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];
|
||||
$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];
|
||||
|
||||
// dd($variables,$data,$contents);
|
||||
// $messagebody = str_replace($variables, $data, $contents);
|
||||
// dd($variables,$data,$contents);
|
||||
// $messagebody = str_replace($variables, $data, $contents);
|
||||
|
||||
foreach ($variables as $key => $variable) {
|
||||
$messagebody = str_replace($variables[$key], $data[$key], $contents);
|
||||
// dd($messagebody);
|
||||
|
||||
$contents = $messagebody;
|
||||
}
|
||||
|
||||
foreach ($variables as $key => $variable) {
|
||||
$messagebody = str_replace($variables[$key], $data[$key], $contents);
|
||||
// dd($messagebody);
|
||||
|
||||
$contents = $messagebody;
|
||||
}
|
||||
|
||||
// dd($messagebody);
|
||||
//$mail->SMTPDebug = 3; // Enable verbose debug output
|
||||
if ($protocol == 'smtp') {
|
||||
$mail->isSMTP(); // Set mailer to use SMTP
|
||||
$mail->Host = $host; // Specify main and backup SMTP servers
|
||||
$mail->SMTPAuth = true; // Enable SMTP authentication
|
||||
$mail->Username = $username; // SMTP username
|
||||
$mail->Password = $password; // SMTP password
|
||||
$mail->SMTPSecure = $smtpsecure; // Enable TLS encryption, `ssl` also accepted
|
||||
$mail->Port = $port; // TCP port to connect to
|
||||
$mail->setFrom($username, $fromname);
|
||||
} elseif ($protocol == 'mail') {
|
||||
$mail->IsSendmail(); // telling the class to use SendMail transport
|
||||
if ($username == $fromname) {
|
||||
$mail->setFrom($username);
|
||||
} else {
|
||||
//$mail->SMTPDebug = 3; // Enable verbose debug output
|
||||
if ($protocol == 'smtp') {
|
||||
$mail->isSMTP(); // Set mailer to use SMTP
|
||||
$mail->Host = $host; // Specify main and backup SMTP servers
|
||||
$mail->SMTPAuth = true; // Enable SMTP authentication
|
||||
$mail->Username = $username; // SMTP username
|
||||
$mail->Password = $password; // SMTP password
|
||||
$mail->SMTPSecure = $smtpsecure; // Enable TLS encryption, `ssl` also accepted
|
||||
$mail->Port = $port; // TCP port to connect to
|
||||
$mail->setFrom($username, $fromname);
|
||||
} elseif ($protocol == 'mail') {
|
||||
$mail->IsSendmail(); // telling the class to use SendMail transport
|
||||
if ($username == $fromname) {
|
||||
$mail->setFrom($username);
|
||||
} else {
|
||||
$mail->setFrom($username, $fromname);
|
||||
}
|
||||
}
|
||||
$mail->addAddress($recipants); // Add a recipient
|
||||
$mail->isHTML(true); // Set email format to HTML
|
||||
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;
|
||||
$mail->addCC($collab_email);
|
||||
}
|
||||
}
|
||||
|
||||
if ($attachment != null) {
|
||||
$size = count($message['attachments']);
|
||||
$attach = $message['attachments'];
|
||||
for ($i = 0; $i < $size; $i++) {
|
||||
$file_path = $attach[$i]->getRealPath();
|
||||
$file_name = $attach[$i]->getClientOriginalName();
|
||||
$mail->addAttachment($file_path, $file_name);
|
||||
}
|
||||
}
|
||||
$mail->CharSet = "utf8";
|
||||
$mail->Subject = $subject;
|
||||
if ($template == 'ticket-reply-agent') {
|
||||
$line = '---Reply above this line--- <br/><br/>';
|
||||
$body = $line . $messagebody;
|
||||
} else {
|
||||
$body = $messagebody;
|
||||
}
|
||||
$rtl = CommonSettings::where('option_name', '=', 'enable_rtl')->first();
|
||||
if($rtl->option_value == 1) {
|
||||
$mail->ContentType = 'text/html';
|
||||
$body = '<html dir="rtl" xml:lang="ar" lang="ar"><head></head><body dir="rtl">' . $body . '</body></html>';
|
||||
} else {
|
||||
}
|
||||
$mail->Body = nl2br($body);
|
||||
|
||||
if (!$mail->send()) {
|
||||
return;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
$mail->addAddress($recipants); // Add a recipient
|
||||
// Name is optional
|
||||
// $mail->addReplyTo('sada059@gmail.com', 'Information');
|
||||
// Optional name
|
||||
$mail->isHTML(true); // Set email format to HTML
|
||||
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;
|
||||
$mail->addCC($collab_email);
|
||||
}
|
||||
}
|
||||
|
||||
// $mail->addBCC($bc);
|
||||
|
||||
if ($attachment != null) {
|
||||
$size = count($message['attachments']);
|
||||
$attach = $message['attachments'];
|
||||
for ($i = 0; $i < $size; $i++) {
|
||||
$file_path = $attach[$i]->getRealPath();
|
||||
$file_name = $attach[$i]->getClientOriginalName();
|
||||
$mail->addAttachment($file_path, $file_name);
|
||||
}
|
||||
}
|
||||
|
||||
$mail->Subject = utf8_decode($subject);
|
||||
if ($template == 'ticket-reply-agent') {
|
||||
$line = '---Reply above this line--- <br/><br/>';
|
||||
$mail->Body = utf8_decode($line.$messagebody);
|
||||
} else {
|
||||
$mail->Body = utf8_decode($messagebody);
|
||||
}
|
||||
|
||||
// $mail->AltBody = $altbody;
|
||||
|
||||
if (!$mail->send()) {
|
||||
return;
|
||||
// echo 'Message could not be sent.';
|
||||
// echo 'Mailer Error: '.$mail->ErrorInfo;
|
||||
} else {
|
||||
return 1;
|
||||
// echo 'Message has been sent';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -295,123 +291,129 @@ class PhpMailController extends Controller
|
||||
*
|
||||
* @return MailNotification
|
||||
*/
|
||||
public function sendEmail($from, $to, $message)
|
||||
{
|
||||
$from_address = $this->fetch_smtp_details($from);
|
||||
public function sendEmail($from, $to, $message) {
|
||||
try {
|
||||
$from_address = $this->fetch_smtp_details($from);
|
||||
if ($from_address == null) {
|
||||
return $from_address;
|
||||
} else {
|
||||
$username = $from_address->email_address;
|
||||
$fromname = $from_address->email_name;
|
||||
$password = \Crypt::decrypt($from_address->password);
|
||||
$smtpsecure = $from_address->sending_encryption;
|
||||
$host = $from_address->sending_host;
|
||||
$port = $from_address->sending_port;
|
||||
$protocol = $from_address->sending_protocol;
|
||||
|
||||
$username = $from_address->email_address;
|
||||
$fromname = $from_address->email_name;
|
||||
$password = \Crypt::decrypt($from_address->password);
|
||||
$smtpsecure = $from_address->sending_encryption;
|
||||
$host = $from_address->sending_host;
|
||||
$port = $from_address->sending_port;
|
||||
if (isset($to['email'])) {
|
||||
$recipants = $to['email'];
|
||||
} else {
|
||||
$recipants = null;
|
||||
}
|
||||
if (isset($to['name'])) {
|
||||
$recipantname = $to['name'];
|
||||
} else {
|
||||
$recipantname = null;
|
||||
}
|
||||
if (isset($to['cc'])) {
|
||||
$cc = $to['cc'];
|
||||
} else {
|
||||
$cc = null;
|
||||
}
|
||||
if (isset($to['bc'])) {
|
||||
$bc = $to['bc'];
|
||||
} else {
|
||||
$bc = null;
|
||||
}
|
||||
if (isset($message['subject'])) {
|
||||
$subject = $message['subject'];
|
||||
} else {
|
||||
$subject = null;
|
||||
}
|
||||
if (isset($message['body'])) {
|
||||
$content = $message['body'];
|
||||
} else {
|
||||
$content = null;
|
||||
}
|
||||
if (isset($message['scenario'])) {
|
||||
$template = $message['scenario'];
|
||||
} else {
|
||||
$template = null;
|
||||
}
|
||||
if (isset($message['attachments'])) {
|
||||
$attachment = $message['attachments'];
|
||||
} else {
|
||||
$attachment = null;
|
||||
}
|
||||
|
||||
if (isset($to['email'])) {
|
||||
$recipants = $to['email'];
|
||||
} else {
|
||||
$recipants = null;
|
||||
}
|
||||
if (isset($to['name'])) {
|
||||
$recipantname = $to['name'];
|
||||
} else {
|
||||
$recipantname = null;
|
||||
}
|
||||
if (isset($to['cc'])) {
|
||||
$cc = $to['cc'];
|
||||
} else {
|
||||
$cc = null;
|
||||
}
|
||||
if (isset($to['bc'])) {
|
||||
$bc = $to['bc'];
|
||||
} else {
|
||||
$bc = null;
|
||||
}
|
||||
if (isset($message['subject'])) {
|
||||
$subject = $message['subject'];
|
||||
} else {
|
||||
$subject = null;
|
||||
}
|
||||
if (isset($message['body'])) {
|
||||
$content = $message['body'];
|
||||
} else {
|
||||
$content = null;
|
||||
}
|
||||
if (isset($message['scenario'])) {
|
||||
$template = $message['scenario'];
|
||||
} else {
|
||||
$template = null;
|
||||
}
|
||||
if (isset($message['attachments'])) {
|
||||
$attachment = $message['attachments'];
|
||||
} else {
|
||||
$attachment = null;
|
||||
}
|
||||
// template variables
|
||||
if (Auth::user()) {
|
||||
$agent = Auth::user()->user_name;
|
||||
} else {
|
||||
$agent = null;
|
||||
}
|
||||
|
||||
// template variables
|
||||
if (Auth::user()) {
|
||||
$agent = Auth::user()->user_name;
|
||||
} else {
|
||||
$agent = null;
|
||||
}
|
||||
$system_link = url('/');
|
||||
|
||||
$system_link = url('/');
|
||||
$system_from = $this->company();
|
||||
|
||||
$system_from = $this->company();
|
||||
$mail = new \PHPMailer();
|
||||
|
||||
$mail = new \PHPMailer();
|
||||
$status = \DB::table('settings_email')->first();
|
||||
|
||||
$status = \DB::table('settings_email')->first();
|
||||
|
||||
// dd($messagebody);
|
||||
//$mail->SMTPDebug = 3; // Enable verbose debug output
|
||||
|
||||
$mail->isSMTP(); // Set mailer to use SMTP
|
||||
$mail->Host = $host; // Specify main and backup SMTP servers
|
||||
$mail->SMTPAuth = true; // Enable SMTP authentication
|
||||
$mail->Username = $username; // SMTP username
|
||||
$mail->Password = $password; // SMTP password
|
||||
$mail->SMTPSecure = $smtpsecure; // Enable TLS encryption, `ssl` also accepted
|
||||
$mail->Port = $port; // TCP port to connect to
|
||||
|
||||
$mail->setFrom($username, $fromname);
|
||||
$mail->addAddress($recipants); // Add a recipient
|
||||
// Name is optional
|
||||
// $mail->addReplyTo('sada059@gmail.com', 'Information');
|
||||
// Optional name
|
||||
$mail->isHTML(true); // Set email format to HTML
|
||||
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;
|
||||
$mail->addCC($collab_email);
|
||||
// dd($messagebody);
|
||||
//$mail->SMTPDebug = 3; // Enable verbose debug output
|
||||
if ($protocol == 'smtp') {
|
||||
$mail->isSMTP(); // Set mailer to use SMTP
|
||||
$mail->Host = $host; // Specify main and backup SMTP servers
|
||||
$mail->SMTPAuth = true; // Enable SMTP authentication
|
||||
$mail->Username = $username; // SMTP username
|
||||
$mail->Password = $password; // SMTP password
|
||||
$mail->SMTPSecure = $smtpsecure; // Enable TLS encryption, `ssl` also accepted
|
||||
$mail->Port = $port; // TCP port to connect to
|
||||
$mail->setFrom($username, $fromname);
|
||||
} elseif ($protocol == 'mail') {
|
||||
$mail->IsSendmail(); // telling the class to use SendMail transport
|
||||
if ($username == $fromname) {
|
||||
$mail->setFrom($username);
|
||||
} else {
|
||||
$mail->setFrom($username, $fromname);
|
||||
}
|
||||
}
|
||||
$mail->addAddress($recipants); // Add a recipient
|
||||
// Name is optional
|
||||
// $mail->addReplyTo('sada059@gmail.com', 'Information');
|
||||
// Optional name
|
||||
$mail->isHTML(true); // Set email format to HTML
|
||||
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;
|
||||
$mail->addCC($collab_email);
|
||||
}
|
||||
}
|
||||
if ($attachment != null) {
|
||||
$size = count($message['attachments']);
|
||||
$attach = $message['attachments'];
|
||||
for ($i = 0; $i < $size; $i++) {
|
||||
$file_path = $attach[$i]->getRealPath();
|
||||
$file_name = $attach[$i]->getClientOriginalName();
|
||||
$mail->addAttachment($file_path, $file_name);
|
||||
}
|
||||
}
|
||||
$mail->CharSet = "utf8";
|
||||
$mail->Subject = $subject;
|
||||
$mail->Body = $content;
|
||||
if (!$mail->send()) {
|
||||
} else {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$mail->addBCC($bc);
|
||||
|
||||
if ($attachment != null) {
|
||||
$size = count($message['attachments']);
|
||||
$attach = $message['attachments'];
|
||||
for ($i = 0; $i < $size; $i++) {
|
||||
$file_path = $attach[$i]->getRealPath();
|
||||
$file_name = $attach[$i]->getClientOriginalName();
|
||||
$mail->addAttachment($file_path, $file_name);
|
||||
}
|
||||
}
|
||||
|
||||
$mail->Subject = utf8_decode($subject);
|
||||
|
||||
$mail->Body = utf8_decode($content);
|
||||
|
||||
// $mail->AltBody = $altbody;
|
||||
|
||||
if (!$mail->send()) {
|
||||
// echo 'Message could not be sent.';
|
||||
// echo 'Mailer Error: ' . $mail->ErrorInfo;
|
||||
} else {
|
||||
// echo 'Message has been sent';
|
||||
} catch (Exception $e) {
|
||||
if($e instanceof ErrorException) {
|
||||
return \Lang::get('lang.outgoing_email_failed');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -420,8 +422,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';
|
||||
@@ -440,8 +441,7 @@ class PhpMailController extends Controller
|
||||
*
|
||||
* @return type integer
|
||||
*/
|
||||
public function mailfrom($reg, $dept_id)
|
||||
{
|
||||
public function mailfrom($reg, $dept_id) {
|
||||
$email = Email::where('id', '=', '1')->first();
|
||||
if ($reg == 1) {
|
||||
return $email->sys_email;
|
||||
@@ -454,4 +454,5 @@ class PhpMailController extends Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
43
app/Http/Controllers/Common/PushNotificationController.php
Normal file
43
app/Http/Controllers/Common/PushNotificationController.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Common;
|
||||
|
||||
// Controllers
|
||||
use App\Http\Controllers\Controller;
|
||||
// Requests
|
||||
use Illuminate\Http\Request;
|
||||
// Models
|
||||
use App\User;
|
||||
// classes
|
||||
use LaravelFCM\Message\PayloadNotificationBuilder;
|
||||
use LaravelFCM\Message\Topics;
|
||||
use LaravelFCM\Message\OptionsBuilder;
|
||||
use LaravelFCM\Message\PayloadDataBuilder;
|
||||
use LaravelFCM\Response\DownstreamResponse;
|
||||
use FCM;
|
||||
use FCMGroup;
|
||||
|
||||
|
||||
/**
|
||||
* **********************************************
|
||||
* PushNotificationController
|
||||
* **********************************************
|
||||
* This controller is used to send notification to FCM cloud which later will
|
||||
* foreward notification to Mobile Application
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class PushNotificationController extends Controller {
|
||||
|
||||
public function response($token, User $user) {
|
||||
}
|
||||
|
||||
/**
|
||||
* function to get the fcm token from the api under a user.
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return type
|
||||
*/
|
||||
public function fcmToken(Request $request, User $user) {
|
||||
}
|
||||
|
||||
}
|
@@ -27,25 +27,16 @@ 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()
|
||||
{
|
||||
// $this->smtp();
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('roles');
|
||||
// self::driver();
|
||||
// self::host();
|
||||
// self::port();
|
||||
// self::from();
|
||||
// self::encryption();
|
||||
// self::username();
|
||||
// self::password();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,8 +44,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return response
|
||||
*/
|
||||
public function widgets()
|
||||
{
|
||||
public function widgets() {
|
||||
return view('themes.default1.admin.helpdesk.theme.widgets');
|
||||
}
|
||||
|
||||
@@ -63,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')
|
||||
@@ -78,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">×</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>
|
||||
@@ -123,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());
|
||||
}
|
||||
@@ -142,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');
|
||||
}
|
||||
|
||||
@@ -152,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')
|
||||
@@ -164,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">×</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>
|
||||
@@ -200,116 +185,26 @@ 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]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Driver.
|
||||
*
|
||||
* @return type void
|
||||
*/
|
||||
public static function driver()
|
||||
{
|
||||
$set = new Smtp();
|
||||
$settings = Smtp::where('id', '=', '1')->first();
|
||||
Config::set('mail.host', $settings->driver);
|
||||
}
|
||||
|
||||
/**
|
||||
* SMTP host.
|
||||
*
|
||||
* @return type void
|
||||
*/
|
||||
public static function host()
|
||||
{
|
||||
$set = new Smtp();
|
||||
$settings = Smtp::where('id', '=', '1')->first();
|
||||
Config::set('mail.host', $settings->host);
|
||||
}
|
||||
|
||||
/**
|
||||
* SMTP port.
|
||||
*
|
||||
* @return type void
|
||||
*/
|
||||
public static function port()
|
||||
{
|
||||
$set = new Smtp();
|
||||
$settings = Smtp::where('id', '=', '1')->first();
|
||||
Config::set('mail.port', intval($settings->port));
|
||||
}
|
||||
|
||||
/**
|
||||
* SMTP from.
|
||||
*
|
||||
* @return type void
|
||||
*/
|
||||
public static function from()
|
||||
{
|
||||
$set = new Smtp();
|
||||
$settings = Smtp::where('id', '=', '1')->first();
|
||||
Config::set('mail.from', ['address' => $settings->email, 'name' => $settings->company_name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* SMTP encryption.
|
||||
*
|
||||
* @return type void
|
||||
*/
|
||||
public static function encryption()
|
||||
{
|
||||
$set = new Smtp();
|
||||
$settings = Smtp::where('id', '=', '1')->first();
|
||||
Config::set('mail.encryption', $settings->encryption);
|
||||
}
|
||||
|
||||
/**
|
||||
* SMTP username.
|
||||
*
|
||||
* @return type void
|
||||
*/
|
||||
public static function username()
|
||||
{
|
||||
$set = new Smtp();
|
||||
$settings = Smtp::where('id', '=', '1')->first();
|
||||
Config::set('mail.username', $settings->email);
|
||||
}
|
||||
|
||||
/**
|
||||
* SMTP password.
|
||||
*
|
||||
* @return type void
|
||||
*/
|
||||
public static function password()
|
||||
{
|
||||
$settings = Smtp::first();
|
||||
if ($settings->password) {
|
||||
$pass = $settings->password;
|
||||
$password = Crypt::decrypt($pass);
|
||||
Config::set('mail.password', $password);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get SMTP.
|
||||
*
|
||||
* @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'));
|
||||
}
|
||||
|
||||
@@ -318,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');
|
||||
@@ -330,47 +224,12 @@ 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]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* SMTP.
|
||||
*
|
||||
* @return type void
|
||||
*/
|
||||
public static function smtp()
|
||||
{
|
||||
$settings = Smtp::where('id', '=', '1')->first();
|
||||
if ($settings->password) {
|
||||
$password = Crypt::decrypt($settings->password);
|
||||
Config::set('mail.driver', $settings->driver);
|
||||
Config::set('mail.password', $password);
|
||||
Config::set('mail.username', $settings->email);
|
||||
Config::set('mail.encryption', $settings->encryption);
|
||||
Config::set('mail.from', ['address' => $settings->email, 'name' => $settings->name]);
|
||||
Config::set('mail.port', intval($settings->port));
|
||||
Config::set('mail.host', $settings->host);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings.
|
||||
*
|
||||
* @param type Smtp $set
|
||||
*
|
||||
* @return type view\
|
||||
*/
|
||||
public function settings(Smtp $set)
|
||||
{
|
||||
$settings = $set->where('id', '1')->first();
|
||||
|
||||
return view('themes.default1.admin.settings', compact('settings'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Post settings.
|
||||
*
|
||||
@@ -379,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);
|
||||
@@ -393,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();
|
||||
@@ -407,60 +265,11 @@ class SettingsController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* version_check.
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function version_check()
|
||||
{
|
||||
$response_url = \URL::route('post-version-check');
|
||||
echo "<form action='http://www.faveohelpdesk.com/billing/public/version' method='post' name='redirect'>";
|
||||
echo "<input type='hidden' name='_token' value='csrf_token()'/>";
|
||||
echo "<input type='hidden' name='title' value='Faveo helpdesk community'/>";
|
||||
echo "<input type='hidden' name='response_url' value='".$response_url."' />";
|
||||
echo '</form>';
|
||||
echo "<script language='javascript'>document.redirect.submit();</script>";
|
||||
}
|
||||
|
||||
/**
|
||||
* post_version_check.
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function post_version_check(Request $request)
|
||||
{
|
||||
// dd($request);
|
||||
$current_version = \Config::get('app.version');
|
||||
$current_version = explode(' ', $current_version);
|
||||
$current_version = $current_version[1];
|
||||
$new_version = $request->value;
|
||||
if ($current_version == $new_version) {
|
||||
return redirect()->route('checkupdate')->with('info', ' No, new Updates');
|
||||
} elseif ($current_version < $new_version) {
|
||||
$version = Version_Check::where('id', '=', '1')->first();
|
||||
$version->current_version = $current_version;
|
||||
$version->new_version = $new_version;
|
||||
$version->save();
|
||||
|
||||
return redirect()->route('checkupdate')->with('info', ' Version '.$new_version.' is Available');
|
||||
} else {
|
||||
return redirect()->route('checkupdate')->with('info', ' Error Checking Version');
|
||||
}
|
||||
}
|
||||
|
||||
public function getupdate()
|
||||
{
|
||||
return \View::make('themes.default1.admin.helpdesk.settings.checkupdate');
|
||||
}
|
||||
|
||||
public function Plugins()
|
||||
{
|
||||
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))
|
||||
@@ -468,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>
|
||||
@@ -485,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>
|
||||
|
||||
|
||||
@@ -494,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']);
|
||||
@@ -508,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'];
|
||||
@@ -521,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;
|
||||
@@ -536,76 +344,85 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function PostPlugins(Request $request)
|
||||
{
|
||||
$v = $this->validate($request, ['plugin' => 'required|mimes:application/zip,zip,Zip']);
|
||||
$plug = new Plugin();
|
||||
$file = $request->file('plugin');
|
||||
//dd($file);
|
||||
$destination = app_path().DIRECTORY_SEPARATOR.'Plugins';
|
||||
$zipfile = $file->getRealPath();
|
||||
/*
|
||||
* get the file name and remove .zip
|
||||
*/
|
||||
$filename2 = $file->getClientOriginalName();
|
||||
$filename2 = str_replace('.zip', '', $filename2);
|
||||
$filename1 = ucfirst($file->getClientOriginalName());
|
||||
$filename = str_replace('.zip', '', $filename1);
|
||||
mkdir($destination.DIRECTORY_SEPARATOR.$filename);
|
||||
/*
|
||||
* extract the zip file using zipper
|
||||
*/
|
||||
\Zipper::make($zipfile)->folder($filename2)->extractTo($destination.DIRECTORY_SEPARATOR.$filename);
|
||||
public function PostPlugins(Request $request) {
|
||||
$this->validate($request, ['plugin' => 'required|mimes:application/zip,zip,Zip']);
|
||||
try {
|
||||
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';
|
||||
$zipfile = $file->getRealPath();
|
||||
/*
|
||||
* get the file name and remove .zip
|
||||
*/
|
||||
$filename2 = $file->getClientOriginalName();
|
||||
$filename2 = str_replace('.zip', '', $filename2);
|
||||
$filename1 = ucfirst($file->getClientOriginalName());
|
||||
$filename = str_replace('.zip', '', $filename1);
|
||||
$dir_check = scandir($destination);
|
||||
if (in_array($filename, $dir_check)) {
|
||||
return redirect()->back()->with('fails', Lang::get('lang.plugin-exists'));
|
||||
}
|
||||
mkdir($destination . DIRECTORY_SEPARATOR . $filename);
|
||||
/*
|
||||
* extract the zip file using zipper
|
||||
*/
|
||||
\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';
|
||||
if (file_exists($seviceporvider) && file_exists($config)) {
|
||||
/*
|
||||
* move to faveo config
|
||||
*/
|
||||
$faveoconfig = config_path().DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$filename.'.php';
|
||||
if ($faveoconfig) {
|
||||
|
||||
//copy($config, $faveoconfig);
|
||||
if (file_exists($file)) {
|
||||
$seviceporvider = $file . DIRECTORY_SEPARATOR . 'ServiceProvider.php';
|
||||
$config = $file . DIRECTORY_SEPARATOR . 'config.php';
|
||||
if (file_exists($seviceporvider) && file_exists($config)) {
|
||||
/*
|
||||
* write provider list in app.php line 128
|
||||
* move to faveo config
|
||||
*/
|
||||
$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 = 144;
|
||||
$lines = file($app, FILE_IGNORE_NEW_LINES);
|
||||
$lines[$line_i_am_looking_for] = $str;
|
||||
file_put_contents($app, implode("\n", $lines));
|
||||
$plug->create(['name' => $filename, 'path' => $filename, 'status' => 1]);
|
||||
$faveoconfig = config_path() . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $filename . '.php';
|
||||
if ($faveoconfig) {
|
||||
|
||||
return redirect()->back()->with('success', 'Installed SuccessFully');
|
||||
//copy($config, $faveoconfig);
|
||||
/*
|
||||
* write provider list in app.php line 128
|
||||
*/
|
||||
$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 = 144;
|
||||
$lines = file($app, FILE_IGNORE_NEW_LINES);
|
||||
$lines[$line_i_am_looking_for] = $str;
|
||||
file_put_contents($app, implode("\n", $lines));
|
||||
$plug->create(['name' => $filename, 'path' => $filename, 'status' => 1]);
|
||||
|
||||
return redirect()->back()->with('success', Lang::get('lang.plugin-installed'));
|
||||
} else {
|
||||
/*
|
||||
* delete if the plugin hasn't config.php and ServiceProvider.php
|
||||
*/
|
||||
$this->deleteDirectory($file);
|
||||
|
||||
return redirect()->back()->with('fails', Lang::get('no-plugin-file') . $file);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* delete if the plugin hasn't config.php and ServiceProvider.php
|
||||
*/
|
||||
$this->deleteDirectory($file);
|
||||
|
||||
return redirect()->back()->with('fails', 'Their is no '.$file);
|
||||
return redirect()->back()->with('fails', Lang::get('plugin-config-missing') . $file);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* delete if the plugin hasn't config.php and ServiceProvider.php
|
||||
* delete if the plugin Name is not equal to the folder name
|
||||
*/
|
||||
$this->deleteDirectory($file);
|
||||
|
||||
return redirect()->back()->with('fails', 'Their is no <b>config.php or ServiceProvider.php</b> '.$file);
|
||||
return redirect()->back()->with('fails', '<b>' . Lang::get('lang.plugin-path-missing') . '</b> ' . $file);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* delete if the plugin Name is not equal to the folder name
|
||||
*/
|
||||
$this->deleteDirectory($file);
|
||||
|
||||
return redirect()->back()->with('fails', '<b>Plugin File Path is not exist</b> '.$file);
|
||||
} catch (Exception $ex) {
|
||||
return redirect()->back()->with('fails', $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -616,8 +433,7 @@ class SettingsController extends Controller
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteDirectory($dir)
|
||||
{
|
||||
public function deleteDirectory($dir) {
|
||||
if (!file_exists($dir)) {
|
||||
return true;
|
||||
}
|
||||
@@ -628,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;
|
||||
}
|
||||
}
|
||||
@@ -638,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) {
|
||||
@@ -648,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;
|
||||
}
|
||||
}
|
||||
@@ -657,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;
|
||||
}
|
||||
@@ -667,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);
|
||||
@@ -680,8 +495,7 @@ class SettingsController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function fetchConfig()
|
||||
{
|
||||
public function fetchConfig() {
|
||||
$configs = $this->ReadConfigs();
|
||||
//dd($configs);
|
||||
$plugs = new Plugin();
|
||||
@@ -717,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);
|
||||
@@ -738,13 +551,12 @@ 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',";
|
||||
$app = base_path() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'app.php';
|
||||
$str = "\n'App\\Plugins\\$slug" . "\\ServiceProvider',";
|
||||
$line_i_am_looking_for = 144;
|
||||
$lines = file($app, FILE_IGNORE_NEW_LINES);
|
||||
$lines[$line_i_am_looking_for] = $str;
|
||||
@@ -757,8 +569,8 @@ 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',";
|
||||
$app = base_path() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'app.php';
|
||||
$str = "\n'App\\Plugins\\$slug" . "\\ServiceProvider',";
|
||||
$line_i_am_looking_for = 144;
|
||||
$lines = file($app, FILE_IGNORE_NEW_LINES);
|
||||
$lines[$line_i_am_looking_for] = $str;
|
||||
@@ -769,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);
|
||||
|
Reference in New Issue
Block a user