@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | public function handle() |
16 | 16 | { |
17 | 17 | $build = \Tremby\LaravelGitVersion\GitVersionHelper::getVersion(); |
18 | - if( env('TD_SANDBOX') == 'TRUE') { |
|
18 | + if (env('TD_SANDBOX') == 'TRUE') { |
|
19 | 19 | $env = 'sandbox'; |
20 | 20 | } |
21 | 21 | else { |
@@ -23,37 +23,37 @@ discard block |
||
23 | 23 | } |
24 | 24 | |
25 | 25 | $userSession = TDsession::where('s_user_id', $this->request->userId)->first(); |
26 | - if($userSession != null ) { |
|
26 | + if ($userSession != null) { |
|
27 | 27 | Log::info('CP_SearchTDTicketJob: Found user session.'); |
28 | - if($userSession->td_token){ |
|
29 | - $TDinstance = new CP_TDinstance( env('TD_BEID'), env('TD_WEBSERVICESKEY'), env('TD_URLROOT'), env('TD_APPID'), $env, (string)$userSession->td_token ); |
|
28 | + if ($userSession->td_token) { |
|
29 | + $TDinstance = new CP_TDinstance(env('TD_BEID'), env('TD_WEBSERVICESKEY'), env('TD_URLROOT'), env('TD_APPID'), $env, (string)$userSession->td_token); |
|
30 | 30 | Log::info('CP_SearchTDTicketJob: CP_TDinstance initialized with existing JWT.'); |
31 | 31 | } |
32 | 32 | else { |
33 | - $TDinstance = new CP_TDinstance( env('TD_BEID'), env('TD_WEBSERVICESKEY'), env('TD_URLROOT'), env('TD_APPID'), $env ); |
|
33 | + $TDinstance = new CP_TDinstance(env('TD_BEID'), env('TD_WEBSERVICESKEY'), env('TD_URLROOT'), env('TD_APPID'), $env); |
|
34 | 34 | Log::info('CP_SearchTDTicketJob: CP_TDinstance initialized with new JWT.'); |
35 | 35 | } |
36 | 36 | |
37 | 37 | Log::info('CP_SearchTDTicketJob: Updating existing CP_TDsession s_token and td_token.'); |
38 | - $userSession->s_token = $this->request->token; |
|
38 | + $userSession->s_token = $this->request->token; |
|
39 | 39 | $userSession->td_token = $TDinstance; |
40 | 40 | $userSession->save(); |
41 | 41 | } |
42 | 42 | else { |
43 | 43 | Log::info('CP_SearchTDTicketJob: No user session.'); |
44 | 44 | Log::info('CP_SearchTDTicketJob: Creating new user session.'); |
45 | - $TDinstance = new CP_TDinstance( env('TD_BEID'), env('TD_WEBSERVICESKEY'), env('TD_URLROOT'), env('TD_APPID'), $env ); |
|
45 | + $TDinstance = new CP_TDinstance(env('TD_BEID'), env('TD_WEBSERVICESKEY'), env('TD_URLROOT'), env('TD_APPID'), $env); |
|
46 | 46 | Log::info('CP_SearchTDTicketJob: New CP_TDinstance initialized.'); |
47 | 47 | $userSession = new TDsession; |
48 | 48 | Log::info('CP_SearchTDTicketJob: New CP_TDsession initialized.'); |
49 | 49 | Log::info('CP_SearchTDTicketJob: Updating CP_TDsession s_token and td_token.'); |
50 | 50 | $userSession->s_user_id = $this->request->userId; |
51 | - $userSession->s_token = $this->request->token; |
|
51 | + $userSession->s_token = $this->request->token; |
|
52 | 52 | $userSession->td_token = $TDinstance; |
53 | 53 | $userSession->save(); |
54 | 54 | } |
55 | 55 | |
56 | - if($TDinstance->checkToken()){ |
|
56 | + if ($TDinstance->checkToken()) { |
|
57 | 57 | Log::info('CP_SearchTDTicketJob: There is a token.'); |
58 | 58 | $auth = true; |
59 | 59 | $tickets = $TDinstance->searchTicketsName($this->request->text); |
@@ -69,12 +69,12 @@ discard block |
||
69 | 69 | if (!count($tickets) && $auth) { |
70 | 70 | return $this->respondToSlack(" |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | { |
16 | 16 | $build = \Tremby\LaravelGitVersion\GitVersionHelper::getVersion(); |
17 | 17 | |
18 | - if( env('TD_SANDBOX') == 'TRUE') { |
|
18 | + if (env('TD_SANDBOX') == 'TRUE') { |
|
19 | 19 | $env = 'sandbox'; |
20 | 20 | } |
21 | 21 | else { |
@@ -23,37 +23,37 @@ discard block |
||
23 | 23 | } |
24 | 24 | |
25 | 25 | $userSession = TDsession::where('s_user_id', $this->request->userId)->first(); |
26 | - if($userSession != null ) { |
|
26 | + if ($userSession != null) { |
|
27 | 27 | Log::info('CP_ShowTDTicketJob: Found user session.'); |
28 | - if($userSession->td_token){ |
|
29 | - $TDinstance = new CP_TDinstance( env('TD_BEID'), env('TD_WEBSERVICESKEY'), env('TD_URLROOT'), env('TD_APPID'), $env, (string)$userSession->td_token ); |
|
28 | + if ($userSession->td_token) { |
|
29 | + $TDinstance = new CP_TDinstance(env('TD_BEID'), env('TD_WEBSERVICESKEY'), env('TD_URLROOT'), env('TD_APPID'), $env, (string)$userSession->td_token); |
|
30 | 30 | Log::info('CP_ShowTDTicketJob: CP_TDinstance initialized with existing JWT.'); |
31 | 31 | } |
32 | 32 | else { |
33 | - $TDinstance = new CP_TDinstance( env('TD_BEID'), env('TD_WEBSERVICESKEY'), env('TD_URLROOT'), env('TD_APPID'), $env ); |
|
33 | + $TDinstance = new CP_TDinstance(env('TD_BEID'), env('TD_WEBSERVICESKEY'), env('TD_URLROOT'), env('TD_APPID'), $env); |
|
34 | 34 | Log::info('CP_ShowTDTicketJob: CP_TDinstance initialized with new JWT.'); |
35 | 35 | } |
36 | 36 | |
37 | 37 | Log::info('CP_ShowTDTicketJob: Updating existing CP_TDsession s_token and td_token.'); |
38 | - $userSession->s_token = $this->request->token; |
|
38 | + $userSession->s_token = $this->request->token; |
|
39 | 39 | $userSession->td_token = $TDinstance; |
40 | 40 | $userSession->save(); |
41 | 41 | } |
42 | 42 | else { |
43 | 43 | Log::info('CP_ShowTDTicketJob: No user session.'); |
44 | 44 | Log::info('CP_ShowTDTicketJob: Creating new user session.'); |
45 | - $TDinstance = new CP_TDinstance( env('TD_BEID'), env('TD_WEBSERVICESKEY'), env('TD_URLROOT'), env('TD_APPID'), $env ); |
|
45 | + $TDinstance = new CP_TDinstance(env('TD_BEID'), env('TD_WEBSERVICESKEY'), env('TD_URLROOT'), env('TD_APPID'), $env); |
|
46 | 46 | Log::info('CP_ShowTDTicketJob: New CP_TDinstance initialized.'); |
47 | 47 | $userSession = new TDsession; |
48 | 48 | Log::info('CP_ShowTDTicketJob: New CP_TDsession initialized.'); |
49 | 49 | Log::info('CP_ShowTDTicketJob: Updating CP_TDsession s_token and td_token.'); |
50 | 50 | $userSession->s_user_id = $this->request->userId; |
51 | - $userSession->s_token = $this->request->token; |
|
51 | + $userSession->s_token = $this->request->token; |
|
52 | 52 | $userSession->td_token = $TDinstance; |
53 | 53 | $userSession->save(); |
54 | 54 | } |
55 | 55 | |
56 | - if($TDinstance->checkToken()){ |
|
56 | + if ($TDinstance->checkToken()) { |
|
57 | 57 | Log::info('CP_ShowTDTicketJob: There is a token.'); |
58 | 58 | $auth = true; |
59 | 59 | $ticket = $TDinstance->ticket($this->request->text); |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | |
68 | - if($ticket && $auth) { |
|
68 | + if ($ticket && $auth) { |
|
69 | 69 | $date = date('F jS, Y', strtotime($ticket['CreatedDate'])); |
70 | 70 | $ticketURL = (string)$TDinstance->rootAppsUrl() . "Tickets/TicketDet?TicketID=" . $ticket['ID']; |
71 | 71 | $assets = $TDinstance->searchAssets($ticket['ID']); |
72 | 72 | $assetnames = "No Assets"; |
73 | 73 | $userSession->increment('td_tickets'); |
74 | 74 | |
75 | - if(count($assets)){ |
|
75 | + if (count($assets)) { |
|
76 | 76 | $assetnames = ''; |
77 | 77 | foreach ($assets as $asset) { |
78 | 78 | $assetnames = $assetnames . $asset['Name'] . ', '; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | ->displayResponseToEveryoneOnChannel() |
103 | 103 | ->send(); |
104 | 104 | } |
105 | - elseif(!$ticket && $auth) { |
|
105 | + elseif (!$ticket && $auth) { |
|
106 | 106 | $this->respondToSlack(" |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | { |
22 | 22 | Log::info('CP_ShowTDTicket: canHandle method called.'); |
23 | 23 | Log::info('CP_ShowTDTicket: Request type is ' . gettype($request) . '.'); |
24 | - if($request->command) { |
|
24 | + if ($request->command) { |
|
25 | 25 | Log::info('CP_ShowTDTicket: Given command ' . $request->command . '.'); |
26 | - if($request->text == 'help' || $request->text == 'Help') { |
|
26 | + if ($request->text == 'help' || $request->text == 'Help') { |
|
27 | 27 | Log::info('CP_ShowTDTicket: User is requesting help. Stepping aside.'); |
28 | 28 | return false; |
29 | 29 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function handle(Request $request): Response |
48 | 48 | { |
49 | - if(is_numeric($request->text)) { |
|
49 | + if (is_numeric($request->text)) { |
|
50 | 50 | $this->dispatch(new ShowTDTicketJob()); |
51 | 51 | return $this->respondToSlack("One moment please…"); |
52 | 52 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | if (in_array($key, $this->encryptable)) { |
13 | 13 | try { |
14 | - if($value){ |
|
14 | + if ($value) { |
|
15 | 15 | $value = Crypt::decrypt($value); |
16 | 16 | } |
17 | 17 | } catch (DecryptException $e) { |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | public function setAttribute($key, $value) |
27 | 27 | { |
28 | 28 | if (in_array($key, $this->encryptable)) { |
29 | - if($value) { |
|
29 | + if ($value) { |
|
30 | 30 | $value = Crypt::encrypt($value); |
31 | 31 | } |
32 | 32 | } |
@@ -11,13 +11,13 @@ discard block |
||
11 | 11 | Log::info('CP_SlackButtonController: processBtn method called.'); |
12 | 12 | Log::info('CP_SlackButtonController: Request type is ' . gettype($request) . '.'); |
13 | 13 | $data = json_decode($request['payload']); |
14 | - if($data) { |
|
14 | + if ($data) { |
|
15 | 15 | Log::info('CP_SlackButtonController: Controller was given data.'); |
16 | 16 | } |
17 | 17 | else { |
18 | 18 | Log::info('CP_SlackButtonController: Controller was called, but no data given.'); |
19 | 19 | } |
20 | - if($data->token == env('SLACK_SLASH_COMMAND_VERIFICATION_TOKEN')) { |
|
20 | + if ($data->token == env('SLACK_SLASH_COMMAND_VERIFICATION_TOKEN')) { |
|
21 | 21 | Log::info('CP_SlackButtonController: Token verified. Proceeding.'); |
22 | 22 | $this->buttonResponse($data); |
23 | 23 | } |
@@ -28,16 +28,16 @@ discard block |
||
28 | 28 | |
29 | 29 | private function buttonResponse($data) { |
30 | 30 | Log::info('CP_SlackButtonController: buttonResponse method called.'); |
31 | - $ch = curl_init( $data->response_url ); |
|
31 | + $ch = curl_init($data->response_url); |
|
32 | 32 | $payload = '{"text":"One moment please…"}'; |
33 | - curl_setopt( $ch, CURLOPT_POSTFIELDS, $payload ); |
|
34 | - curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); |
|
35 | - curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); |
|
33 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); |
|
34 | + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); |
|
35 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
36 | 36 | $result = curl_exec($ch); |
37 | 37 | curl_close($ch); |
38 | 38 | |
39 | 39 | $userSession = TDsession::where('s_user_id', $data->user->id)->first(); |
40 | - if($userSession != null ) { |
|
40 | + if ($userSession != null) { |
|
41 | 41 | Log::info('CP_SlackButtonController: Found user session.'); |
42 | 42 | $userSession->increment('s_showtickets'); |
43 | 43 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | Log::info('CP_SlackButtonController: New CP_TDsession initialized.'); |
49 | 49 | Log::info('CP_SlackButtonController: Updating CP_TDsession s_user_id and s_token.'); |
50 | 50 | $userSession->s_user_id = $data->user->id; |
51 | - $userSession->s_token = $data->token; |
|
51 | + $userSession->s_token = $data->token; |
|
52 | 52 | $userSession->save(); |
53 | 53 | |
54 | 54 | $userSession->increment('s_showtickets'); |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | public function __construct() { |
18 | 18 | $a = func_get_args(); |
19 | 19 | $i = func_num_args(); |
20 | - if (method_exists($this,$f='__construct'.$i)) { |
|
21 | - call_user_func_array(array($this,$f),$a); |
|
20 | + if (method_exists($this, $f = '__construct' . $i)) { |
|
21 | + call_user_func_array(array($this, $f), $a); |
|
22 | 22 | } |
23 | 23 | } |
24 | 24 | |
@@ -64,17 +64,17 @@ discard block |
||
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
67 | - private function authorize($b, $w, $u){ |
|
67 | + private function authorize($b, $w, $u) { |
|
68 | 68 | Log::info('CP_TDauth: authorize method called.'); |
69 | 69 | Log::info('CP_TDauth: authorize requesting at [' . $u . 'auth/loginadmin].'); |
70 | - $ch = curl_init( $u . 'auth/loginadmin'); |
|
71 | - $payload = json_encode( array( "BEID" => $b, "WebServicesKey" => $w ) ); |
|
72 | - curl_setopt( $ch, CURLOPT_POSTFIELDS, $payload ); |
|
73 | - curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); |
|
74 | - curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); |
|
70 | + $ch = curl_init($u . 'auth/loginadmin'); |
|
71 | + $payload = json_encode(array("BEID" => $b, "WebServicesKey" => $w)); |
|
72 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); |
|
73 | + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); |
|
74 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
75 | 75 | $bearer = curl_exec($ch); |
76 | 76 | curl_close($ch); |
77 | - if(!$bearer) { |
|
77 | + if (!$bearer) { |
|
78 | 78 | Log::info('CP_TDauth: Authorization failed.'); |
79 | 79 | } |
80 | 80 | else { |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | |
89 | 89 | public function checkToken() { |
90 | 90 | Log::info('CP_TDauth: checkToken method called.'); |
91 | - if($this->authstring) { |
|
91 | + if ($this->authstring) { |
|
92 | 92 | if (($this->expires - time()) <= 10) { |
93 | 93 | $this->authorize($this->BEID, $this->WebServicesKey, $this->urlroot); |
94 | 94 | Log::info('CP_TDauth: Token was expired. Replaced with new token.'); |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | Log::info('CP_TDinstance: connect method called.'); |
125 | 125 | $this->checkToken(); |
126 | 126 | $ch = curl_init($this->urlroot . $point); |
127 | - curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json', $this->authstring)); |
|
128 | - curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); |
|
127 | + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json', $this->authstring)); |
|
128 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
129 | 129 | if ($type == 'post') { |
130 | 130 | Log::info('CP_TDinstance: connect method POST.'); |
131 | 131 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
@@ -161,12 +161,12 @@ discard block |
||
161 | 161 | Log::info('CP_TDinstance: searchTicketsName method called.'); |
162 | 162 | $flag = $this->flagCheck($search); |
163 | 163 | |
164 | - if(!$flag) { |
|
164 | + if (!$flag) { |
|
165 | 165 | $people = $this->searchPeople($search); |
166 | 166 | foreach ($people as $person) { |
167 | 167 | $uids[] = $person['UID']; |
168 | 168 | } |
169 | - if(isset($uids)) { |
|
169 | + if (isset($uids)) { |
|
170 | 170 | $tickets = $this->searchResponsibility($uids); |
171 | 171 | return $tickets; |
172 | 172 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | } |
176 | 176 | } |
177 | 177 | else { |
178 | - if($flag = '-r') { |
|
178 | + if ($flag = '-r') { |
|
179 | 179 | $data = array("RequestorNameSearch" => substr($search, 0, -3)); |
180 | 180 | $data_string = json_encode($data); |
181 | 181 | $tickets = $this->connect('post', $this->appid . '/tickets/search', $data_string); |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | |
207 | 207 | public function searchResponsibility($search) { |
208 | 208 | Log::info('CP_TDinstance: searchResponsibility method called.'); |
209 | - if (! is_array($search)) { |
|
209 | + if (!is_array($search)) { |
|
210 | 210 | $search = array((string)$search); |
211 | 211 | } |
212 | 212 | $ResponsibilityUids = $search; |