Plugin Directory

Changeset 2812745


Ignore:
Timestamp:
11/05/2022 10:24:59 PM (3 years ago)
Author:
abrain
Message:

Release version 1.10.2

Location:
einsatzverwaltung
Files:
15 edited
2 copied

Legend:

Unmodified
Added
Removed
  • einsatzverwaltung/tags/1.10.2/Core.php

    r2804129 r2812745  
    2020class Core
    2121{
    22     const VERSION = '1.10.1';
    23     const DB_VERSION = 71;
     22    const VERSION = '1.10.2';
     23    const DB_VERSION = 72;
    2424
    2525    /**
  • einsatzverwaltung/tags/1.10.2/CustomFieldsRepository.php

    r2628082 r2812745  
    66use abrain\Einsatzverwaltung\Types\CustomTaxonomy;
    77use abrain\Einsatzverwaltung\Types\CustomType;
    8 use abrain\Einsatzverwaltung\Types\Report;
    98use WP_Term;
    109use function add_action;
     
    1211use function array_diff;
    1312use function array_filter;
     13use function array_keys;
    1414use function array_map;
     15use function array_merge;
     16use function array_search;
     17use function array_slice;
    1518use function array_unique;
     19use function current_action;
    1620use function delete_term_meta;
    1721use function explode;
    1822use function get_term_meta;
     23use function is_numeric;
     24use function preg_match;
    1925
    2026/**
     
    6672                add_action("{$taxonomy}_add_form_fields", array($this, 'onAddFormFields'));
    6773                add_action("{$taxonomy}_edit_form_fields", array($this, 'onEditFormFields'), 10, 2);
    68                 add_action("manage_edit-{$taxonomy}_columns", array($this, 'onCustomColumns'));
     74                add_action("manage_edit-{$taxonomy}_columns", array($this, 'onTaxonomyCustomColumns'));
    6975                add_filter("manage_{$taxonomy}_custom_column", array($this, 'onTaxonomyColumnContent'), 10, 3);
    7076            }
     
    7682            if (!array_key_exists($postType, $this->postTypeFields)) {
    7783                $this->postTypeFields[$postType] = array();
    78                 add_filter("manage_edit-{$postType}_columns", array($this, 'onCustomColumns'));
     84                add_filter("manage_edit-{$postType}_columns", array($this, 'onPostCustomColumns'));
    7985                add_action("manage_{$postType}_posts_custom_column", array($this, 'onPostColumnContent'), 10, 2);
    8086            }
     
    158164
    159165    /**
    160      * Fügt für die zusätzlichen Felder zusätzliche Spalten in der Übersicht ein
    161      *
    162      * @param array $columns
    163      * @return array
    164      */
    165     public function onCustomColumns($columns): array
    166     {
    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 column
    180             $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     /**
    208166     * @param string $columnId
    209167     * @param int $postId
     
    227185
    228186    /**
     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    /**
    229214     * Filterfunktion für den Inhalt der selbst angelegten Spalten
    230215     *
     
    261246
    262247    /**
    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.
    264283     *
    265284     * @param int $termId Term ID
  • einsatzverwaltung/tags/1.10.2/DataAccess/ReportInserter.php

    r2628082 r2812745  
    5353            'post_type' => Report::getSlug(),
    5454            'post_title' => $reportImportObject->getTitle(),
    55             'meta_input' => array(),
     55            'meta_input' => array('einsatz_special' => 0),
    5656            'tax_input' => array()
    5757        );
  • einsatzverwaltung/tags/1.10.2/Types/Unit.php

    r2628113 r2812745  
    183183            'unit_order',
    184184            '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 sie in 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.'
    186186        ));
    187187    }
  • einsatzverwaltung/tags/1.10.2/Types/Vehicle.php

    r2628082 r2812745  
    145145            'vehicleorder',
    146146            '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.'
    148148        ));
    149149        $customFields->add($this, new Checkbox(
  • einsatzverwaltung/tags/1.10.2/Update.php

    r2804129 r2812745  
    55use WP_User;
    66use function add_option;
     7use function add_post_meta;
    78use function add_term_meta;
    89use function array_key_exists;
     
    125126            $this->upgrade1100();
    126127        }
     128
     129        if ($currentDbVersion < 72 && $targetDbVersion >= 72) {
     130            $this->upgrade1102();
     131        }
    127132    }
    128133
     
    642647
    643648    /**
     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    /**
    644673     * Fügt einen Bezeichner für eine Admin Notice der Liste der noch anzuzeigenden Notices hinzu
    645674     *
  • einsatzverwaltung/tags/1.10.2/einsatzverwaltung.php

    r2804129 r2812745  
    44Plugin URI: https://einsatzverwaltung.org
    55Description: Public incident reports for fire departments and other rescue services
    6 Version: 1.10.1
     6Version: 1.10.2
    77Author: Andreas Brain
    88Author URI: https://www.abrain.de
  • einsatzverwaltung/tags/1.10.2/readme.txt

    r2809214 r2812745  
    66Tested up to: 6.1
    77Requires PHP: 7.1.0
    8 Stable tag: 1.10.1
     8Stable tag: 1.10.2
    99License: GPLv2
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5252
    5353== 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
    5458
    5559= 1.10.1 =
  • einsatzverwaltung/trunk/Core.php

    r2804129 r2812745  
    2020class Core
    2121{
    22     const VERSION = '1.10.1';
    23     const DB_VERSION = 71;
     22    const VERSION = '1.10.2';
     23    const DB_VERSION = 72;
    2424
    2525    /**
  • einsatzverwaltung/trunk/CustomFieldsRepository.php

    r2628082 r2812745  
    66use abrain\Einsatzverwaltung\Types\CustomTaxonomy;
    77use abrain\Einsatzverwaltung\Types\CustomType;
    8 use abrain\Einsatzverwaltung\Types\Report;
    98use WP_Term;
    109use function add_action;
     
    1211use function array_diff;
    1312use function array_filter;
     13use function array_keys;
    1414use function array_map;
     15use function array_merge;
     16use function array_search;
     17use function array_slice;
    1518use function array_unique;
     19use function current_action;
    1620use function delete_term_meta;
    1721use function explode;
    1822use function get_term_meta;
     23use function is_numeric;
     24use function preg_match;
    1925
    2026/**
     
    6672                add_action("{$taxonomy}_add_form_fields", array($this, 'onAddFormFields'));
    6773                add_action("{$taxonomy}_edit_form_fields", array($this, 'onEditFormFields'), 10, 2);
    68                 add_action("manage_edit-{$taxonomy}_columns", array($this, 'onCustomColumns'));
     74                add_action("manage_edit-{$taxonomy}_columns", array($this, 'onTaxonomyCustomColumns'));
    6975                add_filter("manage_{$taxonomy}_custom_column", array($this, 'onTaxonomyColumnContent'), 10, 3);
    7076            }
     
    7682            if (!array_key_exists($postType, $this->postTypeFields)) {
    7783                $this->postTypeFields[$postType] = array();
    78                 add_filter("manage_edit-{$postType}_columns", array($this, 'onCustomColumns'));
     84                add_filter("manage_edit-{$postType}_columns", array($this, 'onPostCustomColumns'));
    7985                add_action("manage_{$postType}_posts_custom_column", array($this, 'onPostColumnContent'), 10, 2);
    8086            }
     
    158164
    159165    /**
    160      * Fügt für die zusätzlichen Felder zusätzliche Spalten in der Übersicht ein
    161      *
    162      * @param array $columns
    163      * @return array
    164      */
    165     public function onCustomColumns($columns): array
    166     {
    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 column
    180             $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     /**
    208166     * @param string $columnId
    209167     * @param int $postId
     
    227185
    228186    /**
     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    /**
    229214     * Filterfunktion für den Inhalt der selbst angelegten Spalten
    230215     *
     
    261246
    262247    /**
    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.
    264283     *
    265284     * @param int $termId Term ID
  • einsatzverwaltung/trunk/DataAccess/ReportInserter.php

    r2628082 r2812745  
    5353            'post_type' => Report::getSlug(),
    5454            'post_title' => $reportImportObject->getTitle(),
    55             'meta_input' => array(),
     55            'meta_input' => array('einsatz_special' => 0),
    5656            'tax_input' => array()
    5757        );
  • einsatzverwaltung/trunk/Types/Unit.php

    r2628113 r2812745  
    183183            'unit_order',
    184184            'Reihenfolge',
    185             'Optionale Angabe, mit der die Anzeigereihenfolge der Einheiten beeinflusst werden kann. Einheiten mit der kleineren Zahl werden zuerst angezeigt, anschlie&szlig;end diejenigen ohne Angabe bzw. dem Wert 0. Haben mehrere Einheiten den gleichen Wert, werden sie in alphabetischer Reihenfolge ausgegeben.'
     185            'Einheiten mit der kleineren Zahl werden zuerst angezeigt, anschlie&szlig;end diejenigen mit dem Wert 0. Bei gleichem Wert werden Einheiten in alphabetischer Reihenfolge ausgegeben.'
    186186        ));
    187187    }
  • einsatzverwaltung/trunk/Types/Vehicle.php

    r2628082 r2812745  
    145145            'vehicleorder',
    146146            'Reihenfolge',
    147             'Optionale Angabe, mit der die Anzeigereihenfolge der Fahrzeuge beeinflusst werden kann. Fahrzeuge mit der kleineren Zahl werden zuerst angezeigt, anschlie&szlig;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&szlig;end diejenigen mit dem Wert 0. Bei gleichem Wert werden Fahrzeuge in alphabetischer Reihenfolge ausgegeben.'
    148148        ));
    149149        $customFields->add($this, new Checkbox(
  • einsatzverwaltung/trunk/Update.php

    r2804129 r2812745  
    55use WP_User;
    66use function add_option;
     7use function add_post_meta;
    78use function add_term_meta;
    89use function array_key_exists;
     
    125126            $this->upgrade1100();
    126127        }
     128
     129        if ($currentDbVersion < 72 && $targetDbVersion >= 72) {
     130            $this->upgrade1102();
     131        }
    127132    }
    128133
     
    642647
    643648    /**
     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    /**
    644673     * Fügt einen Bezeichner für eine Admin Notice der Liste der noch anzuzeigenden Notices hinzu
    645674     *
  • einsatzverwaltung/trunk/einsatzverwaltung.php

    r2804129 r2812745  
    44Plugin URI: https://einsatzverwaltung.org
    55Description: Public incident reports for fire departments and other rescue services
    6 Version: 1.10.1
     6Version: 1.10.2
    77Author: Andreas Brain
    88Author URI: https://www.abrain.de
  • einsatzverwaltung/trunk/readme.txt

    r2809214 r2812745  
    66Tested up to: 6.1
    77Requires PHP: 7.1.0
    8 Stable tag: 1.10.1
     8Stable tag: 1.10.2
    99License: GPLv2
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5252
    5353== 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
    5458
    5559= 1.10.1 =
Note: See TracChangeset for help on using the changeset viewer.