@@ -3,14 +3,14 @@ discard block |
||
| 3 | 3 | use Alliance\AllianceHelper; |
| 4 | 4 | use Alliance\DBStaticAlly; |
| 5 | 5 | |
| 6 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) |
|
| 6 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) |
|
| 7 | 7 | { |
| 8 | 8 | $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | $template = gettemplate('ali_info', true); |
| 12 | 12 | |
| 13 | -if($mode == 'exit') |
|
| 13 | +if ($mode == 'exit') |
|
| 14 | 14 | { |
| 15 | 15 | if ($ally['ally_owner'] == $user['id']) |
| 16 | 16 | { |
@@ -27,25 +27,25 @@ discard block |
||
| 27 | 27 | messageBox(sprintf($lang['ali_info_leave_success'], $ally['ally_name']), $lang['sys_alliance']); |
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | -elseif($mode == 'ainfo') |
|
| 30 | +elseif ($mode == 'ainfo') |
|
| 31 | 31 | { |
| 32 | 32 | $tag = sys_get_param_str('tag'); |
| 33 | 33 | $id_ally = sys_get_param_id('a'); |
| 34 | - if($tag) |
|
| 34 | + if ($tag) |
|
| 35 | 35 | { |
| 36 | 36 | $ally = doquery("SELECT * FROM {{alliance}} WHERE ally_tag='{$tag}' LIMIT 1;", '', true); |
| 37 | 37 | } |
| 38 | - elseif($id_ally) |
|
| 38 | + elseif ($id_ally) |
|
| 39 | 39 | { |
| 40 | 40 | $ally = doquery("SELECT * FROM {{alliance}} WHERE id='{$id_ally}' LIMIT 1;", '', true); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - if(!$ally) |
|
| 43 | + if (!$ally) |
|
| 44 | 44 | { |
| 45 | 45 | messageBox($lang['ali_sys_notFound'], $lang['Ally_info_1']); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - if(!$ally['ally_description']) |
|
| 48 | + if (!$ally['ally_description']) |
|
| 49 | 49 | { |
| 50 | 50 | $ally['ally_description'] = $lang['Ally_nodescription']; |
| 51 | 51 | } |
@@ -54,17 +54,17 @@ discard block |
||
| 54 | 54 | 'EXTERNAL' => true, |
| 55 | 55 | 'USER_ALLY_ID' => $user['ally_id'], |
| 56 | 56 | )); |
| 57 | - $page_header = $lang['sys_alliance']; |
|
| 57 | + $page_header = $lang['sys_alliance']; |
|
| 58 | 58 | } |
| 59 | 59 | else |
| 60 | 60 | { |
| 61 | 61 | $page_header = $lang['your_alliance']; |
| 62 | 62 | |
| 63 | - if($ally['ally_owner'] == $user['id']) |
|
| 63 | + if ($ally['ally_owner'] == $user['id']) |
|
| 64 | 64 | { |
| 65 | 65 | $range = $ally['ally_owner_range'] ? $ally['ally_owner_range'] : $lang['Founder']; |
| 66 | 66 | } |
| 67 | - elseif($user['ally_rank_id'] != 0 && isset($ranks[$user['ally_rank_id']]['name'])) |
|
| 67 | + elseif ($user['ally_rank_id'] != 0 && isset($ranks[$user['ally_rank_id']]['name'])) |
|
| 68 | 68 | { |
| 69 | 69 | $range = $ranks[$user['ally_rank_id']]['name']; |
| 70 | 70 | } |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | ]); |
| 100 | 100 | |
| 101 | 101 | $relations = ali_relations($ally['id']); |
| 102 | -foreach($relations as $relation) |
|
| 102 | +foreach ($relations as $relation) |
|
| 103 | 103 | { |
| 104 | - if($relation['alliance_diplomacy_contr_ally_id'] && $relation['alliance_diplomacy_ally_id']) |
|
| 104 | + if ($relation['alliance_diplomacy_contr_ally_id'] && $relation['alliance_diplomacy_ally_id']) |
|
| 105 | 105 | { |
| 106 | 106 | $template->assign_block_vars('relation', array( |
| 107 | 107 | 'NAME' => $relation['alliance_diplomacy_contr_ally_name'], |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | $this->sql_index_field = "{$table_name}_name"; |
| 34 | 34 | $this->sql_value_field = "{$table_name}_value"; |
| 35 | 35 | |
| 36 | - if(!$this->_DB_LOADED) { |
|
| 36 | + if (!$this->_DB_LOADED) { |
|
| 37 | 37 | $this->db_loadAll(); |
| 38 | 38 | } |
| 39 | 39 | } |
@@ -53,10 +53,10 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function db_loadItem($index) { |
| 55 | 55 | $result = null; |
| 56 | - if($index) { |
|
| 56 | + if ($index) { |
|
| 57 | 57 | $index_safe = db_escape($index); |
| 58 | 58 | $queryResult = doquery("SELECT `{$this->sql_value_field}` FROM `{{{$this->table_name}}}` WHERE `{$this->sql_index_field}` = '{$index_safe}' FOR UPDATE", true); |
| 59 | - if(is_array($queryResult) && !empty($queryResult)) { |
|
| 59 | + if (is_array($queryResult) && !empty($queryResult)) { |
|
| 60 | 60 | $this->$index = $result = $queryResult[$this->sql_value_field]; |
| 61 | 61 | } |
| 62 | 62 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | $this->loadDefaults(); |
| 69 | 69 | |
| 70 | 70 | $query = doquery("SELECT * FROM {{{$this->table_name}}} FOR UPDATE;"); |
| 71 | - while($row = db_fetch($query)) { |
|
| 71 | + while ($row = db_fetch($query)) { |
|
| 72 | 72 | $this[$row[$this->sql_index_field]] = $row[$this->sql_value_field]; |
| 73 | 73 | } |
| 74 | 74 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | public function loadDefaults() { |
| 79 | - foreach($this->defaults as $defName => $defValue) { |
|
| 79 | + foreach ($this->defaults as $defName => $defValue) { |
|
| 80 | 80 | $this->$defName = $defValue; |
| 81 | 81 | } |
| 82 | 82 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | public function db_saveItem($item_list, $value = NULL) { |
| 89 | - if(empty($item_list)) { |
|
| 89 | + if (empty($item_list)) { |
|
| 90 | 90 | return; |
| 91 | 91 | } |
| 92 | 92 | |
@@ -94,8 +94,8 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | // Сначала записываем данные в базу - что бы поймать все блокировки |
| 96 | 96 | $qry = array(); |
| 97 | - foreach($item_list as $item_name => $item_value) { |
|
| 98 | - if($item_name) { |
|
| 97 | + foreach ($item_list as $item_name => $item_value) { |
|
| 98 | + if ($item_name) { |
|
| 99 | 99 | $item_value = db_escape($item_value === NULL ? $this->$item_name : $item_value); |
| 100 | 100 | $item_name = db_escape($item_name); |
| 101 | 101 | $qry[] = "('{$item_name}', '{$item_value}')"; |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | doquery("REPLACE INTO `{{" . $this->table_name . "}}` (`{$this->sql_index_field}`, `{$this->sql_value_field}`) VALUES " . implode(',', $qry) . ";"); |
| 105 | 105 | |
| 106 | 106 | // И только после взятия блокировок - меняем значения в кэше |
| 107 | - foreach($item_list as $item_name => $item_value) { |
|
| 108 | - if($item_name && $item_value !== null) { |
|
| 107 | + foreach ($item_list as $item_name => $item_value) { |
|
| 108 | + if ($item_name && $item_value !== null) { |
|
| 109 | 109 | $this->__set($item_name, $item_value); |
| 110 | 110 | } |
| 111 | 111 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | public function __get($name) { |
| 136 | - if($this->force) { |
|
| 136 | + if ($this->force) { |
|
| 137 | 137 | $this->force = false; |
| 138 | 138 | $this->db_loadItem($name); |
| 139 | 139 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | public function __set($name, $value) { |
| 145 | - if($this->force) { |
|
| 145 | + if ($this->force) { |
|
| 146 | 146 | $this->force = false; |
| 147 | 147 | $this->db_saveItem($name, $value); |
| 148 | 148 | } |
@@ -173,9 +173,9 @@ |
||
| 173 | 173 | */ |
| 174 | 174 | public function isChanged() { |
| 175 | 175 | return |
| 176 | - ! empty($this->_changes) |
|
| 176 | + !empty($this->_changes) |
|
| 177 | 177 | || |
| 178 | - ! empty($this->_deltas); |
|
| 178 | + !empty($this->_deltas); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | public function getChanges() { |