Skip to content

Commit

Permalink
Merge branch 'release/2.6.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-anne committed Sep 4, 2018
2 parents b3ed2b4 + 789d14c commit 98fd31c
Show file tree
Hide file tree
Showing 36 changed files with 691 additions and 194 deletions.
34 changes: 25 additions & 9 deletions datainjection.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
<logo>https://raw.githubusercontent.com/pluginsGLPI/datainjection/master/datainjection.png</logo>
<description>
<short>
<fr><![CDATA[Cette extension permet l'import de données dans GLPI à l'aide de fichiers CSV.]]></fr>
<cs><![CDATA[Tento zásuvný modul umožňuje importovat do GLPI data z CSV souborů.]]></cs>
<en><![CDATA[This plugin allows data import into GLPI using CSV files.]]></en>
<fr><![CDATA[Cette extension permet l'import de données dans GLPI à l'aide de fichiers CSV.]]></fr>
</short>
<long>
<cs><![CDATA[Umožňuje vytváření modelů importu pro budoucí opětovné využití. Byl vytvořen pro:<br /> - import dat pocházejících z jiných softwarů pro správu majetku<br /> - import formulářů elektronického doručení<br />Data k importu pomocí tohoto zásuvného modulu jsou:<br /> - data inventáře (s výjimkou software a licencí)<br /> - správní data (smlouvy, kontakty, dodavatelé)<br /> - data nastavení (uživatel, skupina, entita)]]></cs>
<en><![CDATA[It allows to create models of injection for a future re-use. It's been created in order to:<br /> - import data coming from others asset management softwares<br /> - inject electronic delivery forms<br />Data to be imported using the plugin are:<br /> - inventory data (except softwares and licenses)<br /> - management data (contract, contact, supplier)<br /> - configuration data (user, group, entity)]]></en>
<fr><![CDATA[Elle permet de créer des modèles d’injection pour une réutilisation future et a été créée afin de répondre aux besoins suivants :<br /> - reprise des données d'autres outils d'inventaires<br /> - injection de bons de livraisons électroniques<br />Les données pouvant-être injectées sont :<br /> - données d'inventaires (sauf logiciels et licences)<br /> - données de gestion (contrat, contact, fournisseur)<br /> - données de configuration (utilisateur, groupe, entité)]]></fr>
<en><![CDATA[It allows to create models of injection for a future re-use. It's been created in order to:<br /> - import data coming from others asset management softwares<br /> - inject electronic delivery forms<br />Data to be imported using the plugains are:<br /> - inventory data (except softwares and licenses)<br /> - management data (contract, contact, supplier)<br /> - configuration data (user, group, entity)]]></en>
</long>
</description>
<homepage>http://plugins.glpi-project.org/#/plugin/datainjection</homepage>
Expand All @@ -25,6 +27,10 @@
<author>Xavier Caillaud</author>
</authors>
<versions>
<version>
<num>2.6.2</num>
<compatibility>9.3</compatibility>
</version>
<version>
<num>2.6.1</num>
<compatibility>9.3</compatibility>
Expand Down Expand Up @@ -168,25 +174,35 @@
</version>
</versions>
<langs>
<lang>fr_FR</lang>
<lang>cs_CZ</lang>
<lang>en_GB</lang>
<lang>es_ES</lang>
<lang>ru_RU</lang>
<lang>fi_Fi</lang>
<lang>fr_FR</lang>
<lang>pt_BR</lang>
<lang>tr_TR</lang>
<lang>zh_CN</lang>
</langs>
<category>injection/import</category>
<tags>
<fr>
<tag>Import</tag>
<tag>données</tag>
<cs>
<tag>import</tag>
<tag>data</tag>
<tag>csv</tag>
<tag>entités</tag>
</fr>
<tag>entity</tag>
</cs>
<en>
<tag>Injection</tag>
<tag>data</tag>
<tag>csv</tag>
<tag>entities</tag>
</en>
<fr>
<tag>Import</tag>
<tag>données</tag>
<tag>csv</tag>
<tag>entités</tag>
</fr>
</tags>
<license>GPL v2+</license>
</root>
7 changes: 3 additions & 4 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function plugin_datainjection_install() {
`port_unicity` tinyint( 1 ) NOT NULL DEFAULT '0',
`step` int( 11 ) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci";
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_unicode_ci";
$DB->queryOrDie($query, $DB->error());

$query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_datainjection_modelcsvs` (
Expand All @@ -94,7 +94,7 @@ function plugin_datainjection_install() {
`delimiter` varchar(1) NOT NULL default ';',
`is_header_present` tinyint(1) NOT NULL default '1',
PRIMARY KEY (`ID`)
) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci;";
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->queryOrDie($query, $DB->error());

$query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_datainjection_mappings` (
Expand Down Expand Up @@ -1717,8 +1717,7 @@ function plugin_datainjection_update210_220() {
function plugin_datainjection_update220_230() {
global $DB;

if (countElementsInTable("glpi_plugin_datainjection_models",
"`entities_id`='-1'")) {
if (countElementsInTable("glpi_plugin_datainjection_models", ['entities_id' => -1])) {
$query = "UPDATE `glpi_plugin_datainjection_models`
SET `is_private` = '1',
`entities_id` = '0',
Expand Down
60 changes: 27 additions & 33 deletions inc/commoninjectionlib.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,57 +349,51 @@ static function getBlacklistedOptions($itemtype) {
// 80 : entity
$blacklist = [2, 19, 80, 201, 202, 203, 204];

$raw_options_to_blacklist = [];

//add document fields
if (in_array($itemtype, $CFG_GLPI["document_types"])) {
$tabs = Document::rawSearchOptionsToAdd();
$document_fields = [];
unset($tabs['document']);
foreach ($tabs as $k => $v) {
$document_fields[] = $k;
}

$blacklist = array_merge($blacklist, $document_fields);
$raw_options_to_blacklist = array_merge(
$raw_options_to_blacklist,
Document::rawSearchOptionsToAdd($itemtype)
);
}

//add infocoms fields
if (in_array($itemtype, $CFG_GLPI["infocom_types"])) {
$tabs = Infocom::rawSearchOptionsToAdd($itemtype);
$infocom_fields = [];
unset($tabs['financial']);
foreach ($tabs as $k => $v) {
$infocom_fields[] = $k;
}

$blacklist = array_merge($blacklist, $infocom_fields);
$raw_options_to_blacklist = array_merge(
$raw_options_to_blacklist,
Infocom::rawSearchOptionsToAdd($itemtype)
);
}

//add contract fields
if (in_array($itemtype, $CFG_GLPI["contract_types"])) {
$tabs = Contract::rawSearchOptionsToAdd();
$contract_fields = [];
unset($tabs['contract']);
foreach ($tabs as $k => $v) {
$contract_fields[] = $k;
}

$blacklist = array_merge($blacklist, $contract_fields);
$raw_options_to_blacklist = array_merge(
$raw_options_to_blacklist,
Contract::rawSearchOptionsToAdd($itemtype)
);
}

//add networkport fields
if (in_array($itemtype, $CFG_GLPI["networkport_types"])) {
$tabs = NetworkPort::rawSearchOptionsToAdd($itemtype);
$networkport_fields = [];
unset($tabs['network']);
foreach ($tabs as $k => $v) {
$networkport_fields[] = $k;
}
$raw_options_to_blacklist = array_merge(
$raw_options_to_blacklist,
NetworkPort::rawSearchOptionsToAdd($itemtype)
);
}

$blacklist = array_merge($blacklist, $networkport_fields);
foreach ($raw_options_to_blacklist as $raw_option) {
if (!is_numeric($raw_option['id'])) {
continue;
}
$blacklist[] = $raw_option['id'];
}

//add ticket_types fields
if (in_array($itemtype, $CFG_GLPI["ticket_types"])) {
$ticket_fields = [60, 140];
$blacklist = array_merge($blacklist, $ticket_fields);
$blacklist[] = 60;
$blacklist[] = 140;
}

return $blacklist;
Expand Down
8 changes: 5 additions & 3 deletions inc/devicecaseinjection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ function processAfterInsertOrUpdate($values, $add = true, $rights = []) {

if (!countElementsInTable(
$item->getTable(),
"`$foreign`='".$values[get_parent_class($this)]['id']."'
AND `itemtype`='Computer'
AND `items_id`='".$values['Computer']['id']."'"
[
$foreign => $values[get_parent_class($this)]['id'],
'itemtype' => 'Computer',
'items_id' => $values['Computer']['id'],
]
)) {
$tmp[$foreign] = $values[get_parent_class($this)]['id'];
$tmp['items_id'] = $values['Computer']['id'];
Expand Down
8 changes: 5 additions & 3 deletions inc/devicecontrolinjection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ function processAfterInsertOrUpdate($values, $add = true, $rights = []) {

if (!countElementsInTable(
$item->getTable(),
"`$foreign`='".$values[get_parent_class($this)]['id']."'
AND `itemtype`='Computer'
AND `items_id`='".$values['Computer']['id']."'"
[
$foreign => $values[get_parent_class($this)]['id'],
'itemtype' => 'Computer',
'items_id' => $values['Computer']['id'],
]
)) {
$tmp[$foreign] = $values[get_parent_class($this)]['id'];
$tmp['items_id'] = $values['Computer']['id'];
Expand Down
8 changes: 5 additions & 3 deletions inc/devicedriveinjection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ function processAfterInsertOrUpdate($values, $add = true, $rights = []) {

if (!countElementsInTable(
$item->getTable(),
"`$foreign`='".$values[get_parent_class($this)]['id']."'
AND `itemtype`='Computer'
AND `items_id`='".$values['Computer']['id']."'"
[
$foreign => $values[get_parent_class($this)]['id'],
'itemtype' => 'Computer',
'items_id' => $values['Computer']['id'],
]
)) {
$tmp[$foreign] = $values[get_parent_class($this)]['id'];
$tmp['items_id'] = $values['Computer']['id'];
Expand Down
8 changes: 5 additions & 3 deletions inc/deviceharddriveinjection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ function processAfterInsertOrUpdate($values, $add = true, $rights = []) {

if (!countElementsInTable(
$item->getTable(),
"`$foreign`='".$values[get_parent_class($this)]['id']."'
AND `itemtype`='Computer'
AND `items_id`='".$values['Computer']['id']."'"
[
$foreign => $values[get_parent_class($this)]['id'],
'itemtype' => 'Computer',
'items_id' => $values['Computer']['id'],
]
)) {
$tmp[$foreign] = $values[get_parent_class($this)]['id'];
$tmp['items_id'] = $values['Computer']['id'];
Expand Down
8 changes: 5 additions & 3 deletions inc/devicememoryinjection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@ function processAfterInsertOrUpdate($values, $add = true, $rights = []) {
$item = new $class();
$foreign = getForeignKeyFieldForTable(getTableForItemType(get_parent_class($this)));

$where = "`$foreign`='".$values[get_parent_class($this)]['id']."'
AND `itemtype`='Computer'
AND `items_id`='".$values['Computer']['id']."'";
$where = [
$foreign => $values[get_parent_class($this)]['id'],
'itemtype' => 'Computer',
'items_id' => $values['Computer']['id'],
];

if (!countElementsInTable($item->getTable(), $where)) {

Expand Down
8 changes: 5 additions & 3 deletions inc/devicemotherboardinjection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ function processAfterInsertOrUpdate($values, $add = true, $rights = []) {

if (!countElementsInTable(
$item->getTable(),
"`$foreign`='".$values[get_parent_class($this)]['id']."'
AND `itemtype`='Computer'
AND `items_id`='".$values['Computer']['id']."'"
[
$foreign => $values[get_parent_class($this)]['id'],
'itemtype' => 'Computer',
'items_id' => $values['Computer']['id'],
]
)) {
$tmp[$foreign] = $values[get_parent_class($this)]['id'];
$tmp['items_id'] = $values['Computer']['id'];
Expand Down
8 changes: 5 additions & 3 deletions inc/devicenetworkcardinjection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ function processAfterInsertOrUpdate($values, $add = true, $rights = []) {

if (!countElementsInTable(
$item->getTable(),
"`$foreign`='".$values[get_parent_class($this)]['id']."'
AND `itemtype`='Computer'
AND `items_id`='".$values['Computer']['id']."'"
[
$foreign => $values[get_parent_class($this)]['id'],
'itemtype' => 'Computer',
'items_id' => $values['Computer']['id'],
]
)) {
$tmp[$foreign] = $values[get_parent_class($this)]['id'];
$tmp['items_id'] = $values['Computer']['id'];
Expand Down
8 changes: 5 additions & 3 deletions inc/deviceprocessorinjection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@ function processAfterInsertOrUpdate($values, $add = true, $rights = []) {
$item = new $class();
$foreign = getForeignKeyFieldForTable(getTableForItemType(get_parent_class($this)));

$where = "`$foreign`='".$values[get_parent_class($this)]['id']."'
AND `itemtype`='Computer'
AND `items_id`='".$values['Computer']['id']."'";
$where = [
$foreign => $values[get_parent_class($this)]['id'],
'itemtype' => 'Computer',
'items_id' => $values['Computer']['id'],
];

if (!countElementsInTable($item->getTable(), $where)) {

Expand Down
4 changes: 2 additions & 2 deletions inc/entityinjection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function customimport($input = [], $add = true, $rights = []) {
//Does the entity alread exists ?
$results = getAllDatasFromTable(
'glpi_entities',
"`name`='$name' AND `entities_id`='$parent'"
['name' => $name, 'entities_id' => $parent]
);
//Entity doesn't exists => create it
if (empty($results)) {
Expand All @@ -157,7 +157,7 @@ function customDataAlreadyInDB($injectionClass, $values, $options) {
}
$results = getAllDatasFromTable(
'glpi_entities',
"`completename`='".$values['completename']."'"
['completename' => $values['completename']]
);

if (empty($results)) {
Expand Down
2 changes: 1 addition & 1 deletion inc/info.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ static function showAdditionalInformationsForm(PluginDatainjectionModel $model)

$infos = getAllDatasFromTable(
'glpi_plugin_datainjection_infos',
"`models_id` = '". $model->getField('id')."'"
['models_id' => $model->getField('id')]
);

$table = false;
Expand Down
2 changes: 1 addition & 1 deletion inc/injectiontype.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ static function getUsedMappingsOrInfos($options = []) {
$table = (($p['called_by'] == 'PluginDatainjectionMapping') ?"glpi_plugin_datainjection_mappings"
:"glpi_plugin_datainjection_infos");

$datas = getAllDatasFromTable($table, "`models_id` = '".$mapping_or_info['models_id']."'");
$datas = getAllDatasFromTable($table, ['models_id' => $mapping_or_info['models_id']]);

$injectionClass = PluginDatainjectionCommonInjectionLib::getInjectionClassInstance($p['itemtype']);
$options = $injectionClass->getOptions();
Expand Down
9 changes: 9 additions & 0 deletions inc/model.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,15 @@ static function prepareLogResults($models_id) {
$tmp['item'] = $result[$model->fields['itemtype']];
$url = Toolbox::getItemTypeFormURL($model->fields['itemtype'])."?id=".
$result[$model->fields['itemtype']];
//redefine genericobject url of needed
$plugin = new Plugin();
if ($plugin->isActivated('genericobject')
&& array_key_exists($model->fields['itemtype'], PluginGenericobjectType::getTypes())) {
global $CFG_GLPI;
$url = $CFG_GLPI['root_doc']."/plugins/genericobject/front/object.form.php".
"?itemtype=".$model->fields['itemtype']."&id=".$result[$model->fields['itemtype']];
}

$tmp['url'] = "<a href='".$url."'>".$result[$model->fields['itemtype']]."</a>";
}

Expand Down
8 changes: 5 additions & 3 deletions inc/networknameinjection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,11 @@ function processAfterInsertOrUpdate($values, $add = true, $rights = []) {
if (isset($values['NetworkName']['ipaddresses_id'])) {
if (!countElementsInTable(
"glpi_ipaddresses",
"`items_id`='".$values['NetworkName']['id']."'
AND `itemtype`='NetworkName'
AND `name`='".$values['NetworkName']['ipaddresses_id']."'"
[
'items_id' => $values['NetworkName']['id'],
'itemtype' => 'NetworkName',
'name' => $values['NetworkName']['ipaddresses_id'],
]
)) {

$ip = new IPAddress();
Expand Down
2 changes: 1 addition & 1 deletion inc/profile.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static function addDefaultProfileInfos($profiles_id, $rights) {
foreach ($rights as $right => $value) {
if (!countElementsInTable(
'glpi_profilerights',
"`profiles_id`='$profiles_id' AND `name`='$right'"
['profiles_id' => $profiles_id, 'name' => $right]
)) {
$myright['profiles_id'] = $profiles_id;
$myright['name'] = $right;
Expand Down
6 changes: 4 additions & 2 deletions inc/userinjection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,10 @@ function processAfterInsertOrUpdate($values, $add = true, $rights = []) {

if (!countElementsInTable(
"glpi_useremails",
"`users_id`='".$values['User']['id']."'
AND `email`='".$values['User']['useremails_id']."'"
[
'users_id' => $values['User']['id'],
'email' => $values['User']['useremails_id'],
]
)) {
$useremail = new UserEmail();
$tmp['users_id'] = $values['User']['id'];
Expand Down
Binary file modified locales/cs_CZ.mo
Binary file not shown.
Loading

0 comments on commit 98fd31c

Please sign in to comment.