@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | { |
77 | 77 | $path = new Path(tempnam(sys_get_temp_dir(), 'OPT')); //TODO check the return in case of errors this return false on failure |
78 | 78 | unlink($path->getPath()); //remove file to create a dir |
79 | - if(file_exists($path->getPath())) |
|
79 | + if (file_exists($path->getPath())) |
|
80 | 80 | throw new OptimiseException('problem during creation of tmp dir (the directory already exists)'); |
81 | - if(!@mkdir($path->getPath())) |
|
82 | - throw new OptimiseException('problem during creation of tmp dir (mkdir problem)');; |
|
83 | - if(! is_dir($path->getPath())) |
|
81 | + if (!@mkdir($path->getPath())) |
|
82 | + throw new OptimiseException('problem during creation of tmp dir (mkdir problem)'); ; |
|
83 | + if (!is_dir($path->getPath())) |
|
84 | 84 | throw new OptimiseException('problem during creation of tmp dir (it is not possible to create directory)'); |
85 | 85 | return $path; |
86 | 86 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @return bool |
92 | 92 | */ |
93 | 93 | private static function delTree($dir) { |
94 | - $files = array_diff(scandir($dir), array('.','..')); |
|
94 | + $files = array_diff(scandir($dir), array('.', '..')); |
|
95 | 95 | foreach ($files as $file) { |
96 | 96 | (is_dir("$dir/$file")) ? delTree("$dir/$file") : unlink("$dir/$file"); |
97 | 97 | } |
@@ -48,8 +48,9 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function __destruct() |
50 | 50 | { |
51 | - if ($this->path && is_dir($this->path) && !self::delTree($this->path)) |
|
52 | - throw new OptimiseException('problems during removing of path directory'); |
|
51 | + if ($this->path && is_dir($this->path) && !self::delTree($this->path)) { |
|
52 | + throw new OptimiseException('problems during removing of path directory'); |
|
53 | + } |
|
53 | 54 | } |
54 | 55 | |
55 | 56 | /** |
@@ -76,12 +77,16 @@ discard block |
||
76 | 77 | { |
77 | 78 | $path = new Path(tempnam(sys_get_temp_dir(), 'OPT')); //TODO check the return in case of errors this return false on failure |
78 | 79 | unlink($path->getPath()); //remove file to create a dir |
79 | - if(file_exists($path->getPath())) |
|
80 | - throw new OptimiseException('problem during creation of tmp dir (the directory already exists)'); |
|
81 | - if(!@mkdir($path->getPath())) |
|
82 | - throw new OptimiseException('problem during creation of tmp dir (mkdir problem)');; |
|
83 | - if(! is_dir($path->getPath())) |
|
84 | - throw new OptimiseException('problem during creation of tmp dir (it is not possible to create directory)'); |
|
80 | + if(file_exists($path->getPath())) { |
|
81 | + throw new OptimiseException('problem during creation of tmp dir (the directory already exists)'); |
|
82 | + } |
|
83 | + if(!@mkdir($path->getPath())) { |
|
84 | + throw new OptimiseException('problem during creation of tmp dir (mkdir problem)'); |
|
85 | + } |
|
86 | + ; |
|
87 | + if(! is_dir($path->getPath())) { |
|
88 | + throw new OptimiseException('problem during creation of tmp dir (it is not possible to create directory)'); |
|
89 | + } |
|
85 | 90 | return $path; |
86 | 91 | } |
87 | 92 |
@@ -1,21 +1,21 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Created by PhpStorm. |
|
4 | - * User: Claudio Cardinale <[email protected]> |
|
5 | - * Date: 18/12/15 |
|
6 | - * Time: 15.20 |
|
7 | - * This program is free software; you can redistribute it and/or |
|
8 | - * modify it under the terms of the GNU General Public License |
|
9 | - * as published by the Free Software Foundation; either version 2 |
|
10 | - * of the License, or (at your option) any later version. |
|
11 | - * This program is distributed in the hope that it will be useful, |
|
12 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 | - * GNU General Public License for more details. |
|
15 | - * You should have received a copy of the GNU General Public License |
|
16 | - * along with this program; if not, write to the Free Software |
|
17 | - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
18 | - */ |
|
3 | + * Created by PhpStorm. |
|
4 | + * User: Claudio Cardinale <[email protected]> |
|
5 | + * Date: 18/12/15 |
|
6 | + * Time: 15.20 |
|
7 | + * This program is free software; you can redistribute it and/or |
|
8 | + * modify it under the terms of the GNU General Public License |
|
9 | + * as published by the Free Software Foundation; either version 2 |
|
10 | + * of the License, or (at your option) any later version. |
|
11 | + * This program is distributed in the hope that it will be useful, |
|
12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 | + * GNU General Public License for more details. |
|
15 | + * You should have received a copy of the GNU General Public License |
|
16 | + * along with this program; if not, write to the Free Software |
|
17 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
18 | + */ |
|
19 | 19 | |
20 | 20 | namespace plunner\Console\Commands\Optimise; |
21 | 21 |
@@ -1,21 +1,21 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Created by PhpStorm. |
|
4 | - * User: Claudio Cardinale <[email protected]> |
|
5 | - * Date: 24/12/15 |
|
6 | - * Time: 22.53 |
|
7 | - * This program is free software; you can redistribute it and/or |
|
8 | - * modify it under the terms of the GNU General Public License |
|
9 | - * as published by the Free Software Foundation; either version 2 |
|
10 | - * of the License, or (at your option) any later version. |
|
11 | - * This program is distributed in the hope that it will be useful, |
|
12 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 | - * GNU General Public License for more details. |
|
15 | - * You should have received a copy of the GNU General Public License |
|
16 | - * along with this program; if not, write to the Free Software |
|
17 | - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
18 | - */ |
|
3 | + * Created by PhpStorm. |
|
4 | + * User: Claudio Cardinale <[email protected]> |
|
5 | + * Date: 24/12/15 |
|
6 | + * Time: 22.53 |
|
7 | + * This program is free software; you can redistribute it and/or |
|
8 | + * modify it under the terms of the GNU General Public License |
|
9 | + * as published by the Free Software Foundation; either version 2 |
|
10 | + * of the License, or (at your option) any later version. |
|
11 | + * This program is distributed in the hope that it will be useful, |
|
12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 | + * GNU General Public License for more details. |
|
15 | + * You should have received a copy of the GNU General Public License |
|
16 | + * along with this program; if not, write to the Free Software |
|
17 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
18 | + */ |
|
19 | 19 | |
20 | 20 | namespace plunner\Http\Middleware; |
21 | 21 |
@@ -25,15 +25,15 @@ |
||
25 | 25 | public function handle($request, \Closure $next, $custom = '') |
26 | 26 | { |
27 | 27 | $remember = false; |
28 | - if($this->auth->setRequest($request)->getToken() && ($remember = $this->auth->getPayload()->get('remember')) && |
|
29 | - $remember == 'true'){ |
|
28 | + if ($this->auth->setRequest($request)->getToken() && ($remember = $this->auth->getPayload()->get('remember')) && |
|
29 | + $remember == 'true') { |
|
30 | 30 | JWTFactory::setTTL(43200); |
31 | 31 | //config(['jwt.ttl' =>'43200']); //30 days |
32 | 32 | } |
33 | 33 | |
34 | 34 | //this to add the remember me mode field in the new token, but we have the custom check that is an useless |
35 | 35 | //overhead |
36 | - $custom = $custom.';remember-'.$remember=='true'?'true':'false'; |
|
36 | + $custom = $custom.';remember-'.$remember == 'true' ? 'true' : 'false'; |
|
37 | 37 | return parent::handle($request, $next, $custom); |
38 | 38 | } |
39 | 39 |
@@ -30,6 +30,6 @@ |
||
30 | 30 | 'auth' => \plunner\Http\Middleware\Authenticate::class, |
31 | 31 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, |
32 | 32 | 'guest' => \plunner\Http\Middleware\RedirectIfAuthenticated::class, |
33 | - 'jwt.authandrefresh' => \plunner\Http\Middleware\GetUserAndRefresh::class,//'Tymon\JWTAuth\Middleware\GetUserAndRefresh', |
|
33 | + 'jwt.authandrefresh' => \plunner\Http\Middleware\GetUserAndRefresh::class, //'Tymon\JWTAuth\Middleware\GetUserAndRefresh', |
|
34 | 34 | ]; |
35 | 35 | } |
@@ -10,8 +10,8 @@ discard block |
||
10 | 10 | { |
11 | 11 | public function __construct() |
12 | 12 | { |
13 | - config(['auth.model' => \plunner\Company::class]); |
|
14 | - config(['jwt.user' => \plunner\Company::class]); |
|
13 | + config([ 'auth.model' => \plunner\Company::class ]); |
|
14 | + config([ 'jwt.user' => \plunner\Company::class ]); |
|
15 | 15 | $this->middleware('jwt.authandrefresh:mode-cn'); |
16 | 16 | } |
17 | 17 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | public function update(CompanyRequest $request) |
37 | 37 | { |
38 | 38 | $company = \Auth::user(); |
39 | - $input = $request->only(['name', 'password']); |
|
39 | + $input = $request->only([ 'name', 'password' ]); |
|
40 | 40 | $company->update($input); |
41 | 41 | return $company; |
42 | 42 | } |
@@ -10,8 +10,8 @@ discard block |
||
10 | 10 | { |
11 | 11 | public function __construct() |
12 | 12 | { |
13 | - config(['auth.model' => \plunner\Employee::class]); |
|
14 | - config(['jwt.user' => \plunner\Employee::class]); |
|
13 | + config([ 'auth.model' => \plunner\Employee::class ]); |
|
14 | + config([ 'jwt.user' => \plunner\Employee::class ]); |
|
15 | 15 | $this->middleware('jwt.authandrefresh:mode-en'); |
16 | 16 | } |
17 | 17 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | public function update(EmployeeRequest $request) |
37 | 37 | { |
38 | 38 | $employee = \Auth::user(); |
39 | - $input = $request->only(['name', 'password']); |
|
39 | + $input = $request->only([ 'name', 'password' ]); |
|
40 | 40 | $employee->update($input); |
41 | 41 | return $employee; |
42 | 42 | } |
@@ -2,14 +2,11 @@ |
||
2 | 2 | |
3 | 3 | namespace plunner\Http\Controllers\Employees\Planners; |
4 | 4 | |
5 | -use Illuminate\Http\Request; |
|
6 | - |
|
7 | -use plunner\Http\Requests; |
|
8 | -use plunner\Http\Requests\Employees\MeetingRequest; |
|
9 | 5 | use plunner\Http\Controllers\Controller; |
6 | +use plunner\Http\Requests\Employees\MeetingRequest; |
|
10 | 7 | |
11 | -use plunner\Meeting; |
|
12 | 8 | use plunner\Group; |
9 | +use plunner\Meeting; |
|
13 | 10 | |
14 | 11 | class MeetingsController extends Controller |
15 | 12 | { |
@@ -17,8 +17,8 @@ |
||
17 | 17 | */ |
18 | 18 | public function __construct() |
19 | 19 | { |
20 | - config(['auth.model' => \plunner\Planner::class]); |
|
21 | - config(['jwt.user' => \plunner\Planner::class]); |
|
20 | + config([ 'auth.model' => \plunner\Planner::class ]); |
|
21 | + config([ 'jwt.user' => \plunner\Planner::class ]); |
|
22 | 22 | $this->middleware('jwt.authandrefresh:mode-en'); |
23 | 23 | } |
24 | 24 |
@@ -50,19 +50,19 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @var array |
52 | 52 | */ |
53 | - protected $fillable = ['name', 'email', 'password']; |
|
53 | + protected $fillable = [ 'name', 'email', 'password' ]; |
|
54 | 54 | |
55 | 55 | /** |
56 | 56 | * The attributes excluded from the model's JSON form. |
57 | 57 | * |
58 | 58 | * @var array |
59 | 59 | */ |
60 | - protected $hidden = ['password', 'remember_token', 'pivot']; |
|
60 | + protected $hidden = [ 'password', 'remember_token', 'pivot' ]; |
|
61 | 61 | |
62 | 62 | /** |
63 | 63 | * @var array |
64 | 64 | */ |
65 | - protected $appends = ['is_planner']; |
|
65 | + protected $appends = [ 'is_planner' ]; |
|
66 | 66 | |
67 | 67 | public function getIsPlannerAttribute() |
68 | 68 | { |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * to get all meetings where the user can go user groups with meetings |
99 | 99 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
100 | 100 | */ |
101 | - public function meetings(){ |
|
101 | + public function meetings() { |
|
102 | 102 | //TODO durign the inserting chek if the meeting is of a group of the user |
103 | 103 | return $this->belongsToMany(Meeting::class); |
104 | 104 | } |
@@ -114,16 +114,16 @@ discard block |
||
114 | 114 | public function getEmailForPasswordReset() |
115 | 115 | { |
116 | 116 | list(, $caller) = debug_backtrace(false); |
117 | - if(isset($caller['class'])) |
|
118 | - $caller = explode('\\', $caller['class']); |
|
117 | + if (isset($caller[ 'class' ])) |
|
118 | + $caller = explode('\\', $caller[ 'class' ]); |
|
119 | 119 | else |
120 | 120 | $caller = ''; |
121 | 121 | |
122 | 122 | //check if this function is called by email sender |
123 | - if ((count($caller) && $caller[count($caller) - 1] == 'PasswordBroker') || (defined('HHVM_VERSION') && $caller == '')) |
|
123 | + if ((count($caller) && $caller[ count($caller) - 1 ] == 'PasswordBroker') || (defined('HHVM_VERSION') && $caller == '')) |
|
124 | 124 | return $this->email; |
125 | 125 | //return unique identify for token repository |
126 | - return $this->email . $this->company->id; |
|
126 | + return $this->email.$this->company->id; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -114,14 +114,16 @@ |
||
114 | 114 | public function getEmailForPasswordReset() |
115 | 115 | { |
116 | 116 | list(, $caller) = debug_backtrace(false); |
117 | - if(isset($caller['class'])) |
|
118 | - $caller = explode('\\', $caller['class']); |
|
119 | - else |
|
120 | - $caller = ''; |
|
117 | + if(isset($caller['class'])) { |
|
118 | + $caller = explode('\\', $caller['class']); |
|
119 | + } else { |
|
120 | + $caller = ''; |
|
121 | + } |
|
121 | 122 | |
122 | 123 | //check if this function is called by email sender |
123 | - if ((count($caller) && $caller[count($caller) - 1] == 'PasswordBroker') || (defined('HHVM_VERSION') && $caller == '')) |
|
124 | - return $this->email; |
|
124 | + if ((count($caller) && $caller[count($caller) - 1] == 'PasswordBroker') || (defined('HHVM_VERSION') && $caller == '')) { |
|
125 | + return $this->email; |
|
126 | + } |
|
125 | 127 | //return unique identify for token repository |
126 | 128 | return $this->email . $this->company->id; |
127 | 129 | } |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | */ |
17 | 17 | public function __construct() |
18 | 18 | { |
19 | - config(['auth.model' => \plunner\Employee::class]); |
|
20 | - config(['jwt.user' => \plunner\Employee::class]); |
|
19 | + config([ 'auth.model' => \plunner\Employee::class ]); |
|
20 | + config([ 'jwt.user' => \plunner\Employee::class ]); |
|
21 | 21 | $this->middleware('jwt.authandrefresh:mode-en'); |
22 | 22 | } |
23 | 23 | |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | public function index() |
30 | 30 | { |
31 | 31 | $employee = \Auth::user(); |
32 | - return $employee->groups()->with(['meetings'=>function($query) { |
|
32 | + return $employee->groups()->with([ 'meetings'=>function($query) { |
|
33 | 33 | $query->where('start_time', '=', NULL); |
34 | - }])->get(); |
|
34 | + } ])->get(); |
|
35 | 35 | //TODO get only current meetings |
36 | 36 | } |
37 | 37 |
@@ -2,15 +2,12 @@ |
||
2 | 2 | |
3 | 3 | namespace plunner\Http\Controllers\Employees\Planners; |
4 | 4 | |
5 | -use Illuminate\Http\Request; |
|
6 | -use plunner\Employee; |
|
7 | -use plunner\Http\Requests; |
|
8 | -use plunner\Meeting; |
|
5 | +use Illuminate\Support\Facades\Response; |
|
9 | 6 | use plunner\Group; |
10 | -use plunner\MeetingTimeslot; |
|
11 | 7 | use plunner\Http\Controllers\Controller; |
12 | 8 | use plunner\Http\Requests\Employees\MeetingTimeslotRequest; |
13 | -use Illuminate\Support\Facades\Response; |
|
9 | +use plunner\Meeting; |
|
10 | +use plunner\MeetingTimeslot; |
|
14 | 11 | |
15 | 12 | |
16 | 13 | class MeetingTimeslotsController extends Controller |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | */ |
21 | 21 | public function __construct() |
22 | 22 | { |
23 | - config(['auth.model' => \plunner\Planner::class]); |
|
24 | - config(['jwt.user' => \plunner\Planner::class]); |
|
23 | + config([ 'auth.model' => \plunner\Planner::class ]); |
|
24 | + config([ 'jwt.user' => \plunner\Planner::class ]); |
|
25 | 25 | $this->middleware('jwt.authandrefresh:mode-en'); |
26 | 26 | } |
27 | 27 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | if ($meeting->group_id == $groupId) |
41 | 41 | return $meeting->timeslots; |
42 | - return Response::json(['error' => 'meeting->group_id <> groupId'], 403); |
|
42 | + return Response::json([ 'error' => 'meeting->group_id <> groupId' ], 403); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | if ($meeting->group_id == $groupId && $timeslot->meeting_id == $meetingId) |
63 | 63 | return $timeslot; |
64 | - return Response::json(['error' => 'meeting->group_id <> groupId || timeslot->meeting_id <> meetingId'], 403); |
|
64 | + return Response::json([ 'error' => 'meeting->group_id <> groupId || timeslot->meeting_id <> meetingId' ], 403); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $timeslot = $meeting->timeslots()->create($input); |
84 | 84 | return $timeslot; |
85 | 85 | } |
86 | - return Response::json(['error' => 'meeting->group_id <> groupId'], 403); |
|
86 | + return Response::json([ 'error' => 'meeting->group_id <> groupId' ], 403); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | $timeslot->update($input); |
108 | 108 | return $timeslot; |
109 | 109 | } |
110 | - return Response::json(['error' => 'meeting->group_id <> groupId || timeslot->meeting_id <> meetingId'], 403); |
|
110 | + return Response::json([ 'error' => 'meeting->group_id <> groupId || timeslot->meeting_id <> meetingId' ], 403); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -131,6 +131,6 @@ discard block |
||
131 | 131 | $timeslot->delete(); |
132 | 132 | return $timeslot; |
133 | 133 | } |
134 | - return Response::json(['error' => 'meeting->group_id <> groupId || timeslot->meeting_id <> meetingId'], 403); |
|
134 | + return Response::json([ 'error' => 'meeting->group_id <> groupId || timeslot->meeting_id <> meetingId' ], 403); |
|
135 | 135 | } |
136 | 136 | } |
@@ -37,8 +37,9 @@ discard block |
||
37 | 37 | $meeting = Meeting::findOrFail($meetingId); |
38 | 38 | $this->authorize($meeting); |
39 | 39 | |
40 | - if ($meeting->group_id == $groupId) |
|
41 | - return $meeting->timeslots; |
|
40 | + if ($meeting->group_id == $groupId) { |
|
41 | + return $meeting->timeslots; |
|
42 | + } |
|
42 | 43 | return Response::json(['error' => 'meeting->group_id <> groupId'], 403); |
43 | 44 | } |
44 | 45 | |
@@ -59,8 +60,9 @@ discard block |
||
59 | 60 | $timeslot = MeetingTimeslot::findOrFail($timeslotId); |
60 | 61 | $this->authorize($timeslot); |
61 | 62 | |
62 | - if ($meeting->group_id == $groupId && $timeslot->meeting_id == $meetingId) |
|
63 | - return $timeslot; |
|
63 | + if ($meeting->group_id == $groupId && $timeslot->meeting_id == $meetingId) { |
|
64 | + return $timeslot; |
|
65 | + } |
|
64 | 66 | return Response::json(['error' => 'meeting->group_id <> groupId || timeslot->meeting_id <> meetingId'], 403); |
65 | 67 | } |
66 | 68 |