Skip to content
This repository was archived by the owner on Mar 26, 2022. It is now read-only.

Commit ec0cb7f

Browse files
committed
Merge remote-tracking branch 'origin/uran-2.x'
2 parents 2bb351a + a634f60 commit ec0cb7f

File tree

160 files changed

+2171
-1371
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+2171
-1371
lines changed

.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,16 @@ REDIS_HOST=127.0.0.1
2323
REDIS_PASSWORD=null
2424
REDIS_PORT=6379
2525

26+
MAIL_TEST_ADMIN=[email protected]
27+
MAIL_ACTIVE=false
2628
MAIL_DRIVER=smtp
2729
MAIL_HOST=smtp.mailtrap.io
2830
MAIL_PORT=2525
2931
MAIL_USERNAME=null
3032
MAIL_PASSWORD=null
3133
MAIL_ENCRYPTION=null
34+
MAIL_FROM_ADDRESS=[email protected]
35+
MAIL_REPLYTO_ADDRESS=[email protected]
3236

3337
AWS_ACCESS_KEY_ID=
3438
AWS_SECRET_ACCESS_KEY=
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use Illuminate\Console\Command;
6+
7+
require_once base_path('app/Console/Commands/Helpers/GenerateLanguageFile.php');
8+
9+
class AddExpression extends Command
10+
{
11+
/**
12+
* The name and signature of the console command.
13+
*
14+
* @var string
15+
*/
16+
protected $signature = 'locale:add
17+
{language : the language to add eg. en}
18+
{key : the key of the expression eg. general.home}
19+
{value : the localized value of the expression}
20+
{--F|force : Whether confirmation is required to overwrite values}';
21+
22+
/**
23+
* The console command description.
24+
*
25+
* @var string
26+
*/
27+
protected $description = 'Add an expression to a language file';
28+
29+
/**
30+
* Create a new command instance.
31+
*
32+
* @return void
33+
*/
34+
public function __construct()
35+
{
36+
parent::__construct();
37+
}
38+
39+
/**
40+
* Execute the console command.
41+
*
42+
* @return mixed
43+
*/
44+
public function handle()
45+
{
46+
$language = $this->argument('language');
47+
$file = explode('.', $this->argument('key'))[0];
48+
$expression_key = explode('.', $this->argument('key'))[1];
49+
$expression_value = $this->argument('value');
50+
$reviewed = $this->option('force');
51+
$expressions = require base_path('resources/lang/'.$language.'/'.$file.'.php');
52+
if (! ($reviewed)) {
53+
if (isset($expressions[$expression_key])) {
54+
if ($this->confirm('Do you want to override '.$expressions[$expression_key].' to '.$expression_value.'?')) {
55+
$reviewed = true;
56+
}
57+
} else {
58+
if ($this->confirm('Do you want to set '.$expression_key.' as '.$expression_value.'?')) {
59+
$reviewed = true;
60+
}
61+
}
62+
}
63+
if ($reviewed) {
64+
$expressions[$expression_key] = $expression_value;
65+
if (! (ksort($expressions))) {
66+
$this->error('Sorting '.$file_in.' failed.');
67+
}
68+
$file_write = fopen(base_path('resources/lang/'.$language.'/'.$file.'.php'), 'w');
69+
if (! (generate_file($file_write, $expressions))) {
70+
$this->error('Writing to '.$file.' failed.');
71+
}
72+
$this->comment('Set '.$expression_key.' to '.$expression_value.'.');
73+
} else {
74+
$this->comment('Nothing changed.');
75+
}
76+
}
77+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
if (! function_exists('var_export54')) {
4+
function var_export54($var, $indent = '')
5+
{
6+
switch (gettype($var)) {
7+
case 'string':
8+
return '\''.addcslashes($var, "\\\$\"\'\r\n\t\v\f").'\'';
9+
case 'array':
10+
if (count($var) == 0) {
11+
return '[]';
12+
}
13+
$indexed = array_keys($var) === range(0, count($var) - 1);
14+
$r = [];
15+
foreach ($var as $key => $value) {
16+
$r[] = "$indent "
17+
.($indexed ? '' : var_export54($key).' => ')
18+
.var_export54($value, "$indent ");
19+
}
20+
21+
return "[\n".implode(",\n", $r).",\n".$indent.']';
22+
case 'boolean':
23+
return $var ? 'TRUE' : 'FALSE';
24+
default:
25+
return var_export($var, true);
26+
}
27+
}
28+
}
29+
if (! function_exists('generate_file')) {
30+
function generate_file($path, $expressions)
31+
{
32+
return fwrite($path, "<?php\n\nreturn ".var_export54($expressions).";\n");
33+
}
34+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use Illuminate\Console\Command;
6+
7+
require_once base_path('app/Console/Commands/Helpers/GenerateLanguageFile.php');
8+
9+
class SortLanguageFiles extends Command
10+
{
11+
/**
12+
* The name and signature of the console command.
13+
*
14+
* @var string
15+
*/
16+
protected $signature = 'locale:sort';
17+
18+
/**
19+
* The console command description.
20+
*
21+
* @var string
22+
*/
23+
protected $description = 'Sort language expressions';
24+
25+
/**
26+
* Create a new command instance.
27+
*
28+
* @return void
29+
*/
30+
public function __construct()
31+
{
32+
parent::__construct();
33+
}
34+
35+
/**
36+
* Execute the console command.
37+
*
38+
* @return mixed
39+
*/
40+
public function handle()
41+
{
42+
$languages = array_diff(scandir(base_path('resources/lang/')), ['..', '.']);
43+
foreach ($languages as $language) {
44+
$files = array_diff(scandir(base_path('resources/lang/'.$language)), ['..', '.']);
45+
foreach ($files as $file_in) {
46+
$expressions = require base_path('resources/lang/'.$language.'/'.$file_in);
47+
if (! (ksort($expressions))) {
48+
$this->error('Sorting '.$file_in.' failed.');
49+
}
50+
$file_out = fopen(base_path('resources/lang/'.$language.'/'.$file_in), 'w');
51+
if (! (generate_file($file_out, $expressions))) {
52+
$this->error('Writing to '.$file_in.' failed.');
53+
}
54+
}
55+
}
56+
$this->comment('Expressions sorted succesfully');
57+
}
58+
}

app/Http/Controllers/Auth/RegisterController.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,22 @@ public function __construct()
4949

5050
public function showRegistrationForm()
5151
{
52-
return view('auth.register', ['user_type' => Role::COLLEGIST, 'faculties' => Faculty::all(), 'workshops' => Workshop::all()]);
52+
return view('auth.register', [
53+
'user_type' => Role::COLLEGIST,
54+
'faculties' => Faculty::all(),
55+
'workshops' => Workshop::all(),
56+
'countries' => require base_path('countries.php')
57+
]);
5358
}
5459

5560
public function showTenantRegistrationForm()
5661
{
57-
return view('auth.register', ['user_type' => Role::TENANT, 'faculties' => Faculty::all(), 'workshops' => Workshop::all()]);
62+
return view('auth.register', [
63+
'user_type' => Role::TENANT,
64+
'faculties' => Faculty::all(),
65+
'workshops' => Workshop::all(),
66+
'countries' => require base_path('countries.php')
67+
]);
5868
}
5969

6070
/**
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use Illuminate\Http\Request;
6+
use App\User;
7+
use Illuminate\Support\Facades\Mail;
8+
use Illuminate\Support\Facades\Auth;
9+
10+
class EmailController extends Controller
11+
{
12+
//emails need to access the logo
13+
public function getPicture($filename){
14+
$path = public_path() . '//img//' . $filename;
15+
16+
if(!File::exists($path)) {
17+
return response()->json(['message' => 'Image not found'], 404);
18+
}
19+
20+
$file = File::get($path);
21+
$type = File::mimeType($path);
22+
23+
$response = Response::make($file, 200);
24+
$response->header("Content-Type", $type);
25+
26+
return $response;
27+
}
28+
29+
//test emails with url
30+
public function testEmail($mail, $send = false) {
31+
//to see preview: /test_mails/Confirmation
32+
//to send: /test_mails/Confirmation/send
33+
if(config('app.debug')) {
34+
$user = Auth::user();
35+
$mailClass = '\\App\\Mail\\'.$mail;
36+
if($send){
37+
Mail::to($user)->queue(new $mailClass($user->name));
38+
return response("Email sent.");
39+
} else {
40+
return new $mailClass($user->name);
41+
}
42+
} else {
43+
abort(404);
44+
}
45+
}
46+
}

app/Http/Controllers/LocaleController.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,26 @@
77

88
class LocaleController extends Controller
99
{
10-
public function set(Request $request, $locale) {
10+
public function set(Request $request, $locale)
11+
{
1112
App::setLocale($locale);
1213
return redirect()->back()->cookie('locale', $locale, config('app.locale_cookie_lifespan'));
1314
}
15+
16+
public function list()
17+
{
18+
$locale = [];
19+
$languages = array_diff(scandir(base_path('resources/lang/')), ['..', '.']);
20+
foreach ($languages as $language) {
21+
$files = array_diff(scandir(base_path('resources/lang/'.$language)), ['..', '.']);
22+
foreach ($files as $file_in) {
23+
if ($file_in != 'validation.php') {
24+
$name = substr($file_in, 0, strlen($file_in) - 4);
25+
$expressions = require base_path('resources/lang/'.$language.'/'.$file_in);
26+
$locale[$language][$name] = $expressions;
27+
}
28+
}
29+
}
30+
return view('locale.app')->with('locale', $locale);
31+
}
1432
}

app/Mail/Confirmation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function __construct($recipent)
2929
*/
3030
public function build()
3131
{
32-
return $this->text('emails.register')
32+
return $this->markdown('emails.register')
3333
->subject(__('registration.confirmed_signup'));
3434
}
3535
}

config/mail.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
// Set to true, if you wish to send mails on triggers.
66
'active' => env('MAIL_ACTIVE', false),
77

8+
// Test mail to seed the admin user with.
9+
'test_mail' => env('MAIL_TEST_ADMIN', '[email protected]'),
10+
811
/*
912
|--------------------------------------------------------------------------
1013
| Mail Driver

0 commit comments

Comments
 (0)