@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | { |
| 54 | 54 | // |
| 55 | 55 | $calendarId = $this->argument('calendarId'); |
| 56 | - if(is_numeric($calendarId)) |
|
| 56 | + if (is_numeric($calendarId)) |
|
| 57 | 57 | $this->makeForeground(Caldav::findOrFail($calendarId)); |
| 58 | 58 | else |
| 59 | 59 | $this->syncAll(); |
@@ -62,15 +62,15 @@ discard block |
||
| 62 | 62 | private function syncAll() |
| 63 | 63 | { |
| 64 | 64 | $calendars = Caldav::all(); |
| 65 | - if($this->option('background')) { |
|
| 65 | + if ($this->option('background')) { |
|
| 66 | 66 | \Log::debug(self::BACKGROUND_MOD_MEX); |
| 67 | 67 | $this->info(self::BACKGROUND_MOD_MEX); |
| 68 | 68 | foreach ($calendars as $calendar) |
| 69 | 69 | $this->makeBackground($calendar); |
| 70 | 70 | \Log::debug(self::BACKGROUND_COMPLETED_MEX); |
| 71 | 71 | $this->info(self::BACKGROUND_COMPLETED_MEX); |
| 72 | - }else |
|
| 73 | - foreach($calendars as $calendar) |
|
| 72 | + } else |
|
| 73 | + foreach ($calendars as $calendar) |
|
| 74 | 74 | $this->makeForeground($calendar); |
| 75 | 75 | } |
| 76 | 76 | |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | private function makeBackground(Caldav $calendar) |
| 82 | 82 | { |
| 83 | 83 | $event = $this->schedule->command('sync:caldav '.$calendar->calendar_id)->withoutOverlapping(); |
| 84 | - if($event->isDue($this->laravel)) |
|
| 84 | + if ($event->isDue($this->laravel)) |
|
| 85 | 85 | $event->run($this->laravel); |
| 86 | 86 | } |
| 87 | 87 | |
@@ -91,8 +91,8 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | private function makeForeground(Caldav $calendar) |
| 93 | 93 | { |
| 94 | - $this->info('Sync calendar '. $calendar->calendar_id.' started'); |
|
| 94 | + $this->info('Sync calendar '.$calendar->calendar_id.' started'); |
|
| 95 | 95 | (new Sync($calendar))->sync(); |
| 96 | - $this->info('Sync calendar '. $calendar->calendar_id.' completed'); |
|
| 96 | + $this->info('Sync calendar '.$calendar->calendar_id.' completed'); |
|
| 97 | 97 | } |
| 98 | 98 | } |
@@ -37,19 +37,19 @@ |
||
| 37 | 37 | /** |
| 38 | 38 | * @var array |
| 39 | 39 | */ |
| 40 | - protected $touches = ['calendar']; |
|
| 40 | + protected $touches = [ 'calendar' ]; |
|
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * @var array |
| 44 | 44 | */ |
| 45 | - protected $fillable = ['url', 'username', 'password', 'calendar_name']; |
|
| 45 | + protected $fillable = [ 'url', 'username', 'password', 'calendar_name' ]; |
|
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * The attributes excluded from the model's JSON form. |
| 49 | 49 | * |
| 50 | 50 | * @var array |
| 51 | 51 | */ |
| 52 | - protected $hidden = ['password']; |
|
| 52 | + protected $hidden = [ 'password' ]; |
|
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | 55 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
@@ -18,8 +18,8 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | public function __construct() |
| 20 | 20 | { |
| 21 | - config(['auth.model' => Planner::class]); |
|
| 22 | - config(['jwt.user' => Planner::class]); |
|
| 21 | + config([ 'auth.model' => Planner::class ]); |
|
| 22 | + config([ 'jwt.user' => Planner::class ]); |
|
| 23 | 23 | $this->middleware('jwt.authandrefresh:mode-en'); |
| 24 | 24 | } |
| 25 | 25 | |
@@ -21,8 +21,8 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | public function __construct() |
| 23 | 23 | { |
| 24 | - config(['auth.model' => \plunner\Employee::class]); |
|
| 25 | - config(['jwt.user' => \plunner\Employee::class]); |
|
| 24 | + config([ 'auth.model' => \plunner\Employee::class ]); |
|
| 25 | + config([ 'jwt.user' => \plunner\Employee::class ]); |
|
| 26 | 26 | $this->middleware('jwt.authandrefresh:mode-en'); |
| 27 | 27 | } |
| 28 | 28 | |
@@ -73,12 +73,12 @@ discard block |
||
| 73 | 73 | $caldavClient = new SimpleCaldavAdapter(); |
| 74 | 74 | $caldavClient->connect($this->calendar->url, $this->calendar->username, \Crypt::decrypt($this->calendar->password)); |
| 75 | 75 | $calendars = $caldavClient->findCalendars(); |
| 76 | - $caldavClient->setCalendar($calendars[$this->calendar->calendar_name]);//TODO error if the calendar name is wrong |
|
| 76 | + $caldavClient->setCalendar($calendars[ $this->calendar->calendar_name ]); //TODO error if the calendar name is wrong |
|
| 77 | 77 | /** |
| 78 | 78 | * 26 hours before to avoid tiemezone problems and dst problems |
| 79 | 79 | * 30 days after |
| 80 | 80 | */ |
| 81 | - return $caldavClient->getEvents(date('Ymd\THis\Z', time()-93600), date('Ymd\THis\Z', time()+2592000)); |
|
| 81 | + return $caldavClient->getEvents(date('Ymd\THis\Z', time() - 93600), date('Ymd\THis\Z', time() + 2592000)); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -89,13 +89,13 @@ discard block |
||
| 89 | 89 | try |
| 90 | 90 | { |
| 91 | 91 | $events = $this->getEvents(); |
| 92 | - }catch (\it\thecsea\caldav_client_adapter\CaldavException $e) |
|
| 92 | + } catch (\it\thecsea\caldav_client_adapter\CaldavException $e) |
|
| 93 | 93 | { |
| 94 | 94 | \Event::fire(new CaldavErrorEvent($this->calendar, $e->getMessage())); |
| 95 | - return ; |
|
| 96 | - }catch(\Illuminate\Contracts\Encryption\DecryptException $e){ |
|
| 95 | + return; |
|
| 96 | + } catch (\Illuminate\Contracts\Encryption\DecryptException $e) { |
|
| 97 | 97 | \Event::fire(new CaldavErrorEvent($this->calendar, $e->getMessage())); |
| 98 | - return ; |
|
| 98 | + return; |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -105,8 +105,8 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | //remove old timeslots |
| 107 | 107 | $calendarMain->timeslots()->delete(); |
| 108 | - foreach($events as $event){ |
|
| 109 | - if(!($event = $this->parseEvent($event))) |
|
| 108 | + foreach ($events as $event) { |
|
| 109 | + if (!($event = $this->parseEvent($event))) |
|
| 110 | 110 | \Event::fire(new CaldavErrorEvent($this->calendar, 'problem during the parsing an event')); |
| 111 | 111 | else |
| 112 | 112 | $calendarMain->timeslots()->create($event); |
@@ -120,16 +120,16 @@ discard block |
||
| 120 | 120 | private function parseEvent(EventInterface $event) |
| 121 | 121 | { |
| 122 | 122 | $pattern = "/^((DTSTART;)|(DTEND;))(.*)\$/m"; |
| 123 | - if(preg_match_all($pattern, $event->getData(), $matches)){ |
|
| 124 | - if(!isset($matches[4]) || count($matches[4]) != 2) |
|
| 123 | + if (preg_match_all($pattern, $event->getData(), $matches)) { |
|
| 124 | + if (!isset($matches[ 4 ]) || count($matches[ 4 ]) != 2) |
|
| 125 | 125 | return null; |
| 126 | - $ret = []; |
|
| 127 | - if($tmp = $this->parseDate($matches[4][0])) |
|
| 128 | - $ret['time_start'] = $tmp; |
|
| 126 | + $ret = [ ]; |
|
| 127 | + if ($tmp = $this->parseDate($matches[ 4 ][ 0 ])) |
|
| 128 | + $ret[ 'time_start' ] = $tmp; |
|
| 129 | 129 | else |
| 130 | 130 | return null; |
| 131 | - if($tmp = $this->parseDate($matches[4][1])) |
|
| 132 | - $ret['time_end'] = $tmp; |
|
| 131 | + if ($tmp = $this->parseDate($matches[ 4 ][ 1 ])) |
|
| 132 | + $ret[ 'time_end' ] = $tmp; |
|
| 133 | 133 | else |
| 134 | 134 | return null; |
| 135 | 135 | return $ret; |
@@ -144,13 +144,13 @@ discard block |
||
| 144 | 144 | private function parseDate($date) |
| 145 | 145 | { |
| 146 | 146 | $pattern = "/^((TZID=)|(VALUE=))(.*):(.*)\$/m"; |
| 147 | - if(preg_match_all($pattern, $date, $matches)){ |
|
| 148 | - if($matches[1][0] == 'TZID=') |
|
| 147 | + if (preg_match_all($pattern, $date, $matches)) { |
|
| 148 | + if ($matches[ 1 ][ 0 ] == 'TZID=') |
|
| 149 | 149 | { |
| 150 | - return \DateTime::createFromFormat('Ymd\THis', $matches[5][0], new \DateTimeZone($matches[4][0])); |
|
| 151 | - }else if($matches[1][0] == 'VALUE=' && $matches[4][0] == 'DATE') |
|
| 150 | + return \DateTime::createFromFormat('Ymd\THis', $matches[ 5 ][ 0 ], new \DateTimeZone($matches[ 4 ][ 0 ])); |
|
| 151 | + } else if ($matches[ 1 ][ 0 ] == 'VALUE=' && $matches[ 4 ][ 0 ] == 'DATE') |
|
| 152 | 152 | { |
| 153 | - return \DateTime::createFromFormat('Ymd\THis', $matches[5][0].'T000000'); |
|
| 153 | + return \DateTime::createFromFormat('Ymd\THis', $matches[ 5 ][ 0 ].'T000000'); |
|
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | return null; |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | * |
| 38 | 38 | * @var array |
| 39 | 39 | */ |
| 40 | - protected $fillable = ['name', 'enabled']; |
|
| 40 | + protected $fillable = [ 'name', 'enabled' ]; |
|
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | * |
| 12 | 12 | * @var array |
| 13 | 13 | */ |
| 14 | - protected $fillable = ['time_start', 'time_end']; |
|
| 14 | + protected $fillable = [ 'time_start', 'time_end' ]; |
|
| 15 | 15 | |
| 16 | 16 | public function employees() |
| 17 | 17 | { |
@@ -17,8 +17,8 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | public function __construct() |
| 19 | 19 | { |
| 20 | - config(['auth.model' => \plunner\Employee::class]); |
|
| 21 | - config(['jwt.user' => \plunner\Employee::class]); |
|
| 20 | + config([ 'auth.model' => \plunner\Employee::class ]); |
|
| 21 | + config([ 'jwt.user' => \plunner\Employee::class ]); |
|
| 22 | 22 | $this->middleware('jwt.authandrefresh:mode-en'); |
| 23 | 23 | } |
| 24 | 24 | |
@@ -66,8 +66,8 @@ discard block |
||
| 66 | 66 | $employee = \Auth::user(); |
| 67 | 67 | $input = $request->all(); |
| 68 | 68 | $calendar = $employee->calendars()->create($input); |
| 69 | - if(isset($input['password'])) |
|
| 70 | - $input['password'] = \Crypt::encrypt($input['password']); |
|
| 69 | + if (isset($input[ 'password' ])) |
|
| 70 | + $input[ 'password' ] = \Crypt::encrypt($input[ 'password' ]); |
|
| 71 | 71 | $calendar->caldav()->create($input); |
| 72 | 72 | //TODO test |
| 73 | 73 | //TODO validator |
@@ -104,17 +104,17 @@ discard block |
||
| 104 | 104 | $this->authorize($calendar); |
| 105 | 105 | $input = $request->all(); |
| 106 | 106 | $caldav = $calendar->caldav; |
| 107 | - if($caldav){ |
|
| 107 | + if ($caldav) { |
|
| 108 | 108 | $this->validateCaldav($request); |
| 109 | 109 | } |
| 110 | - if(isset($input['password'])) |
|
| 111 | - $input['password'] = \Crypt::encrypt($input['password']); |
|
| 110 | + if (isset($input[ 'password' ])) |
|
| 111 | + $input[ 'password' ] = \Crypt::encrypt($input[ 'password' ]); |
|
| 112 | 112 | $calendar->update($input); |
| 113 | 113 | //TODO test |
| 114 | 114 | //TODO validator |
| 115 | 115 | //TODO check if caldav exists? |
| 116 | 116 | |
| 117 | - if($caldav) |
|
| 117 | + if ($caldav) |
|
| 118 | 118 | $caldav->update($input); |
| 119 | 119 | return $calendar; |
| 120 | 120 | } |
@@ -148,9 +148,9 @@ discard block |
||
| 148 | 148 | $caldavClient->connect($request->input('url'), $request->input('username'), $request->input('password')); |
| 149 | 149 | $calendars = $caldavClient->findCalendars(); |
| 150 | 150 | return array_keys($calendars); |
| 151 | - }catch (\it\thecsea\caldav_client_adapter\CaldavException $e) |
|
| 151 | + } catch (\it\thecsea\caldav_client_adapter\CaldavException $e) |
|
| 152 | 152 | { |
| 153 | - return Response::json(['error' => $e->getMessage()],422); |
|
| 153 | + return Response::json([ 'error' => $e->getMessage() ], 422); |
|
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | $this->validate($request, [ |
| 163 | 163 | 'url' => 'required|max:255', |
| 164 | 164 | 'username' => 'required|max:255', |
| 165 | - 'password' => ((\Route::current()->getName() == 'companies.calendars.caldav')?'required':''), |
|
| 165 | + 'password' => ((\Route::current()->getName() == 'companies.calendars.caldav') ? 'required' : ''), |
|
| 166 | 166 | 'calendar_name' => 'required|max:255', |
| 167 | 167 | ]); |
| 168 | 168 | } |
@@ -46,14 +46,14 @@ |
||
| 46 | 46 | * |
| 47 | 47 | * @var array |
| 48 | 48 | */ |
| 49 | - protected $fillable = ['title', 'description', 'duration']; |
|
| 49 | + protected $fillable = [ 'title', 'description', 'duration' ]; |
|
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * The attributes excluded from the model's JSON form. |
| 53 | 53 | * |
| 54 | 54 | * @var array |
| 55 | 55 | */ |
| 56 | - protected $hidden = ['pivot']; |
|
| 56 | + protected $hidden = [ 'pivot' ]; |
|
| 57 | 57 | |
| 58 | 58 | |
| 59 | 59 | /** |