Completed
Push — work-fleets ( f6000a...17041b )
by SuperNova.WS
05:43
created
includes/classes/DBStaticPlanet.php 2 patches
Doc Comments   +14 added lines patch added patch discarded remove patch
@@ -21,11 +21,19 @@  discard block
 block discarded – undo
21 21
     return empty($result) ? null : $result;
22 22
   }
23 23
 
24
+  /**
25
+   * @param integer $galaxy
26
+   * @param integer $system
27
+   * @param integer $planet
28
+   */
24 29
   public static function db_planet_by_gspt_safe($galaxy, $system, $planet, $planet_type, $for_update = false, $fields = '*') {
25 30
     return classSupernova::db_get_record_list(LOC_PLANET,
26 31
       "{{planets}}.`galaxy` = {$galaxy} AND {{planets}}.`system` = {$system} AND {{planets}}.`planet` = {$planet} AND {{planets}}.`planet_type` = {$planet_type}", true);
27 32
   }
28 33
 
34
+  /**
35
+   * @param integer $planet_type
36
+   */
29 37
   public static function db_planet_by_gspt($galaxy, $system, $planet, $planet_type, $for_update = false, $fields = '*') {
30 38
     $galaxy = intval($galaxy);
31 39
     $system = intval($system);
@@ -120,6 +128,9 @@  discard block
 block discarded – undo
120 128
       "`id_owner` = '{$user_row['id']}' {$conditions} ORDER BY {$order_by}");
121 129
   }
122 130
 
131
+  /**
132
+   * @param integer $planet_id
133
+   */
123 134
   public static function db_planet_list_by_user_or_planet($user_id, $planet_id) {
124 135
     if(!($user_id = idval($user_id)) && !($planet_id = idval($planet_id))) {
125 136
       return false;
@@ -138,6 +149,9 @@  discard block
 block discarded – undo
138 149
     return classSupernova::db_upd_record_by_id(LOC_PLANET, $planet_id, $set);
139 150
   }
140 151
 
152
+  /**
153
+   * @param integer $ui_planet_type
154
+   */
141 155
   public static function db_planet_set_by_gspt($ui_galaxy, $ui_system, $ui_planet, $ui_planet_type = PT_ALL, $set) {
142 156
     if(!($set = trim($set))) {
143 157
       return false;
Please login to merge, or discard this patch.
Spacing   +20 added lines, -21 removed lines patch added patch discarded remove patch
@@ -36,11 +36,10 @@  discard block
 block discarded – undo
36 36
   }
37 37
 
38 38
   public static function db_planet_by_vector($vector, $prefix = '', $for_update = false, $fields = '*') {
39
-    $galaxy = isset($vector[$prefix . 'galaxy']) ? intval($vector[$prefix . 'galaxy']) : 0;
40
-    $system = isset($vector[$prefix . 'system']) ? intval($vector[$prefix . 'system']) : 0;
41
-    $planet = isset($vector[$prefix . 'planet']) ? intval($vector[$prefix . 'planet']) : 0;
42
-    $planet_type = isset($vector[$prefix . 'planet_type']) ? intval($vector[$prefix . 'planet_type']) :
43
-      (isset($vector[$prefix . 'type']) ? intval($vector[$prefix . 'type']) : 0);
39
+    $galaxy = isset($vector[$prefix.'galaxy']) ? intval($vector[$prefix.'galaxy']) : 0;
40
+    $system = isset($vector[$prefix.'system']) ? intval($vector[$prefix.'system']) : 0;
41
+    $planet = isset($vector[$prefix.'planet']) ? intval($vector[$prefix.'planet']) : 0;
42
+    $planet_type = isset($vector[$prefix.'planet_type']) ? intval($vector[$prefix.'planet_type']) : (isset($vector[$prefix.'type']) ? intval($vector[$prefix.'type']) : 0);
44 43
     $planet_type = $planet_type == PT_DEBRIS ? PT_PLANET : $planet_type;
45 44
 
46 45
     return DBStaticPlanet::db_planet_by_gspt_safe($galaxy, $system, $planet, $planet_type, $for_update, $fields);
@@ -61,17 +60,17 @@  discard block
 block discarded – undo
61 60
   }
62 61
 
63 62
   public static function db_planet_by_parent($parent_id, $for_update = false, $fields = '*') {
64
-    if(!($parent_id = idval($parent_id))) {
63
+    if (!($parent_id = idval($parent_id))) {
65 64
       return false;
66 65
     }
67 66
 
68 67
     return classSupernova::db_get_record_list(LOC_PLANET,
69
-      "`parent_planet` = {$parent_id} AND `planet_type` = " . PT_MOON, true);
68
+      "`parent_planet` = {$parent_id} AND `planet_type` = ".PT_MOON, true);
70 69
   }
71 70
 
72 71
   public static function db_planet_by_id_and_owner($planet_id, $owner_id, $for_update = false, $fields = '*') {
73 72
     //if(!($planet_id = intval($planet_id)) || !($owner_id = intval($owner_id))) return false;
74
-    if(!($planet_id = idval($planet_id)) || !($owner_id = idval($owner_id))) {
73
+    if (!($planet_id = idval($planet_id)) || !($owner_id = idval($owner_id))) {
75 74
       return false;
76 75
     }
77 76
 
@@ -82,12 +81,12 @@  discard block
 block discarded – undo
82 81
 
83 82
   public static function db_planet_list_moon_other($user_id, $this_moon_id) {
84 83
     // if(!($user_id = intval($user_id)) || !($this_moon_id = intval($this_moon_id))) return false;
85
-    if(!($user_id = idval($user_id)) || !($this_moon_id = idval($this_moon_id))) {
84
+    if (!($user_id = idval($user_id)) || !($this_moon_id = idval($this_moon_id))) {
86 85
       return false;
87 86
     }
88 87
 
89 88
     return classSupernova::db_get_record_list(LOC_PLANET,
90
-      "`planet_type` = " . PT_MOON . " AND `id_owner` = {$user_id} AND `id` != {$this_moon_id}");
89
+      "`planet_type` = ".PT_MOON." AND `id_owner` = {$user_id} AND `id` != {$this_moon_id}");
91 90
   }
92 91
 
93 92
   public static function db_planet_list_in_system($galaxy, $system) {
@@ -99,7 +98,7 @@  discard block
 block discarded – undo
99 98
   }
100 99
 
101 100
   public static function db_planet_list_sorted($user_row, $skip_planet_id = false, $field_list = '', $conditions = '') {
102
-    if(!is_array($user_row)) {
101
+    if (!is_array($user_row)) {
103 102
       return false;
104 103
     }
105 104
     // $field_list = $field_list != '*' ? "{{planets}}.`id`, `name`, `image`, {{planets}}.`galaxy`, {{planets}}.`system`, {{planets}}.`planet`, `planet_type`{$field_list}" : $field_list;
@@ -113,7 +112,7 @@  discard block
 block discarded – undo
113 112
     );
114 113
     $order_by = classSupernova::$user_options[PLAYER_OPTION_PLANET_SORT];
115 114
     empty($sort_orders[$order_by]) ? $order_by = SORT_ID : false;
116
-    $order_by = $sort_orders[$order_by] . ' ' . (classSupernova::$user_options[PLAYER_OPTION_PLANET_SORT_INVERSE] == SORT_ASCENDING ? 'ASC' : 'DESC');
115
+    $order_by = $sort_orders[$order_by].' '.(classSupernova::$user_options[PLAYER_OPTION_PLANET_SORT_INVERSE] == SORT_ASCENDING ? 'ASC' : 'DESC');
117 116
 
118 117
     // Compilating query
119 118
     return classSupernova::db_get_record_list(LOC_PLANET,
@@ -121,7 +120,7 @@  discard block
 block discarded – undo
121 120
   }
122 121
 
123 122
   public static function db_planet_list_by_user_or_planet($user_id, $planet_id) {
124
-    if(!($user_id = idval($user_id)) && !($planet_id = idval($planet_id))) {
123
+    if (!($user_id = idval($user_id)) && !($planet_id = idval($planet_id))) {
125 124
       return false;
126 125
     }
127 126
 
@@ -131,7 +130,7 @@  discard block
 block discarded – undo
131 130
 
132 131
   public static function db_planet_set_by_id($planet_id, $set) {
133 132
     // if(!($planet_id = intval($planet_id))) return false;
134
-    if(!($planet_id = idval($planet_id))) {
133
+    if (!($planet_id = idval($planet_id))) {
135 134
       return false;
136 135
     }
137 136
 
@@ -139,7 +138,7 @@  discard block
 block discarded – undo
139 138
   }
140 139
 
141 140
   public static function db_planet_set_by_gspt($ui_galaxy, $ui_system, $ui_planet, $ui_planet_type = PT_ALL, $set) {
142
-    if(!($set = trim($set))) {
141
+    if (!($set = trim($set))) {
143 142
       return false;
144 143
     }
145 144
 
@@ -153,7 +152,7 @@  discard block
 block discarded – undo
153 152
 
154 153
   public static function db_planet_set_by_parent($ui_parent_id, $ss_set) {
155 154
     //if(!($si_parent_id = intval($ui_parent_id)) || !($ss_set = trim($ss_set))) return false;
156
-    if(!($si_parent_id = idval($ui_parent_id)) || !($ss_set = trim($ss_set))) {
155
+    if (!($si_parent_id = idval($ui_parent_id)) || !($ss_set = trim($ss_set))) {
157 156
       return false;
158 157
     }
159 158
 
@@ -162,7 +161,7 @@  discard block
 block discarded – undo
162 161
 
163 162
   public static function db_planet_set_by_owner($ui_owner_id, $ss_set) {
164 163
     //if(!($si_owner_id = intval($ui_owner_id)) || !($ss_set = trim($ss_set))) return false;
165
-    if(!($si_owner_id = idval($ui_owner_id)) || !($ss_set = trim($ss_set))) {
164
+    if (!($si_owner_id = idval($ui_owner_id)) || !($ss_set = trim($ss_set))) {
166 165
       return false;
167 166
     }
168 167
 
@@ -172,11 +171,11 @@  discard block
 block discarded – undo
172 171
 
173 172
   public static function db_planet_delete_by_id($planet_id) {
174 173
     // if(!($planet_id = intval($planet_id))) return false;
175
-    if(!($planet_id = idval($planet_id))) {
174
+    if (!($planet_id = idval($planet_id))) {
176 175
       return false;
177 176
     }
178 177
     classSupernova::db_del_record_by_id(LOC_PLANET, $planet_id);
179
-    classSupernova::db_del_record_list(LOC_UNIT, "`unit_location_type` = " . LOC_PLANET . " AND `unit_location_id` = " . $planet_id);
178
+    classSupernova::db_del_record_list(LOC_UNIT, "`unit_location_type` = ".LOC_PLANET." AND `unit_location_id` = ".$planet_id);
180 179
 
181 180
     // Очереди очистятся автоматически по FOREIGN KEY
182 181
     return true;
@@ -184,11 +183,11 @@  discard block
 block discarded – undo
184 183
 
185 184
   public static function db_planet_list_delete_by_owner($ui_owner_id) {
186 185
     // if(!($si_owner_id = intval($ui_owner_id))) return false;
187
-    if(!($si_owner_id = idval($ui_owner_id))) {
186
+    if (!($si_owner_id = idval($ui_owner_id))) {
188 187
       return false;
189 188
     }
190 189
     classSupernova::db_del_record_list(LOC_PLANET, "`id_owner` = {$si_owner_id}");
191
-    classSupernova::db_del_record_list(LOC_UNIT, "`unit_location_type` = " . LOC_PLANET . " AND `unit_player_id` = " . $si_owner_id);
190
+    classSupernova::db_del_record_list(LOC_UNIT, "`unit_location_type` = ".LOC_PLANET." AND `unit_player_id` = ".$si_owner_id);
192 191
 
193 192
     // Очереди очистятся автоматически по FOREIGN KEY
194 193
     return true;
Please login to merge, or discard this patch.
includes/classes/DBStaticUnit.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -56,6 +56,9 @@  discard block
 block discarded – undo
56 56
     WHERE unit_player_id = {$user_id} AND unit_location_type = " . LOC_PLANET . " AND unit_level > 0 AND unit_snid IN (" . STRUC_LABORATORY . ", " . STRUC_LABORATORY_NANO . ");");
57 57
   }
58 58
 
59
+  /**
60
+   * @param string $set
61
+   */
59 62
   public static function db_unit_set_by_id($unit_id, $set) {
60 63
     return classSupernova::db_upd_record_by_id(LOC_UNIT, $unit_id, $set);
61 64
   }
@@ -69,6 +72,9 @@  discard block
 block discarded – undo
69 72
     return classSupernova::db_ins_record(LOC_UNIT, $set);
70 73
   }
71 74
 
75
+  /**
76
+   * @param integer $unit_location_type
77
+   */
72 78
   public static function db_unit_list_delete($user_id = 0, $unit_location_type, $unit_location_id, $unit_snid = 0) {
73 79
     return classSupernova::db_del_record_list(LOC_UNIT,
74 80
       "`unit_location_type` = {$unit_location_type} AND `unit_location_id` = {$unit_location_id}" .
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -21,13 +21,13 @@  discard block
 block discarded – undo
21 21
 
22 22
   public static function db_unit_count_by_user_and_type_and_snid($user_id, $unit_type = 0, $unit_snid = 0) {
23 23
     $query = doquery(
24
-      "SELECT unit_snid, sum(unit_level) as `qty`  FROM {{unit}} WHERE `unit_player_id` = {$user_id} " .
25
-      ($unit_type ? "AND `unit_type` = {$unit_type} " : '') .
26
-      ($unit_snid ? "AND `unit_snid` = {$unit_snid} " : '') .
24
+      "SELECT unit_snid, sum(unit_level) as `qty`  FROM {{unit}} WHERE `unit_player_id` = {$user_id} ".
25
+      ($unit_type ? "AND `unit_type` = {$unit_type} " : '').
26
+      ($unit_snid ? "AND `unit_snid` = {$unit_snid} " : '').
27 27
       'GROUP BY `unit_snid`'
28 28
     );
29 29
     $result = array();
30
-    while($row = db_fetch($query)) {
30
+    while ($row = db_fetch($query)) {
31 31
       $result[$row['unit_snid']] = $row;
32 32
     }
33 33
 
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
     WHERE
44 44
       f.fleet_owner = {$user_id} AND
45 45
       (f.fleet_start_planet_id = {$location_id} OR f.fleet_end_planet_id = {$location_id})
46
-      AND u.unit_snid = {$unit_snid} AND u.`unit_location_type` = " . LOC_FLEET . " AND " . self::db_unit_time_restrictions() .
47
-      " LIMIT 1" .
46
+      AND u.unit_snid = {$unit_snid} AND u.`unit_location_type` = ".LOC_FLEET." AND ".self::db_unit_time_restrictions().
47
+      " LIMIT 1".
48 48
       ($for_update ? ' FOR UPDATE' : '')
49 49
       , true);
50 50
   }
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
   public static function db_unit_list_laboratories($user_id) {
54 54
     return doquery("SELECT DISTINCT unit_location_id AS `id`
55 55
     FROM {{unit}}
56
-    WHERE unit_player_id = {$user_id} AND unit_location_type = " . LOC_PLANET . " AND unit_level > 0 AND unit_snid IN (" . STRUC_LABORATORY . ", " . STRUC_LABORATORY_NANO . ");");
56
+    WHERE unit_player_id = {$user_id} AND unit_location_type = ".LOC_PLANET." AND unit_level > 0 AND unit_snid IN (".STRUC_LABORATORY.", ".STRUC_LABORATORY_NANO.");");
57 57
   }
58 58
 
59 59
   public static function db_unit_set_by_id($unit_id, $set) {
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 
72 72
   public static function db_unit_list_delete($user_id = 0, $unit_location_type, $unit_location_id, $unit_snid = 0) {
73 73
     return classSupernova::db_del_record_list(LOC_UNIT,
74
-      "`unit_location_type` = {$unit_location_type} AND `unit_location_id` = {$unit_location_id}" .
75
-      ($user_id = idval($user_id) ? " AND `unit_player_id` = {$user_id}" : '') .
74
+      "`unit_location_type` = {$unit_location_type} AND `unit_location_id` = {$unit_location_id}".
75
+      ($user_id = idval($user_id) ? " AND `unit_player_id` = {$user_id}" : '').
76 76
       ($unit_snid = idval($unit_snid) ? " AND `unit_snid` = {$unit_snid}" : ''));
77 77
   }
78 78
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
     return doquery(
81 81
       "SELECT unit_player_id, unit_type, unit_snid, unit_level, count(*) AS unit_amount
82 82
     FROM `{{unit}}`
83
-    WHERE unit_level > 0 AND " . self::db_unit_time_restrictions() .
83
+    WHERE unit_level > 0 AND " . self::db_unit_time_restrictions().
84 84
       " GROUP BY unit_player_id, unit_type, unit_snid, unit_level"
85 85
     );
86 86
   }
@@ -92,15 +92,15 @@  discard block
 block discarded – undo
92 92
 
93 93
 
94 94
   public static function db_unit_list_admin_delete_mercenaries_finished() {
95
-    return doquery("DELETE FROM {{unit}} WHERE unit_time_finish IS NOT NULL AND unit_time_finish < FROM_UNIXTIME(" . SN_TIME_NOW . ") AND unit_type = " . UNIT_MERCENARIES);
95
+    return doquery("DELETE FROM {{unit}} WHERE unit_time_finish IS NOT NULL AND unit_time_finish < FROM_UNIXTIME(".SN_TIME_NOW.") AND unit_type = ".UNIT_MERCENARIES);
96 96
   }
97 97
 
98 98
   public static function db_unit_list_admin_set_mercenaries_expire_time($default_length) {
99 99
     return doquery(
100 100
       "UPDATE {{unit}}
101 101
     SET
102
-      unit_time_start = FROM_UNIXTIME(" . SN_TIME_NOW . "),
103
-      unit_time_finish = FROM_UNIXTIME(" . (SN_TIME_NOW + $default_length) . ")
102
+      unit_time_start = FROM_UNIXTIME(" . SN_TIME_NOW."),
103
+      unit_time_finish = FROM_UNIXTIME(" . (SN_TIME_NOW + $default_length).")
104 104
     WHERE unit_type = " . UNIT_MERCENARIES
105 105
     );
106 106
   }
Please login to merge, or discard this patch.