@@ -63,6 +63,10 @@ |
||
63 | 63 | */ |
64 | 64 | protected $accessors = array(); |
65 | 65 | |
66 | + /** |
|
67 | + * @param string $varName |
|
68 | + * @param string $type |
|
69 | + */ |
|
66 | 70 | protected function assignAccessor($varName, $type, $callable) { |
67 | 71 | if (empty($callable)) { |
68 | 72 | return; |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | * @property int|float|string $dbId EntityModel unique ID for entire entities' set |
9 | 9 | */ |
10 | -class EntityModel { |
|
10 | +class EntityModel { |
|
11 | 11 | /** |
12 | 12 | * Link to DB which used by this EntityModel |
13 | 13 | * |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | if (is_callable($callable)) { |
72 | 72 | $this->accessors[$varName][$type] = $callable; |
73 | 73 | } else { |
74 | - throw new \Exception('Error assigning callable in ' . get_called_class() . '! Callable typed [' . $type . '] is not a callable or not accessible in the scope'); |
|
74 | + throw new \Exception('Error assigning callable in '.get_called_class().'! Callable typed ['.$type.'] is not a callable or not accessible in the scope'); |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 |
@@ -34,56 +34,56 @@ |
||
34 | 34 | $gc = $this; |
35 | 35 | |
36 | 36 | // Default db |
37 | - $gc->db = function ($c) { |
|
37 | + $gc->db = function($c) { |
|
38 | 38 | classSupernova::$db = $db = new \db_mysql($c); |
39 | 39 | $db->sn_db_connect(); |
40 | 40 | |
41 | 41 | return $db; |
42 | 42 | }; |
43 | 43 | |
44 | - $gc->debug = function ($c) { |
|
44 | + $gc->debug = function($c) { |
|
45 | 45 | return new \debug(); |
46 | 46 | }; |
47 | 47 | |
48 | - $gc->types = function ($c) { |
|
48 | + $gc->types = function($c) { |
|
49 | 49 | return new \Common\Types(); |
50 | 50 | }; |
51 | 51 | |
52 | - $gc->cache = function ($c) { |
|
52 | + $gc->cache = function($c) { |
|
53 | 53 | return new \classCache(classSupernova::$cache_prefix); |
54 | 54 | }; |
55 | 55 | |
56 | - $gc->config = function ($c) { |
|
56 | + $gc->config = function($c) { |
|
57 | 57 | return new \classConfig(classSupernova::$cache_prefix); |
58 | 58 | }; |
59 | 59 | |
60 | - $gc->localePlayer = function (GlobalContainer $c) { |
|
60 | + $gc->localePlayer = function(GlobalContainer $c) { |
|
61 | 61 | return new \classLocale($c->config->server_locale_log_usage); |
62 | 62 | }; |
63 | 63 | |
64 | - $gc->dbRowOperator = function ($c) { |
|
64 | + $gc->dbRowOperator = function($c) { |
|
65 | 65 | return new \DbRowDirectOperator($c); |
66 | 66 | }; |
67 | 67 | |
68 | - $gc->query = $gc->factory(function (GlobalContainer $c) { |
|
68 | + $gc->query = $gc->factory(function(GlobalContainer $c) { |
|
69 | 69 | return new \DbQueryConstructor($c->db); |
70 | 70 | }); |
71 | 71 | |
72 | - $gc->cacheOperator = function (GlobalContainer $gc) { |
|
72 | + $gc->cacheOperator = function(GlobalContainer $gc) { |
|
73 | 73 | return new \SnDbCachedOperator($gc); |
74 | 74 | }; |
75 | 75 | |
76 | 76 | $gc->snCacheClass = 'SnCache'; |
77 | - $gc->snCache = function (GlobalContainer $gc) { |
|
77 | + $gc->snCache = function(GlobalContainer $gc) { |
|
78 | 78 | return $gc->db->snCache; |
79 | 79 | }; |
80 | 80 | |
81 | 81 | $gc->buddyClass = 'Buddy\BuddyModel'; |
82 | - $gc->buddyModel = function (GlobalContainer $c) { |
|
82 | + $gc->buddyModel = function(GlobalContainer $c) { |
|
83 | 83 | return new $c->buddyClass($c); |
84 | 84 | }; |
85 | 85 | |
86 | - $gc->unitModel = function (GlobalContainer $c) { |
|
86 | + $gc->unitModel = function(GlobalContainer $c) { |
|
87 | 87 | return new \V2Unit\V2UnitModel($c); |
88 | 88 | }; |
89 | 89 | } |
@@ -36,14 +36,14 @@ |
||
36 | 36 | |
37 | 37 | $this->playerArray = $user; |
38 | 38 | |
39 | - $this->playerId = function (BuddyParams $cBuddy) { |
|
39 | + $this->playerId = function(BuddyParams $cBuddy) { |
|
40 | 40 | return $cBuddy->playerArray['id']; |
41 | 41 | }; |
42 | - $this->playerName = function (BuddyParams $cBuddy) { |
|
42 | + $this->playerName = function(BuddyParams $cBuddy) { |
|
43 | 43 | return $cBuddy->playerArray['username']; |
44 | 44 | }; |
45 | - $this->playerNameAndCoordinates = function (BuddyParams $cBuddy) { |
|
46 | - return "{$cBuddy->playerArray['username']} " . uni_render_coordinates($cBuddy->playerArray); |
|
45 | + $this->playerNameAndCoordinates = function(BuddyParams $cBuddy) { |
|
46 | + return "{$cBuddy->playerArray['username']} ".uni_render_coordinates($cBuddy->playerArray); |
|
47 | 47 | }; |
48 | 48 | } |
49 | 49 |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | sys_user_options_unpack($owner_row); |
114 | 114 | |
115 | 115 | if ($force || !$message_class['switchable'] || $owner_row["opt_{$message_class_name}"]) { |
116 | - $insert_values[] = "('" . idval($owner) . "', '{$sender}', '{$timestamp}', '{$message_type}', '" . db_escape($from_unsafe) . "', '" . db_escape($subject_unsafe) . "', '" . db_escape($text_unsafe) . "')"; |
|
116 | + $insert_values[] = "('".idval($owner)."', '{$sender}', '{$timestamp}', '{$message_type}', '".db_escape($from_unsafe)."', '".db_escape($subject_unsafe)."', '".db_escape($text_unsafe)."')"; |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | // TODO - allow sending HTML email only from admin |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | array(), |
154 | 154 | array( |
155 | 155 | // TODO DANGER |
156 | - '`id` IN (' . implode(',', $owners) . ')', |
|
156 | + '`id` IN ('.implode(',', $owners).')', |
|
157 | 157 | ) |
158 | 158 | ); |
159 | 159 | } |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | $sendList = array(); |
173 | 173 | $list = ''; |
174 | 174 | $query = DBStaticUser::db_user_list( |
175 | - "ally_id = '{$ally_id}'" . ($ally_rank_id >= 0 ? " AND ally_rank_id = {$ally_rank_id}" : ''), |
|
175 | + "ally_id = '{$ally_id}'".($ally_rank_id >= 0 ? " AND ally_rank_id = {$ally_rank_id}" : ''), |
|
176 | 176 | false, 'id, username'); |
177 | 177 | foreach ($query as $u) { |
178 | 178 | $sendList[] = $u['id']; |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | $subject_unsafe = substr($subject_unsafe, strlen(classLocale::$lang['msg_answer_prefix'])); |
262 | 262 | $re++; |
263 | 263 | } |
264 | - $re ? $subject_unsafe = classLocale::$lang['msg_answer_prefix'] . $subject_unsafe : false; |
|
264 | + $re ? $subject_unsafe = classLocale::$lang['msg_answer_prefix'].$subject_unsafe : false; |
|
265 | 265 | |
266 | 266 | $subject_unsafe = $subject_unsafe ? $subject_unsafe : classLocale::$lang['msg_subject_default']; |
267 | 267 | |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | return classSupernova::$db->doSelect( |
438 | 438 | "SELECT * FROM {{messages}} |
439 | 439 | WHERE |
440 | - `message_type` = '" . MSG_TYPE_PLAYER . "' AND |
|
440 | + `message_type` = '" . MSG_TYPE_PLAYER."' AND |
|
441 | 441 | ((`message_owner` = '{$user['id']}' AND `message_sender` = '{$recipient_id}') |
442 | 442 | OR |
443 | 443 | (`message_sender` = '{$user['id']}' AND `message_owner` = '{$recipient_id}')) ORDER BY `message_time` DESC LIMIT 20;"); |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | FROM |
482 | 482 | {{messages}} AS m |
483 | 483 | LEFT JOIN {{users}} AS u ON u.id = m.message_owner " . |
484 | - ($int_type_selected >= 0 ? "WHERE `message_type` = {$int_type_selected} " : '') . |
|
484 | + ($int_type_selected >= 0 ? "WHERE `message_type` = {$int_type_selected} " : ''). |
|
485 | 485 | "ORDER BY |
486 | 486 | `message_id` DESC |
487 | 487 | LIMIT |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | $subject_safe = db_escape($subject_unsafe); |
495 | 495 | $text_safe = db_escape($text_unsafe); |
496 | 496 | |
497 | - return classSupernova::$db->doInsertComplex('INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) ' . |
|
497 | + return classSupernova::$db->doInsertComplex('INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) '. |
|
498 | 498 | "SELECT `id`, 0, unix_timestamp(now()), {$message_type_safe}, '{$from_safe}', '{$subject_safe}', '{$text_safe}' FROM {{users}}"); |
499 | 499 | } |
500 | 500 | |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | * @return array|bool|mysqli_result|null |
505 | 505 | */ |
506 | 506 | public static function db_message_count_by_type($int_type_selected) { |
507 | - $page_max = classSupernova::$db->doSelectFetch('SELECT COUNT(*) AS `max` FROM `{{messages}}`' . ($int_type_selected >= 0 ? " WHERE `message_type` = {$int_type_selected};" : '')); |
|
507 | + $page_max = classSupernova::$db->doSelectFetch('SELECT COUNT(*) AS `max` FROM `{{messages}}`'.($int_type_selected >= 0 ? " WHERE `message_type` = {$int_type_selected};" : '')); |
|
508 | 508 | |
509 | 509 | return $page_max; |
510 | 510 | } |