mirror of
https://github.com/pluginsGLPI/example.git
synced 2025-05-04 18:08:42 +02:00
Create a Camera device (regarding revision 22194 of the GLPI core)
git-svn-id: https://forge.glpi-project.org/svn/example/trunk@219 349b9182-4a13-0410-896f-e5e9767dd1b3
This commit is contained in:
parent
76d6268bf1
commit
19e72b8bab
39
front/devicecamera.form.php
Normal file
39
front/devicecamera.form.php
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* @version $Id$
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
GLPI - Gestionnaire Libre de Parc Informatique
|
||||||
|
Copyright (C) 2003-2011 by the INDEPNET Development Team.
|
||||||
|
|
||||||
|
http://indepnet.net/ http://glpi-project.org
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
LICENSE
|
||||||
|
|
||||||
|
This file is part of GLPI.
|
||||||
|
|
||||||
|
GLPI is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
GLPI is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Original Author of file:
|
||||||
|
// Purpose of file:
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
include ('../../../inc/includes.php');
|
||||||
|
|
||||||
|
$dropdown = new PluginExampleDeviceCamera();
|
||||||
|
include (GLPI_ROOT . "/front/dropdown.common.form.php");
|
||||||
|
?>
|
39
front/devicecamera.php
Normal file
39
front/devicecamera.php
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* @version $Id$
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
GLPI - Gestionnaire Libre de Parc Informatique
|
||||||
|
Copyright (C) 2003-2011 by the INDEPNET Development Team.
|
||||||
|
|
||||||
|
http://indepnet.net/ http://glpi-project.org
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
LICENSE
|
||||||
|
|
||||||
|
This file is part of GLPI.
|
||||||
|
|
||||||
|
GLPI is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
GLPI is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Original Author of file:
|
||||||
|
// Purpose of file:
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
include ('../../../inc/includes.php');
|
||||||
|
|
||||||
|
$dropdown = new PluginExampleDeviceCamera();
|
||||||
|
include (GLPI_ROOT . "/front/dropdown.common.php");
|
||||||
|
?>
|
42
hook.php
42
hook.php
@ -521,6 +521,38 @@ function plugin_example_install() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!TableExists('glpi_plugin_example_devicecameras')) {
|
||||||
|
$query = "CREATE TABLE `glpi_plugin_example_devicecameras` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`designation` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||||
|
`comment` text COLLATE utf8_unicode_ci,
|
||||||
|
`manufacturers_id` int(11) NOT NULL DEFAULT '0',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `designation` (`designation`),
|
||||||
|
KEY `manufacturers_id` (`manufacturers_id`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
|
||||||
|
|
||||||
|
$DB->query($query) or die("error creating glpi_plugin_example_examples ". $DB->error());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!TableExists('glpi_plugin_example_items_devicecameras')) {
|
||||||
|
$query = "CREATE TABLE `glpi_plugin_example_items_devicecameras` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`items_id` int(11) NOT NULL DEFAULT '0',
|
||||||
|
`itemtype` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||||
|
`plugin_example_devicecameras_id` int(11) NOT NULL DEFAULT '0',
|
||||||
|
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
|
||||||
|
`is_dynamic` tinyint(1) NOT NULL DEFAULT '0',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `computers_id` (`items_id`),
|
||||||
|
KEY `plugin_example_devicecameras_id` (`plugin_example_devicecameras_id`),
|
||||||
|
KEY `is_deleted` (`is_deleted`),
|
||||||
|
KEY `is_dynamic` (`is_dynamic`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
|
||||||
|
|
||||||
|
$DB->query($query) or die("error creating glpi_plugin_example_examples ". $DB->error());
|
||||||
|
}
|
||||||
|
|
||||||
// To be called for each task the plugin manage
|
// To be called for each task the plugin manage
|
||||||
// task in class
|
// task in class
|
||||||
CronTask::Register('PluginExampleExample', 'Sample', DAY_TIMESTAMP, array('param' => 50));
|
CronTask::Register('PluginExampleExample', 'Sample', DAY_TIMESTAMP, array('param' => 50));
|
||||||
@ -562,6 +594,14 @@ function plugin_example_uninstall() {
|
|||||||
$query = "DROP TABLE `glpi_plugin_example_dropdowns`;";
|
$query = "DROP TABLE `glpi_plugin_example_dropdowns`;";
|
||||||
$DB->query($query) or die("error deleting glpi_plugin_example_dropdowns");
|
$DB->query($query) or die("error deleting glpi_plugin_example_dropdowns");
|
||||||
}
|
}
|
||||||
|
if (TableExists("glpi_plugin_example_devicecameras")) {
|
||||||
|
$query = "DROP TABLE `glpi_plugin_example_devicecameras`;";
|
||||||
|
$DB->query($query) or die("error deleting glpi_plugin_example_devicecameras");
|
||||||
|
}
|
||||||
|
if (TableExists("glpi_plugin_example_items_devicecameras")) {
|
||||||
|
$query = "DROP TABLE `glpi_plugin_example_items_devicecameras`;";
|
||||||
|
$DB->query($query) or die("error deleting glpi_plugin_example_items_devicecameras");
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -587,7 +627,7 @@ function plugin_example_postinit() {
|
|||||||
global $CFG_GLPI;
|
global $CFG_GLPI;
|
||||||
|
|
||||||
// All plugins are initialized, so all types are registered
|
// All plugins are initialized, so all types are registered
|
||||||
foreach ($CFG_GLPI["infocom_types"] as $type) {
|
foreach (Infocom::getItemtypesThatCanHave() as $type) {
|
||||||
// do something
|
// do something
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
49
inc/devicecamera.class.php
Normal file
49
inc/devicecamera.class.php
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* @version $Id$
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
GLPI - Gestionnaire Libre de Parc Informatique
|
||||||
|
Copyright (C) 2003-2011 by the INDEPNET Development Team.
|
||||||
|
|
||||||
|
http://indepnet.net/ http://glpi-project.org
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
LICENSE
|
||||||
|
|
||||||
|
This file is part of GLPI.
|
||||||
|
|
||||||
|
GLPI is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
GLPI is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Original Author of file:
|
||||||
|
// Purpose of file:
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Class of the defined type
|
||||||
|
|
||||||
|
if (!defined('GLPI_ROOT')) {
|
||||||
|
die("Sorry. You can't access directly to this file");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Class DeviceCamera
|
||||||
|
class PluginExampleDeviceCamera extends CommonDevice {
|
||||||
|
|
||||||
|
static function getTypeName($nb=0) {
|
||||||
|
return _n('Camera', 'Cameras', $nb);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
52
inc/item_devicecamera.class.php
Normal file
52
inc/item_devicecamera.class.php
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* @version $Id$
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
GLPI - Gestionnaire Libre de Parc Informatique
|
||||||
|
Copyright (C) 2003-2011 by the INDEPNET Development Team.
|
||||||
|
|
||||||
|
http://indepnet.net/ http://glpi-project.org
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
LICENSE
|
||||||
|
|
||||||
|
This file is part of GLPI.
|
||||||
|
|
||||||
|
GLPI is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
GLPI is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Original Author of file:
|
||||||
|
// Purpose of file:
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Class of the defined type
|
||||||
|
|
||||||
|
if (!defined('GLPI_ROOT')) {
|
||||||
|
die("Sorry. You can't access directly to this file");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Relation between item and devices
|
||||||
|
**/
|
||||||
|
class PluginExampleItem_DeviceCamera extends Item_Devices {
|
||||||
|
|
||||||
|
static public $itemtype_2 = 'PluginExampleDeviceCamera';
|
||||||
|
static public $items_id_2 = 'plugin_example_devicecameras_id';
|
||||||
|
|
||||||
|
static protected $notable = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
@ -56,6 +56,9 @@ function plugin_init_example() {
|
|||||||
Plugin::registerClass('PluginExampleRuleTestCollection',
|
Plugin::registerClass('PluginExampleRuleTestCollection',
|
||||||
array('rulecollections_types' => true));
|
array('rulecollections_types' => true));
|
||||||
|
|
||||||
|
Plugin::registerClass('PluginExampleDeviceCamera',
|
||||||
|
array('device_types' => true));
|
||||||
|
|
||||||
// Display a menu entry ?
|
// Display a menu entry ?
|
||||||
if (isset($_SESSION["glpi_plugin_example_profile"])) { // Right set in change_profile hook
|
if (isset($_SESSION["glpi_plugin_example_profile"])) { // Right set in change_profile hook
|
||||||
$PLUGIN_HOOKS['menu_toadd']['example'] = array('plugins' => 'PluginExampleExample',
|
$PLUGIN_HOOKS['menu_toadd']['example'] = array('plugins' => 'PluginExampleExample',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user