Skip to content

Commit

Permalink
Merge pull request #348 from esac-ic/english-default
Browse files Browse the repository at this point in the history
Remove localization, set english as default
  • Loading branch information
wouterbles authored Oct 19, 2023
2 parents 8890c73 + 0f66f1a commit 8da73b9
Show file tree
Hide file tree
Showing 295 changed files with 2,933 additions and 5,282 deletions.
3 changes: 0 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost:8000

TELESCOPE_ENABLED=true
TELESCOPE_PROD=false

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
Expand Down
42 changes: 17 additions & 25 deletions app/AgendaItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Support\Facades\Storage;

class AgendaItem extends Model
{
Expand All @@ -19,57 +20,48 @@ class AgendaItem extends Model
'endDate',
'image_url',
'category',
'climbing_activity'
'climbing_activity',
];

protected $casts = [
'climbing_activity' => 'boolean'
'climbing_activity' => 'boolean',
];

public function getApplicationForm(): HasOne{
return $this->hasOne(ApplicationForm::class,'id',"application_form_id");
}

public function agendaItemText(){
return $this->hasOne('App\Text', 'id', 'text');
}

public function agendaItemTitle()
public function getApplicationForm(): HasOne
{
return $this->hasOne('App\Text', 'id', 'title');
}
public function agendaItemShortDescription()
{
return $this->hasOne('App\Text', 'id', 'shortDescription');
return $this->hasOne(ApplicationForm::class, 'id', "application_form_id");
}

public function agendaItemCategory()
{
return $this->hasOne('App\AgendaItemCategorie', 'id', 'category')->withTrashed();
return $this->hasOne('App\AgendaItemCategory', 'id', 'category')->withTrashed();
}

public function getCreatedBy()
{
return $this->hasOne('App\User', 'id', 'createdBy');
}

public function getImageUrl(){
if($this->image_url != ""){
return \Storage::disk('public')->url($this->image_url);
public function getImageUrl()
{
if ($this->image_url != "") {
return Storage::disk('public')->url($this->image_url);
} else {
return "/img/default_agenda_item_cover.jpg";
}
}

public function getApplicationFormResponses(){
return $this->hasMany(ApplicationResponse::class,'agenda_id');
public function getApplicationFormResponses()
{
return $this->hasMany(ApplicationResponse::class, 'agenda_id');
}

public function canRegister(){
if($this->subscription_endDate < Carbon::now()){
public function canRegister()
{
if ($this->subscription_endDate < Carbon::now()) {
return false;
} else {
return true;
}
}
}
}
9 changes: 3 additions & 6 deletions app/AgendaItemCategorie.php → app/AgendaItemCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class AgendaItemCategorie extends Model
class AgendaItemCategory extends Model
{
use SoftDeletes;

protected $fillable = [
'name'
'name',
];

public function categorieName(){
return $this->hasOne('App\Text', 'id', 'name')->withTrashed();
}
}
8 changes: 1 addition & 7 deletions app/Certificate.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ class Certificate extends Model
use SoftDeletes;
protected $fillable = [
'name',
'duration',
'abbreviation'
'abbreviation',
];

public function certificateName(){
return $this->hasOne('App\Text', 'id', 'name');
}

}
2 changes: 1 addition & 1 deletion app/Console/Commands/RemoveOldApplications.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct()
public function handle()
{
ApplicationResponse::query()
->where('created_at','<',Carbon::now()->subYear(config('custom.application_response_save_period')))
->where('created_at', '<', Carbon::now()->subYears(config('custom.application_response_save_period')))
->forceDelete();
}
}
2 changes: 1 addition & 1 deletion app/Console/Commands/RemoveOldUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct()
public function handle()
{
User::query()
->whereDate('lid_af','<',Carbon::now()->subYear(config('custom.old_users_save_period')))
->whereDate('lid_af', '<', Carbon::now()->subYears(config('custom.old_users_save_period')))
->update([
'email' => null,
'password' => null,
Expand Down
9 changes: 4 additions & 5 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Console;

use App\Console\Commands\RemoveOldUsers;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

Expand All @@ -25,10 +24,10 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('remove:oldUsers')
->weekly();
$schedule->command('remove:oldApplications')
->weekly();
$schedule->command('remove:oldUsers')
->weekly();
$schedule->command('remove:oldApplications')
->weekly();
}

/**
Expand Down
5 changes: 2 additions & 3 deletions app/CustomClasses/MailList/MailList.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace App\CustomClasses\MailList;


class MailList
{
private $id;
Expand Down Expand Up @@ -103,7 +102,7 @@ public function getMembers(): array
*/
public function addMember(MailListMember $member): MailList
{
array_push($this->members,$member);
array_push($this->members, $member);
return $this;
}
}
}
54 changes: 31 additions & 23 deletions app/CustomClasses/MailList/MailListFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,29 @@ class MailListFacade
private $_mailListParser;
private $_mailManHandler;

public function __construct(MailListParser $mailListParser,MailMan $mailMan)
public function __construct(MailListParser $mailListParser, MailMan $mailMan)
{
$this->_mailListParser = $mailListParser;
$this->_mailManHandler = $mailMan;
}

public function getAllMailLists(){
public function getAllMailLists()
{
$mailLists = array();
$response = $this->_mailManHandler->get('/lists');
foreach($response->entries as $mailList){
array_push($mailLists,$this->_mailListParser->parseMailManMailList($mailList));
foreach ($response->entries as $mailList) {
array_push($mailLists, $this->_mailListParser->parseMailManMailList($mailList));
}
return $mailLists;
}

public function getMailList($id){
public function getMailList($id)
{
$mailList = $this->_mailListParser->parseMailManMailList($this->_mailManHandler->get('/lists/' . $id));
$members = $this->_mailManHandler->get('/lists/' . $id . '/roster/member');

if(property_exists($members,"entries")){
foreach ($members->entries as $member){
if (property_exists($members, "entries")) {
foreach ($members->entries as $member) {
$parsedMember = $this->_mailListParser->parseMailManMember($member);
$mailList->addMember($parsedMember);
}
Expand All @@ -42,21 +44,25 @@ public function getMailList($id){
return $mailList;
}

public function storeMailList(array $data){
public function storeMailList(array $data)
{
$this->_mailManHandler->post("/lists", [
'fqdn_listname' => $data['address'] . env("MAIL_MAN_DOMAIN"),
]);
}

public function deleteMailList($id){
public function deleteMailList($id)
{
$this->_mailManHandler->delete("/lists/" . $id);
}

public function deleteMemberFromMailList($mailListId,$memberEmail){
$this->_mailManHandler->delete("/lists/" . $mailListId ."/member/". $memberEmail);
public function deleteMemberFromMailList($mailListId, $memberEmail)
{
$this->_mailManHandler->delete("/lists/" . $mailListId . "/member/" . $memberEmail);
}

public function addMember($mailListId, $email,$name){
public function addMember($mailListId, $email, $name)
{
$this->_mailManHandler->post(
"/members",
[
Expand All @@ -70,28 +76,30 @@ public function addMember($mailListId, $email,$name){
);
}

public function deleteUserFormAllMailList($user){
foreach ($this->getAllMailLists() as $mailList){
public function deleteUserFormAllMailList($user)
{
foreach ($this->getAllMailLists() as $mailList) {
try {
//we used try to delete the user from the mail list wihout checken if he is in the list because
//that take to much time
$this->deleteMemberFromMailList($mailList->getId(),$user->email);
} catch (\Exception $e){
$this->deleteMemberFromMailList($mailList->getId(), $user->email);
} catch (\Exception $e) {
}
}
}

public function updateUserEmailFormAllMailList($user, $oldEmail, $newEmail){
foreach ($this->getAllMailLists() as $mailList){
public function updateUserEmailFormAllMailList($user, $oldEmail, $newEmail)
{
foreach ($this->getAllMailLists() as $mailList) {
$mailList = $this->getMailList($mailList->getAddress());
foreach ($mailList->getMembers() as $member){
if($oldEmail === $member->getAddress()){
$this->deleteMemberFromMailList($mailList->getId(),$member->getAddress());
$this->addMember($mailList->getId(),$newEmail,$user->getName());
foreach ($mailList->getMembers() as $member) {
if ($oldEmail === $member->getAddress()) {
$this->deleteMemberFromMailList($mailList->getId(), $member->getAddress());
$this->addMember($mailList->getId(), $newEmail, $user->getName());
}
}

}
}

}
}
3 changes: 1 addition & 2 deletions app/CustomClasses/MailList/MailListMember.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace App\CustomClasses\MailList;


class MailListMember
{
private $name;
Expand Down Expand Up @@ -49,4 +48,4 @@ public function setAddress($address)
$this->address = $address;
return $this;
}
}
}
8 changes: 5 additions & 3 deletions app/CustomClasses/MailList/MailListParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class MailListParser
* @param $object
* @return MailList
*/
public function parseMailManMailList($object) : MailList{
public function parseMailManMailList($object): MailList
{
$mailList = new MailList();
$mailList
->setId($object->list_id)
Expand All @@ -36,12 +37,13 @@ public function parseMailManMailList($object) : MailList{
* @param $object
* @return MailListMember
*/
public function parseMailManMember($object) : MailListMember{
public function parseMailManMember($object): MailListMember
{
$member = new MailListMember();
$member
->setAddress($object->email)
->setName($object->display_name);

return $member;
}
}
}
27 changes: 15 additions & 12 deletions app/CustomClasses/MailList/MailMan.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace App\CustomClasses\MailList;


use GuzzleHttp\Client;

class MailMan
Expand All @@ -22,27 +21,31 @@ public function __construct()
$this->_client = new Client();
}

public function get(string $url){
return $this->call("GET",$url);
public function get(string $url)
{
return $this->call("GET", $url);
}

public function post(string $url,array $body){
return $this->call("POST",$url,$body);
public function post(string $url, array $body)
{
return $this->call("POST", $url, $body);
}

public function delete(string $url){
return $this->call("DELETE",$url);
public function delete(string $url)
{
return $this->call("DELETE", $url);
}

private function call(string $method,string $url,array $body = []){
$response = $this->_client->request($method,$this->_baseUrl . $url,[
private function call(string $method, string $url, array $body = [])
{
$response = $this->_client->request($method, $this->_baseUrl . $url, [
"form_params" => $body,
"auth" => [
env('MAIL_MAN_USERNAME'),
env('MAIL_MAN_PASSWORD')
]
env('MAIL_MAN_PASSWORD'),
],
]);

return json_decode($response->getBody()->getContents());
}
}
}
Loading

0 comments on commit 8da73b9

Please sign in to comment.