Changeset 2812745
- Timestamp:
- 11/05/2022 10:24:59 PM (3 years ago)
- Location:
- einsatzverwaltung
- Files:
-
- 15 edited
- 2 copied
-
tags/1.10.2 (copied) (copied from einsatzverwaltung/trunk)
-
tags/1.10.2/Core.php (modified) (1 diff)
-
tags/1.10.2/CustomFieldsRepository.php (modified) (7 diffs)
-
tags/1.10.2/DataAccess/ReportInserter.php (modified) (1 diff)
-
tags/1.10.2/Types/Unit.php (modified) (1 diff)
-
tags/1.10.2/Types/Vehicle.php (modified) (1 diff)
-
tags/1.10.2/Update.php (modified) (3 diffs)
-
tags/1.10.2/einsatzverwaltung.php (modified) (1 diff)
-
tags/1.10.2/readme.txt (copied) (copied from einsatzverwaltung/trunk/readme.txt) (2 diffs)
-
trunk/Core.php (modified) (1 diff)
-
trunk/CustomFieldsRepository.php (modified) (7 diffs)
-
trunk/DataAccess/ReportInserter.php (modified) (1 diff)
-
trunk/Types/Unit.php (modified) (1 diff)
-
trunk/Types/Vehicle.php (modified) (1 diff)
-
trunk/Update.php (modified) (3 diffs)
-
trunk/einsatzverwaltung.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
einsatzverwaltung/tags/1.10.2/Core.php
r2804129 r2812745 20 20 class Core 21 21 { 22 const VERSION = '1.10. 1';23 const DB_VERSION = 7 1;22 const VERSION = '1.10.2'; 23 const DB_VERSION = 72; 24 24 25 25 /** -
einsatzverwaltung/tags/1.10.2/CustomFieldsRepository.php
r2628082 r2812745 6 6 use abrain\Einsatzverwaltung\Types\CustomTaxonomy; 7 7 use abrain\Einsatzverwaltung\Types\CustomType; 8 use abrain\Einsatzverwaltung\Types\Report;9 8 use WP_Term; 10 9 use function add_action; … … 12 11 use function array_diff; 13 12 use function array_filter; 13 use function array_keys; 14 14 use function array_map; 15 use function array_merge; 16 use function array_search; 17 use function array_slice; 15 18 use function array_unique; 19 use function current_action; 16 20 use function delete_term_meta; 17 21 use function explode; 18 22 use function get_term_meta; 23 use function is_numeric; 24 use function preg_match; 19 25 20 26 /** … … 66 72 add_action("{$taxonomy}_add_form_fields", array($this, 'onAddFormFields')); 67 73 add_action("{$taxonomy}_edit_form_fields", array($this, 'onEditFormFields'), 10, 2); 68 add_action("manage_edit-{$taxonomy}_columns", array($this, 'on CustomColumns'));74 add_action("manage_edit-{$taxonomy}_columns", array($this, 'onTaxonomyCustomColumns')); 69 75 add_filter("manage_{$taxonomy}_custom_column", array($this, 'onTaxonomyColumnContent'), 10, 3); 70 76 } … … 76 82 if (!array_key_exists($postType, $this->postTypeFields)) { 77 83 $this->postTypeFields[$postType] = array(); 78 add_filter("manage_edit-{$postType}_columns", array($this, 'on CustomColumns'));84 add_filter("manage_edit-{$postType}_columns", array($this, 'onPostCustomColumns')); 79 85 add_action("manage_{$postType}_posts_custom_column", array($this, 'onPostColumnContent'), 10, 2); 80 86 } … … 158 164 159 165 /** 160 * Fügt für die zusätzlichen Felder zusätzliche Spalten in der Übersicht ein161 *162 * @param array $columns163 * @return array164 */165 public function onCustomColumns($columns): array166 {167 $screen = get_current_screen();168 169 if (empty($screen)) {170 return $columns;171 }172 173 if ($screen->post_type === Report::getSlug() && !empty($screen->taxonomy)) {174 $taxonomy = $screen->taxonomy;175 if (!$this->hasTaxonomy($taxonomy)) {176 return $columns;177 }178 179 // Add the columns after the description column180 $index = array_search('description', array_keys($columns));181 $index = is_numeric($index) ? $index + 1 : count($columns);182 $before = array_slice($columns, 0, $index, true);183 $after = array_slice($columns, $index, null, true);184 185 $columnsToAdd = array();186 /** @var CustomField $field */187 foreach ($this->taxonomyFields[$taxonomy] as $field) {188 $columnsToAdd[$field->key] = $field->label;189 }190 191 return array_merge($before, $columnsToAdd, $after);192 }193 194 $postType = $screen->post_type;195 if (!$this->hasPostType($postType)) {196 return $columns;197 }198 199 /** @var CustomField $field */200 foreach ($this->postTypeFields[$postType] as $field) {201 $columns[$field->key] = $field->label;202 }203 204 return $columns;205 }206 207 /**208 166 * @param string $columnId 209 167 * @param int $postId … … 227 185 228 186 /** 187 * Adds custom columns to our own post types. 188 * 189 * @param string[] $columns 190 * 191 * @return string[] An associative array of column headings. 192 */ 193 public function onPostCustomColumns($columns): array 194 { 195 $currentAction = current_action(); 196 if (preg_match('/^manage_edit-(\w+)_columns$/', $currentAction, $matches) !== 1) { 197 return $columns; 198 } 199 200 $postType = $matches[1]; 201 if (!$this->hasPostType($postType)) { 202 return $columns; 203 } 204 205 /** @var CustomField $field */ 206 foreach ($this->postTypeFields[$postType] as $field) { 207 $columns[$field->key] = $field->label; 208 } 209 210 return $columns; 211 } 212 213 /** 229 214 * Filterfunktion für den Inhalt der selbst angelegten Spalten 230 215 * … … 261 246 262 247 /** 263 * Speichert zusätzliche Infos zu Terms als options ab 248 * Adds custom columns to our own taxonomies. 249 * 250 * @param string[] $columns An associative array of column headings. 251 * 252 * @return string[] 253 */ 254 public function onTaxonomyCustomColumns($columns): array 255 { 256 $currentAction = current_action(); 257 if (preg_match('/^manage_edit-(\w+)_columns$/', $currentAction, $matches) !== 1) { 258 return $columns; 259 } 260 261 $taxonomy = $matches[1]; 262 if (!$this->hasTaxonomy($taxonomy)) { 263 return $columns; 264 } 265 266 // Add the columns after the description column 267 $index = array_search('description', array_keys($columns)); 268 $index = is_numeric($index) ? $index + 1 : count($columns); 269 $before = array_slice($columns, 0, $index, true); 270 $after = array_slice($columns, $index, null, true); 271 272 $columnsToAdd = array(); 273 /** @var CustomField $field */ 274 foreach ($this->taxonomyFields[$taxonomy] as $field) { 275 $columnsToAdd[$field->key] = $field->label; 276 } 277 278 return array_merge($before, $columnsToAdd, $after); 279 } 280 281 /** 282 * Saves custom taxonomy fields to termmeta. 264 283 * 265 284 * @param int $termId Term ID -
einsatzverwaltung/tags/1.10.2/DataAccess/ReportInserter.php
r2628082 r2812745 53 53 'post_type' => Report::getSlug(), 54 54 'post_title' => $reportImportObject->getTitle(), 55 'meta_input' => array( ),55 'meta_input' => array('einsatz_special' => 0), 56 56 'tax_input' => array() 57 57 ); -
einsatzverwaltung/tags/1.10.2/Types/Unit.php
r2628113 r2812745 183 183 'unit_order', 184 184 'Reihenfolge', 185 ' Optionale Angabe, mit der die Anzeigereihenfolge der Einheiten beeinflusst werden kann. Einheiten mit der kleineren Zahl werden zuerst angezeigt, anschließend diejenigen ohne Angabe bzw. dem Wert 0. Haben mehrere Einheiten den gleichen Wert, werden siein alphabetischer Reihenfolge ausgegeben.'185 'Einheiten mit der kleineren Zahl werden zuerst angezeigt, anschließend diejenigen mit dem Wert 0. Bei gleichem Wert werden Einheiten in alphabetischer Reihenfolge ausgegeben.' 186 186 )); 187 187 } -
einsatzverwaltung/tags/1.10.2/Types/Vehicle.php
r2628082 r2812745 145 145 'vehicleorder', 146 146 'Reihenfolge', 147 ' Optionale Angabe, mit der die Anzeigereihenfolge der Fahrzeuge beeinflusst werden kann. Fahrzeuge mit der kleineren Zahl werden zuerst angezeigt, anschließend diejenigen ohne Angabe bzw. dem Wert 0. Haben mehrere Fahrzeuge den gleichen Wert, werden sie in alphabetischer Reihenfolge ausgegeben.'147 'Fahrzeuge mit der kleineren Zahl werden zuerst angezeigt, anschließend diejenigen mit dem Wert 0. Bei gleichem Wert werden Fahrzeuge in alphabetischer Reihenfolge ausgegeben.' 148 148 )); 149 149 $customFields->add($this, new Checkbox( -
einsatzverwaltung/tags/1.10.2/Update.php
r2804129 r2812745 5 5 use WP_User; 6 6 use function add_option; 7 use function add_post_meta; 7 8 use function add_term_meta; 8 9 use function array_key_exists; … … 125 126 $this->upgrade1100(); 126 127 } 128 129 if ($currentDbVersion < 72 && $targetDbVersion >= 72) { 130 $this->upgrade1102(); 131 } 127 132 } 128 133 … … 642 647 643 648 /** 649 * - Adds missing 'special' postmeta for reports that got created via the API 650 * 651 * @since 1.10.2 652 */ 653 public function upgrade1102() 654 { 655 $postsWithoutPostmeta = get_posts([ 656 'post_type' => 'einsatz', 657 'post_status' => ['publish', 'private', 'draft'], 658 'nopaging' => true, 659 'meta_query' => [ 660 [ 661 'key' => 'einsatz_special', 662 'compare' => 'NOT EXISTS' 663 ] 664 ] 665 ]); 666 foreach ($postsWithoutPostmeta as $post) { 667 add_post_meta($post->ID, 'einsatz_special', 0, true); 668 } 669 update_option('einsatzvw_db_version', 72); 670 } 671 672 /** 644 673 * Fügt einen Bezeichner für eine Admin Notice der Liste der noch anzuzeigenden Notices hinzu 645 674 * -
einsatzverwaltung/tags/1.10.2/einsatzverwaltung.php
r2804129 r2812745 4 4 Plugin URI: https://einsatzverwaltung.org 5 5 Description: Public incident reports for fire departments and other rescue services 6 Version: 1.10. 16 Version: 1.10.2 7 7 Author: Andreas Brain 8 8 Author URI: https://www.abrain.de -
einsatzverwaltung/tags/1.10.2/readme.txt
r2809214 r2812745 6 6 Tested up to: 6.1 7 7 Requires PHP: 7.1.0 8 Stable tag: 1.10. 18 Stable tag: 1.10.2 9 9 License: GPLv2 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 52 52 53 53 == Changelog == 54 55 = 1.10.2 = 56 * Fix: Reports created with the API endpoint could show up as special reports 57 * Fix: Table was missing columns when creating e.g. units or vehicles 54 58 55 59 = 1.10.1 = -
einsatzverwaltung/trunk/Core.php
r2804129 r2812745 20 20 class Core 21 21 { 22 const VERSION = '1.10. 1';23 const DB_VERSION = 7 1;22 const VERSION = '1.10.2'; 23 const DB_VERSION = 72; 24 24 25 25 /** -
einsatzverwaltung/trunk/CustomFieldsRepository.php
r2628082 r2812745 6 6 use abrain\Einsatzverwaltung\Types\CustomTaxonomy; 7 7 use abrain\Einsatzverwaltung\Types\CustomType; 8 use abrain\Einsatzverwaltung\Types\Report;9 8 use WP_Term; 10 9 use function add_action; … … 12 11 use function array_diff; 13 12 use function array_filter; 13 use function array_keys; 14 14 use function array_map; 15 use function array_merge; 16 use function array_search; 17 use function array_slice; 15 18 use function array_unique; 19 use function current_action; 16 20 use function delete_term_meta; 17 21 use function explode; 18 22 use function get_term_meta; 23 use function is_numeric; 24 use function preg_match; 19 25 20 26 /** … … 66 72 add_action("{$taxonomy}_add_form_fields", array($this, 'onAddFormFields')); 67 73 add_action("{$taxonomy}_edit_form_fields", array($this, 'onEditFormFields'), 10, 2); 68 add_action("manage_edit-{$taxonomy}_columns", array($this, 'on CustomColumns'));74 add_action("manage_edit-{$taxonomy}_columns", array($this, 'onTaxonomyCustomColumns')); 69 75 add_filter("manage_{$taxonomy}_custom_column", array($this, 'onTaxonomyColumnContent'), 10, 3); 70 76 } … … 76 82 if (!array_key_exists($postType, $this->postTypeFields)) { 77 83 $this->postTypeFields[$postType] = array(); 78 add_filter("manage_edit-{$postType}_columns", array($this, 'on CustomColumns'));84 add_filter("manage_edit-{$postType}_columns", array($this, 'onPostCustomColumns')); 79 85 add_action("manage_{$postType}_posts_custom_column", array($this, 'onPostColumnContent'), 10, 2); 80 86 } … … 158 164 159 165 /** 160 * Fügt für die zusätzlichen Felder zusätzliche Spalten in der Übersicht ein161 *162 * @param array $columns163 * @return array164 */165 public function onCustomColumns($columns): array166 {167 $screen = get_current_screen();168 169 if (empty($screen)) {170 return $columns;171 }172 173 if ($screen->post_type === Report::getSlug() && !empty($screen->taxonomy)) {174 $taxonomy = $screen->taxonomy;175 if (!$this->hasTaxonomy($taxonomy)) {176 return $columns;177 }178 179 // Add the columns after the description column180 $index = array_search('description', array_keys($columns));181 $index = is_numeric($index) ? $index + 1 : count($columns);182 $before = array_slice($columns, 0, $index, true);183 $after = array_slice($columns, $index, null, true);184 185 $columnsToAdd = array();186 /** @var CustomField $field */187 foreach ($this->taxonomyFields[$taxonomy] as $field) {188 $columnsToAdd[$field->key] = $field->label;189 }190 191 return array_merge($before, $columnsToAdd, $after);192 }193 194 $postType = $screen->post_type;195 if (!$this->hasPostType($postType)) {196 return $columns;197 }198 199 /** @var CustomField $field */200 foreach ($this->postTypeFields[$postType] as $field) {201 $columns[$field->key] = $field->label;202 }203 204 return $columns;205 }206 207 /**208 166 * @param string $columnId 209 167 * @param int $postId … … 227 185 228 186 /** 187 * Adds custom columns to our own post types. 188 * 189 * @param string[] $columns 190 * 191 * @return string[] An associative array of column headings. 192 */ 193 public function onPostCustomColumns($columns): array 194 { 195 $currentAction = current_action(); 196 if (preg_match('/^manage_edit-(\w+)_columns$/', $currentAction, $matches) !== 1) { 197 return $columns; 198 } 199 200 $postType = $matches[1]; 201 if (!$this->hasPostType($postType)) { 202 return $columns; 203 } 204 205 /** @var CustomField $field */ 206 foreach ($this->postTypeFields[$postType] as $field) { 207 $columns[$field->key] = $field->label; 208 } 209 210 return $columns; 211 } 212 213 /** 229 214 * Filterfunktion für den Inhalt der selbst angelegten Spalten 230 215 * … … 261 246 262 247 /** 263 * Speichert zusätzliche Infos zu Terms als options ab 248 * Adds custom columns to our own taxonomies. 249 * 250 * @param string[] $columns An associative array of column headings. 251 * 252 * @return string[] 253 */ 254 public function onTaxonomyCustomColumns($columns): array 255 { 256 $currentAction = current_action(); 257 if (preg_match('/^manage_edit-(\w+)_columns$/', $currentAction, $matches) !== 1) { 258 return $columns; 259 } 260 261 $taxonomy = $matches[1]; 262 if (!$this->hasTaxonomy($taxonomy)) { 263 return $columns; 264 } 265 266 // Add the columns after the description column 267 $index = array_search('description', array_keys($columns)); 268 $index = is_numeric($index) ? $index + 1 : count($columns); 269 $before = array_slice($columns, 0, $index, true); 270 $after = array_slice($columns, $index, null, true); 271 272 $columnsToAdd = array(); 273 /** @var CustomField $field */ 274 foreach ($this->taxonomyFields[$taxonomy] as $field) { 275 $columnsToAdd[$field->key] = $field->label; 276 } 277 278 return array_merge($before, $columnsToAdd, $after); 279 } 280 281 /** 282 * Saves custom taxonomy fields to termmeta. 264 283 * 265 284 * @param int $termId Term ID -
einsatzverwaltung/trunk/DataAccess/ReportInserter.php
r2628082 r2812745 53 53 'post_type' => Report::getSlug(), 54 54 'post_title' => $reportImportObject->getTitle(), 55 'meta_input' => array( ),55 'meta_input' => array('einsatz_special' => 0), 56 56 'tax_input' => array() 57 57 ); -
einsatzverwaltung/trunk/Types/Unit.php
r2628113 r2812745 183 183 'unit_order', 184 184 'Reihenfolge', 185 ' Optionale Angabe, mit der die Anzeigereihenfolge der Einheiten beeinflusst werden kann. Einheiten mit der kleineren Zahl werden zuerst angezeigt, anschließend diejenigen ohne Angabe bzw. dem Wert 0. Haben mehrere Einheiten den gleichen Wert, werden siein alphabetischer Reihenfolge ausgegeben.'185 'Einheiten mit der kleineren Zahl werden zuerst angezeigt, anschließend diejenigen mit dem Wert 0. Bei gleichem Wert werden Einheiten in alphabetischer Reihenfolge ausgegeben.' 186 186 )); 187 187 } -
einsatzverwaltung/trunk/Types/Vehicle.php
r2628082 r2812745 145 145 'vehicleorder', 146 146 'Reihenfolge', 147 ' Optionale Angabe, mit der die Anzeigereihenfolge der Fahrzeuge beeinflusst werden kann. Fahrzeuge mit der kleineren Zahl werden zuerst angezeigt, anschließend diejenigen ohne Angabe bzw. dem Wert 0. Haben mehrere Fahrzeuge den gleichen Wert, werden sie in alphabetischer Reihenfolge ausgegeben.'147 'Fahrzeuge mit der kleineren Zahl werden zuerst angezeigt, anschließend diejenigen mit dem Wert 0. Bei gleichem Wert werden Fahrzeuge in alphabetischer Reihenfolge ausgegeben.' 148 148 )); 149 149 $customFields->add($this, new Checkbox( -
einsatzverwaltung/trunk/Update.php
r2804129 r2812745 5 5 use WP_User; 6 6 use function add_option; 7 use function add_post_meta; 7 8 use function add_term_meta; 8 9 use function array_key_exists; … … 125 126 $this->upgrade1100(); 126 127 } 128 129 if ($currentDbVersion < 72 && $targetDbVersion >= 72) { 130 $this->upgrade1102(); 131 } 127 132 } 128 133 … … 642 647 643 648 /** 649 * - Adds missing 'special' postmeta for reports that got created via the API 650 * 651 * @since 1.10.2 652 */ 653 public function upgrade1102() 654 { 655 $postsWithoutPostmeta = get_posts([ 656 'post_type' => 'einsatz', 657 'post_status' => ['publish', 'private', 'draft'], 658 'nopaging' => true, 659 'meta_query' => [ 660 [ 661 'key' => 'einsatz_special', 662 'compare' => 'NOT EXISTS' 663 ] 664 ] 665 ]); 666 foreach ($postsWithoutPostmeta as $post) { 667 add_post_meta($post->ID, 'einsatz_special', 0, true); 668 } 669 update_option('einsatzvw_db_version', 72); 670 } 671 672 /** 644 673 * Fügt einen Bezeichner für eine Admin Notice der Liste der noch anzuzeigenden Notices hinzu 645 674 * -
einsatzverwaltung/trunk/einsatzverwaltung.php
r2804129 r2812745 4 4 Plugin URI: https://einsatzverwaltung.org 5 5 Description: Public incident reports for fire departments and other rescue services 6 Version: 1.10. 16 Version: 1.10.2 7 7 Author: Andreas Brain 8 8 Author URI: https://www.abrain.de -
einsatzverwaltung/trunk/readme.txt
r2809214 r2812745 6 6 Tested up to: 6.1 7 7 Requires PHP: 7.1.0 8 Stable tag: 1.10. 18 Stable tag: 1.10.2 9 9 License: GPLv2 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 52 52 53 53 == Changelog == 54 55 = 1.10.2 = 56 * Fix: Reports created with the API endpoint could show up as special reports 57 * Fix: Table was missing columns when creating e.g. units or vehicles 54 58 55 59 = 1.10.1 =
Note: See TracChangeset
for help on using the changeset viewer.