@@ -17,34 +17,34 @@ discard block |
||
17 | 17 | $template = SnTemplate::gettemplate('notes', true); |
18 | 18 | |
19 | 19 | $result = array(); |
20 | -if(($result_message = sys_get_param_str('MESSAGE')) && isset($lang[$result_message])) { |
|
20 | +if (($result_message = sys_get_param_str('MESSAGE')) && isset($lang[$result_message])) { |
|
21 | 21 | $result[] = array('STATUS' => sys_get_param_int('STATUS'), 'MESSAGE' => $lang[$result_message]); |
22 | 22 | } |
23 | 23 | |
24 | 24 | $note_id_edit = sys_get_param_id('note_id_edit'); |
25 | -if(sys_get_param('note_delete')) { |
|
25 | +if (sys_get_param('note_delete')) { |
|
26 | 26 | try { |
27 | 27 | $not = ''; |
28 | 28 | $query_where = ''; |
29 | - switch(sys_get_param_str('note_delete_range')) { |
|
29 | + switch (sys_get_param_str('note_delete_range')) { |
|
30 | 30 | case 'all': |
31 | 31 | break; |
32 | 32 | |
33 | 33 | case 'marked_not': |
34 | 34 | $not = 'NOT'; |
35 | 35 | case 'marked': |
36 | - if(!is_array($notes_marked = sys_get_param('note'))) { |
|
36 | + if (!is_array($notes_marked = sys_get_param('note'))) { |
|
37 | 37 | throw new exception('note_err_none_selected', ERR_WARNING); |
38 | 38 | } |
39 | 39 | |
40 | 40 | $notes_marked_filtered = array(); |
41 | - foreach($notes_marked as $note_id => $note_select) { |
|
42 | - if($note_select == 'on' && $note_id = idval($note_id)) { |
|
41 | + foreach ($notes_marked as $note_id => $note_select) { |
|
42 | + if ($note_select == 'on' && $note_id = idval($note_id)) { |
|
43 | 43 | $notes_marked_filtered[] = $note_id; |
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
47 | - if(empty($notes_marked_filtered)) { |
|
47 | + if (empty($notes_marked_filtered)) { |
|
48 | 48 | throw new exception('note_err_none_selected', ERR_WARNING); |
49 | 49 | } |
50 | 50 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | doquery("DELETE FROM {{notes}} WHERE `owner` = {$user['id']} {$query_where};"); |
62 | 62 | db_mysql::db_transaction_commit(); |
63 | 63 | throw new exception($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added', ERR_NONE); |
64 | - } catch(exception $e) { |
|
64 | + } catch (exception $e) { |
|
65 | 65 | $note_id_edit = 0; |
66 | 66 | db_mysql::db_transaction_rollback(); |
67 | 67 | $result[] = array( |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | 'MESSAGE' => $lang[$e->getMessage()], |
70 | 70 | ); |
71 | 71 | } |
72 | -} elseif(($note_title = sys_get_param_str('note_title')) || ($note_text = sys_get_param_str('note_text'))) { |
|
72 | +} elseif (($note_title = sys_get_param_str('note_title')) || ($note_text = sys_get_param_str('note_text'))) { |
|
73 | 73 | $note_title == SN::$db->db_escape($lang['note_new_title']) ? $note_title = '' : false; |
74 | 74 | ($note_text = sys_get_param_str('note_text')) == SN::$db->db_escape($lang['note_new_text']) ? $note_text = '' : false; |
75 | 75 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | $note_system = max(0, min(sys_get_param_id('note_system'), SN::$config->game_maxSystem)); |
79 | 79 | $note_planet = max(0, min(sys_get_param_id('note_planet'), SN::$config->game_maxPlanet + 1)); |
80 | 80 | |
81 | - if(!$note_text && !$note_title && !$note_galaxy && !$note_system && !$note_planet) { |
|
81 | + if (!$note_text && !$note_title && !$note_galaxy && !$note_system && !$note_planet) { |
|
82 | 82 | throw new exception('note_err_note_empty', ERR_WARNING); |
83 | 83 | } |
84 | 84 | |
@@ -87,15 +87,15 @@ discard block |
||
87 | 87 | $note_sticky = intval(sys_get_param_id('note_sticky')) ? 1 : 0; |
88 | 88 | |
89 | 89 | db_mysql::db_transaction_start(); |
90 | - if($note_id_edit) { |
|
90 | + if ($note_id_edit) { |
|
91 | 91 | $check_note_id = doquery("SELECT `id`, `owner` FROM {{notes}} WHERE `id` = {$note_id_edit} LIMIT 1 FOR UPDATE", true); |
92 | - if(!$check_note_id) { |
|
92 | + if (!$check_note_id) { |
|
93 | 93 | throw new exception('note_err_note_not_found', ERR_ERROR); |
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
97 | - if($note_id_edit) { |
|
98 | - if($check_note_id['owner'] != $user['id']) { |
|
97 | + if ($note_id_edit) { |
|
98 | + if ($check_note_id['owner'] != $user['id']) { |
|
99 | 99 | throw new exception('note_err_owner_wrong', ERR_ERROR); |
100 | 100 | } |
101 | 101 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | db_mysql::db_transaction_commit(); |
111 | 111 | sys_redirect('notes.php?STATUS=' . ERR_NONE . '&MESSAGE=' . ($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added')); |
112 | 112 | // throw new exception($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added', ERR_NONE); |
113 | - } catch(exception $e) { |
|
113 | + } catch (exception $e) { |
|
114 | 114 | $note_id_edit = 0; |
115 | 115 | db_mysql::db_transaction_rollback(); |
116 | 116 | $result[] = array( |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | } |
121 | 121 | } |
122 | 122 | |
123 | -if(!$note_id_edit) { |
|
123 | +if (!$note_id_edit) { |
|
124 | 124 | \Note\Note::note_assign($template, array( |
125 | 125 | 'id' => 0, |
126 | 126 | 'time' => SN_TIME_NOW, |
@@ -133,13 +133,13 @@ discard block |
||
133 | 133 | |
134 | 134 | $note_exist = false; |
135 | 135 | $notes_query = doquery("SELECT * FROM {{notes}} WHERE owner={$user['id']} ORDER BY priority DESC, galaxy ASC, system ASC, planet ASC, planet_type ASC, `time` DESC"); |
136 | -while($note_row = db_fetch($notes_query)) { |
|
136 | +while ($note_row = db_fetch($notes_query)) { |
|
137 | 137 | \Note\Note::note_assign($template, $note_row); |
138 | 138 | $note_exist = $note_exist || $note_row['id'] == $note_id_edit; |
139 | 139 | } |
140 | 140 | $note_id_edit = $note_exist ? $note_id_edit : 0; |
141 | 141 | |
142 | -foreach($note_priority_classes as $note_priority_id => $note_priority_class) { |
|
142 | +foreach ($note_priority_classes as $note_priority_id => $note_priority_class) { |
|
143 | 143 | $template->assign_block_vars('note_priority', array( |
144 | 144 | 'ID' => $note_priority_id, |
145 | 145 | 'CLASS' => $note_priority_classes[$note_priority_id], |
@@ -147,14 +147,14 @@ discard block |
||
147 | 147 | )); |
148 | 148 | } |
149 | 149 | |
150 | -foreach($lang['sys_planet_type'] as $planet_type_id => $planet_type_string) { |
|
150 | +foreach ($lang['sys_planet_type'] as $planet_type_id => $planet_type_string) { |
|
151 | 151 | $template->assign_block_vars('planet_type', array( |
152 | 152 | 'ID' => $planet_type_id, |
153 | 153 | 'TEXT' => $planet_type_string, |
154 | 154 | )); |
155 | 155 | } |
156 | 156 | |
157 | -foreach($result as $result_data) { |
|
157 | +foreach ($result as $result_data) { |
|
158 | 158 | $template->assign_block_vars('result', $result_data); |
159 | 159 | } |
160 | 160 |