Skip to content

Commit

Permalink
Fixed the issue that prevents save of icon path for an existing itemtype
Browse files Browse the repository at this point in the history
  • Loading branch information
tomolimo committed Jul 13, 2021
1 parent 601fdaf commit 5587a82
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions inc/itemtype.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ public function maybeTranslated() {
function showForm($id = null, $options = []) {
global $CFG_GLPI;

if (!$this->isNewID($id)) {
$this->check($id, READ);
} else {
// Create item
$this->check(-1, CREATE);
if (!$this->isNewID($id)) {
$this->check($id, READ);
} else {
// Create item
$this->check(-1, CREATE);
}

$this->showFormHeader(['colspan' => 3]);
Expand All @@ -78,7 +78,7 @@ function showForm($id = null, $options = []) {
echo "<tr class='tab_bg_1'>";
echo "<td><label for='urlpath'>".__('Icon path (example: \'plugins/impacts/pics/PluginAccountsAccount.png\')', 'impacts')."</label></td>";
echo "<td><input size=50 type='text' id='urlpath' name='url_path_pics' value='".$this->fields['url_path_pics']."'/></td>";
$file_path = GLPI_ROOT . "/" . $this->fields['url_path_pics'];
$file_path = GLPI_ROOT . "/" . $this->fields['url_path_pics'];
if (file_exists($file_path)
&& is_file($file_path)) {
echo "<td><img src='".$CFG_GLPI['root_doc'] . "/" . $this->fields['url_path_pics']."' style='width: 32px; height: 32px;'/></td>";
Expand All @@ -87,11 +87,11 @@ function showForm($id = null, $options = []) {
}
echo "</tr'>\n";

if (isset($_REQUEST['_in_modal'])) {
echo "<input type='hidden' name='_in_modal' value='1'>";
if (isset($_REQUEST['_in_modal'])) {
echo "<input type='hidden' name='_in_modal' value='1'>";
}

$this->showFormButtons($options);
$this->showFormButtons($options);

}

Expand Down Expand Up @@ -149,7 +149,7 @@ function prepareInputForUpdate($input) {
$input = false;
}
$elt = new self;
if ($input && $elt->getFromDBByCrit(['name' => $input['name']])) {
if ($input && $elt->getFromDBByCrit(['name' => $input['name']]) && $input['url_path_pics'] == $elt->fields['url_path_pics']) {
Session::addMessageAfterRedirect(
sprintf(__('Item type class: \''.$input['name'].'\' is already existing!')),
true,
Expand Down
2 changes: 1 addition & 1 deletion setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
// ----------------------------------------------------------------------


define('IMPACTS_VERSION', '2.0.3');
define('IMPACTS_VERSION', '2.0.4');

// Minimal GLPI version, inclusive
define("IMPACTS_MIN_GLPI", "9.5");
Expand Down

0 comments on commit 5587a82

Please sign in to comment.