Skip to content

Commit

Permalink
Merge branch 'release/2.6.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-anne committed Sep 4, 2018
2 parents 6a0dd68 + 83050ac commit 2003590
Show file tree
Hide file tree
Showing 18 changed files with 68 additions and 35 deletions.
14 changes: 14 additions & 0 deletions genericobject.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
<short>
<fr><![CDATA[Faites l'inventaire de nouveaux types d'objets]]></fr>
<en><![CDATA[Do the inventory of new, non-native object types]]></en>
<cs><![CDATA[Inventarizace nových, nenativních typů objektů]]></cs>
</short>
<long>
<fr><![CDATA[Ce plugin vous permet de faire l'inventaire de nouveaux types d'objets génériques, sans avoir à programmer. Generic Objects vous permet de créer ces nouveaux types, les champs disponibles pour ces types. Il est intégré à GLPi dans ses fonctionnalités mère (Helpdesk, réservation, gabarits, etc.). Generic Objects est compatible avec le plugin File Injection permettant l'injection des données.]]></fr>
<en><![CDATA[This plugin allows you to do the inventory of new item types without having to code, it allows you to create those new item types, it allows type creation, manages available fields. Has full integration with the software (Helpdesk, loans, templates, etc.) It has support and connectivity for and with the File Injection plugin]]></en>
<cs><![CDATA[Tento zásuvný modul umožňuje inventarizovat nové typy položek, aniž by bylo třeba programovat. Umožňuje vytvářet tyto nové typy položek, typů a spravovat kolonky, které budou k dispozici. Je plně začleněný do software (Služba podpory, zápůjčky, šablony, atd.) Má podporu a propojení pro a se zásuvným modulem Vkládání dat ze souboru]]></cs>
</long>
</description>
<homepage>https://github.com/pluginsGLPI/genericobject</homepage>
Expand All @@ -22,6 +24,10 @@
<author>Walid Nouh</author>
</authors>
<versions>
<version>
<num>2.6.1</num>
<compatibility>9.3</compatibility>
</version>
<version>
<num>2.6.0</num>
<compatibility>9.3</compatibility>
Expand Down Expand Up @@ -109,6 +115,7 @@
</version>
</versions>
<langs>
<lang>cs_CZ</lang>
<lang>fr_FR</lang>
<lang>en_GB</lang>
<lang>es_AR</lang>
Expand All @@ -129,6 +136,13 @@
<tag>helpdesk</tag>
<tag>loans</tag>
</en>
<cs>
<tag>inventář</tag>
<tag>objekty</tag>
<tag>obecné</tag>
<tag>službapodpory</tag>
<tag>zápůjčky</tag>
</cs>
</tags>
<license>GPL v2+</license>
</root>
13 changes: 6 additions & 7 deletions inc/profile.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ function getProfilesFromDB($id, $config = true) {
global $DB;
$prof_datas = [];
foreach (getAllDatasFromTable(getTableForItemType(__CLASS__),
"`profiles_id`='" . $id . "'") as $prof) {
['profiles_id' => $id]) as $prof) {
if ($prof['right'] != "" || $config) {
$prof_datas[$prof['itemtype']] = $prof['right'];
$prof_datas[$prof['itemtype'].'_open_ticket'] = $prof['open_ticket'];
Expand Down Expand Up @@ -381,8 +381,8 @@ static function install(Migration $migration) {
if (preg_match("/PluginGenericobject(.*)/", $right['itemtype'], $results)) {
$newrightname = 'plugin_genericobject_'.strtolower($results[1]).'s';
if (!countElementsInTable('glpi_profilerights',
"`profiles_id`='".$right['profiles_id']."'
AND `name`='$newrightname'")) {
['profiles_id' => $right['profiles_id'],
'name' => $newrightname])) {
switch ($right['right']) {
case null:
case '':
Expand All @@ -401,8 +401,8 @@ static function install(Migration $migration) {
'rights' => $rightvalue]);

if (!countElementsInTable('glpi_profilerights',
"`profiles_id`='".$right['profiles_id']."'
AND `name`='plugin_genericobject_types'")) {
['profiles_id' => $right['profiles_id'],
'name' => 'plugin_genericobject_types'])) {
$profileRight->add(['profiles_id' => $right['profiles_id'],
'name' => 'plugin_genericobject_types',
'rights' => 23]);
Expand All @@ -428,8 +428,7 @@ static function install(Migration $migration) {
}
//$migration->dropTable('glpi_plugin_genericobject_profiles');
}
if (!countElementsInTable('glpi_profilerights',
"`name` LIKE '%genericobject%'")) {
if (!countElementsInTable('glpi_profilerights', ['name' => ['LIKE', '%genericobject%']])) {
self::createFirstAccess();
}
}
Expand Down
21 changes: 10 additions & 11 deletions inc/type.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function prepareInputForAdd($input) {
$input['name'] = self::filterInput($input['name']);

//Name must not be present in DB
if (countElementsInTable(getTableForItemType(__CLASS__), "`name`='".$input['name']."'")) {
if (countElementsInTable(getTableForItemType(__CLASS__), ['name' => $input['name']])) {
Session::addMessageAfterRedirect(__("A type already exists with the same name", "genericobject"), ERROR, true);
return [];
} else {
Expand Down Expand Up @@ -940,7 +940,7 @@ public static function addTable($itemtype) {
PRIMARY KEY ( `id` ),
KEY `date_mod` (`date_mod`),
KEY `date_creation` (`date_creation`)
) ENGINE = MYISAM COMMENT = '$itemtype' DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
) ENGINE = InnoDB COMMENT = '$itemtype' DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query);

$query = "INSERT INTO `glpi_displaypreferences` (`id`, `itemtype`, `num`, `rank`, `users_id`) " .
Expand Down Expand Up @@ -970,7 +970,7 @@ public static function addItemsTable($itemtype) {
KEY `date_mod` (`date_mod`),
KEY `date_creation` (`date_creation`),
KEY `item` (`itemtype`,`items_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query);
}

Expand Down Expand Up @@ -1249,7 +1249,7 @@ static function checkClassAndFilesForOneItemType($itemtype, $name, $overwrite =
if ($DB->tableExists($table) && ($overwrite || !class_exists($itemtype))) {
self::addNewObject($name, $itemtype, ['add_table' => false,
'create_default_profile' => false,
'add_injection_file' => false,
'add_injection_file' => $overwrite,
'add_language_file' => false,
'overwrite_locales' => $overwrite_locales ]);
}
Expand Down Expand Up @@ -1373,7 +1373,7 @@ public static function addDropdownTable($table, $options = []) {
KEY `date_mod` (`date_mod`),
KEY `date_creation` (`date_creation`),
KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query);
}
if ($params['entities_id']) {
Expand Down Expand Up @@ -1596,7 +1596,7 @@ static function getClassByName($name) {

static function getFamilyNameByItemtype($itemtype) {
$types = getAllDatasFromTable("glpi_plugin_genericobject_types",
"`itemtype`='$itemtype' AND `is_active`='1'");
['itemtype' => $itemtype, 'is_active' => 1]);
if (empty($types)) {
return false;
} else {
Expand Down Expand Up @@ -1642,7 +1642,7 @@ static function getTypes($all = false) {
$table = getTableForItemType(__CLASS__);
if ($DB->tableExists($table)) {
$mytypes = [];
foreach (getAllDatasFromTable($table, (!$all?" is_active=" . self::ACTIVE:""), 'false', 'name') as $data) {
foreach (getAllDatasFromTable($table, (!$all ? ['is_active' => self::ACTIVE] : []), false, 'name') as $data) {
//If class is not present on the filesystem, do not list itemtype
$mytypes[$data['itemtype']] = $data;
}
Expand All @@ -1661,7 +1661,7 @@ static function getTypesByFamily($all = false) {
$table = getTableForItemType(__CLASS__);
if ($DB->tableExists($table)) {
$mytypes = [];
foreach (getAllDatasFromTable($table, (!$all?" is_active=" . self::ACTIVE:"")) as $data) {
foreach (getAllDatasFromTable($table, (!$all ? ['is_active' => self::ACTIVE] : [])) as $data) {
//If class is not present on the filesystem, do not list itemtype
if (file_exists(GENERICOBJECT_CLASS_PATH."/".$data['name'].".class.php")) {
$mytypes[$data['plugin_genericobject_typefamilies_id']][$data['itemtype']] = $data;
Expand Down Expand Up @@ -1981,7 +1981,7 @@ static function install(Migration $migration) {
`linked_itemtypes` text NULL,
`plugin_genericobject_typefamilies_id` INT( 11 ) NOT NULL DEFAULT 0,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM COMMENT = 'Object types definition table' DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
) ENGINE = InnoDB COMMENT = 'Object types definition table' DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query) or die($DB->error());
}

Expand Down Expand Up @@ -2050,8 +2050,7 @@ static function install(Migration $migration) {
14 => 10, 15 => 11];
foreach ($prefs as $num => $rank) {
if (!countElementsInTable("glpi_displaypreferences",
"`itemtype`='".__CLASS__."' AND `num`='$num'
AND `users_id`='0'")) {
['itemtype' => __CLASS__, 'num' => $num, 'users_id' => 0])) {
$preference = new DisplayPreference();
$tmp['itemtype'] = __CLASS__;
$tmp['num'] = $num;
Expand Down
12 changes: 8 additions & 4 deletions inc/typefamily.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static function install(Migration $migration) {
PRIMARY KEY (`id`),
KEY `date_mod` (`date_mod`),
KEY `date_creation` (`date_creation`)
) ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
) ENGINE = InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query) or die($DB->error());
}
}
Expand Down Expand Up @@ -87,8 +87,12 @@ static function getFamilies() {


static function getItemtypesByFamily($families_id) {
return getAllDatasFromTable('glpi_plugin_genericobject_types',
"plugin_genericobject_typefamilies_id='$families_id'
AND is_active='1'");
return getAllDatasFromTable(
'glpi_plugin_genericobject_types',
[
'plugin_genericobject_typefamilies_id' => $families_id,
'is_active' => 1
]
);
}
}
Binary file modified locales/es_ES.mo
Binary file not shown.
2 changes: 1 addition & 1 deletion locales/es_ES.po
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-06-22 13:21+0000\n"
"PO-Revision-Date: 2017-12-13 13:22+0000\n"
"Last-Translator: Alexandre Delaunay <[email protected]>\n"
"Last-Translator: alexandre delaunay <[email protected]>\n"
"Language-Team: Spanish (Spain) (http://www.transifex.com/teclib/glpi-project-plugin-genericobject/language/es_ES/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down
Binary file modified locales/fr_FR.mo
Binary file not shown.
9 changes: 5 additions & 4 deletions locales/fr_FR.po
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# This file is distributed under the same license as the PACKAGE package.
#
# Translators:
# Alexandre Delaunay <[email protected]>, 2017
# alexandre delaunay <[email protected]>, 2017
# Cédric Anne, 2018
# Manu1400 <[email protected]>, 2016
# Johan Cwiklinski <[email protected]>, 2016-2017
# Le Rohellec Benoit <[email protected]>, 2015
Expand All @@ -13,8 +14,8 @@ msgstr ""
"Project-Id-Version: GLPI Plugin - Genericobject\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-06-22 13:21+0000\n"
"PO-Revision-Date: 2017-12-13 13:24+0000\n"
"Last-Translator: Alexandre Delaunay <[email protected]>\n"
"PO-Revision-Date: 2018-07-23 08:33+0000\n"
"Last-Translator: Cédric Anne\n"
"Language-Team: French (France) (http://www.transifex.com/teclib/glpi-project-plugin-genericobject/language/fr_FR/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -109,7 +110,7 @@ msgstr "Famille"

#: inc/type.class.php:466
msgid "Internal identifier"
msgstr "Indentifiant interne"
msgstr "Identifiant interne"

#: inc/type.class.php:520
msgid "Behaviour"
Expand Down
Binary file modified locales/pl_PL.mo
Binary file not shown.
2 changes: 1 addition & 1 deletion locales/pl_PL.po
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-06-22 13:21+0000\n"
"PO-Revision-Date: 2017-12-13 13:22+0000\n"
"Last-Translator: Alexandre Delaunay <[email protected]>\n"
"Last-Translator: alexandre delaunay <[email protected]>\n"
"Language-Team: Polish (Poland) (http://www.transifex.com/teclib/glpi-project-plugin-genericobject/language/pl_PL/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down
Binary file modified locales/pt_BR.mo
Binary file not shown.
2 changes: 1 addition & 1 deletion locales/pt_BR.po
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-06-22 13:21+0000\n"
"PO-Revision-Date: 2017-12-13 13:22+0000\n"
"Last-Translator: Alexandre Delaunay <[email protected]>\n"
"Last-Translator: alexandre delaunay <[email protected]>\n"
"Language-Team: Portuguese (Brazil) (http://www.transifex.com/teclib/glpi-project-plugin-genericobject/language/pt_BR/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down
Binary file modified locales/ro_RO.mo
Binary file not shown.
2 changes: 1 addition & 1 deletion locales/ro_RO.po
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-06-22 13:21+0000\n"
"PO-Revision-Date: 2017-12-13 13:22+0000\n"
"Last-Translator: Alexandre Delaunay <[email protected]>\n"
"Last-Translator: alexandre delaunay <[email protected]>\n"
"Language-Team: Romanian (Romania) (http://www.transifex.com/teclib/glpi-project-plugin-genericobject/language/ro_RO/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down
Binary file modified locales/ru_RU.mo
Binary file not shown.
2 changes: 1 addition & 1 deletion locales/ru_RU.po
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-06-22 13:21+0000\n"
"PO-Revision-Date: 2017-12-13 13:22+0000\n"
"Last-Translator: Alexandre Delaunay <[email protected]>\n"
"Last-Translator: alexandre delaunay <[email protected]>\n"
"Language-Team: Russian (Russia) (http://www.transifex.com/teclib/glpi-project-plugin-genericobject/language/ru_RU/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down
22 changes: 19 additions & 3 deletions objects/objectinjection.class.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,26 @@ class %%INJECTIONCLASS%% extends %%CLASSNAME%%
return $lib->getInjectionResults();
}

/**
* Get search options formatted for injection mapping usage in datainjection plugin.
*
* @return array
*/
function getOptions($primary_type = '') {
$parent = get_parent_class($this);
$parentclass = new $parent();
return $parentclass->getObjectSearchOptions(true);
$plugin = new Plugin();
if (!$plugin->isActivated('datainjection')) {
return [];
}

return PluginDatainjectionCommonInjectionLib::addToSearchOptions(
Search::getOptions(get_parent_class($this)),
[
'ignore_fields' => PluginDatainjectionCommonInjectionLib::getBlacklistedOptions(
get_parent_class($this)
),
],
$this
);
}

}
2 changes: 1 addition & 1 deletion setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
----------------------------------------------------------------------
*/

define ('PLUGIN_GENERICOBJECT_VERSION', '2.6.0');
define ('PLUGIN_GENERICOBJECT_VERSION', '2.6.1');

// Minimal GLPI version, inclusive
define("PLUGIN_GENERICOBJECT_MIN_GLPI", "9.3");
Expand Down

0 comments on commit 2003590

Please sign in to comment.