Revisão ab2f5151 app/Console/Commands/Expresso/SieveGetUid.php
app/Console/Commands/Expresso/SieveGetUid.php | ||
---|---|---|
13 | 13 |
* |
14 | 14 |
* @var string |
15 | 15 |
*/ |
16 |
protected $signature = 'expresso:sieve-get {--u|uid=} {cmd?}';
|
|
16 |
protected $signature = 'expresso:get-user-sieve-filters-by-line {--u|uid=} {cmd?}';
|
|
17 | 17 |
|
18 | 18 |
/** |
19 | 19 |
* The console command description. |
20 | 20 |
* |
21 | 21 |
* @var string |
22 | 22 |
*/ |
23 |
protected $description = 'Lista os scripts sieve do usuario';
|
|
23 |
protected $description = 'lista os filtros de usuários ( entrada: usuários separados por vírgula )';
|
|
24 | 24 |
|
25 | 25 |
/** |
26 | 26 |
* Create a new command instance. |
... | ... | |
43 | 43 |
|
44 | 44 |
$uid = $this->option('uid') ?? null; |
45 | 45 |
|
46 |
if( isset($arguments['cmd']) && $arguments['cmd'] == 'help' ) |
|
47 |
{ |
|
48 |
$this->help(); |
|
49 |
|
|
50 |
} else { |
|
51 |
|
|
52 |
if( !is_null($uid) ){ |
|
53 |
|
|
54 |
$sieveRules = $this->getSieveRules($uid); |
|
55 |
|
|
56 |
if( isset($arguments['cmd']) && $arguments['cmd'] == 'print' ) |
|
57 |
{ |
|
58 |
$rules = []; |
|
59 |
foreach( $sieveRules as $key => $sieve ){ |
|
60 |
$rules[$key]['regra'] = unserialize( $sieve->rule ); |
|
61 |
$rules[$key]['habilitada'] = $sieve->is_enabled; |
|
62 |
$rules[$key]['dt_criacao'] = date('d/m/Y', strtotime($sieve->created_dt)); |
|
63 |
|
|
64 |
print_r( $rules[$key] ); |
|
65 |
} |
|
66 |
} |
|
67 |
|
|
68 |
if( isset($arguments['cmd']) && $arguments['cmd'] == 'file' ) |
|
69 |
{ |
|
70 |
$lines = "Usuario : " . $uid . PHP_EOL; |
|
71 | 46 |
|
72 |
foreach( $sieveRules as $key => $sieve ){ |
|
73 |
$lines .= "regra : " . $sieve->rule . PHP_EOL; |
|
74 |
$lines .= "habilitada : " . $sieve->is_enabled . PHP_EOL; |
|
75 |
$lines .= "dt_criacao : " . date('d/m/Y', strtotime($sieve->created_dt)) . PHP_EOL; |
|
76 |
$lines .= "************************************************************************" . PHP_EOL . PHP_EOL; |
|
77 |
} |
|
47 |
if( !is_null($uid) ){ |
|
78 | 48 |
|
79 |
Storage::put('file/file_'.$uid.'.txt', $lines ); |
|
49 |
$sieveRules = $this->getSieveRules($uid); |
|
50 |
|
|
51 |
if( isset($arguments['cmd']) && $arguments['cmd'] == 'print' ) |
|
52 |
{ |
|
53 |
$rules = []; |
|
54 |
foreach( $sieveRules as $key => $sieve ){ |
|
55 |
$rules[$key]['regra'] = unserialize( $sieve->rule ); |
|
56 |
$rules[$key]['habilitada'] = $sieve->is_enabled; |
|
57 |
$rules[$key]['dt_criacao'] = date('d/m/Y', strtotime($sieve->created_dt)); |
|
58 |
|
|
59 |
print_r( $rules[$key] ); |
|
80 | 60 |
} |
61 |
} |
|
81 | 62 |
|
82 |
if( isset($arguments['cmd']) && $arguments['cmd'] == 'fileSogo' ) |
|
83 |
{ |
|
84 |
print_r( storage_path('fileSogo') ); |
|
63 |
if( isset($arguments['cmd']) && $arguments['cmd'] == 'file' ) |
|
64 |
{ |
|
65 |
$lines = "Usuario : " . $uid . PHP_EOL; |
|
66 |
|
|
67 |
foreach( $sieveRules as $key => $sieve ){ |
|
68 |
$lines .= "regra : " . $sieve->rule . PHP_EOL; |
|
69 |
$lines .= "habilitada : " . $sieve->is_enabled . PHP_EOL; |
|
70 |
$lines .= "dt_criacao : " . date('d/m/Y', strtotime($sieve->created_dt)) . PHP_EOL; |
|
71 |
$lines .= "************************************************************************" . PHP_EOL . PHP_EOL; |
|
85 | 72 |
} |
73 |
|
|
74 |
Storage::put('file/file_'.$uid.'.txt', $lines ); |
|
86 | 75 |
} |
87 |
} |
|
88 | 76 |
|
89 |
$this->newLine(); |
|
77 |
if( isset($arguments['cmd']) && $arguments['cmd'] == 'fileSogo' ) |
|
78 |
{ |
|
79 |
print_r( storage_path('fileSogo') ); |
|
80 |
} |
|
81 |
} |
|
90 | 82 |
} |
91 | 83 |
|
92 | 84 |
private function getSieveRules( $user ) |
... | ... | |
98 | 90 |
|
99 | 91 |
return $sieveRules; |
100 | 92 |
} |
101 |
|
|
102 |
private function help() |
|
103 |
{ |
|
104 |
$this->newLine(); |
|
105 |
$this->info('EXEMPLO DE UTILIZACAO : '); |
|
106 |
$this->info('Ex: php artisan expresso:sieve-get --uid=<000000> { print | file | fileSogo }'); |
|
107 |
$this->newLine(); |
|
108 |
} |
|
109 | 93 |
} |
Exportar para Unified diff