Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
9e6c6b0
Add php cs fixer (test)
jackburton79 Jun 30, 2020
fbb0366
Delete main.yml
jackburton79 Jun 30, 2020
afe4266
Rename .php_cs.dist to .php-cs-fixer.dist.php
jackburton79 Oct 23, 2021
48c309c
Merge branch 'pluginsGLPI:master' into master
jackburton79 Oct 23, 2021
61a08dd
Merge branch 'pluginsGLPI:master' into master
jackburton79 Oct 24, 2021
2792d7b
README: Removed comment added in fork
jackburton79 Oct 25, 2021
7960efc
Revert "Rename .php_cs.dist to .php-cs-fixer.dist.php"
jackburton79 Oct 25, 2021
7b2af2b
glpi10 compatibility:
jackburton79 Dec 17, 2021
1ef47af
Fix spurious '\n' in profile window in GLPI 10. Use double quotes whe…
jackburton79 Apr 7, 2022
88c0352
On uninstall, delete reservations for rooms
jackburton79 Apr 7, 2022
e4086fb
missing parenthesis
Apr 7, 2022
2601186
Also fix wrong placement of semicolon
jackburton79 Apr 7, 2022
3c0e9df
Try to use Innodb and utf8mb4 (WIP)
jackburton79 Apr 7, 2022
1847730
Fix collate statement
jackburton79 Apr 7, 2022
a4edf0d
Fix signed int fields
jackburton79 Apr 7, 2022
d3300c6
Uninstall: use double quotes otherwise the variable doesn't get expanded
jackburton79 Apr 7, 2022
f1fcf53
Remove automatic actions
jackburton79 Apr 7, 2022
c26d962
Update POT
jackburton79 Apr 7, 2022
123b7a8
Updated italian translation
jackburton79 Apr 8, 2022
4c7a3e2
Update italian mo file
jackburton79 Apr 8, 2022
5a010df
Fix unsigned & timestamps
jackburton79 Apr 8, 2022
341e016
Fix addSelect for glpi10
jackburton79 Jun 6, 2022
21be6ce
room.form.php: improve by avoiding nesting of 'if' conditions
jackburton79 Jun 6, 2022
8b372b8
Comment autocompletion for text fields since it's been deprecated
jackburton79 Jun 6, 2022
f3078e2
Restore cloning rooms in glpi 10
jackburton79 Jun 6, 2022
037e37a
Fix missing Name and other fields
jackburton79 Oct 24, 2022
207c7b5
add translation (es_AR)
ftoledo Jan 6, 2024
fc0fbd3
Merge pull request #6 from ftoledo/glpi-10
jackburton79 Jan 7, 2024
7eb7ee2
Style fixes
jackburton79 Aug 31, 2023
d270f06
Fix uncaught exception
jackburton79 May 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .github/workflows/main.yml

This file was deleted.

8 changes: 0 additions & 8 deletions .github/workflows/php-lint.yml

This file was deleted.

3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ This plugin allows you to manage the rooms and the elements that are included
in. A room is not the same as a location that already exists in GLPI because it
can not contain items nor be loaned (which a room can be).

GLPI 9.5.1 compatibility added and tested. Translation fixed (gettext domain).
I also added a basic hungarian translation :)

Installation
------------

Expand Down
112 changes: 50 additions & 62 deletions front/room.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,68 +26,56 @@

$newID = $room->add($_POST);
Html::back();
} else {
if (isset($_POST['delete'])) { // Supression d'une salle
$room->check($_POST['id'], DELETE);

$room->delete($_POST);
Html::redirect($CFG_GLPI['root_doc'] . '/plugins/room/index.php');
} else {
if (isset($_POST['purge'])) { // Purge de la salle
$room->check($_POST['id'], PURGE);

$room->delete($_POST, 1);
Html::redirect($CFG_GLPI['root_doc'] . '/plugins/room/index.php');
} else {
if (isset($_POST['restore'])) { // Restauration de la salle
$room->check($_POST['id'], PURGE);

$room->restore($_POST);
Html::redirect($CFG_GLPI['root_doc'] . '/plugins/room/index.php');
} else {
if (isset($_POST['update'])) { // Modification d'une salle
$room->check($_POST['id'], UPDATE);

$room->update($_POST);
Html::back();
} else {
if (isset($_POST['additem'])) { // Ajout de la liaison à un ordinateur
$room->check($_POST['room_id'], UPDATE); // Ça devrait pas être rooms_id?

if ($_POST['room_id'] > 0 && $_POST['computers_id'] > 0) {
$room->plugin_room_AddDevice($_POST['room_id'], $_POST['computers_id']);
}
Html::back();
} else {
if (isset($_POST['deleteitem'])) { // Suppression de la liaison à un ordinateur
$room->check($_POST['room_id'], UPDATE);

if (count($_POST['item'])) {
foreach ($_POST['item'] as $key => $val) {
$room->plugin_room_DeleteDevice($key);
}
}
Html::back();
} else { // Logiquement on passe ici pour visualiser une salle
$room->check($_GET['id'], READ);

// test l'onglet de départ a afficher à l'ouverture de la fiche
if (!isset($_SESSION['glpi_tab'])) {
$_SESSION['glpi_tab'] = 1;
}
if (isset($_GET['tab'])) {
$_SESSION['glpi_tab'] = $_GET['tab'];
}

Html::header(__('Room Management', 'room'), '', 'assets', 'pluginroommenu');

$room->display($_GET);

Html::footer();
}
}
}
}
} else if (isset($_POST['delete'])) { // Supression d'une salle
$room->check($_POST['id'], DELETE);

$room->delete($_POST);
Html::redirect($CFG_GLPI['root_doc'] . '/plugins/room/index.php');
} else if (isset($_POST['purge'])) { // Purge de la salle
$room->check($_POST['id'], PURGE);

$room->delete($_POST, 1);
Html::redirect($CFG_GLPI['root_doc'] . '/plugins/room/index.php');
} else if (isset($_POST['restore'])) { // Restauration de la salle
$room->check($_POST['id'], PURGE);

$room->restore($_POST);
Html::redirect($CFG_GLPI['root_doc'] . '/plugins/room/index.php');
} else if (isset($_POST['update'])) { // Modification d'une salle
$room->check($_POST['id'], UPDATE);

$room->update($_POST);
Html::back();
} else if (isset($_POST['additem'])) { // Ajout de la liaison à un ordinateur
$room->check($_POST['room_id'], UPDATE); // Ça devrait pas être rooms_id?

if ($_POST['room_id'] > 0 && $_POST['computers_id'] > 0) {
$room->plugin_room_AddDevice($_POST['room_id'], $_POST['computers_id']);
}
Html::back();
} else if (isset($_POST['deleteitem'])) { // Suppression de la liaison à un ordinateur
$room->check($_POST['room_id'], UPDATE);

if (count($_POST['item'])) {
foreach ($_POST['item'] as $key => $val) {
$room->plugin_room_DeleteDevice($key);
}
}
Html::back();
} else { // Logiquement on passe ici pour visualiser une salle
$room->check($_GET['id'], READ);

// test l'onglet de départ a afficher à l'ouverture de la fiche
if (!isset($_SESSION['glpi_tab'])) {
$_SESSION['glpi_tab'] = 1;
}
if (isset($_GET['tab'])) {
$_SESSION['glpi_tab'] = $_GET['tab'];
}

Html::header(__('Room Management', 'room'), '', 'assets', 'pluginroommenu');

$room->display($_GET);

Html::footer();
}
91 changes: 49 additions & 42 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,36 @@ function plugin_room_install()
if (!$DB->tableExists('glpi_plugin_room_rooms')) {
$query = <<<'EOS'
CREATE TABLE `glpi_plugin_room_rooms` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(255) collate utf8_unicode_ci default NULL,
`entities_id` int(11) NOT NULL default 0,
`locations_id` int(11) NOT NULL default 0,
`id` int unsigned NOT NULL auto_increment,
`name` varchar(255) collate utf8mb4_unicode_ci default NULL,
`entities_id` int unsigned NOT NULL default 0,
`locations_id` int unsigned NOT NULL default 0,
`is_recursive` smallint(6) NOT NULL default 0,
`is_deleted` smallint(6) NOT NULL default 0,
`type` int(11) NOT NULL default 0,
`date_mod` datetime default NULL,
`type` int unsigned NOT NULL default 0,
`date_mod` timestamp NULL default NULL,
`size` smallint(6) NOT NULL default 0,
`count_linked` smallint(6) NOT NULL default 0,
`buy` datetime default NULL,
`access` int(11) NOT NULL default 0,
`buy` timestamp NULL default NULL,
`access` int unsigned NOT NULL default 0,
`printer` smallint(6) NOT NULL default 0,
`videoprojector` smallint(6) NOT NULL default 0,
`wifi` smallint(6) NOT NULL default 0,
`comment` text collate utf8_unicode_ci,
`opening` varchar(255) collate utf8_unicode_ci default NULL,
`limits` varchar(255) collate utf8_unicode_ci default NULL,
`text1` varchar(255) collate utf8_unicode_ci default NULL,
`text2` varchar(255) collate utf8_unicode_ci default NULL,
`dropdown1` int(11) NOT NULL default 0,
`dropdown2` int(11) NOT NULL default 0,
`tech_num` int(11) NOT NULL default 0,
`users_id` int(11) NOT NULL default 0,
`comment` text collate utf8mb4_unicode_ci,
`opening` varchar(255) collate utf8mb4_unicode_ci default NULL,
`limits` varchar(255) collate utf8mb4_unicode_ci default NULL,
`text1` varchar(255) collate utf8mb4_unicode_ci default NULL,
`text2` varchar(255) collate utf8mb4_unicode_ci default NULL,
`dropdown1` int unsigned NOT NULL default 0,
`dropdown2` int unsigned NOT NULL default 0,
`tech_num` int unsigned NOT NULL default 0,
`users_id` int unsigned NOT NULL default 0,
`is_template` smallint(6) NOT NULL default 0, # not used / for reservation search engine
`location` smallint(6) NOT NULL default 0, # not used / for reservation search engine
`state` smallint(6) NOT NULL default 0, # not used / for reservation search engine
`manufacturers_id` smallint(6) NOT NULL default 0, # not used / for reservation search engine
`groups_id` smallint(6) NOT NULL default 0, # not used / for reservation search engine
`groups_id_tech` int(11) NOT NULL default 0 COMMENT "Group in charge of the hardware. RELATION to glpi_groups (id)",
`manufacturers_id` int unsigned NOT NULL default 0, # not used / for reservation search engine
`groups_id` int unsigned NOT NULL default 0, # not used / for reservation search engine
`groups_id_tech` int unsigned NOT NULL default 0 COMMENT "Group in charge of the hardware. RELATION to glpi_groups (id)",
PRIMARY KEY (`id`),
KEY `entities_id` (`entities_id`),
KEY `is_deleted` (`is_deleted`),
Expand All @@ -50,7 +50,7 @@ function plugin_room_install()
KEY `dropdown2` (`dropdown2`),
KEY `tech_num` (`tech_num`),
KEY `users_id` (`users_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC
EOS;
$DB->query($query) || die('error adding glpi_plugin_room table ' . __('Error during the database update', 'room') . $DB->error());
}
Expand All @@ -59,13 +59,13 @@ function plugin_room_install()
if (!$DB->TableExists('glpi_plugin_room_rooms_computers')) {
$query = <<<'EOS'
CREATE TABLE `glpi_plugin_room_rooms_computers` (
`id` int(11) NOT NULL auto_increment,
`computers_id` int(11) NOT NULL,
`rooms_id` int(11) NOT NULL,
`id` int unsigned NOT NULL auto_increment,
`computers_id` int unsigned NOT NULL,
`rooms_id` int unsigned NOT NULL,
PRIMARY KEY (`id`),
UNIQUE `computers_id` (`computers_id`),
KEY `rooms_id` (`rooms_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
EOS;
$DB->query($query) || die('error adding glpi_plugin_room_rooms_computers table ' . __('Error during the database update', 'room') . $DB->error());
}
Expand All @@ -74,12 +74,12 @@ function plugin_room_install()
if (!$DB->TableExists('glpi_plugin_room_roomtypes')) {
$query = <<<'EOS'
CREATE TABLE `glpi_plugin_room_roomtypes` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(255) collate utf8_unicode_ci default NULL,
`comment` text collate utf8_unicode_ci,
`id` int unsigned NOT NULL auto_increment,
`name` varchar(255) collate utf8mb4_unicode_ci default NULL,
`comment` text collate utf8mb4_unicode_ci,
PRIMARY KEY (`id`),
KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
EOS;
$DB->query($query) || die('error adding glpi_plugin_room_roomtypes table ' . __('Error during the database update', 'room') . $DB->error());
}
Expand All @@ -88,12 +88,12 @@ function plugin_room_install()
if (!$DB->TableExists('glpi_plugin_room_roomaccessconds')) {
$query = <<<'EOS'
CREATE TABLE `glpi_plugin_room_roomaccessconds` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(255) collate utf8_unicode_ci default NULL,
`comment` text collate utf8_unicode_ci,
`id` int unsigned NOT NULL auto_increment,
`name` varchar(255) collate utf8mb4_unicode_ci default NULL,
`comment` text collate utf8mb4_unicode_ci,
PRIMARY KEY (`id`),
KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
EOS;
$DB->query($query) || die('error adding glpi_plugin_room_roomaccessconds table ' . __('Error during the database update', 'room') . $DB->error());
}
Expand All @@ -102,12 +102,12 @@ function plugin_room_install()
if (!$DB->TableExists('glpi_plugin_room_dropdown1s')) {
$query = <<<'EOS'
CREATE TABLE `glpi_plugin_room_dropdown1s` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(255) collate utf8_unicode_ci default NULL,
`comment` text collate utf8_unicode_ci,
`id` int unsigned NOT NULL auto_increment,
`name` varchar(255) collate utf8mb4_unicode_ci default NULL,
`comment` text collate utf8mb4_unicode_ci,
PRIMARY KEY (`id`),
KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
EOS;
$DB->query($query) || die('error adding glpi_plugin_room_roomspecificities table ' . __('Error during the database update', 'room') . $DB->error());
}
Expand All @@ -121,6 +121,7 @@ function plugin_room_uninstall()
{
global $DB;

// Drop plugin tables
$tables = [
'glpi_plugin_room_rooms_computers',
'glpi_plugin_room_roomtypes',
Expand All @@ -133,6 +134,11 @@ function plugin_room_uninstall()
$DB->query("DROP TABLE IF EXISTS `$table`;");
}

// Delete reservations
$DB->query('DELETE FROM `glpi_reservations` WHERE `reservationitems_id` in
(SELECT id FROM `glpi_reservationitems` WHERE `itemtype` = "PluginRoomRoom");');

// Delete logs, items and other things from glpi tables
$tables_glpi = [
'glpi_displaypreferences',
'glpi_documents_items',
Expand All @@ -143,7 +149,7 @@ function plugin_room_uninstall()
];

foreach ($tables_glpi as $table_glpi) {
$DB->query('DELETE FROM `$table_glpi` WHERE `itemtype` = "PluginRoomRoom";');
$DB->query("DELETE FROM `$table_glpi` WHERE `itemtype` = 'PluginRoomRoom';");
}

return true;
Expand Down Expand Up @@ -293,10 +299,10 @@ function plugin_room_getAddSearchOptions($itemtype)

function plugin_room_addSelect($type, $ID, $num)
{
global $SEARCH_OPTION;
$searchopt = &Search::getOptions($type);

$table = $SEARCH_OPTION[$type][$ID]['table'];
$field = $SEARCH_OPTION[$type][$ID]['field'];
$table = $searchopt[$ID]['table'];
$field = $searchopt[$ID]['field'];

// Example of standard Select clause but use it ONLY for specific Select
// No need of the function if you do not have specific cases
Expand Down Expand Up @@ -358,7 +364,8 @@ function plugin_room_MassiveActionsProcess($data)

function plugin_room_AssignToTicket($types)
{
if (in_array('PluginRoomRoom', $_SESSION['glpiactiveprofile']['helpdesk_item_type'])) {
if (isset($_SESSION['glpiactiveprofile']['helpdesk_item_type'])
&& in_array('PluginRoomRoom', $_SESSION['glpiactiveprofile']['helpdesk_item_type'])) {
$types['PluginRoomRoom'] = __('Room Management', 'room');
}
return $types;
Expand Down
3 changes: 2 additions & 1 deletion inc/profile.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,10 @@ public function showForm($profiles_id = 0, $openform = true, $closeform = true)
_sx('button', 'Save'),
[
'name' => 'update',
'class' => 'btn btn-primary',
]
);
echo '</div>\n';
echo "</div>\n";
Html::closeForm();
}
echo '</div>';
Expand Down
Loading