|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * --------------------------------------------------------------------- |
| 5 | + * Formcreator is a plugin which allows creation of custom forms of |
| 6 | + * easy access. |
| 7 | + * --------------------------------------------------------------------- |
| 8 | + * LICENSE |
| 9 | + * |
| 10 | + * This file is part of Formcreator. |
| 11 | + * |
| 12 | + * Formcreator is free software; you can redistribute it and/or modify |
| 13 | + * it under the terms of the GNU General Public License as published by |
| 14 | + * the Free Software Foundation; either version 2 of the License, or |
| 15 | + * (at your option) any later version. |
| 16 | + * |
| 17 | + * Formcreator is distributed in the hope that it will be useful, |
| 18 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | + * GNU General Public License for more details. |
| 21 | + * |
| 22 | + * You should have received a copy of the GNU General Public License |
| 23 | + * along with Formcreator. If not, see <http://www.gnu.org/licenses/>. |
| 24 | + * --------------------------------------------------------------------- |
| 25 | + * @copyright Copyright © 2011 - 2021 Teclib' |
| 26 | + * @license http://www.gnu.org/licenses/gpl.txt GPLv3+ |
| 27 | + * @link https://github.com/pluginsGLPI/formcreator/ |
| 28 | + * @link https://pluginsglpi.github.io/formcreator/ |
| 29 | + * @link http://plugins.glpi-project.org/#/plugin/formcreator |
| 30 | + * --------------------------------------------------------------------- |
| 31 | + */ |
| 32 | + |
| 33 | +use Glpi\Dashboard\Dashboard; |
| 34 | +use Glpi\Dashboard\Item; |
| 35 | + |
| 36 | +class PluginFormcreatorUpgradeTo2_13_10 |
| 37 | +{ |
| 38 | + /** @var Migration */ |
| 39 | + protected $migration; |
| 40 | + |
| 41 | + public function isResyncIssuesRequired() |
| 42 | + { |
| 43 | + return false; |
| 44 | + } |
| 45 | + |
| 46 | + /** |
| 47 | + * @param Migration $migration |
| 48 | + */ |
| 49 | + public function upgrade(Migration $migration) |
| 50 | + { |
| 51 | + $this->migration = $migration; |
| 52 | + $this->resizeWidgets(); |
| 53 | + } |
| 54 | + |
| 55 | + /** |
| 56 | + * Resize widgets of the `plugin_formcreator_issue_counters` dashboard to match |
| 57 | + * the mini_tickets core dashboard style |
| 58 | + * |
| 59 | + * @return void |
| 60 | + */ |
| 61 | + public function resizeWidgets() |
| 62 | + { |
| 63 | + // Get container |
| 64 | + $dashboard = new Dashboard(); |
| 65 | + $found = $dashboard->getFromDB("plugin_formcreator_issue_counters"); |
| 66 | + |
| 67 | + if (!$found) { |
| 68 | + // Unable to fetch dashboard |
| 69 | + return; |
| 70 | + }; |
| 71 | + |
| 72 | + $di = new Item(); |
| 73 | + $cards = $di->find(['dashboards_dashboards_id' => $dashboard->fields['id']]); |
| 74 | + |
| 75 | + foreach ($cards as $card) { |
| 76 | + $di = new Item(); |
| 77 | + $di->update([ |
| 78 | + 'id' => $card['id'], |
| 79 | + 'height' => 2, |
| 80 | + ]); |
| 81 | + } |
| 82 | + } |
| 83 | +} |
0 commit comments