@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | { |
34 | 34 | $friends = $this->model->getFriends(); |
35 | 35 | $i = 0; |
36 | - foreach($friends as $friend) |
|
36 | + foreach ($friends as $friend) |
|
37 | 37 | { |
38 | 38 | $i = $i + 1; |
39 | 39 | $user_loader = $this->user_loader->load_users(array( |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | { |
58 | 58 | $requests = $this->model->get_friends_requests(); |
59 | 59 | $i = 0; |
60 | - foreach($requests as $request) |
|
60 | + foreach ($requests as $request) |
|
61 | 61 | { |
62 | 62 | $i = $i + 1; |
63 | 63 | $user_loader = $this->user_loader->load_users(array( |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | |
81 | 81 | public function delete_request($requests_id) |
82 | 82 | { |
83 | - if(is_array($requests_id)) |
|
83 | + if (is_array($requests_id)) |
|
84 | 84 | { |
85 | - foreach($requests_id as $id) |
|
85 | + foreach ($requests_id as $id) |
|
86 | 86 | { |
87 | 87 | $this->model->delete_friend_request($id); |
88 | 88 | } |
@@ -95,12 +95,12 @@ discard block |
||
95 | 95 | |
96 | 96 | public function approve_request($requests_id) |
97 | 97 | { |
98 | - if(is_array($requests_id)) |
|
98 | + if (is_array($requests_id)) |
|
99 | 99 | { |
100 | - foreach($requests_id as $id) |
|
100 | + foreach ($requests_id as $id) |
|
101 | 101 | { |
102 | 102 | $request_data = $this->model->get_friend_request($id); |
103 | - if($request_data) |
|
103 | + if ($request_data) |
|
104 | 104 | { |
105 | 105 | $this->model->add_friend(array( |
106 | 106 | 'user_id' => $request_data['user_id'], |
@@ -122,26 +122,26 @@ discard block |
||
122 | 122 | } |
123 | 123 | |
124 | 124 | public function send_request($user_id) { |
125 | - $user_id = ( int ) $user_id; |
|
125 | + $user_id = (int)$user_id; |
|
126 | 126 | $sender_id = $this->user->data ['user_id']; |
127 | 127 | |
128 | - $insert = array ( |
|
128 | + $insert = array( |
|
129 | 129 | 'user_id' => $user_id, |
130 | 130 | 'sender_id' => $sender_id |
131 | 131 | ); |
132 | 132 | |
133 | - if ($request_id = $this->model->insert_friends_request ( $insert )) { |
|
133 | + if ($request_id = $this->model->insert_friends_request($insert)) { |
|
134 | 134 | |
135 | - $notification_data = array ( |
|
135 | + $notification_data = array( |
|
136 | 136 | 'request_id' => $request_id, |
137 | 137 | 'sender_id' => $sender_id, |
138 | 138 | 'sender_username' => $this->user->data ['username'], |
139 | 139 | 'user_id' => $user_id |
140 | 140 | ); |
141 | 141 | |
142 | - $this->notification_manager->add_notifications ( array ( |
|
142 | + $this->notification_manager->add_notifications(array( |
|
143 | 143 | 'florinp.messenger.notification.type.friend_request' |
144 | - ), $notification_data ); |
|
144 | + ), $notification_data); |
|
145 | 145 | |
146 | 146 | return true; |
147 | 147 | } |
@@ -151,9 +151,9 @@ discard block |
||
151 | 151 | |
152 | 152 | public function remove_friend($user_id) { |
153 | 153 | |
154 | - if(is_array($user_id)) |
|
154 | + if (is_array($user_id)) |
|
155 | 155 | { |
156 | - foreach($user_id as $id) |
|
156 | + foreach ($user_id as $id) |
|
157 | 157 | { |
158 | 158 | $this->model->remove_friend($id); |
159 | 159 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | } |
162 | 162 | else |
163 | 163 | { |
164 | - if($user_id > 1) |
|
164 | + if ($user_id > 1) |
|
165 | 165 | { |
166 | 166 | $this->model->remove_friend($user_id); |
167 | 167 | return true; |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | protected $notification_manager; |
19 | 19 | protected $emojione; |
20 | 20 | |
21 | - public function __construct(\phpbb\config\config $config, \phpbb\controller\helper $helper, \phpbb\template\template $template, \phpbb\request\request $request ,\phpbb\user $user, \florinp\messenger\models\main_model $model, \phpbb\notification\manager $notification_manager, \florinp\messenger\libs\emojione $emojione) |
|
21 | + public function __construct(\phpbb\config\config $config, \phpbb\controller\helper $helper, \phpbb\template\template $template, \phpbb\request\request $request, \phpbb\user $user, \florinp\messenger\models\main_model $model, \phpbb\notification\manager $notification_manager, \florinp\messenger\libs\emojione $emojione) |
|
22 | 22 | { |
23 | 23 | $this->config = $config; |
24 | 24 | $this->helper = $helper; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | { |
44 | 44 | /* AJAX check */ |
45 | 45 | $http_request = $this->request->server('HTTP_X_REQUESTED_WITH'); |
46 | - if(empty($http_request) && strtolower($http_request) != 'xmlhttprequest') { |
|
46 | + if (empty($http_request) && strtolower($http_request) != 'xmlhttprequest') { |
|
47 | 47 | return new Response("The request is invalid", 500); |
48 | 48 | } |
49 | 49 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $sender_id = $this->user->data['user_id']; |
53 | 53 | |
54 | 54 | |
55 | - if($receiver_id != 0 && trim($text) != '') |
|
55 | + if ($receiver_id != 0 && trim($text) != '') |
|
56 | 56 | { |
57 | 57 | $text = htmlspecialchars($text); |
58 | 58 | $text = str_replace(array("\n", "\r"), '', $text); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | 'sentAt' => time() |
65 | 65 | ); |
66 | 66 | |
67 | - if($id = $this->model->sendMessage($message)) |
|
67 | + if ($id = $this->model->sendMessage($message)) |
|
68 | 68 | { |
69 | 69 | $lastMessage = $this->model->getMessageById($id); |
70 | 70 | $response = array('success' => true, 'message' => $lastMessage); |
@@ -82,14 +82,14 @@ discard block |
||
82 | 82 | public function getFile($id) |
83 | 83 | { |
84 | 84 | global $phpbb_root_path; |
85 | - $uploadDir = $phpbb_root_path . 'store/messenger/files'; |
|
85 | + $uploadDir = $phpbb_root_path.'store/messenger/files'; |
|
86 | 86 | $id = explode('_', $id)[1]; |
87 | 87 | $file = $this->model->getFileById($id); |
88 | - if($file && is_file($uploadDir.'/'.$file['file'])) { |
|
88 | + if ($file && is_file($uploadDir.'/'.$file['file'])) { |
|
89 | 89 | header('Content-Type: application/csv'); |
90 | - header('Content-Disposition: attachment; filename=' . $file['file']); |
|
90 | + header('Content-Disposition: attachment; filename='.$file['file']); |
|
91 | 91 | header('Pragma: no-cache'); |
92 | - readfile($uploadDir . '/' . $file['file']); |
|
92 | + readfile($uploadDir.'/'.$file['file']); |
|
93 | 93 | } else { |
94 | 94 | return new Response("The request is invalid", 500); |
95 | 95 | } |
@@ -102,16 +102,16 @@ discard block |
||
102 | 102 | $receiver_id = $this->request->variable('receiver_id', 0); |
103 | 103 | $sender_id = $this->user->data['user_id']; |
104 | 104 | |
105 | - $uploadDir = $phpbb_root_path . 'store/messenger/files'; |
|
105 | + $uploadDir = $phpbb_root_path.'store/messenger/files'; |
|
106 | 106 | $file = $this->request->file('file'); |
107 | - if($receiver_id != 0 && !empty($file)) { |
|
108 | - if($file['error'] == 0) { |
|
107 | + if ($receiver_id != 0 && !empty($file)) { |
|
108 | + if ($file['error'] == 0) { |
|
109 | 109 | $extension = pathinfo($file['name'], PATHINFO_EXTENSION); |
110 | 110 | $fileName = $file['name']; |
111 | 111 | $newName = md5(time().''.$fileName).'.'.$extension; |
112 | 112 | $type = $file['type']; |
113 | 113 | |
114 | - if(move_uploaded_file($file['tmp_name'], $uploadDir . '/' . $newName)) { |
|
114 | + if (move_uploaded_file($file['tmp_name'], $uploadDir.'/'.$newName)) { |
|
115 | 115 | $data = array( |
116 | 116 | 'sender_id' => $sender_id, |
117 | 117 | 'receiver_id' => $receiver_id, |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | 'file' => $newName, |
120 | 120 | 'type' => $type |
121 | 121 | ); |
122 | - if($id = $this->model->sendFile($data)) { |
|
122 | + if ($id = $this->model->sendFile($data)) { |
|
123 | 123 | $lastFile = $this->model->getFileById($id); |
124 | 124 | $response = array('success' => true, 'file' => $lastFile); |
125 | 125 | } else { |
@@ -154,13 +154,13 @@ discard block |
||
154 | 154 | { |
155 | 155 | /* AJAX check */ |
156 | 156 | $http_request = $this->request->server('HTTP_X_REQUESTED_WITH'); |
157 | - if(empty($http_request) && strtolower($http_request) != 'xmlhttprequest') { |
|
157 | + if (empty($http_request) && strtolower($http_request) != 'xmlhttprequest') { |
|
158 | 158 | return new Response("The request is invalid", 500); |
159 | 159 | } |
160 | 160 | |
161 | 161 | $friend_id = $this->request->variable('friend_id', 0); |
162 | 162 | |
163 | - if($friend_id > 0) { |
|
163 | + if ($friend_id > 0) { |
|
164 | 164 | $messages = $this->model->getMessages($friend_id); |
165 | 165 | return new JsonResponse($messages, 200); |
166 | 166 | } |
@@ -171,12 +171,12 @@ discard block |
||
171 | 171 | { |
172 | 172 | /* AJAX check */ |
173 | 173 | $http_request = $this->request->server('HTTP_X_REQUESTED_WITH'); |
174 | - if(empty($http_request) && strtolower($http_request) != 'xmlhttprequest') { |
|
174 | + if (empty($http_request) && strtolower($http_request) != 'xmlhttprequest') { |
|
175 | 175 | return new Response("The request is invalid", 500); |
176 | 176 | } |
177 | 177 | |
178 | 178 | $friend_id = $this->request->variable('friend_id', 0); |
179 | - if($friend_id > 0) |
|
179 | + if ($friend_id > 0) |
|
180 | 180 | { |
181 | 181 | $newVal = $this->model->updateMessagesStatus($friend_id); |
182 | 182 | return new JsonResponse(array('success' => true, 'newVal' => $newVal), 200); |
@@ -188,12 +188,12 @@ discard block |
||
188 | 188 | { |
189 | 189 | /* AJAX check */ |
190 | 190 | $http_request = $this->request->server('HTTP_X_REQUESTED_WITH'); |
191 | - if(empty($http_request) && strtolower($http_request) != 'xmlhttprequest') { |
|
191 | + if (empty($http_request) && strtolower($http_request) != 'xmlhttprequest') { |
|
192 | 192 | return new Response("The request is invalid", 500); |
193 | 193 | } |
194 | 194 | |
195 | 195 | $friend_id = $this->request->variable('friend_id', 0); |
196 | - if($friend_id > 0) |
|
196 | + if ($friend_id > 0) |
|
197 | 197 | { |
198 | 198 | $messages = $this->model->getInboxFromId($friend_id); |
199 | 199 | return new JsonResponse(array('success' => true, 'messages' => $messages), 200); |
@@ -205,12 +205,12 @@ discard block |
||
205 | 205 | { |
206 | 206 | /* AJAX check */ |
207 | 207 | $http_request = $this->request->server('HTTP_X_REQUESTED_WITH'); |
208 | - if(empty($http_request) && strtolower($http_request) != 'xmlhttprequest') { |
|
208 | + if (empty($http_request) && strtolower($http_request) != 'xmlhttprequest') { |
|
209 | 209 | return new Response("The request is invalid", 500); |
210 | 210 | } |
211 | 211 | |
212 | 212 | $friends = $this->model->getFriends(); |
213 | - $friends_online = array_filter($friends, function($friend){ |
|
213 | + $friends_online = array_filter($friends, function($friend) { |
|
214 | 214 | return $friend['user_status'] != 0; |
215 | 215 | }); |
216 | 216 | |
@@ -226,12 +226,12 @@ discard block |
||
226 | 226 | { |
227 | 227 | $emoticons = \florinp\messenger\libs\emojione::$ascii_replace; |
228 | 228 | $eicons = array(); |
229 | - foreach($emoticons as $code => $value) { |
|
229 | + foreach ($emoticons as $code => $value) { |
|
230 | 230 | $eicons[$value] = $code; |
231 | 231 | } |
232 | 232 | |
233 | 233 | $response = array(); |
234 | - foreach($eicons as $emoticon) { |
|
234 | + foreach ($eicons as $emoticon) { |
|
235 | 235 | $item = array(); |
236 | 236 | $item['code'] = $emoticon; |
237 | 237 | $item['image'] = $this->emojione->toImage($emoticon); |
@@ -46,21 +46,21 @@ discard block |
||
46 | 46 | { |
47 | 47 | $context = new RequestContext(); |
48 | 48 | $context->fromRequest($this->symfony_request); |
49 | - $baseUrl = generate_board_url(true) . $context->getBaseUrl(); |
|
49 | + $baseUrl = generate_board_url(true).$context->getBaseUrl(); |
|
50 | 50 | |
51 | 51 | $scriptName = $this->symfony_request->getScriptName(); |
52 | 52 | $scriptName = substr($scriptName, -1, 1) == '/' ? '' : utf8_basename($scriptName); |
53 | 53 | |
54 | - if($scriptName != '') { |
|
54 | + if ($scriptName != '') { |
|
55 | 55 | $baseUrl = str_replace('/'.$scriptName, '', $baseUrl); |
56 | 56 | } |
57 | 57 | |
58 | 58 | $friends = $this->model->getFriends(); |
59 | - $friends_online = array_filter($friends, function($friend){ |
|
59 | + $friends_online = array_filter($friends, function($friend) { |
|
60 | 60 | return $friend['user_status'] != 0; |
61 | 61 | }); |
62 | 62 | $this->template->assign_var('S_COUNT_FRIENDS', count($friends_online)); |
63 | - foreach($friends as $friend) |
|
63 | + foreach ($friends as $friend) |
|
64 | 64 | { |
65 | 65 | $this->template->assign_block_vars('chat_friends', array( |
66 | 66 | 'U_USERID' => $friend['user_id'], |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | public function check_login() |
89 | 89 | { |
90 | 90 | $s_enable_messenger = 0; |
91 | - if(in_array($this->user->data['user_type'], array(USER_NORMAL, USER_FOUNDER))) |
|
91 | + if (in_array($this->user->data['user_type'], array(USER_NORMAL, USER_FOUNDER))) |
|
92 | 92 | { |
93 | 93 | $s_enable_messenger = 1; |
94 | 94 | } |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | { |
100 | 100 | $context = new RequestContext(); |
101 | 101 | $context->fromRequest($this->symfony_request); |
102 | - $baseUrl = generate_board_url(true) . $context->getBaseUrl(); |
|
102 | + $baseUrl = generate_board_url(true).$context->getBaseUrl(); |
|
103 | 103 | |
104 | 104 | $scriptName = $this->symfony_request->getScriptName(); |
105 | 105 | $scriptName = substr($scriptName, -1, 1) == '/' ? '' : utf8_basename($scriptName); |
106 | 106 | |
107 | - if($scriptName != '') { |
|
107 | + if ($scriptName != '') { |
|
108 | 108 | $baseUrl = str_replace('/'.$scriptName, '', $baseUrl); |
109 | 109 | } |
110 | 110 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | 'sender_id' => $user_id |
125 | 125 | )); |
126 | 126 | $check_widget = true; |
127 | - if($user_id == $this->user->data['user_id']) $check_widget = false; |
|
127 | + if ($user_id == $this->user->data['user_id']) $check_widget = false; |
|
128 | 128 | $this->template->assign_vars(array( |
129 | 129 | 'U_USER_ID' => $user_id, |
130 | 130 | 'U_CHECK_FRIEND' => $check_friend, |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | { |
11 | 11 | global $phpbb_root_path; |
12 | 12 | |
13 | - switch($old_state) |
|
13 | + switch ($old_state) |
|
14 | 14 | { |
15 | 15 | case '': |
16 | 16 | $db = new \florinp\messenger\libs\database(); |
@@ -34,11 +34,11 @@ discard block |
||
34 | 34 | ); |
35 | 35 | "); |
36 | 36 | |
37 | - $messengerDir = $phpbb_root_path . 'store/messenger'; |
|
38 | - if(!is_dir($messengerDir)) { |
|
37 | + $messengerDir = $phpbb_root_path.'store/messenger'; |
|
38 | + if (!is_dir($messengerDir)) { |
|
39 | 39 | mkdir($messengerDir, 0777); |
40 | - $filesDir = $messengerDir . '/files'; |
|
41 | - if(!is_dir($filesDir)) { |
|
40 | + $filesDir = $messengerDir.'/files'; |
|
41 | + if (!is_dir($filesDir)) { |
|
42 | 42 | mkdir($filesDir, 0777); |
43 | 43 | } |
44 | 44 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | public function disable_step($old_state) |
62 | 62 | { |
63 | - switch($old_state) |
|
63 | + switch ($old_state) |
|
64 | 64 | { |
65 | 65 | case '': |
66 | 66 | $phpbb_notifications = $this->container->get('notification_manager'); |
@@ -79,16 +79,16 @@ discard block |
||
79 | 79 | { |
80 | 80 | global $phpbb_root_path; |
81 | 81 | |
82 | - $database = $phpbb_root_path . 'store/messenger.db'; |
|
83 | - if(is_file($database)) { |
|
82 | + $database = $phpbb_root_path.'store/messenger.db'; |
|
83 | + if (is_file($database)) { |
|
84 | 84 | unlink($database); |
85 | 85 | } |
86 | 86 | |
87 | - $messengerDir = $phpbb_root_path . 'store/messenger'; |
|
88 | - if(is_dir($messengerDir)) { |
|
87 | + $messengerDir = $phpbb_root_path.'store/messenger'; |
|
88 | + if (is_dir($messengerDir)) { |
|
89 | 89 | $objects = scandir($messengerDir); |
90 | - foreach($objects as $object) { |
|
91 | - if($object != '.' && $object != '..') { |
|
90 | + foreach ($objects as $object) { |
|
91 | + if ($object != '.' && $object != '..') { |
|
92 | 92 | if (filetype($messengerDir."/".$object) == "dir") rmdir($messengerDir."/".$object); else unlink($messengerDir."/".$object); |
93 | 93 | } |
94 | 94 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | { |
13 | 13 | global $phpbb_root_path; |
14 | 14 | |
15 | - $database = $phpbb_root_path . 'store/messenger.db'; |
|
15 | + $database = $phpbb_root_path.'store/messenger.db'; |
|
16 | 16 | parent::__construct('sqlite:'.$database); |
17 | 17 | parent::setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
18 | 18 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | public function select($sql, $array = array(), $fetchMode = PDO::FETCH_ASSOC) |
21 | 21 | { |
22 | 22 | $sth = $this->prepare($sql); |
23 | - foreach($array as $key => $value) |
|
23 | + foreach ($array as $key => $value) |
|
24 | 24 | { |
25 | 25 | $sth->bindValue("$key", $value); |
26 | 26 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | $sth = $this->prepare("INSERT INTO $table (`$fieldNames`) VALUES ($fieldValues)"); |
40 | 40 | |
41 | - foreach($data as $key => $value) |
|
41 | + foreach ($data as $key => $value) |
|
42 | 42 | { |
43 | 43 | $sth->bindValue(":$key", $value); |
44 | 44 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | ksort($data); |
52 | 52 | |
53 | 53 | $fieldDetails = NULL; |
54 | - foreach($data as $key=> $value) { |
|
54 | + foreach ($data as $key=> $value) { |
|
55 | 55 | $fieldDetails .= "`$key`=:$key,"; |
56 | 56 | } |
57 | 57 | $fieldDetails = rtrim($fieldDetails, ','); |
@@ -2401,7 +2401,7 @@ discard block |
||
2401 | 2401 | // useful for sending emojis back to mobile devices |
2402 | 2402 | static function shortnameToUnicode($string) { |
2403 | 2403 | $string = preg_replace_callback('/'.self::$ignoredRegexp.'|('.self::$shortcodeRegexp.')/Si', 'static::shortnameToUnicodeCallback', $string); |
2404 | - if(self::$ascii) { |
|
2404 | + if (self::$ascii) { |
|
2405 | 2405 | $string = preg_replace_callback('/'.self::$ignoredRegexp.'|((\\s|^)'.self::$asciiRegexp.'(?=\\s|$|[!,\.]))/S', 'static::asciiToUnicodeCallback', $string); |
2406 | 2406 | } |
2407 | 2407 | return $string; |
@@ -2414,7 +2414,7 @@ discard block |
||
2414 | 2414 | } |
2415 | 2415 | static function shortnameToImage($string) { |
2416 | 2416 | $string = preg_replace_callback('/'.self::$ignoredRegexp.'|('.self::$shortcodeRegexp.')/Si', 'static::shortnameToImageCallback', $string); |
2417 | - if(self::$ascii) { |
|
2417 | + if (self::$ascii) { |
|
2418 | 2418 | $string = preg_replace_callback('/'.self::$ignoredRegexp.'|((\\s|^)'.self::$asciiRegexp.'(?=\\s|$|[!,\.]))/S', 'static::asciiToImageCallback', $string); |
2419 | 2419 | } |
2420 | 2420 | return $string; |
@@ -2430,7 +2430,7 @@ discard block |
||
2430 | 2430 | // ######## preg_replace callbacks |
2431 | 2431 | // ########################################## |
2432 | 2432 | static function shortnameToAsciiCallback($m) { |
2433 | - if((!is_array($m)) || (!isset($m[1])) || (empty($m[1]))) { |
|
2433 | + if ((!is_array($m)) || (!isset($m[1])) || (empty($m[1]))) { |
|
2434 | 2434 | return $m[0]; |
2435 | 2435 | } |
2436 | 2436 | else { |
@@ -2438,7 +2438,7 @@ discard block |
||
2438 | 2438 | |
2439 | 2439 | $shortname = $m[0]; |
2440 | 2440 | |
2441 | - if(!isset(self::$shortcode_replace[$shortname])) { |
|
2441 | + if (!isset(self::$shortcode_replace[$shortname])) { |
|
2442 | 2442 | return $m[0]; |
2443 | 2443 | } |
2444 | 2444 | |
@@ -2448,7 +2448,7 @@ discard block |
||
2448 | 2448 | } |
2449 | 2449 | } |
2450 | 2450 | static function shortnameToUnicodeCallback($m) { |
2451 | - if((!is_array($m)) || (!isset($m[1])) || (empty($m[1]))) { |
|
2451 | + if ((!is_array($m)) || (!isset($m[1])) || (empty($m[1]))) { |
|
2452 | 2452 | return $m[0]; |
2453 | 2453 | } |
2454 | 2454 | else { |
@@ -2456,7 +2456,7 @@ discard block |
||
2456 | 2456 | |
2457 | 2457 | $shortname = $m[1]; |
2458 | 2458 | |
2459 | - if(!isset($flipped[$shortname])) { |
|
2459 | + if (!isset($flipped[$shortname])) { |
|
2460 | 2460 | return $m[0]; |
2461 | 2461 | } |
2462 | 2462 | |
@@ -2466,13 +2466,13 @@ discard block |
||
2466 | 2466 | } |
2467 | 2467 | } |
2468 | 2468 | static function shortnameToImageCallback($m) { |
2469 | - if((!is_array($m)) || (!isset($m[1])) || (empty($m[1]))) { |
|
2469 | + if ((!is_array($m)) || (!isset($m[1])) || (empty($m[1]))) { |
|
2470 | 2470 | return $m[0]; |
2471 | 2471 | } |
2472 | 2472 | else { |
2473 | 2473 | $shortname = $m[1]; |
2474 | 2474 | |
2475 | - if(!isset(self::$shortcode_replace[$shortname])) { |
|
2475 | + if (!isset(self::$shortcode_replace[$shortname])) { |
|
2476 | 2476 | return $m[0]; |
2477 | 2477 | } |
2478 | 2478 | |
@@ -2480,11 +2480,11 @@ discard block |
||
2480 | 2480 | $unicode = self::$shortcode_replace[$shortname]; |
2481 | 2481 | $filename = strtoupper($unicode); |
2482 | 2482 | |
2483 | - if(self::$unicodeAlt) { $alt = self::convert($unicode); } |
|
2483 | + if (self::$unicodeAlt) { $alt = self::convert($unicode); } |
|
2484 | 2484 | else { $alt = $shortname; } |
2485 | 2485 | |
2486 | - if(self::$imageType == 'png') { |
|
2487 | - if(self::$sprites) { |
|
2486 | + if (self::$imageType == 'png') { |
|
2487 | + if (self::$sprites) { |
|
2488 | 2488 | return '<span class="emojione-'.strtoupper($unicode).'" title="'.htmlspecialchars($shortname).'">'.$alt.'</span>'; |
2489 | 2489 | } |
2490 | 2490 | else { |
@@ -2492,7 +2492,7 @@ discard block |
||
2492 | 2492 | } |
2493 | 2493 | } |
2494 | 2494 | |
2495 | - if(self::$sprites) { |
|
2495 | + if (self::$sprites) { |
|
2496 | 2496 | return '<svg class="emojione"><description>'.$alt.'</description><use xlink:href="'.self::$imagePathSVGSprites.'#emoji-'.strtoupper($unicode).'"></use></svg>'; |
2497 | 2497 | } |
2498 | 2498 | else { |
@@ -2501,7 +2501,7 @@ discard block |
||
2501 | 2501 | } |
2502 | 2502 | } |
2503 | 2503 | static function asciiToUnicodeCallback($m) { |
2504 | - if((!is_array($m)) || (!isset($m[3])) || (empty($m[3]))) { |
|
2504 | + if ((!is_array($m)) || (!isset($m[3])) || (empty($m[3]))) { |
|
2505 | 2505 | return $m[0]; |
2506 | 2506 | } |
2507 | 2507 | else { |
@@ -2511,7 +2511,7 @@ discard block |
||
2511 | 2511 | } |
2512 | 2512 | } |
2513 | 2513 | static function asciiToImageCallback($m) { |
2514 | - if((!is_array($m)) || (!isset($m[3])) || (empty($m[3]))) { |
|
2514 | + if ((!is_array($m)) || (!isset($m[3])) || (empty($m[3]))) { |
|
2515 | 2515 | return $m[0]; |
2516 | 2516 | } |
2517 | 2517 | else { |
@@ -2519,11 +2519,11 @@ discard block |
||
2519 | 2519 | $unicode = self::$ascii_replace[$shortname]; |
2520 | 2520 | |
2521 | 2521 | // unicode char or shortname for the alt tag? (unicode is better for copying and pasting the resulting text) |
2522 | - if(self::$unicodeAlt) { $alt = self::convert($unicode); } |
|
2522 | + if (self::$unicodeAlt) { $alt = self::convert($unicode); } |
|
2523 | 2523 | else { $alt = htmlspecialchars($shortname); } |
2524 | 2524 | |
2525 | - if(self::$imageType == 'png') { |
|
2526 | - if(self::$sprites) { |
|
2525 | + if (self::$imageType == 'png') { |
|
2526 | + if (self::$sprites) { |
|
2527 | 2527 | return $m[2].'<span class="emojione-'.strtoupper($unicode).'" title="'.htmlspecialchars($shortname).'">'.$alt.'</span>'; |
2528 | 2528 | } |
2529 | 2529 | else { |
@@ -2531,7 +2531,7 @@ discard block |
||
2531 | 2531 | } |
2532 | 2532 | } |
2533 | 2533 | |
2534 | - if(self::$sprites) { |
|
2534 | + if (self::$sprites) { |
|
2535 | 2535 | return $m[2].'<svg class="emojione"><description>'.$alt.'</description><use xlink:href="'.self::$imagePathSVGSprites.'#emoji-'.strtoupper($unicode).'"></use></svg>'; |
2536 | 2536 | } |
2537 | 2537 | else { |
@@ -2540,14 +2540,14 @@ discard block |
||
2540 | 2540 | } |
2541 | 2541 | } |
2542 | 2542 | static function toShortCallback($m) { |
2543 | - if((!is_array($m)) || (!isset($m[1])) || (empty($m[1]))) { |
|
2543 | + if ((!is_array($m)) || (!isset($m[1])) || (empty($m[1]))) { |
|
2544 | 2544 | return $m[0]; |
2545 | 2545 | } |
2546 | 2546 | else { |
2547 | 2547 | $unicode = $m[1]; |
2548 | - if(!isset(self::$unicode_replace[$unicode])) { |
|
2548 | + if (!isset(self::$unicode_replace[$unicode])) { |
|
2549 | 2549 | $unicode = substr($m[1], 0, 4); |
2550 | - if(!isset(self::$unicode_replace[$unicode])) { |
|
2550 | + if (!isset(self::$unicode_replace[$unicode])) { |
|
2551 | 2551 | return $m[0]; |
2552 | 2552 | } |
2553 | 2553 | } |
@@ -2556,15 +2556,15 @@ discard block |
||
2556 | 2556 | } |
2557 | 2557 | } |
2558 | 2558 | static function unicodeToImageCallback($m) { |
2559 | - if((!is_array($m)) || (!isset($m[1])) || (empty($m[1]))) { |
|
2559 | + if ((!is_array($m)) || (!isset($m[1])) || (empty($m[1]))) { |
|
2560 | 2560 | return $m[0]; |
2561 | 2561 | } |
2562 | 2562 | else { |
2563 | 2563 | $unicode = $m[1]; |
2564 | 2564 | |
2565 | - if(!isset(self::$unicode_replace[$unicode])) { |
|
2565 | + if (!isset(self::$unicode_replace[$unicode])) { |
|
2566 | 2566 | $unicode = substr($m[1], 0, 4); |
2567 | - if(!isset(self::$unicode_replace[$unicode])) { |
|
2567 | + if (!isset(self::$unicode_replace[$unicode])) { |
|
2568 | 2568 | return $m[0]; |
2569 | 2569 | } |
2570 | 2570 | } |
@@ -2572,11 +2572,11 @@ discard block |
||
2572 | 2572 | $shortname = self::$unicode_replace[$unicode]; |
2573 | 2573 | $filename = strtoupper(self::$shortcode_replace[$shortname]); |
2574 | 2574 | |
2575 | - if(self::$unicodeAlt) { $alt = $unicode; } |
|
2575 | + if (self::$unicodeAlt) { $alt = $unicode; } |
|
2576 | 2576 | else { $alt = $shortname; } |
2577 | 2577 | |
2578 | - if(self::$imageType == 'png') { |
|
2579 | - if(self::$sprites) { |
|
2578 | + if (self::$imageType == 'png') { |
|
2579 | + if (self::$sprites) { |
|
2580 | 2580 | return '<span class="emojione-'.strtoupper($unicode).'" title="'.htmlspecialchars($shortname).'">'.$alt.'</span>'; |
2581 | 2581 | } |
2582 | 2582 | else { |
@@ -2584,7 +2584,7 @@ discard block |
||
2584 | 2584 | } |
2585 | 2585 | } |
2586 | 2586 | |
2587 | - if(self::$sprites) { |
|
2587 | + if (self::$sprites) { |
|
2588 | 2588 | return '<svg class="emojione"><description>'.$alt.'</description><use xlink:href="'.self::$imagePathSVGSprites.'#emoji-'.strtoupper($unicode).'"></use></svg>'; |
2589 | 2589 | } |
2590 | 2590 | else { |
@@ -2597,9 +2597,9 @@ discard block |
||
2597 | 2597 | // ######## helper methods |
2598 | 2598 | // ########################################## |
2599 | 2599 | static function convert($unicode) { |
2600 | - if(stristr($unicode,'-')) { |
|
2601 | - $pairs = explode('-',$unicode); |
|
2602 | - return '&#x'.implode(';&#x',$pairs).';'; |
|
2600 | + if (stristr($unicode, '-')) { |
|
2601 | + $pairs = explode('-', $unicode); |
|
2602 | + return '&#x'.implode(';&#x', $pairs).';'; |
|
2603 | 2603 | } |
2604 | 2604 | else { |
2605 | 2605 | return '&#x'.$unicode.';'; |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | { |
10 | 10 | return array( |
11 | 11 | 'add_tables' => array( |
12 | - $this->table_prefix . 'messenger_friends_request' => array( |
|
12 | + $this->table_prefix.'messenger_friends_request' => array( |
|
13 | 13 | 'COLUMNS' => array( |
14 | 14 | 'request_id' => array('UINT', null, 'auto_increment', 0), |
15 | 15 | 'user_id' => array('UINT', 0), |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | ), |
20 | 20 | 'PRIMARY_KEY' => 'request_id' |
21 | 21 | ), |
22 | - $this->table_prefix . 'messenger_user_friends' => array( |
|
22 | + $this->table_prefix.'messenger_user_friends' => array( |
|
23 | 23 | 'COLUMNS' => array( |
24 | 24 | 'user_id' => array('UINT', 0), |
25 | 25 | 'friend_id' => array('UINT', 0) |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | { |
34 | 34 | return array( |
35 | 35 | 'drop_tables' => array( |
36 | - $this->table_prefix . 'messenger_friends_request', |
|
37 | - $this->table_prefix . 'messenger_user_friends' |
|
36 | + $this->table_prefix.'messenger_friends_request', |
|
37 | + $this->table_prefix.'messenger_user_friends' |
|
38 | 38 | ) |
39 | 39 | ); |
40 | 40 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | array( |
21 | 21 | 'module_basename' => '\florinp\messenger\ucp\ucp_friends_module', |
22 | 22 | 'module_class' => 'ucp_friends_module', |
23 | - 'modes' => array('friends','requests'), |
|
23 | + 'modes' => array('friends', 'requests'), |
|
24 | 24 | ), |
25 | 25 | ) |
26 | 26 | ), |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | array( |
37 | 37 | 'module_basename' => '\florinp\messenger\ucp\ucp_friends_module', |
38 | 38 | 'module_class' => 'ucp_friends_module', |
39 | - 'modes' => array('friends','requests'), |
|
39 | + 'modes' => array('friends', 'requests'), |
|
40 | 40 | ) |
41 | 41 | ) |
42 | 42 | ), |
@@ -29,16 +29,16 @@ discard block |
||
29 | 29 | u.user_colour, |
30 | 30 | s.session_id, |
31 | 31 | s.session_time |
32 | - FROM ". $this->user_friends_table ." |
|
33 | - LEFT JOIN ". USERS_TABLE ." AS u ON u.user_id = ". $this->user_friends_table .".friend_id |
|
34 | - LEFT JOIN ". SESSIONS_TABLE ." AS s ON s.session_user_id = u.user_id |
|
35 | - WHERE ". $this->user_friends_table .".user_id = ". (int)$this->user->data['user_id'] ." |
|
32 | + FROM ". $this->user_friends_table." |
|
33 | + LEFT JOIN ". USERS_TABLE." AS u ON u.user_id = ".$this->user_friends_table.".friend_id |
|
34 | + LEFT JOIN ". SESSIONS_TABLE." AS s ON s.session_user_id = u.user_id |
|
35 | + WHERE ". $this->user_friends_table.".user_id = ".(int)$this->user->data['user_id']." |
|
36 | 36 | GROUP BY u.user_id |
37 | 37 | "; |
38 | 38 | $result = $this->db->sql_query($sql); |
39 | 39 | |
40 | 40 | $friends = array(); |
41 | - while($row = $this->db->sql_fetchrow($result)) |
|
41 | + while ($row = $this->db->sql_fetchrow($result)) |
|
42 | 42 | { |
43 | 43 | $friends[] = array( |
44 | 44 | 'user_id' => $row['user_id'], |
@@ -63,15 +63,15 @@ discard block |
||
63 | 63 | `sender_id`, |
64 | 64 | `status`, |
65 | 65 | `time` |
66 | - FROM ". $this->friends_request_table ." |
|
67 | - WHERE `user_id` = ". (int)$this->user->data['user_id'] ." |
|
66 | + FROM ". $this->friends_request_table." |
|
67 | + WHERE `user_id` = ". (int)$this->user->data['user_id']." |
|
68 | 68 | AND `status` = 0 |
69 | 69 | ORDER BY `time` DESC |
70 | 70 | "; |
71 | 71 | |
72 | 72 | $result = $this->db->sql_query($sql); |
73 | 73 | |
74 | - while($row = $this->db->sql_fetchrow($result)) |
|
74 | + while ($row = $this->db->sql_fetchrow($result)) |
|
75 | 75 | { |
76 | 76 | $requests[] = $row; |
77 | 77 | } |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | `sender_id`, |
88 | 88 | `status`, |
89 | 89 | `time` |
90 | - FROM ". $this->friends_request_table ." |
|
91 | - WHERE `request_id` = ". (int)$id ." |
|
90 | + FROM ". $this->friends_request_table." |
|
91 | + WHERE `request_id` = ". (int)$id." |
|
92 | 92 | AND `status` = 0 |
93 | 93 | ORDER BY `time` DESC |
94 | 94 | LIMIT 1 |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $result = $this->db->sql_query($sql); |
97 | 97 | $row = $this->db->sql_fetchrow($result); |
98 | 98 | |
99 | - if($this->approve_friend_request($id)) |
|
99 | + if ($this->approve_friend_request($id)) |
|
100 | 100 | { |
101 | 101 | return $row; |
102 | 102 | } |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | `sender_id`, |
115 | 115 | `status`, |
116 | 116 | `time` |
117 | - FROM ". $this->friends_request_table ." |
|
118 | - WHERE `sender_id` = ". (int)$sender_id ." |
|
117 | + FROM ". $this->friends_request_table." |
|
118 | + WHERE `sender_id` = ". (int)$sender_id." |
|
119 | 119 | AND `status` = 0 |
120 | 120 | ORDER BY `time` DESC |
121 | 121 | LIMIT 1 |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | |
129 | 129 | public function insert_friends_request(array $data) { |
130 | 130 | $sql = " |
131 | - INSERT INTO " . $this->friends_request_table . " |
|
131 | + INSERT INTO " . $this->friends_request_table." |
|
132 | 132 | ( |
133 | 133 | `user_id`, |
134 | 134 | `sender_id`, |
@@ -137,21 +137,21 @@ discard block |
||
137 | 137 | ) |
138 | 138 | VALUES |
139 | 139 | ( |
140 | - " . ( int ) $data ['user_id'] . ", |
|
141 | - " . ( int ) $data ['sender_id'] . ", |
|
140 | + " . (int)$data ['user_id'].", |
|
141 | + " . (int)$data ['sender_id'].", |
|
142 | 142 | 0, |
143 | - " . time () . " |
|
143 | + " . time()." |
|
144 | 144 | ) |
145 | 145 | "; |
146 | - $this->db->sql_query ( $sql ); |
|
146 | + $this->db->sql_query($sql); |
|
147 | 147 | |
148 | - return $this->db->sql_nextid (); |
|
148 | + return $this->db->sql_nextid(); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | public function delete_friend_request($request_id) |
152 | 152 | { |
153 | 153 | $sql = " |
154 | - DELETE FROM ". $this->friends_request_table ." WHERE `request_id` = ". (int)$request_id ." |
|
154 | + DELETE FROM ". $this->friends_request_table." WHERE `request_id` = ".(int)$request_id." |
|
155 | 155 | "; |
156 | 156 | |
157 | 157 | return $this->db->sql_query($sql); |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | public function approve_friend_request($request_id) |
161 | 161 | { |
162 | 162 | $sql = " |
163 | - UPDATE ". $this->friends_request_table ." SET `status` = 1 WHERE `request_id` = ". (int)$request_id ." |
|
163 | + UPDATE ". $this->friends_request_table." SET `status` = 1 WHERE `request_id` = ".(int)$request_id." |
|
164 | 164 | "; |
165 | 165 | |
166 | 166 | return $this->db->sql_query($sql); |
@@ -170,21 +170,21 @@ discard block |
||
170 | 170 | { |
171 | 171 | |
172 | 172 | $check_friend = $this->check_friend($data); |
173 | - if($check_friend == false) |
|
173 | + if ($check_friend == false) |
|
174 | 174 | { |
175 | 175 | $sql = " |
176 | - INSERT INTO ". $this->user_friends_table ." |
|
176 | + INSERT INTO ". $this->user_friends_table." |
|
177 | 177 | ( |
178 | 178 | `user_id`, |
179 | 179 | `friend_id` |
180 | 180 | ) |
181 | 181 | VALUES |
182 | 182 | ( |
183 | - ". (int)$data['user_id'] .", |
|
184 | - ". (int)$data['friend_id'] ." |
|
183 | + ". (int)$data['user_id'].", |
|
184 | + ". (int)$data['friend_id']." |
|
185 | 185 | ) |
186 | 186 | "; |
187 | - if($this->db->sql_query($sql)) |
|
187 | + if ($this->db->sql_query($sql)) |
|
188 | 188 | { |
189 | 189 | $aux = $data['user_id']; |
190 | 190 | $data['user_id'] = $data['friend_id']; |
@@ -208,13 +208,13 @@ discard block |
||
208 | 208 | { |
209 | 209 | $sql = " |
210 | 210 | SELECT COUNT(*) AS `count` |
211 | - FROM ". $this->user_friends_table ." |
|
212 | - WHERE `user_id` = ". (int)$data['user_id'] ." |
|
213 | - AND `friend_id` = ". (int)$data['friend_id'] ." |
|
211 | + FROM ". $this->user_friends_table." |
|
212 | + WHERE `user_id` = ". (int)$data['user_id']." |
|
213 | + AND `friend_id` = ". (int)$data['friend_id']." |
|
214 | 214 | "; |
215 | 215 | $this->db->sql_query($sql); |
216 | 216 | $count = $this->db->sql_fetchfield('count'); |
217 | - if($count > 0) |
|
217 | + if ($count > 0) |
|
218 | 218 | { |
219 | 219 | return true; |
220 | 220 | } |
@@ -228,15 +228,15 @@ discard block |
||
228 | 228 | { |
229 | 229 | $sql = " |
230 | 230 | SELECT COUNT(*) AS `count` |
231 | - FROM ". $this->friends_request_table ." |
|
232 | - WHERE `user_id` = ". (int)$data['user_id'] ." |
|
233 | - AND `sender_id` = ". (int)$data['sender_id'] ." |
|
231 | + FROM ". $this->friends_request_table." |
|
232 | + WHERE `user_id` = ". (int)$data['user_id']." |
|
233 | + AND `sender_id` = ". (int)$data['sender_id']." |
|
234 | 234 | AND `status` = 0 |
235 | 235 | LIMIT 1 |
236 | 236 | "; |
237 | 237 | $this->db->sql_query($sql); |
238 | 238 | $count = $this->db->sql_fetchfield('count'); |
239 | - if($count > 0) |
|
239 | + if ($count > 0) |
|
240 | 240 | { |
241 | 241 | return true; |
242 | 242 | } |
@@ -248,10 +248,10 @@ discard block |
||
248 | 248 | |
249 | 249 | public function remove_friend($user_id) |
250 | 250 | { |
251 | - $sql = "DELETE FROM ". $this->user_friends_table ." WHERE `user_id` = ". (int)$user_id .""; |
|
251 | + $sql = "DELETE FROM ".$this->user_friends_table." WHERE `user_id` = ".(int)$user_id.""; |
|
252 | 252 | $this->db->sql_query($sql); |
253 | 253 | |
254 | - $sql = "DELETE FROM ". $this->user_friends_table ." WHERE `friend_id` = ". (int)$user_id .""; |
|
254 | + $sql = "DELETE FROM ".$this->user_friends_table." WHERE `friend_id` = ".(int)$user_id.""; |
|
255 | 255 | $this->db->sql_query($sql); |
256 | 256 | } |
257 | 257 |