Skip to content

Commit

Permalink
Merge branch 'release/2.8.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-anne committed Feb 6, 2020
2 parents a94de2d + 7dbcccf commit f8c6587
Show file tree
Hide file tree
Showing 38 changed files with 1,225 additions and 378 deletions.
397 changes: 279 additions & 118 deletions composer.lock

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion genericobject.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
<author>Walid Nouh</author>
</authors>
<versions>
<version>
<num>2.8.0</num>
<compatibility>~9.4.0</compatibility>
<download_url>https://github.com/pluginsGLPI/genericobject/releases/download/2.8.0/glpi-genericobject-2.8.0.tar.bz2</download_url>
</version>
<version>
<num>2.7.0</num>
<compatibility>~9.4.0</compatibility>
Expand Down Expand Up @@ -155,6 +160,6 @@
</tags>
<screenshots>
<screenshot>https://raw.githubusercontent.com/pluginsGLPI/genericobject/master/genericobject.gif</screenshot>
<screenshots>
</screenshots>
<license>GPL v2+</license>
</root>
1 change: 1 addition & 0 deletions inc/field.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ public static function addNewField($table, $field, $after = false) {
case 'bool' :
$query .= "TINYINT (1) NOT NULL DEFAULT '0'";
break;
case 'emptyspace' :
case 'text' :
$query .= "VARCHAR ( 255 ) collate utf8_unicode_ci NOT NULL DEFAULT ''";
break;
Expand Down
72 changes: 69 additions & 3 deletions inc/object.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,60 @@ public function __construct() {
}
}


/**
* Display information on treeview plugin
*
* @params itemtype, id, pic, url, name
*
* @return params
**/
static function showGenericObjectTreeview($params) {
global $CFG_GLPI;

if (array_key_exists($params['itemtype'], PluginGenericobjectType::getTypes())) {
$item = new $params['itemtype']();
if ($item->getFromDB($params['id'])) {
$params['name'] = $item->fields["name"];
$params['url'] = $CFG_GLPI['root_doc']."/plugins/genericobject/front/object.form.php".
"?itemtype=".$params['itemtype']."&id=".$params['id'];
}
}
return $params;
}

/**
* Display node search url on treeview plugin
*
* @params itemtype, id, pic, url, name
*
* @return params
**/
static function getParentNodeSearchUrl($params) {

if (array_key_exists($params['itemtype'], PluginGenericobjectType::getTypes())) {

$item = new $params['itemtype']();
$search = $item->getObjectSearchOptions();

//get searchoption id for location_id
foreach ($search as $key => $val) {
if (isset($val['table']) && $val['table'] === 'glpi_locations') {
$index= $key;
}
}

$token = Session::getNewCSRFToken();

$params['searchurl'] = $params['itemtype']::getSearchURL()."&is_deleted=0&criteria[0][field]=".$index."&criteria[0]".
"[searchtype]=equals&criteria[0][value]=".$params['locations_id']."&search=Rechercher&start=0&_glpi_csrf_token=$token";
return $params;

}

return $params;
}

static function install() {
}

Expand Down Expand Up @@ -160,11 +214,12 @@ static function registerType() {
if (!in_array($class, $CFG_GLPI['asset_types'])) {
array_push($CFG_GLPI['asset_types'], $class);
}
if (!in_array($class, $CFG_GLPI['globalsearch_types'])) {
array_push($CFG_GLPI['globalsearch_types'], $class);
}

if (!in_array($class, $CFG_GLPI['state_types'])) {
array_push($CFG_GLPI['state_types'], $class);
}

if (!in_array($class, $CFG_GLPI['globalsearch_types'])) {
array_push($CFG_GLPI['globalsearch_types'], $class);
}
}
Expand Down Expand Up @@ -522,6 +577,11 @@ function displayField($canedit, $name, $value, $template, $description = []) {
if (!empty($searchoption)
&& !in_array($name, self::getFieldsToHide())) {

if (isset($searchoption['input_type']) && 'emptyspace' === $searchoption['input_type']) {
$searchoption['name'] = "&nbsp;";
$description['Type'] = 'emptyspace';
}

$this->startColumn();
echo $searchoption['name'];
if (isset($searchoption['autoname']) && $searchoption['autoname'] && $template) {
Expand Down Expand Up @@ -600,6 +660,10 @@ function displayField($canedit, $name, $value, $template, $description = []) {
"</textarea>";
break;

case "emptyspace":
echo '&nbsp;';
break;

case "date":
Html::showDateField(
$name, [
Expand Down Expand Up @@ -872,6 +936,8 @@ function rawSearchOptions() {
$option['datatype'] = 'itemlink';
$option['itemlink_type'] = get_called_class();
$option['massiveaction'] = false;
// Enable autocomplete only for name, other fields may contains sensitive data
$option['autocomplete'] = true;
} else {
if (isset($searchoption['datatype']) && $searchoption['datatype'] == 'weblink') {
$option['datatype'] = 'weblink';
Expand Down
22 changes: 22 additions & 0 deletions inc/type.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ function rawSearchOptions() {
'field' => 'name',
'name' => __('Model'),
'datatype' => 'itemlink',
'autocomplete' => true,
];

$sopt[] = [
Expand Down Expand Up @@ -546,7 +547,9 @@ function showBehaviorForm($ID, $options = []) {
"use_plugin_order" => __("order plugin", "genericobject"),
"use_plugin_uninstall" => __("item's uninstallation plugin", "genericobject"),
"use_plugin_simcard" => __("simcard plugin", "genericobject"),
"use_plugin_treeview" => __("treeview plugin", "genericobject"),
];

$plugin = new Plugin();
$odd = 0;
foreach ($use as $right => $label) {
Expand Down Expand Up @@ -654,6 +657,16 @@ function showBehaviorForm($ID, $options = []) {
echo Dropdown::EMPTY_VALUE;
echo "<input type='hidden' name='use_plugin_simcard' value='0'>\n";
}
break;
case 'use_plugin_treeview' :
if ($plugin->isActivated('treeview')) {
Html::showCheckbox(['name' => $right,
'checked' => $this->fields[$right]]);
} else {
echo Dropdown::EMPTY_VALUE;
echo "<input type='hidden' name='use_plugin_treeview' value='0'>\n";
}

break;
case 'use_plugin_geninventorynumber' :
if ($plugin->isActivated('geninventorynumber')) {
Expand Down Expand Up @@ -1901,6 +1914,14 @@ function canUsePluginSimcard() {
return $this->fields['use_plugin_simcard'];
}

function canUsePluginTreeview() {
$plugin = new Plugin();
if (!$plugin->isInstalled("treeview") || !$plugin->isActivated("treeview")) {
return false;
}
return $this->fields['use_plugin_treeview'];
}

function canUsePluginGeninventoryNumber() {
$plugin = new Plugin();
if (!$plugin->isInstalled("geninventorynumber")
Expand Down Expand Up @@ -2001,6 +2022,7 @@ static function install(Migration $migration) {
$migration->addField($table, "linked_itemtypes", "text");
$migration->addField($table, "plugin_genericobject_typefamilies_id", "integer");
$migration->addField($table, "use_plugin_simcard", "bool");
$migration->addField($table, "use_plugin_treeview", "bool");
$migration->migrationOneTable($table);

//If files are missing, recreate them!
Expand Down
Binary file modified locales/cs_CZ.mo
Binary file not shown.
42 changes: 23 additions & 19 deletions locales/cs_CZ.po
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
# This file is distributed under the same license as the PACKAGE package.
#
# Translators:
# Pavel Borecki <[email protected]>, 2018
# Pavel Borecki <[email protected]>, 2018-2019
# Walid Nouh, 2015
msgid ""
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: 2018-06-12 12:43+0000\n"
"POT-Creation-Date: 2020-02-06 15:56+0000\n"
"PO-Revision-Date: 2019-11-09 06:06+0000\n"
"Last-Translator: Pavel Borecki <[email protected]>\n"
"Language-Team: Czech (Czech Republic) (http://www.transifex.com/teclib/glpi-project-plugin-genericobject/language/cs_CZ/)\n"
"MIME-Version: 1.0\n"
Expand All @@ -26,7 +26,7 @@ msgstr "Typ objektů"

#: front/type.form.php:73 front/familylist.php:33 front/familylist.php:41
#: index.php:58 inc/object_item.class.php:109 inc/profile.class.php:39
#: inc/type.class.php:289 inc/type.class.php:415 setup.php:193
#: inc/type.class.php:289 inc/type.class.php:416 setup.php:224
msgid "Objects management"
msgstr "Správa objektů"

Expand Down Expand Up @@ -100,68 +100,72 @@ msgstr "Je třeba, aby typ začínal písmenem"
msgid "A type already exists with the same name"
msgstr "Typ se stejným názvem už existuje"

#: inc/type.class.php:376 inc/type.class.php:505 inc/typefamily.class.php:36
#: inc/type.class.php:377 inc/type.class.php:506 inc/typefamily.class.php:36
msgid "Family of type of objects"
msgstr "Rodina typu objektů"

#: inc/type.class.php:466
#: inc/type.class.php:467
msgid "Internal identifier"
msgstr "Vnitřní identifikátor"

#: inc/type.class.php:520
#: inc/type.class.php:521
msgid "Behaviour"
msgstr "Chování"

#: inc/type.class.php:539
#: inc/type.class.php:540
msgid "Network connections"
msgstr "Síťová připojení"

#: inc/type.class.php:543
#: inc/type.class.php:544
msgid "injection file plugin"
msgstr "zásuvný modul vkládání souborů"

#: inc/type.class.php:545
#: inc/type.class.php:546
msgid "geninventorynumber plugin"
msgstr "zásuvný modul vytváření inventárních čísel"

#: inc/type.class.php:546
#: inc/type.class.php:547
msgid "order plugin"
msgstr "zásuvný modul správa objednávek"

#: inc/type.class.php:547
#: inc/type.class.php:548
msgid "item's uninstallation plugin"
msgstr "zásuvný modul odinstalace položek"

#: inc/type.class.php:548
#: inc/type.class.php:549
msgid "simcard plugin"
msgstr "zásuvný modul sim karty"

#: inc/type.class.php:700
#: inc/type.class.php:550
msgid "treeview plugin"
msgstr "zásuvný modul stromového pohledu"

#: inc/type.class.php:713
msgid "Regenerate files"
msgstr "Znovu vytvořit soubory"

#: inc/type.class.php:713
#: inc/type.class.php:726
msgid "Link to other objects"
msgstr "Propojit s ostatními objekty"

#. TRANS: %1$s is itemtype name
#: inc/type.class.php:2017
#: inc/type.class.php:2039
#, php-format
msgid "Unable to load the class %1$s."
msgstr "Nedaří se načíst třídu %1$s."

#. TRANS: %1$s is itemtype name
#: inc/type.class.php:2019
#: inc/type.class.php:2041
#, php-format
msgid ""
"You probably have garbage data in your database for this plugin and missing "
"files in %1$s"
msgstr "Nejspíš ve své databázi máte pro tento modul v nepořádku data a chybí soubory v %1$s"

#: inc/object.class.php:471
#: inc/object.class.php:526
msgid "Object preview"
msgstr "Náhled objektu"

#: inc/object.class.php:751
#: inc/object.class.php:815
msgid "You must configure rights to enable the preview"
msgstr "Pro zapnutí náhledu je třeba nastavit oprávnění"
Binary file modified locales/en_GB.mo
Binary file not shown.
Loading

0 comments on commit f8c6587

Please sign in to comment.