1
0
mirror of https://github.com/freescout-helpdesk/freescout.git synced 2024-11-25 11:52:29 +01:00

Merge pull request #116 from freescout-helpdesk/analysis-zGngEk

Apply fixes from StyleCI
This commit is contained in:
FreeScout 2018-11-12 16:35:47 +03:00 committed by GitHub
commit d99636afb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 20 additions and 21 deletions

View File

@ -4,7 +4,6 @@ namespace App\Console\Commands;
use App\Misc\WpApi;
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
class ModuleCheckLicenses extends Command
{
@ -41,23 +40,22 @@ class ModuleCheckLicenses extends Command
{
// Get active official modules and check validity of their licenses
$modules = \Module::getActive();
$this->info('Active modules found: '.count($modules));
foreach ($modules as $module) {
$license = $module->getLicense();
if (!$module->isOfficial() || !$license) {
continue;
}
$params = [
'license' => $license,
'module_alias' => $module->getAlias(),
'url' => \App\Module::getAppUrl()
'url' => \App\Module::getAppUrl(),
];
$result = WpApi::checkLicense($params);
if (!empty($result['status']) && $result['status'] != 'valid') {
$msg = 'Module '.$module->getName().' has been deactivated due to invalid license: '.json_encode($result);
$this->error($module->getName().': '.$msg);

View File

@ -1388,5 +1388,4 @@ class ConversationsController extends Controller
return redirect()->away($conversation->url($folder_id, null, ['show_draft' => $thread->id]));
}
}

View File

@ -257,17 +257,16 @@ class ModulesController extends Controller
$params = [
'license' => $module->getLicense(),
'module_alias' => $alias,
'url' => \App\Module::getAppUrl()
'url' => \App\Module::getAppUrl(),
];
$license_result = WpApi::checkLicense($params);
if (!empty($license_result['code']) && !empty($license_result['message'])) {
// Remove remembered license key and deactivate license in DB
\App\Module::deactivateLicense($alias, '');
$response['msg'] = $license_result['message'];
} elseif (!empty($license_result['status']) && $license_result['status'] != 'valid' && $license_result['status'] != 'inactive')
{
} elseif (!empty($license_result['status']) && $license_result['status'] != 'valid' && $license_result['status'] != 'inactive') {
// Remove remembered license key and deactivate license in DB
\App\Module::deactivateLicense($alias, '');

View File

@ -110,9 +110,10 @@ class PublicController extends Controller
/*
* Set a thread as read by customer
*/
public function setThreadAsRead($conversation_id, $thread_id) {
public function setThreadAsRead($conversation_id, $thread_id)
{
$conversation = Conversation::findOrFail($conversation_id);
$thread = Thread::findOrFail($thread_id);
$thread = Thread::findOrFail($thread_id);
// We only track the first opening
if (empty($thread->opened_at)) {
@ -132,5 +133,4 @@ class PublicController extends Controller
return $response;
}
}

View File

@ -162,6 +162,7 @@ class Module extends Model
/**
* Get URL used to active and check license.
*
* @return [type] [description]
*/
public static function getAppUrl()

View File

@ -1,7 +1,7 @@
<?php
namespace App;
use App\Attachment;
use Illuminate\Database\Eloquent\Model;
class Thread extends Model
@ -142,8 +142,8 @@ class Thread extends Model
'opened_at',
'created_at',
'updated_at',
'deleted_at'
];
'deleted_at',
];
/**
* The user assigned to this thread (assignedTo).

View File

@ -368,16 +368,15 @@ class User extends Authenticatable
if (!$dateForHuman) {
return '';
}
}
if ( stripos($dateForHuman, 'just') === false ) {
if (stripos($dateForHuman, 'just') === false) {
return $dateForHuman.' @ '.$date->format('H:i');
} else {
return $dateForHuman;
}
}
public static function getUserPermissionName($user_permission)
{
$user_permission_names = [

View File

@ -476,7 +476,8 @@ abstract class Module extends ServiceProvider
/**
* Check if module is official.
* @return boolean [description]
*
* @return bool [description]
*/
public function isOfficial()
{
@ -485,6 +486,7 @@ abstract class Module extends ServiceProvider
/**
* Get module license from DB.
*
* @return [type] [description]
*/
public function getLicense()

View File

@ -291,6 +291,7 @@ abstract class Repository implements RepositoryInterface, Countable
/**
* Get active modules.
*
* @return [type] [description]
*/
public function getActive() : array

View File

@ -97,4 +97,4 @@ Route::post('/system/tools', ['uses' => 'SystemController@toolsExecute', 'middle
Route::post('/system/ajax', ['uses' => 'SystemController@ajax', 'laroute' => true, 'middleware' => ['auth', 'roles'], 'roles' => ['admin']])->name('system.ajax');
// Open tracking
Route::get('/thread/read/{conversation_id}/{thread_id}', 'PublicController@setThreadAsRead')->name('open_tracking.set_read');
Route::get('/thread/read/{conversation_id}/{thread_id}', 'PublicController@setThreadAsRead')->name('open_tracking.set_read');