mirror of
https://github.com/freescout-helpdesk/freescout.git
synced 2025-01-31 20:11:38 +01:00
Apply fixes from StyleCI
This commit is contained in:
parent
a2e35bacbd
commit
6346437754
@ -95,6 +95,7 @@ class ActivityLog extends Activity
|
||||
{
|
||||
$col = str_replace('_', ' ', $col);
|
||||
$col = ucfirst($col);
|
||||
|
||||
return $col;
|
||||
}
|
||||
}
|
||||
|
@ -77,11 +77,11 @@ class Attachment extends Model
|
||||
|
||||
$attachment = new self();
|
||||
$attachment->thread_id = $thread_id;
|
||||
$attachment->user_id = $user_id;
|
||||
$attachment->user_id = $user_id;
|
||||
$attachment->file_name = $file_name;
|
||||
$attachment->mime_type = $mime_type;
|
||||
$attachment->type = $type;
|
||||
$attachment->embedded = $embedded;
|
||||
$attachment->type = $type;
|
||||
$attachment->embedded = $embedded;
|
||||
$attachment->save();
|
||||
|
||||
// Save file from content or copy file.
|
||||
@ -112,7 +112,7 @@ class Attachment extends Model
|
||||
|
||||
/**
|
||||
* Get file path.
|
||||
* Examples: 1/2, 1/3
|
||||
* Examples: 1/2, 1/3.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
@ -144,8 +144,9 @@ class Attachment extends Model
|
||||
|
||||
/**
|
||||
* Detect attachment type by it's mime type.
|
||||
*
|
||||
* @param string $mime_type
|
||||
*
|
||||
* @param string $mime_type
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function detectType($mime_type)
|
||||
@ -227,15 +228,15 @@ class Attachment extends Model
|
||||
/**
|
||||
* Delete attachments from disk and DB.
|
||||
* Embeds are not taken into account.
|
||||
*
|
||||
* @param array $attachments
|
||||
*
|
||||
* @param array $attachments
|
||||
*/
|
||||
public static function deleteByIds($attachment_ids)
|
||||
{
|
||||
if (!count($attachment_ids)) {
|
||||
return;
|
||||
}
|
||||
$attachments = Attachment::whereIn('id', $attachment_ids)->get();
|
||||
$attachments = self::whereIn('id', $attachment_ids)->get();
|
||||
|
||||
// Delete from disk
|
||||
foreach ($attachments as $attachment) {
|
||||
@ -244,6 +245,6 @@ class Attachment extends Model
|
||||
}
|
||||
|
||||
// Delete from DB
|
||||
Attachment::whereIn('id', $attachment_ids)->delete();
|
||||
self::whereIn('id', $attachment_ids)->delete();
|
||||
}
|
||||
}
|
||||
|
@ -3,16 +3,13 @@
|
||||
* Created by PhpStorm.
|
||||
* User: leemason
|
||||
* Date: 31/10/15
|
||||
* Time: 00:20
|
||||
* Time: 00:20.
|
||||
*/
|
||||
|
||||
namespace App\Broadcasting\Broadcasters;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Broadcasting\Broadcasters\Broadcaster;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Database\DatabaseManager;
|
||||
use Illuminate\Support\Str;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
|
||||
@ -43,20 +40,22 @@ class PolycastBroadcaster extends Broadcaster
|
||||
|
||||
// insert the new event
|
||||
\DB::table('polycast_events')->insert([
|
||||
'channels' => json_encode($channels),
|
||||
'event' => $event,
|
||||
'payload' => json_encode($payload),
|
||||
'created_at' => Carbon::now()->toDateTimeString()
|
||||
'channels' => json_encode($channels),
|
||||
'event' => $event,
|
||||
'payload' => json_encode($payload),
|
||||
'created_at' => Carbon::now()->toDateTimeString(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Authenticate the incoming request for a given channel.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function auth($request) {
|
||||
public function auth($request)
|
||||
{
|
||||
|
||||
// For connect request
|
||||
if (empty($request->channels)) {
|
||||
@ -67,10 +66,11 @@ class PolycastBroadcaster extends Broadcaster
|
||||
foreach ($request->channels as $channel_name => $channel_info) {
|
||||
// Copied from Illuminate\Broadcasting\Broadcasters\PusherBroadcaster
|
||||
if (Str::startsWith($channel_name, ['private-', 'presence-']) &&
|
||||
! $request->user()) {
|
||||
!$request->user()) {
|
||||
echo 1;
|
||||
exit();
|
||||
throw new AccessDeniedHttpException;
|
||||
|
||||
throw new AccessDeniedHttpException();
|
||||
}
|
||||
|
||||
$channelName = Str::startsWith($channel_name, 'private-')
|
||||
@ -88,11 +88,13 @@ class PolycastBroadcaster extends Broadcaster
|
||||
/**
|
||||
* Return the valid authentication response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param mixed $result
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param mixed $result
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function validAuthenticationResponse($request, $result) {
|
||||
public function validAuthenticationResponse($request, $result)
|
||||
{
|
||||
// By some reason this is never called
|
||||
return false;
|
||||
|
||||
@ -107,20 +109,20 @@ class PolycastBroadcaster extends Broadcaster
|
||||
// ]]);
|
||||
}
|
||||
|
||||
public function isDeferred()
|
||||
{
|
||||
public function isDeferred()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Created as there was an error:
|
||||
* "Call to undefined method App\Broadcasting\Broadcasters\PolycastBroadcaster::channel()"
|
||||
*
|
||||
* It is called from routes/channels.php
|
||||
*/
|
||||
/*
|
||||
* Created as there was an error:
|
||||
* "Call to undefined method App\Broadcasting\Broadcasters\PolycastBroadcaster::channel()"
|
||||
*
|
||||
* It is called from routes/channels.php
|
||||
*/
|
||||
// public function channel($channel, callable $callback)
|
||||
// {
|
||||
// return true;
|
||||
// //return (int) $user->id === (int) $id;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
@ -3,19 +3,17 @@
|
||||
namespace App\Channels;
|
||||
|
||||
use App\Events\RealtimeBroadcastNotificationCreated;
|
||||
use RuntimeException;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Notifications\Channels\BroadcastChannel;
|
||||
use Illuminate\Notifications\Messages\BroadcastMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class RealtimeBroadcastChannel extends BroadcastChannel
|
||||
{
|
||||
/**
|
||||
* Send the given notification immediately using non-quable event.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @param \Illuminate\Notifications\Notification $notification
|
||||
* @param mixed $notifiable
|
||||
* @param \Illuminate\Notifications\Notification $notification
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function send($notifiable, Notification $notification)
|
||||
|
@ -10,8 +10,8 @@ use App\Events\ConversationCustomerChanged;
|
||||
use App\Events\CustomerCreatedConversation;
|
||||
use App\Events\CustomerReplied;
|
||||
use App\Events\UserReplied;
|
||||
use App\Misc\Mail;
|
||||
use App\Mailbox;
|
||||
use App\Misc\Mail;
|
||||
use App\Option;
|
||||
use App\Subscription;
|
||||
use App\Thread;
|
||||
@ -96,13 +96,13 @@ class FetchEmails extends Command
|
||||
public function fetch($mailbox)
|
||||
{
|
||||
$client = new Client([
|
||||
'host' => $mailbox->in_server,
|
||||
'port' => $mailbox->in_port,
|
||||
'encryption' => $mailbox->getInEncryptionName(),
|
||||
'host' => $mailbox->in_server,
|
||||
'port' => $mailbox->in_port,
|
||||
'encryption' => $mailbox->getInEncryptionName(),
|
||||
'validate_cert' => true,
|
||||
'username' => $mailbox->in_username,
|
||||
'password' => $mailbox->in_password,
|
||||
'protocol' => $mailbox->getInProtocolName(),
|
||||
'username' => $mailbox->in_username,
|
||||
'password' => $mailbox->in_password,
|
||||
'protocol' => $mailbox->getInProtocolName(),
|
||||
]);
|
||||
|
||||
// Connect to the Server
|
||||
@ -353,7 +353,7 @@ class FetchEmails extends Command
|
||||
try {
|
||||
activity()
|
||||
->withProperties([
|
||||
'error' => $message,
|
||||
'error' => $message,
|
||||
'mailbox' => $mailbox_name,
|
||||
])
|
||||
->useLog(\App\ActivityLog::NAME_EMAILS_FETCHING)
|
||||
@ -557,7 +557,7 @@ class FetchEmails extends Command
|
||||
if ($created_attachment) {
|
||||
$created_attachments[] = [
|
||||
'imap_attachment' => $email_attachment,
|
||||
'attachment' => $created_attachment
|
||||
'attachment' => $created_attachment,
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -628,6 +628,7 @@ class FetchEmails extends Command
|
||||
$body = str_replace('cid:'.$attachment['imap_attachment']->id, $attachment['attachment']->url(), $body);
|
||||
}
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
@ -674,7 +675,7 @@ class FetchEmails extends Command
|
||||
/**
|
||||
* Create customers from emails.
|
||||
*
|
||||
* @param array $emails_data
|
||||
* @param array $emails_data
|
||||
*/
|
||||
public function createCustomers($emails, $exclude_emails)
|
||||
{
|
||||
|
@ -40,8 +40,7 @@ class FetchMonitor extends Command
|
||||
$now = time();
|
||||
|
||||
$last_successful_run = \Option::get('fetch_emails_last_successful_run');
|
||||
if ($last_successful_run && $last_successful_run < $now - \Option::get('alert_fetch_period')*60) {
|
||||
|
||||
if ($last_successful_run && $last_successful_run < $now - \Option::get('alert_fetch_period') * 60) {
|
||||
$mins_ago = floor(($now - $last_successful_run) / 60);
|
||||
|
||||
$text = 'There are some problems fetching emails: last time emails were successfully fetched <strong>'.$mins_ago.' minutes ago</strong>. Please check <a href="'.route('logs', ['name' => 'fetch_errors']).'">fetching logs</a> and <a href="'.route('system').'#cron">make sure</a> that the flollowing cron task is running: <code>php artisan schedule:run</code>';
|
||||
|
@ -52,6 +52,7 @@ class ModuleBuild extends Command
|
||||
}
|
||||
if (!$modules_aliases) {
|
||||
$this->error('No modules found');
|
||||
|
||||
return;
|
||||
}
|
||||
$all = true;
|
||||
@ -70,6 +71,7 @@ class ModuleBuild extends Command
|
||||
$module = \Module::findByAlias($module_alias);
|
||||
if (!$module) {
|
||||
$this->error('Module with the specified alias not found: '.$module_alias);
|
||||
|
||||
return;
|
||||
}
|
||||
$this->buildModule($module);
|
||||
@ -84,6 +86,7 @@ class ModuleBuild extends Command
|
||||
$public_symlink = public_path('modules').DIRECTORY_SEPARATOR.$module->alias;
|
||||
if (!file_exists($public_symlink)) {
|
||||
$this->error('Public symlink ['.$public_symlink.'] not found. Run module installation command first: php artisan freescout:module-install');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -108,7 +111,6 @@ class ModuleBuild extends Command
|
||||
}
|
||||
|
||||
$this->info("Created: {$file_path}");
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* php artisan freescout:module-install modulealias
|
||||
* php artisan freescout:module-install modulealias.
|
||||
*/
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
@ -56,6 +57,7 @@ class ModuleInstall extends Command
|
||||
}
|
||||
if (!$modules_aliases) {
|
||||
$this->error('No modules found');
|
||||
|
||||
return;
|
||||
}
|
||||
$install_all = $this->confirm('You have not specified a module alias, would you like to install all available modules ('.implode(', ', $modules_aliases).')?');
|
||||
@ -74,6 +76,7 @@ class ModuleInstall extends Command
|
||||
$module = \Module::findByAlias($module_alias);
|
||||
if (!$module) {
|
||||
$this->error('Module with the specified alias not found: '.$module_alias);
|
||||
|
||||
return;
|
||||
}
|
||||
$this->call('module:migrate', ['module' => $module->getName(), '--force' => true]);
|
||||
@ -91,7 +94,7 @@ class ModuleInstall extends Command
|
||||
if (file_exists($from)) {
|
||||
return $this->info('Public symlink already exists');
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
symlink($to, $from);
|
||||
} catch (\Exception $e) {
|
||||
|
@ -2,9 +2,8 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Axn\Laroute\Routes\Collection as Routes;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class ModuleLaroute extends Command
|
||||
{
|
||||
@ -31,8 +30,8 @@ class ModuleLaroute extends Command
|
||||
{
|
||||
$app = app();
|
||||
|
||||
$this->config = $app['config'];
|
||||
$this->generator = $app->make('Lord\Laroute\Generators\GeneratorInterface');
|
||||
$this->config = $app['config'];
|
||||
$this->generator = $app->make('Lord\Laroute\Generators\GeneratorInterface');
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
@ -58,6 +57,7 @@ class ModuleLaroute extends Command
|
||||
}
|
||||
if (!$modules_aliases) {
|
||||
$this->error('No modules found');
|
||||
|
||||
return;
|
||||
}
|
||||
$all = true;
|
||||
@ -75,6 +75,7 @@ class ModuleLaroute extends Command
|
||||
$module = \Module::findByAlias($module_alias);
|
||||
if (!$module) {
|
||||
$this->error('Module with the specified alias not found: '.$module_alias);
|
||||
|
||||
return;
|
||||
}
|
||||
$this->generateModuleRoutes($module);
|
||||
@ -88,6 +89,7 @@ class ModuleLaroute extends Command
|
||||
$public_symlink = public_path('modules').DIRECTORY_SEPARATOR.$module->getAlias();
|
||||
if (!file_exists($public_symlink)) {
|
||||
$this->error('Public symlink ['.$public_symlink.'] not found. Run module installation command first: php artisan freescout:module-install');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -123,16 +125,15 @@ class ModuleLaroute extends Command
|
||||
*/
|
||||
protected function getTemplateData()
|
||||
{
|
||||
$namespace = $this->getOptionOrConfig('namespace');
|
||||
$routes = $this->routes->toJSON();
|
||||
$absolute = $this->config->get('laroute.absolute', false);
|
||||
$rootUrl = $this->config->get('app.url', '');
|
||||
$prefix = $this->config->get('laroute.prefix', '');
|
||||
$namespace = $this->getOptionOrConfig('namespace');
|
||||
$routes = $this->routes->toJSON();
|
||||
$absolute = $this->config->get('laroute.absolute', false);
|
||||
$rootUrl = $this->config->get('app.url', '');
|
||||
$prefix = $this->config->get('laroute.prefix', '');
|
||||
|
||||
return compact('namespace', 'routes', 'absolute', 'rootUrl', 'prefix');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the path where the file will be generated.
|
||||
*
|
||||
@ -140,7 +141,7 @@ class ModuleLaroute extends Command
|
||||
*/
|
||||
protected function getFileGenerationPath($module_alias)
|
||||
{
|
||||
$path = 'public/modules/'.$module_alias.'/js';
|
||||
$path = 'public/modules/'.$module_alias.'/js';
|
||||
$filename = 'laroute'; //$this->getOptionOrConfig('filename');
|
||||
|
||||
return "{$path}/{$filename}.js";
|
||||
|
@ -43,11 +43,12 @@ class Update extends Command
|
||||
if (!$this->confirmToProceed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ini_set('memory_limit', '128M');
|
||||
|
||||
if (\Updater::isNewVersionAvailable(config('app.version'))) {
|
||||
$this->info('Updating... This may take several minutes');
|
||||
|
||||
try {
|
||||
// Script may fail here and stop with the error:
|
||||
// PHP Fatal error: Allowed memory size of 94371840 bytes exhausted
|
||||
|
@ -48,11 +48,12 @@ class Kernel extends ConsoleKernel
|
||||
// Command runs as subprocess and sets cache mutex. If schedule:run command is killed
|
||||
// subprocess does not clear the mutex and it stays in the cache until cache:clear is executed.
|
||||
// By default, the lock will expire after 24 hours.
|
||||
//
|
||||
//
|
||||
// cache:clear clears the mutex, but sometimes process continues running, so we need to kill it.
|
||||
|
||||
|
||||
if (function_exists('shell_exec')) {
|
||||
$running_commands = 0;
|
||||
|
||||
try {
|
||||
$processes = preg_split("/[\r\n]/", shell_exec("ps aux | grep 'queue:work'"));
|
||||
foreach ($processes as $process) {
|
||||
|
@ -3,9 +3,6 @@
|
||||
namespace App;
|
||||
|
||||
use App\Events\ConversationCustomerChanged;
|
||||
use App\ConversationFolder;
|
||||
use App\Folder;
|
||||
use App\Thread;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
|
||||
@ -143,6 +140,7 @@ class Conversation extends Model
|
||||
|
||||
/**
|
||||
* Cache of the conversations starred by user.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $starred_conversation_ids = null;
|
||||
@ -162,17 +160,17 @@ class Conversation extends Model
|
||||
parent::boot();
|
||||
|
||||
self::creating(function (Conversation $model) {
|
||||
$next_ticket = (int)Option::get('next_ticket');
|
||||
$next_ticket = (int) Option::get('next_ticket');
|
||||
$current_number = Conversation::max('number');
|
||||
|
||||
if ($next_ticket) {
|
||||
Option::remove('next_ticket');
|
||||
}
|
||||
|
||||
if ($next_ticket && $next_ticket >= ($current_number +1) && !Conversation::where('number', $next_ticket)->exists()) {
|
||||
if ($next_ticket && $next_ticket >= ($current_number + 1) && !Conversation::where('number', $next_ticket)->exists()) {
|
||||
$model->number = $next_ticket;
|
||||
} else {
|
||||
$model->number = $current_number +1;
|
||||
$model->number = $current_number + 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -497,8 +495,9 @@ class Conversation extends Model
|
||||
$url = $next_conversation->url();
|
||||
} else {
|
||||
// Show folder
|
||||
$url = route('mailboxes.view.folder', ['id' => $this->mailbox_id, 'folder_id' => Conversation::getCurrentFolder($this->folder_id)]);
|
||||
$url = route('mailboxes.view.folder', ['id' => $this->mailbox_id, 'folder_id' => self::getCurrentFolder($this->folder_id)]);
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
@ -512,8 +511,9 @@ class Conversation extends Model
|
||||
$url = $prev_conversation->url();
|
||||
} else {
|
||||
// Show folder
|
||||
$url = route('mailboxes.view.folder', ['id' => $this->mailbox_id, 'folder_id' => Conversation::getCurrentFolder($this->folder_id)]);
|
||||
$url = route('mailboxes.view.folder', ['id' => $this->mailbox_id, 'folder_id' => self::getCurrentFolder($this->folder_id)]);
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
@ -689,7 +689,7 @@ class Conversation extends Model
|
||||
* For each user starred conversations are cached.
|
||||
*/
|
||||
public function isStarredByUser($user_id = null)
|
||||
{
|
||||
{
|
||||
if (!$user_id) {
|
||||
$user = auth()->user();
|
||||
if ($user) {
|
||||
@ -729,7 +729,7 @@ class Conversation extends Model
|
||||
*/
|
||||
public static function getUserStarredConversationIds($mailbox_id, $user_id = null)
|
||||
{
|
||||
return \Cache::rememberForever('user_starred_conversations_'.$user_id, function() use ($mailbox_id, $user_id) {
|
||||
return \Cache::rememberForever('user_starred_conversations_'.$user_id, function () use ($mailbox_id, $user_id) {
|
||||
// Get user's folder
|
||||
$folder = Folder::select('id')
|
||||
->where('mailbox_id', $mailbox_id)
|
||||
@ -748,6 +748,7 @@ class Conversation extends Model
|
||||
])
|
||||
->useLog(\App\ActivityLog::NAME_SYSTEM)
|
||||
->log(\App\ActivityLog::DESCRIPTION_SYSTEM_ERROR);
|
||||
|
||||
return [];
|
||||
}
|
||||
});
|
||||
@ -784,42 +785,34 @@ class Conversation extends Model
|
||||
{
|
||||
if ($folder->type == Folder::TYPE_MINE) {
|
||||
// Get conversations from personal folder
|
||||
$query_conversations = Conversation::where('user_id', $user_id)
|
||||
$query_conversations = self::where('user_id', $user_id)
|
||||
->where('mailbox_id', $folder->mailbox_id)
|
||||
->whereIn('status', [Conversation::STATUS_ACTIVE, Conversation::STATUS_PENDING])
|
||||
->where('state', Conversation::STATE_PUBLISHED);
|
||||
|
||||
->whereIn('status', [self::STATUS_ACTIVE, self::STATUS_PENDING])
|
||||
->where('state', self::STATE_PUBLISHED);
|
||||
} elseif ($folder->type == Folder::TYPE_ASSIGNED) {
|
||||
|
||||
// Assigned - do not show my conversations
|
||||
$query_conversations = $folder->conversations()
|
||||
// This condition also removes from result records with user_id = null
|
||||
->where('user_id', '<>', $user_id)
|
||||
->where('state', Conversation::STATE_PUBLISHED);
|
||||
|
||||
->where('state', self::STATE_PUBLISHED);
|
||||
} elseif ($folder->type == Folder::TYPE_STARRED) {
|
||||
|
||||
$starred_conversation_ids = Conversation::getUserStarredConversationIds($folder->mailbox_id, $user_id);
|
||||
$query_conversations = Conversation::whereIn('id', $starred_conversation_ids);
|
||||
|
||||
$starred_conversation_ids = self::getUserStarredConversationIds($folder->mailbox_id, $user_id);
|
||||
$query_conversations = self::whereIn('id', $starred_conversation_ids);
|
||||
} elseif ($folder->isIndirect()) {
|
||||
|
||||
// Conversations are connected to folder via conversation_folder table.
|
||||
$query_conversations = Conversation::select('conversations.*')
|
||||
$query_conversations = self::select('conversations.*')
|
||||
//->where('conversations.mailbox_id', $folder->mailbox_id)
|
||||
->join('conversation_folder', 'conversations.id', '=', 'conversation_folder.conversation_id')
|
||||
->where('conversation_folder.folder_id', $folder->id);
|
||||
if ($folder->type != Folder::TYPE_DRAFTS) {
|
||||
$query_conversations->where('state', Conversation::STATE_PUBLISHED);
|
||||
$query_conversations->where('state', self::STATE_PUBLISHED);
|
||||
}
|
||||
|
||||
} elseif ($folder->type == Folder::TYPE_DELETED) {
|
||||
|
||||
$query_conversations = $folder->conversations()->where('state', Conversation::STATE_DELETED);
|
||||
|
||||
$query_conversations = $folder->conversations()->where('state', self::STATE_DELETED);
|
||||
} else {
|
||||
|
||||
$query_conversations = $folder->conversations()->where('state', Conversation::STATE_PUBLISHED);
|
||||
$query_conversations = $folder->conversations()->where('state', self::STATE_PUBLISHED);
|
||||
}
|
||||
|
||||
return $query_conversations;
|
||||
@ -905,7 +898,6 @@ class Conversation extends Model
|
||||
}
|
||||
|
||||
foreach ($conversations as $conversation) {
|
||||
|
||||
if (empty($conversation->user_id)) {
|
||||
continue;
|
||||
}
|
||||
@ -971,7 +963,7 @@ class Conversation extends Model
|
||||
}
|
||||
|
||||
$values = [
|
||||
'folder_id' => $folder->id,
|
||||
'folder_id' => $folder->id,
|
||||
'conversation_id' => $this->id,
|
||||
];
|
||||
$folder_exists = ConversationFolder::select('id')->where($values)->first();
|
||||
@ -980,7 +972,7 @@ class Conversation extends Model
|
||||
$this->folders()->attach($folder->id);
|
||||
}
|
||||
$folder->updateCounters();
|
||||
|
||||
|
||||
// updateOrCreate does not create properly with ManyToMany
|
||||
// $values = [
|
||||
// 'folder_id' => $folder->id,
|
||||
@ -1014,8 +1006,10 @@ class Conversation extends Model
|
||||
->first();
|
||||
if (!$has_drafts) {
|
||||
$this->removeFromFolder(Folder::TYPE_DRAFTS);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3,11 +3,10 @@
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
|
||||
class ConversationFolder extends Model
|
||||
{
|
||||
/**
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
@ -15,4 +14,4 @@ class ConversationFolder extends Model
|
||||
protected $table = 'conversation_folder';
|
||||
|
||||
protected $fillable = ['folder_id', 'conversation_id'];
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App;
|
||||
|
||||
use App\Email;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Watson\Rememberable\Rememberable;
|
||||
|
||||
@ -664,7 +663,7 @@ class Customer extends Model
|
||||
{
|
||||
$email = Email::sanitizeEmail($email);
|
||||
if (!$email) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
$email_obj = Email::where('email', $email)->first();
|
||||
if ($email_obj) {
|
||||
|
@ -3,17 +3,15 @@
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class RealtimeBroadcastNotificationCreated implements ShouldBroadcastNow
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
/**
|
||||
* The notifiable entity who received the notification.
|
||||
*
|
||||
* @var mixed
|
||||
@ -55,7 +53,7 @@ class RealtimeBroadcastNotificationCreated implements ShouldBroadcastNow
|
||||
{
|
||||
$channels = $this->notification->broadcastOn();
|
||||
|
||||
if (! empty($channels)) {
|
||||
if (!empty($channels)) {
|
||||
return $channels;
|
||||
}
|
||||
|
||||
@ -72,7 +70,7 @@ class RealtimeBroadcastNotificationCreated implements ShouldBroadcastNow
|
||||
public function broadcastWith()
|
||||
{
|
||||
return array_merge($this->data, [
|
||||
'id' => $this->notification->id,
|
||||
'id' => $this->notification->id,
|
||||
'type' => get_class($this->notification),
|
||||
]);
|
||||
// return [
|
||||
@ -95,4 +93,4 @@ class RealtimeBroadcastNotificationCreated implements ShouldBroadcastNow
|
||||
|
||||
return $class.'.'.$this->notifiable->getKey();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -166,12 +166,12 @@ class Folder extends Model
|
||||
*/
|
||||
public function isIndirect()
|
||||
{
|
||||
return in_array($this->type, Folder::$indirect_types);
|
||||
return in_array($this->type, self::$indirect_types);
|
||||
}
|
||||
|
||||
public function updateCounters()
|
||||
{
|
||||
if ($this->type == Folder::TYPE_MINE && $this->user_id) {
|
||||
if ($this->type == self::TYPE_MINE && $this->user_id) {
|
||||
$this->active_count = Conversation::where('user_id', $this->user_id)
|
||||
->where('mailbox_id', $this->mailbox_id)
|
||||
->where('status', Conversation::STATUS_ACTIVE)
|
||||
@ -181,10 +181,10 @@ class Folder extends Model
|
||||
->where('mailbox_id', $this->mailbox_id)
|
||||
->where('state', Conversation::STATE_PUBLISHED)
|
||||
->count();
|
||||
} elseif ($this->type == Folder::TYPE_STARRED) {
|
||||
} elseif ($this->type == self::TYPE_STARRED) {
|
||||
$this->active_count = count(Conversation::getUserStarredConversationIds($this->mailbox_id, $this->user_id));
|
||||
$this->total_count = $this->active_count;
|
||||
} elseif ($this->type == Folder::TYPE_DELETED) {
|
||||
} elseif ($this->type == self::TYPE_DELETED) {
|
||||
$this->active_count = $this->conversations()->where('state', Conversation::STATE_DELETED)
|
||||
->count();
|
||||
$this->total_count = $this->active_count;
|
||||
@ -210,13 +210,13 @@ class Folder extends Model
|
||||
public function getActiveCount($folders = [])
|
||||
{
|
||||
$active_count = $this->active_count;
|
||||
if ($this->type == Folder::TYPE_ASSIGNED) {
|
||||
if ($this->type == self::TYPE_ASSIGNED) {
|
||||
if ($folders) {
|
||||
$mine_folder = $folders->firstWhere('type', Folder::TYPE_MINE);
|
||||
$mine_folder = $folders->firstWhere('type', self::TYPE_MINE);
|
||||
} else {
|
||||
$mine_folder = $this->mailbox->folders()->where('type', Folder::TYPE_MINE)->first();
|
||||
$mine_folder = $this->mailbox->folders()->where('type', self::TYPE_MINE)->first();
|
||||
}
|
||||
|
||||
|
||||
if ($mine_folder) {
|
||||
$active_count = $active_count - $mine_folder->active_count;
|
||||
if ($active_count < 0) {
|
||||
|
@ -7,10 +7,10 @@ use App\Conversation;
|
||||
use App\Customer;
|
||||
use App\Events\ConversationStatusChanged;
|
||||
use App\Events\ConversationUserChanged;
|
||||
use App\Events\UserAddedNote;
|
||||
use App\Events\UserCreatedConversation;
|
||||
use App\Events\UserCreatedConversationDraft;
|
||||
use App\Events\UserCreatedThreadDraft;
|
||||
use App\Events\UserAddedNote;
|
||||
use App\Events\UserReplied;
|
||||
use App\Folder;
|
||||
use App\Mailbox;
|
||||
@ -80,6 +80,7 @@ class ConversationsController extends Controller
|
||||
->first();
|
||||
|
||||
\Session::reflash();
|
||||
|
||||
return redirect()->away($conversation->url($folder->id));
|
||||
}
|
||||
}
|
||||
@ -97,6 +98,7 @@ class ConversationsController extends Controller
|
||||
}
|
||||
|
||||
\Session::reflash();
|
||||
|
||||
return redirect()->away($conversation->url($folder->id));
|
||||
}
|
||||
|
||||
@ -156,14 +158,14 @@ class ConversationsController extends Controller
|
||||
}
|
||||
|
||||
return view($template, [
|
||||
'conversation' => $conversation,
|
||||
'mailbox' => $conversation->mailbox,
|
||||
'customer' => $customer,
|
||||
'threads' => $conversation->threads()->orderBy('created_at', 'desc')->get(),
|
||||
'folder' => $folder,
|
||||
'folders' => $conversation->mailbox->getAssesibleFolders(),
|
||||
'after_send' => $after_send,
|
||||
'to_customers' => $to_customers,
|
||||
'conversation' => $conversation,
|
||||
'mailbox' => $conversation->mailbox,
|
||||
'customer' => $customer,
|
||||
'threads' => $conversation->threads()->orderBy('created_at', 'desc')->get(),
|
||||
'folder' => $folder,
|
||||
'folders' => $conversation->mailbox->getAssesibleFolders(),
|
||||
'after_send' => $after_send,
|
||||
'to_customers' => $to_customers,
|
||||
'prev_conversations' => $prev_conversations,
|
||||
]);
|
||||
}
|
||||
@ -406,7 +408,7 @@ class ConversationsController extends Controller
|
||||
}
|
||||
|
||||
if ($validator->fails()) {
|
||||
foreach ($validator->errors() ->getMessages()as $errors) {
|
||||
foreach ($validator->errors()->getMessages()as $errors) {
|
||||
foreach ($errors as $field => $message) {
|
||||
$response['msg'] .= $message.' ';
|
||||
}
|
||||
@ -423,11 +425,11 @@ class ConversationsController extends Controller
|
||||
}
|
||||
|
||||
if (!$response['msg']) {
|
||||
|
||||
|
||||
// Get attachments info
|
||||
$attachments_info = $this->processReplyAttachments($request);
|
||||
|
||||
// Determine redirect.
|
||||
// Determine redirect.
|
||||
// Must be done before updating current conversation's status or assignee.
|
||||
if (!$new) {
|
||||
$response['redirect_url'] = $this->getRedirectUrl($request, $conversation, $user);
|
||||
@ -727,7 +729,7 @@ class ConversationsController extends Controller
|
||||
}
|
||||
//$thread->status = $request->status;
|
||||
$thread->state = Thread::STATE_DRAFT;
|
||||
|
||||
|
||||
$thread->source_via = Thread::PERSON_USER;
|
||||
$thread->source_type = Thread::SOURCE_TYPE_WEB;
|
||||
if ($customer) {
|
||||
@ -785,7 +787,7 @@ class ConversationsController extends Controller
|
||||
case 'discard_draft':
|
||||
|
||||
$thread = Thread::find($request->thread_id);
|
||||
|
||||
|
||||
if (!$thread) {
|
||||
// Discarding nont saved yet draft
|
||||
$response['status'] = 'success';
|
||||
@ -798,7 +800,7 @@ class ConversationsController extends Controller
|
||||
|
||||
if (!$response['msg']) {
|
||||
$conversation = $thread->conversation;
|
||||
|
||||
|
||||
if ($conversation->state == Conversation::STATE_DRAFT) {
|
||||
// New conversation draft being discarded
|
||||
$folder_id = $conversation->getCurrentFolder();
|
||||
@ -820,7 +822,7 @@ class ConversationsController extends Controller
|
||||
$conversation->mailbox->updateFoldersCounters(Folder::TYPE_DRAFTS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$response['status'] = 'success';
|
||||
}
|
||||
break;
|
||||
@ -841,10 +843,10 @@ class ConversationsController extends Controller
|
||||
if (!$response['msg']) {
|
||||
$response['data'] = [
|
||||
'thread_id' => $thread->id,
|
||||
'to' => $thread->getToFirst(),
|
||||
'cc' => $thread->getCcString(),
|
||||
'bcc' => $thread->getBccString(),
|
||||
'body' => $thread->body,
|
||||
'to' => $thread->getToFirst(),
|
||||
'cc' => $thread->getCcString(),
|
||||
'bcc' => $thread->getBccString(),
|
||||
'body' => $thread->body,
|
||||
];
|
||||
$response['status'] = 'success';
|
||||
}
|
||||
@ -881,7 +883,7 @@ class ConversationsController extends Controller
|
||||
$response = $this->ajaxConversationsFilter($request, $response, $user);
|
||||
} else {
|
||||
$response = $this->ajaxConversationsPagination($request, $response, $user);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// Change conversation customer
|
||||
@ -1021,7 +1023,7 @@ class ConversationsController extends Controller
|
||||
|
||||
return view('conversations/ajax_html/send_log', [
|
||||
'customers_log' => $customers_log,
|
||||
'users_log' => $users_log,
|
||||
'users_log' => $users_log,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -1136,7 +1138,7 @@ class ConversationsController extends Controller
|
||||
if (!$response['msg']) {
|
||||
$embedded = true;
|
||||
|
||||
if (!empty($request->attach) && (int)$request->attach) {
|
||||
if (!empty($request->attach) && (int) $request->attach) {
|
||||
$embedded = false;
|
||||
}
|
||||
|
||||
@ -1159,6 +1161,7 @@ class ConversationsController extends Controller
|
||||
$response['msg'] = __('Error occured uploading file');
|
||||
}
|
||||
}
|
||||
|
||||
return \Response::json($response);
|
||||
}
|
||||
|
||||
@ -1193,7 +1196,7 @@ class ConversationsController extends Controller
|
||||
$query_conversations = Conversation::getQueryByFolder($folder, $user->id);
|
||||
$conversations = $folder->queryAddOrderBy($query_conversations)->paginate(Conversation::DEFAULT_LIST_SIZE, ['*'], 'page', $request->page);
|
||||
}
|
||||
|
||||
|
||||
$response['status'] = 'success';
|
||||
|
||||
$response['html'] = view('conversations/conversations_table', [
|
||||
@ -1328,7 +1331,7 @@ class ConversationsController extends Controller
|
||||
|
||||
return [
|
||||
'has_attachments' => $has_attachments,
|
||||
'attachments' => $attachments,
|
||||
'attachments' => $attachments,
|
||||
];
|
||||
}
|
||||
|
||||
@ -1349,6 +1352,7 @@ class ConversationsController extends Controller
|
||||
// Check undo timeout
|
||||
if ($thread->created_at->diffInSeconds(now()) > Conversation::UNDO_TIMOUT) {
|
||||
\Session::flash('flash_error_floating', __('Sending can not be undone'));
|
||||
|
||||
return redirect()->away($conversation->url($conversation->folder_id));
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@ use App\Conversation;
|
||||
use App\Customer;
|
||||
use App\Email;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Validator;
|
||||
|
||||
class CustomersController extends Controller
|
||||
@ -73,7 +72,7 @@ class CustomersController extends Controller
|
||||
//'emails.1' => __('Email'),
|
||||
'emails.*' => __('Email'),
|
||||
]);
|
||||
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect()->route('customers.update', ['id' => $id])
|
||||
->withErrors($validator)
|
||||
@ -96,12 +95,12 @@ class CustomersController extends Controller
|
||||
foreach ($new_emails as $new_email) {
|
||||
$email = Email::where('email', $new_email)->first();
|
||||
if ($email && $email->customer) {
|
||||
// If customer whose email is removed does not have first name and other emails
|
||||
// If customer whose email is removed does not have first name and other emails
|
||||
// we have to create first name for this customer
|
||||
if (!$email->customer->first_name && count($email->customer->emails) == 1) {
|
||||
if ($request->first_name) {
|
||||
$email->customer->first_name = $request->first_name;
|
||||
} else if ($customer->first_name) {
|
||||
} elseif ($customer->first_name) {
|
||||
$email->customer->first_name = $customer->first_name;
|
||||
} else {
|
||||
$email->customer->first_name = mb_ucfirst($email->getNameFromEmail());
|
||||
@ -110,12 +109,12 @@ class CustomersController extends Controller
|
||||
}
|
||||
|
||||
$flash_message .= __('Email :tag_email_begin:email:tag_email_end has been moved from another customer: :a_begin:customer:a_end.', [
|
||||
'email' => $email->email,
|
||||
'email' => $email->email,
|
||||
'tag_email_begin' => '<strong>',
|
||||
'tag_email_end' => '</strong>',
|
||||
'customer' => $email->customer->getFullName(),
|
||||
'a_begin' => '<strong><a href="'.$email->customer->url().'" target="_blank">',
|
||||
'a_end' => '</a></strong>',
|
||||
'tag_email_end' => '</strong>',
|
||||
'customer' => $email->customer->getFullName(),
|
||||
'a_begin' => '<strong><a href="'.$email->customer->url().'" target="_blank">',
|
||||
'a_end' => '</a></strong>',
|
||||
]).' ';
|
||||
|
||||
$new_emails_change_customer[] = $email->email;
|
||||
@ -209,10 +208,10 @@ class CustomersController extends Controller
|
||||
->where('customer_id', $customer->id)
|
||||
->orderBy('created_at', 'desc')
|
||||
->paginate(Conversation::DEFAULT_LIST_SIZE);
|
||||
|
||||
|
||||
return view('customers/conversations', [
|
||||
'customer' => $customer,
|
||||
'conversations' => $conversations
|
||||
'conversations' => $conversations,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -222,8 +221,8 @@ class CustomersController extends Controller
|
||||
public function ajaxSearch(Request $request)
|
||||
{
|
||||
$response = [
|
||||
'results' => [],
|
||||
'pagination' => ['more' => false]
|
||||
'results' => [],
|
||||
'pagination' => ['more' => false],
|
||||
];
|
||||
|
||||
$q = $request->q;
|
||||
@ -247,8 +246,8 @@ class CustomersController extends Controller
|
||||
$id = $customer->email;
|
||||
}
|
||||
$response['results'][] = [
|
||||
'id' => $id,
|
||||
'text' => $text
|
||||
'id' => $id,
|
||||
'text' => $text,
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -337,7 +337,7 @@ class MailboxesController extends Controller
|
||||
}
|
||||
|
||||
return view('mailboxes/auto_reply', [
|
||||
'mailbox' => $mailbox
|
||||
'mailbox' => $mailbox,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -349,9 +349,9 @@ class MailboxesController extends Controller
|
||||
$mailbox = Mailbox::findOrFail($id);
|
||||
|
||||
$this->authorize('update', $mailbox);
|
||||
|
||||
|
||||
$request->merge([
|
||||
'auto_reply_enabled' => ($request->filled('auto_reply_enabled') ?? false)
|
||||
'auto_reply_enabled' => ($request->filled('auto_reply_enabled') ?? false),
|
||||
]);
|
||||
|
||||
if ($request->auto_reply_enabled) {
|
||||
@ -363,8 +363,8 @@ class MailboxesController extends Controller
|
||||
]);
|
||||
$validator->setAttributeNames([
|
||||
'auto_reply_subject' => __('Subject'),
|
||||
'auto_reply_message' => __('Message')
|
||||
]);
|
||||
'auto_reply_message' => __('Message'),
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect()->route('mailboxes.auto_reply', ['id' => $id])
|
||||
@ -482,7 +482,7 @@ class MailboxesController extends Controller
|
||||
$mailbox->users()->sync([]);
|
||||
$mailbox->folders()->delete();
|
||||
// Maybe remove notifications on events in this mailbox?
|
||||
|
||||
|
||||
$mailbox->delete();
|
||||
|
||||
\Session::flash('flash_success_floating', __('Mailbox deleted'));
|
||||
|
@ -104,7 +104,7 @@ class ModulesController extends Controller
|
||||
return view('modules/modules', [
|
||||
'installed_modules' => $installed_modules,
|
||||
'modules_directory' => $modules_directory,
|
||||
'flashes' => $flashes
|
||||
'flashes' => $flashes,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ class ModulesController extends Controller
|
||||
case 'install':
|
||||
case 'activate_license':
|
||||
$license = $request->license;
|
||||
$alias = $request->alias;
|
||||
$alias = $request->alias;
|
||||
|
||||
if (!$license) {
|
||||
$response['msg'] = __('Empty license key');
|
||||
@ -139,25 +139,25 @@ class ModulesController extends Controller
|
||||
|
||||
if (WpApi::$lastError) {
|
||||
$response['msg'] = WpApi::$lastError['message'];
|
||||
} else if (!empty($result['code']) && !empty($result['message'])) {
|
||||
} elseif (!empty($result['code']) && !empty($result['message'])) {
|
||||
$response['msg'] = $result['message'];
|
||||
} else {
|
||||
if (!empty($result['status']) && $result['status'] == 'valid') {
|
||||
|
||||
if ($request->action == 'install') {
|
||||
// Download and install module
|
||||
$license_details = WpApi::getVersion($params);
|
||||
|
||||
|
||||
if (WpApi::$lastError) {
|
||||
$response['msg'] = WpApi::$lastError['message'];
|
||||
} else if (!empty($license_details['code']) && !empty($license_details['message'])) {
|
||||
} elseif (!empty($license_details['code']) && !empty($license_details['message'])) {
|
||||
$response['msg'] = $license_details['message'];
|
||||
} elseif (!empty($license_details['download_link'])) {
|
||||
// Download module
|
||||
$module_archive = \Module::getPath().DIRECTORY_SEPARATOR.$alias.'.zip';
|
||||
|
||||
try {
|
||||
\Helper::downloadRemoteFile($license_details['download_link'], $module_archive);
|
||||
} catch(\Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
$response['msg'] = $e->getMessage();
|
||||
}
|
||||
|
||||
@ -168,7 +168,7 @@ class ModulesController extends Controller
|
||||
// Extract
|
||||
try {
|
||||
\Helper::unzip($module_archive, \Module::getPath());
|
||||
} catch(\Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
$response['msg'] = $e->getMessage();
|
||||
}
|
||||
// Check if extracted module exists
|
||||
@ -190,9 +190,7 @@ class ModulesController extends Controller
|
||||
|
||||
\Session::flash('flash_success_floating', __('Module successfully installed!'));
|
||||
$response['status'] = 'success';
|
||||
|
||||
} elseif ($download_error) {
|
||||
|
||||
$response['reload'] = true;
|
||||
|
||||
if ($response['msg']) {
|
||||
@ -211,7 +209,6 @@ class ModulesController extends Controller
|
||||
\Session::flash('flash_success_floating', __('License successfully activated!'));
|
||||
$response['status'] = 'success';
|
||||
}
|
||||
|
||||
} elseif (!empty($result['error'])) {
|
||||
switch ($result['error']) {
|
||||
case 'missing':
|
||||
@ -221,19 +218,19 @@ class ModulesController extends Controller
|
||||
$response['msg'] = __("You have to activate each bundle's module separately");
|
||||
break;
|
||||
case 'disabled':
|
||||
$response['msg'] = __("License key has been revoked");
|
||||
$response['msg'] = __('License key has been revoked');
|
||||
break;
|
||||
case 'no_activations_left':
|
||||
$response['msg'] = __("No activations left for this license key");
|
||||
$response['msg'] = __('No activations left for this license key');
|
||||
break;
|
||||
case 'expired':
|
||||
$response['msg'] = __("License key has expired");
|
||||
$response['msg'] = __('License key has expired');
|
||||
break;
|
||||
case 'key_mismatch':
|
||||
$response['msg'] = __("License key belongs to another module");
|
||||
$response['msg'] = __('License key belongs to another module');
|
||||
break;
|
||||
case 'invalid_item_id':
|
||||
$response['msg'] = __("Module not found in the modules directory");
|
||||
$response['msg'] = __('Module not found in the modules directory');
|
||||
break;
|
||||
default:
|
||||
$response['msg'] = __('Error code:'.' '.$result['error']);
|
||||
@ -250,7 +247,7 @@ class ModulesController extends Controller
|
||||
$alias = $request->alias;
|
||||
\App\Module::setActive($alias, true);
|
||||
|
||||
$outputLog = new BufferedOutput;
|
||||
$outputLog = new BufferedOutput();
|
||||
\Artisan::call('freescout:module-install', ['module_alias' => $alias], $outputLog);
|
||||
$output = $outputLog->fetch();
|
||||
|
||||
@ -285,7 +282,7 @@ class ModulesController extends Controller
|
||||
$alias = $request->alias;
|
||||
\App\Module::setActive($alias, false);
|
||||
|
||||
$outputLog = new BufferedOutput;
|
||||
$outputLog = new BufferedOutput();
|
||||
\Artisan::call('freescout:clear-cache', [], $outputLog);
|
||||
$output = $outputLog->fetch();
|
||||
|
||||
@ -318,7 +315,7 @@ class ModulesController extends Controller
|
||||
$module->delete();
|
||||
\Session::flash('flash_success_floating', __('Module deleted'));
|
||||
} else {
|
||||
$response['msg'] = __("Module not found").': '.$alias;
|
||||
$response['msg'] = __('Module not found').': '.$alias;
|
||||
}
|
||||
|
||||
$response['status'] = 'success';
|
||||
|
@ -17,7 +17,6 @@ class PublicController extends Controller
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -37,7 +36,6 @@ class PublicController extends Controller
|
||||
|
||||
/**
|
||||
* Save user from invitation.
|
||||
*
|
||||
*/
|
||||
public function userSetupSave($hash, Request $request)
|
||||
{
|
||||
|
@ -3,11 +3,9 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\ActivityLog;
|
||||
use App\Option;
|
||||
use App\SendLog;
|
||||
use App\Thread;
|
||||
use App\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SecureController extends Controller
|
||||
@ -63,7 +61,7 @@ class SecureController extends Controller
|
||||
$activities = ActivityLog::inLog($request->name)->orderBy('created_at', 'desc')->paginate($page_size);
|
||||
$name = $request->name;
|
||||
} elseif (count($names)) {
|
||||
$name = ActivityLog::NAME_OUT_EMAILS;
|
||||
$name = ActivityLog::NAME_OUT_EMAILS;
|
||||
// $activities = ActivityLog::inLog($names[0])->orderBy('created_at', 'desc')->paginate($page_size);
|
||||
// $name = $names[0];
|
||||
}
|
||||
@ -113,12 +111,11 @@ class SecureController extends Controller
|
||||
$activities = SendLog::orderBy('created_at', 'desc')->paginate($page_size);
|
||||
|
||||
foreach ($activities as $record) {
|
||||
|
||||
$conversation = '';
|
||||
if ($record->thread_id) {
|
||||
$conversation = Thread::find($record->thread_id);
|
||||
}
|
||||
|
||||
|
||||
$status = $record->getStatusName();
|
||||
if ($record->status_message) {
|
||||
$status .= '. '.$record->status_message;
|
||||
@ -134,7 +131,6 @@ class SecureController extends Controller
|
||||
'customer' => $record->customer,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
array_unshift($names, ActivityLog::NAME_OUT_EMAILS);
|
||||
@ -145,16 +141,16 @@ class SecureController extends Controller
|
||||
}
|
||||
|
||||
return view('secure/logs', [
|
||||
'logs' => $logs,
|
||||
'names' => $names,
|
||||
'logs' => $logs,
|
||||
'names' => $names,
|
||||
'current_name' => $name,
|
||||
'cols' => $cols,
|
||||
'activities' => $activities
|
||||
'cols' => $cols,
|
||||
'activities' => $activities,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs page submitted
|
||||
* Logs page submitted.
|
||||
*/
|
||||
public function logsSubmit(Request $request)
|
||||
{
|
||||
@ -165,7 +161,7 @@ class SecureController extends Controller
|
||||
$activities = ActivityLog::inLog($request->name)->orderBy('created_at', 'desc')->get();
|
||||
$name = $request->name;
|
||||
} elseif (count($names = ActivityLog::select('log_name')->distinct()->get()->pluck('log_name'))) {
|
||||
$name = ActivityLog::NAME_OUT_EMAILS;
|
||||
$name = ActivityLog::NAME_OUT_EMAILS;
|
||||
// $activities = ActivityLog::inLog($names[0])->orderBy('created_at', 'desc')->get();
|
||||
// $name = $names[0];
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ use App\Conversation;
|
||||
use App\Option;
|
||||
use App\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Validator;
|
||||
|
||||
class SettingsController extends Controller
|
||||
@ -22,12 +21,12 @@ class SettingsController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* General settings
|
||||
* General settings.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function view($section = 'general')
|
||||
{
|
||||
{
|
||||
$settings = $this->getSectionSettings($section);
|
||||
|
||||
if (!$settings) {
|
||||
@ -37,10 +36,10 @@ class SettingsController extends Controller
|
||||
$sections = $this->getSections();
|
||||
|
||||
$template_vars = [
|
||||
'settings' => $settings,
|
||||
'section' => $section,
|
||||
'sections' => $this->getSections(),
|
||||
'section_name' => $sections[$section]['title']
|
||||
'settings' => $settings,
|
||||
'section' => $section,
|
||||
'sections' => $this->getSections(),
|
||||
'section_name' => $sections[$section]['title'],
|
||||
];
|
||||
$template_vars = $this->getTemplateVars($section, $template_vars);
|
||||
|
||||
@ -63,7 +62,6 @@ class SettingsController extends Controller
|
||||
if (!empty($rules)) {
|
||||
return Validator::make(request()->all(), $rules);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getTemplateVars($section, $template_vars)
|
||||
@ -73,11 +71,11 @@ class SettingsController extends Controller
|
||||
$template_vars['sendmail_path'] = ini_get('sendmail_path');
|
||||
$template_vars['mail_drivers'] = [
|
||||
'mail' => __("PHP's mail() function"),
|
||||
'sendmail' => __("Sendmail"),
|
||||
'sendmail' => __('Sendmail'),
|
||||
'smtp' => 'SMTP',
|
||||
];
|
||||
break;
|
||||
|
||||
|
||||
// default:
|
||||
// $template_vars = \Event::fire('filter.settings_template_vars', [$template_vars]);
|
||||
// break;
|
||||
@ -102,12 +100,12 @@ class SettingsController extends Controller
|
||||
break;
|
||||
case 'emails':
|
||||
$settings = [
|
||||
'mail_from' => \App\Misc\Mail::getSystemMailFrom(),
|
||||
'mail_driver' => Option::get('mail_driver', \Config::get('mail.driver')),
|
||||
'mail_host' => Option::get('mail_host', \Config::get('mail.host')),
|
||||
'mail_port' => Option::get('mail_port', \Config::get('mail.port')),
|
||||
'mail_username' => Option::get('mail_username', \Config::get('mail.username')),
|
||||
'mail_password' => Option::get('mail_password', \Config::get('mail.password')),
|
||||
'mail_from' => \App\Misc\Mail::getSystemMailFrom(),
|
||||
'mail_driver' => Option::get('mail_driver', \Config::get('mail.driver')),
|
||||
'mail_host' => Option::get('mail_host', \Config::get('mail.host')),
|
||||
'mail_port' => Option::get('mail_port', \Config::get('mail.port')),
|
||||
'mail_username' => Option::get('mail_username', \Config::get('mail.username')),
|
||||
'mail_password' => Option::get('mail_password', \Config::get('mail.password')),
|
||||
'mail_encryption' => Option::get('mail_encryption', \Config::get('mail.encryption')),
|
||||
];
|
||||
break;
|
||||
@ -169,8 +167,8 @@ class SettingsController extends Controller
|
||||
$request = request();
|
||||
|
||||
$request->settings = array_merge($request->settings, [
|
||||
'email_branding' => !empty($request->settings['email_branding']) ? $request->settings['email_branding'] : 0,
|
||||
'open_tracking' => !empty($request->settings['open_tracking']) ? $request->settings['open_tracking'] : 0,
|
||||
'email_branding' => !empty($request->settings['email_branding']) ? $request->settings['email_branding'] : 0,
|
||||
'open_tracking' => !empty($request->settings['open_tracking']) ? $request->settings['open_tracking'] : 0,
|
||||
'enrich_customer_data' => !empty($request->settings['enrich_customer_data']) ? $request->settings['enrich_customer_data'] : 0,
|
||||
]);
|
||||
|
||||
|
@ -134,7 +134,7 @@ class SystemController extends Controller
|
||||
|
||||
// Check new version
|
||||
$new_version_available = false;
|
||||
$latest_version = \Cache::remember('latest_version', 15, function() {
|
||||
$latest_version = \Cache::remember('latest_version', 15, function () {
|
||||
return \Updater::getVersionAvailable();
|
||||
});
|
||||
|
||||
@ -143,12 +143,12 @@ class SystemController extends Controller
|
||||
}
|
||||
|
||||
return view('system/status', [
|
||||
'commands' => $commands,
|
||||
'queued_jobs' => $queued_jobs,
|
||||
'failed_jobs' => $failed_jobs,
|
||||
'php_extensions' => $php_extensions,
|
||||
'commands' => $commands,
|
||||
'queued_jobs' => $queued_jobs,
|
||||
'failed_jobs' => $failed_jobs,
|
||||
'php_extensions' => $php_extensions,
|
||||
'new_version_available' => $new_version_available,
|
||||
'latest_version' => $latest_version,
|
||||
'latest_version' => $latest_version,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -163,18 +163,20 @@ class SystemController extends Controller
|
||||
}
|
||||
|
||||
return view('system/tools', [
|
||||
'output' => $output
|
||||
'output' => $output,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute tools action.
|
||||
* @param Request $request [description]
|
||||
* @return [type] [description]
|
||||
*
|
||||
* @param Request $request [description]
|
||||
*
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function toolsExecute(Request $request)
|
||||
{
|
||||
$outputLog = new BufferedOutput;
|
||||
$outputLog = new BufferedOutput();
|
||||
|
||||
switch ($request->action) {
|
||||
case 'clear_cache':
|
||||
|
@ -221,8 +221,8 @@ class UsersController extends Controller
|
||||
$users = $this->getUsersForSidebar($id);
|
||||
|
||||
return view('users/permissions', [
|
||||
'user' => $user,
|
||||
'mailboxes' => $mailboxes,
|
||||
'user' => $user,
|
||||
'mailboxes' => $mailboxes,
|
||||
'user_mailboxes' => $user->mailboxes,
|
||||
'users' => $users,
|
||||
]);
|
||||
@ -240,7 +240,7 @@ class UsersController extends Controller
|
||||
if (!$user->isAdmin()) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
|
||||
$user = User::findOrFail($id);
|
||||
|
||||
$user->mailboxes()->sync($request->mailboxes);
|
||||
@ -311,10 +311,10 @@ class UsersController extends Controller
|
||||
// Both send and resend
|
||||
case 'send_invite':
|
||||
if (!$auth_user->isAdmin()) {
|
||||
$response['msg'] = __('Not enough permissions');
|
||||
$response['msg'] = __('Not enough permissions');
|
||||
}
|
||||
if (empty($request->user_id)) {
|
||||
$response['msg'] = __('Incorrect user');
|
||||
$response['msg'] = __('Incorrect user');
|
||||
}
|
||||
if (!$response['msg']) {
|
||||
$user = User::find($request->user_id);
|
||||
@ -340,10 +340,10 @@ class UsersController extends Controller
|
||||
// Reset password
|
||||
case 'reset_password':
|
||||
if (!auth()->user()->isAdmin()) {
|
||||
$response['msg'] = __('Not enough permissions');
|
||||
$response['msg'] = __('Not enough permissions');
|
||||
}
|
||||
if (empty($request->user_id)) {
|
||||
$response['msg'] = __('Incorrect user');
|
||||
$response['msg'] = __('Incorrect user');
|
||||
}
|
||||
if (!$response['msg']) {
|
||||
$user = User::find($request->user_id);
|
||||
@ -368,7 +368,7 @@ class UsersController extends Controller
|
||||
// Load website notifications
|
||||
case 'web_notifications':
|
||||
if (!$auth_user) {
|
||||
$response['msg'] = __('You are not logged in');
|
||||
$response['msg'] = __('You are not logged in');
|
||||
}
|
||||
if (!$response['msg']) {
|
||||
$web_notifications_info = $auth_user->getWebsiteNotificationsInfo(false);
|
||||
@ -376,8 +376,8 @@ class UsersController extends Controller
|
||||
'web_notifications_info_data' => $web_notifications_info['data'],
|
||||
])->render();
|
||||
|
||||
$response['has_more_pages'] = (int)$web_notifications_info['notifications']->hasMorePages();
|
||||
|
||||
$response['has_more_pages'] = (int) $web_notifications_info['notifications']->hasMorePages();
|
||||
|
||||
$response['status'] = 'success';
|
||||
}
|
||||
break;
|
||||
@ -385,7 +385,7 @@ class UsersController extends Controller
|
||||
// Mark all user website notifications as read
|
||||
case 'mark_notifications_as_read':
|
||||
if (!$auth_user) {
|
||||
$response['msg'] = __('You are not logged in');
|
||||
$response['msg'] = __('You are not logged in');
|
||||
}
|
||||
if (!$response['msg']) {
|
||||
$auth_user->unreadNotifications()->update(['read_at' => now()]);
|
||||
@ -431,7 +431,6 @@ class UsersController extends Controller
|
||||
}
|
||||
|
||||
if (!$response['msg']) {
|
||||
|
||||
event(new UserDeleted($user, $auth_user));
|
||||
|
||||
// We have to process conversations one by one to set move them to Unassigned folder,
|
||||
@ -533,7 +532,7 @@ class UsersController extends Controller
|
||||
// Check current password
|
||||
if (!Hash::check($request->password_current, $user->password)) {
|
||||
$validator->errors()->add('password_current', __('This password is incorrect.'));
|
||||
} else if (Hash::check($request->password, $user->password)) {
|
||||
} elseif (Hash::check($request->password, $user->password)) {
|
||||
// Check new password
|
||||
$validator->errors()->add('password', __('The new password is the same as the old password.'));
|
||||
}
|
||||
|
@ -2,24 +2,26 @@
|
||||
|
||||
/**
|
||||
* Redirect to HTTPS if force_redirect is enabled.
|
||||
*
|
||||
*
|
||||
* https://stackoverflow.com/questions/28402726/laravel-5-redirect-to-https
|
||||
*/
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\App;
|
||||
|
||||
class HttpsRedirect {
|
||||
|
||||
class HttpsRedirect
|
||||
{
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if (\Config::get('app.force_https') == 'true') {
|
||||
$request->setTrustedProxies( [ $request->getClientIp() ] );
|
||||
$request->setTrustedProxies([$request->getClientIp()]);
|
||||
if (!$request->secure() /*&& App::environment() === 'production'*/) {
|
||||
return redirect()->secure($request->getRequestUri());
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,9 +12,9 @@ class ResponseHeaders
|
||||
|
||||
// Disable caching
|
||||
if (method_exists($response, 'header')) {
|
||||
$response->header('Pragma', 'no-cache');
|
||||
$response->header('Cache-Control', 'no-cache, max-age=0, must-revalidate, no-store');
|
||||
}
|
||||
$response->header('Pragma', 'no-cache');
|
||||
$response->header('Cache-Control', 'no-cache, max-age=0, must-revalidate, no-store');
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
@ -2,11 +2,12 @@
|
||||
/**
|
||||
* Send alert to super admin.
|
||||
*/
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Mail\Alert;
|
||||
use App\SendLog;
|
||||
use App\User;
|
||||
use App\Mail\Alert;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
@ -41,7 +42,7 @@ class SendAlert implements ShouldQueue
|
||||
{
|
||||
// Configure mail driver according to Mailbox settings
|
||||
\MailHelper::setSystemMailDriver();
|
||||
|
||||
|
||||
$recipients = [];
|
||||
|
||||
$super_admin = User::getSuperAdmin();
|
||||
|
@ -56,9 +56,9 @@ class SendAutoReply implements ShouldQueue
|
||||
|
||||
$customer_email = $this->conversation->customer_email;
|
||||
$recipients = [$customer_email];
|
||||
$failures = [];
|
||||
$exception = null;
|
||||
|
||||
$failures = [];
|
||||
$exception = null;
|
||||
|
||||
try {
|
||||
Mail::to([['name' => $this->customer->getFullName(), 'email' => $customer_email]])
|
||||
->send(new AutoReply($this->conversation, $this->mailbox, $this->customer, $headers));
|
||||
|
@ -7,7 +7,6 @@ namespace App\Jobs;
|
||||
|
||||
use App\Mail\UserEmailReplyError;
|
||||
use App\SendLog;
|
||||
use App\Thread;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
@ -48,6 +47,7 @@ class SendEmailReplyError implements ShouldQueue
|
||||
\App\Misc\Mail::setMailDriver($this->mailbox);
|
||||
|
||||
$exception = null;
|
||||
|
||||
try {
|
||||
Mail::to([['name' => '', 'email' => $this->from]])
|
||||
->send(new UserEmailReplyError());
|
||||
|
@ -57,7 +57,7 @@ class SendNotificationToUsers
|
||||
// We can not check imported here, as after conversation has been imported via API
|
||||
// notifications has to be sent.
|
||||
//if (!$conversation->imported) {
|
||||
|
||||
|
||||
// Using the last argument you can make event to be processed immediately
|
||||
Subscription::registerEvent($event_type, $conversation, $caused_by_user_id/*, true*/);
|
||||
}
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Contracts\Mail\Mailer as MailerContract;
|
||||
use Illuminate\Mail\Mailable;
|
||||
|
||||
class Alert extends Mailable
|
||||
@ -20,7 +18,6 @@ class Alert extends Mailable
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
*/
|
||||
public function __construct($text, $title = '')
|
||||
{
|
||||
|
@ -2,41 +2,32 @@
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Contracts\Mail\Mailer as MailerContract;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class AutoReply extends Mailable
|
||||
{
|
||||
/**
|
||||
* Conversation created by customer.
|
||||
*
|
||||
*/
|
||||
public $conversation;
|
||||
|
||||
/**
|
||||
* Mailbox.
|
||||
*
|
||||
*/
|
||||
public $mailbox;
|
||||
|
||||
/**
|
||||
* Customer.
|
||||
*
|
||||
*/
|
||||
public $customer;
|
||||
|
||||
/**
|
||||
* Custom headers.
|
||||
*
|
||||
*/
|
||||
public $headers = [];
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
*/
|
||||
public function __construct($conversation, $mailbox, $customer, $headers)
|
||||
{
|
||||
|
@ -2,12 +2,7 @@
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Option;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Contracts\Mail\Mailer as MailerContract;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class PasswordChanged extends Mailable
|
||||
{
|
||||
@ -18,7 +13,6 @@ class PasswordChanged extends Mailable
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
*/
|
||||
public function __construct($user)
|
||||
{
|
||||
|
@ -2,11 +2,9 @@
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Contracts\Mail\Mailer as MailerContract;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
// https://medium.com/@guysmilez/queuing-mailables-with-custom-headers-in-laravel-5-4-ab615f022f17
|
||||
//abstract class AbstractMessage extends Mailable
|
||||
@ -92,7 +90,7 @@ class ReplyToCustomer extends Mailable
|
||||
|
||||
if ($this->threads->first()->has_attachments) {
|
||||
foreach ($this->threads->first()->attachments as $attachment) {
|
||||
$message->attach($attachment->getLocalFilePath());
|
||||
$message->attach($attachment->getLocalFilePath());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Contracts\Mail\Mailer as MailerContract;
|
||||
use Illuminate\Mail\Mailable;
|
||||
|
||||
class Test extends Mailable
|
||||
@ -12,7 +10,6 @@ class Test extends Mailable
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
*/
|
||||
public function __construct($mailbox = null)
|
||||
{
|
||||
|
@ -2,11 +2,10 @@
|
||||
/**
|
||||
* User replied from wrong email address to the email notification.
|
||||
*/
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class UserEmailReplyError extends Mailable
|
||||
{
|
||||
@ -17,7 +16,6 @@ class UserEmailReplyError extends Mailable
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,11 +3,7 @@
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Option;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Contracts\Mail\Mailer as MailerContract;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class UserInvite extends Mailable
|
||||
{
|
||||
@ -18,7 +14,6 @@ class UserInvite extends Mailable
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
*/
|
||||
public function __construct($user)
|
||||
{
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class UserNotification extends Mailable
|
||||
{
|
||||
@ -45,7 +43,7 @@ class UserNotification extends Mailable
|
||||
|
||||
/**
|
||||
* Mailbox.
|
||||
*
|
||||
*
|
||||
* @var [type]
|
||||
*/
|
||||
public $mailbox;
|
||||
|
@ -440,7 +440,7 @@ class Mailbox extends Model
|
||||
|
||||
/**
|
||||
* Get main email and aliases.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getEmails()
|
||||
@ -456,13 +456,14 @@ class Mailbox extends Model
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $emails;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove mailbox email and aliases from the list of emails.
|
||||
*
|
||||
* @param array $list
|
||||
* @param array $list
|
||||
* @param Mailbox $mailbox
|
||||
*
|
||||
* @return array
|
||||
|
@ -3,6 +3,7 @@
|
||||
/**
|
||||
* Class for defining common app functions.
|
||||
*/
|
||||
|
||||
namespace App\Misc;
|
||||
|
||||
class Helper
|
||||
@ -24,48 +25,48 @@ class Helper
|
||||
*/
|
||||
public static $menu = [
|
||||
'dashboard' => 'dashboard',
|
||||
'mailbox' => [
|
||||
'mailbox' => [
|
||||
'mailboxes.view',
|
||||
'conversations.view',
|
||||
'conversations.create',
|
||||
'conversations.draft',
|
||||
'conversations.search',
|
||||
'conversations.view',
|
||||
'conversations.create',
|
||||
'conversations.draft',
|
||||
'conversations.search',
|
||||
],
|
||||
'manage' => [
|
||||
'settings' => 'settings',
|
||||
'settings' => 'settings',
|
||||
'mailboxes' => [
|
||||
'mailboxes',
|
||||
'mailboxes.update',
|
||||
'mailboxes.create',
|
||||
'mailboxes.connection',
|
||||
'mailboxes.connection.incoming',
|
||||
'mailboxes.permissions',
|
||||
'mailboxes.auto_reply',
|
||||
'mailboxes',
|
||||
'mailboxes.update',
|
||||
'mailboxes.create',
|
||||
'mailboxes.connection',
|
||||
'mailboxes.connection.incoming',
|
||||
'mailboxes.permissions',
|
||||
'mailboxes.auto_reply',
|
||||
],
|
||||
'users' => [
|
||||
'users',
|
||||
'users.create',
|
||||
'users.profile',
|
||||
'users.permissions',
|
||||
'users.notifications',
|
||||
'users.password',
|
||||
'users',
|
||||
'users.create',
|
||||
'users.profile',
|
||||
'users.permissions',
|
||||
'users.notifications',
|
||||
'users.password',
|
||||
],
|
||||
'logs' => [
|
||||
'logs',
|
||||
'logs',
|
||||
'logs.app',
|
||||
],
|
||||
'system' => [
|
||||
'system',
|
||||
'system',
|
||||
'system.tools',
|
||||
],
|
||||
],
|
||||
// No menu item selected
|
||||
'customers' => []
|
||||
'customers' => [],
|
||||
];
|
||||
|
||||
public static $locales = [
|
||||
'af' => ['name' => 'Afrikaans',
|
||||
'en' => 'Afrikaans',
|
||||
'en' => 'Afrikaans',
|
||||
],
|
||||
'sq' => ['name' => 'Shqip',
|
||||
'en' => 'Albanian',
|
||||
@ -302,7 +303,7 @@ class Helper
|
||||
'en' => 'Portuguese (Portugal)',
|
||||
],
|
||||
'pt_BR' => ['name' => 'Português do Brasil',
|
||||
'en' => 'Portuguese (Brazil)',
|
||||
'en' => 'Portuguese (Brazil)',
|
||||
],
|
||||
'ro' => ['name' => 'Română',
|
||||
'en' => 'Romanian',
|
||||
@ -505,7 +506,7 @@ class Helper
|
||||
foreach ($menu as $primary_name => $primary_items) {
|
||||
if (!is_array($primary_items)) {
|
||||
if ($current_route == $primary_items) {
|
||||
return ($primary_name == $menu_item_name);
|
||||
return $primary_name == $menu_item_name;
|
||||
}
|
||||
if ($primary_name == $menu_item_name) {
|
||||
return false;
|
||||
@ -515,19 +516,20 @@ class Helper
|
||||
foreach ($primary_items as $secondary_name => $secondary_routes) {
|
||||
if (is_array($secondary_routes)) {
|
||||
if (in_array($current_route, $secondary_routes)) {
|
||||
return ($secondary_name == $menu_item_name || $primary_name == $menu_item_name);
|
||||
return $secondary_name == $menu_item_name || $primary_name == $menu_item_name;
|
||||
}
|
||||
} elseif (is_string($secondary_name)) {
|
||||
if ($current_route == $secondary_routes) {
|
||||
return ($secondary_name == $menu_item_name || $primary_name == $menu_item_name);
|
||||
return $secondary_name == $menu_item_name || $primary_name == $menu_item_name;
|
||||
}
|
||||
} else {
|
||||
if ($current_route == $secondary_routes) {
|
||||
return ($primary_name == $menu_item_name);
|
||||
return $primary_name == $menu_item_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -540,7 +542,6 @@ class Helper
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resize image without using Intervention package.
|
||||
*/
|
||||
@ -553,27 +554,27 @@ class Helper
|
||||
|
||||
if (preg_match('/png/i', $mime_type)) {
|
||||
$src = imagecreatefrompng($file);
|
||||
} else if (preg_match('/gif/i', $mime_type)) {
|
||||
} elseif (preg_match('/gif/i', $mime_type)) {
|
||||
$src = imagecreatefromgif($file);
|
||||
} else if (preg_match('/bmp/i', $mime_type)) {
|
||||
} elseif (preg_match('/bmp/i', $mime_type)) {
|
||||
$src = imagecreatefrombmp($file);
|
||||
} else {
|
||||
$src = imagecreatefromjpeg($file);
|
||||
}
|
||||
|
||||
|
||||
$original_aspect = $width / $height;
|
||||
$thumb_aspect = $thumb_width / $thumb_height;
|
||||
if ( $original_aspect == $thumb_aspect ) {
|
||||
if ($original_aspect == $thumb_aspect) {
|
||||
$new_height = $thumb_height;
|
||||
$new_width = $thumb_width;
|
||||
} elseif ( $original_aspect > $thumb_aspect ) {
|
||||
// If image is wider than thumbnail (in aspect ratio sense)
|
||||
$new_height = $thumb_height;
|
||||
$new_width = $width / ($height / $thumb_height);
|
||||
} elseif ($original_aspect > $thumb_aspect) {
|
||||
// If image is wider than thumbnail (in aspect ratio sense)
|
||||
$new_height = $thumb_height;
|
||||
$new_width = $width / ($height / $thumb_height);
|
||||
} else {
|
||||
// If the thumbnail is wider than the image
|
||||
$new_width = $thumb_width;
|
||||
$new_height = $height / ($width / $thumb_width);
|
||||
// If the thumbnail is wider than the image
|
||||
$new_width = $thumb_width;
|
||||
$new_height = $height / ($width / $thumb_width);
|
||||
}
|
||||
|
||||
$thumb = imagecreatetruecolor($thumb_width, $thumb_height);
|
||||
@ -600,6 +601,7 @@ class Helper
|
||||
if ($array && $exclude_array) {
|
||||
$array = array_diff($array, $exclude_array);
|
||||
}
|
||||
|
||||
return $array;
|
||||
} else {
|
||||
return [];
|
||||
@ -614,7 +616,7 @@ class Helper
|
||||
/**
|
||||
* Create zip archive.
|
||||
* Source example: public/files/*
|
||||
* File name example: test.zip
|
||||
* File name example: test.zip.
|
||||
*/
|
||||
public static function createZipArchive($source, $file_name, $folder = '')
|
||||
{
|
||||
@ -656,9 +658,11 @@ class Helper
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if application version
|
||||
* @param [type] $ver [description]
|
||||
* @return [type] [description]
|
||||
* Check if application version.
|
||||
*
|
||||
* @param [type] $ver [description]
|
||||
*
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public static function checkAppVersion($version2, $operator = '>=')
|
||||
{
|
||||
@ -678,7 +682,7 @@ class Helper
|
||||
|
||||
/**
|
||||
* Extract ZIP archive.
|
||||
* to: must be apsolute path, otherwise extracted into /public/$to
|
||||
* to: must be apsolute path, otherwise extracted into /public/$to.
|
||||
*/
|
||||
public static function unzip($archive, $to)
|
||||
{
|
||||
|
@ -35,8 +35,8 @@ class Mail
|
||||
* Encryptions.
|
||||
*/
|
||||
const MAIL_ENCRYPTION_NONE = '';
|
||||
const MAIL_ENCRYPTION_SSL = 'ssl';
|
||||
const MAIL_ENCRYPTION_TLS = 'tls';
|
||||
const MAIL_ENCRYPTION_SSL = 'ssl';
|
||||
const MAIL_ENCRYPTION_TLS = 'tls';
|
||||
|
||||
/**
|
||||
* If reply is not extracted properly from the incoming email, add here new separator.
|
||||
@ -89,8 +89,8 @@ class Mail
|
||||
{
|
||||
\Config::set('mail.driver', self::getSystemMailDriver());
|
||||
\Config::set('mail.from', [
|
||||
'address' => self::getSystemMailFrom(),
|
||||
'name' => Option::get('company_name', \Config::get('app.name'))
|
||||
'address' => self::getSystemMailFrom(),
|
||||
'name' => Option::get('company_name', \Config::get('app.name')),
|
||||
]);
|
||||
|
||||
// SMTP
|
||||
@ -114,18 +114,18 @@ class Mail
|
||||
$vars = [];
|
||||
|
||||
if (!empty($data['conversation'])) {
|
||||
$vars['{%subject%}'] = $data['conversation']->subject;
|
||||
$vars['{%conversation.number%}'] = $data['conversation']->number;
|
||||
$vars['{%customer.email%}'] = $data['conversation']->customer_email;
|
||||
$vars['{%subject%}'] = $data['conversation']->subject;
|
||||
$vars['{%conversation.number%}'] = $data['conversation']->number;
|
||||
$vars['{%customer.email%}'] = $data['conversation']->customer_email;
|
||||
}
|
||||
if (!empty($data['mailbox'])) {
|
||||
$vars['{%mailbox.email%}'] = $data['mailbox']->email;
|
||||
$vars['{%mailbox.name%}'] = $data['mailbox']->name;
|
||||
$vars['{%mailbox.email%}'] = $data['mailbox']->email;
|
||||
$vars['{%mailbox.name%}'] = $data['mailbox']->name;
|
||||
}
|
||||
if (!empty($data['customer'])) {
|
||||
$vars['{%customer.fullName%}'] = $data['customer']->getFullName(true);
|
||||
$vars['{%customer.fullName%}'] = $data['customer']->getFullName(true);
|
||||
$vars['{%customer.firstName%}'] = $data['customer']->getFirstName(true);
|
||||
$vars['{%customer.lastName%}'] = $data['customer']->last_name;
|
||||
$vars['{%customer.lastName%}'] = $data['customer']->last_name;
|
||||
}
|
||||
|
||||
return strtr($text, $vars);
|
||||
@ -136,7 +136,7 @@ class Mail
|
||||
*/
|
||||
public static function hasVars($text)
|
||||
{
|
||||
return preg_match("/({%|%})/", $text);
|
||||
return preg_match('/({%|%})/', $text);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -156,6 +156,7 @@ class Mail
|
||||
if (!$mail_from) {
|
||||
$mail_from = 'freescout@'.\Helper::getDomain();
|
||||
}
|
||||
|
||||
return $mail_from;
|
||||
}
|
||||
|
||||
@ -177,6 +178,7 @@ class Mail
|
||||
\MailHelper::setMailDriver($mailbox);
|
||||
|
||||
$status_message = '';
|
||||
|
||||
try {
|
||||
\Mail::to([$to])->send(new \App\Mail\Test($mailbox));
|
||||
} catch (\Exception $e) {
|
||||
@ -188,6 +190,7 @@ class Mail
|
||||
\MailHelper::setSystemMailDriver();
|
||||
|
||||
$status_message = '';
|
||||
|
||||
try {
|
||||
\Mail::to([['name' => '', 'email' => $to]])
|
||||
->send(new \App\Mail\Test());
|
||||
@ -206,6 +209,7 @@ class Mail
|
||||
}
|
||||
} else {
|
||||
SendLog::log(null, null, $to, SendLog::MAIL_TYPE_TEST, SendLog::STATUS_ACCEPTED);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -286,8 +290,9 @@ class Mail
|
||||
\MailHelper::setSystemMailDriver();
|
||||
|
||||
$status_message = '';
|
||||
|
||||
try {
|
||||
\Mail::raw($body, function($message) use ($subject, $attachments, $from_user) {
|
||||
\Mail::raw($body, function ($message) use ($subject, $attachments, $from_user) {
|
||||
$message
|
||||
->subject($subject)
|
||||
->to(\Config::get('app.freescout_email'));
|
||||
|
@ -11,9 +11,9 @@ class WpApi
|
||||
const METHOD_GET = 'get';
|
||||
const METHOD_POST = 'post';
|
||||
|
||||
const ACTION_CHECK_LICENSE = 'check_license';
|
||||
const ACTION_CHECK_LICENSE = 'check_license';
|
||||
const ACTION_ACTIVATE_LICENSE = 'activate_license';
|
||||
const ACTION_GET_VERSION = 'get_version';
|
||||
const ACTION_GET_VERSION = 'get_version';
|
||||
|
||||
public static $lastError;
|
||||
|
||||
@ -32,17 +32,18 @@ class WpApi
|
||||
try {
|
||||
$response = Zttp::$method(self::url($endpoint), $params);
|
||||
} catch (\Exception $e) {
|
||||
self::$lastError = array(
|
||||
'code' => $e->getCode(),
|
||||
self::$lastError = [
|
||||
'code' => $e->getCode(),
|
||||
'message' => $e->getMessage(),
|
||||
);
|
||||
];
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
// https://guzzle3.readthedocs.io/http-client/response.html
|
||||
if ($response->status() < 500) {
|
||||
$json = $response->json();
|
||||
if (!empty($json['code']) && !empty($json['message']) &&
|
||||
if (!empty($json['code']) && !empty($json['message']) &&
|
||||
!empty($json['data']) && !empty($json['data']['status']) && $json['data']['status'] != 200
|
||||
) {
|
||||
self::$lastError = $json;
|
||||
|
@ -3,6 +3,7 @@
|
||||
* 'active' parameter in module.json is not taken in account.
|
||||
* Module 'active' flag is taken from DB.
|
||||
*/
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@ -20,15 +21,16 @@ class Module extends Model
|
||||
|
||||
public static function getCached()
|
||||
{
|
||||
if (!self::$modules) {
|
||||
if (!self::$modules) {
|
||||
// At this stage modules table may not exist
|
||||
try {
|
||||
self::$modules = Module::all();
|
||||
self::$modules = self::all();
|
||||
} catch (\Exception $e) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
return self::$modules;
|
||||
}
|
||||
|
||||
return self::$modules;
|
||||
}
|
||||
|
||||
public static function isActive($alias)
|
||||
@ -48,6 +50,7 @@ class Module extends Model
|
||||
if ($save) {
|
||||
$module->save();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -76,9 +79,11 @@ class Module extends Model
|
||||
|
||||
/**
|
||||
* Activate module license.
|
||||
* @param [type] $alias [description]
|
||||
* @param [type] $details_url [description]
|
||||
* @return boolean [description]
|
||||
*
|
||||
* @param [type] $alias [description]
|
||||
* @param [type] $details_url [description]
|
||||
*
|
||||
* @return bool [description]
|
||||
*/
|
||||
public static function activateLicense($alias, $license)
|
||||
{
|
||||
@ -100,9 +105,10 @@ class Module extends Model
|
||||
{
|
||||
$module = self::getByAlias($alias);
|
||||
if (!$module) {
|
||||
$module = new Module();
|
||||
$module = new self();
|
||||
$module->alias = $alias;
|
||||
}
|
||||
|
||||
return $module;
|
||||
}
|
||||
|
||||
@ -130,7 +136,7 @@ class Module extends Model
|
||||
if ($modules) {
|
||||
return self::getCached()->where('alias', $alias)->first();
|
||||
} else {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@ namespace App\Notifications;
|
||||
use App\Conversation;
|
||||
use App\Subscription;
|
||||
use App\Thread;
|
||||
use App\Channels\RealtimeBroadcastChannel;
|
||||
use Illuminate\Notifications\Messages\BroadcastMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
@ -34,7 +33,8 @@ class BroadcastNotification extends Notification
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $user
|
||||
* @param mixed $user
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function via($user)
|
||||
@ -47,7 +47,8 @@ class BroadcastNotification extends Notification
|
||||
/**
|
||||
* Get the broadcastable representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @param mixed $notifiable
|
||||
*
|
||||
* @return BroadcastMessage
|
||||
*/
|
||||
public function toBroadcast($user)
|
||||
@ -78,7 +79,6 @@ class BroadcastNotification extends Notification
|
||||
|
||||
// HTML for the menu notification (uses same medium as for email)
|
||||
if (in_array(Subscription::MEDIUM_EMAIL, $payload->mediums)) {
|
||||
|
||||
$web_notifications_info = [];
|
||||
|
||||
// Get last reply or note of the conversation to display it's text
|
||||
|
@ -2,6 +2,7 @@
|
||||
/**
|
||||
* Website notification (DB notification).
|
||||
*/
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Conversation;
|
||||
@ -28,7 +29,8 @@ class WebsiteNotification extends Notification
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $user
|
||||
* @param mixed $user
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function via($user)
|
||||
@ -39,13 +41,14 @@ class WebsiteNotification extends Notification
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*
|
||||
* @param mixed $user
|
||||
* @param mixed $user
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($user)
|
||||
{
|
||||
return [
|
||||
'thread_id' => $this->thread->id,
|
||||
'thread_id' => $this->thread->id,
|
||||
'conversation_id' => $this->conversation->id,
|
||||
];
|
||||
}
|
||||
@ -94,7 +97,6 @@ class WebsiteNotification extends Notification
|
||||
|
||||
// Populate all collected data into array
|
||||
foreach ($notifications as $notification) {
|
||||
|
||||
$conversation_number = '';
|
||||
if (!empty($notification->data['number'])) {
|
||||
$conversation_number = $notification->data['number'];
|
||||
|
@ -12,7 +12,7 @@ class SendLogObserver
|
||||
public function created(SendLog $send_log)
|
||||
{
|
||||
// Update status for thread if any
|
||||
if ($send_log->thread_id && ($send_log->customer_id || ($send_log->user_id && $send_log->user_id == $send_log->thread->user_id)) ) {
|
||||
if ($send_log->thread_id && ($send_log->customer_id || ($send_log->user_id && $send_log->user_id == $send_log->thread->user_id))) {
|
||||
$send_log->thread->send_status = $send_log->status;
|
||||
$send_log->thread->save();
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* todo: implement caching by saving all options in one cache variable on register_shutdown_function
|
||||
* todo: implement caching by saving all options in one cache variable on register_shutdown_function.
|
||||
*/
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@ -23,9 +24,10 @@ class Option extends Model
|
||||
/**
|
||||
* Set an option.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @return boolean
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function set($name, $value)
|
||||
{
|
||||
@ -45,7 +47,7 @@ class Option extends Model
|
||||
|
||||
$serialized_value = self::maybeSerialize($value);
|
||||
|
||||
$option = Option::firstOrCreate(
|
||||
$option = self::firstOrCreate(
|
||||
['name' => $name], ['value' => $serialized_value]
|
||||
);
|
||||
|
||||
@ -62,12 +64,13 @@ class Option extends Model
|
||||
/**
|
||||
* Get option.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get($name, $default = false, $decode = true)
|
||||
{
|
||||
// If not passed, get default value from config
|
||||
// If not passed, get default value from config
|
||||
if (func_num_args() == 1) {
|
||||
$default = self::getDefault($name, $default);
|
||||
}
|
||||
@ -76,7 +79,7 @@ class Option extends Model
|
||||
return self::$cache[$name];
|
||||
}
|
||||
|
||||
$option = Option::where('name', (string)$name)->first();
|
||||
$option = self::where('name', (string) $name)->first();
|
||||
if ($option) {
|
||||
if ($decode) {
|
||||
$value = self::maybeUnserialize($option->value);
|
||||
@ -94,7 +97,6 @@ class Option extends Model
|
||||
|
||||
public static function getDefault($option_name, $default)
|
||||
{
|
||||
|
||||
$options = \Config::get('app.options');
|
||||
|
||||
if (isset($options[$option_name]) && isset($options[$option_name]['default'])) {
|
||||
@ -106,16 +108,18 @@ class Option extends Model
|
||||
|
||||
public static function remove($name)
|
||||
{
|
||||
Option::where('name', (string)$name)->delete();
|
||||
self::where('name', (string) $name)->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize data, if needed.
|
||||
*/
|
||||
public static function maybeSerialize($data) {
|
||||
public static function maybeSerialize($data)
|
||||
{
|
||||
if (is_array($data) || is_object($data)) {
|
||||
return serialize( $data );
|
||||
return serialize($data);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
@ -130,8 +134,10 @@ class Option extends Model
|
||||
} catch (\Exception $e) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
return $original;
|
||||
}
|
||||
|
||||
return $original;
|
||||
}
|
||||
|
||||
@ -139,16 +145,17 @@ class Option extends Model
|
||||
* Check value to find if it was serialized.
|
||||
* Serialized data is always a string.
|
||||
*/
|
||||
public static function isSerialized($data, $strict = true) {
|
||||
public static function isSerialized($data, $strict = true)
|
||||
{
|
||||
// if it isn't a string, it isn't serialized.
|
||||
if (!is_string($data )) {
|
||||
if (!is_string($data)) {
|
||||
return false;
|
||||
}
|
||||
$data = trim($data);
|
||||
if ('N;' == $data) {
|
||||
return true;
|
||||
}
|
||||
if (strlen( $data ) < 4) {
|
||||
if (strlen($data) < 4) {
|
||||
return false;
|
||||
}
|
||||
if (':' !== $data[1]) {
|
||||
@ -161,36 +168,41 @@ class Option extends Model
|
||||
}
|
||||
} else {
|
||||
$semicolon = strpos($data, ';');
|
||||
$brace = strpos($data, '}');
|
||||
$brace = strpos($data, '}');
|
||||
// Either ; or } must exist.
|
||||
if (false === $semicolon && false === $brace)
|
||||
if (false === $semicolon && false === $brace) {
|
||||
return false;
|
||||
}
|
||||
// But neither must be in the first X characters.
|
||||
if (false !== $semicolon && $semicolon < 3)
|
||||
if (false !== $semicolon && $semicolon < 3) {
|
||||
return false;
|
||||
if (false !== $brace && $brace < 4)
|
||||
}
|
||||
if (false !== $brace && $brace < 4) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$token = $data[0];
|
||||
switch ($token) {
|
||||
case 's' :
|
||||
case 's':
|
||||
if ($strict) {
|
||||
if ('"' !== substr( $data, -2, 1)) {
|
||||
if ('"' !== substr($data, -2, 1)) {
|
||||
return false;
|
||||
}
|
||||
} elseif (false === strpos( $data, '"')) {
|
||||
} elseif (false === strpos($data, '"')) {
|
||||
return false;
|
||||
}
|
||||
// or else fall through
|
||||
case 'a' :
|
||||
case 'O' :
|
||||
return (bool)preg_match("/^{$token}:[0-9]+:/s", $data);
|
||||
case 'b' :
|
||||
case 'i' :
|
||||
case 'd' :
|
||||
case 'a':
|
||||
case 'O':
|
||||
return (bool) preg_match("/^{$token}:[0-9]+:/s", $data);
|
||||
case 'b':
|
||||
case 'i':
|
||||
case 'd':
|
||||
$end = $strict ? '$' : '';
|
||||
return (bool)preg_match("/^{$token}:[0-9.E-]+;$end/", $data);
|
||||
|
||||
return (bool) preg_match("/^{$token}:[0-9.E-]+;$end/", $data);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -51,8 +51,8 @@ class AppServiceProvider extends ServiceProvider
|
||||
}
|
||||
|
||||
// Process module registration error - disable module and show error to admin
|
||||
\Eventy::addFilter('modules.register_error', function($exception, $module) {
|
||||
|
||||
\Eventy::addFilter('modules.register_error', function ($exception, $module) {
|
||||
|
||||
// request() does is empty at this stage
|
||||
if (!empty($_POST['action']) && $_POST['action'] == 'activate') {
|
||||
|
||||
@ -68,13 +68,11 @@ class AppServiceProvider extends ServiceProvider
|
||||
'role' => \App\User::ROLE_ADMIN,
|
||||
]]);
|
||||
|
||||
return null;
|
||||
|
||||
return;
|
||||
} elseif (empty($_POST)) {
|
||||
|
||||
|
||||
// failed to open stream: No such file or directory
|
||||
if (strstr($exception->getMessage(), 'No such file or directory')) {
|
||||
|
||||
\App\Module::deactiveModule($module->getAlias());
|
||||
|
||||
\Session::flash('flashes_floating', [[
|
||||
@ -83,7 +81,8 @@ class AppServiceProvider extends ServiceProvider
|
||||
'role' => \App\User::ROLE_ADMIN,
|
||||
]]);
|
||||
}
|
||||
return null;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return $exception;
|
||||
|
@ -53,13 +53,13 @@ class EventServiceProvider extends ServiceProvider
|
||||
],
|
||||
|
||||
'App\Events\UserCreatedConversationDraft' => [
|
||||
|
||||
|
||||
],
|
||||
|
||||
'App\Events\UserCreatedThreadDraft' => [
|
||||
|
||||
|
||||
],
|
||||
|
||||
|
||||
'App\Events\UserReplied' => [
|
||||
'App\Listeners\SendReplyToCustomer',
|
||||
'App\Listeners\SendNotificationToUsers',
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Created by PhpStorm.
|
||||
* User: leemason
|
||||
* Date: 30/10/15
|
||||
* Time: 19:34
|
||||
* Time: 19:34.
|
||||
*/
|
||||
|
||||
namespace App\Providers;
|
||||
@ -19,7 +19,8 @@ use Illuminate\Support\ServiceProvider;
|
||||
class PolycastServiceProvider extends ServiceProvider
|
||||
{
|
||||
//public function boot(BroadcastingFactory $factory){
|
||||
public function boot(){
|
||||
public function boot()
|
||||
{
|
||||
|
||||
// register the polycast driver
|
||||
// $factory->extend('polycast', function(/*Application $app*/){
|
||||
@ -47,13 +48,12 @@ class PolycastServiceProvider extends ServiceProvider
|
||||
$this->app['router']->group(['middleware' => ['web']], function ($router) {
|
||||
|
||||
// establish connection and send current time
|
||||
$this->app['router']->post('polycast/connect', function(Request $request){
|
||||
$this->app['router']->post('polycast/connect', function (Request $request) {
|
||||
return ['status' => 'success', 'time' => Carbon::now()->toDateTimeString()];
|
||||
});
|
||||
|
||||
// send payloads to requested browser
|
||||
$this->app['router']->post('polycast/receive', function(Request $request){
|
||||
|
||||
$this->app['router']->post('polycast/receive', function (Request $request) {
|
||||
\Broadcast::auth($request);
|
||||
|
||||
$query = \DB::table('polycast_events')
|
||||
@ -61,10 +61,10 @@ class PolycastServiceProvider extends ServiceProvider
|
||||
|
||||
$channels = $request->get('channels', []);
|
||||
|
||||
foreach($channels as $channel => $events){
|
||||
foreach($events as $event) {
|
||||
foreach ($channels as $channel => $events) {
|
||||
foreach ($events as $event) {
|
||||
// No need to add index to DB for this query.
|
||||
$query->orWhere(function($query) use ($channel, $event, $request){
|
||||
$query->orWhere(function ($query) use ($channel, $event, $request) {
|
||||
$query->where('channels', 'like', '%"'.$channel.'"%')
|
||||
->where('event', '=', $event)
|
||||
->where('created_at', '>=', $request->get('time'));
|
||||
@ -75,15 +75,16 @@ class PolycastServiceProvider extends ServiceProvider
|
||||
$collection = collect($query->get());
|
||||
|
||||
$payload = $collection->map(function ($item, $key) use ($request) {
|
||||
$created = \Carbon\Carbon::createFromFormat("Y-m-d H:i:s", $item->created_at);
|
||||
$requested = \Carbon\Carbon::createFromFormat("Y-m-d H:i:s", $request->get('time'));
|
||||
$created = \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $item->created_at);
|
||||
$requested = \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $request->get('time'));
|
||||
$item->channels = json_decode($item->channels);
|
||||
$item->payload = json_decode($item->payload);
|
||||
// Add extra data to the payload
|
||||
$item->data = BroadcastNotification::fetchPayloadData($item->payload);
|
||||
|
||||
|
||||
$item->delay = $requested->diffInSeconds($created);
|
||||
$item->requested_at = $requested->toDateTimeString();
|
||||
|
||||
return $item;
|
||||
});
|
||||
|
||||
@ -94,11 +95,9 @@ class PolycastServiceProvider extends ServiceProvider
|
||||
return ['status' => 'success', 'time' => Carbon::now()->toDateTimeString(), 'payloads' => $payload];
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public function register(){
|
||||
|
||||
public function register()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -27,9 +27,9 @@ class SendLog extends Model
|
||||
*/
|
||||
const MAIL_TYPE_EMAIL_TO_CUSTOMER = 1;
|
||||
const MAIL_TYPE_USER_NOTIFICATION = 2;
|
||||
const MAIL_TYPE_AUTO_REPLY = 3;
|
||||
const MAIL_TYPE_INVITE = 4;
|
||||
const MAIL_TYPE_PASSWORD_CHANGED = 5;
|
||||
const MAIL_TYPE_AUTO_REPLY = 3;
|
||||
const MAIL_TYPE_INVITE = 4;
|
||||
const MAIL_TYPE_PASSWORD_CHANGED = 5;
|
||||
const MAIL_TYPE_WRONG_USER_EMAIL_MESSAGE = 6;
|
||||
const MAIL_TYPE_TEST = 7;
|
||||
const MAIL_TYPE_ALERT = 8;
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
namespace App;
|
||||
|
||||
use App\Conversation;
|
||||
use App\Notifications\BroadcastNotification;
|
||||
use App\Notifications\WebsiteNotification;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@ -247,7 +246,7 @@ class Subscription extends Model
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$users_to_notify[$subscription->medium][] = $subscription->user;
|
||||
$users_to_notify[$subscription->medium] = array_unique($users_to_notify[$subscription->medium]);
|
||||
}
|
||||
@ -340,7 +339,6 @@ class Subscription extends Model
|
||||
continue;
|
||||
}
|
||||
foreach ($notify[$medium] as $notify_info) {
|
||||
|
||||
$thread_id = $notify_info['threads'][0]->id;
|
||||
|
||||
foreach ($notify_info['users'] as $user) {
|
||||
@ -353,7 +351,7 @@ class Subscription extends Model
|
||||
'conversation' => $notify_info['conversation'],
|
||||
'threads' => $notify_info['threads'],
|
||||
'mediums' => $mediums,
|
||||
];
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -363,7 +361,7 @@ class Subscription extends Model
|
||||
}
|
||||
|
||||
// todo: mobile notification
|
||||
|
||||
|
||||
self::$occured_events = [];
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App;
|
||||
|
||||
use App\Attachment;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Thread extends Model
|
||||
@ -213,7 +212,7 @@ class Thread extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user who created the thread (cached)
|
||||
* Get user who created the thread (cached).
|
||||
*/
|
||||
public function created_by_user_cached()
|
||||
{
|
||||
@ -271,11 +270,12 @@ class Thread extends Model
|
||||
* Get first address from the To list.
|
||||
*/
|
||||
public function getToFirst()
|
||||
{
|
||||
{
|
||||
$to = $this->getToArray();
|
||||
|
||||
return array_shift($to);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get type name.
|
||||
*/
|
||||
@ -421,6 +421,7 @@ class Thread extends Model
|
||||
if ($ucfirst) {
|
||||
$name = ucfirst($name);
|
||||
}
|
||||
|
||||
return $name;
|
||||
} else {
|
||||
// User may be deleted
|
||||
@ -454,7 +455,7 @@ class Thread extends Model
|
||||
*/
|
||||
public function getPerson($cached = false)
|
||||
{
|
||||
if ($this->type == Thread::TYPE_CUSTOMER) {
|
||||
if ($this->type == self::TYPE_CUSTOMER) {
|
||||
if ($cached) {
|
||||
return $this->customer_cached;
|
||||
} else {
|
||||
@ -479,45 +480,45 @@ class Thread extends Model
|
||||
|
||||
// Person
|
||||
$person = '';
|
||||
if ($this->type == Thread::TYPE_CUSTOMER) {
|
||||
if ($this->type == self::TYPE_CUSTOMER) {
|
||||
$person = $this->customer_cached->getFullName(true);
|
||||
} elseif ($this->state == Thread::STATE_DRAFT && !empty($this->edited_by_user_id)) {
|
||||
} elseif ($this->state == self::STATE_DRAFT && !empty($this->edited_by_user_id)) {
|
||||
// Draft
|
||||
if (auth()->user() && $this->edited_by_user_id == auth()->user()->id) {
|
||||
$person = __("you");
|
||||
$person = __('you');
|
||||
} else {
|
||||
$person = $this->edited_by_user->getFullName();
|
||||
}
|
||||
} elseif ($this->created_by_user_cached) {
|
||||
if ($this->created_by_user_id && auth()->user() && $this->created_by_user_cached->id == auth()->user()->id) {
|
||||
$person = __("you");
|
||||
$person = __('you');
|
||||
} else {
|
||||
$person = $this->created_by_user_cached->getFullName();
|
||||
}
|
||||
}
|
||||
|
||||
// Did this
|
||||
if ($this->type == Thread::TYPE_LINEITEM) {
|
||||
if ($this->action_type == Thread::ACTION_TYPE_STATUS_CHANGED) {
|
||||
$did_this = __("marked as :status_name conversation #:conversation_number", ['status_name' => $this->getStatusName(), 'conversation_number' => $conversation_number]);
|
||||
} elseif ($this->action_type == Thread::ACTION_TYPE_USER_CHANGED) {
|
||||
$did_this = __("assigned :assignee convsersation #:conversation_number", ['assignee' => $this->getAssigneeName(false, null), 'conversation_number' => $conversation_number]);
|
||||
} elseif ($this->action_type == Thread::ACTION_TYPE_CUSTOMER_CHANGED) {
|
||||
$did_this = __("changed the customer to :customer in conversation #:conversation_number", ['customer' => $this->customer->getFullName(true), 'conversation_number' => $conversation_number]);
|
||||
if ($this->type == self::TYPE_LINEITEM) {
|
||||
if ($this->action_type == self::ACTION_TYPE_STATUS_CHANGED) {
|
||||
$did_this = __('marked as :status_name conversation #:conversation_number', ['status_name' => $this->getStatusName(), 'conversation_number' => $conversation_number]);
|
||||
} elseif ($this->action_type == self::ACTION_TYPE_USER_CHANGED) {
|
||||
$did_this = __('assigned :assignee convsersation #:conversation_number', ['assignee' => $this->getAssigneeName(false, null), 'conversation_number' => $conversation_number]);
|
||||
} elseif ($this->action_type == self::ACTION_TYPE_CUSTOMER_CHANGED) {
|
||||
$did_this = __('changed the customer to :customer in conversation #:conversation_number', ['customer' => $this->customer->getFullName(true), 'conversation_number' => $conversation_number]);
|
||||
}
|
||||
} elseif ($this->state == Thread::STATE_DRAFT) {
|
||||
} elseif ($this->state == self::STATE_DRAFT) {
|
||||
if (empty($this->edited_by_user_id)) {
|
||||
$did_this = __("created a draft");
|
||||
$did_this = __('created a draft');
|
||||
} else {
|
||||
$did_this = __("edited :creator's draft", ['creator' => $this->created_by_user_cached->getFirstName()]);
|
||||
}
|
||||
} else {
|
||||
} else {
|
||||
if ($this->first) {
|
||||
$did_this = __("started a new conversation #:conversation_number", ['conversation_number' => $conversation_number]);
|
||||
} elseif ($this->type == Thread::TYPE_NOTE) {
|
||||
$did_this = __("added a note to conversation #:conversation_number", ['conversation_number' => $conversation_number]);
|
||||
$did_this = __('started a new conversation #:conversation_number', ['conversation_number' => $conversation_number]);
|
||||
} elseif ($this->type == self::TYPE_NOTE) {
|
||||
$did_this = __('added a note to conversation #:conversation_number', ['conversation_number' => $conversation_number]);
|
||||
} else {
|
||||
$did_this = __("replied to conversation #:conversation_number", ['conversation_number' => $conversation_number]);
|
||||
$did_this = __('replied to conversation #:conversation_number', ['conversation_number' => $conversation_number]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -527,10 +528,10 @@ class Thread extends Model
|
||||
}
|
||||
|
||||
return __($description, [
|
||||
'person' => $person,
|
||||
'person' => $person,
|
||||
'person_tag_start' => '<strong>',
|
||||
'person_tag_end' => '</strong>',
|
||||
'did_this' => $did_this
|
||||
'person_tag_end' => '</strong>',
|
||||
'did_this' => $did_this,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -558,7 +559,7 @@ class Thread extends Model
|
||||
|
||||
public function isDraft()
|
||||
{
|
||||
return $this->state == Thread::STATE_DRAFT;
|
||||
return $this->state == self::STATE_DRAFT;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -575,8 +576,10 @@ class Thread extends Model
|
||||
|
||||
/**
|
||||
* Get name for the reply to customer.
|
||||
* @param [type] $mailbox [description]
|
||||
* @return [type] [description]
|
||||
*
|
||||
* @param [type] $mailbox [description]
|
||||
*
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getFromName($mailbox = null)
|
||||
{
|
||||
@ -589,7 +592,7 @@ class Thread extends Model
|
||||
if (empty($mailbox)) {
|
||||
$mailbox = $this->conversation->mailbox;
|
||||
}
|
||||
// Mailbox name by default
|
||||
// Mailbox name by default
|
||||
$name = $mailbox->name;
|
||||
|
||||
if ($mailbox->from_name == Mailbox::FROM_NAME_CUSTOM && $mailbox->from_name_custom) {
|
||||
@ -597,6 +600,7 @@ class Thread extends Model
|
||||
} elseif ($mailbox->from_name == Mailbox::FROM_NAME_USER && $this->getCreatedBy()) {
|
||||
$name = $this->getCreatedBy()->getFirstName(true);
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
|
64
app/User.php
64
app/User.php
@ -8,10 +8,7 @@ namespace App;
|
||||
|
||||
use App\Mail\PasswordChanged;
|
||||
use App\Mail\UserInvite;
|
||||
use App\Email;
|
||||
use App\Option;
|
||||
use App\Notifications\WebsiteNotification;
|
||||
use App\SendLog;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Auth\Notifications\ResetPassword as ResetPasswordNotification;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
@ -362,9 +359,9 @@ class User extends Authenticatable
|
||||
{
|
||||
$user_permission_names = [
|
||||
self::PERM_DELETE_CONVERSATIONS => __('Users are allowed to delete notes/conversations'),
|
||||
self::PERM_EDIT_CONVERSATIONS => __('Users are allowed to edit notes/threads'),
|
||||
self::PERM_EDIT_SAVED_REPLIES => __('Users are allowed to edit/delete saved replies'),
|
||||
self::PERM_EDIT_TAGS => __('Users are allowed to manage tags'),
|
||||
self::PERM_EDIT_CONVERSATIONS => __('Users are allowed to edit notes/threads'),
|
||||
self::PERM_EDIT_SAVED_REPLIES => __('Users are allowed to edit/delete saved replies'),
|
||||
self::PERM_EDIT_TAGS => __('Users are allowed to manage tags'),
|
||||
];
|
||||
|
||||
if (!empty($user_permission_names[$user_permission])) {
|
||||
@ -377,8 +374,8 @@ class User extends Authenticatable
|
||||
public function getInviteStateName()
|
||||
{
|
||||
$names = [
|
||||
self::INVITE_STATE_ACTIVATED => __('Active'),
|
||||
self::INVITE_STATE_SENT => __('Invited'),
|
||||
self::INVITE_STATE_ACTIVATED => __('Active'),
|
||||
self::INVITE_STATE_SENT => __('Invited'),
|
||||
self::INVITE_STATE_NOT_INVITED => __('Not Invited'),
|
||||
];
|
||||
if (!isset($names[$this->invite_state])) {
|
||||
@ -393,7 +390,8 @@ class User extends Authenticatable
|
||||
*/
|
||||
public function sendInvite($throw_exceptions = false)
|
||||
{
|
||||
function saveToSendLog($user, $status) {
|
||||
function saveToSendLog($user, $status)
|
||||
{
|
||||
SendLog::log(null, null, $user->email, SendLog::MAIL_TYPE_INVITE, $status, null, $user->id);
|
||||
}
|
||||
|
||||
@ -435,14 +433,14 @@ class User extends Authenticatable
|
||||
saveToSendLog($this, SendLog::STATUS_SEND_ERROR);
|
||||
|
||||
if ($throw_exceptions) {
|
||||
throw new \Exception(__("Error occured sending email to :email. Please check logs for more details.", ['email' => $this->email]), 1);
|
||||
throw new \Exception(__('Error occured sending email to :email. Please check logs for more details.', ['email' => $this->email]), 1);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->invite_state != User::INVITE_STATE_SENT) {
|
||||
$this->invite_state = User::INVITE_STATE_SENT;
|
||||
if ($this->invite_state != self::INVITE_STATE_SENT) {
|
||||
$this->invite_state = self::INVITE_STATE_SENT;
|
||||
$this->save();
|
||||
}
|
||||
|
||||
@ -456,7 +454,8 @@ class User extends Authenticatable
|
||||
*/
|
||||
public function sendPasswordChanged()
|
||||
{
|
||||
function saveToSendLog($user, $status) {
|
||||
function saveToSendLog($user, $status)
|
||||
{
|
||||
SendLog::log(null, null, $user->email, SendLog::MAIL_TYPE_PASSWORD_CHANGED, $status, null, $user->id);
|
||||
}
|
||||
|
||||
@ -477,11 +476,13 @@ class User extends Authenticatable
|
||||
->log(\App\ActivityLog::DESCRIPTION_EMAILS_SENDING_ERROR_PASSWORD_CHANGED);
|
||||
|
||||
saveToSendLog($this, SendLog::STATUS_SEND_ERROR);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (\Mail::failures()) {
|
||||
saveToSendLog($this, SendLog::STATUS_SEND_ERROR);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -493,7 +494,8 @@ class User extends Authenticatable
|
||||
/**
|
||||
* Send the password reset notification.
|
||||
*
|
||||
* @param string $token
|
||||
* @param string $token
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function sendPasswordResetNotification($token)
|
||||
@ -513,13 +515,14 @@ class User extends Authenticatable
|
||||
if ($cache) {
|
||||
// Get from cache
|
||||
$user = $this;
|
||||
return \Cache::rememberForever('user_web_notifications_'.$user->id, function() use ($user) {
|
||||
|
||||
return \Cache::rememberForever('user_web_notifications_'.$user->id, function () use ($user) {
|
||||
$notifications = $user->getWebsiteNotifications();
|
||||
|
||||
$info = [
|
||||
'data' => WebsiteNotification::fetchNotificationsData($notifications),
|
||||
'notifications' => $notifications,
|
||||
'unread_count' => $user->unreadNotifications()->count()
|
||||
'unread_count' => $user->unreadNotifications()->count(),
|
||||
];
|
||||
|
||||
$info['html'] = view('users/partials/web_notifications', ['web_notifications_info_data' => $info['data']])->render();
|
||||
@ -530,9 +533,9 @@ class User extends Authenticatable
|
||||
$notifications = $this->getWebsiteNotifications();
|
||||
|
||||
$info = [
|
||||
'data' => WebsiteNotification::fetchNotificationsData($notifications),
|
||||
'data' => WebsiteNotification::fetchNotificationsData($notifications),
|
||||
'notifications' => $notifications,
|
||||
'unread_count' => $this->unreadNotifications()->count()
|
||||
'unread_count' => $this->unreadNotifications()->count(),
|
||||
];
|
||||
|
||||
return $info;
|
||||
@ -547,7 +550,7 @@ class User extends Authenticatable
|
||||
public function getPhotoUrl()
|
||||
{
|
||||
if (!empty($this->photo_url)) {
|
||||
return Storage::url(User::PHOTO_DIRECTORY.DIRECTORY_SEPARATOR.$this->photo_url);
|
||||
return Storage::url(self::PHOTO_DIRECTORY.DIRECTORY_SEPARATOR.$this->photo_url);
|
||||
} else {
|
||||
return '/img/default-avatar.png';
|
||||
}
|
||||
@ -558,14 +561,14 @@ class User extends Authenticatable
|
||||
*/
|
||||
public function savePhoto($uploaded_file)
|
||||
{
|
||||
$resized_image = \App\Misc\Helper::resizeImage($uploaded_file->getRealPath(), $uploaded_file->getMimeType(), self::PHOTO_SIZE, self::PHOTO_SIZE) ;
|
||||
$resized_image = \App\Misc\Helper::resizeImage($uploaded_file->getRealPath(), $uploaded_file->getMimeType(), self::PHOTO_SIZE, self::PHOTO_SIZE);
|
||||
|
||||
if (!$resized_image) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$file_name = md5(Hash::make($this->id)).'.jpg';
|
||||
$dest_path = Storage::path(User::PHOTO_DIRECTORY.DIRECTORY_SEPARATOR.$file_name);
|
||||
$dest_path = Storage::path(self::PHOTO_DIRECTORY.DIRECTORY_SEPARATOR.$file_name);
|
||||
|
||||
$dest_dir = pathinfo($dest_path, PATHINFO_DIRNAME);
|
||||
if (!file_exists($dest_dir)) {
|
||||
@ -574,14 +577,14 @@ class User extends Authenticatable
|
||||
|
||||
// Remove current photo
|
||||
if ($this->photo_url) {
|
||||
Storage::delete(User::PHOTO_DIRECTORY.DIRECTORY_SEPARATOR.$this->photo_url);
|
||||
Storage::delete(self::PHOTO_DIRECTORY.DIRECTORY_SEPARATOR.$this->photo_url);
|
||||
}
|
||||
|
||||
imagejpeg($resized_image, $dest_path, self::PHOTO_QUALITY);
|
||||
// $photo_url = $request->file('photo_url')->storeAs(
|
||||
// User::PHOTO_DIRECTORY, !Hash::make($user->id).'.jpg'
|
||||
// );
|
||||
|
||||
|
||||
return $file_name;
|
||||
}
|
||||
|
||||
@ -591,7 +594,7 @@ class User extends Authenticatable
|
||||
public function removePhoto()
|
||||
{
|
||||
if ($this->photo_url) {
|
||||
Storage::delete(User::PHOTO_DIRECTORY.DIRECTORY_SEPARATOR.$this->photo_url);
|
||||
Storage::delete(self::PHOTO_DIRECTORY.DIRECTORY_SEPARATOR.$this->photo_url);
|
||||
}
|
||||
$this->photo_url = '';
|
||||
}
|
||||
@ -609,11 +612,12 @@ class User extends Authenticatable
|
||||
/**
|
||||
* Todo: implement super admin role.
|
||||
* For now we return just first admin.
|
||||
*
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public static function getSuperAdmin()
|
||||
{
|
||||
return User::where('role', User::ROLE_ADMIN)->first();
|
||||
return self::where('role', self::ROLE_ADMIN)->first();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -621,7 +625,7 @@ class User extends Authenticatable
|
||||
*/
|
||||
public static function create($data)
|
||||
{
|
||||
$user = new User();
|
||||
$user = new self();
|
||||
|
||||
if (empty($data['email']) || empty($data['password'])) {
|
||||
return false;
|
||||
@ -634,7 +638,7 @@ class User extends Authenticatable
|
||||
|
||||
try {
|
||||
$user->save();
|
||||
} catch(\Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -648,18 +652,18 @@ class User extends Authenticatable
|
||||
{
|
||||
$user = auth()->user();
|
||||
if ($user) {
|
||||
return ($user->role >= $role);
|
||||
return $user->role >= $role;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get dummy user, for example, when real user has been deleted
|
||||
* Get dummy user, for example, when real user has been deleted.
|
||||
*/
|
||||
public static function getDeletedUser()
|
||||
{
|
||||
$user = new User();
|
||||
$user = new self();
|
||||
$user->first_name = 'DELETED';
|
||||
$user->last_name = 'DELETED';
|
||||
$user->email = 'deleted@example.org';
|
||||
|
@ -171,7 +171,7 @@ return [
|
||||
|--------------------------------------------------------------------------
|
||||
| Parameters used to run queued jobs processing.
|
||||
| Checks for new jobs every 5 seconds.
|
||||
| Do not set more than 1 retry, as it may lead to sending repeated emails if one recipient fails
|
||||
| Do not set more than 1 retry, as it may lead to sending repeated emails if one recipient fails
|
||||
| and another succeeds.
|
||||
|-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -184,7 +184,6 @@ return [
|
||||
*/
|
||||
'required_extensions' => ['mysql / mysqli', 'mbstring', 'xml', 'imap', /*'mcrypt' mcrypt is deprecated*/ 'json', 'gd', 'fileinfo', 'openssl', 'zip', 'tokenizer'/*, 'dom', 'xmlwriter', 'libxml', 'phar'*/],
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Enable if using CloudFlare "Flexible SSL":
|
||||
@ -199,9 +198,9 @@ return [
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'options' => [
|
||||
'alert_fetch' => ['default' => false],
|
||||
'alert_fetch' => ['default' => false],
|
||||
'alert_fetch_period' => ['default' => 15], // min
|
||||
'email_branding' => ['default' => true],
|
||||
'email_branding' => ['default' => true],
|
||||
],
|
||||
|
||||
/*
|
||||
@ -267,7 +266,7 @@ return [
|
||||
// If we remove some service provider file from here and from disk,
|
||||
// when updating the app, users will receive "Class '...' not found" error,
|
||||
// because their cached config still has this service provider listed.
|
||||
|
||||
|
||||
// Autodiscovery did not work for this one, becasuse it's composer.json
|
||||
// does not have a `extra` section.
|
||||
Codedge\Updater\UpdaterServiceProvider::class,
|
||||
|
@ -33,7 +33,7 @@ return [
|
||||
'polycast' => [
|
||||
'driver' => 'polycast',
|
||||
// this deletes old events after 2 minutes, this can be changed to leave them in the db longer if required
|
||||
'delete_old' => 2,
|
||||
'delete_old' => 2,
|
||||
],
|
||||
|
||||
'pusher' => [
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
// Causes:
|
||||
// Call to undefined method Illuminate\Validation\Rules\In::__set_state()
|
||||
//use Illuminate\Validation\Rule;
|
||||
@ -16,12 +17,12 @@ return [
|
||||
|
|
||||
*/
|
||||
'core' => [
|
||||
'minPhpVersion' => '7.0.0'
|
||||
'minPhpVersion' => '7.0.0',
|
||||
],
|
||||
'final' => [
|
||||
'key' => false,
|
||||
'publish' => false
|
||||
],
|
||||
'key' => false,
|
||||
'publish' => false,
|
||||
],
|
||||
'requirements' => [
|
||||
'php' => [
|
||||
'OpenSSL',
|
||||
@ -51,13 +52,13 @@ return [
|
||||
|
|
||||
*/
|
||||
'permissions' => [
|
||||
'storage/app/' => '775',
|
||||
'storage/framework/' => '775',
|
||||
'storage/app/' => '775',
|
||||
'storage/framework/' => '775',
|
||||
'storage/framework/cache/data/' => '775',
|
||||
'storage/logs/' => '775',
|
||||
'bootstrap/cache/' => '775',
|
||||
'public/css/builds/' => '775',
|
||||
'public/js/builds/' => '775',
|
||||
'storage/logs/' => '775',
|
||||
'bootstrap/cache/' => '775',
|
||||
'public/css/builds/' => '775',
|
||||
'public/js/builds/' => '775',
|
||||
],
|
||||
|
||||
/*
|
||||
@ -130,7 +131,7 @@ return [
|
||||
],
|
||||
'dump' => [
|
||||
'data' => 'Dumping a not found message.',
|
||||
]
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
|
@ -24,23 +24,23 @@ return [
|
||||
|
||||
'stubs' => [
|
||||
'enabled' => true,
|
||||
'path' => base_path() . '/overrides/Nwidart/Modules/Commands/stubs',
|
||||
'files' => [
|
||||
'start' => 'start.php',
|
||||
'routes' => 'Http/routes.php',
|
||||
'views/index' => 'Resources/views/index.blade.php',
|
||||
'views/master' => 'Resources/views/layouts/master.blade.php',
|
||||
'path' => base_path().'/overrides/Nwidart/Modules/Commands/stubs',
|
||||
'files' => [
|
||||
'start' => 'start.php',
|
||||
'routes' => 'Http/routes.php',
|
||||
'views/index' => 'Resources/views/index.blade.php',
|
||||
'views/master' => 'Resources/views/layouts/master.blade.php',
|
||||
'scaffold/config' => 'Config/config.php',
|
||||
'composer' => 'composer.json',
|
||||
'composer' => 'composer.json',
|
||||
],
|
||||
'replacements' => [
|
||||
'start' => ['LOWER_NAME', 'ROUTES_LOCATION'],
|
||||
'routes' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'],
|
||||
'json' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'],
|
||||
'views/index' => ['LOWER_NAME'],
|
||||
'views/master' => ['STUDLY_NAME'],
|
||||
'start' => ['LOWER_NAME', 'ROUTES_LOCATION'],
|
||||
'routes' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'],
|
||||
'json' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'],
|
||||
'views/index' => ['LOWER_NAME'],
|
||||
'views/master' => ['STUDLY_NAME'],
|
||||
'scaffold/config' => ['STUDLY_NAME'],
|
||||
'composer' => [
|
||||
'composer' => [
|
||||
'LOWER_NAME',
|
||||
'STUDLY_NAME',
|
||||
'VENDOR',
|
||||
@ -92,29 +92,29 @@ return [
|
||||
| Set the generate key to false to not generate that folder
|
||||
*/
|
||||
'generator' => [
|
||||
'config' => ['path' => 'Config', 'generate' => true],
|
||||
'command' => ['path' => 'Console', 'generate' => true],
|
||||
'migration' => ['path' => 'Database/Migrations', 'generate' => true],
|
||||
'seeder' => ['path' => 'Database/Seeders', 'generate' => true],
|
||||
'factory' => ['path' => 'Database/factories', 'generate' => true],
|
||||
'model' => ['path' => 'Entities', 'generate' => true],
|
||||
'controller' => ['path' => 'Http/Controllers', 'generate' => true],
|
||||
'filter' => ['path' => 'Http/Middleware', 'generate' => true],
|
||||
'request' => ['path' => 'Http/Requests', 'generate' => true],
|
||||
'provider' => ['path' => 'Providers', 'generate' => true],
|
||||
'assets' => ['path' => 'Resources/assets', 'generate' => true],
|
||||
'lang' => ['path' => 'Resources/lang', 'generate' => true],
|
||||
'views' => ['path' => 'Resources/views', 'generate' => true],
|
||||
'test' => ['path' => 'Tests', 'generate' => true],
|
||||
'repository' => ['path' => 'Repositories', 'generate' => false],
|
||||
'event' => ['path' => 'Events', 'generate' => false],
|
||||
'listener' => ['path' => 'Listeners', 'generate' => false],
|
||||
'policies' => ['path' => 'Policies', 'generate' => false],
|
||||
'rules' => ['path' => 'Rules', 'generate' => false],
|
||||
'jobs' => ['path' => 'Jobs', 'generate' => false],
|
||||
'emails' => ['path' => 'Emails', 'generate' => false],
|
||||
'config' => ['path' => 'Config', 'generate' => true],
|
||||
'command' => ['path' => 'Console', 'generate' => true],
|
||||
'migration' => ['path' => 'Database/Migrations', 'generate' => true],
|
||||
'seeder' => ['path' => 'Database/Seeders', 'generate' => true],
|
||||
'factory' => ['path' => 'Database/factories', 'generate' => true],
|
||||
'model' => ['path' => 'Entities', 'generate' => true],
|
||||
'controller' => ['path' => 'Http/Controllers', 'generate' => true],
|
||||
'filter' => ['path' => 'Http/Middleware', 'generate' => true],
|
||||
'request' => ['path' => 'Http/Requests', 'generate' => true],
|
||||
'provider' => ['path' => 'Providers', 'generate' => true],
|
||||
'assets' => ['path' => 'Resources/assets', 'generate' => true],
|
||||
'lang' => ['path' => 'Resources/lang', 'generate' => true],
|
||||
'views' => ['path' => 'Resources/views', 'generate' => true],
|
||||
'test' => ['path' => 'Tests', 'generate' => true],
|
||||
'repository' => ['path' => 'Repositories', 'generate' => false],
|
||||
'event' => ['path' => 'Events', 'generate' => false],
|
||||
'listener' => ['path' => 'Listeners', 'generate' => false],
|
||||
'policies' => ['path' => 'Policies', 'generate' => false],
|
||||
'rules' => ['path' => 'Rules', 'generate' => false],
|
||||
'jobs' => ['path' => 'Jobs', 'generate' => false],
|
||||
'emails' => ['path' => 'Emails', 'generate' => false],
|
||||
'notifications' => ['path' => 'Notifications', 'generate' => false],
|
||||
'resource' => ['path' => 'Transformers', 'generate' => false],
|
||||
'resource' => ['path' => 'Transformers', 'generate' => false],
|
||||
],
|
||||
],
|
||||
/*
|
||||
@ -129,7 +129,7 @@ return [
|
||||
|
||||
'scan' => [
|
||||
'enabled' => false,
|
||||
'paths' => [
|
||||
'paths' => [
|
||||
base_path('vendor/*/*'),
|
||||
],
|
||||
],
|
||||
@ -145,7 +145,7 @@ return [
|
||||
'composer' => [
|
||||
'vendor' => 'nwidart',
|
||||
'author' => [
|
||||
'name' => 'Nicolas Widart',
|
||||
'name' => 'Nicolas Widart',
|
||||
'email' => 'n.widart@gmail.com',
|
||||
],
|
||||
],
|
||||
@ -160,7 +160,7 @@ return [
|
||||
'cache' => [
|
||||
// Modules 'active' flag is stored in DB in modules, so we have to cache modules info
|
||||
'enabled' => true,
|
||||
'key' => 'laravel-modules',
|
||||
'key' => 'laravel-modules',
|
||||
// Minues
|
||||
'lifetime' => 60,
|
||||
],
|
||||
@ -173,7 +173,7 @@ return [
|
||||
*/
|
||||
'register' => [
|
||||
'translations' => true,
|
||||
/**
|
||||
/*
|
||||
* load files on boot or register method
|
||||
*
|
||||
* Note: boot not compatible with asgardcms
|
||||
|
@ -8,7 +8,7 @@
|
||||
* if ( ! $this->config->get('purifier.finalize')) {
|
||||
* $config->autoFinalize = false;
|
||||
* }
|
||||
* $config->loadArray($this->getConfig());
|
||||
* $config->loadArray($this->getConfig());.
|
||||
*
|
||||
* You must NOT delete the default settings
|
||||
* anything in settings should be compacted with params that needed to instance HTMLPurifier_Config.
|
||||
@ -33,14 +33,14 @@ return [
|
||||
'test' => [
|
||||
'Attr.EnableID' => 'true',
|
||||
],
|
||||
"youtube" => [
|
||||
"HTML.SafeIframe" => 'true',
|
||||
"URI.SafeIframeRegexp" => "%^(http://|https://|//)(www.youtube.com/embed/|player.vimeo.com/video/)%",
|
||||
'youtube' => [
|
||||
'HTML.SafeIframe' => 'true',
|
||||
'URI.SafeIframeRegexp' => '%^(http://|https://|//)(www.youtube.com/embed/|player.vimeo.com/video/)%',
|
||||
],
|
||||
'custom_definition' => [
|
||||
'id' => 'html5-definitions',
|
||||
'rev' => 1,
|
||||
'debug' => false,
|
||||
'id' => 'html5-definitions',
|
||||
'rev' => 1,
|
||||
'debug' => false,
|
||||
'elements' => [
|
||||
// http://developers.whatwg.org/sections.html
|
||||
['section', 'Block', 'Flow', 'Common'],
|
||||
@ -49,39 +49,39 @@ return [
|
||||
['aside', 'Block', 'Flow', 'Common'],
|
||||
['header', 'Block', 'Flow', 'Common'],
|
||||
['footer', 'Block', 'Flow', 'Common'],
|
||||
|
||||
// Content model actually excludes several tags, not modelled here
|
||||
|
||||
// Content model actually excludes several tags, not modelled here
|
||||
['address', 'Block', 'Flow', 'Common'],
|
||||
['hgroup', 'Block', 'Required: h1 | h2 | h3 | h4 | h5 | h6', 'Common'],
|
||||
|
||||
// http://developers.whatwg.org/grouping-content.html
|
||||
|
||||
// http://developers.whatwg.org/grouping-content.html
|
||||
['figure', 'Block', 'Optional: (figcaption, Flow) | (Flow, figcaption) | Flow', 'Common'],
|
||||
['figcaption', 'Inline', 'Flow', 'Common'],
|
||||
|
||||
// http://developers.whatwg.org/the-video-element.html#the-video-element
|
||||
|
||||
// http://developers.whatwg.org/the-video-element.html#the-video-element
|
||||
['video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', [
|
||||
'src' => 'URI',
|
||||
'type' => 'Text',
|
||||
'width' => 'Length',
|
||||
'height' => 'Length',
|
||||
'poster' => 'URI',
|
||||
'preload' => 'Enum#auto,metadata,none',
|
||||
'controls' => 'Bool',
|
||||
'src' => 'URI',
|
||||
'type' => 'Text',
|
||||
'width' => 'Length',
|
||||
'height' => 'Length',
|
||||
'poster' => 'URI',
|
||||
'preload' => 'Enum#auto,metadata,none',
|
||||
'controls' => 'Bool',
|
||||
]],
|
||||
['source', 'Block', 'Flow', 'Common', [
|
||||
'src' => 'URI',
|
||||
'type' => 'Text',
|
||||
'src' => 'URI',
|
||||
'type' => 'Text',
|
||||
]],
|
||||
|
||||
// http://developers.whatwg.org/text-level-semantics.html
|
||||
// http://developers.whatwg.org/text-level-semantics.html
|
||||
['s', 'Inline', 'Inline', 'Common'],
|
||||
['var', 'Inline', 'Inline', 'Common'],
|
||||
['sub', 'Inline', 'Inline', 'Common'],
|
||||
['sup', 'Inline', 'Inline', 'Common'],
|
||||
['mark', 'Inline', 'Inline', 'Common'],
|
||||
['wbr', 'Inline', 'Empty', 'Core'],
|
||||
|
||||
// http://developers.whatwg.org/edits.html
|
||||
|
||||
// http://developers.whatwg.org/edits.html
|
||||
['ins', 'Block', 'Flow', 'Common', ['cite' => 'URI', 'datetime' => 'CDATA']],
|
||||
['del', 'Block', 'Flow', 'Common', ['cite' => 'URI', 'datetime' => 'CDATA']],
|
||||
],
|
||||
|
@ -37,11 +37,11 @@ return [
|
||||
|
||||
'repository_types' => [
|
||||
'github' => [
|
||||
'type' => 'github',
|
||||
'type' => 'github',
|
||||
'repository_vendor' => 'freescout-helpdesk', //env('SELF_UPDATER_REPO_VENDOR', ''),
|
||||
'repository_name' => 'freescout', //env('SELF_UPDATER_REPO_NAME', ''),
|
||||
'repository_url' => '',
|
||||
'download_path' => storage_path().DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'updater', //env('SELF_UPDATER_DOWNLOAD_PATH', sys_get_temp_dir()),
|
||||
'repository_name' => 'freescout', //env('SELF_UPDATER_REPO_NAME', ''),
|
||||
'repository_url' => '',
|
||||
'download_path' => storage_path().DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'updater', //env('SELF_UPDATER_DOWNLOAD_PATH', sys_get_temp_dir()),
|
||||
],
|
||||
],
|
||||
|
||||
@ -90,8 +90,8 @@ return [
|
||||
*/
|
||||
|
||||
'mail_to' => [
|
||||
'address' => env('SELF_UPDATER_MAILTO_ADDRESS', ''),
|
||||
'name' => env('SELF_UPDATER_MAILTO_NAME', ''),
|
||||
'address' => env('SELF_UPDATER_MAILTO_ADDRESS', ''),
|
||||
'name' => env('SELF_UPDATER_MAILTO_NAME', ''),
|
||||
'subject_update_available' => env('SELF_UPDATER_MAILTO_UPDATE_AVAILABLE_SUBJECT', 'Update available'),
|
||||
'subject_update_succeeded' => env('SELF_UPDATER_MAILTO_UPDATE_SUCCEEDED_SUBJECT', 'Update succeeded'),
|
||||
],
|
||||
@ -111,7 +111,7 @@ return [
|
||||
],
|
||||
'post_update' => [
|
||||
'freescout:after-app-update' => [
|
||||
'class' => \App\Console\Commands\AfterAppUpdate::class,
|
||||
'class' => \App\Console\Commands\AfterAppUpdate::class,
|
||||
'params' => [],
|
||||
],
|
||||
// 'freescout:clear-cache' => [
|
||||
|
@ -18,17 +18,17 @@ return [
|
||||
'roles',
|
||||
],
|
||||
// todo: replace admin with superadmin
|
||||
'roles' => ['admin']
|
||||
'roles' => ['admin'],
|
||||
],
|
||||
|
||||
/**
|
||||
/*
|
||||
* Enable deletion of translations
|
||||
*
|
||||
* @type boolean
|
||||
*/
|
||||
'delete_enabled' => true,
|
||||
|
||||
/**
|
||||
/*
|
||||
* Exclude specific groups from Laravel Translation Manager.
|
||||
* This is useful if, for example, you want to avoid editing the official Laravel language files.
|
||||
*
|
||||
@ -42,7 +42,7 @@ return [
|
||||
*/
|
||||
'exclude_groups' => [],
|
||||
|
||||
/**
|
||||
/*
|
||||
* Exclude specific languages from Laravel Translation Manager.
|
||||
*
|
||||
* @type array
|
||||
@ -54,7 +54,7 @@ return [
|
||||
*/
|
||||
'exclude_langs' => [],
|
||||
|
||||
/**
|
||||
/*
|
||||
* Export translations with keys output alphabetically.
|
||||
*/
|
||||
'sort_keys ' => false,
|
||||
|
@ -28,10 +28,10 @@ $factory->define(Conversation::class, function (Faker $faker, $params) {
|
||||
}
|
||||
|
||||
return [
|
||||
'type' => $faker->randomElement([Conversation::TYPE_EMAIL, Conversation::TYPE_PHONE]),
|
||||
'folder_id' => $folder_id,
|
||||
'state' => Conversation::STATE_PUBLISHED, // $faker->randomElement(array_keys(Conversation::$states)),
|
||||
'subject' => $faker->sentence(7),
|
||||
'type' => $faker->randomElement([Conversation::TYPE_EMAIL, Conversation::TYPE_PHONE]),
|
||||
'folder_id' => $folder_id,
|
||||
'state' => Conversation::STATE_PUBLISHED, // $faker->randomElement(array_keys(Conversation::$states)),
|
||||
'subject' => $faker->sentence(7),
|
||||
'customer_email' => $customer_email,
|
||||
'cc' => json_encode([$faker->unique()->safeEmail]),
|
||||
'bcc' => json_encode([$faker->unique()->safeEmail]),
|
||||
|
@ -16,10 +16,10 @@ use Faker\Generator as Faker;
|
||||
$factory->define(App\User::class, function (Faker $faker) {
|
||||
return [
|
||||
'first_name' => $faker->firstName,
|
||||
'last_name' => $faker->lastName,
|
||||
'email' => $faker->unique()->safeEmail,
|
||||
'job_title' => $faker->jobTitle,
|
||||
'phone' => $faker->phoneNumber,
|
||||
'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret
|
||||
'last_name' => $faker->lastName,
|
||||
'email' => $faker->unique()->safeEmail,
|
||||
'job_title' => $faker->jobTitle,
|
||||
'phone' => $faker->phoneNumber,
|
||||
'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret
|
||||
];
|
||||
});
|
||||
|
@ -1,19 +1,18 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateTranslationsTable extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('ltm_translations', function(Blueprint $table)
|
||||
{
|
||||
class CreateTranslationsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('ltm_translations', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('status')->default(0);
|
||||
$table->string('locale');
|
||||
@ -22,16 +21,15 @@ class CreateTranslationsTable extends Migration {
|
||||
$table->text('value')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('ltm_translations');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use App\User;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateUsersTable extends Migration
|
||||
{
|
||||
|
@ -30,7 +30,7 @@ class CreateConversationsTable extends Migration
|
||||
$table->string('subject', 998)->nullable();
|
||||
// Customer's email to which replies from users are sent.
|
||||
// Not used when fetching emails.
|
||||
// Customer may have several emails, so we need to know which
|
||||
// Customer may have several emails, so we need to know which
|
||||
// email to use for each conversation.
|
||||
$table->string('customer_email', 191)->nullable();
|
||||
// CC and BCC store values from the last reply from customer or user
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* Table stores conversations which user marked as starred
|
||||
* Table stores conversations which user marked as starred.
|
||||
*/
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateConversationFolderTable extends Migration
|
||||
{
|
||||
|
@ -2,9 +2,9 @@
|
||||
/**
|
||||
* Outgoing emails.
|
||||
*/
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateSendLogsTable extends Migration
|
||||
{
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateNotificationsTable extends Migration
|
||||
{
|
||||
|
@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
use \Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreatePolycastEventsTable extends Migration {
|
||||
|
||||
class CreatePolycastEventsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
@ -13,7 +13,7 @@ class CreatePolycastEventsTable extends Migration {
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('polycast_events', function(Blueprint $table){
|
||||
Schema::create('polycast_events', function (Blueprint $table) {
|
||||
$table->engine = 'InnoDB';
|
||||
|
||||
$table->increments('id');
|
||||
@ -33,5 +33,4 @@ class CreatePolycastEventsTable extends Migration {
|
||||
{
|
||||
Schema::drop('polycast_events');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateModulesTable extends Migration
|
||||
{
|
||||
|
@ -27,18 +27,18 @@ class DatabaseSeeder extends Seeder
|
||||
$customer->emails()->save($email);
|
||||
|
||||
$conversation = factory(App\Conversation::class)->create([
|
||||
'created_by_user_id' => $user->id,
|
||||
'mailbox_id' => $m->id,
|
||||
'customer_id' => $customer->id,
|
||||
'customer_email' => $email->email,
|
||||
'user_id' => $user->id,
|
||||
'status' => array_rand([Conversation::STATUS_ACTIVE => 1, Conversation::STATUS_PENDING => 1])
|
||||
'created_by_user_id' => $user->id,
|
||||
'mailbox_id' => $m->id,
|
||||
'customer_id' => $customer->id,
|
||||
'customer_email' => $email->email,
|
||||
'user_id' => $user->id,
|
||||
'status' => array_rand([Conversation::STATUS_ACTIVE => 1, Conversation::STATUS_PENDING => 1]),
|
||||
]);
|
||||
|
||||
$thread = factory(App\Thread::class)->make([
|
||||
'customer_id' => $customer->id,
|
||||
'to' => $email->email,
|
||||
'conversation_id' => $conversation->id
|
||||
'customer_id' => $customer->id,
|
||||
'to' => $email->email,
|
||||
'conversation_id' => $conversation->id,
|
||||
]);
|
||||
$conversation->threads()->save($thread);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
/**
|
||||
* Overriding vendor class to generate routes for modules.
|
||||
*/
|
||||
|
||||
namespace Axn\Laroute\Routes;
|
||||
|
||||
use Illuminate\Routing\Route;
|
||||
@ -43,30 +44,29 @@ class Collection extends BaseCollection
|
||||
$data = parent::getRouteInformation($route, $filter, $namespace);
|
||||
|
||||
if (!$data || empty($data['name'])) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
// If `module` parameter is set for the route we choose only routes from this module
|
||||
$action = $route->getAction();
|
||||
|
||||
if ($action && !empty($action['controller'])) {
|
||||
|
||||
preg_match('/^Modules\\\([^\\\]+)\\\/', $action['controller'], $m);
|
||||
|
||||
if (!empty($m[1])) {
|
||||
if (!$this->module) {
|
||||
// We are generating routes for the main application,
|
||||
// missing route of the module
|
||||
return null;
|
||||
return;
|
||||
} else {
|
||||
// Route belongs to another module
|
||||
if ($this->module != strtolower($m[1])) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
} elseif ($this->module) {
|
||||
// Include only module routes into module JS file
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,15 +2,15 @@
|
||||
|
||||
namespace Codedge\Updater\SourceRepositoryTypes;
|
||||
|
||||
use File;
|
||||
use Storage;
|
||||
use GuzzleHttp\Client;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use Codedge\Updater\Events\UpdateFailed;
|
||||
use Codedge\Updater\AbstractRepositoryType;
|
||||
use Codedge\Updater\Events\UpdateAvailable;
|
||||
use Codedge\Updater\Events\UpdateSucceeded;
|
||||
use Codedge\Updater\Contracts\SourceRepositoryTypeContract;
|
||||
use Codedge\Updater\Events\UpdateAvailable;
|
||||
use Codedge\Updater\Events\UpdateFailed;
|
||||
use Codedge\Updater\Events\UpdateSucceeded;
|
||||
use File;
|
||||
use GuzzleHttp\Client;
|
||||
use Storage;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
|
||||
/**
|
||||
* Github.php.
|
||||
@ -56,12 +56,12 @@ class GithubRepositoryType extends AbstractRepositoryType implements SourceRepos
|
||||
{
|
||||
$version = $currentVersion ?: $this->getVersionInstalled();
|
||||
|
||||
if (! $version) {
|
||||
if (!$version) {
|
||||
throw new \InvalidArgumentException('No currently installed version specified.');
|
||||
}
|
||||
|
||||
if (version_compare($version, $this->getVersionAvailable(), '<')) {
|
||||
if (! $this->versionFileExists()) {
|
||||
if (!$this->versionFileExists()) {
|
||||
$this->setVersionFile($this->getVersionAvailable());
|
||||
event(new UpdateAvailable($this->getVersionAvailable()));
|
||||
}
|
||||
@ -95,17 +95,17 @@ class GithubRepositoryType extends AbstractRepositoryType implements SourceRepos
|
||||
$storagePath = $this->config['download_path'];
|
||||
//$storagePath = storage_path().DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'updater';
|
||||
|
||||
if (! File::exists($storagePath)) {
|
||||
if (!File::exists($storagePath)) {
|
||||
File::makeDirectory($storagePath, 493, true, true);
|
||||
}
|
||||
|
||||
if (! empty($version)) {
|
||||
if (!empty($version)) {
|
||||
$release = $releaseCollection->where('name', $version)->first();
|
||||
}
|
||||
|
||||
$storageFilename = "{$release->name}.zip";
|
||||
|
||||
if (! $this->isSourceAlreadyFetched($release->name)) {
|
||||
if (!$this->isSourceAlreadyFetched($release->name)) {
|
||||
$storageFile = $storagePath.DIRECTORY_SEPARATOR.$storageFilename;
|
||||
$this->downloadRelease($this->client, $release->zipball_url, $storageFile);
|
||||
|
||||
@ -126,7 +126,7 @@ class GithubRepositoryType extends AbstractRepositoryType implements SourceRepos
|
||||
$this->setPathToUpdate(base_path(), $this->config['exclude_folders']);
|
||||
|
||||
if ($this->hasCorrectPermissionForUpdate()) {
|
||||
if (! empty($version)) {
|
||||
if (!empty($version)) {
|
||||
$sourcePath = $this->config['download_path'].DIRECTORY_SEPARATOR.$version;
|
||||
} else {
|
||||
$sourcePath = File::directories($this->config['download_path'])[0];
|
||||
|
@ -120,8 +120,10 @@ class Json
|
||||
|
||||
/**
|
||||
* Get file contents as array.
|
||||
* @return array
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAttributes()
|
||||
{
|
||||
@ -133,7 +135,7 @@ class Json
|
||||
|
||||
// any JSON parsing errors should throw an exception
|
||||
if (json_last_error() > 0) {
|
||||
throw new InvalidJsonException('Error processing file: ' . $this->getPath() . '. Error: ' . json_last_error_msg());
|
||||
throw new InvalidJsonException('Error processing file: '.$this->getPath().'. Error: '.json_last_error_msg());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -190,7 +190,7 @@ abstract class Module extends ServiceProvider
|
||||
{
|
||||
$lowerName = $this->getLowerName();
|
||||
|
||||
$langPath = $this->getPath() . '/Resources/lang';
|
||||
$langPath = $this->getPath().'/Resources/lang';
|
||||
|
||||
if (is_dir($langPath)) {
|
||||
$this->loadTranslationsFrom($langPath, $lowerName);
|
||||
@ -213,7 +213,7 @@ abstract class Module extends ServiceProvider
|
||||
return array_get($this->moduleJson, $file, function () use ($file) {
|
||||
// In this Laravel-Modules package caching is not working, so we need to implement it.
|
||||
// https://github.com/nWidart/laravel-modules/issues/659
|
||||
|
||||
|
||||
// Cache stores module.json files as arrays
|
||||
$cachedManifestsArray = $this->app['cache']->get($this->app['config']->get('modules.cache.key'));
|
||||
|
||||
@ -221,14 +221,15 @@ abstract class Module extends ServiceProvider
|
||||
foreach ($cachedManifestsArray as $manifest) {
|
||||
// We found manifest data in cache
|
||||
if (!empty($manifest['name']) && $manifest['name'] == $this->getName()) {
|
||||
return $this->moduleJson[$file] = new Json($this->getPath() . '/' . $file, $this->app['files'], $manifest);
|
||||
return $this->moduleJson[$file] = new Json($this->getPath().'/'.$file, $this->app['files'], $manifest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We have to set `active` flag from DB modules table.
|
||||
$json = new Json($this->getPath() . '/' . $file, $this->app['files']);
|
||||
$json->set('active', (int)\App\Module::isActive($json->get('alias')));
|
||||
$json = new Json($this->getPath().'/'.$file, $this->app['files']);
|
||||
$json->set('active', (int) \App\Module::isActive($json->get('alias')));
|
||||
|
||||
return $this->moduleJson[$file] = $json;
|
||||
//return $this->moduleJson[$file] = new Json($this->getPath() . '/' . $file, $this->app['files']);
|
||||
});
|
||||
@ -238,7 +239,7 @@ abstract class Module extends ServiceProvider
|
||||
* Get a specific data from json file by given the key.
|
||||
*
|
||||
* @param string $key
|
||||
* @param null $default
|
||||
* @param null $default
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
@ -290,8 +291,9 @@ abstract class Module extends ServiceProvider
|
||||
*/
|
||||
protected function fireEvent($event)
|
||||
{
|
||||
$this->app['events']->fire(sprintf('modules.%s.' . $event, $this->getLowerName()), [$this]);
|
||||
$this->app['events']->fire(sprintf('modules.%s.'.$event, $this->getLowerName()), [$this]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the aliases from this module.
|
||||
*/
|
||||
@ -315,7 +317,7 @@ abstract class Module extends ServiceProvider
|
||||
protected function registerFiles()
|
||||
{
|
||||
foreach ($this->get('files', []) as $file) {
|
||||
include $this->path . '/' . $file;
|
||||
include $this->path.'/'.$file;
|
||||
}
|
||||
}
|
||||
|
||||
@ -340,7 +342,7 @@ abstract class Module extends ServiceProvider
|
||||
{
|
||||
// echo "<pre>";
|
||||
// print_r($this->json());
|
||||
|
||||
|
||||
//return (int)\App\Module::isActive($this->getAlias()) == $status;
|
||||
return $this->get('active', 0) === $status;
|
||||
}
|
||||
@ -359,6 +361,7 @@ abstract class Module extends ServiceProvider
|
||||
* Alternate for "enabled" method.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function active()
|
||||
@ -370,6 +373,7 @@ abstract class Module extends ServiceProvider
|
||||
* Determine whether the current module not activated.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function notActive()
|
||||
@ -443,7 +447,7 @@ abstract class Module extends ServiceProvider
|
||||
*/
|
||||
public function getExtraPath(string $path) : string
|
||||
{
|
||||
return $this->getPath() . '/' . $path;
|
||||
return $this->getPath().'/'.$path;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -44,6 +44,7 @@ abstract class Repository implements RepositoryInterface, Countable
|
||||
|
||||
/**
|
||||
* Cache in memory.
|
||||
*
|
||||
* @var [type]
|
||||
*/
|
||||
protected $cache;
|
||||
@ -51,7 +52,7 @@ abstract class Repository implements RepositoryInterface, Countable
|
||||
/**
|
||||
* The constructor.
|
||||
*
|
||||
* @param Container $app
|
||||
* @param Container $app
|
||||
* @param string|null $path
|
||||
*/
|
||||
public function __construct(Container $app, $path = null)
|
||||
@ -80,6 +81,7 @@ abstract class Repository implements RepositoryInterface, Countable
|
||||
* @param string $path
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function addPath($path)
|
||||
@ -120,11 +122,12 @@ abstract class Repository implements RepositoryInterface, Countable
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Module instance
|
||||
*
|
||||
* Creates a new Module instance.
|
||||
*
|
||||
* @param Container $app
|
||||
* @param $name
|
||||
* @param $path
|
||||
*
|
||||
* @return \Nwidart\Modules\Module
|
||||
*/
|
||||
abstract protected function createModule(...$args);
|
||||
@ -151,10 +154,10 @@ abstract class Repository implements RepositoryInterface, Countable
|
||||
$modules[$name] = $this->createModule($this->app, $name, dirname($manifest));
|
||||
|
||||
// Overwrite module `active` flag with value from DB modules table.
|
||||
// Configuration is cached right when freescout:clear-cache is executed.
|
||||
// Configuration is cached right when freescout:clear-cache is executed.
|
||||
$alias = $modules[$name]->getAlias();
|
||||
if ($alias) {
|
||||
$modules[$name]->json()->set('active', (int)\App\Module::isActive($alias));
|
||||
$modules[$name]->json()->set('active', (int) \App\Module::isActive($alias));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -197,7 +200,7 @@ abstract class Repository implements RepositoryInterface, Countable
|
||||
$modules = [];
|
||||
|
||||
foreach ($cached as $name => $module) {
|
||||
$path = $module["path"];
|
||||
$path = $module['path'];
|
||||
|
||||
$modules[$name] = $this->createModule($this->app, $name, $path);
|
||||
}
|
||||
@ -215,6 +218,7 @@ abstract class Repository implements RepositoryInterface, Countable
|
||||
if ($this->cache) {
|
||||
return $this->cache;
|
||||
}
|
||||
|
||||
return $this->app['cache']->remember($this->config('cache.key'), $this->config('cache.lifetime'), function () {
|
||||
|
||||
// By some reason when Nwidart\Modules\Module is converted into array
|
||||
@ -222,7 +226,7 @@ abstract class Repository implements RepositoryInterface, Countable
|
||||
// Set `active` flag from DB for each module
|
||||
foreach ($array as $key => $item) {
|
||||
if (!empty($item['alias'])) {
|
||||
$item['active'] = (int)\App\Module::isActive($item['alias']);
|
||||
$item['active'] = (int) \App\Module::isActive($item['alias']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -363,7 +367,9 @@ abstract class Repository implements RepositoryInterface, Countable
|
||||
|
||||
/**
|
||||
* Find a specific module.
|
||||
*
|
||||
* @param $name
|
||||
*
|
||||
* @return mixed|void
|
||||
*/
|
||||
public function find($name)
|
||||
@ -373,31 +379,31 @@ abstract class Repository implements RepositoryInterface, Countable
|
||||
return $module;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a specific module by its alias.
|
||||
*
|
||||
* @param $alias
|
||||
*
|
||||
* @return mixed|void
|
||||
*/
|
||||
public function findByAlias($alias)
|
||||
{
|
||||
foreach ($this->all() as $module) {
|
||||
if (strtolower($module->getAlias()) === $alias) {
|
||||
//if ($module->getAlias() === $alias) {
|
||||
//if ($module->getAlias() === $alias) {
|
||||
return $module;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check by alias if module is active.
|
||||
* @param [type] $alias [description]
|
||||
* @return boolean [description]
|
||||
*
|
||||
* @param [type] $alias [description]
|
||||
*
|
||||
* @return bool [description]
|
||||
*/
|
||||
public function isActive($alias)
|
||||
{
|
||||
@ -408,13 +414,15 @@ abstract class Repository implements RepositoryInterface, Countable
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Find all modules that are required by a module. If the module cannot be found, throw an exception.
|
||||
*
|
||||
* @param $name
|
||||
* @return array
|
||||
*
|
||||
* @throws ModuleNotFoundException
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function findRequirements($name)
|
||||
{
|
||||
@ -431,8 +439,11 @@ abstract class Repository implements RepositoryInterface, Countable
|
||||
|
||||
/**
|
||||
* Alternative for "find" method.
|
||||
*
|
||||
* @param $name
|
||||
*
|
||||
* @return mixed|void
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function get($name)
|
||||
@ -445,9 +456,9 @@ abstract class Repository implements RepositoryInterface, Countable
|
||||
*
|
||||
* @param $name
|
||||
*
|
||||
* @return Module
|
||||
*
|
||||
* @throws ModuleNotFoundException
|
||||
*
|
||||
* @return Module
|
||||
*/
|
||||
public function findOrFail($name)
|
||||
{
|
||||
@ -482,9 +493,9 @@ abstract class Repository implements RepositoryInterface, Countable
|
||||
public function getModulePath($module)
|
||||
{
|
||||
try {
|
||||
return $this->findOrFail($module)->getPath() . '/';
|
||||
return $this->findOrFail($module)->getPath().'/';
|
||||
} catch (ModuleNotFoundException $e) {
|
||||
return $this->getPath() . '/' . Str::studly($module) . '/';
|
||||
return $this->getPath().'/'.Str::studly($module).'/';
|
||||
}
|
||||
}
|
||||
|
||||
@ -497,20 +508,20 @@ abstract class Repository implements RepositoryInterface, Countable
|
||||
*/
|
||||
public function assetPath($module) : string
|
||||
{
|
||||
return $this->config('paths.assets') . '/' . $module;
|
||||
return $this->config('paths.assets').'/'.$module;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a specific config data from a configuration file.
|
||||
*
|
||||
* @param $key
|
||||
*
|
||||
* @param null $default
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function config($key, $default = null)
|
||||
{
|
||||
return $this->app['config']->get('modules.' . $key, $default);
|
||||
return $this->app['config']->get('modules.'.$key, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -559,8 +570,10 @@ abstract class Repository implements RepositoryInterface, Countable
|
||||
|
||||
/**
|
||||
* Get module used for cli session.
|
||||
* @return string
|
||||
*
|
||||
* @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUsedNow() : string
|
||||
{
|
||||
@ -571,6 +584,7 @@ abstract class Repository implements RepositoryInterface, Countable
|
||||
* Get used now.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function getUsed()
|
||||
@ -600,9 +614,12 @@ abstract class Repository implements RepositoryInterface, Countable
|
||||
|
||||
/**
|
||||
* Get asset url from a specific module.
|
||||
*
|
||||
* @param string $asset
|
||||
* @return string
|
||||
*
|
||||
* @throws InvalidAssetPath
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function asset($asset) : string
|
||||
{
|
||||
@ -611,9 +628,9 @@ abstract class Repository implements RepositoryInterface, Countable
|
||||
}
|
||||
list($name, $url) = explode(':', $asset);
|
||||
|
||||
$baseUrl = str_replace(public_path() . DIRECTORY_SEPARATOR, '', $this->getAssetsPath());
|
||||
$baseUrl = str_replace(public_path().DIRECTORY_SEPARATOR, '', $this->getAssetsPath());
|
||||
|
||||
$url = $this->app['url']->asset($baseUrl . "/{$name}/" . $url);
|
||||
$url = $this->app['url']->asset($baseUrl."/{$name}/".$url);
|
||||
|
||||
return str_replace(['http://', 'https://'], '//', $url);
|
||||
}
|
||||
@ -644,9 +661,12 @@ abstract class Repository implements RepositoryInterface, Countable
|
||||
|
||||
/**
|
||||
* Enabling a specific module.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*
|
||||
* @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function enable($name)
|
||||
{
|
||||
@ -655,9 +675,12 @@ abstract class Repository implements RepositoryInterface, Countable
|
||||
|
||||
/**
|
||||
* Disabling a specific module.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*
|
||||
* @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function disable($name)
|
||||
{
|
||||
@ -666,9 +689,12 @@ abstract class Repository implements RepositoryInterface, Countable
|
||||
|
||||
/**
|
||||
* Delete a specific module.
|
||||
*
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*
|
||||
* @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function delete($name) : bool
|
||||
{
|
||||
@ -736,13 +762,16 @@ abstract class Repository implements RepositoryInterface, Countable
|
||||
|
||||
/**
|
||||
* Get module option.
|
||||
* @param [type] $module_alias [description]
|
||||
* @param [type] $option_name [description]
|
||||
* @param boolean $default [description]
|
||||
* @return [type] [description]
|
||||
*
|
||||
* @param [type] $module_alias [description]
|
||||
* @param [type] $option_name [description]
|
||||
* @param bool $default [description]
|
||||
*
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getOption($module_alias, $option_name, $default = false) {
|
||||
// If not passed, get default value from config
|
||||
public function getOption($module_alias, $option_name, $default = false)
|
||||
{
|
||||
// If not passed, get default value from config
|
||||
if (func_num_args() == 2) {
|
||||
$options = \Config::get(strtolower($module_alias).'.options');
|
||||
|
||||
@ -756,11 +785,13 @@ abstract class Repository implements RepositoryInterface, Countable
|
||||
|
||||
/**
|
||||
* Set module option.
|
||||
*
|
||||
* @param [type] $module_alias [description]
|
||||
* @param [type] $option_name [description]
|
||||
* @param [type] $option_value [description]
|
||||
*/
|
||||
public function setOption($module_alias, $option_name, $option_value) {
|
||||
public function setOption($module_alias, $option_name, $option_value)
|
||||
{
|
||||
return \Option::set(strtolower($module_alias).'.'.$option_name, $option_value);
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,9 @@ namespace RachidLaasri\LaravelInstaller\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use RachidLaasri\LaravelInstaller\Helpers\EnvironmentManager;
|
||||
use RachidLaasri\LaravelInstaller\Events\EnvironmentSaved;
|
||||
use RachidLaasri\LaravelInstaller\Helpers\EnvironmentManager;
|
||||
use Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class EnvironmentController extends Controller
|
||||
{
|
||||
@ -62,8 +61,9 @@ class EnvironmentController extends Controller
|
||||
/**
|
||||
* Processes the newly saved environment configuration (Classic).
|
||||
*
|
||||
* @param Request $input
|
||||
* @param Request $input
|
||||
* @param Redirector $redirect
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function saveClassic(Request $input, Redirector $redirect)
|
||||
@ -87,8 +87,9 @@ class EnvironmentController extends Controller
|
||||
/**
|
||||
* Processes the newly saved environment configuration (Form Wizard).
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
* @param Redirector $redirect
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function saveWizard(Request $request, Redirector $redirect)
|
||||
@ -101,32 +102,32 @@ class EnvironmentController extends Controller
|
||||
$validator = Validator::make($request->all(), $rules, $messages);
|
||||
|
||||
if ($request->app_force_https == 'true') {
|
||||
$request->merge(['app_url' => preg_replace("/^http:/i", 'https:', $request->app_url)]);
|
||||
$request->merge(['app_url' => preg_replace('/^http:/i', 'https:', $request->app_url)]);
|
||||
}
|
||||
|
||||
$this->rememberOldRequest($request);
|
||||
|
||||
if ($validator->fails()) {
|
||||
$errors = $validator->errors();
|
||||
|
||||
return view('vendor.installer.environment-wizard', compact('errors', 'envConfig'));
|
||||
}
|
||||
|
||||
// Check DB connection
|
||||
//$this->EnvironmentManager->saveFileWizard($request);
|
||||
try {
|
||||
\Config::set("database.connections.install", [
|
||||
\Config::set('database.connections.install', [
|
||||
'driver' => 'mysql',
|
||||
"host" => $request->database_hostname,
|
||||
"database" => $request->database_name,
|
||||
"username" => $request->database_username,
|
||||
"password" => $request->database_password,
|
||||
'host' => $request->database_hostname,
|
||||
'database' => $request->database_name,
|
||||
'username' => $request->database_username,
|
||||
'password' => $request->database_password,
|
||||
'charset' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
'prefix' => '',
|
||||
]);
|
||||
\DB::connection('install')->getPdo();
|
||||
} catch (\Exception $e) {
|
||||
|
||||
$validator->getMessageBag()->add('general', 'Could not establish database connection: '.$e->getMessage());
|
||||
$validator->getMessageBag()->add('database_hostname', 'Database Host: Please check entered value.');
|
||||
$validator->getMessageBag()->add('database_port', 'Database Port: Please check entered value.');
|
||||
|
@ -3,10 +3,10 @@
|
||||
namespace RachidLaasri\LaravelInstaller\Controllers;
|
||||
|
||||
use Illuminate\Routing\Controller;
|
||||
use RachidLaasri\LaravelInstaller\Events\LaravelInstallerFinished;
|
||||
use RachidLaasri\LaravelInstaller\Helpers\EnvironmentManager;
|
||||
use RachidLaasri\LaravelInstaller\Helpers\FinalInstallManager;
|
||||
use RachidLaasri\LaravelInstaller\Helpers\InstalledFileManager;
|
||||
use RachidLaasri\LaravelInstaller\Events\LaravelInstallerFinished;
|
||||
|
||||
class FinalController extends Controller
|
||||
{
|
||||
@ -14,6 +14,7 @@ class FinalController extends Controller
|
||||
* Update installed file and display finished view.
|
||||
*
|
||||
* @param InstalledFileManager $fileManager
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function finish(InstalledFileManager $fileManager, FinalInstallManager $finalInstall, EnvironmentManager $environment)
|
||||
@ -29,8 +30,8 @@ class FinalController extends Controller
|
||||
|
||||
// Now clear cache and cache config
|
||||
\Artisan::call('freescout:clear-cache');
|
||||
|
||||
event(new LaravelInstallerFinished);
|
||||
|
||||
event(new LaravelInstallerFinished());
|
||||
|
||||
return view('vendor.installer.finished', compact('finalMessages', 'finalStatusMessage', 'finalEnvFile', 'dbMessage'));
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class DatabaseManager
|
||||
*/
|
||||
public function migrateAndSeed()
|
||||
{
|
||||
$outputLog = new BufferedOutput;
|
||||
$outputLog = new BufferedOutput();
|
||||
|
||||
$this->sqlite($outputLog);
|
||||
|
||||
@ -29,18 +29,18 @@ class DatabaseManager
|
||||
* Run the migration and call the seeder.
|
||||
*
|
||||
* @param collection $outputLog
|
||||
*
|
||||
* @return collection
|
||||
*/
|
||||
private function migrate($outputLog)
|
||||
{
|
||||
try{
|
||||
Artisan::call('migrate', ["--force"=> true], $outputLog);
|
||||
}
|
||||
catch(Exception $e){
|
||||
try {
|
||||
Artisan::call('migrate', ['--force'=> true], $outputLog);
|
||||
} catch (Exception $e) {
|
||||
return $this->response($e->getMessage(), 'error', $outputLog);
|
||||
}
|
||||
|
||||
return $this->response(trans('installer_messages.final.finished'), 'success', $outputLog);;
|
||||
return $this->response(trans('installer_messages.final.finished'), 'success', $outputLog);
|
||||
//return $this->seed($outputLog);
|
||||
}
|
||||
|
||||
@ -48,14 +48,14 @@ class DatabaseManager
|
||||
* Seed the database.
|
||||
*
|
||||
* @param collection $outputLog
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function seed($outputLog)
|
||||
{
|
||||
try{
|
||||
try {
|
||||
Artisan::call('db:seed', ['--force' => true], $outputLog);
|
||||
}
|
||||
catch(Exception $e){
|
||||
} catch (Exception $e) {
|
||||
return $this->response($e->getMessage(), 'error', $outputLog);
|
||||
}
|
||||
|
||||
@ -66,16 +66,17 @@ class DatabaseManager
|
||||
* Return a formatted error messages.
|
||||
*
|
||||
* @param $message
|
||||
* @param string $status
|
||||
* @param string $status
|
||||
* @param collection $outputLog
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function response($message, $status = 'danger', $outputLog)
|
||||
private function response($message, $status, $outputLog)
|
||||
{
|
||||
return [
|
||||
'status' => $status,
|
||||
'message' => $message,
|
||||
'dbOutputLog' => $outputLog->fetch()
|
||||
'status' => $status,
|
||||
'message' => $message,
|
||||
'dbOutputLog' => $outputLog->fetch(),
|
||||
];
|
||||
}
|
||||
|
||||
@ -86,13 +87,13 @@ class DatabaseManager
|
||||
*/
|
||||
private function sqlite($outputLog)
|
||||
{
|
||||
if(DB::connection() instanceof SQLiteConnection) {
|
||||
if (DB::connection() instanceof SQLiteConnection) {
|
||||
$database = DB::connection()->getDatabaseName();
|
||||
if(!file_exists($database)) {
|
||||
if (!file_exists($database)) {
|
||||
touch($database);
|
||||
DB::reconnect(Config::get('database.default'));
|
||||
}
|
||||
$outputLog->write('Using SqlLite database: ' . $database, 1);
|
||||
$outputLog->write('Using SqlLite database: '.$database, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,8 @@ class EnvironmentManager
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEnvPath() {
|
||||
public function getEnvPath()
|
||||
{
|
||||
return $this->envPath;
|
||||
}
|
||||
|
||||
@ -58,7 +59,8 @@ class EnvironmentManager
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEnvExamplePath() {
|
||||
public function getEnvExamplePath()
|
||||
{
|
||||
return $this->envExamplePath;
|
||||
}
|
||||
|
||||
@ -66,6 +68,7 @@ class EnvironmentManager
|
||||
* Save the edited content to the .env file.
|
||||
*
|
||||
* @param Request $input
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function saveFileClassic(Request $input)
|
||||
@ -74,8 +77,7 @@ class EnvironmentManager
|
||||
|
||||
try {
|
||||
file_put_contents($this->envPath, $input->get('envConfig'));
|
||||
}
|
||||
catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$message = trans('installer_messages.environment.errors');
|
||||
}
|
||||
|
||||
@ -86,6 +88,7 @@ class EnvironmentManager
|
||||
* Save the form content to the .env file.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function saveFileWizard(Request $request)
|
||||
@ -98,26 +101,26 @@ class EnvironmentManager
|
||||
//'APP_KEY=' . 'base64:bODi8VtmENqnjklBmNJzQcTTSC8jNjBysfnjQN59btE=' . "\n" .
|
||||
// 'APP_DEBUG=' . $request->app_debug . "\n" .
|
||||
// 'APP_LOG_LEVEL=' . $request->app_log_level . "\n" .
|
||||
'# Every time you are making changes in .env file, in order changes to take an effect you need to run:' . "\n" .
|
||||
'# php artisan freescout:clear-cache' . "\n\n" .
|
||||
'# Application URL' . "\n" .
|
||||
'APP_URL=' . $request->app_url . "\n\n" .
|
||||
'# Use HTTP protocol and redirect to HTTPS' . "\n" .
|
||||
'APP_FORCE_HTTPS=' . $request->app_force_https . "\n\n" .
|
||||
'# Timezones: https://github.com/freescout-helpdesk/freescout/wiki/PHP-Timezones' . "\n" .
|
||||
'# Comment it to use default timezone from php.ini' . "\n" .
|
||||
'APP_TIMEZONE=' . $request->app_timezone . "\n\n" .
|
||||
'DB_CONNECTION=' . $request->database_connection . "\n" .
|
||||
'DB_HOST=' . $request->database_hostname . "\n" .
|
||||
'DB_PORT=' . $request->database_port . "\n" .
|
||||
'DB_DATABASE=' . $request->database_name . "\n" .
|
||||
'DB_USERNAME=' . $request->database_username . "\n" .
|
||||
'DB_PASSWORD=' . $request->database_password . "\n\n" .
|
||||
'# Run the following console command to generate the key: php artisan key:generate' . "\n" .
|
||||
'# Otherwise application will show the following error: "Whoops, looks like something went wrong"' . "\n" .
|
||||
'APP_KEY=' . \Config::get('app.key') . "\n\n" .
|
||||
'# Uncomment to see errors in your browser, don\'t forget to comment it back when debugging finished' . "\n" .
|
||||
'#APP_DEBUG=' . 'true' . "\n";
|
||||
'# Every time you are making changes in .env file, in order changes to take an effect you need to run:'."\n".
|
||||
'# php artisan freescout:clear-cache'."\n\n".
|
||||
'# Application URL'."\n".
|
||||
'APP_URL='.$request->app_url."\n\n".
|
||||
'# Use HTTP protocol and redirect to HTTPS'."\n".
|
||||
'APP_FORCE_HTTPS='.$request->app_force_https."\n\n".
|
||||
'# Timezones: https://github.com/freescout-helpdesk/freescout/wiki/PHP-Timezones'."\n".
|
||||
'# Comment it to use default timezone from php.ini'."\n".
|
||||
'APP_TIMEZONE='.$request->app_timezone."\n\n".
|
||||
'DB_CONNECTION='.$request->database_connection."\n".
|
||||
'DB_HOST='.$request->database_hostname."\n".
|
||||
'DB_PORT='.$request->database_port."\n".
|
||||
'DB_DATABASE='.$request->database_name."\n".
|
||||
'DB_USERNAME='.$request->database_username."\n".
|
||||
'DB_PASSWORD='.$request->database_password."\n\n".
|
||||
'# Run the following console command to generate the key: php artisan key:generate'."\n".
|
||||
'# Otherwise application will show the following error: "Whoops, looks like something went wrong"'."\n".
|
||||
'APP_KEY='.\Config::get('app.key')."\n\n".
|
||||
'# Uncomment to see errors in your browser, don\'t forget to comment it back when debugging finished'."\n".
|
||||
'#APP_DEBUG='.'true'."\n";
|
||||
// 'BROADCAST_DRIVER=' . $request->broadcast_driver . "\n" .
|
||||
// 'CACHE_DRIVER=' . $request->cache_driver . "\n" .
|
||||
// 'SESSION_DRIVER=' . $request->session_driver . "\n" .
|
||||
@ -137,15 +140,14 @@ class EnvironmentManager
|
||||
|
||||
try {
|
||||
file_put_contents($this->envPath, $envFileData);
|
||||
}
|
||||
catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$results = trans('installer_messages.environment.errors');
|
||||
}
|
||||
|
||||
// Clear and update cache
|
||||
// If we cache config here, it caches env data from memory
|
||||
//\Artisan::call('freescout:clear-cache');
|
||||
\Artisan::call('freescout:clear-cache', ["--doNotCacheConfig" => true]);
|
||||
\Artisan::call('freescout:clear-cache', ['--doNotCacheConfig' => true]);
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
@ -17,17 +17,17 @@ class FinalInstallManager
|
||||
{
|
||||
// After BufferedOutput it is impossible to get sessions values
|
||||
$user_data = [
|
||||
'email' => old('admin_email'),
|
||||
'password' => old('admin_password'),
|
||||
'role' => \App\User::ROLE_ADMIN,
|
||||
'email' => old('admin_email'),
|
||||
'password' => old('admin_password'),
|
||||
'role' => \App\User::ROLE_ADMIN,
|
||||
'first_name' => old('admin_first_name'),
|
||||
'last_name' => old('admin_last_name'),
|
||||
'last_name' => old('admin_last_name'),
|
||||
];
|
||||
// Remove admin data from sessions
|
||||
// We need it to display on the page
|
||||
//session(['_old_input' => []]);
|
||||
|
||||
$outputLog = new BufferedOutput;
|
||||
$outputLog = new BufferedOutput();
|
||||
|
||||
$this->runCommands($outputLog);
|
||||
//$this->generateKey($outputLog);
|
||||
@ -46,7 +46,7 @@ class FinalInstallManager
|
||||
try {
|
||||
Artisan::call('freescout:clear-cache', [], $outputLog);
|
||||
Artisan::call('storage:link', [], $outputLog);
|
||||
} catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
return static::response($e->getMessage(), $outputLog);
|
||||
}
|
||||
|
||||
@ -57,16 +57,16 @@ class FinalInstallManager
|
||||
* Generate New Application Key.
|
||||
*
|
||||
* @param collection $outputLog
|
||||
*
|
||||
* @return collection
|
||||
*/
|
||||
private static function generateKey($outputLog)
|
||||
{
|
||||
try{
|
||||
if (config('installer.final.key')){
|
||||
Artisan::call('key:generate', ["--force"=> true], $outputLog);
|
||||
try {
|
||||
if (config('installer.final.key')) {
|
||||
Artisan::call('key:generate', ['--force'=> true], $outputLog);
|
||||
}
|
||||
}
|
||||
catch(Exception $e){
|
||||
} catch (Exception $e) {
|
||||
return static::response($e->getMessage(), $outputLog);
|
||||
}
|
||||
|
||||
@ -77,35 +77,36 @@ class FinalInstallManager
|
||||
* Publish vendor assets.
|
||||
*
|
||||
* @param collection $outputLog
|
||||
*
|
||||
* @return collection
|
||||
*/
|
||||
private static function publishVendorAssets($outputLog)
|
||||
{
|
||||
try{
|
||||
if (config('installer.final.publish')){
|
||||
try {
|
||||
if (config('installer.final.publish')) {
|
||||
Artisan::call('vendor:publish', ['--all' => true], $outputLog);
|
||||
}
|
||||
}
|
||||
catch(Exception $e){
|
||||
} catch (Exception $e) {
|
||||
return static::response($e->getMessage(), $outputLog);
|
||||
}
|
||||
|
||||
return $outputLog;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a formatted error messages.
|
||||
*
|
||||
* @param $message
|
||||
* @param collection $outputLog
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private static function response($message, $outputLog)
|
||||
{
|
||||
return [
|
||||
'status' => 'error',
|
||||
'message' => $message,
|
||||
'dbOutputLog' => $outputLog->fetch()
|
||||
'status' => 'error',
|
||||
'message' => $message,
|
||||
'dbOutputLog' => $outputLog->fetch(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -13,18 +13,16 @@ class InstalledFileManager
|
||||
{
|
||||
$installedLogFile = storage_path('.installed');
|
||||
|
||||
$dateStamp = date("Y/m/d h:i:sa");
|
||||
$dateStamp = date('Y/m/d h:i:sa');
|
||||
|
||||
if (!file_exists($installedLogFile))
|
||||
{
|
||||
$message = trans('installer_messages.installed.success_log_message') . $dateStamp . "\n";
|
||||
if (!file_exists($installedLogFile)) {
|
||||
$message = trans('installer_messages.installed.success_log_message').$dateStamp."\n";
|
||||
|
||||
file_put_contents($installedLogFile, $message);
|
||||
|
||||
} else {
|
||||
$message = trans('installer_messages.updater.log.success_message') . $dateStamp;
|
||||
$message = trans('installer_messages.updater.log.success_message').$dateStamp;
|
||||
|
||||
file_put_contents($installedLogFile, $message.PHP_EOL , FILE_APPEND | LOCK_EX);
|
||||
file_put_contents($installedLogFile, $message.PHP_EOL, FILE_APPEND | LOCK_EX);
|
||||
}
|
||||
|
||||
return $message;
|
||||
@ -39,4 +37,4 @@ class InstalledFileManager
|
||||
{
|
||||
return $this->create();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,18 +25,16 @@ class PermissionsChecker
|
||||
* Check for the folders permissions.
|
||||
*
|
||||
* @param array $folders
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function check(array $folders)
|
||||
{
|
||||
foreach($folders as $folder => $permission)
|
||||
{
|
||||
foreach ($folders as $folder => $permission) {
|
||||
//if(!($this->getPermission($folder) >= $permission))
|
||||
if (!$this->isWritable($folder))
|
||||
{
|
||||
if (!$this->isWritable($folder)) {
|
||||
$this->addFileAndSetErrors($folder, $permission, false);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->addFile($folder, $permission, true);
|
||||
}
|
||||
}
|
||||
@ -48,6 +46,7 @@ class PermissionsChecker
|
||||
* Get a folder permission.
|
||||
*
|
||||
* @param $folder
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getPermission($folder)
|
||||
@ -57,8 +56,10 @@ class PermissionsChecker
|
||||
|
||||
/**
|
||||
* Check if folder is writable by creating a temp file.
|
||||
* @param [type] $folder [description]
|
||||
* @return [type] [description]
|
||||
*
|
||||
* @param [type] $folder [description]
|
||||
*
|
||||
* @return [type] [description]
|
||||
*/
|
||||
private function isWritable($folder)
|
||||
{
|
||||
@ -71,6 +72,7 @@ class PermissionsChecker
|
||||
$file = $path.'.installer_test';
|
||||
if ($file && file_put_contents($file, 'test')) {
|
||||
unlink($file);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@ -90,9 +92,9 @@ class PermissionsChecker
|
||||
private function addFile($folder, $permission, $isSet)
|
||||
{
|
||||
array_push($this->results['permissions'], [
|
||||
'folder' => $folder,
|
||||
'folder' => $folder,
|
||||
'permission' => $permission,
|
||||
'isSet' => $isSet
|
||||
'isSet' => $isSet,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -109,4 +111,4 @@ class PermissionsChecker
|
||||
|
||||
$this->results['errors'] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,16 +11,16 @@ class canInstall
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param Redirector $redirect
|
||||
*
|
||||
* @return mixed
|
||||
* @param Redirector $redirect
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if($this->alreadyInstalled()) {
|
||||
|
||||
if ($this->alreadyInstalled()) {
|
||||
$installedRedirect = config('installer.installedAlreadyAction');
|
||||
|
||||
switch ($installedRedirect) {
|
||||
@ -28,6 +28,7 @@ class canInstall
|
||||
case 'route':
|
||||
$routeName = config('installer.installed.redirectOptions.route.name');
|
||||
$data = config('installer.installed.redirectOptions.route.message');
|
||||
|
||||
return redirect()->route($routeName)->with(['data' => $data]);
|
||||
break;
|
||||
|
||||
@ -47,6 +48,7 @@ class canInstall
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -2,11 +2,11 @@
|
||||
|
||||
// Check PHP version
|
||||
if (!version_compare(phpversion(), '7.0.0', '>=')) {
|
||||
echo 'PHP 7.x is required to run FreeScout.';
|
||||
exit();
|
||||
echo 'PHP 7.x is required to run FreeScout.';
|
||||
exit();
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* Laravel - A PHP Framework For Web Artisans.
|
||||
*
|
||||
* @author Taylor Otwell <taylor@laravel.com>
|
||||
|
@ -2,20 +2,19 @@
|
||||
/**
|
||||
* Application installer.
|
||||
*/
|
||||
|
||||
ini_set('display_errors', 'Off');
|
||||
|
||||
$root_dir = realpath(__DIR__.'/..').'/';
|
||||
|
||||
// Dotenv library for reading .env files
|
||||
require_once($root_dir.'vendor/vlucas/phpdotenv/src/Dotenv.php');
|
||||
require_once($root_dir.'vendor/vlucas/phpdotenv/src/Loader.php');
|
||||
require_once($root_dir.'vendor/vlucas/phpdotenv/src/Validator.php');
|
||||
require_once($root_dir.'vendor/vlucas/phpdotenv/src/Exception/ExceptionInterface.php');
|
||||
require_once($root_dir.'vendor/vlucas/phpdotenv/src/Exception/InvalidCallbackException.php');
|
||||
require_once($root_dir.'vendor/vlucas/phpdotenv/src/Exception/InvalidFileException.php');
|
||||
require_once($root_dir.'vendor/vlucas/phpdotenv/src/Exception/InvalidPathException.php');
|
||||
require_once($root_dir.'vendor/vlucas/phpdotenv/src/Exception/ValidationException.php');
|
||||
require_once $root_dir.'vendor/vlucas/phpdotenv/src/Dotenv.php';
|
||||
require_once $root_dir.'vendor/vlucas/phpdotenv/src/Loader.php';
|
||||
require_once $root_dir.'vendor/vlucas/phpdotenv/src/Validator.php';
|
||||
require_once $root_dir.'vendor/vlucas/phpdotenv/src/Exception/ExceptionInterface.php';
|
||||
require_once $root_dir.'vendor/vlucas/phpdotenv/src/Exception/InvalidCallbackException.php';
|
||||
require_once $root_dir.'vendor/vlucas/phpdotenv/src/Exception/InvalidFileException.php';
|
||||
require_once $root_dir.'vendor/vlucas/phpdotenv/src/Exception/InvalidPathException.php';
|
||||
require_once $root_dir.'vendor/vlucas/phpdotenv/src/Exception/ValidationException.php';
|
||||
// Symfony proces
|
||||
//require_once($root_dir.'vendor/symfony/process/Process.php');
|
||||
|
||||
@ -33,55 +32,55 @@ function generateRandomKey()
|
||||
|
||||
function writeNewEnvironmentFileWith($key, $environmentFilePath)
|
||||
{
|
||||
file_put_contents($environmentFilePath, preg_replace(
|
||||
"/^APP_KEY=/m",
|
||||
file_put_contents($environmentFilePath, preg_replace(
|
||||
'/^APP_KEY=/m',
|
||||
'APP_KEY='.$key,
|
||||
file_get_contents($environmentFilePath)
|
||||
));
|
||||
}
|
||||
|
||||
// Get app key
|
||||
// Get app key
|
||||
function getAppKey($root_dir, $check_cache = true)
|
||||
{
|
||||
// First check APP_KEY in cache
|
||||
if ($check_cache && file_exists($root_dir.'bootstrap/cache/config.php')) {
|
||||
$config = include $root_dir.'bootstrap/cache/config.php';
|
||||
// First check APP_KEY in cache
|
||||
if ($check_cache && file_exists($root_dir.'bootstrap/cache/config.php')) {
|
||||
$config = include $root_dir.'bootstrap/cache/config.php';
|
||||
|
||||
if (!empty($config)) {
|
||||
if (!empty($config['app']['key'])) {
|
||||
return $config['app']['key'];
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($config)) {
|
||||
if (!empty($config['app']['key'])) {
|
||||
return $config['app']['key'];
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Read .env file into $_ENV
|
||||
try {
|
||||
$dotenv = new Dotenv\Dotenv($root_dir);
|
||||
// If using load() if $_ENV['APP_KEY'] was present in .env before it will not be updated when reading
|
||||
$dotenv->overload();
|
||||
} catch (\Exception $e) {
|
||||
// Do nothing
|
||||
}
|
||||
// Read .env file into $_ENV
|
||||
try {
|
||||
$dotenv = new Dotenv\Dotenv($root_dir);
|
||||
// If using load() if $_ENV['APP_KEY'] was present in .env before it will not be updated when reading
|
||||
$dotenv->overload();
|
||||
} catch (\Exception $e) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
if (!empty($_ENV['APP_KEY'])) {
|
||||
return $_ENV['APP_KEY'];
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
if (!empty($_ENV['APP_KEY'])) {
|
||||
return $_ENV['APP_KEY'];
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function clearCache($root_dir)
|
||||
{
|
||||
if (file_exists($root_dir.'bootstrap/cache/config.php')) {
|
||||
unlink($root_dir.'bootstrap/cache/config.php');
|
||||
}
|
||||
if (file_exists($root_dir.'bootstrap/cache/config.php')) {
|
||||
unlink($root_dir.'bootstrap/cache/config.php');
|
||||
}
|
||||
}
|
||||
|
||||
function showError($msg)
|
||||
{
|
||||
echo <<<HTML
|
||||
echo <<<HTML
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
@ -111,9 +110,9 @@ HTML;
|
||||
|
||||
function showPermissionsError()
|
||||
{
|
||||
$root_dir_no_slash = realpath(__DIR__.'/..');
|
||||
$root_dir_no_slash = realpath(__DIR__.'/..');
|
||||
|
||||
showError('Web installer could not write data into <strong>'.$root_dir_no_slash.'/.env</strong> file. Please give your web server user (<strong>'.get_current_user().'</strong>) write permissions in <code>'.$root_dir_no_slash.'</code> folder:<br/><br/>
|
||||
showError('Web installer could not write data into <strong>'.$root_dir_no_slash.'/.env</strong> file. Please give your web server user (<strong>'.get_current_user().'</strong>) write permissions in <code>'.$root_dir_no_slash.'</code> folder:<br/><br/>
|
||||
<textarea rows="4" readonly="readonly" style="font-size:12px;">sudo chgrp '.get_current_user().' '.$root_dir_no_slash.'
|
||||
sudo chmod ug+rwx '.$root_dir_no_slash.'</textarea><br/>If it does not help, please follow <a href="http://freescout.net/install/#82-manual-installation" target="_blank">Manual installation</a> instructions.');
|
||||
}
|
||||
@ -122,41 +121,41 @@ $app_key = getAppKey($root_dir);
|
||||
|
||||
// Generate APP_KEY
|
||||
if (empty($app_key)) {
|
||||
// Copy .env.example
|
||||
if (!file_exists($root_dir.'.env')) {
|
||||
copy($root_dir.'.env.example', $root_dir.'.env');
|
||||
// Copy .env.example
|
||||
if (!file_exists($root_dir.'.env')) {
|
||||
copy($root_dir.'.env.example', $root_dir.'.env');
|
||||
|
||||
if (!file_exists($root_dir.'.env')) {
|
||||
//echo 'Please copy <code>.env.example</code> file to <code>.env</code> and reload this page.';
|
||||
showPermissionsError();
|
||||
exit();
|
||||
}
|
||||
}
|
||||
if (!file_exists($root_dir.'.env')) {
|
||||
//echo 'Please copy <code>.env.example</code> file to <code>.env</code> and reload this page.';
|
||||
showPermissionsError();
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
// Add APP_KEY= to the .env file if needed
|
||||
// Without APP_KEY= the key will not be generated
|
||||
if (!preg_match("/^APP_KEY=/m", file_get_contents($root_dir.'.env'))) {
|
||||
$append_result = file_put_contents($root_dir.'.env', PHP_EOL.'APP_KEY=', FILE_APPEND);
|
||||
if (!$append_result) {
|
||||
//showError('Could not write APP_KEY to .env file. Please run the following commands in SSH console:<br/><code>php artisan key:generate</code><br/><code>php artisan freescout:clear-cache</code>');
|
||||
showPermissionsError();
|
||||
exit();
|
||||
}
|
||||
}
|
||||
// Add APP_KEY= to the .env file if needed
|
||||
// Without APP_KEY= the key will not be generated
|
||||
if (!preg_match('/^APP_KEY=/m', file_get_contents($root_dir.'.env'))) {
|
||||
$append_result = file_put_contents($root_dir.'.env', PHP_EOL.'APP_KEY=', FILE_APPEND);
|
||||
if (!$append_result) {
|
||||
//showError('Could not write APP_KEY to .env file. Please run the following commands in SSH console:<br/><code>php artisan key:generate</code><br/><code>php artisan freescout:clear-cache</code>');
|
||||
showPermissionsError();
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
writeNewEnvironmentFileWith(generateRandomKey(), $root_dir.'.env');
|
||||
writeNewEnvironmentFileWith(generateRandomKey(), $root_dir.'.env');
|
||||
|
||||
// Clear cache
|
||||
// We have to clear cache to avoid infinite redirects
|
||||
clearCache($root_dir);
|
||||
|
||||
$app_key = getAppKey($root_dir, false);
|
||||
// Clear cache
|
||||
// We have to clear cache to avoid infinite redirects
|
||||
clearCache($root_dir);
|
||||
|
||||
$app_key = getAppKey($root_dir, false);
|
||||
}
|
||||
|
||||
if (!empty($app_key)) {
|
||||
// When APP_KEY generated, redirect to /install
|
||||
header("Location: /install");
|
||||
// When APP_KEY generated, redirect to /install
|
||||
header('Location: /install');
|
||||
} else {
|
||||
showPermissionsError();
|
||||
showPermissionsError();
|
||||
}
|
||||
exit();
|
||||
exit();
|
||||
|
196
public/tools.php
196
public/tools.php
@ -2,58 +2,57 @@
|
||||
/**
|
||||
* Application installer.
|
||||
*/
|
||||
|
||||
ini_set('display_errors', 'On');
|
||||
|
||||
$root_dir = realpath(__DIR__.'/..').'/';
|
||||
|
||||
// Dotenv library for reading .env files
|
||||
require_once($root_dir.'vendor/vlucas/phpdotenv/src/Dotenv.php');
|
||||
require_once($root_dir.'vendor/vlucas/phpdotenv/src/Loader.php');
|
||||
require_once($root_dir.'vendor/vlucas/phpdotenv/src/Validator.php');
|
||||
require_once($root_dir.'vendor/vlucas/phpdotenv/src/Exception/ExceptionInterface.php');
|
||||
require_once($root_dir.'vendor/vlucas/phpdotenv/src/Exception/InvalidCallbackException.php');
|
||||
require_once($root_dir.'vendor/vlucas/phpdotenv/src/Exception/InvalidFileException.php');
|
||||
require_once($root_dir.'vendor/vlucas/phpdotenv/src/Exception/InvalidPathException.php');
|
||||
require_once($root_dir.'vendor/vlucas/phpdotenv/src/Exception/ValidationException.php');
|
||||
require_once $root_dir.'vendor/vlucas/phpdotenv/src/Dotenv.php';
|
||||
require_once $root_dir.'vendor/vlucas/phpdotenv/src/Loader.php';
|
||||
require_once $root_dir.'vendor/vlucas/phpdotenv/src/Validator.php';
|
||||
require_once $root_dir.'vendor/vlucas/phpdotenv/src/Exception/ExceptionInterface.php';
|
||||
require_once $root_dir.'vendor/vlucas/phpdotenv/src/Exception/InvalidCallbackException.php';
|
||||
require_once $root_dir.'vendor/vlucas/phpdotenv/src/Exception/InvalidFileException.php';
|
||||
require_once $root_dir.'vendor/vlucas/phpdotenv/src/Exception/InvalidPathException.php';
|
||||
require_once $root_dir.'vendor/vlucas/phpdotenv/src/Exception/ValidationException.php';
|
||||
|
||||
// Get app key
|
||||
// Get app key
|
||||
function getAppKey($root_dir, $check_cache = true)
|
||||
{
|
||||
// First check APP_KEY in cache
|
||||
if ($check_cache && file_exists($root_dir.'bootstrap/cache/config.php')) {
|
||||
$config = include $root_dir.'bootstrap/cache/config.php';
|
||||
// First check APP_KEY in cache
|
||||
if ($check_cache && file_exists($root_dir.'bootstrap/cache/config.php')) {
|
||||
$config = include $root_dir.'bootstrap/cache/config.php';
|
||||
|
||||
if (!empty($config)) {
|
||||
if (!empty($config['app']['key'])) {
|
||||
return $config['app']['key'];
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($config)) {
|
||||
if (!empty($config['app']['key'])) {
|
||||
return $config['app']['key'];
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Read .env file into $_ENV
|
||||
try {
|
||||
$dotenv = new Dotenv\Dotenv($root_dir);
|
||||
// If using load() if $_ENV['APP_KEY'] was present in .env before it will not be updated when reading
|
||||
$dotenv->overload();
|
||||
} catch (\Exception $e) {
|
||||
// Do nothing
|
||||
}
|
||||
// Read .env file into $_ENV
|
||||
try {
|
||||
$dotenv = new Dotenv\Dotenv($root_dir);
|
||||
// If using load() if $_ENV['APP_KEY'] was present in .env before it will not be updated when reading
|
||||
$dotenv->overload();
|
||||
} catch (\Exception $e) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
if (!empty($_ENV['APP_KEY'])) {
|
||||
return $_ENV['APP_KEY'];
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
if (!empty($_ENV['APP_KEY'])) {
|
||||
return $_ENV['APP_KEY'];
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function clearCache($root_dir)
|
||||
{
|
||||
if (file_exists($root_dir.'bootstrap/cache/config.php')) {
|
||||
unlink($root_dir.'bootstrap/cache/config.php');
|
||||
}
|
||||
if (file_exists($root_dir.'bootstrap/cache/config.php')) {
|
||||
unlink($root_dir.'bootstrap/cache/config.php');
|
||||
}
|
||||
}
|
||||
|
||||
$alerts = [];
|
||||
@ -61,70 +60,69 @@ $errors = [];
|
||||
$app_key = $_POST['app_key'] ?? '';
|
||||
|
||||
if (!empty($_POST)) {
|
||||
if (trim($app_key) != trim(getAppKey($root_dir))) {
|
||||
$errors['app_key'] = 'Invalid App Key';
|
||||
} else {
|
||||
clearCache($root_dir);
|
||||
if ($_POST['action'] == 'cc') {
|
||||
$alerts[] = [
|
||||
'type' => 'success',
|
||||
'text' => 'Cache cleared successfully.',
|
||||
];
|
||||
} else {
|
||||
if (!function_exists('shell_exec')) {
|
||||
$alerts[] = [
|
||||
'type' => 'danger',
|
||||
'text' => '<code>shell_exec</code> function is unavailable. Can not run updating.',
|
||||
];
|
||||
} else {
|
||||
try {
|
||||
$php_path = 'php';
|
||||
if (!empty($_POST['php_path'])) {
|
||||
$php_path = $_POST['php_path'];
|
||||
}
|
||||
|
||||
if (trim($app_key) != trim(getAppKey($root_dir))) {
|
||||
$errors['app_key'] = 'Invalid App Key';
|
||||
} else {
|
||||
clearCache($root_dir);
|
||||
if ($_POST['action'] == 'cc') {
|
||||
$alerts[] = [
|
||||
'type' => 'success',
|
||||
'text' => 'Cache cleared successfully.',
|
||||
];
|
||||
} else {
|
||||
if (!function_exists('shell_exec')) {
|
||||
$alerts[] = [
|
||||
'type' => 'danger',
|
||||
'text' => '<code>shell_exec</code> function is unavailable. Can not run updating.',
|
||||
];
|
||||
} else {
|
||||
try {
|
||||
$php_path = 'php';
|
||||
if (!empty($_POST['php_path'])) {
|
||||
$php_path = $_POST['php_path'];
|
||||
}
|
||||
// First check PHP version
|
||||
$version_output = shell_exec($php_path.' -v');
|
||||
|
||||
// First check PHP version
|
||||
$version_output = shell_exec($php_path.' -v');
|
||||
|
||||
if (!strstr($version_output, 'PHP 7.')) {
|
||||
$alerts[] = [
|
||||
'type' => 'danger',
|
||||
'text' => 'Incorrect PHP version (7.x is required):<br/><br/><pre>'.htmlspecialchars($version_output).'</pre>',
|
||||
];
|
||||
} else {
|
||||
if ($_POST['action'] == 'update') {
|
||||
// Update Now
|
||||
$output = shell_exec($php_path.' '.$root_dir.'artisan freescout:update --force');
|
||||
if (strstr($output, 'Broadcasting queue restart signal')) {
|
||||
$alerts[] = [
|
||||
'type' => 'success',
|
||||
'text' => 'Updating finished:<br/><pre>'.htmlspecialchars($output).'</pre>',
|
||||
];
|
||||
} else {
|
||||
$alerts[] = [
|
||||
'type' => 'danger',
|
||||
'text' => 'Something went wrong... Please <strong><a href="https://freescout.net/download/" target="_blank">download</a></strong> the latest version and extract it into your application folder replacing existing files. After that click "Migrate DB" button.<br/><br/><pre>'.htmlspecialchars($output).'</pre>',
|
||||
];
|
||||
}
|
||||
} else {
|
||||
// Migreate DB
|
||||
$output = shell_exec($php_path.' '.$root_dir.'artisan migrate --force');
|
||||
$alerts[] = [
|
||||
'type' => 'success',
|
||||
'text' => 'Migrating finished:<br/><br/><pre>'.htmlspecialchars($output).'</pre>',
|
||||
];
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$alerts[] = [
|
||||
'type' => 'danger',
|
||||
'text' => 'Error occured: '.htmlspecialchars($e->getMessage()),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!strstr($version_output, 'PHP 7.')) {
|
||||
$alerts[] = [
|
||||
'type' => 'danger',
|
||||
'text' => 'Incorrect PHP version (7.x is required):<br/><br/><pre>'.htmlspecialchars($version_output).'</pre>',
|
||||
];
|
||||
} else {
|
||||
if ($_POST['action'] == 'update') {
|
||||
// Update Now
|
||||
$output = shell_exec($php_path.' '.$root_dir.'artisan freescout:update --force');
|
||||
if (strstr($output, 'Broadcasting queue restart signal')) {
|
||||
$alerts[] = [
|
||||
'type' => 'success',
|
||||
'text' => 'Updating finished:<br/><pre>'.htmlspecialchars($output).'</pre>',
|
||||
];
|
||||
} else {
|
||||
$alerts[] = [
|
||||
'type' => 'danger',
|
||||
'text' => 'Something went wrong... Please <strong><a href="https://freescout.net/download/" target="_blank">download</a></strong> the latest version and extract it into your application folder replacing existing files. After that click "Migrate DB" button.<br/><br/><pre>'.htmlspecialchars($output).'</pre>',
|
||||
];
|
||||
}
|
||||
} else {
|
||||
// Migreate DB
|
||||
$output = shell_exec($php_path.' '.$root_dir.'artisan migrate --force');
|
||||
$alerts[] = [
|
||||
'type' => 'success',
|
||||
'text' => 'Migrating finished:<br/><br/><pre>'.htmlspecialchars($output).'</pre>',
|
||||
];
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$alerts[] = [
|
||||
'type' => 'danger',
|
||||
'text' => 'Error occured: '.htmlspecialchars($e->getMessage()),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -2,174 +2,174 @@
|
||||
|
||||
return [
|
||||
|
||||
/**
|
||||
/*
|
||||
*
|
||||
* Shared translations.
|
||||
*
|
||||
*/
|
||||
'title' => 'FreeScout Installer',
|
||||
'next' => 'Next Step',
|
||||
'back' => 'Previous',
|
||||
'title' => 'FreeScout Installer',
|
||||
'next' => 'Next Step',
|
||||
'back' => 'Previous',
|
||||
'finish' => 'Install',
|
||||
'forms' => [
|
||||
'forms' => [
|
||||
'errorTitle' => 'The Following errors occurred:',
|
||||
],
|
||||
|
||||
/**
|
||||
/*
|
||||
*
|
||||
* Home page translations.
|
||||
*
|
||||
*/
|
||||
'welcome' => [
|
||||
'templateTitle' => 'Welcome',
|
||||
'title' => 'FreeScout Installer',
|
||||
'message' => 'Easy Installation and Setup Wizard.',
|
||||
'next' => 'Check Requirements',
|
||||
'title' => 'FreeScout Installer',
|
||||
'message' => 'Easy Installation and Setup Wizard.',
|
||||
'next' => 'Check Requirements',
|
||||
],
|
||||
|
||||
/**
|
||||
/*
|
||||
*
|
||||
* Requirements page translations.
|
||||
*
|
||||
*/
|
||||
'requirements' => [
|
||||
'templateTitle' => 'Step 1 | Server Requirements',
|
||||
'title' => 'Server Requirements',
|
||||
'next' => 'Check Permissions',
|
||||
'title' => 'Server Requirements',
|
||||
'next' => 'Check Permissions',
|
||||
],
|
||||
|
||||
/**
|
||||
/*
|
||||
*
|
||||
* Permissions page translations.
|
||||
*
|
||||
*/
|
||||
'permissions' => [
|
||||
'templateTitle' => 'Step 2 | Permissions',
|
||||
'title' => 'Permissions',
|
||||
'next' => 'Configure Environment',
|
||||
'title' => 'Permissions',
|
||||
'next' => 'Configure Environment',
|
||||
],
|
||||
|
||||
/**
|
||||
/*
|
||||
*
|
||||
* Environment page translations.
|
||||
*
|
||||
*/
|
||||
'environment' => [
|
||||
'menu' => [
|
||||
'templateTitle' => 'Step 3 | Environment Settings',
|
||||
'title' => 'Environment Settings',
|
||||
'desc' => 'Please select how you want to configure the apps <code>.env</code> file.',
|
||||
'wizard-button' => 'Form Wizard Setup',
|
||||
'templateTitle' => 'Step 3 | Environment Settings',
|
||||
'title' => 'Environment Settings',
|
||||
'desc' => 'Please select how you want to configure the apps <code>.env</code> file.',
|
||||
'wizard-button' => 'Form Wizard Setup',
|
||||
'classic-button' => 'Classic Text Editor',
|
||||
],
|
||||
'wizard' => [
|
||||
'templateTitle' => 'Step 3 | Environment Settings | Guided Wizard',
|
||||
'title' => 'Guided <code>.env</code> Wizard',
|
||||
'tabs' => [
|
||||
'title' => 'Guided <code>.env</code> Wizard',
|
||||
'tabs' => [
|
||||
'environment' => 'Environment',
|
||||
'database' => 'Database',
|
||||
'application' => 'Application'
|
||||
'database' => 'Database',
|
||||
'application' => 'Application',
|
||||
],
|
||||
'form' => [
|
||||
'name_required' => 'An environment name is required.',
|
||||
'app_name_label' => 'App Name',
|
||||
'app_name_placeholder' => 'App Name',
|
||||
'app_environment_label' => 'App Environment',
|
||||
'app_environment_label_local' => 'Local',
|
||||
'name_required' => 'An environment name is required.',
|
||||
'app_name_label' => 'App Name',
|
||||
'app_name_placeholder' => 'App Name',
|
||||
'app_environment_label' => 'App Environment',
|
||||
'app_environment_label_local' => 'Local',
|
||||
'app_environment_label_developement' => 'Development',
|
||||
'app_environment_label_qa' => 'Qa',
|
||||
'app_environment_label_production' => 'Production',
|
||||
'app_environment_label_other' => 'Other',
|
||||
'app_environment_placeholder_other' => 'Enter your environment...',
|
||||
'app_debug_label' => 'App Debug',
|
||||
'app_debug_label_true' => 'True',
|
||||
'app_debug_label_false' => 'False',
|
||||
'app_log_level_label' => 'App Log Level',
|
||||
'app_log_level_label_debug' => 'debug',
|
||||
'app_log_level_label_info' => 'info',
|
||||
'app_log_level_label_notice' => 'notice',
|
||||
'app_log_level_label_warning' => 'warning',
|
||||
'app_log_level_label_error' => 'error',
|
||||
'app_log_level_label_critical' => 'critical',
|
||||
'app_log_level_label_alert' => 'alert',
|
||||
'app_log_level_label_emergency' => 'emergency',
|
||||
'app_url_label' => 'App Url',
|
||||
'app_url_placeholder' => 'App Url',
|
||||
'db_connection_label' => 'Database Connection',
|
||||
'db_connection_label_mysql' => 'mysql',
|
||||
'db_connection_label_sqlite' => 'sqlite',
|
||||
'db_connection_label_pgsql' => 'pgsql',
|
||||
'db_connection_label_sqlsrv' => 'sqlsrv',
|
||||
'db_host_label' => 'Database Host',
|
||||
'db_host_placeholder' => 'Database Host',
|
||||
'db_port_label' => 'Database Port',
|
||||
'db_port_placeholder' => 'Database Port',
|
||||
'db_name_label' => 'Database Name',
|
||||
'db_name_placeholder' => 'Database Name',
|
||||
'db_username_label' => 'Database User Name',
|
||||
'db_username_placeholder' => 'Database User Name',
|
||||
'db_password_label' => 'Database Password',
|
||||
'db_password_placeholder' => 'Database Password',
|
||||
'app_environment_label_qa' => 'Qa',
|
||||
'app_environment_label_production' => 'Production',
|
||||
'app_environment_label_other' => 'Other',
|
||||
'app_environment_placeholder_other' => 'Enter your environment...',
|
||||
'app_debug_label' => 'App Debug',
|
||||
'app_debug_label_true' => 'True',
|
||||
'app_debug_label_false' => 'False',
|
||||
'app_log_level_label' => 'App Log Level',
|
||||
'app_log_level_label_debug' => 'debug',
|
||||
'app_log_level_label_info' => 'info',
|
||||
'app_log_level_label_notice' => 'notice',
|
||||
'app_log_level_label_warning' => 'warning',
|
||||
'app_log_level_label_error' => 'error',
|
||||
'app_log_level_label_critical' => 'critical',
|
||||
'app_log_level_label_alert' => 'alert',
|
||||
'app_log_level_label_emergency' => 'emergency',
|
||||
'app_url_label' => 'App Url',
|
||||
'app_url_placeholder' => 'App Url',
|
||||
'db_connection_label' => 'Database Connection',
|
||||
'db_connection_label_mysql' => 'mysql',
|
||||
'db_connection_label_sqlite' => 'sqlite',
|
||||
'db_connection_label_pgsql' => 'pgsql',
|
||||
'db_connection_label_sqlsrv' => 'sqlsrv',
|
||||
'db_host_label' => 'Database Host',
|
||||
'db_host_placeholder' => 'Database Host',
|
||||
'db_port_label' => 'Database Port',
|
||||
'db_port_placeholder' => 'Database Port',
|
||||
'db_name_label' => 'Database Name',
|
||||
'db_name_placeholder' => 'Database Name',
|
||||
'db_username_label' => 'Database User Name',
|
||||
'db_username_placeholder' => 'Database User Name',
|
||||
'db_password_label' => 'Database Password',
|
||||
'db_password_placeholder' => 'Database Password',
|
||||
|
||||
'app_tabs' => [
|
||||
'more_info' => 'More Info',
|
||||
'broadcasting_title' => 'Broadcasting, Caching, Session, & Queue',
|
||||
'broadcasting_label' => 'Broadcast Driver',
|
||||
'more_info' => 'More Info',
|
||||
'broadcasting_title' => 'Broadcasting, Caching, Session, & Queue',
|
||||
'broadcasting_label' => 'Broadcast Driver',
|
||||
'broadcasting_placeholder' => 'Broadcast Driver',
|
||||
'cache_label' => 'Cache Driver',
|
||||
'cache_placeholder' => 'Cache Driver',
|
||||
'session_label' => 'Session Driver',
|
||||
'session_placeholder' => 'Session Driver',
|
||||
'queue_label' => 'Queue Driver',
|
||||
'queue_placeholder' => 'Queue Driver',
|
||||
'redis_label' => 'Redis Driver',
|
||||
'redis_host' => 'Redis Host',
|
||||
'redis_password' => 'Redis Password',
|
||||
'redis_port' => 'Redis Port',
|
||||
'cache_label' => 'Cache Driver',
|
||||
'cache_placeholder' => 'Cache Driver',
|
||||
'session_label' => 'Session Driver',
|
||||
'session_placeholder' => 'Session Driver',
|
||||
'queue_label' => 'Queue Driver',
|
||||
'queue_placeholder' => 'Queue Driver',
|
||||
'redis_label' => 'Redis Driver',
|
||||
'redis_host' => 'Redis Host',
|
||||
'redis_password' => 'Redis Password',
|
||||
'redis_port' => 'Redis Port',
|
||||
|
||||
'mail_label' => 'Mail',
|
||||
'mail_driver_label' => 'Mail Driver',
|
||||
'mail_driver_placeholder' => 'Mail Driver',
|
||||
'mail_host_label' => 'Mail Host',
|
||||
'mail_host_placeholder' => 'Mail Host',
|
||||
'mail_port_label' => 'Mail Port',
|
||||
'mail_port_placeholder' => 'Mail Port',
|
||||
'mail_username_label' => 'Mail Username',
|
||||
'mail_username_placeholder' => 'Mail Username',
|
||||
'mail_password_label' => 'Mail Password',
|
||||
'mail_password_placeholder' => 'Mail Password',
|
||||
'mail_encryption_label' => 'Mail Encryption',
|
||||
'mail_label' => 'Mail',
|
||||
'mail_driver_label' => 'Mail Driver',
|
||||
'mail_driver_placeholder' => 'Mail Driver',
|
||||
'mail_host_label' => 'Mail Host',
|
||||
'mail_host_placeholder' => 'Mail Host',
|
||||
'mail_port_label' => 'Mail Port',
|
||||
'mail_port_placeholder' => 'Mail Port',
|
||||
'mail_username_label' => 'Mail Username',
|
||||
'mail_username_placeholder' => 'Mail Username',
|
||||
'mail_password_label' => 'Mail Password',
|
||||
'mail_password_placeholder' => 'Mail Password',
|
||||
'mail_encryption_label' => 'Mail Encryption',
|
||||
'mail_encryption_placeholder' => 'Mail Encryption',
|
||||
|
||||
'pusher_label' => 'Pusher',
|
||||
'pusher_app_id_label' => 'Pusher App Id',
|
||||
'pusher_app_id_palceholder' => 'Pusher App Id',
|
||||
'pusher_app_key_label' => 'Pusher App Key',
|
||||
'pusher_app_key_palceholder' => 'Pusher App Key',
|
||||
'pusher_app_secret_label' => 'Pusher App Secret',
|
||||
'pusher_label' => 'Pusher',
|
||||
'pusher_app_id_label' => 'Pusher App Id',
|
||||
'pusher_app_id_palceholder' => 'Pusher App Id',
|
||||
'pusher_app_key_label' => 'Pusher App Key',
|
||||
'pusher_app_key_palceholder' => 'Pusher App Key',
|
||||
'pusher_app_secret_label' => 'Pusher App Secret',
|
||||
'pusher_app_secret_palceholder' => 'Pusher App Secret',
|
||||
],
|
||||
'buttons' => [
|
||||
'setup_database' => 'Setup Database',
|
||||
'setup_database' => 'Setup Database',
|
||||
'setup_application' => 'Setup Application',
|
||||
'install' => 'Install',
|
||||
'install' => 'Install',
|
||||
],
|
||||
],
|
||||
],
|
||||
'classic' => [
|
||||
'templateTitle' => 'Step 3 | Environment Settings | Classic Editor',
|
||||
'title' => 'Classic Environment Editor',
|
||||
'save' => 'Save .env',
|
||||
'back' => 'Use Form Wizard',
|
||||
'install' => 'Save and Install',
|
||||
'title' => 'Classic Environment Editor',
|
||||
'save' => 'Save .env',
|
||||
'back' => 'Use Form Wizard',
|
||||
'install' => 'Save and Install',
|
||||
],
|
||||
'success' => 'Your .env file settings have been saved.',
|
||||
'errors' => 'Unable to save the .env file, Please create it manually.',
|
||||
'errors' => 'Unable to save the .env file, Please create it manually.',
|
||||
],
|
||||
|
||||
'install' => 'Install',
|
||||
|
||||
/**
|
||||
/*
|
||||
*
|
||||
* Installed Log translations.
|
||||
*
|
||||
@ -178,36 +178,36 @@ return [
|
||||
'success_log_message' => 'FreeScout Installer successfully INSTALLED on ',
|
||||
],
|
||||
|
||||
/**
|
||||
/*
|
||||
*
|
||||
* Final page translations.
|
||||
*
|
||||
*/
|
||||
'final' => [
|
||||
'title' => 'Installation Finished',
|
||||
'title' => 'Installation Finished',
|
||||
'templateTitle' => 'Installation Finished',
|
||||
'finished' => 'Application has been successfully installed.',
|
||||
'migration' => 'Migration & Seed Console Output:',
|
||||
'console' => 'Application Console Output:',
|
||||
'log' => 'Installation Log Entry:',
|
||||
'env' => 'Final .env File:',
|
||||
'exit' => 'Click here to exit',
|
||||
'finished' => 'Application has been successfully installed.',
|
||||
'migration' => 'Migration & Seed Console Output:',
|
||||
'console' => 'Application Console Output:',
|
||||
'log' => 'Installation Log Entry:',
|
||||
'env' => 'Final .env File:',
|
||||
'exit' => 'Click here to exit',
|
||||
],
|
||||
|
||||
/**
|
||||
/*
|
||||
*
|
||||
* Update specific translations
|
||||
*
|
||||
*/
|
||||
'updater' => [
|
||||
/**
|
||||
/*
|
||||
*
|
||||
* Shared translations.
|
||||
*
|
||||
*/
|
||||
'title' => 'FreeScout Updater',
|
||||
|
||||
/**
|
||||
/*
|
||||
*
|
||||
* Welcome page translations for update feature.
|
||||
*
|
||||
@ -217,26 +217,26 @@ return [
|
||||
'message' => 'Welcome to the update wizard.',
|
||||
],
|
||||
|
||||
/**
|
||||
/*
|
||||
*
|
||||
* Welcome page translations for update feature.
|
||||
*
|
||||
*/
|
||||
'overview' => [
|
||||
'title' => 'Overview',
|
||||
'message' => 'There is 1 update.|There are :number updates.',
|
||||
'install_updates' => "Install Updates"
|
||||
'title' => 'Overview',
|
||||
'message' => 'There is 1 update.|There are :number updates.',
|
||||
'install_updates' => 'Install Updates',
|
||||
],
|
||||
|
||||
/**
|
||||
/*
|
||||
*
|
||||
* Final page translations.
|
||||
*
|
||||
*/
|
||||
'final' => [
|
||||
'title' => 'Finished',
|
||||
'title' => 'Finished',
|
||||
'finished' => 'Application\'s database has been successfully updated.',
|
||||
'exit' => 'Click here to exit',
|
||||
'exit' => 'Click here to exit',
|
||||
],
|
||||
|
||||
'log' => [
|
||||
|
@ -94,4 +94,4 @@ Route::post('/modules/ajax', ['uses' => 'ModulesController@ajax', 'laroute' => t
|
||||
Route::get('/system/status', ['uses' => 'SystemController@status', 'middleware' => ['auth', 'roles'], 'roles' => ['admin']])->name('system');
|
||||
Route::get('/system/tools', ['uses' => 'SystemController@tools', 'middleware' => ['auth', 'roles'], 'roles' => ['admin']])->name('system.tools');
|
||||
Route::post('/system/tools', ['uses' => 'SystemController@toolsExecute', 'middleware' => ['auth', 'roles'], 'roles' => ['admin']]);
|
||||
Route::post('/system/ajax', ['uses' => 'SystemController@ajax', 'laroute' => true, 'middleware' => ['auth', 'roles'], 'roles' => ['admin']])->name('system.ajax');
|
||||
Route::post('/system/ajax', ['uses' => 'SystemController@ajax', 'laroute' => true, 'middleware' => ['auth', 'roles'], 'roles' => ['admin']])->name('system.ajax');
|
||||
|
Loading…
x
Reference in New Issue
Block a user