Applied fixes from StyleCI

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

View File

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

View File

@@ -2,34 +2,35 @@
namespace App\Http\Controllers\Common;
use App\Http\Controllers\Api\v1\PushNotificationController;
use App\Http\Controllers\Controller;
use App\Model\helpdesk\Notification\Notification;
use App\Model\helpdesk\Notification\NotificationType;
use App\Model\helpdesk\Notification\UserNotification;
use App\Model\helpdesk\Ticket\Tickets;
use App\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
* under the folling occurrence
* 1. Ticket Creation
* 2. Ticket Reply
* 3. User Creation
*
* 3. User Creation.
*
* @author Ladybird <info@ladybirdweb.com>
*/
public $user;
/**
* Constructor
*/
public function __construct(PushNotificationController $PushNotificationController) {
* Constructor.
*/
public function __construct(PushNotificationController $PushNotificationController)
{
$this->PushNotificationController = $PushNotificationController;
$user = new User();
$this->user = $user;
@@ -41,12 +42,14 @@ class NotificationController extends Controller {
/**
* This function is used to create in app notifications.
*
* @param type $model_id
* @param type $userid_created
* @param type $type_id
* @param type $forwhome
*/
public function create($model_id, $userid_created, $type_id, $forwhome = []) {
public function create($model_id, $userid_created, $type_id, $forwhome = [])
{
try {
if (empty($forwhome)) {
$ticket = Tickets::where('id', '=', $model_id)->first();
@@ -67,48 +70,62 @@ class NotificationController extends Controller {
}
/**
* This function is to mark all ticket to read status
* This function is to mark all ticket to read status.
*
* @param type $id
*
* @return int
*/
public function markAllRead($id) {
public function markAllRead($id)
{
$markasread = UserNotification::where('user_id', '=', \Auth::user()->id)->where('is_read', '=', '0')->get();
foreach ($markasread as $mark) {
$mark->is_read = '1';
$mark->save();
}
return 1;
}
/**
* This function to mark read
* This function to mark read.
*
* @param type $id
*
* @return int
*/
public function markRead($id) {
public function markRead($id)
{
$markasread = UserNotification::where('notification_id', '=', $id)->where('user_id', '=', \Auth::user()->id)->where('is_read', '=', '0')->get();
foreach ($markasread as $mark) {
$mark->is_read = '1';
$mark->save();
}
return 1;
}
/**
* function to show all the notifications
* function to show all the notifications.
*
* @return type
*/
public function show() {
public function show()
{
$notifications = $this->getNotifications();
return view('notifications-all', compact('notifications'));
}
/**
* function to delete notifications
* function to delete notifications.
*
* @param type $id
*
* @return int
*/
public function delete($id) {
public function delete($id)
{
$markasread = UserNotification::where('notification_id', '=', $id)->where('user_id', '=', \Auth::user()->id)->get();
foreach ($markasread as $mark) {
$mark->delete();
@@ -119,14 +136,16 @@ class NotificationController extends Controller {
/**
* get the page to list the notifications.
*
* @return response
*/
public static function getNotifications() {
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;
}
}

View File

@@ -6,16 +6,18 @@ use App\Http\Controllers\Controller;
use App\Model\Common\TemplateType;
use App\Model\helpdesk\Agent\Department;
use App\Model\helpdesk\Email\Emails;
use App\Model\helpdesk\Settings\CommonSettings;
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) {
class PhpMailController extends Controller
{
public function fetch_smtp_details($id)
{
$emails = Emails::where('id', '=', $id)->first();
return $emails;
}
@@ -24,42 +26,43 @@ class PhpMailController extends Controller {
*
* @return Mail
*/
public function sendmail($from, $to, $message, $template_variables) {
// try {
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);
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;
$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($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 {
@@ -70,16 +73,16 @@ class PhpMailController extends Controller {
} 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($message['scenario'])) {
$template = $message['scenario'];
} else {
$template = null;
}
if (isset($message['attachments'])) {
$attachment = $message['attachments'];
} else {
$attachment = null;
}
// template variables
if (Auth::user()) {
@@ -87,86 +90,86 @@ class PhpMailController extends Controller {
} 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;
}
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('/');
@@ -174,9 +177,9 @@ class PhpMailController extends Controller {
$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;
//
@@ -186,31 +189,31 @@ class PhpMailController extends Controller {
$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 . ']';
}
} else {
$subject = $message['subject'];
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 {
$contents = null;
$subject = null;
$subject = $message['subject'];
}
} 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);
@@ -241,7 +244,7 @@ class PhpMailController extends Controller {
$mail->setFrom($username, $fromname);
}
}
$mail->addAddress($recipants); // Add a recipient
$mail->addAddress($recipants); // Add a recipient
$mail->isHTML(true); // Set email format to HTML
if ($cc != null) {
foreach ($cc as $collaborator) {
@@ -253,37 +256,37 @@ class PhpMailController extends Controller {
}
}
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;
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;
}
}
}
/**
@@ -291,7 +294,8 @@ class PhpMailController extends Controller {
*
* @return MailNotification
*/
public function sendEmail($from, $to, $message) {
public function sendEmail($from, $to, $message)
{
try {
$from_address = $this->fetch_smtp_details($from);
if ($from_address == null) {
@@ -403,7 +407,7 @@ class PhpMailController extends Controller {
$mail->addAttachment($file_path, $file_name);
}
}
$mail->CharSet = "utf8";
$mail->CharSet = 'utf8';
$mail->Subject = $subject;
$mail->Body = $content;
if (!$mail->send()) {
@@ -411,9 +415,9 @@ class PhpMailController extends Controller {
}
}
} catch (Exception $e) {
if($e instanceof ErrorException) {
if ($e instanceof ErrorException) {
return \Lang::get('lang.outgoing_email_failed');
}
}
}
}
@@ -422,7 +426,8 @@ 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';
@@ -441,7 +446,8 @@ 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,5 +460,4 @@ class PhpMailController extends Controller {
}
}
}
}
}

View File

@@ -5,39 +5,35 @@ 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;
// Models
use FCM;
use FCMGroup;
// classes
use Illuminate\Http\Request;
/**
* **********************************************
* PushNotificationController
* **********************************************
* This controller is used to send notification to FCM cloud which later will
* foreward notification to Mobile Application
* 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) {
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) {
public function fcmToken(Request $request, User $user)
{
}
}

View File

@@ -11,7 +11,6 @@ use App\Model\helpdesk\Email\Smtp;
// models
use App\Model\helpdesk\Settings\Plugin;
use App\Model\helpdesk\Theme\Widgets;
use App\Model\helpdesk\Utility\Version_Check;
use Config;
// classes
use Crypt;
@@ -27,14 +26,15 @@ use Lang;
* ***************************
* Controller to keep smtp details and fetch where ever needed.
*/
class SettingsController extends Controller {
class SettingsController extends Controller
{
/**
* Create a new controller instance.
*
* @return type void
*/
public function __construct() {
public function __construct()
{
$this->middleware('auth');
$this->middleware('roles');
}
@@ -44,7 +44,8 @@ class SettingsController extends Controller {
*
* @return response
*/
public function widgets() {
public function widgets()
{
return view('themes.default1.admin.helpdesk.theme.widgets');
}
@@ -53,7 +54,8 @@ 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')
@@ -67,33 +69,33 @@ class SettingsController extends Controller {
return $model->value;
})
->addColumn('Actions', function ($model) {
return '<span data-toggle="modal" data-target="#edit_widget' . $model->id . '"><a class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a></span>
<div class="modal fade" id="edit_widget' . $model->id . '">
return '<span data-toggle="modal" data-target="#edit_widget'.$model->id.'"><a class="btn btn-warning btn-xs">'.\Lang::get('lang.edit').'</a></span>
<div class="modal fade" id="edit_widget'.$model->id.'">
<div class="modal-dialog">
<div class="modal-content">
<form action="' . url('edit-widget/' . $model->id) . '" method="POST">
<form action="'.url('edit-widget/'.$model->id).'" method="POST">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">' . strtoupper($model->name) . ' </h4>
<h4 class="modal-title">'.strtoupper($model->name).' </h4>
</div>
<div class="modal-body">
<div class="form-group" style="width:100%">
<label>' . \Lang::get('lang.title') . '</label><br/>
<input type="text" name="title" value="' . $model->title . '" class="form-control" style="width:100%">
<label>'.\Lang::get('lang.title').'</label><br/>
<input type="text" name="title" value="'.$model->title.'" class="form-control" style="width:100%">
</div>
<br/>
<div class="form-group" style="width:100%">
<label>' . \Lang::get('lang.content') . '</label><br/>
<textarea name="content" class="form-control" style="width:100%" id="Content' . $model->id . '">' . $model->value . '</textarea>
<label>'.\Lang::get('lang.content').'</label><br/>
<textarea name="content" class="form-control" style="width:100%" id="Content'.$model->id.'">'.$model->value.'</textarea>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">' . \Lang::get('lang.close') . '</button>
<input type="submit" class="btn btn-primary" value="' . \Lang::get('lang.update') . '">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">'.\Lang::get('lang.close').'</button>
<input type="submit" class="btn btn-primary" value="'.\Lang::get('lang.update').'">
</div>
<script>
$(function () {
$("#Content' . $model->id . '").wysihtml5();
$("#Content'.$model->id.'").wysihtml5();
});
</script>
</form>
@@ -112,13 +114,15 @@ 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());
}
@@ -129,7 +133,8 @@ class SettingsController extends Controller {
*
* @return response
*/
public function social_buttons() {
public function social_buttons()
{
return view('themes.default1.admin.helpdesk.theme.social');
}
@@ -138,7 +143,8 @@ 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')
@@ -149,25 +155,25 @@ class SettingsController extends Controller {
return $model->value;
})
->addColumn('Actions', function ($model) {
return '<span data-toggle="modal" data-target="#edit_widget' . $model->id . '"><a class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a></span>
<div class="modal fade" id="edit_widget' . $model->id . '">
return '<span data-toggle="modal" data-target="#edit_widget'.$model->id.'"><a class="btn btn-warning btn-xs">'.\Lang::get('lang.edit').'</a></span>
<div class="modal fade" id="edit_widget'.$model->id.'">
<div class="modal-dialog">
<div class="modal-content">
<form action="' . url('edit-widget/' . $model->id) . '" method="POST">
<form action="'.url('edit-widget/'.$model->id).'" method="POST">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">' . strtoupper($model->name) . ' </h4>
<h4 class="modal-title">'.strtoupper($model->name).' </h4>
</div>
<div class="modal-body">
<br/>
<div class="form-group" style="width:100%">
<label>' . \Lang::get('lang.link') . '</label><br/>
<input type="url" name="content" class="form-control" style="width:100%" value="' . $model->value . '">
<label>'.\Lang::get('lang.link').'</label><br/>
<input type="url" name="content" class="form-control" style="width:100%" value="'.$model->value.'">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">' . \Lang::get('lang.close') . '</button>
<input type="submit" class="btn btn-primary" value="' . \Lang::get('lang.update') . '">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">'.\Lang::get('lang.close').'</button>
<input type="submit" class="btn btn-primary" value="'.\Lang::get('lang.update').'">
</div>
</form>
</div>
@@ -185,14 +191,15 @@ 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]);
}
@@ -203,8 +210,10 @@ class SettingsController extends Controller {
*
* @return type view
*/
public function getsmtp() {
public function getsmtp()
{
$settings = Smtp::where('id', '=', '1')->first();
return view('themes.default1.admin.helpdesk.emails.smtp', compact('settings'));
}
@@ -213,7 +222,8 @@ 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');
@@ -224,6 +234,7 @@ 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]);
@@ -238,7 +249,8 @@ 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);
@@ -251,7 +263,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();
@@ -265,11 +277,13 @@ class SettingsController extends Controller {
}
}
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))
@@ -277,15 +291,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>
@@ -294,8 +308,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>
@@ -303,12 +317,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']);
@@ -317,7 +331,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'];
@@ -330,8 +344,9 @@ 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;
@@ -344,15 +359,16 @@ class SettingsController extends Controller {
*
* @return type
*/
public function PostPlugins(Request $request) {
public function PostPlugins(Request $request)
{
$this->validate($request, ['plugin' => 'required|mimes:application/zip,zip,Zip']);
try {
if (!extension_loaded('zip')){
if (!extension_loaded('zip')) {
throw new Exception('Please enable zip extension in your php');
}
$plug = new Plugin();
$file = $request->file('plugin');
$destination = app_path() . DIRECTORY_SEPARATOR . 'Plugins';
$destination = app_path().DIRECTORY_SEPARATOR.'Plugins';
$zipfile = $file->getRealPath();
/*
* get the file name and remove .zip
@@ -365,31 +381,31 @@ class SettingsController extends Controller {
if (in_array($filename, $dir_check)) {
return redirect()->back()->with('fails', Lang::get('lang.plugin-exists'));
}
mkdir($destination . DIRECTORY_SEPARATOR . $filename);
mkdir($destination.DIRECTORY_SEPARATOR.$filename);
/*
* extract the zip file using zipper
*/
\Zipper::make($zipfile)->folder($filename2)->extractTo($destination . DIRECTORY_SEPARATOR . $filename);
\Zipper::make($zipfile)->folder($filename2)->extractTo($destination.DIRECTORY_SEPARATOR.$filename);
$file = app_path() . DIRECTORY_SEPARATOR . 'Plugins' . DIRECTORY_SEPARATOR . $filename; // Plugin file path
$file = app_path().DIRECTORY_SEPARATOR.'Plugins'.DIRECTORY_SEPARATOR.$filename; // Plugin file path
if (file_exists($file)) {
$seviceporvider = $file . DIRECTORY_SEPARATOR . 'ServiceProvider.php';
$config = $file . DIRECTORY_SEPARATOR . 'config.php';
$seviceporvider = $file.DIRECTORY_SEPARATOR.'ServiceProvider.php';
$config = $file.DIRECTORY_SEPARATOR.'config.php';
if (file_exists($seviceporvider) && file_exists($config)) {
/*
* move to faveo config
*/
$faveoconfig = config_path() . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $filename . '.php';
$faveoconfig = config_path().DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$filename.'.php';
if ($faveoconfig) {
//copy($config, $faveoconfig);
/*
* write provider list in app.php line 128
*/
$app = base_path() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'app.php';
$app = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
chmod($app, 0644);
$str = "\n\n\t\t\t'App\\Plugins\\$filename" . "\\ServiceProvider',";
$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;
@@ -403,7 +419,7 @@ class SettingsController extends Controller {
*/
$this->deleteDirectory($file);
return redirect()->back()->with('fails', Lang::get('no-plugin-file') . $file);
return redirect()->back()->with('fails', Lang::get('no-plugin-file').$file);
}
} else {
/*
@@ -411,7 +427,7 @@ class SettingsController extends Controller {
*/
$this->deleteDirectory($file);
return redirect()->back()->with('fails', Lang::get('plugin-config-missing') . $file);
return redirect()->back()->with('fails', Lang::get('plugin-config-missing').$file);
}
} else {
/*
@@ -419,7 +435,7 @@ class SettingsController extends Controller {
*/
$this->deleteDirectory($file);
return redirect()->back()->with('fails', '<b>' . Lang::get('lang.plugin-path-missing') . '</b> ' . $file);
return redirect()->back()->with('fails', '<b>'.Lang::get('lang.plugin-path-missing').'</b> '.$file);
}
} catch (Exception $ex) {
return redirect()->back()->with('fails', $ex->getMessage());
@@ -433,7 +449,8 @@ class SettingsController extends Controller {
*
* @return bool
*/
public function deleteDirectory($dir) {
public function deleteDirectory($dir)
{
if (!file_exists($dir)) {
return true;
}
@@ -444,8 +461,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;
}
}
@@ -454,8 +471,9 @@ 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) {
@@ -463,7 +481,7 @@ class SettingsController extends Controller {
continue;
}
if (is_dir($dir . DIRECTORY_SEPARATOR . $file)) {
if (is_dir($dir.DIRECTORY_SEPARATOR.$file)) {
$files[$key] = $file;
}
}
@@ -472,7 +490,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;
}
@@ -482,7 +500,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);
@@ -495,7 +513,8 @@ class SettingsController extends Controller {
}
}
public function fetchConfig() {
public function fetchConfig()
{
$configs = $this->ReadConfigs();
//dd($configs);
$plugs = new Plugin();
@@ -531,14 +550,15 @@ 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);
@@ -551,12 +571,13 @@ class SettingsController extends Controller {
return redirect()->back()->with('success', 'Deleted Successfully');
}
public function StatusPlugin($slug) {
public function StatusPlugin($slug)
{
$plugs = new Plugin();
$plug = $plugs->where('name', $slug)->first();
if (!$plug) {
$app = base_path() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'app.php';
$str = "\n'App\\Plugins\\$slug" . "\\ServiceProvider',";
$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;
@@ -569,8 +590,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;
@@ -581,8 +602,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);