From 3a60202e1da8167244c6afd43788a62801d79656 Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Tue, 25 Oct 2016 16:54:35 +0200 Subject: [PATCH 01/27] Update readme --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 4fc4fcd8..4f82b971 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,14 @@ Data to be imported using the plugins are: - management data (contract, contact, supplier), - configuration data (user, group, entity). +### Contributing + +* Open a ticket for each bug/feature so it can be discussed +* Follow [development guidelines](http://glpi-developer-documentation.readthedocs.io/en/latest/plugins.html) +* Refer to [GitFlow](http://git-flow.readthedocs.io/) process for branching +* Work on a new branch on your own fork +* Open a PR that will be reviewed by a developer + ## Français Cette extension permet l'injection de données dans [GLPI](http://glpi-project.org) à l'aide de fichiers CSV @@ -27,3 +35,11 @@ Les données pouvant-être injectées sont : - données d'inventaires (sauf logiciels et licences), - données de gestion (contrat, contact, fournisseur), - données de configuration (utilisateur, groupe, entité). + +### Contribuer + +* Ouvrez un ticket pour chaque bogue/fonctionnalité que cela puisse être discuté +* Suivez [les règles de développement](http://glpi-developer-documentation.readthedocs.io/en/latest/plugins.html) +* Référez-vous au processus [GitFlow](http://git-flow.readthedocs.io/) pour gérer les branches +* Travaillez sur une nouvelle branche sur votre fork +* Ouvrez une PR qui sera revue par un développeur From 06dcef1fac43d8758841dc473aa6c726f4a13b41 Mon Sep 17 00:00:00 2001 From: Thierry Bugier Pineau Date: Mon, 23 Jan 2017 10:25:03 +0100 Subject: [PATCH 02/27] load CSS only on pages of the plugin --- setup.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.php b/setup.php index 4c7436d3..36533495 100644 --- a/setup.php +++ b/setup.php @@ -58,7 +58,9 @@ function plugin_init_datainjection() { = array('Profile' => array('PluginDatainjectionProfile', 'purgeProfiles')); // Css file - $PLUGIN_HOOKS['add_css']['datainjection'] = 'css/datainjection.css'; + if (strpos($_SERVER['REQUEST_URI'], "plugins/datainjection") !== false) { + $PLUGIN_HOOKS['add_css']['datainjection'] = 'css/datainjection.css'; + } // Javascript file $PLUGIN_HOOKS['add_javascript']['datainjection'] = 'javascript/datainjection.js'; From e8a0ff9c059fadf5adf797144c8c69de92ec43ed Mon Sep 17 00:00:00 2001 From: Walid Date: Sun, 22 Jan 2017 22:40:24 +0100 Subject: [PATCH 03/27] fix #31 Update headers and plugin's forge URL --- ajax/dropdownChooseField.php | 6 +- ajax/dropdownMandatory.php | 6 +- ajax/dropdownSelectModel.php | 6 +- ajax/injection.php | 6 +- ajax/results.php | 6 +- docs/README.txt | 82 +-- front/clientinjection.form.php | 6 +- front/export.csv.php | 6 +- front/export.pdf.php | 5 +- front/info.form.php | 6 +- front/mapping.form.php | 6 +- front/model.form.php | 6 +- front/model.php | 6 +- front/popup.php | 6 +- hook.php | 4 +- inc/autoupdatesysteminjection.class.php | 6 +- inc/backend.class.php | 6 +- inc/backendcsv.class.php | 4 +- inc/backendinterface.class.php | 6 +- inc/budgetinjection.class.php | 6 +- inc/cartridgeiteminjection.class.php | 6 +- inc/clientinjection.class.php | 6 +- inc/commoninjectionlib.class.php | 6 +- inc/computer_iteminjection.class.php | 6 +- ...omputer_softwarelicenseinjection.class.php | 6 +- ...omputer_softwareversioninjection.class.php | 6 +- inc/computerinjection.class.php | 6 +- inc/computermodelinjection.class.php | 6 +- inc/computertypeinjection.class.php | 8 +- inc/consumableiteminjection.class.php | 6 +- inc/contact_supplierinjection.class.php | 6 +- inc/contactinjection.class.php | 6 +- inc/contacttypeinjection.class.php | 6 +- inc/contract_iteminjection.class.php | 6 +- inc/contract_supplierinjection.class.php | 6 +- inc/contractinjection.class.php | 6 +- inc/contracttypeinjection.class.php | 6 +- inc/data.class.php | 6 +- inc/devicecaseinjection.class.php | 6 +- inc/devicecasetypeinjection.class.php | 6 +- inc/devicecontrolinjection.class.php | 6 +- inc/devicedriveinjection.class.php | 6 +- inc/deviceecasetypeinjection.class.php | 6 +- inc/deviceharddriveinjection.class.php | 6 +- inc/devicememoryinjection.class.php | 6 +- inc/devicememorytypeinjection.class.php | 6 +- inc/devicemotherboardinjection.class.php | 6 +- inc/devicenetworkcardinjection.class.php | 6 +- inc/deviceprocessorinjection.class.php | 6 +- inc/documentinjection.class.php | 6 +- inc/documenttypeinjection.class.php | 6 +- inc/domaininjection.class.php | 6 +- inc/dropdown.class.php | 4 +- inc/engine.class.php | 4 +- inc/entityinjection.class.php | 6 +- inc/filesystemtypeinjection.class.php | 6 +- inc/group_userinjection.class.php | 6 +- inc/groupinjection.class.php | 6 +- inc/info.class.php | 6 +- inc/infocollection.class.php | 6 +- inc/infocominjection.class.php | 6 +- inc/injectioninterface.class.php | 6 +- inc/injectiontype.class.php | 6 +- inc/interfacetypeinjection.class.php | 6 +- inc/itilcategoryinjection.class.php | 6 +- inc/knowbaseitemcategoryinjection.class.php | 6 +- inc/knowbaseiteminjection.class.php | 6 +- inc/locationinjection.class.php | 6 +- inc/manufacturerinjection.class.php | 6 +- inc/mapping.class.php | 4 +- inc/mappingcollection.class.php | 6 +- inc/menu.class.php | 6 +- inc/model.class.php | 4 +- inc/modelcsv.class.php | 4 +- inc/monitorinjection.class.php | 6 +- inc/monitormodelinjection.class.php | 6 +- inc/monitortypeinjection.class.php | 6 +- inc/netpointinjection.class.php | 6 +- ...etworkequipmentfirmwareinjection.class.php | 6 +- inc/networkequipmentinjection.class.php | 6 +- inc/networkequipmentmodelinjection.class.php | 6 +- inc/networkequipmenttypeinjection.class.php | 6 +- inc/networkinjection.class.php | 6 +- inc/networkinterfaceinjection.class.php | 6 +- inc/networknameinjection.class.php | 6 +- inc/networkport_vlaninjection.class.php | 6 +- inc/networkportinjection.class.php | 6 +- inc/operatingsysteminjection.class.php | 6 +- ...ratingsystemservicepackinjection.class.php | 6 +- inc/operatingsystemversioninjection.class.php | 6 +- inc/peripheralinjection.class.php | 6 +- inc/peripheralmodelinjection.class.php | 6 +- inc/peripheraltypeinjection.class.php | 6 +- inc/phoneinjection.class.php | 6 +- inc/phonemodelinjection.class.php | 6 +- inc/phonepowersupplytypeinjection.class.php | 6 +- inc/phonetypeinjection.class.php | 6 +- inc/printerinjection.class.php | 6 +- inc/printermodelinjection.class.php | 6 +- inc/printertypeinjection.class.php | 6 +- inc/profile.class.php | 4 +- inc/profile_userinjection.class.php | 6 +- inc/profileinjection.class.php | 6 +- inc/requesttypeinjection.class.php | 6 +- inc/session.class.php | 6 +- inc/softwareinjection.class.php | 6 +- inc/softwarelicenseinjection.class.php | 6 +- inc/softwarelicensetypeinjection.class.php | 6 +- inc/softwareversioninjection.class.php | 6 +- inc/solutiontemplateinjection.class.php | 6 +- inc/solutiontypeinjection.class.php | 6 +- inc/stateinjection.class.php | 6 +- inc/supplierinjection.class.php | 6 +- inc/suppliertypeinjection.class.php | 6 +- inc/taskcategoryinjection.class.php | 6 +- inc/userinjection.class.php | 6 +- inc/virtualmachinestateinjection.class.php | 6 +- inc/virtualmachinesysteminjection.class.php | 6 +- inc/virtualmachinetypeinjection.class.php | 6 +- inc/vlaninjection.class.php | 6 +- inc/webservice.class.php | 6 +- locales/en_GB.php | 4 +- locales/fr_FR.php | 4 +- locales/pt_BR.php | 6 +- setup.php | 4 +- testwebservice.php | 6 +- tools/move_to_po.php | 613 +++++++++--------- 127 files changed, 713 insertions(+), 711 deletions(-) diff --git a/ajax/dropdownChooseField.php b/ajax/dropdownChooseField.php index 4fe4d8c2..bb563780 100644 --- a/ajax/dropdownChooseField.php +++ b/ajax/dropdownChooseField.php @@ -1,6 +1,6 @@ . - -------------------------------------------------------------------------- - @package datainjection - @author the datainjection plugin team - @copyright Copyright (c) 2010-2011 Order plugin team - @license GPLv2+ - http://www.gnu.org/licenses/gpl.txt - @link https://forge.indepnet.net/projects/datainjection - @link http://www.glpi-project.org/ - @since 2009 - ---------------------------------------------------------------------- */ - -Author :Walid NOUH - -1 - Presentation - -This plugin enables you inject data from CSV files into GLPI. - -Compatibility 0.72 -PHP5 or higher is required ! - -2 - Installation + LICENSE + + This file is part of the datainjection plugin. + + Datainjection plugin 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. + + Datainjection plugin 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 datainjection. If not, see . + -------------------------------------------------------------------------- + @package datainjection + @author the datainjection plugin team + @copyright Copyright (c) 2010-2017 Datainjection plugin team + @license GPLv2+ + http://www.gnu.org/licenses/gpl.txt + @link https://github.com/pluginsGLPI/datainjection + @link http://www.glpi-project.org/ + @since 2009 + ---------------------------------------------------------------------- */ + +Author :Walid NOUH + +1 - Presentation + +This plugin enables you inject data from CSV files into GLPI. + +Compatibility 0.72 +PHP5 or higher is required ! + +2 - Installation RPM are available in Fedora/EPEL repository yum install glpi-data-injection Else - Download the tarball of this plugin - Uncompress it in the plugins directory of your glpi installation - + Download the tarball of this plugin + Uncompress it in the plugins directory of your glpi installation + Once copied in the repertory, go the the "Configuration"->"Plugins"->"File injection" menu, and install the plugin diff --git a/front/clientinjection.form.php b/front/clientinjection.form.php index d6402d68..1877b143 100644 --- a/front/clientinjection.form.php +++ b/front/clientinjection.form.php @@ -1,6 +1,6 @@ \ No newline at end of file +?> diff --git a/inc/consumableiteminjection.class.php b/inc/consumableiteminjection.class.php index 3ba415b2..1c3f16ff 100644 --- a/inc/consumableiteminjection.class.php +++ b/inc/consumableiteminjection.class.php @@ -1,6 +1,6 @@ . - -------------------------------------------------------------------------- - */ - -// ---------------------------------------------------------------------- -// Original Author of file: Julien Dombre -// Purpose of file: -// ---------------------------------------------------------------------- - -chdir(dirname($_SERVER["SCRIPT_FILENAME"])); - -if ($argv) { - for ($i=1 ; $i'.$sing_trans.' '.$current_string_plural.'->'.$plural_trans."\n"; - if (!strlen($sing_trans) || !strlen($plural_trans)) { -// echo "clean\n"; - $sing_trans = ''; - $plural_trans = ''; - } - $content = "msgstr[0] \"$sing_trans\"\n"; - $content .= "msgstr[1] \"$plural_trans\"\n"; - } - } else { - $content=''; - } - } - $context = ''; - } - // Standard replacement - $content = preg_replace('/charset=CHARSET/','charset=UTF-8',$content); - - if (preg_match('/Plural-Forms/',$content)) { - $content = "\"Plural-Forms: nplurals=2; plural=(n != 1)\\n\"\n"; - } - - if (fwrite($po, $content) === FALSE) { - echo "unable to write in po file"; - exit; - } - - } -} -fclose($pot); -fclose($po); - - -function search_in_dict($string, $context) { - global $REFLANG, $LANG; - - if ($context) { - $string = "$context/$string"; - } - - $ponctmatch = "([\.: \(\)]*)"; - $varmatch = "(%s)*"; - - if (preg_match("/$varmatch$ponctmatch(.*)$ponctmatch$varmatch$/U",$string,$reg)) { -// print_r($reg); - $left = $reg[1]; - $left .= $reg[2]; - $string = $reg[3]; - $right = $reg[4]; - if (isset($reg[5])) { - $right .= $reg[5]; - } - } - -// echo $left.' <- '.$string.' -> '.$right."\n"; - foreach ($REFLANG as $mod => $data) { - - foreach ($data as $key => $val) { - - if (!is_array($val)){ - if (!isset($LANG[$mod][$key])) { - continue; - } - - // Search same case with punc - if (strcmp($val,$left.$string.$right) === 0) { - return $LANG[$mod][$key]; - } - // Search same case with punc - if (strcasecmp($val,$left.$string.$right) === 0) { - return $LANG[$mod][$key]; - } - - // Search same case with left punc - if (strcmp($val,$left.$string) === 0) { - return $LANG[$mod][$key].$right; - } - // Search same case with left punc - if (strcasecmp($val,$left.$string) === 0) { - return $LANG[$mod][$key].$right; - } - - // Search same case with right punc - if (strcmp($val,$string.$right) === 0) { - return $left.$LANG[$mod][$key]; - } - // Search same case with right punc - if (strcasecmp($val,$string.$right) === 0) { - return $left.$LANG[$mod][$key]; - } - - // Search same case without punc - if (strcmp($val,$string) === 0) { - return $left.$LANG[$mod][$key].$right; - } - // Search non case sensitive - if (strcasecmp($val,$string) === 0) { - return $left.$LANG[$mod][$key].$right; - } - } else { - //toolbox::logdebug($val); - //toolbox::logdebug($key); - //toolbox::logdebug($mod); - foreach ($val as $k => $v) { - if (!isset($LANG[$mod][$key][$k])) { - continue; - } - - // Search same case with punc - if (strcmp($v,$left.$string.$right) === 0) { - return $LANG[$mod][$key][$k]; - } - // Search same case with punc - if (strcasecmp($v,$left.$string.$right) === 0) { - return $LANG[$mod][$key][$k]; - } - - // Search same case with left punc - if (strcmp($v,$left.$string) === 0) { - return $LANG[$mod][$key][$k].$right; - } - // Search same case with left punc - if (strcasecmp($v,$left.$string) === 0) { - return $LANG[$mod][$key][$k].$right; - } - - // Search same case with right punc - if (strcmp($v,$string.$right) === 0) { - return $left.$LANG[$mod][$key][$k]; - } - // Search same case with right punc - if (strcasecmp($v,$string.$right) === 0) { - return $left.$LANG[$mod][$key][$k]; - } - - // Search same case without punc - if (strcmp($v,$string) === 0) { - return $left.$LANG[$mod][$key][$k].$right; - } - // Search non case sensitive - if (strcasecmp($v,$string) === 0) { - return $left.$LANG[$mod][$key][$k].$right; - } - } - } - } - } - - return ""; -} +. + -------------------------------------------------------------------------- + @package datainjection + @author the datainjection plugin team + @copyright Copyright (c) 2010-2017 Datainjection plugin team + @license GPLv2+ + http://www.gnu.org/licenses/gpl.txt + @link https://github.com/pluginsGLPI/datainjection + @link http://www.glpi-project.org/ + @since 2009 + */ + +// ---------------------------------------------------------------------- +// Original Author of file: Julien Dombre +// Purpose of file: +// ---------------------------------------------------------------------- + +chdir(dirname($_SERVER["SCRIPT_FILENAME"])); + +if ($argv) { + for ($i=1 ; $i'.$sing_trans.' '.$current_string_plural.'->'.$plural_trans."\n"; + if (!strlen($sing_trans) || !strlen($plural_trans)) { +// echo "clean\n"; + $sing_trans = ''; + $plural_trans = ''; + } + $content = "msgstr[0] \"$sing_trans\"\n"; + $content .= "msgstr[1] \"$plural_trans\"\n"; + } + } else { + $content=''; + } + } + $context = ''; + } + // Standard replacement + $content = preg_replace('/charset=CHARSET/','charset=UTF-8',$content); + + if (preg_match('/Plural-Forms/',$content)) { + $content = "\"Plural-Forms: nplurals=2; plural=(n != 1)\\n\"\n"; + } + + if (fwrite($po, $content) === FALSE) { + echo "unable to write in po file"; + exit; + } + + } +} +fclose($pot); +fclose($po); + + +function search_in_dict($string, $context) { + global $REFLANG, $LANG; + + if ($context) { + $string = "$context/$string"; + } + + $ponctmatch = "([\.: \(\)]*)"; + $varmatch = "(%s)*"; + + if (preg_match("/$varmatch$ponctmatch(.*)$ponctmatch$varmatch$/U",$string,$reg)) { +// print_r($reg); + $left = $reg[1]; + $left .= $reg[2]; + $string = $reg[3]; + $right = $reg[4]; + if (isset($reg[5])) { + $right .= $reg[5]; + } + } + +// echo $left.' <- '.$string.' -> '.$right."\n"; + foreach ($REFLANG as $mod => $data) { + + foreach ($data as $key => $val) { + + if (!is_array($val)){ + if (!isset($LANG[$mod][$key])) { + continue; + } + + // Search same case with punc + if (strcmp($val,$left.$string.$right) === 0) { + return $LANG[$mod][$key]; + } + // Search same case with punc + if (strcasecmp($val,$left.$string.$right) === 0) { + return $LANG[$mod][$key]; + } + + // Search same case with left punc + if (strcmp($val,$left.$string) === 0) { + return $LANG[$mod][$key].$right; + } + // Search same case with left punc + if (strcasecmp($val,$left.$string) === 0) { + return $LANG[$mod][$key].$right; + } + + // Search same case with right punc + if (strcmp($val,$string.$right) === 0) { + return $left.$LANG[$mod][$key]; + } + // Search same case with right punc + if (strcasecmp($val,$string.$right) === 0) { + return $left.$LANG[$mod][$key]; + } + + // Search same case without punc + if (strcmp($val,$string) === 0) { + return $left.$LANG[$mod][$key].$right; + } + // Search non case sensitive + if (strcasecmp($val,$string) === 0) { + return $left.$LANG[$mod][$key].$right; + } + } else { + //toolbox::logdebug($val); + //toolbox::logdebug($key); + //toolbox::logdebug($mod); + foreach ($val as $k => $v) { + if (!isset($LANG[$mod][$key][$k])) { + continue; + } + + // Search same case with punc + if (strcmp($v,$left.$string.$right) === 0) { + return $LANG[$mod][$key][$k]; + } + // Search same case with punc + if (strcasecmp($v,$left.$string.$right) === 0) { + return $LANG[$mod][$key][$k]; + } + + // Search same case with left punc + if (strcmp($v,$left.$string) === 0) { + return $LANG[$mod][$key][$k].$right; + } + // Search same case with left punc + if (strcasecmp($v,$left.$string) === 0) { + return $LANG[$mod][$key][$k].$right; + } + + // Search same case with right punc + if (strcmp($v,$string.$right) === 0) { + return $left.$LANG[$mod][$key][$k]; + } + // Search same case with right punc + if (strcasecmp($v,$string.$right) === 0) { + return $left.$LANG[$mod][$key][$k]; + } + + // Search same case without punc + if (strcmp($v,$string) === 0) { + return $left.$LANG[$mod][$key][$k].$right; + } + // Search non case sensitive + if (strcasecmp($v,$string) === 0) { + return $left.$LANG[$mod][$key][$k].$right; + } + } + } + } + } + + return ""; +} ?> \ No newline at end of file From 0e4e066e2aeba91e8ded4ea1ad25dc5cb815a958 Mon Sep 17 00:00:00 2001 From: Walid Date: Sun, 22 Jan 2017 22:44:18 +0100 Subject: [PATCH 04/27] Update forge URL in setup function --- setup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.php b/setup.php index 457e2915..1d86b349 100644 --- a/setup.php +++ b/setup.php @@ -78,7 +78,7 @@ function plugin_version_datainjection() { return array('name' => __('File injection', 'datainjection'), 'minGlpiVersion' => '0.85', 'author' => 'Walid Nouh, Remi Collet, Nelly Mahu-Lasson, Xavier Caillaud', - 'homepage' => 'https://forge.glpi-project.org/projects/datainjection', + 'homepage' => 'https://github.com/pluginsGLPI/datainjection', 'license' => 'GPLv2+', 'version' => '2.4.2' ); From 8e527655ac2dbdfb55cbe981a837be0044c6fd97 Mon Sep 17 00:00:00 2001 From: Walid Date: Sun, 22 Jan 2017 23:09:23 +0100 Subject: [PATCH 05/27] Use transifex for translations --- .tx/config | 8 + RoboFile.php | 13 + RoboFilePlugin.php | 146 +++++++ locales/{glpi.pot => datainjection.pot} | 206 +++++----- locales/en_GB.mo | Bin 7938 -> 0 bytes locales/en_GB.php | 173 -------- locales/en_GB.po | 505 ------------------------ locales/fr_FR.php | 174 -------- locales/pt_BR.php | 173 -------- 9 files changed, 268 insertions(+), 1130 deletions(-) create mode 100644 .tx/config create mode 100644 RoboFile.php create mode 100644 RoboFilePlugin.php rename locales/{glpi.pot => datainjection.pot} (59%) delete mode 100644 locales/en_GB.mo delete mode 100644 locales/en_GB.php delete mode 100644 locales/en_GB.po delete mode 100644 locales/fr_FR.php delete mode 100644 locales/pt_BR.php diff --git a/.tx/config b/.tx/config new file mode 100644 index 00000000..39ae1e99 --- /dev/null +++ b/.tx/config @@ -0,0 +1,8 @@ +[main] +host = https://www.transifex.com + +[glpi-plugins-datainjection.datainjection-243pot] +file_filter = locales/.po +source_file = locales/datainjection.pot +source_lang = en +minimum_perc: 100 diff --git a/RoboFile.php b/RoboFile.php new file mode 100644 index 00000000..047d37ad --- /dev/null +++ b/RoboFile.php @@ -0,0 +1,13 @@ +minifyCSS() + ->minifyJS(); + } + + /** + * Minify CSS stylesheets + * + * @return void + */ + public function minifyCSS() + { + $css_dir = __DIR__ . '/css'; + if (is_dir($css_dir)) { + foreach(glob("$css_dir/*.css") as $css_file) { + if (!$this->endsWith($css_file, 'min.css')) { + $this->taskMinify($css_file) + ->to(str_replace('.css', '.min.css', $css_file)) + ->type('css') + ->run(); + } + } + } + return $this; + } + + /** + * Minify JavaScript files stylesheets + * + * @return void + */ + public function minifyJS() + { + $js_dir = __DIR__ . '/js'; + if (is_dir($js_dir)) { + foreach(glob("$js_dir/*.js") as $js_file) { + if (!$this->endsWith($js_file, 'min.js')) { + $this->taskMinify($js_file) + ->to(str_replace('.js', '.min.js', $js_file)) + ->type('js') + ->run(); + } + } + } + return $this; + } + + /** + * Extract translatable strings + * + * @return void + */ + public function localesExtract() + { + $this->_exec('tools/extract_template.sh'); + return $this; + } + + /** + * Push locales to transifex + * + * @return void + */ + public function localesPush() + { + $this->_exec('tx push -s'); + return $this; + } + + /** + * Pull locales from transifex. + * + * @return void + */ + public function localesPull($percent = 70) + { + $this->_exec('tx pull -a --minimum-perc=' .$percent); + return $this; + } + + /** + * Build MO files + * + * @return void + */ + public function localesMo() + { + $this->_exec('./tools/release --compile-mo'); + return $this; + } + + /** + * Extract and send locales + * + * @return void + */ + public function localesSend() + { + $this->localesExtract() + ->localesPush(); + return $this; + } + + /** + * Retrieve locales and generate mo files + * + * @return void + */ + public function localesGenerate($percent = 70) { + $this->localesPull($percent) + ->localesMo(); + return $this; + } + + /** + * Checks if a string ends with another string + * + * @param string $haystack Full string + * @param string $needle Ends string + * + * @return boolean + * @see http://stackoverflow.com/a/834355 + */ + private function endsWith($haystack, $needle) { + $length = strlen($needle); + if ($length == 0) { + return true; + } + + return (substr($haystack, -$length) === $needle); + } +} diff --git a/locales/glpi.pot b/locales/datainjection.pot similarity index 59% rename from locales/glpi.pot rename to locales/datainjection.pot index aeefae72..ba9d0b0d 100644 --- a/locales/glpi.pot +++ b/locales/datainjection.pot @@ -1,14 +1,14 @@ # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR Datainjection Development Team -# This file is distributed under the same license as the PACKAGE package. +# This file is distributed under the same license as the GLPI - Datainjection plugin package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" -"Project-Id-Version: GLPI - Datainjection plugin 2.2.0\n" +"Project-Id-Version: GLPI - Datainjection plugin 2.3.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-07-17 16:10+0200\n" +"POT-Creation-Date: 2017-01-22 22:57+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -18,26 +18,17 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" -#: hook.php:120 hook.php:134 +#: hook.php:115 hook.php:129 setup.php:50 msgid "Can't create folder" msgstr "" -#: setup.php:52 setup.php:132 -#, php-format -msgid "%s must exists and be writable for web server user" -msgstr "" - -#: setup.php:58 setup.php:59 inc/clientinjection.class.php:194 -msgid "Injection of the file" -msgstr "" - -#: setup.php:103 front/clientinjection.form.php:33 inc/profile.class.php:71 -#: inc/profile.class.php:141 +#: setup.php:76 front/clientinjection.form.php:33 inc/menu.class.php:36 +#: inc/profile.class.php:64 msgid "File injection" msgstr "" -#: setup.php:137 -msgid "This plugin requires GLPI >= 0.84" +#: setup.php:89 +msgid "This plugin requires GLPI 0.85 or higher" msgstr "" #: front/clientinjection.form.php:47 @@ -60,143 +51,148 @@ msgid "" "asked for theses informations while using the model." msgstr "" -#: front/popup.php:37 inc/mapping.class.php:118 +#: front/popup.php:37 inc/mapping.class.php:109 msgid "See the file" msgstr "" -#: front/popup.php:43 inc/model.class.php:1357 +#: front/popup.php:43 inc/model.class.php:1350 msgid "File injection report" msgstr "" -#: inc/clientinjection.class.php:78 +#: inc/clientinjection.class.php:81 msgid "Use an existing model" msgstr "" -#: inc/clientinjection.class.php:86 +#: inc/clientinjection.class.php:89 msgid "No model currently available" msgstr "" -#: inc/clientinjection.class.php:90 +#: inc/clientinjection.class.php:95 msgid "You can start the model creation by hitting the button" msgstr "" -#: inc/clientinjection.class.php:135 inc/dropdown.class.php:86 -#: inc/model.class.php:659 +#: inc/clientinjection.class.php:140 inc/dropdown.class.php:86 +#: inc/model.class.php:652 msgid "File to inject" msgstr "" -#: inc/clientinjection.class.php:138 inc/info.class.php:241 +#: inc/clientinjection.class.php:143 inc/info.class.php:232 msgid "Choose a file" msgstr "" -#: inc/clientinjection.class.php:144 +#: inc/clientinjection.class.php:149 msgid "File encoding" msgstr "" -#: inc/clientinjection.class.php:152 +#: inc/clientinjection.class.php:157 msgid "Warning : existing data will be overridden" msgstr "" -#: inc/clientinjection.class.php:154 +#: inc/clientinjection.class.php:159 msgid "" -"Watch out, you're about to inject datas into GLPI. Are you sure you want to " +"Watch out, you're about to inject data into GLPI. Are you sure you want to " "do it ?" msgstr "" -#: inc/clientinjection.class.php:160 +#: inc/clientinjection.class.php:165 msgid "Launch the import" msgstr "" -#: inc/clientinjection.class.php:190 +#: inc/clientinjection.class.php:195 msgid "Import progress" msgstr "" -#: inc/clientinjection.class.php:253 +#: inc/clientinjection.class.php:199 inc/menu.class.php:52 +#: inc/menu.class.php:53 inc/profile.class.php:41 +msgid "Injection of the file" +msgstr "" + +#: inc/clientinjection.class.php:258 #, php-format msgid "Injection of the file... %d%%" msgstr "" -#: inc/clientinjection.class.php:264 +#: inc/clientinjection.class.php:269 msgid "Injection finished" msgstr "" -#: inc/clientinjection.class.php:334 +#: inc/clientinjection.class.php:338 msgid "Injection's results" msgstr "" -#: inc/clientinjection.class.php:339 +#: inc/clientinjection.class.php:343 msgid "Injection successful" msgstr "" -#: inc/clientinjection.class.php:342 +#: inc/clientinjection.class.php:346 msgid "Injection encounters errors" msgstr "" -#: inc/clientinjection.class.php:351 +#: inc/clientinjection.class.php:355 msgid "See the log" msgstr "" -#: inc/clientinjection.class.php:357 +#: inc/clientinjection.class.php:361 msgid "Export rapport in PDF" msgstr "" -#: inc/clientinjection.class.php:363 +#: inc/clientinjection.class.php:367 msgid "Export the log" msgstr "" -#: inc/clientinjection.class.php:371 +#: inc/clientinjection.class.php:375 msgid "Finish" msgstr "" -#: inc/commoninjectionlib.class.php:1815 +#: inc/commoninjectionlib.class.php:1817 msgid "Add from CSV file" msgstr "" -#: inc/commoninjectionlib.class.php:1817 +#: inc/commoninjectionlib.class.php:1819 msgid "Update from CSV file" msgstr "" -#: inc/commoninjectionlib.class.php:1858 +#: inc/commoninjectionlib.class.php:1860 msgid "No right to import data" msgstr "" -#: inc/commoninjectionlib.class.php:1862 +#: inc/commoninjectionlib.class.php:1864 msgid "No right to update data" msgstr "" -#: inc/commoninjectionlib.class.php:1866 +#: inc/commoninjectionlib.class.php:1868 msgid "Size of the inserted value is to expansive" msgstr "" -#: inc/commoninjectionlib.class.php:1870 +#: inc/commoninjectionlib.class.php:1872 msgid "Import not allowed" msgstr "" -#: inc/commoninjectionlib.class.php:1874 +#: inc/commoninjectionlib.class.php:1876 msgid "Import failed" msgstr "" -#: inc/commoninjectionlib.class.php:1878 +#: inc/commoninjectionlib.class.php:1880 msgid "At least one mandatory field is not present" msgstr "" -#: inc/commoninjectionlib.class.php:1882 -msgid "Datas to insert are correct" +#: inc/commoninjectionlib.class.php:1884 +msgid "Data to insert are correct" msgstr "" -#: inc/commoninjectionlib.class.php:1886 +#: inc/commoninjectionlib.class.php:1888 msgid "One data is not the good type" msgstr "" -#: inc/commoninjectionlib.class.php:1890 +#: inc/commoninjectionlib.class.php:1892 msgid "Warning" msgstr "" -#: inc/commoninjectionlib.class.php:1894 +#: inc/commoninjectionlib.class.php:1896 msgid "Data not found" msgstr "" -#: inc/commoninjectionlib.class.php:1898 inc/model.class.php:1222 +#: inc/commoninjectionlib.class.php:1900 inc/model.class.php:1215 msgid "Undetermined" msgstr "" @@ -224,11 +220,11 @@ msgstr "" msgid "1,234.56" msgstr "" -#: inc/dropdown.class.php:87 inc/model.class.php:660 +#: inc/dropdown.class.php:87 inc/model.class.php:654 msgid "Mappings" msgstr "" -#: inc/dropdown.class.php:88 inc/model.class.php:663 +#: inc/dropdown.class.php:88 inc/model.class.php:657 msgid "Additional Information" msgstr "" @@ -248,23 +244,23 @@ msgstr "" msgid "ISO8859-1" msgstr "" -#: inc/info.class.php:87 inc/info.class.php:143 inc/mapping.class.php:125 +#: inc/info.class.php:78 inc/info.class.php:134 inc/mapping.class.php:116 msgid "Tables" msgstr "" -#: inc/info.class.php:89 inc/info.class.php:145 +#: inc/info.class.php:80 inc/info.class.php:136 msgid "Mandatory information" msgstr "" -#: inc/info.class.php:144 +#: inc/info.class.php:135 msgid "Fields" msgstr "" -#: inc/info.class.php:240 +#: inc/info.class.php:231 msgid "Complementary information" msgstr "" -#: inc/info.class.php:249 +#: inc/info.class.php:240 msgid "Download file sample" msgstr "" @@ -276,171 +272,171 @@ msgstr "" msgid "-------Choose a field-------" msgstr "" -#: inc/mapping.class.php:124 +#: inc/mapping.class.php:115 msgid "Header of the file" msgstr "" -#: inc/mapping.class.php:127 +#: inc/mapping.class.php:118 msgid "Link field" msgstr "" -#: inc/model.class.php:71 +#: inc/model.class.php:73 inc/profile.class.php:38 msgid "Model management" msgstr "" -#: inc/model.class.php:348 inc/model.class.php:568 +#: inc/model.class.php:339 inc/model.class.php:558 msgid "Allow lines creation" msgstr "" -#: inc/model.class.php:354 inc/model.class.php:571 +#: inc/model.class.php:345 inc/model.class.php:561 msgid "Allow lines update" msgstr "" -#: inc/model.class.php:360 inc/model.class.php:556 -msgid "Type of datas to import" +#: inc/model.class.php:351 inc/model.class.php:546 +msgid "Type of data to import" msgstr "" -#: inc/model.class.php:367 inc/model.class.php:580 +#: inc/model.class.php:358 inc/model.class.php:570 msgid "Allow creation of dropdowns" msgstr "" -#: inc/model.class.php:372 inc/model.class.php:584 +#: inc/model.class.php:363 inc/model.class.php:574 msgid "Dates format" msgstr "" -#: inc/model.class.php:378 inc/model.class.php:595 +#: inc/model.class.php:369 inc/model.class.php:585 msgid "Float format" msgstr "" -#: inc/model.class.php:384 inc/model.class.php:602 +#: inc/model.class.php:375 inc/model.class.php:592 msgid "Try to establish network connection is possible" msgstr "" -#: inc/model.class.php:390 inc/model.class.php:606 +#: inc/model.class.php:381 inc/model.class.php:596 msgid "Port unicity criteria" msgstr "" -#: inc/model.class.php:576 +#: inc/model.class.php:566 msgid "Advanced options" msgstr "" -#: inc/model.class.php:591 +#: inc/model.class.php:581 msgid "Allow update of existing fields" msgstr "" -#: inc/model.class.php:630 +#: inc/model.class.php:620 msgctxt "button" msgid "Validate the model" msgstr "" -#: inc/model.class.php:691 +#: inc/model.class.php:685 msgid "Load this file" msgstr "" -#: inc/model.class.php:769 +#: inc/model.class.php:763 msgid "Please enter a name for the model" msgstr "" -#: inc/model.class.php:775 +#: inc/model.class.php:769 msgid "Your model should allow import and/or update of data" msgstr "" -#: inc/model.class.php:797 +#: inc/model.class.php:791 msgid "You are not the initial creator of this model" msgstr "" -#: inc/model.class.php:858 +#: inc/model.class.php:851 #, php-format msgid "Impossible to copy the file in %s" msgstr "" -#: inc/model.class.php:865 +#: inc/model.class.php:858 msgid "File format is wrong" msgstr "" -#: inc/model.class.php:866 +#: inc/model.class.php:859 msgid "Extension csv required" msgstr "" -#: inc/model.class.php:940 +#: inc/model.class.php:933 msgid "Not data to import" msgstr "" -#: inc/model.class.php:993 +#: inc/model.class.php:986 msgid "The file is ok." msgstr "" -#: inc/model.class.php:1016 +#: inc/model.class.php:1009 msgid "The number of columns of the file is incorrect." msgstr "" -#: inc/model.class.php:1017 +#: inc/model.class.php:1010 #, php-format msgid "%d awaited column" msgid_plural "%d awaited columns" msgstr[0] "" msgstr[1] "" -#: inc/model.class.php:1019 +#: inc/model.class.php:1012 #, php-format msgid "%d found column" msgid_plural "%d found columns" msgstr[0] "" msgstr[1] "" -#: inc/model.class.php:1053 +#: inc/model.class.php:1046 msgid "At least one column is incorrect" msgstr "" -#: inc/model.class.php:1060 +#: inc/model.class.php:1053 msgid "Into the file" msgstr "" -#: inc/model.class.php:1063 +#: inc/model.class.php:1056 msgid "From the model" msgstr "" -#: inc/model.class.php:1285 inc/model.class.php:1364 +#: inc/model.class.php:1278 inc/model.class.php:1357 msgid "Array of successful injections" msgstr "" -#: inc/model.class.php:1292 inc/model.class.php:1322 inc/model.class.php:1367 -#: inc/model.class.php:1385 +#: inc/model.class.php:1285 inc/model.class.php:1315 inc/model.class.php:1360 +#: inc/model.class.php:1378 msgid "Line" msgstr "" -#: inc/model.class.php:1293 inc/model.class.php:1324 inc/model.class.php:1368 -#: inc/model.class.php:1387 +#: inc/model.class.php:1286 inc/model.class.php:1317 inc/model.class.php:1361 +#: inc/model.class.php:1380 msgid "Data Import" msgstr "" -#: inc/model.class.php:1294 inc/model.class.php:1325 inc/model.class.php:1369 -#: inc/model.class.php:1388 +#: inc/model.class.php:1287 inc/model.class.php:1318 inc/model.class.php:1362 +#: inc/model.class.php:1381 msgid "Injection type" msgstr "" -#: inc/model.class.php:1295 inc/model.class.php:1326 inc/model.class.php:1370 -#: inc/model.class.php:1389 +#: inc/model.class.php:1288 inc/model.class.php:1319 inc/model.class.php:1363 +#: inc/model.class.php:1382 msgid "Object Identifier" msgstr "" -#: inc/model.class.php:1315 inc/model.class.php:1382 +#: inc/model.class.php:1308 inc/model.class.php:1375 msgid "Array of unsuccessful injections" msgstr "" -#: inc/model.class.php:1323 inc/model.class.php:1386 inc/model.class.php:1400 +#: inc/model.class.php:1316 inc/model.class.php:1379 inc/model.class.php:1393 msgid "Data check" msgstr "" -#: inc/modelcsv.class.php:158 +#: inc/modelcsv.class.php:149 msgid "Specific file format options" msgstr "" -#: inc/modelcsv.class.php:161 +#: inc/modelcsv.class.php:152 msgid "Header's presence" msgstr "" -#: inc/modelcsv.class.php:165 +#: inc/modelcsv.class.php:156 msgid "File delimitor" msgstr "" diff --git a/locales/en_GB.mo b/locales/en_GB.mo deleted file mode 100644 index 56ede5bf43eaf77541d9be9fb6feacbc9c59a3d9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7938 zcmeH~TWlOx8OKj)Db(T8E6@w&01Zi+?8eSL>)c!?PEGB^#CF=!Htl$4Y)?Epvz?0_ zM+N1jl)@7TkSf|LDuRbrJRtHwrGNxNswxm5f#9J~fmF3cYCz(lRmJu9pE=CKRo?c7;_68fEFHyTi_B@|EC?F zgYTvMlH&!(*Wp#v{~LY?Ue#yJm2f@05$=Z9!fALlJPAJrKL>AyPe2RLJN^M~r2H>< z4ZL+t#eMMol#jvd;RBFAbDAHznlHc)z^_2*JqzCl&qL{d-nG97ucLgyl`o}})_paU zNj5;u(+{O@Kh*efS3d(a{y|rM1ZvzjAb;iwSN}BBexHT1&(9$yGA}~S`>Jby9e$AV z6;ys4UJteYL8$R}Lg_mRKMK!4t>;Oob$%bpPCtSCncwmweJ{bw;OkKK`8!nq%lXlK z*FpJnBm6Mj2IaRgNLO
    Zl8`xhP0LapluQ0x8~l)e|B)^`C;z%?{#KleI*9%}xx zQ2M_I*}8cS;tKN{cq{xPl-@OTmR;9F*<&-L$=m@q!+W6S|1vxSzw7GjEJph|0pAT5 zq4YciWw%G6^gjvT1J6O}Jr5`0E3gI!+2jrwLhb7;)Vh8Ix4{>n;_yn0FZmF#~X~%EEjg-$rmS$dc{0EfZuf%xT*UeCV*#)(~gAmu6qfmNJK-u*) zl>SFt`{R%$nP*)2$B?Pbub}+-imU$%l)isLjbHPTYJLkfezPkdf*LmkrSBeBKM%Fv zB`EuR3F>@34mIz0T>CkwxOomLUVaC){x@Cwb!=Ap)4HSgD; z^gRW2zRp3}=UJ%!KZTm_*HHfaGh~bAZ%}^gyP=xrMkxPpfNCFcJOQ<@MW}T@3Z?Hc zsP#PqC*bo?`?-P5hRGdEvrT2L#yS@zhGZ*-gzAI?d`MMrz z-cfi4F1Y&Fpw@d6i_!Vo2BoI~Ww*mn`tOB0Un!K{({K`g8`j{Pa0gsRkn(CyK&Cbi z!ENv{C_DTD%D#Vce9iF3+a92J3Yq``E@UH2pLA^kp)C{RcwwRQ;43=Rxk&k{H|xV zLiua?mEZNe3sFq!kq`UJH_oPG1oyf3L8v(M5S^oGdn3hN=qu*|=8SEraKUF-k}R;EoehJ?ca;}4meX_^2ke%u+cs_AVak`fUN%vqmm!~(rb){V zPabE+C{Rt9he_;3b~I)kEl(w?7rnU2rjxeHnHh?rWXU$uplr9vto75R?I%m!wkV8) ztlPs4s49!L@8#$!=co#rp|nOA&sBRvN1A%eYRHOaGsv>pBC=t8GHALbbefC!9XjMT z3Ovl5#DVjc4Kt=_CTYqnW~jGA3om$ik}g;3)iX|V+fIWli0ND8iHy;-evns7FvDKF zF0ZyIr$s(~>TwX}98Oy8C}=T($HZZeMGtzpXGdG@B+X6v-kcAb3)QRimH|^1Gn*$2 zB?xlsrP@igdPZU3%17oPmX8t-cj85xc~WZ*#d(-7+ag|wX*P#WNt;c*cF8cd69-2+ zwfTHtqhyX^9>f_ww#{tOron?nmZiUIcYaa&cY)+6gJrAeo< z>$R#+x5)gZ0m^C1UCO(3io=vGzhGUu{p zU`8j8?%K6|cWuB_hPJaF>-Re)nb}heu2i+tWDbXCWtS`qbsAY$Gifh(72ylJmL8o* zv@$>u=Rum;AWf6Bw{5oEiWGFa_pbSEYwPv8UF)x1+cRb*zyC zIa0J{s)$fXW#;INV#$vB=nBb}sX0m-(CE(5mWAe$gssbvY9&26n^gIkq?`p2(*%CQ zhPhn|qez*W?J|nE(3!O%$xqXI5$Vuhc3Hig@Ewv0W>y?dC_M$l53xf^kG)ov`&Ytz zLI-wyXxMtbU&duwQN&?W2fN7!BS=HfOa_E$=NxnjI?a>e>7a8+suaS)7rm$mWCV5) zoN9X<_r<_Wwu2^iYE~J<9pg^ApOU9DGv#z}Ad1K@^CQ-%QdPH&iIatT**EU`r21IW zvT|Uxf^IHWf6DEsnB#c4w3FGxV-urx-(K5a-?gpkk>x?VI<=WyP73V-+w`W^x8!Xd z){bTB_U@!uS9#FO7O(`nRBJ{a?Fn^K*Szvvk?CWk(PhqIiR5tEEYtUu3}xdWUrN#i z%n`@cH$j_fCspP!Q^b{atmvq+cy<1!r$%bK%yg_TN!sEt`ewTPB>vaOcv@fjc;&lT zrM^48G*-HGw2hSxWf*pXG~w=$hCcC6*PINH6!|9EY#kpFZ-$aK6PEeIEiqK$kj?9M zh)%L^R=AfXFD?i8jLGeOgDuO?k+P_4M54<>t_|g#0K1l+#v0Y4)w{`FFdY%ywQ2W$ zU}u)?e3<7Qi_a8!&b`A8D>HR@2Vf|3>PY9y@6_7Wn7WLU&6nX?=6YM@K;5}Ev&xm* zhiqpmwU-_DqL6ZRsH*9Fzt(EimU#@MRKDs*^*)C=O_XqIqkio;p8~$1jVgR=_8?PN zcGh>*#rT%`)_Q;6vGN008_(uKzjj+Om(`|{hV7d;I#nBXm#Z4XgNEJGKd`mdzq2;5 z(+=!t4D@g8-_qYt$J()AF_gNu>9?~nuzO?w0R6_e2i2xh&U&OvPQ%{iEs_)M@X+Yk z*wFMryC=_D=>Z%g)@Rdw42kCoa(Qhk@LCN!Hgx3h^w8l$cF)+@fhepe>D<1)@zL=^ zE887lL&FK#EJhcx->`XbD&O3W*!>{M(o3@--&;oiNHb`rS+%=+Mcg=)(S9^mq zasSA%zKN(vy{IAmn$_ETc`L6j>Ye-j>g|2?_D+Uby}if17nqg1cW>?L?Ok`)@@v|At6#mn Y^Izra?S1w3zIuEAzun&dmuvff0G8fMb^rhX diff --git a/locales/en_GB.php b/locales/en_GB.php deleted file mode 100644 index 986d8f35..00000000 --- a/locales/en_GB.php +++ /dev/null @@ -1,173 +0,0 @@ -. - -------------------------------------------------------------------------- - @package datainjection - @author the datainjection plugin team - @copyright Copyright (c) 2010-2017 Datainjection plugin team - @license GPLv2+ - http://www.gnu.org/licenses/gpl.txt - @link https://github.com/pluginsGLPI/datainjection - @link http://www.glpi-project.org/ - @since 2009 - ---------------------------------------------------------------------- */ - -$LANG['datainjection']['name'][1] = "File injection"; - -$LANG['datainjection']['choiceStep'][6] = "Use an existing model"; - -$LANG['datainjection']['model'][4] = "Type of datas to import"; -$LANG['datainjection']['model'][5] = "Type of file"; -$LANG['datainjection']['model'][6] = "Allow lines creation"; -$LANG['datainjection']['model'][7] = "Allow lines update"; -$LANG['datainjection']['model'][8] = "Allow creation of dropdowns"; -$LANG['datainjection']['model'][9] = "Header's presence"; -$LANG['datainjection']['model'][10] = "File delimitor"; -$LANG['datainjection']['model'][12] = "Allow update of existing fields"; -$LANG['datainjection']['model'][15] = "Advanced options"; -$LANG['datainjection']['model'][18] = "Private"; -$LANG['datainjection']['model'][20] = "Try to establish network connection is possible"; -$LANG['datainjection']['model'][21] = "Dates format"; -$LANG['datainjection']['model'][22] = "dd-mm-yyyy"; -$LANG['datainjection']['model'][23] = "mm-dd-yyyy"; -$LANG['datainjection']['model'][24] = "yyyy-mm-dd"; -$LANG['datainjection']['model'][25] = "1 234.56"; -$LANG['datainjection']['model'][26] = "1 234,56"; -$LANG['datainjection']['model'][27] = "1,234.56"; -$LANG['datainjection']['model'][28] = "Float format"; -$LANG['datainjection']['model'][29] = "Specific file format options"; -$LANG['datainjection']['model'][30] = "Please enter a name for the model"; -$LANG['datainjection']['model'][31] = "Your model should allow import and/or update of data”"; -$LANG['datainjection']['model'][32] = "The file is ok.". - "
    You can start doing the mapping with GLPI fields”"; -$LANG['datainjection']['model'][33] = "No model currently available"; -$LANG['datainjection']['model'][34] = "You can start the model creation by hitting the button"; -$LANG['datainjection']['model'][35] = "Creation of the model on going"; -$LANG['datainjection']['model'][36] = "Model available for use"; -$LANG['datainjection']['model'][37] = "Validation"; -$LANG['datainjection']['model'][38] = "Validate the model"; -$LANG['datainjection']['model'][39] = "List of the models"; -$LANG['datainjection']['model'][40] = "Download file sample"; - -$LANG['datainjection']['fileStep'][3] = "Choose a file"; -$LANG['datainjection']['fileStep'][4] = "The file could not be found"; -$LANG['datainjection']['fileStep'][5] = "File format is wrong"; -$LANG['datainjection']['fileStep'][6] = "Extension"; -$LANG['datainjection']['fileStep'][7] = "required"; -$LANG['datainjection']['fileStep'][8] = "Impossible to copy the file in"; -$LANG['datainjection']['fileStep'][9] = "File encoding"; -$LANG['datainjection']['fileStep'][10] = "Automatic detection"; -$LANG['datainjection']['fileStep'][11] = "UTF-8"; -$LANG['datainjection']['fileStep'][12] = "ISO8859-1"; -$LANG['datainjection']['fileStep'][13] = "Load this file"; - -$LANG['datainjection']['mapping'][2] = "Header of the file"; -$LANG['datainjection']['mapping'][3] = "Tables"; -$LANG['datainjection']['mapping'][4] = "Fields"; -$LANG['datainjection']['mapping'][5] = "Link field"; -$LANG['datainjection']['mapping'][6] = "-------Choose a table-------"; -$LANG['datainjection']['mapping'][7] = "-------Choose a field-------"; -$LANG["datainjection"]["mapping"][8] = "Connected to : device name"; -$LANG["datainjection"]["mapping"][9] = "Connected to : port number"; -$LANG["datainjection"]["mapping"][10] = "Connected to : port MAC address"; -$LANG['datainjection']['mapping'][11] = "One link field must be selected :
    it will be used to check if data already exists"; -$LANG['datainjection']['mapping'][13] = "Warning : existing data will be overridden"; - -$LANG['datainjection']['info'][1] = "Complementary informations"; -$LANG['datainjection']['info'][3] = "This step allows you to add informations not present in the file. You'll be asked for theses informations while using the model."; -$LANG['datainjection']['info'][5] = "Mandatory information"; - -$LANG['datainjection']['saveStep'][11] = "The number of columns of the file is incorrect."; -$LANG['datainjection']['saveStep'][12] = "At least one column is incorrect"; -$LANG['datainjection']['saveStep'][17] = " found column(s)"; -$LANG['datainjection']['saveStep'][18] = " Into the file : "; -$LANG['datainjection']['saveStep'][19] = " From the model : "; - -$LANG['datainjection']['fillInfoStep'][1] = "Watch out, you're about to inject datas into GLPI. Are you sure you want to do it ?"; -$LANG['datainjection']['fillInfoStep'][3] = "* Mandatory field"; -$LANG['datainjection']['fillInfoStep'][4] = "One mandatory field is not filled"; - -$LANG['datainjection']['importStep'][1] = "Injection of the file"; -$LANG['datainjection']['importStep'][3] = "Injection finished"; - -$LANG['datainjection']['log'][1] = "Injection's results"; -$LANG['datainjection']['log'][3] = "Injection successful"; -$LANG['datainjection']['log'][4] = "Array of successful injections"; -$LANG['datainjection']['log'][5] = "Array of unsuccessful injections"; -$LANG['datainjection']['log'][8] = "Injection encounters errors"; -$LANG['datainjection']['log'][9] = "Data check"; -$LANG['datainjection']['log'][10] = "Data Import"; -$LANG['datainjection']['log'][11] = "Injection type"; -$LANG['datainjection']['log'][12] = "Object Identifier"; -$LANG['datainjection']['log'][13] = "Line"; - -$LANG['datainjection']['button'][3] = "See the file"; -$LANG['datainjection']['button'][4] = "See the log"; -$LANG['datainjection']['button'][5] = "Export the log"; -$LANG['datainjection']['button'][6] = "Finish"; -$LANG['datainjection']['button'][7] = "Export rapport in PDF"; -$LANG['datainjection']['button'][8] = "Close"; - -$LANG['datainjection']['result'][2] = "Datas to insert are correct"; -$LANG['datainjection']['result'][4] = "At least one mandatory field is not present"; -$LANG['datainjection']['result'][6] = "Undetermined"; -$LANG['datainjection']['result'][7] = "Import is successful"; -$LANG['datainjection']['result'][8] = "Add"; -$LANG['datainjection']['result'][9] = "Update"; -$LANG['datainjection']['result'][10] = "Success"; -$LANG['datainjection']['result'][11] = "Failure"; -$LANG['datainjection']['result'][12] = "Warning"; -$LANG['datainjection']['result'][17] = "No data to insert"; -$LANG['datainjection']['result'][18] = "File injection report"; -$LANG['datainjection']['result'][21] = "Import is impossible"; -$LANG['datainjection']['result'][22] = "Bad type"; -$LANG['datainjection']['result'][23] = "A mandatory field is mising"; - -$LANG['datainjection']['result'][30] = "Data already exists"; -$LANG['datainjection']['result'][31] = "No right to import data"; -$LANG['datainjection']['result'][32] = "No right to update data"; -$LANG['datainjection']['result'][33] = "Data not found"; -$LANG['datainjection']['result'][34] = "Data already used"; -$LANG['datainjection']['result'][35] = "More than one value fouond"; -$LANG['datainjection']['result'][36] = "Object is already linked"; -$LANG['datainjection']['result'][37] = "Maximum field size exceeded"; -$LANG['datainjection']['result'][39] = "Import refused by the dictionnary"; - -$LANG['datainjection']['profiles'][1] = "Model management"; - -$LANG['datainjection']['mappings'][1] = "Number of ports"; -$LANG['datainjection']['mappings'][7] = "Port unicity criteria"; - -$LANG['datainjection']['history'][1] = "from CSV file"; - -$LANG['datainjection']['model'][0] = "Model"; - -$LANG['datainjection']['tabs'][0] = "Mappings"; -$LANG['datainjection']['tabs'][1] = "Additional Information"; -$LANG['datainjection']['tabs'][2] = "Fixed values"; -$LANG['datainjection']['tabs'][3] = "File to inject"; - -$LANG['datainjection']['import'][0] = "Launch the import"; -$LANG['datainjection']['import'][1] = "Import progress"; - -$LANG['datainjection']['port'][1] = "Network link"; -$LANG['datainjection']['entity'][1] = "Entity informations"; - -$LANG['datainjection']['install'][1] = "must exists and be writable for web server user"; -?> \ No newline at end of file diff --git a/locales/en_GB.po b/locales/en_GB.po deleted file mode 100644 index a5bc456e..00000000 --- a/locales/en_GB.po +++ /dev/null @@ -1,505 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR Datainjection Development Team -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -msgid "" -msgstr "" -"Project-Id-Version: GLPI - Datainjection plugin 2.3.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-07-17 16:10+0200\n" -"PO-Revision-Date: 2013-07-17 17:19+0100\n" -"Last-Translator: Xavier CAILLAUD \n" -"Language-Team: LANGUAGE \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Language: fr_FR\n" -"Plural-Forms: nplurals=2; plural=(n > 1);\n" -"X-Generator: Poedit 1.5.7\n" - -#: hook.php:120 hook.php:134 -msgid "Can't create folder" -msgstr "Can't create folder" - -#: setup.php:52 setup.php:132 -#, php-format -msgid "%s must exists and be writable for web server user" -msgstr "%s must exists and be writable for web server user" - -#: setup.php:58 setup.php:59 inc/clientinjection.class.php:194 -msgid "Injection of the file" -msgstr "Injection of the file" - -#: setup.php:103 front/clientinjection.form.php:33 inc/profile.class.php:71 -#: inc/profile.class.php:141 -msgid "File injection" -msgstr "File injection" - -#: setup.php:137 -msgid "This plugin requires GLPI >= 0.84" -msgstr "This plugin requires GLPI >= 0.84" - -#: front/clientinjection.form.php:47 -msgid "One mandatory field is not filled" -msgstr "One mandatory field is not filled" - -#: front/clientinjection.form.php:77 front/model.form.php:83 -msgid "The file could not be found" -msgstr "The file could not be found" - -#: front/mapping.form.php:58 -msgid "" -"One link field must be selected: it will be used to check if data already " -"exists" -msgstr "" -"One link field must be selected: it will be used to check if data already " -"exists" - -#: front/mapping.form.php:68 -msgid "" -"This step allows you to add informations not present in the file. You'll be " -"asked for theses informations while using the model." -msgstr "" -"This step allows you to add informations not present in the file. You'll be " -"asked for theses informations while using the model." - -#: front/popup.php:37 inc/mapping.class.php:118 -msgid "See the file" -msgstr "See the file" - -#: front/popup.php:43 inc/model.class.php:1357 -msgid "File injection report" -msgstr "File injection report" - -#: inc/clientinjection.class.php:78 -msgid "Use an existing model" -msgstr "Use an existing model" - -#: inc/clientinjection.class.php:86 -msgid "No model currently available" -msgstr "No model currently available" - -#: inc/clientinjection.class.php:90 -msgid "You can start the model creation by hitting the button" -msgstr "You can start the model creation by hitting the button" - -#: inc/clientinjection.class.php:135 inc/dropdown.class.php:86 -#: inc/model.class.php:659 -msgid "File to inject" -msgstr "File to inject" - -#: inc/clientinjection.class.php:138 inc/info.class.php:241 -msgid "Choose a file" -msgstr "Choose a file" - -#: inc/clientinjection.class.php:144 -msgid "File encoding" -msgstr "File encoding" - -#: inc/clientinjection.class.php:152 -msgid "Warning : existing data will be overridden" -msgstr "Warning : existing data will be overridden" - -#: inc/clientinjection.class.php:154 -msgid "" -"Watch out, you're about to inject datas into GLPI. Are you sure you want to " -"do it ?" -msgstr "" -"Watch out, you're about to inject datas into GLPI. Are you sure you want to " -"do it ?" - -#: inc/clientinjection.class.php:160 -msgid "Launch the import" -msgstr "Launch the import" - -#: inc/clientinjection.class.php:190 -msgid "Import progress" -msgstr "Import progress" - -#: inc/clientinjection.class.php:253 -#, php-format -msgid "Injection of the file... %d%%" -msgstr "Injection of the file... %d%%" - -#: inc/clientinjection.class.php:264 -msgid "Injection finished" -msgstr "Injection finished" - -#: inc/clientinjection.class.php:334 -msgid "Injection's results" -msgstr "Injection's results" - -#: inc/clientinjection.class.php:339 -msgid "Injection successful" -msgstr "Injection successful" - -#: inc/clientinjection.class.php:342 -msgid "Injection encounters errors" -msgstr "Injection encounters errors" - -#: inc/clientinjection.class.php:351 -msgid "See the log" -msgstr "See the log" - -#: inc/clientinjection.class.php:357 -msgid "Export rapport in PDF" -msgstr "Export rapport in PDF" - -#: inc/clientinjection.class.php:363 -msgid "Export the log" -msgstr "Export the log" - -#: inc/clientinjection.class.php:371 -msgid "Finish" -msgstr "Finish" - -#: inc/commoninjectionlib.class.php:1815 -msgid "Add from CSV file" -msgstr "Add from CSV file" - -#: inc/commoninjectionlib.class.php:1817 -msgid "Update from CSV file" -msgstr "Update from CSV file" - -#: inc/commoninjectionlib.class.php:1858 -msgid "No right to import data" -msgstr "No right to import data" - -#: inc/commoninjectionlib.class.php:1862 -msgid "No right to update data" -msgstr "No right to update data" - -#: inc/commoninjectionlib.class.php:1866 -msgid "Size of the inserted value is to expansive" -msgstr "Size of the inserted value is to expansive" - -#: inc/commoninjectionlib.class.php:1870 -msgid "Import not allowed" -msgstr "Import not allowed" - -#: inc/commoninjectionlib.class.php:1874 -msgid "Import failed" -msgstr "Import failed" - -#: inc/commoninjectionlib.class.php:1878 -msgid "At least one mandatory field is not present" -msgstr "At least one mandatory field is not present" - -#: inc/commoninjectionlib.class.php:1882 -msgid "Datas to insert are correct" -msgstr "Datas to insert are correct" - -#: inc/commoninjectionlib.class.php:1886 -msgid "One data is not the good type" -msgstr "One data is not the good type" - -#: inc/commoninjectionlib.class.php:1890 -msgid "Warning" -msgstr "Warning" - -#: inc/commoninjectionlib.class.php:1894 -msgid "Data not found" -msgstr "Data not found" - -#: inc/commoninjectionlib.class.php:1898 inc/model.class.php:1222 -msgid "Undetermined" -msgstr "Undetermined" - -#: inc/dropdown.class.php:36 -msgid "dd-mm-yyyy" -msgstr "dd-mm-yyyy" - -#: inc/dropdown.class.php:38 -msgid "mm-dd-yyyy" -msgstr "mm-dd-yyyy" - -#: inc/dropdown.class.php:40 -msgid "yyyy-mm-dd" -msgstr "yyyy-mm-dd" - -#: inc/dropdown.class.php:59 -msgid "1 234.56" -msgstr "1 234.56" - -#: inc/dropdown.class.php:61 -msgid "1 234,56" -msgstr "1 234,56" - -#: inc/dropdown.class.php:63 -msgid "1,234.56" -msgstr "1,234.56" - -#: inc/dropdown.class.php:87 inc/model.class.php:660 -msgid "Mappings" -msgstr "Mappings" - -#: inc/dropdown.class.php:88 inc/model.class.php:663 -msgid "Additional Information" -msgstr "Additional Information" - -#: inc/dropdown.class.php:90 -msgid "Model available for use" -msgstr "Model available for use" - -#: inc/dropdown.class.php:113 -msgid "Automatic detection" -msgstr "Automatic detection" - -#: inc/dropdown.class.php:115 -msgid "UTF-8" -msgstr "UTF-8" - -#: inc/dropdown.class.php:116 -msgid "ISO8859-1" -msgstr "ISO8859-1" - -#: inc/info.class.php:87 inc/info.class.php:143 inc/mapping.class.php:125 -msgid "Tables" -msgstr "Tables" - -#: inc/info.class.php:89 inc/info.class.php:145 -msgid "Mandatory information" -msgstr "Mandatory information" - -#: inc/info.class.php:144 -msgid "Fields" -msgstr "Fields" - -#: inc/info.class.php:240 -msgid "Complementary information" -msgstr "Complementary information" - -#: inc/info.class.php:249 -msgid "Download file sample" -msgstr "Download file sample" - -#: inc/injectiontype.class.php:121 -msgid "-------Choose a table-------" -msgstr "-------Choose a table-------" - -#: inc/injectiontype.class.php:177 -msgid "-------Choose a field-------" -msgstr "-------Choose a field-------" - -#: inc/mapping.class.php:124 -msgid "Header of the file" -msgstr "Header of the file" - -#: inc/mapping.class.php:127 -msgid "Link field" -msgstr "Link field" - -#: inc/model.class.php:71 -msgid "Model management" -msgstr "Model management" - -#: inc/model.class.php:348 inc/model.class.php:568 -msgid "Allow lines creation" -msgstr "Allow lines creation" - -#: inc/model.class.php:354 inc/model.class.php:571 -msgid "Allow lines update" -msgstr "Allow lines update" - -#: inc/model.class.php:360 inc/model.class.php:556 -msgid "Type of datas to import" -msgstr "Type of datas to import" - -#: inc/model.class.php:367 inc/model.class.php:580 -msgid "Allow creation of dropdowns" -msgstr "Allow creation of dropdowns" - -#: inc/model.class.php:372 inc/model.class.php:584 -msgid "Dates format" -msgstr "Dates format" - -#: inc/model.class.php:378 inc/model.class.php:595 -msgid "Float format" -msgstr "Float format" - -#: inc/model.class.php:384 inc/model.class.php:602 -msgid "Try to establish network connection is possible" -msgstr "Try to establish network connection is possible" - -#: inc/model.class.php:390 inc/model.class.php:606 -msgid "Port unicity criteria" -msgstr "Port unicity criteria" - -#: inc/model.class.php:576 -msgid "Advanced options" -msgstr "Advanced options" - -#: inc/model.class.php:591 -msgid "Allow update of existing fields" -msgstr "Allow update of existing fields" - -#: inc/model.class.php:630 -msgctxt "button" -msgid "Validate the model" -msgstr "Validate the model" - -#: inc/model.class.php:691 -msgid "Load this file" -msgstr "Load this file" - -#: inc/model.class.php:769 -msgid "Please enter a name for the model" -msgstr "Please enter a name for the model" - -#: inc/model.class.php:775 -msgid "Your model should allow import and/or update of data" -msgstr "Your model should allow import and/or update of data" - -#: inc/model.class.php:797 -msgid "You are not the initial creator of this model" -msgstr "You are not the initial creator of this model" - -#: inc/model.class.php:858 -#, php-format -msgid "Impossible to copy the file in %s" -msgstr "Impossible to copy the file in %s" - -#: inc/model.class.php:865 -msgid "File format is wrong" -msgstr "File format is wrong" - -#: inc/model.class.php:866 -msgid "Extension csv required" -msgstr "Extension csv required" - -#: inc/model.class.php:940 -msgid "Not data to import" -msgstr "Not data to import" - -#: inc/model.class.php:993 -msgid "The file is ok." -msgstr "The file is ok." - -#: inc/model.class.php:1016 -msgid "The number of columns of the file is incorrect." -msgstr "The number of columns of the file is incorrect." - -#: inc/model.class.php:1017 -#, php-format -msgid "%d awaited column" -msgid_plural "%d awaited columns" -msgstr[0] "%d awaited column" -msgstr[1] "%d awaited columns" - -#: inc/model.class.php:1019 -#, php-format -msgid "%d found column" -msgid_plural "%d found columns" -msgstr[0] "%d found column" -msgstr[1] "%d found columns" - -#: inc/model.class.php:1053 -msgid "At least one column is incorrect" -msgstr "At least one column is incorrect" - -#: inc/model.class.php:1060 -msgid "Into the file" -msgstr "Into the file" - -#: inc/model.class.php:1063 -msgid "From the model" -msgstr "From the model" - -#: inc/model.class.php:1285 inc/model.class.php:1364 -msgid "Array of successful injections" -msgstr "Array of successful injections" - -#: inc/model.class.php:1292 inc/model.class.php:1322 inc/model.class.php:1367 -#: inc/model.class.php:1385 -msgid "Line" -msgstr "Line" - -#: inc/model.class.php:1293 inc/model.class.php:1324 inc/model.class.php:1368 -#: inc/model.class.php:1387 -msgid "Data Import" -msgstr "Data Import" - -#: inc/model.class.php:1294 inc/model.class.php:1325 inc/model.class.php:1369 -#: inc/model.class.php:1388 -msgid "Injection type" -msgstr "Injection type" - -#: inc/model.class.php:1295 inc/model.class.php:1326 inc/model.class.php:1370 -#: inc/model.class.php:1389 -msgid "Object Identifier" -msgstr "Object Identifier" - -#: inc/model.class.php:1315 inc/model.class.php:1382 -msgid "Array of unsuccessful injections" -msgstr "Array of unsuccessful injections" - -#: inc/model.class.php:1323 inc/model.class.php:1386 inc/model.class.php:1400 -msgid "Data check" -msgstr "Data check" - -#: inc/modelcsv.class.php:158 -msgid "Specific file format options" -msgstr "Specific file format options" - -#: inc/modelcsv.class.php:161 -msgid "Header's presence" -msgstr "Header's presence" - -#: inc/modelcsv.class.php:165 -msgid "File delimitor" -msgstr "File delimitor" - -#: inc/networkequipmentinjection.class.php:69 -msgid "Number of ports" -msgstr "Number of ports" - -#: inc/networkportinjection.class.php:85 -msgid "Port MAC address" -msgstr "Port MAC address" - -#: inc/webservice.class.php:70 -msgid "Model unknown" -msgstr "Model unknown" - -#: inc/webservice.class.php:75 inc/webservice.class.php:80 -msgid "You cannot access this model" -msgstr "You cannot access this model" - -#: inc/webservice.class.php:95 -msgid "Entity unknown" -msgstr "Entity unknown" - -#: inc/webservice.class.php:100 -msgid "You cannot access this entity" -msgstr "You cannot access this entity" - -#~ msgid "required" -#~ msgstr "required" - -#~ msgid "Creation of the model on going" -#~ msgstr "Creation of the model on going" - -#~ msgid "List of the models" -#~ msgstr "List of the models" - -#~ msgid "Connected to : device name" -#~ msgstr "Connected to : device name" - -#~ msgid "Connected to : port number" -#~ msgstr "Connected to : port number" - -#~ msgid "Datas are still in the database" -#~ msgstr "Datas are still in the database" - -#~ msgid "Import is successful" -#~ msgstr "Import is successful" - -#~ msgid "Data already used" -#~ msgstr "Data already used" - -#~ msgid "More than one value found" -#~ msgstr "More than one value found" - -#~ msgid "Object is already linked" -#~ msgstr "Object is already linked" diff --git a/locales/fr_FR.php b/locales/fr_FR.php deleted file mode 100644 index 5842066d..00000000 --- a/locales/fr_FR.php +++ /dev/null @@ -1,174 +0,0 @@ -. - -------------------------------------------------------------------------- - @package datainjection - @author the datainjection plugin team - @copyright Copyright (c) 2010-2017 Datainjection plugin team - @license GPLv2+ - http://www.gnu.org/licenses/gpl.txt - @link https://github.com/pluginsGLPI/datainjection - @link http://www.glpi-project.org/ - @since 2009 - ---------------------------------------------------------------------- */ - -$LANG['datainjection']['name'][1] = "Injection de fichiers"; - -$LANG['datainjection']['choiceStep'][6] = "Utiliser un modèle existant"; - -$LANG['datainjection']['model'][4] = "Type de données à insérer"; -$LANG['datainjection']['model'][5] = "Type de fichier"; -$LANG['datainjection']['model'][6] = "Création des lignes"; -$LANG['datainjection']['model'][7] = "Mise à jour des lignes"; -$LANG['datainjection']['model'][8] = "Ajouter des intitulés"; -$LANG['datainjection']['model'][9] = "Présence d'un en-tête"; -$LANG['datainjection']['model'][10] = "Délimiteur du fichier"; -$LANG['datainjection']['model'][12] = "Mise à jour des champs existants"; -$LANG['datainjection']['model'][15] = "Options avancées"; -$LANG['datainjection']['model'][18] = "Privé"; -$LANG['datainjection']['model'][20] = "Essayer de réaliser les connexions réseau"; -$LANG['datainjection']['model'][21] = "Format des dates"; -$LANG['datainjection']['model'][22] = "jj-mm-aaaa"; -$LANG['datainjection']['model'][23] = "mm-jj-aaaa"; -$LANG['datainjection']['model'][24] = "aaaa-mm-jj"; -$LANG['datainjection']['model'][25] = "1 234.56"; -$LANG['datainjection']['model'][26] = "1 234,56"; -$LANG['datainjection']['model'][27] = "1,234.56"; -$LANG['datainjection']['model'][28] = "Format des nombres flottants"; -$LANG['datainjection']['model'][29] = "Options spécifiques au format de fichier"; -$LANG['datainjection']['model'][31] = "Votre modèle doit permettre l'import et/ou la mise à jour de données"; -$LANG['datainjection']['model'][32] = "Le fichier est correct.". - "
    Vous pouvez à présent faire les correspondances avec les champs de GLPI"; -$LANG['datainjection']['model'][33] = "Aucun modèle n'est disponible actuellement"; -$LANG['datainjection']['model'][34] = "Vous pouvez en créer un en cliquant sur le bouton"; -$LANG['datainjection']['model'][35] = "Modèle en cours de création"; -$LANG['datainjection']['model'][36] = "Modèle utilisable"; -$LANG['datainjection']['model'][37] = "Validation"; -$LANG['datainjection']['model'][38] = "Valider le modèle"; -$LANG['datainjection']['model'][39] = "Liste des modèles"; -$LANG['datainjection']['model'][40] = "Téléchargement fichier example"; - -$LANG['datainjection']['fileStep'][3] = "Choix du fichier"; -$LANG['datainjection']['fileStep'][4] = "Le fichier est introuvable"; -$LANG['datainjection']['fileStep'][5] = "Le fichier n'a pas le bon format"; -$LANG['datainjection']['fileStep'][6] = "Extension"; -$LANG['datainjection']['fileStep'][7] = "requise"; -$LANG['datainjection']['fileStep'][8] = "Impossible de copier le fichier dans"; -$LANG['datainjection']['fileStep'][9] = "Encodage du fichier"; -$LANG['datainjection']['fileStep'][10] = "Détection automatique"; -$LANG['datainjection']['fileStep'][11] = "UTF-8"; -$LANG['datainjection']['fileStep'][12] = "ISO8859-1"; -$LANG['datainjection']['fileStep'][13] = "Charger le fichier"; - -$LANG['datainjection']['mapping'][2] = "En-tête du fichier"; -$LANG['datainjection']['mapping'][3] = "Tables"; -$LANG['datainjection']['mapping'][4] = "Champs"; -$LANG['datainjection']['mapping'][5] = "Champs de liaison"; -$LANG['datainjection']['mapping'][6] = "-------Choisir une table-------"; -$LANG['datainjection']['mapping'][7] = "-------Choisir un champ-------"; -$LANG["datainjection"]["mapping"][8] = "Connecté à : Nom actif"; -$LANG["datainjection"]["mapping"][9] = "Connecté à : Numéro de port"; -$LANG["datainjection"]["mapping"][10] = "Connecté à : adresse MAC du port"; -$LANG['datainjection']['mapping'][11] = "Au moins un champs de liaison doit être renseigné :
    il permet de rechercher si les données à insérer existent déjà en base"; -$LANG['datainjection']['mapping'][13] = "Attention : Les données existantes seront écrasées !"; - -$LANG['datainjection']['info'][1] = "Informations complémentaires"; -$LANG['datainjection']['info'][3] = "Vous pouvez à présent définir des données qui devront être saisies manuellement au moment de l'import."; -$LANG['datainjection']['info'][5] = "Information obligatoire"; - -$LANG['datainjection']['saveStep'][11] = "Le nombre de colonnes du fichier n'est pas correct : "; -$LANG['datainjection']['saveStep'][12] = "Au moins une colonne est incorrecte : "; -$LANG['datainjection']['saveStep'][16] = " colonne(s) attendue(s)"; -$LANG['datainjection']['saveStep'][17] = " colonne(s) trouvée(s)"; -$LANG['datainjection']['saveStep'][18] = " Dans le fichier "; -$LANG['datainjection']['saveStep'][19] = " Dans le modèle "; - -$LANG['datainjection']['fillInfoStep'][1] = "Attention ! Vous allez importer des données dans GLPI.Etes-vous sûr de vouloir continuer ?"; -$LANG['datainjection']['fillInfoStep'][3] = "* Champ obligatoire"; -$LANG['datainjection']['fillInfoStep'][4] = "Un champ obligatoire n'est pas remplis"; - -$LANG['datainjection']['importStep'][1] = "Importation du fichier"; -$LANG['datainjection']['importStep'][3] = "Importation terminée"; - -$LANG['datainjection']['log'][1] = "Résultat de l'importation"; -$LANG['datainjection']['log'][3] = "L'importation a réussi"; -$LANG['datainjection']['log'][4] = "Tableau des imports qui ont réussis"; -$LANG['datainjection']['log'][5] = "Tableau des imports qui ont échoués ou partiellement réussis"; -$LANG['datainjection']['log'][8] = "L'importation a rencontré des erreurs"; -$LANG['datainjection']['log'][9] = "Vérification des données"; -$LANG['datainjection']['log'][10] = "Import des données"; -$LANG['datainjection']['log'][11] = "Type d'injection"; -$LANG['datainjection']['log'][12] = "Identifiant de l'objet"; -$LANG['datainjection']['log'][13] = "Ligne"; - -$LANG['datainjection']['button'][3] = "Voir un aperçu du fichier"; -$LANG['datainjection']['button'][4] = "Voir le rapport"; -$LANG['datainjection']['button'][5] = "Générer CSV des erreurs"; -$LANG['datainjection']['button'][6] = "Terminer"; -$LANG['datainjection']['button'][7] = "Exporter le rapport en PDF"; -$LANG['datainjection']['button'][8] = "Fermer"; - -$LANG['datainjection']['result'][2] = "Les données à insérer sont correctes"; -$LANG['datainjection']['result'][4] = "Au moins un champs obligatoire n'est pas remplis"; -$LANG['datainjection']['result'][6] = "Indéterminé"; -$LANG['datainjection']['result'][7] = "L'import s'est bien passé"; -$LANG['datainjection']['result'][8] = "Ajout"; -$LANG['datainjection']['result'][9] = "Mise à jour"; -$LANG['datainjection']['result'][10] = "Succès"; -$LANG['datainjection']['result'][11] = "Echec"; -$LANG['datainjection']['result'][12] = "Avertissement"; -$LANG['datainjection']['result'][17] = "Pas de données à insérer"; -$LANG['datainjection']['result'][18] = "Rapport d'injection du fichier"; -$LANG['datainjection']['result'][21] = "Import impossible"; -$LANG['datainjection']['result'][22] = "Mauvais type"; -$LANG['datainjection']['result'][23] = "Au moins un champs obligatoire est manquant"; - -$LANG['datainjection']['result'][30] = "Les données existent déjà en base"; -$LANG['datainjection']['result'][31] = "Pas les droits pour importer les données"; -$LANG['datainjection']['result'][32] = "Pas les droits pour mettre à jour les données"; -$LANG['datainjection']['result'][33] = "Donnée introuvable"; -$LANG['datainjection']['result'][34] = "Donnée déjà utilisée"; -$LANG['datainjection']['result'][35] = "Plus d'une valeur trouvée"; -$LANG['datainjection']['result'][36] = "L'objet est déjà lié"; -$LANG['datainjection']['result'][37] = "Taille maximum du champs dépassée"; -$LANG['datainjection']['result'][39] = "Import refusé par le dictionnaire"; - -$LANG['datainjection']['profiles'][1] = "Gestion des modèles"; - -$LANG['datainjection']['mappings'][1] = "Nombre de ports"; -$LANG['datainjection']['mappings'][7] = "Critère d'unicité d'un port"; - -$LANG['datainjection']['history'][1] = "depuis un fichier CSV"; - -$LANG['datainjection']['model'][0] = "Modèle"; - -$LANG['datainjection']['tabs'][0] = "Correspondances"; -$LANG['datainjection']['tabs'][1] = "Infos complémentaires"; -$LANG['datainjection']['tabs'][2] = "Valeurs fixées"; -$LANG['datainjection']['tabs'][3] = "Fichier à injecter"; - -$LANG['datainjection']['import'][0] = "Procéder à l'import"; -$LANG['datainjection']['import'][1] = "Etat d'avancement de l'import"; - -$LANG['datainjection']['port'][1] = "Liaison réseau"; -$LANG['datainjection']['entity'][1] = "Informations entité"; - -$LANG['datainjection']['install'][1] = "doit exister et accessible en écriture pour l'utilisateur du serveur Web"; - -?> \ No newline at end of file diff --git a/locales/pt_BR.php b/locales/pt_BR.php deleted file mode 100644 index 6e92fcfa..00000000 --- a/locales/pt_BR.php +++ /dev/null @@ -1,173 +0,0 @@ -. - -------------------------------------------------------------------------- - @package datainjection - @author the datainjection plugin team - @copyright Copyright (c) 2010-2017 Datainjection plugin team - @license GPLv2+ - http://www.gnu.org/licenses/gpl.txt - @link https://github.com/pluginsGLPI/datainjection - @link http://www.glpi-project.org/ - @since 2009 - ---------------------------------------------------------------------- */ - -$LANG['datainjection']['name'][1] = "File injection"; - -$LANG['datainjection']['choiceStep'][6] = "Usar um modelo existente"; - -$LANG['datainjection']['model'][4] = "Tipo de dado para importação"; -$LANG['datainjection']['model'][5] = "Tipo de arquivo"; -$LANG['datainjection']['model'][6] = "Permitir criação de linhas"; -$LANG['datainjection']['model'][7] = "Permitir atualização de linhas"; -$LANG['datainjection']['model'][8] = "Permitir criação de dropdowns"; -$LANG['datainjection']['model'][9] = "Cabeçalho presente"; -$LANG['datainjection']['model'][10] = "Delimitador do arquivo"; -$LANG['datainjection']['model'][12] = "Permitir atualização de campos existentes"; -$LANG['datainjection']['model'][15] = "Opções avançadas"; -$LANG['datainjection']['model'][18] = "Privado"; -$LANG['datainjection']['model'][20] = "Tentar estabelecer uma conexão de rede se possível"; -$LANG['datainjection']['model'][21] = "Formato de data"; -$LANG['datainjection']['model'][22] = "dd-mm-yyyy"; -$LANG['datainjection']['model'][23] = "mm-dd-yyyy"; -$LANG['datainjection']['model'][24] = "yyyy-mm-dd"; -$LANG['datainjection']['model'][25] = "1 234.56"; -$LANG['datainjection']['model'][26] = "1 234,56"; -$LANG['datainjection']['model'][27] = "1,234.56"; -$LANG['datainjection']['model'][28] = "Float format"; -$LANG['datainjection']['model'][29] = "Formato de data especifico"; -$LANG['datainjection']['model'][30] = "Por favor, entre com um nome para o modelo"; -$LANG['datainjection']['model'][31] = "Seu modelo deve permitir a importação e/ou atualização dos dados”"; -$LANG['datainjection']['model'][32] = "O arquivos está ok.". - "
    Você pode começar a fazer o mapeamento com os campos do GLPI”"; -$LANG['datainjection']['model'][33] = "Nenhum modelo disponível atualmente"; -$LANG['datainjection']['model'][34] = "Você pode iniciar a criação do modelo, pressionando o botão"; -$LANG['datainjection']['model'][35] = "Criação do modelo em curso"; -$LANG['datainjection']['model'][36] = "Modelo disponível para uso"; -$LANG['datainjection']['model'][37] = "Validação"; -$LANG['datainjection']['model'][38] = "Validar o modelo"; -$LANG['datainjection']['model'][39] = "Lista de modelos"; -$LANG['datainjection']['model'][40] = "Fazer download de arquivo de exemplo"; - -$LANG['datainjection']['fileStep'][3] = "Escolha um arquivo"; -$LANG['datainjection']['fileStep'][4] = "O arquivo não pode ser encontrado"; -$LANG['datainjection']['fileStep'][5] = "Formato do arquivo está errado"; -$LANG['datainjection']['fileStep'][6] = "Extensão"; -$LANG['datainjection']['fileStep'][7] = "Requerido"; -$LANG['datainjection']['fileStep'][8] = "Impossível copiar o arquivo em"; -$LANG['datainjection']['fileStep'][9] = "File encoding"; -$LANG['datainjection']['fileStep'][10] = "Detecção automática"; -$LANG['datainjection']['fileStep'][11] = "UTF-8"; -$LANG['datainjection']['fileStep'][12] = "ISO8859-1"; -$LANG['datainjection']['fileStep'][13] = "Abrir este arquivo"; - -$LANG['datainjection']['mapping'][2] = "Cabeçalho do arquivo"; -$LANG['datainjection']['mapping'][3] = "Tabelas"; -$LANG['datainjection']['mapping'][4] = "Campos"; -$LANG['datainjection']['mapping'][5] = "Relacionar Campos"; -$LANG['datainjection']['mapping'][6] = "-------Escolha uma tabela-------"; -$LANG['datainjection']['mapping'][7] = "-------Escolha um campo-------"; -$LANG["datainjection"]["mapping"][8] = "Conectado em : nome do dispositivo"; -$LANG["datainjection"]["mapping"][9] = "Conectado em : número da porta"; -$LANG["datainjection"]["mapping"][10] = "Conectado em : porta MAC address"; -$LANG['datainjection']['mapping'][11] = "Um campo de relação deve ser selecionado :
    ele será usado para verificar se os dados já existem no sistema"; -$LANG['datainjection']['mapping'][13] = "Atenção : os dados existentes serão sobrescritos"; - -$LANG['datainjection']['info'][1] = "Informação complementar"; -$LANG['datainjection']['info'][3] = "Este passo permite que você adicione informações que não estão presentes no arquivo. Estas informações serão solicitadas quando você estiver usando o modelo."; -$LANG['datainjection']['info'][5] = "Informação obrigatória"; - -$LANG['datainjection']['saveStep'][11] = "O número de colunas no arquivo está incorreto."; -$LANG['datainjection']['saveStep'][12] = "Uma das colunas está incorreta"; -$LANG['datainjection']['saveStep'][17] = " Coluna(s) encontrada(s)"; -$LANG['datainjection']['saveStep'][18] = " No arquivo : "; -$LANG['datainjection']['saveStep'][19] = " Do modelo : "; - -$LANG['datainjection']['fillInfoStep'][1] = "Cuidado, você está preste a injetar dados no GLPI. Você está certo de que deseja prosseguir?"; -$LANG['datainjection']['fillInfoStep'][3] = "* campo mandatório"; -$LANG['datainjection']['fillInfoStep'][5] = "Um campo obrigatório não foi preenchido, verifique"; - -$LANG['datainjection']['importStep'][1] = "Injetando o arquivo"; -$LANG['datainjection']['importStep'][3] = "Inserção finalizada"; - -$LANG['datainjection']['log'][1] = "Resultado da inserção"; -$LANG['datainjection']['log'][3] = "Inserção concluída com sucesso"; -$LANG['datainjection']['log'][4] = "Lista de inserções bem sucedidas"; -$LANG['datainjection']['log'][5] = "Lista de inserções com falhas"; -$LANG['datainjection']['log'][8] = "Erros encontrados"; -$LANG['datainjection']['log'][9] = "Checar dados"; -$LANG['datainjection']['log'][10] = "Importar Dados"; -$LANG['datainjection']['log'][11] = "Tipo de inserção"; -$LANG['datainjection']['log'][12] = "Identificador do objeto"; -$LANG['datainjection']['log'][13] = "Linha"; - -$LANG['datainjection']['button'][3] = "Veja o arquivo"; -$LANG['datainjection']['button'][4] = "Veja o log"; -$LANG['datainjection']['button'][5] = "Exportar o log"; -$LANG['datainjection']['button'][6] = "Finalizar"; -$LANG['datainjection']['button'][7] = "Exportar relatório em PDF"; -$LANG['datainjection']['button'][8] = "Fechar"; - -$LANG['datainjection']['result'][2] = "Dados a inserir estão corretos"; -$LANG['datainjection']['result'][4] = "Pelo menos um dos campos obrigatórios não está presente, verifique"; -$LANG['datainjection']['result'][6] = "Impossível determinar"; -$LANG['datainjection']['result'][7] = "Importação realizada com sucesso"; -$LANG['datainjection']['result'][8] = "Adicionar"; -$LANG['datainjection']['result'][9] = "Atualizar"; -$LANG['datainjection']['result'][10] = "Successo"; -$LANG['datainjection']['result'][11] = "Falha"; -$LANG['datainjection']['result'][12] = "Atenção"; -$LANG['datainjection']['result'][17] = "Nenhum data para inserir"; -$LANG['datainjection']['result'][18] = "Relatório do File Injection"; -$LANG['datainjection']['result'][21] = "Importação é impossível"; -$LANG['datainjection']['result'][22] = "Tipo de arquivo desconhecido"; -$LANG['datainjection']['result'][23] = "Um campo mandatório está faltando"; - -$LANG['datainjection']['result'][30] = "O dado já existe"; -$LANG['datainjection']['result'][31] = "Sem direitos para importação dos dados"; -$LANG['datainjection']['result'][32] = "Sem direitos para atualização dos dados"; -$LANG['datainjection']['result'][33] = "Dados não encontrados"; -$LANG['datainjection']['result'][34] = "Dados já utilizados"; -$LANG['datainjection']['result'][35] = "Mais de um valor encontrado"; -$LANG['datainjection']['result'][36] = "Objeto já está relacionado"; -$LANG['datainjection']['result'][37] = "Tamanho máximo do campo excedido"; -$LANG['datainjection']['result'][39] = "Import refused by the dictionnary"; - -$LANG['datainjection']['profiles'][1] = "Gerenciamento de modelos"; - -$LANG['datainjection']['mappings'][1] = "Números de portas"; -$LANG['datainjection']['mappings'][7] = "Critério de unicidade de porta"; - -$LANG['datainjection']['history'][1] = "de um arquivo CSV"; - -$LANG['datainjection']['model'][0] = "Modelo"; - -$LANG['datainjection']['tabs'][0] = "Mapeamento"; -$LANG['datainjection']['tabs'][1] = "Informações adicionais"; -$LANG['datainjection']['tabs'][2] = "Valores fixados"; -$LANG['datainjection']['tabs'][3] = "Arquivo para inserção"; - -$LANG['datainjection']['import'][0] = "Iniciar importação"; -$LANG['datainjection']['import'][1] = "Progresso da importação"; - -$LANG['datainjection']['port'][1] = "Network link"; -$LANG['datainjection']['entity'][1] = "Entity informations"; - -$LANG['datainjection']['install'][1] = "must exists and be writable for web server user"; -?> \ No newline at end of file From f77bf12696ac1927692aa45441fb561aa30677aa Mon Sep 17 00:00:00 2001 From: Walid Date: Sun, 22 Jan 2017 23:35:17 +0100 Subject: [PATCH 06/27] Fix right call --- inc/clientinjection.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/clientinjection.class.php b/inc/clientinjection.class.php index 09e21708..f33f3ab8 100644 --- a/inc/clientinjection.class.php +++ b/inc/clientinjection.class.php @@ -31,7 +31,7 @@ class PluginDatainjectionClientInjection { static $rightname = "plugin_datainjection_use"; - + const STEP_UPLOAD = 0; const STEP_PROCESS = 1; const STEP_RESULT = 2; @@ -88,7 +88,7 @@ function showForm($ID, $options=array()) { } else { $text = __('No model currently available', 'datainjection'); - if (Session::haveRight(plugin_datainjection_model, CREATE) ) { + if (Session::haveRight('plugin_datainjection_model', CREATE) ) { $text = sprintf(__('%1$s %2$s'), $text.". ", sprintf(__('%1$s: %2$s'), From e1dd73fc4fda0afc5d1c91241ba27354edc68b12 Mon Sep 17 00:00:00 2001 From: Walid Date: Tue, 31 Jan 2017 00:22:19 +0100 Subject: [PATCH 07/27] Fix infocm dates declaration --- inc/infocominjection.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/inc/infocominjection.class.php b/inc/infocominjection.class.php index 3796afd8..ea30d032 100644 --- a/inc/infocominjection.class.php +++ b/inc/infocominjection.class.php @@ -93,7 +93,8 @@ function getOptions($primary_type='') { $tab[23]['checktype'] = 'date'; $tab[24]['checktype'] = 'date'; $tab[25]['checktype'] = 'date'; - $tab[26]['checktype'] = 'date'; + $tab[27]['checktype'] = 'date'; + $tab[28]['checktype'] = 'date'; //Remove some options because some fields cannot be imported $blacklist = PluginDatainjectionCommonInjectionLib::getBlacklistedOptions(get_parent_class($this)); @@ -104,7 +105,7 @@ function getOptions($primary_type='') { $key = array_search(19, $options['ignore_fields']); unset($options['ignore_fields'][$key]); - $options['displaytype'] = array("date" => array(4, 5, 23, 24, 25, 26), + $options['displaytype'] = array("date" => array(4, 5, 23, 24, 25, 27, 28), "dropdown" => array(6, 9, 19), "dropdown_integer" => array(6, 14), "decimal" => array(8, 13, 17), From cbcb402b8fd1526602ce5c3169b0d05b13fc826f Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Wed, 8 Feb 2017 14:19:26 +0100 Subject: [PATCH 08/27] Add missing version constant; update xml file --- datainjection.xml | 6 ++++++ setup.php | 2 ++ 2 files changed, 8 insertions(+) diff --git a/datainjection.xml b/datainjection.xml index a2015207..1c3ce0cc 100644 --- a/datainjection.xml +++ b/datainjection.xml @@ -25,6 +25,12 @@ Xavier Caillaud + + 2.4.3 + 0.85 + 0.90 + 9.1 + 2.4.2 0.85 diff --git a/setup.php b/setup.php index 1d86b349..1e554539 100644 --- a/setup.php +++ b/setup.php @@ -28,6 +28,8 @@ @since 2009 ---------------------------------------------------------------------- */ +define ('PLUGIN_DATAINJECTION_VERSION', '2.4.3'); + if (!defined("PLUGIN_DATAINJECTION_UPLOAD_DIR")) { define("PLUGIN_DATAINJECTION_UPLOAD_DIR", GLPI_PLUGIN_DOC_DIR."/datainjection/"); } From e87eb6448d4c684e427bf0b6977fe9e0e3b7e860 Mon Sep 17 00:00:00 2001 From: Walid Date: Sun, 22 Jan 2017 22:56:00 +0100 Subject: [PATCH 09/27] Add tools scripts --- .gitignore | 5 + .travis.yml | 64 ++++ composer.json | 8 + tools/HEADER | 26 ++ tools/modify_headers.pl | 102 ++++++ tools/phpcs-rules.xml | 22 ++ tools/release | 680 ++++++++++++++++++++++++++++++++++++++++ 7 files changed, 907 insertions(+) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 composer.json create mode 100644 tools/HEADER create mode 100755 tools/modify_headers.pl create mode 100644 tools/phpcs-rules.xml create mode 100755 tools/release diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..f0331232 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +dist/ +vendor/ +.gh_token +*.min.* + diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..ec7693e6 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,64 @@ +language: php + +env: + - DB=mysql + +before_script: + - composer self-update + - if [[ ${TRAVIS_PHP_VERSION:0:3} == "5.4" ]]; then sed -e "s|.*"consolidation/robo".*$||" -i composer.json && composer update; fi + - composer install -o +# - mysql -u root -e 'create database glpitest;' +# - php tools/cliinstall.php --lang=en_US --db=glpitest --user=root --tests + +script: +# - mysql -u root -e 'select version();' +# - phpunit --verbose + - vendor/bin/phpcs -p --ignore=vendor --ignore=js --standard=vendor/glpi-project/coding-standard/GlpiStandard/ . + +matrix: + include: + - php: 5.4 + addons: + mariadb: 5.5 + - php: 5.5 + addons: + mariadb: 5.5 +# - php: 5.6 +# addons: +# mariadb: 5.5 +# - php: 5.6 +# addons: +# mariadb: 10.0 + - php: 5.6 + addons: + mariadb: 10.1 +# - php: 7.0 +# addons: +# mariadb: 10.0 + - php: 7.0 + addons: + mariadb: 10.1 +# - php: 7.1 +# addons: +# mariadb: 10.0 + - php: 7.1 + addons: + mariadb: 10.1 + - php: nightly + addons: + mariadb: 10.1 + allow_failures: + - php: nightly + +cache: + directories: + - $HOME/.composer/cache + +#notifications: +# irc: +# channels: +# - "irc.freenode.org#channel" +# on_success: change +# on_failure: always +# use_notice: true +# skip_join: true diff --git a/composer.json b/composer.json new file mode 100644 index 00000000..d7815a6a --- /dev/null +++ b/composer.json @@ -0,0 +1,8 @@ +{ + "require-dev": { + "consolidation/robo": "dev-master@dev", + "patchwork/jsqueeze": "~1.0", + "natxet/CssMin": "~3.0", + "glpi-project/coding-standard": "0.5" + } +} diff --git a/tools/HEADER b/tools/HEADER new file mode 100644 index 00000000..80a64f2e --- /dev/null +++ b/tools/HEADER @@ -0,0 +1,26 @@ + * @version $Id: HEADER 14684 2011-06-11 06:32:40Z remi $ + LICENSE + + This file is part of the datainjection plugin. + + Datainjection plugin 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. + + Datainjection plugin 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 datainjection. If not, see . + -------------------------------------------------------------------------- + @package datainjection + @author the datainjection plugin team + @copyright Copyright (c) 2009-2017 Datainjection plugin team + @license GPLv2+ + http://www.gnu.org/licenses/gpl.txt + @link https://github.com/pluginsGLPI/datainjection + @link http://www.glpi-project.org/ + @since 2009 diff --git a/tools/modify_headers.pl b/tools/modify_headers.pl new file mode 100755 index 00000000..71719e28 --- /dev/null +++ b/tools/modify_headers.pl @@ -0,0 +1,102 @@ +#!/usr/bin/perl +#!/usr/bin/perl -w + +# ---------------------------------------------------------------------- +# GLPI - Gestionnaire Libre de Parc Informatique +# Copyright (C) 2003-2006 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, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# ------------------------------------------------------------------------ + + +do_dir(".."); + + +sub do_dir{ +local ($dir)=@_; +print "Entering $dir\n"; + +opendir(DIRHANDLE,$dir)||die "ERROR: can not read current directory\n"; +foreach (readdir(DIRHANDLE)){ + if ($_ ne '..' && $_ ne '.'){ + if (-d "$dir/$_"){ + if ($_ !~ m/.svn/i && $_ !~ m/CVS/i && $_ !~ m/lib/i){ + + do_dir("$dir/$_"); + } + } else { + if(!(-l "$dir/$_")){ + if ((index($_,".php",0)!=-1)||(index($_,".txt",0)!=-1)||(index($_,".css",0)!=-1)){ + do_file("$dir/$_"); + } + } + } + } +} +closedir DIRHANDLE; + +} + +sub do_file{ + local ($file)=@_; + print $file."\n"; + ### DELETE HEADERS + open(INIT_FILE,$file); + @lines=; + close(INIT_FILE); + + open(TMP_FILE,">/tmp/tmp_glpi.txt"); + + $status=''; + foreach (@lines){ + if ($_ =~ m/\*\//){ + $status="END"; + } + + if ($status =~ m/END/||$status !~ m/BEGIN/){ + print TMP_FILE $_; + } + + if ($status !~ m/END/){ + if ($_ =~ m/\/\*/){ + $status="BEGIN"; + ##### ADD NEW HEADERS + open(HEADER_FILE,"HEADER"); + @headers=; + foreach (@headers){ + print TMP_FILE $_; + } + close(HEADER_FILE) ; + + } + } + } + close(TMP_FILE); + + system("cp -f /tmp/tmp_glpi.txt $file"); + + + +} + + + diff --git a/tools/phpcs-rules.xml b/tools/phpcs-rules.xml new file mode 100644 index 00000000..f3314a0e --- /dev/null +++ b/tools/phpcs-rules.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/tools/release b/tools/release new file mode 100755 index 00000000..2f0b3ee7 --- /dev/null +++ b/tools/release @@ -0,0 +1,680 @@ +#!/usr/bin/python +# Adapted from Galette release script + +import os, sys, argparse, re, git, subprocess +import tarfile, shutil, gitdb, time, urllib2, json +from datetime import datetime +from termcolor import colored +from lxml import etree + +plugin_dir = os.path.dirname( + os.path.dirname(os.path.abspath(__file__)) +) +dist_dir = os.path.join( + plugin_dir, + 'dist' +) +verbose = False +tagrefs = None +force = False +commit = None +extra = None +sign = True +github = True +assume_yes = False +banned = [ + 'dist', + 'vendor', + '.git', + '.gitignore', + '.gh_token', + '.tx', + 'tools', + 'tests' +] +gh_orga = 'pluginsGLPI' +script_version = '1.0.0' + +def print_err(msg): + """ + Display colored error message + """ + print colored(msg, 'red', attrs=['bold']) + +def get_numeric_version(ver): + """ + Returns all numeric version + """ + return re.findall(r'\d+', ver) + +def valid_version(ver): + """ + Check if provided version is valid. + + Takes all digits in passed version, then reassemble them with dots + to check if it is the same as original given one. + """ + return '.'.join(get_numeric_version(ver)) == ver + +def incr_version(ver): + """ + Increment version number + """ + version = get_numeric_version(ver) + version[-1] = str(int(version[-1]) + 1) + return version + +def propose_version(): + """ + Propose new minor and major versions, + according to existing git tags + """ + last_major = '0' + last_minor = '0' + + for tagref in tagrefs: + if valid_version(tagref.name): + #last minor version is always the last one :) + if tagref.name > last_minor: + last_minor = tagref.name + + #last major version + if len(tagref.name) == 5 and tagref.name > last_major: + last_major = tagref.name + + if verbose: + print 'last minor: %s | last major %s' % (last_minor, last_major) + + #no version provided. propose one + new_minor = None + new_major = None + + if len(last_minor) == 5: + #if the latest is a major version + new_minor = last_minor + ('.1') + else: + new_minor = '.'.join(incr_version(last_minor)) + + new_major = '.'.join(incr_version(last_major)) + + print """Proposed versions: + minor: %s + major: %s + """ % (new_minor, new_major) + +def get_latest_version(): + """ + Look for latest version + """ + last = None + for tagref in tagrefs: + if valid_version(tagref.name): + #last created minor version is always the last one :) + if tagref.name > last: + last = tagref.name + + return last + +def is_existing_version(ver): + """ + Look specified version exists + """ + for tagref in tagrefs: + if valid_version(tagref.name): + if tagref.name == ver: + return True + return False + +def ask_user_confirm(msg): + """ + Ask user his confirmation + """ + if assume_yes: + return True + else: + while True: + sys.stdout.write(msg) + choice = raw_input().lower() + if choice == 'y' or choice == 'yes': + return True + elif choice == 'n' or choice == 'no': + return False + else: + print_err( + "Invalid input. Please enter 'yes' or 'no' (or 'y' or 'n')." + ) + +def get_rel_name(buildver): + """ + Build archive name from command line parameters + That would be used for git archiving prefix and archive name + """ + archive_name = None + + if commit and extra: + now = datetime.now() + archive_name = 'glpi-%s-%s-%s-%s-%s' % ( + plugin_name, + buildver, + extra, + now.strftime('%Y%m%d'), + commit + ) + else: + archive_name = 'glpi-%s-%s' % (plugin_name, buildver) + + return archive_name + +def _do_build(repo, ver): + """ + Proceed build + """ + exists = False + ascexists = False + rel_name = get_rel_name(ver) + archive_name = rel_name + '.tar.bz2' + archive = os.path.join( + dist_dir, + archive_name + ) + + if not force: + #first check if a version + local = False + ascLocal = False + + #check if a release exists upstream + #FIXME: this retrieve only publicated release, not drafts + url = 'https://api.github.com/repos/%s/%s/releases/tags/%s' % (gh_orga, plugin_name, ver) + + exists = False + gh_id = None + + try: + request = urllib2.Request(url) + handle = urllib2.urlopen(request) + contents = json.loads(handle.read()) + + for asset in contents['assets']: + if archive_name == asset['name']: + exists = True + gh_id = contents['id'] + break + except (urllib2.URLError, urllib2.HTTPError): + pass + + if exists: + #we know a release exists for this tag. Check if files have been uploaded yet + pass + + if not exists: + #also check from local repo + exists = os.path.exists(archive) + if exists: + local = True + + #also check from local repo + ascexists = os.path.exists( + os.path.join( + dist_dir, + archive_name + '.asc' + ) + ) + + if exists or ascexists: + msg = None + if exists: + loctxt = '' + if local: + loctxt = 'locally ' + msg = 'Relase %s already %sexists' % (rel_name, loctxt) + + if ascexists: + loctxt = '' + if ascLocal: + loctxt = ' locally' + if msg is not None: + msg += ' and has been %ssigned!' % loctxt + else: + msg += 'Release has been %ssigned!' % loctxt + + msg += '\n\nYou will *NOT* build another one :)' + print_err(msg) + else: + print 'Building %s...' % rel_name + + if verbose: + typestr = 'Tag' + typever = ver + + if commit and extra: + typestr = 'Commit' + typever = commit + + print 'Release name: %s, %s: %s, Dest: %s' % ( + rel_name, + typestr, + typever, + archive + ) + + paths = os.listdir(plugin_dir) + paths = list(set(paths) - set(banned)) + + if commit and extra: + print 'Archiving GIT commit %s' % commit + with open(archive, 'wb') as stream: + repo.archive(stream, commit, prefix=plugin_name+'/', path=paths) + else: + print 'Archiving GIT tag %s' % ver + with open(archive, 'wb') as stream: + repo.archive(stream, ver, prefix=plugin_name+'/', path=paths) + + print 'Adding vendor libraries' + prepare(plugin_name, archive) + + if sign: + do_sign(archive) + + if github: + create_gh_release(archive, gh_id, plugin_name, ver) + +def do_sign(archive): + sign_cmd = 'gpg --no-use-agent --detach-sign --armor %s' % archive + p1 = subprocess.Popen(sign_cmd, shell=True) + p1.communicate() + +def create_gh_release(archive, gh_id, plugin_name, ver): + with open(gh_cred_file, 'r') as fd: + token = fd.readline().strip() + + gh = github.Github(token) + gh_user = gh.get_user() + + for gh_repo in gh_user.get_repos(): + if gh_repo.full_name == '%s/%s' % (gh_orga, plugin_name): + break + + gh_release = None + + #check in all releases (including drafts) if nothing has been found yet + if gh_id is None: + for gh_rel in gh_repo.get_releases(): + if gh_rel.tag_name == ver: + gh_release = gh_rel + break + + #create release if it does not exists + if gh_id is None and gh_release is None: + is_prerelease = False if commit else True + gh_release = gh_repo.create_git_release( + ver, + 'GLPi %s %s' % (plugin_name, ver), + 'Automated release from release script', + True, + is_prerelease + ) + elif gh_id is not None: + gh_release = gh_repo.get_release(gh_id) + + #upload = ask_user_confirm( + # 'Do you want to upload archive %s? [yes/No] ' % archive + #) + + #if upload: + # do_upload(archive, gh_id, plugin_name, ver) + +#def do_upload(archive, gh_id, plugin_name, ver): + #from uritemplate import URITemplate + #import requests + #import mimetypes + + #Upload asset + #template = URITemplate(gh_release.upload_url) + + #headers = {'Content-Type': 'application/octet-stream', 'Authorization': 'token %s' % token} + #params = {'name': '%s-%s.tar.bz2' % (plugin_name, ver)} + #url = template.expand(params) + + ## Bad request :'( + #f = open('/var/www/webapps/glpi/plugins/order/dist/glpi-order-1.9.5.tar.bz2', 'rb') + #r = requests.post( + # url, + # data=f, + # headers=headers + #) + #print r.json() + #r.raise_for_status() + +def prepare(rel_name, archive): + """ + Add external libraries to the archive, if any + """ + + plugin = tarfile.open(archive, 'r') + src_dir = os.path.join(dist_dir, 'src') + if not os.path.exists(src_dir): + os.makedirs(src_dir) + plugin.extractall(path=src_dir) + plugin.close() + + build_dir = os.path.join(src_dir, plugin_name) + if os.path.exists(os.path.join(build_dir, 'composer.lock')): + composer = ['composer', 'install', '-o', '--no-dev'] + + if not verbose: + composer.insert(-1, '-q') + + p1 = subprocess.Popen( + composer, + cwd=build_dir + ) + p1.communicate() + + compile_mo(build_dir) + + minify(build_dir) + + plugin = tarfile.open(archive, 'w|bz2') + + for i in os.listdir(src_dir): + plugin.add( + os.path.join(src_dir, i), + arcname=rel_name + ) + + plugin.close() + shutil.rmtree(src_dir) + +def compile_mo(build_dir): + locales_dir = os.path.join(build_dir, 'locales') + if verbose: + print 'Locales dir: %s' % locales_dir + if os.path.exists(locales_dir): + for file in os.listdir(locales_dir): + if file.endswith('.po'): + if verbose: + print 'Compiling %s...' % file + p1 = subprocess.Popen( + ['msgfmt', file, '-o', file.replace('.po', '.mo')], + cwd=locales_dir + ) + p1.communicate() + +def minify(build_dir): + if os.path.exists(os.path.join(plugin_dir, 'vendor')): + robo = [os.path.join(plugin_dir, 'vendor', 'bin', 'robo'), 'minify'] + if not verbose: + robo.insert(-1, '-q') + + if verbose: + print robo + + p1 = subprocess.Popen( + robo, + cwd=build_dir + ) + p1.communicate() + elif verbose: + print_err("Robo.li is not installed; cannot minify!") + +def valid_commit(repo, c): + """ + Validate commit existance in repository + """ + global commit + + try: + dformat = '%a, %d %b %Y %H:%M' + repo_commit = repo.commit(c) + + commit = repo_commit.hexsha[:10] + print colored("""Commit informations: + Hash: %s + Author: %s + Authored date: %s + Commiter: %s + Commit date: %s + Message: %s""" % ( + commit, + repo_commit.author, + time.strftime(dformat, time.gmtime(repo_commit.authored_date)), + repo_commit.committer, + time.strftime(dformat, time.gmtime(repo_commit.committed_date)), + repo_commit.message + ), None, 'on_grey', attrs=['bold']) + return True + except gitdb.exc.BadObject: + return False + +def guess_plugin_name(): + """ + Tries to guess plugin name, ask user at last + """ + name = None + + filename = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + 'extract_template.sh' + ) + + #try to get configured plugin name + if os.path.exists(filename): + with file(filename) as input: + for count, line in enumerate(input): + results = re.match(r"^NAME='(.+)'$", line) + if results: + name = results.group(1) + break + + if name is None: + #No configured name found. Let's use current directory name + name = os.path.split(plugin_dir)[-1] + + return name.lower() + +def check_version(buildver): + if verbose: + print 'Checking for version %s' % buildver + + filename = os.path.join( + plugin_dir, + 'setup.php' + ) + + found = None + #find version constant + if os.path.exists(filename): + with file(filename) as input: + for count, line in enumerate(input): + regexp = ".*('|\")PLUGIN_%s_VERSION('|\"), ('|\")(.+)('|\")" % plugin_name.upper() + results = re.match(regexp, line) + if results: + found = results.group(4) + break + + if not found == buildver: + print_err('Plugin version check has failed (%s but %s found)!' % (buildver, found)) + return False + + #check plugins website XML file + xmlfile = os.path.join(plugin_dir, '%s.xml' % plugin_name) + if not os.path.exists(xmlfile): + xmlfile = os.path.join(plugin_dir, 'plugin.xml') + if not os.path.exists(xmlfile): + xmlfile = None + + if xmlfile != None: + if verbose: + print 'XML file found in %s' % xmlfile + try: + xmldoc = etree.parse(xmlfile) + for version in xmldoc.getiterator('num'): + if version.text == buildver: + if verbose: + print '%s found in the XML file!' % buildver + return True + print_err('%s *NOT* found in the XML file %s' % (buildver, xmlfile)) + except etree.XMLSyntaxError as err: + print_err('%s is *NOT* XML valid!' % (xmlfile)) + if verbose: + print format(err) + return False + else: + print_err('Plugins website configuration file has not been found!') + return False + +def main(): + """ + Main method + """ + global verbose, tagrefs, force, extra, assume_yes, sign, plugin_name, github, gh_cred_file + + parser = argparse.ArgumentParser(description='GLPi plugins release script', version=script_version) + group = parser.add_mutually_exclusive_group() + group.add_argument( + '-r', + '--release', + help='Version to release' + ) + parser.add_argument( + '-g', + '--nogithub', + help="DO NOT Create github draft release", + action='store_false' + ) + parser.add_argument( + '-C', + '--check-only', + help="Only do chec, does not release anything", + action='store_true' + ) + group.add_argument( + '-p', + '--propose', + help='Calculate and propose next possible versions', + action='store_true' + ) + parser.add_argument( + '-c', + '--commit', + help='Specify commit to archive (-v required)' + ) + parser.add_argument( + '-e', + '--extra', + help='Extra version informations (-c required)' + ) + parser.add_argument( + '-m', + '--compile-mo', + help="Compile MO files from PO files (exclusive)", + action='store_true' + ) + parser.add_argument( + '-M', + '--minify', + help="Minify CSS ans JS files", + action='store_true' + ) + parser.add_argument( + '-S', + '--nosign', + help="Do not sign release tarball", + action="store_false" + ) + parser.add_argument( + '-Y', + '--assume-yes', + help='Assume YES to all questions. Be sure to understand what you are doing!', + action='store_true' + ) + parser.add_argument( + '-V', + '--verbose', + help='Be more verbose', + action="store_true" + ) + parser.add_argument('-f', action='store_true') + args = parser.parse_args() + + verbose=args.verbose + sign=args.nosign + github=args.nogithub + + if verbose: + print args + + if github: + import github + gh_cred_file = os.path.join(plugin_dir, '.gh_token') + if not os.path.exists(gh_cred_file): + print_err('GitHub credential file does not exists! Either create it or use the --nogithub option.') + sys.exit(1) + + plugin_name = guess_plugin_name() + + plugin_repo = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + repo = git.Repo(plugin_repo) + tagrefs = repo.tags + + if args.f == True: + force = ask_user_confirm( + 'Are you *REALLY* sure you mean -f when you typed -f? [yes/No] ' + ) + assume_yes=args.assume_yes + + if args.check_only: + print '*** Entering *check-only* mode ***' + + #check if dist_dir exists + if not os.path.exists(dist_dir): + os.makedirs(dist_dir) + + build = False + buildver = None + if args.compile_mo or args.minify: + if args.compile_mo: + compile_mo(plugin_repo) + if args.minify: + minify(plugin_repo) + elif (args.extra or args.commit) and (not args.extra or not args.commit or not args.release): + print_err('You have to specify --version --commit and --extra all together') + sys.exit(1) + elif args.commit and args.release and args.extra: + if valid_commit(repo, args.commit): + if verbose: + print 'Commit is valid' + build = True + buildver = args.release + extra = args.extra + else: + print_err('Invalid commit ref %s' % args.commit) + elif args.release: + if not valid_version(args.release): + print_err('%s is not a valid version number!' % args.release) + sys.exit(1) + else: + #check if specified version exists + if not is_existing_version(args.release): + print_err('%s does not exist!' % args.release) + else: + build = True + buildver = args.release + elif args.propose: + propose_version() + else: + buildver = get_latest_version() + if force: + build = True + else: + build = ask_user_confirm( + 'Do you want to build version %s? [Yes/no] ' % buildver + ) + + if build: + if check_version(buildver) and args.check_only == False: + _do_build(repo, buildver) + +if __name__ == "__main__": + main() From ffe95eef8006fefdac468f1fd843493deb28334c Mon Sep 17 00:00:00 2001 From: Walid Date: Sun, 22 Jan 2017 23:35:54 +0100 Subject: [PATCH 10/27] Apply coding standards --- RoboFilePlugin.php | 32 +- ajax/dropdownChooseField.php | 10 +- ajax/dropdownMandatory.php | 9 +- ajax/dropdownSelectModel.php | 20 +- ajax/injection.php | 9 +- ajax/results.php | 9 +- css/datainjection.css | 4 +- front/clientinjection.form.php | 58 +- front/export.csv.php | 4 +- front/export.pdf.php | 6 +- front/info.form.php | 12 +- front/mapping.form.php | 31 +- front/model.form.php | 109 +-- front/model.php | 9 +- front/popup.php | 19 +- hook.php | 628 +++++++-------- inc/autoupdatesysteminjection.class.php | 10 +- inc/backend.class.php | 24 +- inc/backendcsv.class.php | 63 +- inc/backendinterface.class.php | 24 +- inc/budgetinjection.class.php | 18 +- inc/cartridgeiteminjection.class.php | 18 +- inc/clientinjection.class.php | 221 +++--- inc/commoninjectionlib.class.php | 716 ++++++++++-------- inc/computer_iteminjection.class.php | 15 +- ...omputer_softwarelicenseinjection.class.php | 29 +- ...omputer_softwareversioninjection.class.php | 30 +- inc/computerinjection.class.php | 20 +- inc/computermodelinjection.class.php | 12 +- inc/computertypeinjection.class.php | 12 +- inc/consumableiteminjection.class.php | 20 +- inc/contact_supplierinjection.class.php | 16 +- inc/contactinjection.class.php | 16 +- inc/contacttypeinjection.class.php | 12 +- inc/contract_iteminjection.class.php | 13 +- inc/contract_supplierinjection.class.php | 16 +- inc/contractinjection.class.php | 74 +- inc/contracttypeinjection.class.php | 12 +- inc/data.class.php | 11 +- inc/devicecaseinjection.class.php | 24 +- inc/devicecasetypeinjection.class.php | 12 +- inc/devicecontrolinjection.class.php | 26 +- inc/devicedriveinjection.class.php | 26 +- inc/deviceecasetypeinjection.class.php | 12 +- inc/deviceharddriveinjection.class.php | 24 +- inc/devicememoryinjection.class.php | 21 +- inc/devicememorytypeinjection.class.php | 12 +- inc/devicemotherboardinjection.class.php | 24 +- inc/devicenetworkcardinjection.class.php | 24 +- inc/deviceprocessorinjection.class.php | 21 +- inc/documentinjection.class.php | 13 +- inc/documenttypeinjection.class.php | 12 +- inc/domaininjection.class.php | 12 +- inc/dropdown.class.php | 60 +- inc/engine.class.php | 113 +-- inc/entityinjection.class.php | 48 +- inc/filesystemtypeinjection.class.php | 12 +- inc/group_userinjection.class.php | 17 +- inc/groupinjection.class.php | 14 +- inc/info.class.php | 184 +++-- inc/infocollection.class.php | 15 +- inc/infocominjection.class.php | 33 +- inc/injectioninterface.class.php | 48 +- inc/injectiontype.class.php | 104 ++- inc/interfacetypeinjection.class.php | 12 +- inc/itilcategoryinjection.class.php | 18 +- inc/knowbaseitemcategoryinjection.class.php | 12 +- inc/knowbaseiteminjection.class.php | 20 +- inc/locationinjection.class.php | 12 +- inc/manufacturerinjection.class.php | 12 +- inc/mapping.class.php | 55 +- inc/mappingcollection.class.php | 45 +- inc/menu.class.php | 10 +- inc/model.class.php | 667 +++++++++------- inc/modelcsv.class.php | 36 +- inc/monitorinjection.class.php | 22 +- inc/monitormodelinjection.class.php | 12 +- inc/monitortypeinjection.class.php | 12 +- inc/netpointinjection.class.php | 16 +- ...etworkequipmentfirmwareinjection.class.php | 12 +- inc/networkequipmentinjection.class.php | 24 +- inc/networkequipmentmodelinjection.class.php | 12 +- inc/networkequipmenttypeinjection.class.php | 12 +- inc/networkinjection.class.php | 12 +- inc/networkinterfaceinjection.class.php | 12 +- inc/networknameinjection.class.php | 25 +- inc/networkport_vlaninjection.class.php | 14 +- inc/networkportinjection.class.php | 104 +-- inc/operatingsysteminjection.class.php | 12 +- ...ratingsystemservicepackinjection.class.php | 12 +- inc/operatingsystemversioninjection.class.php | 12 +- inc/peripheralinjection.class.php | 20 +- inc/peripheralmodelinjection.class.php | 12 +- inc/peripheraltypeinjection.class.php | 12 +- inc/phoneinjection.class.php | 20 +- inc/phonemodelinjection.class.php | 12 +- inc/phonepowersupplytypeinjection.class.php | 12 +- inc/phonetypeinjection.class.php | 12 +- inc/printerinjection.class.php | 46 +- inc/printermodelinjection.class.php | 12 +- inc/printertypeinjection.class.php | 12 +- inc/profile.class.php | 102 +-- inc/profile_userinjection.class.php | 14 +- inc/profileinjection.class.php | 31 +- inc/requesttypeinjection.class.php | 14 +- inc/session.class.php | 10 +- inc/softwareinjection.class.php | 82 +- inc/softwarelicenseinjection.class.php | 63 +- inc/softwarelicensetypeinjection.class.php | 12 +- inc/softwareversioninjection.class.php | 62 +- inc/solutiontemplateinjection.class.php | 16 +- inc/solutiontypeinjection.class.php | 14 +- inc/stateinjection.class.php | 12 +- inc/supplierinjection.class.php | 16 +- inc/suppliertypeinjection.class.php | 12 +- inc/taskcategoryinjection.class.php | 14 +- inc/userinjection.class.php | 39 +- inc/virtualmachinestateinjection.class.php | 12 +- inc/virtualmachinesysteminjection.class.php | 12 +- inc/virtualmachinetypeinjection.class.php | 12 +- inc/vlaninjection.class.php | 14 +- inc/webservice.class.php | 145 ++-- javascript/datainjection.js | 14 +- setup.php | 264 ++++--- testwebservice.php | 13 +- tools/move_to_po.php | 308 -------- 126 files changed, 3148 insertions(+), 2835 deletions(-) delete mode 100644 tools/move_to_po.php diff --git a/RoboFilePlugin.php b/RoboFilePlugin.php index 7aa9732d..9f017970 100644 --- a/RoboFilePlugin.php +++ b/RoboFilePlugin.php @@ -11,8 +11,7 @@ class RoboFilePlugin extends \Robo\Tasks * * @return void */ - public function minify() - { + public function minify() { $this->minifyCSS() ->minifyJS(); } @@ -22,11 +21,10 @@ public function minify() * * @return void */ - public function minifyCSS() - { + public function minifyCSS() { $css_dir = __DIR__ . '/css'; if (is_dir($css_dir)) { - foreach(glob("$css_dir/*.css") as $css_file) { + foreach (glob("$css_dir/*.css") as $css_file) { if (!$this->endsWith($css_file, 'min.css')) { $this->taskMinify($css_file) ->to(str_replace('.css', '.min.css', $css_file)) @@ -43,11 +41,10 @@ public function minifyCSS() * * @return void */ - public function minifyJS() - { + public function minifyJS() { $js_dir = __DIR__ . '/js'; if (is_dir($js_dir)) { - foreach(glob("$js_dir/*.js") as $js_file) { + foreach (glob("$js_dir/*.js") as $js_file) { if (!$this->endsWith($js_file, 'min.js')) { $this->taskMinify($js_file) ->to(str_replace('.js', '.min.js', $js_file)) @@ -64,8 +61,7 @@ public function minifyJS() * * @return void */ - public function localesExtract() - { + public function localesExtract() { $this->_exec('tools/extract_template.sh'); return $this; } @@ -75,8 +71,7 @@ public function localesExtract() * * @return void */ - public function localesPush() - { + public function localesPush() { $this->_exec('tx push -s'); return $this; } @@ -84,10 +79,11 @@ public function localesPush() /** * Pull locales from transifex. * + * @param integer $percent Completeness percentage + * * @return void */ - public function localesPull($percent = 70) - { + public function localesPull($percent = 70) { $this->_exec('tx pull -a --minimum-perc=' .$percent); return $this; } @@ -97,8 +93,7 @@ public function localesPull($percent = 70) * * @return void */ - public function localesMo() - { + public function localesMo() { $this->_exec('./tools/release --compile-mo'); return $this; } @@ -108,8 +103,7 @@ public function localesMo() * * @return void */ - public function localesSend() - { + public function localesSend() { $this->localesExtract() ->localesPush(); return $this; @@ -118,6 +112,8 @@ public function localesSend() /** * Retrieve locales and generate mo files * + * @param integer $percent Completeness percentage + * * @return void */ public function localesGenerate($percent = 70) { diff --git a/ajax/dropdownChooseField.php b/ajax/dropdownChooseField.php index bb563780..43b66517 100644 --- a/ajax/dropdownChooseField.php +++ b/ajax/dropdownChooseField.php @@ -29,13 +29,11 @@ ---------------------------------------------------------------------- */ // Direct access to file -if (strpos($_SERVER['PHP_SELF'],"dropdownChooseField.php")) { - include ('../../../inc/includes.php'); - header("Content-Type: text/html; charset=UTF-8"); - Html::header_nocache(); +if (strpos($_SERVER['PHP_SELF'], "dropdownChooseField.php")) { + include '../../../inc/includes.php'; + header("Content-Type: text/html; charset=UTF-8"); + Html::header_nocache(); } Session::checkCentralAccess(); PluginDatainjectionInjectionType::dropdownFields($_POST); - -?> \ No newline at end of file diff --git a/ajax/dropdownMandatory.php b/ajax/dropdownMandatory.php index d1096cc6..71255276 100644 --- a/ajax/dropdownMandatory.php +++ b/ajax/dropdownMandatory.php @@ -29,12 +29,11 @@ ---------------------------------------------------------------------- */ // Direct access to file -if (strpos($_SERVER['PHP_SELF'],"dropdownMandatory.php")) { - include ('../../../inc/includes.php'); - header("Content-Type: text/html; charset=UTF-8"); - Html::header_nocache(); +if (strpos($_SERVER['PHP_SELF'], "dropdownMandatory.php")) { + include '../../../inc/includes.php'; + header("Content-Type: text/html; charset=UTF-8"); + Html::header_nocache(); } Session::checkCentralAccess(); PluginDatainjectionInjectionType::showMandatoryCheckBox($_POST); -?> \ No newline at end of file diff --git a/ajax/dropdownSelectModel.php b/ajax/dropdownSelectModel.php index e5c53d3f..81533faf 100644 --- a/ajax/dropdownSelectModel.php +++ b/ajax/dropdownSelectModel.php @@ -29,25 +29,25 @@ ---------------------------------------------------------------------- */ // Direct access to file -if (strpos($_SERVER['PHP_SELF'],"dropdownSelectModel.php")) { - include ('../../../inc/includes.php'); - header("Content-Type: text/html; charset=UTF-8"); - Html::header_nocache(); +if (strpos($_SERVER['PHP_SELF'], "dropdownSelectModel.php")) { + include '../../../inc/includes.php'; + header("Content-Type: text/html; charset=UTF-8"); + Html::header_nocache(); } Session::checkCentralAccess(); if (isset($_SESSION['datainjection']['models_id']) - && $_SESSION['datainjection']['models_id']!=$_POST['models_id']) { - PluginDatainjectionModel::cleanSessionVariables(); + && $_SESSION['datainjection']['models_id']!=$_POST['models_id'] +) { + PluginDatainjectionModel::cleanSessionVariables(); } $_SESSION['datainjection']['step'] = PluginDatainjectionClientInjection::STEP_UPLOAD; $model = new PluginDatainjectionModel(); if (($_POST['models_id'] > 0) - && $model->can($_POST['models_id'], READ)) { - PluginDatainjectionInfo::showAdditionalInformationsForm($model); + && $model->can($_POST['models_id'], READ) +) { + PluginDatainjectionInfo::showAdditionalInformationsForm($model); } - -?> \ No newline at end of file diff --git a/ajax/injection.php b/ajax/injection.php index 78b163f8..838b2dd6 100644 --- a/ajax/injection.php +++ b/ajax/injection.php @@ -29,13 +29,12 @@ ---------------------------------------------------------------------- */ // Direct access to file -if (strpos($_SERVER['PHP_SELF'],"injection.php")) { - include ('../../../inc/includes.php'); - header("Content-Type: text/html; charset=UTF-8"); - Html::header_nocache(); +if (strpos($_SERVER['PHP_SELF'], "injection.php")) { + include '../../../inc/includes.php'; + header("Content-Type: text/html; charset=UTF-8"); + Html::header_nocache(); } Session::checkCentralAccess(); $model = unserialize($_SESSION['datainjection']['currentmodel']); PluginDatainjectionClientInjection::showInjectionForm($model, $_SESSION['glpiactive_entity']); -?> \ No newline at end of file diff --git a/ajax/results.php b/ajax/results.php index d680a623..ec4c57ee 100644 --- a/ajax/results.php +++ b/ajax/results.php @@ -29,13 +29,12 @@ ---------------------------------------------------------------------- */ // Direct access to file -if (strpos($_SERVER['PHP_SELF'],"results.php")) { - include ('../../../inc/includes.php'); - header("Content-Type: text/html; charset=UTF-8"); - Html::header_nocache(); +if (strpos($_SERVER['PHP_SELF'], "results.php")) { + include '../../../inc/includes.php'; + header("Content-Type: text/html; charset=UTF-8"); + Html::header_nocache(); } Session::checkCentralAccess(); $model = unserialize($_SESSION['datainjection']['currentmodel']); PluginDatainjectionClientInjection::showResultsForm($model); -?> \ No newline at end of file diff --git a/css/datainjection.css b/css/datainjection.css index aa88d7a3..275ef8a5 100644 --- a/css/datainjection.css +++ b/css/datainjection.css @@ -84,7 +84,7 @@ margin-right: 10px; .preview { float: left; -margin-left: 10px; +margin-left: 10px; } /**************************************************************/ @@ -310,4 +310,4 @@ text-align: center; font-size: 14px; font-weight: bold; } -/**************************************************************/ \ No newline at end of file +/**************************************************************/ diff --git a/front/clientinjection.form.php b/front/clientinjection.form.php index 1877b143..59aa1f12 100644 --- a/front/clientinjection.form.php +++ b/front/clientinjection.form.php @@ -28,14 +28,16 @@ @since 2009 ---------------------------------------------------------------------- */ -include ('../../../inc/includes.php'); +require '../../../inc/includes.php'; -Html::header(__('File injection', 'datainjection'), $_SERVER["PHP_SELF"], - "tools", "plugindatainjectionmenu", "client"); +Html::header( + __('File injection', 'datainjection'), $_SERVER["PHP_SELF"], + "tools", "plugindatainjectionmenu", "client" +); if (isset($_SESSION['datainjection']['go'])) { - $model = unserialize($_SESSION['datainjection']['currentmodel']); - PluginDatainjectionClientInjection::showInjectionForm($model, $_SESSION['glpiactive_entity']); + $model = unserialize($_SESSION['datainjection']['currentmodel']); + PluginDatainjectionClientInjection::showInjectionForm($model, $_SESSION['glpiactive_entity']); } else if (isset($_POST['upload'])) { $model = new PluginDatainjectionModel(); @@ -44,21 +46,23 @@ //If additional informations provided : check if mandatory infos are present if (!$model->checkMandatoryFields($_SESSION['datainjection']['infos'])) { - Session::addMessageAfterRedirect(__('One mandatory field is not filled', 'datainjection'), - true, ERROR, true); + Session::addMessageAfterRedirect( + __('One mandatory field is not filled', 'datainjection'), + true, ERROR, true + ); } else if (isset($_FILES['filename']['name']) - && $_FILES['filename']['name'] - && $_FILES['filename']['tmp_name'] - && !$_FILES['filename']['error'] - && $_FILES['filename']['size']) { + && $_FILES['filename']['name'] + && $_FILES['filename']['tmp_name'] + && !$_FILES['filename']['error'] + && $_FILES['filename']['size']) { - //Read file using automatic encoding detection, and do not delete file once readed - $options = array('file_encoding' => $_POST['file_encoding'], + //Read file using automatic encoding detection, and do not delete file once readed + $options = array('file_encoding' => $_POST['file_encoding'], 'mode' => PluginDatainjectionModel::PROCESS, 'delete_file' => false); - $response = $model->processUploadedFile($options); - $model->cleanData(); + $response = $model->processUploadedFile($options); + $model->cleanData(); if ($response) { //File uploaded successfully and matches the given model : switch to the import tab @@ -67,33 +71,31 @@ //Store model in session for injection $_SESSION['datainjection']['currentmodel'] = serialize($model); $_SESSION['datainjection']['go'] = true; - } else { //Got back to the file upload page $_SESSION['datainjection']['step'] = PluginDatainjectionClientInjection::STEP_UPLOAD; } } else { - Session::addMessageAfterRedirect(__('The file could not be found', 'datainjection'), - true, ERROR, true); + Session::addMessageAfterRedirect( + __('The file could not be found', 'datainjection'), + true, ERROR, true + ); } - Html::back(); -} else if (isset($_POST['finish']) - || isset($_POST['cancel'])) { + Html::back(); +} else if (isset($_POST['finish']) || isset($_POST['cancel'])) { - PluginDatainjectionSession::removeParams(); - Html::redirect(Toolbox::getItemTypeFormURL('PluginDatainjectionClientInjection')); + PluginDatainjectionSession::removeParams(); + Html::redirect(Toolbox::getItemTypeFormURL('PluginDatainjectionClientInjection')); } else { if (isset($_GET['id'])) { // Allow link to a model PluginDatainjectionSession::setParam('models_id', $_GET['id']); } - $clientInjection = new PluginDatainjectionClientInjection(); - $clientInjection->title(); - $clientInjection->showForm(0); + $clientInjection = new PluginDatainjectionClientInjection(); + $clientInjection->title(); + $clientInjection->showForm(0); } Html::footer(); - -?> \ No newline at end of file diff --git a/front/export.csv.php b/front/export.csv.php index 28b78877..928ab376 100644 --- a/front/export.csv.php +++ b/front/export.csv.php @@ -28,8 +28,6 @@ @since 2009 ---------------------------------------------------------------------- */ -include ('../../../inc/includes.php'); +require '../../../inc/includes.php'; PluginDatainjectionClientInjection::exportErrorsInCSV(); - -?> \ No newline at end of file diff --git a/front/export.pdf.php b/front/export.pdf.php index 61a1eab7..7b38742c 100644 --- a/front/export.pdf.php +++ b/front/export.pdf.php @@ -28,9 +28,7 @@ @since 2009 ---------------------------------------------------------------------- */ -include ('../../../inc/includes.php'); -include ("../../../lib/ezpdf/class.ezpdf.php"); +require '../../../inc/includes.php'; +require "../../../lib/ezpdf/class.ezpdf.php"; PluginDatainjectionModel::exportAsPDF($_GET['models_id']); - -?> \ No newline at end of file diff --git a/front/info.form.php b/front/info.form.php index a9cdd381..66c8ef1d 100644 --- a/front/info.form.php +++ b/front/info.form.php @@ -28,16 +28,16 @@ @since 2009 ---------------------------------------------------------------------- */ -include ('../../../inc/includes.php'); +require '../../../inc/includes.php'; /* Update mappings */ -if (isset ($_POST["update"])) { +if (isset($_POST["update"])) { - PluginDatainjectionInfo::manageInfos($_POST['models_id'], $_POST); + PluginDatainjectionInfo::manageInfos($_POST['models_id'], $_POST); } else if (isset($_POST["delete"])) { - $info = new PluginDatainjectionInfo(); + $info = new PluginDatainjectionInfo(); foreach ($_POST["item"] as $key => $val) { $input = array('id' => $key); if ($val == 1) { @@ -45,11 +45,9 @@ $info->delete($input); } } - Html::back(); + Html::back(); } Session::setActiveTab('PluginDatainjectionModel', 'PluginDatainjectionModel$5'); Html::back(); - -?> \ No newline at end of file diff --git a/front/mapping.form.php b/front/mapping.form.php index bc8abb73..4fffc080 100644 --- a/front/mapping.form.php +++ b/front/mapping.form.php @@ -28,12 +28,12 @@ @since 2009 ---------------------------------------------------------------------- */ -include ('../../../inc/includes.php'); +require '../../../inc/includes.php'; /* Update mappings */ -if (isset ($_POST["update"])) { - $at_least_one_mandatory = false; - $mapping = new PluginDatainjectionMapping(); +if (isset($_POST["update"])) { + $at_least_one_mandatory = false; + $mapping = new PluginDatainjectionMapping(); foreach ($_POST['data'] as $id => $mapping_infos) { $mapping_infos['id'] = $id; @@ -55,22 +55,31 @@ } if (!$at_least_one_mandatory) { - Session::addMessageAfterRedirect(__('One link field must be selected: it will be used to check if data already exists', - 'datainjection'), true, ERROR, true); + Session::addMessageAfterRedirect( + __( + 'One link field must be selected: it will be used to check if data already exists', + 'datainjection' + ), true, ERROR, true + ); } else { $model = new PluginDatainjectionModel(); $model->getFromDB($_POST['models_id']); if ($model->fields['step'] != PluginDatainjectionModel::READY_TO_USE_STEP) { - PluginDatainjectionModel::changeStep($_POST['models_id'], - PluginDatainjectionModel::OTHERS_STEP); + PluginDatainjectionModel::changeStep( + $_POST['models_id'], + PluginDatainjectionModel::OTHERS_STEP + ); Session::setActiveTab('PluginDatainjectionModel', 'PluginDatainjectionModel$5'); - Session::addMessageAfterRedirect(__("This step allows you to add informations not present in the file. You'll be asked for theses informations while using the model.", - 'datainjection')); + Session::addMessageAfterRedirect( + __( + "This step allows you to add informations not present in the file. You'll be asked for theses informations while using the model.", + 'datainjection' + ) + ); } unset($_SESSION['datainjection']['lines']); } } Html::back(); -?> \ No newline at end of file diff --git a/front/model.form.php b/front/model.form.php index cef85259..134163e4 100644 --- a/front/model.form.php +++ b/front/model.form.php @@ -28,76 +28,81 @@ @since 2009 ---------------------------------------------------------------------- */ -include ('../../../inc/includes.php'); +require '../../../inc/includes.php'; -if (!isset ($_GET["id"])) { - $_GET["id"] = ""; +if (!isset($_GET["id"])) { + $_GET["id"] = ""; } -if (!isset ($_GET["withtemplate"])) { - $_GET["withtemplate"] = ""; +if (!isset($_GET["withtemplate"])) { + $_GET["withtemplate"] = ""; } $model = new PluginDatainjectionModel(); $model->checkGlobal(READ); -/* add */ -if (isset ($_POST["add"])) { - $model->check(-1, UPDATE ,$_POST); - $newID = $model->add($_POST); - - //Set display to the advanced options tab - Session::setActiveTab('PluginDatainjectionModel', 'PluginDatainjectionModel$3'); - Html::redirect(Toolbox::getItemTypeFormURL('PluginDatainjectionModel')."?id=$newID"); - -/* delete */ -} else if (isset ($_POST["delete"])) { - $model->check($_POST['id'], DELETE); - $model->delete($_POST); - $model->redirectToList(); - -/* update */ -} else if (isset ($_POST["update"])) { - //Update model - $model->check($_POST['id'], UPDATE); - $model->update($_POST); - - $specific_model = PluginDatainjectionModel::getInstance('csv'); - $specific_model->saveFields($_POST); - Html::back(); - -/* update order */ -} elseif (isset ($_POST["validate"])) { - $model->check($_POST['id'], UPDATE); - $model->switchReadyToUse(); - Html::back(); - -} elseif (isset($_POST['upload'])) { +if (isset($_POST["add"])) { + /* add */ + $model->check(-1, UPDATE, $_POST); + $newID = $model->add($_POST); + + //Set display to the advanced options tab + Session::setActiveTab('PluginDatainjectionModel', 'PluginDatainjectionModel$3'); + Html::redirect(Toolbox::getItemTypeFormURL('PluginDatainjectionModel')."?id=$newID"); + +} else if (isset($_POST["delete"])) { + /* delete */ + $model->check($_POST['id'], DELETE); + $model->delete($_POST); + $model->redirectToList(); + +} else if (isset($_POST["update"])) { + /* update */ + //Update model + $model->check($_POST['id'], UPDATE); + $model->update($_POST); + + $specific_model = PluginDatainjectionModel::getInstance('csv'); + $specific_model->saveFields($_POST); + Html::back(); + +} else if (isset($_POST["validate"])) { + /* update order */ + $model->check($_POST['id'], UPDATE); + $model->switchReadyToUse(); + Html::back(); + +} else if (isset($_POST['upload'])) { if (!empty($_FILES)) { $model->check($_POST['id'], UPDATE); - if ($model->processUploadedFile(array('file_encoding' => 'csv', - 'mode' => PluginDatainjectionModel::CREATION))) { + if ($model->processUploadedFile( + array('file_encoding' => 'csv', + 'mode' => PluginDatainjectionModel::CREATION) + )) { Session::setActiveTab('PluginDatainjectionModel', 'PluginDatainjectionModel$4'); } else { - Session::addMessageAfterRedirect(__('The file could not be found', 'datainjection'), - true, ERROR, true); + Session::addMessageAfterRedirect( + __('The file could not be found', 'datainjection'), + true, ERROR, true + ); } } - Html::back(); - -} elseif (isset($_GET['sample'])) { - $model->check($_GET['sample'], READ); - $modeltype = PluginDatainjectionModel::getInstance($model->getField('filetype')); - $modeltype->getFromDBByModelID($model->getField('id')); - $modeltype->showSample($model); - exit (0); + Html::back(); + +} else if (isset($_GET['sample'])) { + $model->check($_GET['sample'], READ); + $modeltype = PluginDatainjectionModel::getInstance($model->getField('filetype')); + $modeltype->getFromDBByModelID($model->getField('id')); + $modeltype->showSample($model); + exit(0); } -Html::header(PluginDatainjectionModel::getTypeName(), '', - "tools", "plugindatainjectionmenu", "model"); +Html::header( + PluginDatainjectionModel::getTypeName(), '', + "tools", "plugindatainjectionmenu", "model" +); $model->display(array('id' =>$_GET["id"])); Html::footer(); -?> \ No newline at end of file diff --git a/front/model.php b/front/model.php index 04ed07a5..c45af5cf 100644 --- a/front/model.php +++ b/front/model.php @@ -28,13 +28,16 @@ @since 2009 ---------------------------------------------------------------------- */ -include ('../../../inc/includes.php'); +require '../../../inc/includes.php'; -Html::header(PluginDatainjectionModel::getTypeName(), '', "tools", "plugindatainjectionmenu", "model"); +Html::header( + PluginDatainjectionModel::getTypeName(), '', "tools", + "plugindatainjectionmenu", "model" +); $model = new PluginDatainjectionModel(); $model->checkGlobal(READ); Search::show('PluginDatainjectionModel'); -Html::footer(); \ No newline at end of file +Html::footer(); diff --git a/front/popup.php b/front/popup.php index 5d4648eb..56e7626a 100644 --- a/front/popup.php +++ b/front/popup.php @@ -28,21 +28,20 @@ @since 2009 ---------------------------------------------------------------------- */ -include ('../../../inc/includes.php'); +require '../../../inc/includes.php'; Session::checkLoginUser(); switch ($_GET["popup"]) { case "preview" : - Html::popHeader(__('See the file', 'datainjection'), $_SERVER['PHP_SELF']); - PluginDatainjectionModel::showPreviewMappings($_GET['models_id']); - Html::popFooter(); - break; + Html::popHeader(__('See the file', 'datainjection'), $_SERVER['PHP_SELF']); + PluginDatainjectionModel::showPreviewMappings($_GET['models_id']); + Html::popFooter(); + break; case "log" : - Html::popHeader(__('File injection report', 'datainjection'), $_SERVER['PHP_SELF']); - PluginDatainjectionModel::showLogResults($_GET['models_id']); - Html::popFooter(); - break; + Html::popHeader(__('File injection report', 'datainjection'), $_SERVER['PHP_SELF']); + PluginDatainjectionModel::showLogResults($_GET['models_id']); + Html::popFooter(); + break; } -?> \ No newline at end of file diff --git a/hook.php b/hook.php index 709b0382..322a9289 100644 --- a/hook.php +++ b/hook.php @@ -29,34 +29,36 @@ ---------------------------------------------------------------------- */ function plugin_datainjection_registerMethods() { - global $WEBSERVICES_METHOD; - $methods = array('getModel' =>'methodGetModel', - 'listModels' =>'methodListModels', - 'inject' =>'methodInject', - 'listItemtypes' =>'methodListItemtypes'); + global $WEBSERVICES_METHOD; - foreach ($methods as $code => $method) { - $WEBSERVICES_METHOD['datainjection.'.$code] = array('PluginDatainjectionWebservice', - $method); - } + $methods = ['getModel' => 'methodGetModel', + 'listModels' => 'methodListModels', + 'inject' => 'methodInject', + 'listItemtypes' => 'methodListItemtypes']; + + foreach ($methods as $code => $method) { + $WEBSERVICES_METHOD['datainjection.'.$code] + = ['PluginDatainjectionWebservice', $method]; + } } function plugin_datainjection_install() { - global $DB; - - include_once (GLPI_ROOT."/plugins/datainjection/inc/profile.class.php"); - $migration = new Migration('2.3.0'); - + + global $DB; + + include_once GLPI_ROOT."/plugins/datainjection/inc/profile.class.php"; + $migration = new Migration('2.3.0'); + switch (plugin_datainjection_needUpdateOrInstall()) { case -1 : - plugin_datainjection_update220_230(); - plugin_datainjection_upgrade23_240($migration); - return true; + plugin_datainjection_update220_230(); + plugin_datainjection_upgrade23_240($migration); + return true; case 0 : - $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_datainjection_models` ( + $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_datainjection_models` ( `id` int(11) NOT NULL auto_increment, `name` varchar(255) NOT NULL, `comment` text NULL, @@ -78,9 +80,9 @@ function plugin_datainjection_install() { `step` int( 11 ) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci"; - $DB->queryOrDie($query, $DB->error()); + $DB->queryOrDie($query, $DB->error()); - $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_datainjection_modelcsvs` ( + $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_datainjection_modelcsvs` ( `id` int(11) NOT NULL auto_increment, `models_id` int(11) NOT NULL, `itemtype` varchar(255) NOT NULL default '', @@ -88,9 +90,9 @@ function plugin_datainjection_install() { `is_header_present` tinyint(1) NOT NULL default '1', PRIMARY KEY (`ID`) ) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci;"; - $DB->queryOrDie($query, $DB->error()); + $DB->queryOrDie($query, $DB->error()); - $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_datainjection_mappings` ( + $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_datainjection_mappings` ( `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , `models_id` INT( 11 ) NOT NULL , `itemtype` varchar(255) NOT NULL default '', @@ -99,50 +101,60 @@ function plugin_datainjection_install() { `value` VARCHAR( 255 ) NOT NULL , `is_mandatory` TINYINT( 1 ) NOT NULL DEFAULT '0' ) ENGINE = MYISAM CHARSET=utf8 COLLATE=utf8_unicode_ci ;"; - $DB->queryOrDie($query, $DB->error()); + $DB->queryOrDie($query, $DB->error()); - $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_datainjection_infos` ( + $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_datainjection_infos` ( `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , `models_id` INT( 11 ) NOT NULL , `itemtype` varchar(255) NOT NULL default '', `value` VARCHAR( 255 ) NOT NULL , `is_mandatory` TINYINT( 1 ) NOT NULL DEFAULT '0' ) ENGINE = MYISAM CHARSET=utf8 COLLATE=utf8_unicode_ci ;"; - $DB->queryOrDie($query, $DB->error()); + $DB->queryOrDie($query, $DB->error()); if (!is_dir(PLUGIN_DATAINJECTION_UPLOAD_DIR)) { @ mkdir(PLUGIN_DATAINJECTION_UPLOAD_DIR) - or die(sprintf(__('%1$s %2$s'), __("Can't create folder", 'datainjection'), - PLUGIN_DATAINJECTION_UPLOAD_DIR)); + or die( + sprintf( + __('%1$s %2$s'), __("Can't create folder", 'datainjection'), + PLUGIN_DATAINJECTION_UPLOAD_DIR + ) + ); PluginDatainjectionProfile::createFirstAccess($_SESSION["glpiactiveprofile"]["id"]); } - break; + break; default : - break; + break; case 1 : - //When updating, check if the upload folder is already present + //When updating, check if the upload folder is already present if (!is_dir(PLUGIN_DATAINJECTION_UPLOAD_DIR)) { @ mkdir(PLUGIN_DATAINJECTION_UPLOAD_DIR) - or die(sprintf(__('%1$s %2$s'), __("Can't create folder", 'datainjection'), - PLUGIN_DATAINJECTION_UPLOAD_DIR)); + or die( + sprintf( + __('%1$s %2$s'), __("Can't create folder", 'datainjection'), + PLUGIN_DATAINJECTION_UPLOAD_DIR + ) + ); } - //Old temporary directory, needs to be removed ! + //Old temporary directory, needs to be removed ! if (is_dir(GLPI_PLUGIN_DOC_DIR."/data_injection/")) { Toolbox::deleteDir(GLPI_PLUGIN_DOC_DIR."/data_injection/"); } if (TableExists("glpi_plugin_data_injection_models") - && !FieldExists("glpi_plugin_data_injection_models","recursive")) { + && !FieldExists("glpi_plugin_data_injection_models", "recursive") + ) { // Update plugin_datainjection_update131_14(); } if (TableExists("glpi_plugin_data_injection_models") - && !FieldExists("glpi_plugin_data_injection_models","port_unicity")) { + && !FieldExists("glpi_plugin_data_injection_models", "port_unicity") + ) { $migration->addField('glpi_plugin_data_injection_models', 'port_unicity', 'bool'); $migration->executeMigration(); @@ -156,168 +168,189 @@ function plugin_datainjection_install() { plugin_datainjection_update170_20(); } - plugin_datainjection_update210_220(); + plugin_datainjection_update210_220(); - plugin_datainjection_update220_230(); + plugin_datainjection_update220_230(); - plugin_datainjection_upgrade23_240($migration); - - break; + plugin_datainjection_upgrade23_240($migration); + + break; } - return true; + return true; } function plugin_datainjection_uninstall() { - global $DB; - $tables = array("glpi_plugin_datainjection_models", - "glpi_plugin_datainjection_modelcsvs", - "glpi_plugin_datainjection_mappings", - "glpi_plugin_datainjection_infos", - "glpi_plugin_datainjection_filetype", - "glpi_plugin_datainjection_profiles"); + global $DB; + + $tables = ["glpi_plugin_datainjection_models", + "glpi_plugin_datainjection_modelcsvs", + "glpi_plugin_datainjection_mappings", + "glpi_plugin_datainjection_infos", + "glpi_plugin_datainjection_filetype", + "glpi_plugin_datainjection_profiles"]; - foreach ($tables as $table) { - if (TableExists($table)) { - $DB->queryOrDie("DROP TABLE IF EXISTS `".$table."`", $DB->error()); + foreach ($tables as $table) { + if (TableExists($table)) { + $DB->queryOrDie("DROP TABLE IF EXISTS `".$table."`", $DB->error()); + } } - } - if (is_dir(PLUGIN_DATAINJECTION_UPLOAD_DIR)) { - Toolbox::deleteDir(PLUGIN_DATAINJECTION_UPLOAD_DIR); - } + if (is_dir(PLUGIN_DATAINJECTION_UPLOAD_DIR)) { + Toolbox::deleteDir(PLUGIN_DATAINJECTION_UPLOAD_DIR); + } - plugin_init_datainjection(); - return true; + plugin_init_datainjection(); + return true; } function plugin_datainjection_upgrade23_240($migration) { - PluginDatainjectionProfile::migrateProfiles(); - - //Drop profile table : no use anymore ! - $migration->dropTable('glpi_plugin_datainjection_profiles'); + + PluginDatainjectionProfile::migrateProfiles(); + + //Drop profile table : no use anymore ! + $migration->dropTable('glpi_plugin_datainjection_profiles'); } function plugin_datainjection_update131_14() { - global $DB; - $migration = new Migration('1.4'); + global $DB; - $migration->addField('glpi_plugin_data_injection_models', 'float_format', 'bool'); + $migration = new Migration('1.4'); - //Template recursivity : need standardize names in order to use privatePublicSwitch - $migration->changeField('glpi_plugin_data_injection_models', 'user_id', 'FK_users', 'integer'); - $migration->changeField('glpi_plugin_data_injection_models', 'public', 'private', 'bool'); + $migration->addField( + 'glpi_plugin_data_injection_models', 'float_format', + 'bool' + ); - $migration->migrationOneTable('glpi_plugin_data_injection_models'); + //Template recursivity : need standardize names in order to use privatePublicSwitch + $migration->changeField( + 'glpi_plugin_data_injection_models', 'user_id', + 'FK_users', 'integer' + ); + $migration->changeField( + 'glpi_plugin_data_injection_models', 'public', + 'private', 'bool' + ); - $sql = "UPDATE `glpi_plugin_data_injection_models` + $migration->migrationOneTable('glpi_plugin_data_injection_models'); + + $sql = "UPDATE `glpi_plugin_data_injection_models` SET `FK_entities` = '-1', `private` = '1' WHERE `private` = '0'"; - $DB->query($sql); + $DB->query($sql); - $sql = "UPDATE `glpi_plugin_data_injection_models` + $sql = "UPDATE `glpi_plugin_data_injection_models` SET `private` = '0' WHERE `private` = '1' AND `FK_entities` > '0'"; - $DB->query($sql); + $DB->query($sql); - $migration->addField('glpi_plugin_data_injection_models', 'recursive','bool'); + $migration->addField( + 'glpi_plugin_data_injection_models', 'recursive', + 'bool' + ); - $sql = "UPDATE `glpi_plugin_data_injection_profiles` + $sql = "UPDATE `glpi_plugin_data_injection_profiles` SET `create_model` = `use_model` WHERE `create_model` IS NULL"; - $DB->query($sql); + $DB->query($sql); - $migration->dropField('glpi_plugin_data_injection_profiles', 'use_model'); - $migration->changeField('glpi_plugin_data_injection_profiles', 'create_model', 'model', 'char'); + $migration->dropField('glpi_plugin_data_injection_profiles', 'use_model'); + $migration->changeField( + 'glpi_plugin_data_injection_profiles', + 'create_model', 'model', 'char' + ); - $migration->executeMigration(); + $migration->executeMigration(); } function plugin_datainjection_update15_170() { - global $DB; - $tables = array("glpi_plugin_data_injection_models" => "glpi_plugin_datainjection_models", - "glpi_plugin_data_injection_models_csv" => "glpi_plugin_datainjection_models_csv", - "glpi_plugin_data_injection_models_csv" => "glpi_plugin_datainjection_models_csv", - "glpi_plugin_data_injection_mappings" => "glpi_plugin_datainjection_mappings", - "glpi_plugin_data_injection_infos" => "glpi_plugin_datainjection_infos", - "glpi_plugin_data_injection_filetype" => "glpi_plugin_datainjection_filetype", - "glpi_plugin_data_injection_profiles" => "glpi_plugin_datainjection_profiles"); + global $DB; - foreach ($tables as $oldname => $newname) { - $query = "RENAME TABLE IF EXISTS `".$oldname."` TO `".$newname."`"; - $DB->query($query); - } + $tables = ["glpi_plugin_data_injection_models" => "glpi_plugin_datainjection_models", + "glpi_plugin_data_injection_models_csv" => "glpi_plugin_datainjection_models_csv", + "glpi_plugin_data_injection_models_csv" => "glpi_plugin_datainjection_models_csv", + "glpi_plugin_data_injection_mappings" => "glpi_plugin_datainjection_mappings", + "glpi_plugin_data_injection_infos" => "glpi_plugin_datainjection_infos", + "glpi_plugin_data_injection_filetype" => "glpi_plugin_datainjection_filetype", + "glpi_plugin_data_injection_profiles" => "glpi_plugin_datainjection_profiles"]; + + foreach ($tables as $oldname => $newname) { + $query = "RENAME TABLE IF EXISTS `".$oldname."` TO `".$newname."`"; + $DB->query($query); + } } function plugin_datainjection_update170_20() { global $DB; - $migration = new Migration('2.0'); - $migration->changeField('glpi_plugin_datainjection_models', 'ID', 'id', 'autoincrement'); - $migration->changeField('glpi_plugin_datainjection_models', 'type', 'filetype', 'string', - array('value' => 'csv')); + $migration->changeField('glpi_plugin_datainjection_models', 'ID', 'id', + 'autoincrement'); + $migration->changeField('glpi_plugin_datainjection_models', 'type', + 'filetype', 'string', ['value' => 'csv']); $migration->addField('glpi_plugin_datainjection_models', 'step', 'integer'); - $migration->changeField('glpi_plugin_datainjection_models', 'comments', 'comment', 'text'); - $migration->changeField('glpi_plugin_datainjection_models', 'device_type', 'itemtype', 'string', - array('value' => '')); - $migration->changeField('glpi_plugin_datainjection_models', 'FK_entities', 'entities_id', - 'integer'); - $migration->changeField('glpi_plugin_datainjection_models', 'private', 'is_private', 'bool'); - $migration->changeField('glpi_plugin_datainjection_models', 'FK_users', 'users_id', 'integer'); - $migration->changeField('glpi_plugin_datainjection_models', 'recursive', 'is_recursive', 'bool'); + $migration->changeField('glpi_plugin_datainjection_models', 'comments', + 'comment', 'text'); + $migration->changeField('glpi_plugin_datainjection_models', 'device_type', + 'itemtype', 'string', ['value' => '']); + $migration->changeField('glpi_plugin_datainjection_models', 'FK_entities', + 'entities_id', 'integer'); + $migration->changeField('glpi_plugin_datainjection_models', 'private', + 'is_private', 'bool'); + $migration->changeField('glpi_plugin_datainjection_models', 'FK_users', + 'users_id', 'integer'); + $migration->changeField('glpi_plugin_datainjection_models', 'recursive', + 'is_recursive', 'bool'); $migration->migrationOneTable('glpi_plugin_datainjection_models'); $query = "UPDATE `glpi_plugin_datainjection_models` - SET `step` = '5'"; + SET `step` = '5'"; $DB->query($query); $query = "UPDATE `glpi_plugin_datainjection_models` - SET `filetype` = 'csv'"; + SET `filetype` = 'csv'"; $DB->queryOrDie($query, "update filetype of glpi_plugin_datainjection_models"); - $migration->dropTable('glpi_plugin_datainjection_filetype'); - $migration->renameTable('glpi_plugin_datainjection_models_csv', - 'glpi_plugin_datainjection_modelcsvs'); + 'glpi_plugin_datainjection_modelcsvs'); - $migration->changeField('glpi_plugin_datainjection_modelcsvs', 'model_id', 'models_id', - 'integer'); - $migration->changeField('glpi_plugin_datainjection_modelcsvs', 'device_type', 'itemtype', - 'string', array('value' => '')); + $migration->changeField('glpi_plugin_datainjection_modelcsvs', 'model_id', + 'models_id', 'integer'); + $migration->changeField('glpi_plugin_datainjection_modelcsvs', 'device_type', + 'itemtype', 'string', ['value' => '']); $migration->changeField('glpi_plugin_datainjection_modelcsvs', 'header_present', - 'is_header_present', 'bool', array('value' => 1)); - - - $migration->changeField('glpi_plugin_datainjection_mappings', 'mandatory', 'is_mandatory', - 'bool'); - $migration->changeField('glpi_plugin_datainjection_mappings', 'type', 'itemtype', 'string', - array('value' => '')); - $migration->changeField('glpi_plugin_datainjection_mappings', 'model_id', 'models_id', 'integer'); - - $migration->changeField('glpi_plugin_datainjection_infos', 'type', 'itemtype', 'string', - array('value' => '')); - $migration->changeField('glpi_plugin_datainjection_infos', 'model_id', 'models_id', 'integer'); - $migration->changeField('glpi_plugin_datainjection_infos', 'mandatory', 'is_mandatory', - 'bool'); - - - $glpitables = array('glpi_plugin_datainjection_models', - 'glpi_plugin_datainjection_mappings', - 'glpi_plugin_datainjection_infos', - 'glpi_plugin_datainjection_modelcsvs', - 'glpi_plugin_datainjection_profiles'); + 'is_header_present', 'bool', ['value' => 1]); + + $migration->changeField('glpi_plugin_datainjection_mappings', 'mandatory', + 'is_mandatory', 'bool'); + $migration->changeField('glpi_plugin_datainjection_mappings', 'type', + 'itemtype', 'string', ['value' => '']); + $migration->changeField('glpi_plugin_datainjection_mappings', 'model_id', + 'models_id', 'integer'); + + $migration->changeField('glpi_plugin_datainjection_infos', 'type', + 'itemtype', 'string', ['value' => '']); + $migration->changeField('glpi_plugin_datainjection_infos', 'model_id', + 'models_id', 'integer'); + $migration->changeField('glpi_plugin_datainjection_infos', 'mandatory', + 'is_mandatory', 'bool'); + + $glpitables = ['glpi_plugin_datainjection_models', + 'glpi_plugin_datainjection_mappings', + 'glpi_plugin_datainjection_modelcsvs', + 'glpi_plugin_datainjection_infos', + 'glpi_plugin_datainjection_profiles']; foreach ($glpitables as $table) { $migration->changeField($table, 'ID', 'id', 'autoincrement'); @@ -327,11 +360,11 @@ function plugin_datainjection_update170_20() { $migration->migrationOneTable('glpi_plugin_datainjection_infos'); $migration->migrationOneTable('glpi_plugin_datainjection_modelcsvs'); - $glpitables = array('glpi_plugin_datainjection_models', - 'glpi_plugin_datainjection_mappings', - 'glpi_plugin_datainjection_infos', - 'glpi_plugin_datainjection_modelcsvs'); - Plugin::migrateItemType (array(), array(), $glpitables); + $glpitables = ['glpi_plugin_datainjection_models', + 'glpi_plugin_datainjection_mappings', + 'glpi_plugin_datainjection_infos', + 'glpi_plugin_datainjection_modelcsvs']; + Plugin::migrateItemType(array(), array(), $glpitables); $query = "UPDATE `glpi_plugin_datainjection_mappings` SET `itemtype` = 'none' , @@ -346,73 +379,58 @@ function plugin_datainjection_update170_20() { $DB->queryOrDie($query, "Datainjection infos table : error updating not mapped fields"); $foreignkeys = array('assign' - => array(array('to' => 'users_id_assign', - 'tables' => array('glpi_tickets'))), - - 'assign_group' + => array(array('to' => 'users_id_assign', + 'tables' => array('glpi_tickets'))), + 'assign_group' => array(array('to' => 'groups_id_assign', 'tables' => array('glpi_tickets'))), - - 'assign_ent' + 'assign_ent' => array(array('to' => 'suppliers_id_assign', 'tables' => array('glpi_tickets'))), - - 'auth_method' + 'auth_method' => array(array('to' => 'authtype', 'noindex' => array('glpi_users'), 'tables' => array('glpi_users'))), - - 'author' + 'author' => array(array('to' => 'users_id', 'tables' => array('glpi_ticketfollowups', 'glpi_knowbaseitems', 'glpi_tickets'))), - - 'auto_update' + 'auto_update' => array(array('to' => 'autoupdatesystems_id', 'tables' => array('glpi_computers'))), - - 'budget' + 'budget' => array(array('to' => 'budgets_id', 'tables' => array('glpi_infocoms'))), - - 'buy_version' + 'buy_version' => array(array('to' => 'softwareversions_id_buy', 'tables' => array('glpi_softwarelicenses'))), - - 'category' + 'category' => array(array('to' => 'ticketcategories_id', 'tables' => array('glpi_tickets')), array('to' => 'softwarecategories_id', 'tables' => array('glpi_softwares'))), - - 'categoryID' + 'categoryID' => array(array('to' => 'knowbaseitemcategories_id', 'tables' => array('glpi_knowbaseitems'))), - - 'cID' + 'cID' => array(array('to' => 'computers_id', 'tables' => array('glpi_computers_softwareversions'))), - - 'computer' + 'computer' => array(array('to' => 'items_id', 'tables' => array('glpi_tickets'))), - - 'computer_id' + 'computer_id' => array(array('to' => 'computers_id', 'tables' => array('glpi_registrykeys'))), - - 'contract_type' + 'contract_type' => array(array('to' => 'contracttypes_id', 'tables' => array('glpi_contracts'))), - - 'default_rubdoc_tracking' + 'default_rubdoc_tracking' => array(array('to' => 'documentcategories_id_forticket', 'tables' => array('glpi_configs'), 'comments' => array('glpi_configs' => 'default category for documents added with a ticket'))), - - 'device_type' + 'device_type' => array(array('to' => 'itemtype', 'tables' => array('glpi_alerts', 'glpi_contracts_items', 'glpi_documents_items', 'glpi_infocoms', @@ -421,59 +439,48 @@ function plugin_datainjection_update170_20() { 'glpi_networkports', 'glpi_reservationitems', 'glpi_tickets'))), - - 'domain' + 'domain' => array(array('to' => 'domains_id', 'tables' => array('glpi_computers', 'glpi_networkequipments', 'glpi_printers'))), - - 'end1' + 'end1' => array(array('to' => 'items_id', 'tables' => array('glpi_computers_items'), 'comments' => array('glpi_computers_items' => 'RELATION to various table, according to itemtype (ID)')), array('to' => 'networkports_id_1', 'tables' => array('glpi_networkports_networkports'))), - - 'end2' + 'end2' => array(array('to' => 'computers_id', 'tables' => array('glpi_computers_items')), array('to' => 'networkports_id_2', 'tables' => array('glpi_networkports_networkports')) ), - - 'firmware' + 'firmware' => array(array('to' => 'networkequipmentfirmwares_id', 'tables' => array('glpi_networkequipments'))), - - 'FK_bookmark' + 'FK_bookmark' => array(array('to' => 'bookmarks_id', 'tables' => array('glpi_bookmarks_users'))), - - 'FK_computers' + 'FK_computers' => array(array('to' => 'computers_id', 'tables' => array('glpi_computerdisks', 'glpi_softwarelicenses'))), - - 'FK_contact' + 'FK_contact' => array(array('to' => 'contacts_id', 'tables' => array('glpi_contacts_suppliers'))), - - 'FK_contract' + 'FK_contract' => array(array('to' => 'contracts_id', 'tables' => array('glpi_contracts_suppliers', 'glpi_contracts_items'))), - - 'FK_device' + 'FK_device' => array(array('to' => 'items_id', 'tables' => array('glpi_alerts', 'glpi_contracts_items', 'glpi_documents_items', 'glpi_infocoms'))), - - 'FK_doc' + 'FK_doc' => array(array('to' => 'documents_id', 'tables' => array('glpi_documents_items'))), - - 'manufacturer' + 'manufacturer' => array(array('to' => 'suppliers_id', 'tables' => array('glpi_contacts_suppliers', 'glpi_contracts_suppliers', @@ -495,8 +502,7 @@ function plugin_datainjection_update170_20() { 'glpi_networkequipments', 'glpi_peripherals', 'glpi_phones', 'glpi_printers', 'glpi_softwares'))), - - 'FK_entities' + 'FK_entities' => array(array('to' => 'entities_id', 'tables' => array('glpi_bookmarks', 'glpi_cartridgeitems', 'glpi_computers', 'glpi_consumableitems', @@ -515,61 +521,53 @@ function plugin_datainjection_update170_20() { 'glpi_tickets', 'glpi_users', 'glpi_profiles_users'), 'default' => array('glpi_bookmarks' => "-1"))), - - 'FK_filesystems' + 'FK_filesystems' => array(array('to' => 'filesystems_id', 'tables' => array('glpi_computerdisks'))), - - 'FK_glpi_cartridges_type' + 'FK_glpi_cartridges_type' => array(array('to' => 'cartridgeitems_id', 'tables' => array('glpi_cartridges', 'glpi_cartridges_printermodels'))), - - 'FK_glpi_consumables_type' + 'FK_glpi_consumables_type' => array(array('to' => 'consumableitems_id', 'tables' => array('glpi_consumables'))), - - 'FK_glpi_dropdown_model_printers' + 'FK_glpi_dropdown_model_printers' => array(array('to' => 'printermodels_id', 'tables' => array('glpi_cartridges_printermodels'))), - - 'FK_glpi_printers' + 'FK_glpi_printers' => array(array('to' => 'printers_id', 'tables' => array('glpi_cartridges'))), - - 'FK_group' + 'FK_group' => array(array('to' => 'groups_id', 'tables' => array('glpi_tickets'))), - - 'FK_groups' + 'FK_groups' => array(array('to' => 'groups_id', 'tables' => array('glpi_computers', 'glpi_monitors', 'glpi_networkequipments', 'glpi_peripherals', 'glpi_phones', 'glpi_printers', 'glpi_softwares', 'glpi_groups_users'))), - - 'FK_interface' + 'FK_interface' => array(array('to' => 'interfacetypes_id', 'tables' => array('glpi_devicegraphiccards'))), - 'FK_item' + 'FK_item' => array(array('to' => 'items_id', 'tables' => array('glpi_mailingsettings'))), - 'FK_links' + 'FK_links' => array(array('to' => 'links_id', 'tables' => array('glpi_links_itemtypes'))), - 'FK_port' + 'FK_port' => array(array('to' => 'networkports_id', 'tables' => array('glpi_networkports_vlans'))), - 'FK_profiles' + 'FK_profiles' => array(array('to' => 'profiles_id', 'tables' => array('glpi_profiles_users', 'glpi_users'))), - 'FK_users' + 'FK_users' => array(array('to' => 'users_id', 'tables' => array('glpi_bookmarks', 'glpi_displaypreferences', @@ -581,46 +579,46 @@ function plugin_datainjection_update170_20() { 'glpi_peripherals', 'glpi_phones', 'glpi_printers', 'glpi_softwares'))), - 'FK_vlan' + 'FK_vlan' => array(array('to' => 'vlans_id', 'tables' => array('glpi_networkports_vlans'))), - 'glpi_id' + 'glpi_id' => array(array('to' => 'computers_id', 'tables' => array('glpi_ocslinks'))), - 'id_assign' + 'id_assign' => array(array('to' => 'users_id', 'tables' => array('glpi_ticketplannings'))), - 'id_auth' + 'id_auth' => array(array('to' => 'auths_id', 'tables' => array('glpi_users'))), - 'id_device' + 'id_device' => array(array('to' => 'items_id', 'tables' => array('glpi_reservationitems'))), - 'id_item' + 'id_item' => array(array('to' => 'reservationitems_id', 'tables' => array('glpi_reservations'))), - 'id_user' + 'id_user' => array(array('to' => 'users_id', 'tables' => array('glpi_consumables', 'glpi_reservations'))), - 'iface' + 'iface' => array(array('to' => 'networkinterfaces_id', 'tables' => array('glpi_networkports'))), - 'interface' + 'interface' => array(array('to' => 'interfacetypes_id', 'tables' => array('glpi_devicecontrols', 'glpi_deviceharddrives', 'glpi_devicedrives'))), - 'location' + 'location' => array(array('to' => 'locations_id', 'tables' => array('glpi_cartridgeitems', 'glpi_computers', 'glpi_consumableitems', 'glpi_netpoints', @@ -629,7 +627,7 @@ function plugin_datainjection_update170_20() { 'glpi_printers', 'glpi_users', 'glpi_softwares'))), - 'model' + 'model' => array(array('to' => 'computermodels_id', 'tables' => array('glpi_computers')), array('to' => 'monitormodels_id', @@ -643,33 +641,33 @@ function plugin_datainjection_update170_20() { array('to' => 'printermodels_id', 'tables' => array('glpi_printers'))), - 'netpoint' + 'netpoint' => array(array('to' => 'netpoints_id', 'tables' => array('glpi_networkports'))), - 'network' + 'network' => array(array('to' => 'networks_id', 'tables' => array('glpi_computers', 'glpi_networkequipments', 'glpi_printers'))), - 'on_device' + 'on_device' => array(array('to' => 'items_id', 'tables' => array('glpi_networkports'))), - 'os' + 'os' => array(array('to' => 'operatingsystems_id', 'tables' => array('glpi_computers'))), - 'os_license_id' + 'os_license_id' => array(array('to' => 'os_licenseid', 'tables' => array('glpi_computers'))), - 'os_version' + 'os_version' => array(array('to' => 'operatingsystemversions_id', 'tables' => array('glpi_computers'))), - 'parentID' + 'parentID' => array(array('to' => 'knowbaseitemcategories_id', 'tables' => array('glpi_knowbaseitemcategories')), array('to' => 'locations_id', @@ -679,28 +677,28 @@ function plugin_datainjection_update170_20() { array('to' => 'entities_id', 'tables' => array('glpi_entities')) ), - 'platform' + 'platform' => array(array('to' => 'operatingsystems_id', 'tables' => array('glpi_softwares'))), - 'power' + 'power' => array(array('to' => 'phonepowersupplies_id', 'tables' => array('glpi_phones'))), - 'recipient' + 'recipient' => array(array('to' => 'users_id_recipient', 'tables' => array('glpi_tickets'))), - 'rubrique' + 'rubrique' => array(array('to' => 'documentcategories_id', 'tables' => array('glpi_documents'))), - 'sID' + 'sID' => array(array('to' => 'softwares_id', 'tables' => array('glpi_softwarelicenses', 'glpi_softwareversions'))), - 'state' + 'state' => array(array('to' => 'states_id', 'tables' => array('glpi_computers', 'glpi_monitors', 'glpi_networkequipments', @@ -708,7 +706,7 @@ function plugin_datainjection_update170_20() { 'glpi_printers', 'glpi_softwareversions'))), - 'tech_num' + 'tech_num' => array(array('to' => 'users_id_tech', 'tables' => array('glpi_cartridgeitems', 'glpi_computers', 'glpi_consumableitems', 'glpi_monitors', @@ -716,11 +714,11 @@ function plugin_datainjection_update170_20() { 'glpi_peripherals', 'glpi_phones', 'glpi_printers', 'glpi_softwares'))), - 'title' + 'title' => array(array('to' => 'usertitles_id', 'tables' => array('glpi_users'))), - 'type' + 'type' => array(array('to' => 'cartridgeitemtypes_id', 'tables' => array('glpi_cartridgeitems')), array('to' => 'computertypes_id', @@ -753,76 +751,76 @@ function plugin_datainjection_update170_20() { 'tables' => array('glpi_computers_items', 'glpi_displaypreferences'))), - 'update_software' + 'update_software' => array(array('to' => 'softwares_id', 'tables' => array('glpi_softwares'))), - 'use_version' + 'use_version' => array(array('to' => 'softwareversions_id_use', 'tables' => array('glpi_softwarelicenses'))), - 'vID' + 'vID' => array(array('to' => 'softwareversions_id', 'tables' => array('glpi_computers_softwareversions'))), - 'conpta_num' + 'conpta_num' => array(array('to' => 'accounting_number', 'tables' => array('glpi_contracts'))), - 'num_commande' + 'num_commande' => array(array('to' => 'order_number', 'tables' => array('glpi_infocoms'))), - 'bon_livraison' + 'bon_livraison' => array(array('to' => 'delivery_number', 'tables' => array('glpi_infocoms'))), - 'num_immo' + 'num_immo' => array(array('to' => 'immo_number', 'tables' => array('glpi_infocoms'))), - 'facture' + 'facture' => array(array('to' => 'bill', 'tables' => array('glpi_infocoms'))), - 'amort_time' + 'amort_time' => array(array('to' => 'sink_time', 'tables' => array('glpi_infocoms'))), - 'amort_type' + 'amort_type' => array(array('to' => 'sink_type', 'tables' => array('glpi_infocoms'))), - 'ifmac' + 'ifmac' => array(array('to' => 'mac', 'tables' => array('glpi_networkequipments'))), - 'ifaddr' + 'ifaddr' => array(array('to' => 'ip', 'tables' => array('glpi_networkequipments', 'glpi_networkports'))), - 'ramSize' + 'ramSize' => array(array('to' => 'memory_size', 'tables' => array('glpi_printers'))), - 'ramSize' + 'ramSize' => array(array('to' => 'memory_size', 'tables' => array('glpi_printers'))), - 'facturation' + 'facturation' => array(array('to' => 'billing', 'tables' => array('glpi_contracts'))), - 'monday' + 'monday' => array(array('to' => 'use_monday', 'tables' => array('glpi_contracts'))), - 'saturday' + 'saturday' => array(array('to' => 'use_saturday', 'tables' => array('glpi_contracts'))), - 'recursive' + 'recursive' => array(array('to' => 'is_recursive', 'tables' => array('glpi_networkequipments', 'glpi_groups', 'glpi_contracts', 'glpi_contacts', @@ -830,59 +828,59 @@ function plugin_datainjection_update170_20() { 'glpi_softwares', 'glpi_softwareversions', 'glpi_softwarelicences'))), - 'faq' + 'faq' => array(array('to' => 'is_faq', 'tables' => array('glpi_knowbaseitems'))), - 'flags_micro' + 'flags_micro' => array(array('to' => 'have_micro', 'tables' => array('glpi_monitors'))), - 'flags_speaker' + 'flags_speaker' => array(array('to' => 'have_speaker', 'tables' => array('glpi_monitors'))), - 'flags_subd' + 'flags_subd' => array(array('to' => 'have_subd', 'tables' => array('glpi_monitors'))), - 'flags_bnc' + 'flags_bnc' => array(array('to' => 'have_bnc', 'tables' => array('glpi_monitors'))), - 'flags_dvi' + 'flags_dvi' => array(array('to' => 'have_dvi', 'tables' => array('glpi_monitors'))), - 'flags_pivot' + 'flags_pivot' => array(array('to' => 'have_pivot', 'tables' => array('glpi_monitors'))), - 'flags_hp' + 'flags_hp' => array(array('to' => 'have_hp', 'tables' => array('glpi_phones'))), - 'flags_casque' + 'flags_casque' => array(array('to' => 'have_headset', 'tables' => array('glpi_phones'))), - 'flags_usb' + 'flags_usb' => array(array('to' => 'have_usb', 'tables' => array('glpi_printers'))), - 'flags_par' + 'flags_par' => array(array('to' => 'have_parallel', 'tables' => array('glpi_printers'))), - 'flags_serial' + 'flags_serial' => array(array('to' => 'have_serial', 'tables' => array('glpi_printers'))), - 'initial_pages' + 'initial_pages' => array(array('to' => 'init_pages_counter', 'tables' => array('glpi_printers'))), - 'global' + 'global' => array(array('to' => 'is_global', 'tables' => array('glpi_monitors', 'glpi_networkequipments', 'glpi_peripherals', 'glpi_phones', @@ -933,7 +931,7 @@ function plugin_datainjection_update170_20() { 'glpi_peripheraltypes', 'glpi_phonetypes', 'glpi_printertypes', 'glpi_users'))), - 'notes' => array(array('to' => 'notepad', + 'notes' => array(array('to' => 'notepad', 'tables' => array('glpi_cartridgeitems', 'glpi_computers', 'glpi_consumableitems', 'glpi_contacts', 'glpi_contracts', 'glpi_documents', @@ -943,45 +941,41 @@ function plugin_datainjection_update170_20() { 'glpi_networkequipments', 'glpi_softwares')))); - $foreignkeys = Plugin::doHookFunction("plugin_datainjection_migratefields",$foreignkeys); - - $query = "SELECT `itemtype`, `value` - FROM `glpi_plugin_datainjection_mappings` - WHERE `itemtype` NOT IN ('none') - GROUP BY `itemtype`,`value`"; - - foreach ($DB->request($query) as $data) { - if (isset($foreignkeys[$data['value']])) { - foreach ($foreignkeys[$data['value']] as $field_info) { - $table = getTableForItemType($data['itemtype']); - - if (in_array($table,$field_info['tables'])) { - $query = "UPDATE `glpi_plugin_datainjection_mappings` - SET `value` = '".$field_info['to']."' - WHERE `itemtype` = '".$data['itemtype']."' - AND `value` = '".$data['value']."'"; - $DB->queryOrDie($query, "Datainjection : error converting mapping fields"); - - $query = "UPDATE `glpi_plugin_datainjection_infos` - SET `value` = '".$field_info['to']."' - WHERE `itemtype` = '".$data['itemtype']."' - AND `value` = '".$data['value']."'"; - $DB->queryOrDie($query, "Datainjection : error converting infos fields"); + $foreignkeys = Plugin::doHookFunction("plugin_datainjection_migratefields", $foreignkeys); + $query = "SELECT `itemtype`, `value` + FROM `glpi_plugin_datainjection_mappings` + WHERE `itemtype` NOT IN ('none') + GROUP BY `itemtype`,`value`"; + + foreach ($DB->request($query) as $data) { + if (isset($foreignkeys[$data['value']])) { + foreach ($foreignkeys[$data['value']] as $field_info) { + $table = getTableForItemType($data['itemtype']); + if (in_array($table, $field_info['tables'])) { + $query = "UPDATE `glpi_plugin_datainjection_mappings` + SET `value` = '".$field_info['to']."' + WHERE `itemtype` = '".$data['itemtype']."' + AND `value` = '".$data['value']."'"; + $DB->queryOrDie($query, "Datainjection : error converting mapping fields"); + $query = "UPDATE `glpi_plugin_datainjection_infos` + SET `value` = '".$field_info['to']."' + WHERE `itemtype` = '".$data['itemtype']."' + AND `value` = '".$data['value']."'"; + $DB->queryOrDie($query, "Datainjection : error converting infos fields"); } } } } } - function plugin_datainjection_update210_220() { global $DB; - foreach(array('glpi_plugin_datainjection_mappings', - 'glpi_plugin_datainjection_infos') as $table) { + foreach (['glpi_plugin_datainjection_mappings', + 'glpi_plugin_datainjection_infos'] as $table) { - $move = array('TicketCategory' => 'ITILCategory', - 'TicketSolutionType' => 'SolutionType'); + $move = ['TicketCategory' => 'ITILCategory', + 'TicketSolutionType' => 'SolutionType']; foreach ($move as $old => $new) { $query = "UPDATE `".$table."` SET `itemtype` = '".$new."' @@ -996,13 +990,13 @@ function plugin_datainjection_update210_220() { AND `value` = 'email'"; $DB->query($query); } -} - +} 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', @@ -1018,15 +1012,19 @@ function plugin_datainjection_update220_230() { * @param $params array **/ function plugin_datainjection_loadHook($hook_name, $params=array ()) { + global $PLUGIN_HOOKS; if (!empty($params)) { $type = $params["type"]; //If a plugin type is defined - Plugin::doOneHook($PLUGIN_HOOKS['plugin_types'][$type], 'datainjection_' . $hook_name); + Plugin::doOneHook( + $PLUGIN_HOOKS['plugin_types'][$type], + 'datainjection_' . $hook_name + ); } else { - if (isset ($PLUGIN_HOOKS['plugin_types'])) { + if (isset($PLUGIN_HOOKS['plugin_types'])) { //Browse all plugins foreach ($PLUGIN_HOOKS['plugin_types'] as $type => $name) { Plugin::doOneHook($name, 'datainjection_' . $hook_name); @@ -1038,7 +1036,7 @@ function plugin_datainjection_loadHook($hook_name, $params=array ()) { function plugin_datainjection_needUpdateOrInstall() { - //Install plugin + //Install plugin if (!TableExists('glpi_plugin_datainjection_models')) { return 0; } @@ -1047,7 +1045,7 @@ function plugin_datainjection_needUpdateOrInstall() { return -1; } - return 1; + return 1; } @@ -1060,8 +1058,10 @@ function plugin_datainjection_addDefaultWhere($itemtype) { switch ($itemtype) { case 'PluginDatainjectionModel' : - $models = PluginDatainjectionModel::getModels(Session::getLoginUserID(), 'name', - $_SESSION['glpiactive_entity'], true); + $models = PluginDatainjectionModel::getModels( + Session::getLoginUserID(), 'name', + $_SESSION['glpiactive_entity'], true + ); if (count($models) > 0) { $tab = array(); foreach ($models as $model) { @@ -1073,7 +1073,7 @@ function plugin_datainjection_addDefaultWhere($itemtype) { return $where; } return false; + default: + break; } - } -?> diff --git a/inc/autoupdatesysteminjection.class.php b/inc/autoupdatesysteminjection.class.php index 8071ea4f..c7a318b2 100644 --- a/inc/autoupdatesysteminjection.class.php +++ b/inc/autoupdatesysteminjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionAutoUpdateSystemInjection extends AutoUpdateSystem - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,11 +45,13 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } @@ -68,7 +71,7 @@ function getOptions($primary_type='') { } - /** + /** * Standard method to add an object into glpi * * @param $values array fields to add into glpi @@ -84,4 +87,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/backend.class.php b/inc/backend.class.php index 8bf5f787..8013c65c 100644 --- a/inc/backend.class.php +++ b/inc/backend.class.php @@ -30,7 +30,8 @@ /* * Common backend to read files to import */ -abstract class PluginDatainjectionBackend { +abstract class PluginDatainjectionBackend +{ private $file = ""; private $delimiter; @@ -38,12 +39,12 @@ abstract class PluginDatainjectionBackend { private $errmsg; private $numberOfLines = 0; - const ENCODING_ISO8859_1 = 0; - const ENCODING_UFT8 = 1; - const ENCODING_AUTO = 2; + const ENCODING_ISO8859_1 = 0; + const ENCODING_UFT8 = 1; + const ENCODING_AUTO = 2; - /** + /** * Get header of the file * * @param $injectionData @@ -58,14 +59,14 @@ static function getHeader(PluginDatainjectionData $injectionData, $header_presen } $nb = count($injectionData->getDataAtLine(0)); - for ($i=0 ; $i<$nb ; $i++) { + for ($i=0; $i<$nb; $i++) { $header[] = $i; } return $header; } - /** + /** * Get the backend implementation by type * * @param $type @@ -79,8 +80,9 @@ static function getInstance($type) { static function is_utf8($string) { - // From http://w3.org/International/questions/qa-forms-utf-8.html - return preg_match('%^(?: + // From http://w3.org/International/questions/qa-forms-utf-8.html + return preg_match( + '%^(?: [\x09\x0A\x0D\x20-\x7E] # ASCII | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs @@ -89,7 +91,8 @@ static function is_utf8($string) { | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3 | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15 | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 - )*$%xs', $string); + )*$%xs', $string + ); } @@ -102,4 +105,3 @@ static function toUTF8($string) { } } -?> diff --git a/inc/backendcsv.class.php b/inc/backendcsv.class.php index c9380257..f71329ea 100644 --- a/inc/backendcsv.class.php +++ b/inc/backendcsv.class.php @@ -27,8 +27,9 @@ @link http://www.glpi-project.org/ @since 2009 ---------------------------------------------------------------------- */ - class PluginDatainjectionBackendcsv extends PluginDatainjectionBackend - implements PluginDatainjectionBackendInterface { +class PluginDatainjectionBackendcsv extends PluginDatainjectionBackend + implements PluginDatainjectionBackendInterface +{ private $delimiter = ''; private $isHeaderPresent = true; @@ -36,38 +37,43 @@ class PluginDatainjectionBackendcsv extends PluginDatainjectionBackend function __construct() { + $this->errmsg = ""; } - //Getters & setters + //Getters & setters function getDelimiter() { + return $this->delimiter; } function isHeaderPresent() { + return $this->isHeaderPresent; } - /** + /** * @param $delimiter **/ function setDelimiter($delimiter) { + $this->delimiter = $delimiter; } - /** + /** * @param $present (true by default) **/ function setHeaderPresent($present=true) { + $this->isHeaderPresent = $present; } - /** + /** * CSV File parsing methods * * @param $fic @@ -75,17 +81,19 @@ function setHeaderPresent($present=true) { * @param $encoding (default 1) **/ static function parseLine($fic, $data, $encoding=1) { + global $DB; $csv = array(); $num = count($data); - for($c=0 ; $c<$num ; $c++) { + for ($c=0; $c<$num; $c++) { //If field is not the last, or if field is the last of the line and is not empty if (($c < ($num -1)) || (($c == ($num -1)) - && ($data[$num -1] != PluginDatainjectionCommonInjectionLib::EMPTY_VALUE))) { + && ($data[$num -1] != PluginDatainjectionCommonInjectionLib::EMPTY_VALUE)) + ) { $tmp = trim($DB->escape($data[$c])); switch ($encoding) { //If file is ISO8859-1 : encode the data in utf8 @@ -95,14 +103,14 @@ static function parseLine($fic, $data, $encoding=1) { } else { $csv[0][] = $tmp; } - break; + break; case PluginDatainjectionBackend::ENCODING_UFT8 : - $csv[0][] = $tmp; - break; + $csv[0][] = $tmp; + break; default : //PluginDatainjectionBackend :: ENCODING_AUTO : - $csv[0][] = PluginDatainjectionBackend::toUTF8($tmp); + $csv[0][] = PluginDatainjectionBackend::toUTF8($tmp); } } } @@ -110,7 +118,7 @@ static function parseLine($fic, $data, $encoding=1) { } - /** + /** * @param $newfile * @param $encoding **/ @@ -121,7 +129,7 @@ function init($newfile,$encoding) { } - /** + /** * Read a CSV file and store data in an array * * @param $numberOfLines inumber of lines to be read (-1 means all file) (default 1) @@ -133,7 +141,7 @@ function read($numberOfLines=1) { $continue = true; $data = false; - for ($index = 0 ; (($numberOfLines == -1) || ($index < $numberOfLines)) && $continue ; $index++) { + for ($index = 0; (($numberOfLines == -1) || ($index < $numberOfLines)) && $continue; $index++) { $data = $this->getNextLine(); if ($data) { $injectionData->addToData($data); @@ -147,7 +155,7 @@ function read($numberOfLines=1) { } - /** + /** * Store the number of lines red from the file * * @see plugins/datainjection/inc/PluginDatainjectionBackendInterface::storeNumberOfLines() @@ -157,10 +165,11 @@ function storeNumberOfLines() { $fic = fopen($this->file, 'r'); $index = 0; - while (($data = fgetcsv($fic, 0, $this->getDelimiter())) !== FALSE) { + while (($data = fgetcsv($fic, 0, $this->getDelimiter())) !== false) { //If line is not empty if ((count($data) > 1) - || ($data[0] != PluginDatainjectionCommonInjectionLib::EMPTY_VALUE)) { + || ($data[0] != PluginDatainjectionCommonInjectionLib::EMPTY_VALUE) + ) { $line = self::parseLine($fic, $data, $this->encoding); if (count($line[0]) > 0) { @@ -179,49 +188,53 @@ function storeNumberOfLines() { function getNumberOfLines() { + return $this->numberOfLines; } - /** + /** * Open the csv file **/ function openFile() { + $this->file_handler = fopen($this->file, 'r'); } - /** + /** * Close the csv file **/ function closeFile() { + fclose($this->file_handler); } - /** + /** * Read next line of the csv file **/ function getNextLine() { $data = fgetcsv($this->file_handler, 0, $this->getDelimiter()); - if ($data === FALSE) { + if ($data === false) { return false; } $line = array(); if ((count($data) > 1) - || ($data[0] != PluginDatainjectionCommonInjectionLib::EMPTY_VALUE)) { + || ($data[0] != PluginDatainjectionCommonInjectionLib::EMPTY_VALUE) + ) { $line = self::parseLine($this->file_handler, $data, $this->encoding); } return $line; } - /** + /** * Delete csv file from disk **/ function deleteFile() { + unlink($this->file); } } -?> diff --git a/inc/backendinterface.class.php b/inc/backendinterface.class.php index bb4ba701..1998975d 100644 --- a/inc/backendinterface.class.php +++ b/inc/backendinterface.class.php @@ -31,39 +31,39 @@ /** * Interface to be implemented for each injection backend **/ -interface PluginDatainjectionBackendInterface { +interface PluginDatainjectionBackendInterface +{ - /** + /** * Read from file * * @param $numberOfLines (default 1) **/ - function read($numberOfLines=1); + function read($numberOfLines=1); - /** + /** * Delete file **/ - function deleteFile(); + function deleteFile(); - /** + /** * Export results to a file **/ - //function export($file, PluginDatainjectionModel $model, $tab_result); + //function export($file, PluginDatainjectionModel $model, $tab_result); - /** + /** * Store the number of lines red from the file **/ - function storeNumberOfLines(); + function storeNumberOfLines(); - /** + /** * Get the number of lines in the file **/ - function getNumberOfLines(); + function getNumberOfLines(); } -?> \ No newline at end of file diff --git a/inc/budgetinjection.class.php b/inc/budgetinjection.class.php index ee1e5cd1..424aa87e 100644 --- a/inc/budgetinjection.class.php +++ b/inc/budgetinjection.class.php @@ -29,12 +29,13 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionBudgetInjection extends Budget - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -46,16 +47,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -72,15 +75,15 @@ function getOptions($primary_type='') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("date" => array(3,5), - "yesno" => array(86), - "multiline_text" => array(16, 90), - "decimal" => array(4)); + "yesno" => array(86), + "multiline_text" => array(16, 90), + "decimal" => array(4)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -91,4 +94,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/cartridgeiteminjection.class.php b/inc/cartridgeiteminjection.class.php index 2b8bc3d7..6a4377c5 100644 --- a/inc/cartridgeiteminjection.class.php +++ b/inc/cartridgeiteminjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionCartridgeItemInjection extends CartridgeItem - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -45,16 +46,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -75,9 +78,9 @@ function getOptions($primary_type='') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("dropdown" => array(3, 4, 23, 49), - "user" => array(24), - "multiline_text" => array(16, 90), - "dropdown_integer" => array(8)); + "user" => array(24), + "multiline_text" => array(16, 90), + "dropdown_integer" => array(8)); $options['checktype'] = array("integer" => array(8)); @@ -85,7 +88,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -96,4 +99,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/clientinjection.class.php b/inc/clientinjection.class.php index f33f3ab8..7934fd07 100644 --- a/inc/clientinjection.class.php +++ b/inc/clientinjection.class.php @@ -28,30 +28,32 @@ @since 2009 ---------------------------------------------------------------------- */ - class PluginDatainjectionClientInjection { +class PluginDatainjectionClientInjection +{ static $rightname = "plugin_datainjection_use"; - const STEP_UPLOAD = 0; - const STEP_PROCESS = 1; - const STEP_RESULT = 2; + const STEP_UPLOAD = 0; + const STEP_PROCESS = 1; + const STEP_RESULT = 2; - //Injection results + //Injection results private $results = array(); - //Model used for injection + //Model used for injection private $model; - //Overall injection results + //Overall injection results private $global_results; - /** + /** * Print a good title for group pages * *@return nothing (display) **/ function title() { + global $CFG_GLPI; $buttons = array (); @@ -61,69 +63,80 @@ function title() { $url = Toolbox::getItemTypeSearchURL('PluginDatainjectionModel'); $buttons[$url] = PluginDatainjectionModel::getTypeName(); $title = ""; - Html::displayTitle($CFG_GLPI["root_doc"] . "/plugins/datainjection/pics/datainjection.png", - PluginDatainjectionModel::getTypeName(), $title, $buttons); + Html::displayTitle( + $CFG_GLPI["root_doc"] . "/plugins/datainjection/pics/datainjection.png", + PluginDatainjectionModel::getTypeName(), $title, $buttons + ); } } function showForm($ID, $options=array()) { + global $CFG_GLPI; echo "
    "; + "enctype='multipart/form-data'>"; echo "
    "; echo ""; - $models = PluginDatainjectionModel::getModels(Session::getLoginUserID(), 'name', - $_SESSION['glpiactive_entity'], false); + $models = PluginDatainjectionModel::getModels( + Session::getLoginUserID(), 'name', + $_SESSION['glpiactive_entity'], false + ); echo ""; echo ""; if (count($models) > 0) { - echo "
    " .__('Use an existing model', 'datainjection') ."
    ".__('Model')." "; - PluginDatainjectionModel::dropdown(); + echo "".__('Model')." "; + PluginDatainjectionModel::dropdown(); } else { - $text = __('No model currently available', 'datainjection'); - - if (Session::haveRight('plugin_datainjection_model', CREATE) ) { - - $text = sprintf(__('%1$s %2$s'), $text.". ", - sprintf(__('%1$s: %2$s'), - __('You can start the model creation by hitting the button', - 'datainjection'), - PluginDatainjectionModel::getTypeName())); + $text = __('No model currently available', 'datainjection'); + + if (Session::haveRight('plugin_datainjection_model', CREATE)) { + + $text = sprintf( + __('%1$s %2$s'), $text.". ", + sprintf( + __('%1$s: %2$s'), + __( + 'You can start the model creation by hitting the button', + 'datainjection' + ), + PluginDatainjectionModel::getTypeName() + ) + ); } - echo "".$text; + echo "".$text; } - echo "

    "; + echo "
    "; - echo ""; - Html::closeForm(); - echo "
    "; + echo ""; + Html::closeForm(); + echo ""; if (PluginDatainjectionSession::getParam('models_id')) { - $p['models_id'] = PluginDatainjectionSession::getParam('models_id'); + $p['models_id'] = PluginDatainjectionSession::getParam('models_id'); switch (PluginDatainjectionSession::getParam('step')) { case self::STEP_UPLOAD : - $url = $CFG_GLPI["root_doc"]."/plugins/datainjection/ajax/dropdownSelectModel.php"; - Ajax::updateItem("span_injection", $url, $p); + $url = $CFG_GLPI["root_doc"]."/plugins/datainjection/ajax/dropdownSelectModel.php"; + Ajax::updateItem("span_injection", $url, $p); break; case self::STEP_RESULT : - $url = $CFG_GLPI["root_doc"]."/plugins/datainjection/ajax/results.php"; - Ajax::updateItem("span_injection", $url, $p); + $url = $CFG_GLPI["root_doc"]."/plugins/datainjection/ajax/results.php"; + Ajax::updateItem("span_injection", $url, $p); break; } } } - /** + /** * @param $options array **/ static function showUploadFileForm($options=array()) { @@ -131,7 +144,7 @@ static function showUploadFileForm($options=array()) { $add_form = (isset($options['add_form']) && $options['add_form']); $confirm = (isset($options['confirm']) && $options['confirm']); $url = (($confirm == 'creation')?Toolbox::getItemTypeFormURL('PluginDatainjectionModel') - :Toolbox::getItemTypeFormURL(__CLASS__)); + :Toolbox::getItemTypeFormURL(__CLASS__)); if ($add_form) { echo ""; } @@ -146,7 +159,7 @@ static function showUploadFileForm($options=array()) { echo ""; echo ""; - echo "" . __('File encoding', 'datainjection') . ""; + echo "". __('File encoding', 'datainjection').""; PluginDatainjectionDropdown::dropdownFileEncoding(); echo "\n"; @@ -156,8 +169,10 @@ static function showUploadFileForm($options=array()) { if ($confirm == 'creation') { $message = __('Warning : existing data will be overridden', 'datainjection'); } else { - $message = __("Watch out, you're about to inject data into GLPI. Are you sure you want to do it ?", - 'datainjection'); + $message = __( + "Watch out, you're about to inject data into GLPI. Are you sure you want to do it ?", + 'datainjection' + ); } $alert = "OnClick='return window.confirm(\"$message\");'"; } @@ -165,8 +180,8 @@ static function showUploadFileForm($options=array()) { $options['submit'] = __('Launch the import', 'datainjection'); } echo ""; - echo "  "; + htmlentities($options['submit'], ENT_QUOTES, 'UTF-8'). "' $alert>"; + echo "  "; echo "\n"; echo "
    "; if ($add_form) { @@ -175,7 +190,7 @@ static function showUploadFileForm($options=array()) { } - /** + /** * @param $model PluginDatainjectionModel object * @param $entities_id **/ @@ -196,7 +211,7 @@ static function showInjectionForm(PluginDatainjectionModel $model, $entities_id) echo ""; echo ""; - Html::createProgressBar(__('Injection of the file', 'datainjection')) ; + Html::createProgressBar(__('Injection of the file', 'datainjection')); echo ""; echo "
    "; @@ -205,11 +220,12 @@ static function showInjectionForm(PluginDatainjectionModel $model, $entities_id) } - /** + /** * @param $model PluginDatainjectionModel object * @param $entities_id **/ static function processInjection(PluginDatainjectionModel $model, $entities_id) { + global $CFG_GLPI; // To prevent problem of execution time during injection @@ -222,8 +238,10 @@ static function processInjection(PluginDatainjectionModel $model, $entities_id) $clientinjection = new PluginDatainjectionClientInjection; //New injection engine - $engine = new PluginDatainjectionEngine($model, PluginDatainjectionSession::getParam('infos'), - $entities_id); + $engine = new PluginDatainjectionEngine( + $model, PluginDatainjectionSession::getParam('infos'), + $entities_id + ); $backend = $model->getBackend(); $model->loadSpecificModel(); @@ -237,64 +255,76 @@ static function processInjection(PluginDatainjectionModel $model, $entities_id) //If header is present, then get the second line if ($model->getSpecificModel()->isHeaderPresent()) { - $line = $backend->getNextLine(); + $line = $backend->getNextLine(); } - //While CSV file is not EOF - $prev = ''; - $deb = time(); + //While CSV file is not EOF + $prev = ''; + $deb = time(); while ($line != null) { - //Inject line - $injectionline = $index + ($model->getSpecificModel()->isHeaderPresent()?2:1); - $clientinjection->results[] = $engine->injectLine($line[0],$injectionline); + //Inject line + $injectionline = $index + ($model->getSpecificModel()->isHeaderPresent()?2:1); + $clientinjection->results[] = $engine->injectLine($line[0], $injectionline); - $pos = number_format($index*100/$nblines,1); + $pos = number_format($index*100/$nblines, 1); if ($pos != $prev) { - $prev = $pos; - $fin = time()-$deb; - //TODO yllen - Html::changeProgressBarPosition($index, $nblines, - sprintf(__('%1$s (%2$s)'), - sprintf(__('Injection of the file... %d%%', - 'datainjection'), $pos), - Html::timestampToString(time()-$deb, true))); + $prev = $pos; + $fin = time()-$deb; + //TODO yllen + Html::changeProgressBarPosition( + $index, $nblines, + sprintf( + __('%1$s (%2$s)'), + sprintf( + __( + 'Injection of the file... %d%%', + 'datainjection' + ), $pos + ), + Html::timestampToString(time()-$deb, true) + ) + ); } - $line = $backend->getNextLine(); - $index++; + $line = $backend->getNextLine(); + $index++; } - //EOF : change progressbar to 100% ! - Html::changeProgressBarPosition(100, 100, - sprintf(__('%1$s (%2$s)'), - __('Injection finished', 'datainjection'), - Html::timestampToString(time()-$deb, true))); + //EOF : change progressbar to 100% ! + Html::changeProgressBarPosition( + 100, 100, + sprintf( + __('%1$s (%2$s)'), + __('Injection finished', 'datainjection'), + Html::timestampToString(time()-$deb, true) + ) + ); - // Restore - $CFG_GLPI["debug_sql"] = 1; + // Restore + $CFG_GLPI["debug_sql"] = 1; - //Close CSV file - $backend->closeFile(); + //Close CSV file + $backend->closeFile(); - //Delete CSV file - $backend->deleteFile(); + //Delete CSV file + $backend->deleteFile(); - //Change step - $_SESSION['datainjection']['step'] = self::STEP_RESULT; + //Change step + $_SESSION['datainjection']['step'] = self::STEP_RESULT; - //Display results form - PluginDatainjectionSession::setParam('results', json_encode($clientinjection->results)); - PluginDatainjectionSession::setParam('error_lines', json_encode($engine->getLinesInError())); - $p['models_id'] = $model->fields['id']; - $p['nblines'] = $nblines; + //Display results form + PluginDatainjectionSession::setParam('results', json_encode($clientinjection->results)); + PluginDatainjectionSession::setParam('error_lines', json_encode($engine->getLinesInError())); + $p['models_id'] = $model->fields['id']; + $p['nblines'] = $nblines; - unset($_SESSION['datainjection']['go']); + unset($_SESSION['datainjection']['go']); - $url = $CFG_GLPI["root_doc"]."/plugins/datainjection/ajax/results.php"; - Ajax::updateItem("span_injection",$url,$p); + $url = $CFG_GLPI["root_doc"]."/plugins/datainjection/ajax/results.php"; + Ajax::updateItem("span_injection", $url, $p); } - /** + /** * to be used instead of Toolbox::stripslashes_deep to reduce memory usage * execute stripslashes in place (no copy) * @@ -312,10 +342,11 @@ static function stripslashes_array(&$value) { } - /** + /** * @param $model PluginDatainjectionModel object **/ static function showResultsForm(PluginDatainjectionModel $model) { + global $CFG_GLPI; $results = json_decode(PluginDatainjectionSession::getParam('results'), true); @@ -333,7 +364,7 @@ static function showResultsForm(PluginDatainjectionModel $model) { } echo ""; + "/plugins/datainjection/front/clientinjection.form.php'>"; echo ""; echo ""; @@ -349,22 +380,22 @@ static function showResultsForm(PluginDatainjectionModel $model) { echo ""; echo "
    " . __("Injection's results", 'datainjection')."
    "; $url = $CFG_GLPI["root_doc"]."/plugins/datainjection/front/popup.php?popup=log&models_id=". - $model->fields['id']; + $model->fields['id']; echo ""; + "'height=400, width=1000, top=100, left=100, scrollbars=yes' );w.focus();\"/' ". + "title='".__('See the log', 'datainjection')."'>"; echo ""; $plugin = new Plugin; if ($plugin->isActivated('pdf')) { echo " fields['id']."'\" title='".__('Export rapport in PDF', 'datainjection')."'>"; + $model->fields['id']."'\" title='".__('Export rapport in PDF', 'datainjection')."'>"; echo ""; } if (!empty($error_lines)) { echo " "; + __('Export the log', 'datainjection')."'>"; echo ""; } @@ -372,7 +403,7 @@ static function showResultsForm(PluginDatainjectionModel $model) { echo "
    "; echo ""; + __('Finish', 'datainjection')."'>"; echo "
    "; Html::closeForm(); @@ -404,7 +435,7 @@ static function exportErrorsInCSV() { fclose($tmpfile); $name = "Error-".PluginDatainjectionSession::getParam('file_name'); - $name = str_replace(' ','',$name); + $name = str_replace(' ', '', $name); header('Content-disposition: attachment; filename='.$name); header('Content-Type: application/octet-stream'); header('Content-Transfer-Encoding: fichier'); diff --git a/inc/commoninjectionlib.class.php b/inc/commoninjectionlib.class.php index 5c8a2fe5..466cc54c 100644 --- a/inc/commoninjectionlib.class.php +++ b/inc/commoninjectionlib.class.php @@ -28,94 +28,95 @@ @since 2009 ---------------------------------------------------------------------- */ -class PluginDatainjectionCommonInjectionLib { +class PluginDatainjectionCommonInjectionLib +{ - //Injection results + //Injection results private $results = array(); - //Values to inject + //Values to inject private $values = array(); - //Fields mandatory for injection + //Fields mandatory for injection private $mandatory_fields = array(); - //List of fields which can agregate more than one value (type multiline_text) + //List of fields which can agregate more than one value (type multiline_text) private $severalvalues_fields = array(); private $optional_infos = array(); - //Injection class to use + //Injection class to use private $injectionClass; - //Primary type to inject + //Primary type to inject private $primary_type; - //Store checks to perform on values + //Store checks to perform on values private $checks = array(); - //Store rights + //Store rights private $rights = array(); - //Store specific fields formats + //Store specific fields formats private $formats = array(); - //Entity in which data will be inserted + //Entity in which data will be inserted private $entity = 0; - const ACTION_CHECK = 0; + const ACTION_CHECK = 0; - //Type of action to perform - const IMPORT_ADD = 0; - const IMPORT_UPDATE = 1; - const IMPORT_DELETE = 2; + //Type of action to perform + const IMPORT_ADD = 0; + const IMPORT_UPDATE = 1; + const IMPORT_DELETE = 2; - //Action return constants - const SUCCESS = 10; //Injection OK - const FAILED = 11; //Error during injection - const WARNING = 12; //Injection ok but partial + //Action return constants + const SUCCESS = 10; //Injection OK + const FAILED = 11; //Error during injection + const WARNING = 12; //Injection ok but partial - //Field check return constants - const TYPE_MISMATCH = 22; - const MANDATORY = 23; - const ITEM_NOT_FOUND = 24; + //Field check return constants + const TYPE_MISMATCH = 22; + const MANDATORY = 23; + const ITEM_NOT_FOUND = 24; - //Injection Message - const ERROR_CANNOT_IMPORT = 31; - const ERROR_CANNOT_UPDATE = 32; - const WARNING_NOTFOUND = 33; - const ERROR_FIELDSIZE_EXCEEDED = 37; - const ERROR_IMPORT_REFUSED = 39; //Dictionnary explicitly refuse import + //Injection Message + const ERROR_CANNOT_IMPORT = 31; + const ERROR_CANNOT_UPDATE = 32; + const WARNING_NOTFOUND = 33; + const ERROR_FIELDSIZE_EXCEEDED = 37; + const ERROR_IMPORT_REFUSED = 39; //Dictionnary explicitly refuse import - //Empty values - const EMPTY_VALUE = ''; - const DROPDOWN_EMPTY_VALUE = 0; + //Empty values + const EMPTY_VALUE = ''; + const DROPDOWN_EMPTY_VALUE = 0; - //Format constants - const FLOAT_TYPE_COMMA = 0; //xxxx,xx - const FLOAT_TYPE_DOT = 1; //xxxx.xx - const FLOAT_TYPE_DOT_AND_COM = 2; //xx,xxx.xx + //Format constants + const FLOAT_TYPE_COMMA = 0; //xxxx,xx + const FLOAT_TYPE_DOT = 1; //xxxx.xx + const FLOAT_TYPE_DOT_AND_COM = 2; //xx,xxx.xx - //Date management constants - const DATE_TYPE_DDMMYYYY = "dd-mm-yyyy"; - const DATE_TYPE_MMDDYYYY = "mm-dd-yyyy"; - const DATE_TYPE_YYYYMMDD = "yyyy-mm-dd"; + //Date management constants + const DATE_TYPE_DDMMYYYY = "dd-mm-yyyy"; + const DATE_TYPE_MMDDYYYY = "mm-dd-yyyy"; + const DATE_TYPE_YYYYMMDD = "yyyy-mm-dd"; - //Port unicity constants - const UNICITY_NETPORT_LOGICAL_NUMBER = 0; - const UNICITY_NETPORT_NAME = 1; - const UNICITY_NETPORT_MACADDRESS = 2; - const UNICITY_NETPORT_LOGICAL_NUMBER_NAME = 3; - const UNICITY_NETPORT_LOGICAL_NUMBER_MAC = 4; - const UNICITY_NETPORT_LOGICAL_NUMBER_NAME_MAC = 5; + //Port unicity constants + const UNICITY_NETPORT_LOGICAL_NUMBER = 0; + const UNICITY_NETPORT_NAME = 1; + const UNICITY_NETPORT_MACADDRESS = 2; + const UNICITY_NETPORT_LOGICAL_NUMBER_NAME = 3; + const UNICITY_NETPORT_LOGICAL_NUMBER_MAC = 4; + const UNICITY_NETPORT_LOGICAL_NUMBER_NAME_MAC = 5; - //Field status must evolve when ticket #2216 will be resolved - const FIELD_INJECTABLE = 1; - const FIELD_VIRTUAL = 2; + //Field status must evolve when ticket #2216 will be resolved + const FIELD_INJECTABLE = 1; + const FIELD_VIRTUAL = 2; - /** + /** * Set default values for injection parameters * * @return nothing @@ -123,27 +124,27 @@ class PluginDatainjectionCommonInjectionLib { function setDefaultValues() { $this->checks = array('ip' => false, 'mac' => false, - 'integer' => false, 'yes' => false, - 'bool' => false, 'date' => false, - 'float' => false, 'string' => false, - 'right_r' => false, 'right_rw' => false, - 'interface' => false, 'auth_method' => false, - 'port_unicity' => false); + 'integer' => false, 'yes' => false, + 'bool' => false, 'date' => false, + 'float' => false, 'string' => false, + 'right_r' => false, 'right_rw' => false, + 'interface' => false, 'auth_method' => false, + 'port_unicity' => false); //Rights options $this->rights = array('add_dropdown' => false, - 'overwrite_notempty_fields' => false, - 'can_add' => false, - 'can_update' => false, - 'can_delete' => false); + 'overwrite_notempty_fields' => false, + 'can_add' => false, + 'can_update' => false, + 'can_delete' => false); //Field format options $this->formats = array('date_format' => self::DATE_TYPE_YYYYMMDD, - 'float_format' => self::FLOAT_TYPE_COMMA); + 'float_format' => self::FLOAT_TYPE_COMMA); } - /** + /** * Constructor : store all needed options into the library * * @param $injectionClass class which represents the itemtype to injection @@ -188,7 +189,7 @@ function __construct($injectionClass, $values=array(), $injection_options=array( $this->formats = $injection_options['formats']; } else { $this->formats = array('date_format' => self::DATE_TYPE_YYYYMMDD, - 'float_format' => self::FLOAT_TYPE_DOT); + 'float_format' => self::FLOAT_TYPE_DOT); } //Store values to inject @@ -207,7 +208,7 @@ function __construct($injectionClass, $values=array(), $injection_options=array( } - /** + /** * Check and add fields for itemtype which depend on other itemtypes * (for example SoftwareLicense needs to be linked to a Software) * @@ -218,12 +219,12 @@ function areTypeMandatoryFieldsOK($injectionClass) { $itemtype = self::getItemtypeByInjectionClass($injectionClass); //Add more values needed for mandatory fields management - if (method_exists($injectionClass,'getValueForAdditionalMandatoryFields')) { + if (method_exists($injectionClass, 'getValueForAdditionalMandatoryFields')) { $this->values = $injectionClass->getValueForAdditionalMandatoryFields($this->values); } //Add new mandatory fields to check, needed by other itemtypes to inject - if (method_exists($injectionClass,'addSpecificMandatoryFields')) { + if (method_exists($injectionClass, 'addSpecificMandatoryFields')) { $fields = $injectionClass->addSpecificMandatoryFields(); foreach ($fields as $key => $value) { $this->mandatory_fields[$itemtype][$key] = $value; @@ -234,19 +235,20 @@ function areTypeMandatoryFieldsOK($injectionClass) { if (count($this->mandatory_fields[$itemtype]) > 0) { foreach ($this->mandatory_fields[$itemtype] as $field => $value) { //Get value associated with the mandatory field - $value = $this->getValueByItemtypeAndName($itemtype,$field); + $value = $this->getValueByItemtypeAndName($itemtype, $field); //Get search option associated with the mandatory field - $option = self::findSearchOption($injectionClass->getOptions($itemtype),$field); + $option = self::findSearchOption($injectionClass->getOptions($itemtype), $field); //If field not defined, or if value is the dropdown's default value //If no value found or value is 0 and field is a dropdown, //then mandatory field management failed if (($value == false) || (($value == self::DROPDOWN_EMPTY_VALUE) - && self::isFieldADropdown($option['displaytype']))) { + && self::isFieldADropdown($option['displaytype'])) + ) { $status_check = false; - $this->results[self::ACTION_CHECK][] = array(self::MANDATORY,$option['name']); + $this->results[self::ACTION_CHECK][] = array(self::MANDATORY, $option['name']); } } } @@ -254,7 +256,7 @@ function areTypeMandatoryFieldsOK($injectionClass) { } - /** + /** * Check if a field type represents a dropdown or not * * @param $field_type the type of field @@ -263,15 +265,17 @@ function areTypeMandatoryFieldsOK($injectionClass) { **/ static function isFieldADropdown($field_type) { - if (!in_array($field_type, array('integer', 'decimal', 'tree', 'text', 'multiline_text', - 'date'))) { + if (!in_array( + $field_type, array('integer', 'decimal', 'tree', + 'text', 'multiline_text', 'date') + )) { return true; } return false; } - /** + /** * Return an the class of an item by giving his injection class * * @param $injectionClassName the injection class name @@ -285,7 +289,7 @@ static function getItemtypeInstanceByInjection($injectionClassName) { } - /** + /** * Get an itemtype name by giving his injection class name * * @param $injectionClassName the injection class name @@ -293,11 +297,12 @@ static function getItemtypeInstanceByInjection($injectionClassName) { * @return the itemtype associated */ static function getItemtypeByInjection($injectionClassName) { + return self::getItemtypeByInjectionClass(new $injectionClassName); } - /** + /** * Get an itemtype by giving an injection class object * * @param $injectionClassName the injection class object @@ -305,11 +310,12 @@ static function getItemtypeByInjection($injectionClassName) { * @return an instance of the itemtype associated to the injection class */ static function getItemtypeByInjectionClass($injectionClass) { + return Toolbox::ucfirst(getItemTypeForTable($injectionClass->getTable())); } - /** + /** * Get an injection class instance for an itemtype * * @param $itemtype the itemtype @@ -327,7 +333,7 @@ static function getInjectionClassInstance($itemtype) { } - /** + /** * Add blacklisted fields for an itemtype * * @param $itemtype the itemtype @@ -335,6 +341,7 @@ static function getInjectionClassInstance($itemtype) { * @return the array of all blacklisted fields */ static function getBlacklistedOptions($itemtype) { + global $CFG_GLPI; //2 : id @@ -399,7 +406,7 @@ static function getBlacklistedOptions($itemtype) { } - /** + /** * Find and return the right search option * * @param $options the search options array @@ -412,7 +419,8 @@ static function findSearchOption($options, $lookfor) { $found = false; foreach ($options as $option) { if (isset($option['injectable']) && ($option['injectable'] == self::FIELD_INJECTABLE) - && isset($option['linkfield']) && ($option['linkfield'] == $lookfor)) { + && isset($option['linkfield']) && ($option['linkfield'] == $lookfor) + ) { $found = $option; } @@ -422,32 +430,34 @@ static function findSearchOption($options, $lookfor) { } - //--------------------------------------------------// - //----------- Injection options getters -----------// - //------------------------------------------------// + //--------------------------------------------------// + //----------- Injection options getters -----------// + //------------------------------------------------// - /** + /** * Get date format used for injection * * @return date format used **/ private function getDateFormat() { + return $this->formats['date_format']; } - /** + /** * Get date format used for injection * * @return date format used **/ private function getFloatFormat() { + return $this->formats['float_format']; } - /** + /** * Get itemtype associated to the injectionClass * * @return an itemtype @@ -459,7 +469,7 @@ private function getItemtype() { } - /** + /** * Get itemtype associated to the injectionClass * * @return an itemtype @@ -471,17 +481,18 @@ private function getItemInstance() { } - /** + /** * Return injection results * * @return an array which contains the reformat/check/injection logs **/ public function getInjectionResults() { + return $this->results; } - /** + /** * Get ID associate to the value from the CSV file is needed (for example for dropdown tables) * * @return nothing @@ -511,7 +522,7 @@ private function manageFieldValues() { } - /** + /** * Get the ID associated with a value from the CSV file * * @param $injectionClass @@ -524,7 +535,8 @@ private function manageFieldValues() { * @return nothing **/ private function getFieldValue($injectionClass, $itemtype, $searchOption, $field, $value, - $add=true) { + $add=true + ) { if (isset($searchOption['storevaluein'])) { $linkfield = $searchOption['storevaluein']; } else { @@ -545,9 +557,9 @@ private function getFieldValue($injectionClass, $itemtype, $searchOption, $field //To add a user password, it's mandatory is give a password and it's confirmation //Here we cannot detect if it's an add or update. We'll handle updates later in the process if ($add && $itemtype == 'User') { - $this->setValueForItemtype($itemtype, $linkfield, $value); - //Add field password2 is not already present - //(can be present if password was an addtional information) + $this->setValueForItemtype($itemtype, $linkfield, $value); + //Add field password2 is not already present + //(can be present if password was an addtional information) if (!isset($this->values[$itemtype][$field])) { $this->setValueForItemtype($itemtype, $linkfield."2", $value); } @@ -566,84 +578,74 @@ private function getFieldValue($injectionClass, $itemtype, $searchOption, $field if ($item->canCreate() && $this->rights['add_dropdown']) { $id = $item->import($input); } else { - $id = $item->findID($input); + $id = $item->findID($input); } - } else if ($item instanceof CommonDropdown) { + } else if ($item instanceof CommonDropdown) { if ($item->canCreate() && $this->rights['add_dropdown']) { $canadd = true; } else { $canadd = false; } - $id = $item->importExternal($value, $this->entity, - $this->addExternalDropdownParameters($itemtype), - '', $canadd); + $id = $item->importExternal( + $value, $this->entity, + $this->addExternalDropdownParameters($itemtype), + '', $canadd + ); } else { - $id = self::findSingle($item, $searchOption, $this->entity, $value); + $id = self::findSingle($item, $searchOption, $this->entity, $value); } - // Use EMPTY_VALUE for Mandatory field check - $this->setValueForItemtype($itemtype, $linkfield, ($id>0 ? $id : self::EMPTY_VALUE)); + // Use EMPTY_VALUE for Mandatory field check + $this->setValueForItemtype($itemtype, $linkfield, ($id>0 ? $id : self::EMPTY_VALUE)); if ($value && $id <= 0) { - $this->results['status'] = self::WARNING; - $this->results[self::ACTION_CHECK]['status'] = self::WARNING; - $this->results[self::ACTION_CHECK][] = array(self::WARNING_NOTFOUND, - $searchOption['name']."='$value'"); + $this->results['status'] = self::WARNING; + $this->results[self::ACTION_CHECK]['status'] = self::WARNING; + $this->results[self::ACTION_CHECK][] = array(self::WARNING_NOTFOUND, + $searchOption['name']."='$value'"); } break; case 'template' : $id = self::getTemplateIDByName($itemtype, $value); if ($id) { - //Template id is stored into the item's id : when adding the object - //glpi will understand that it needs to take fields from the template - $this->setValueForItemtype($itemtype, '_oldID', $id); + //Template id is stored into the item's id : when adding the object + //glpi will understand that it needs to take fields from the template + $this->setValueForItemtype($itemtype, '_oldID', $id); } break; case 'contact' : if ($value != Dropdown::EMPTY_VALUE) { - $id = self::findContact($value, $this->entity); + $id = self::findContact($value, $this->entity); } else { $id = Dropdown::EMPTY_VALUE; } - $this->setValueForItemtype($itemtype, $linkfield, $id); + $this->setValueForItemtype($itemtype, $linkfield, $id); break; case 'user' : if ($value != Dropdown::EMPTY_VALUE) { - $id = self::findUser($value, $this->entity); + $id = self::findUser($value, $this->entity); } else { $id = Dropdown::EMPTY_VALUE; } - $this->setValueForItemtype($itemtype, $linkfield, $id); - break; -/* - case 'multiline_text': - $message = ''; - if ($value != self::EMPTY_VALUE) { - //If update : do not overwrite the existing field in DB, append at the end ! - //if ($add == self::IMPORT_UPDATE) { - $message = $this->values[$itemtype][$linkfield]."\n"; - //} - - $message .= $value; - $this->setValueForItemtype($itemtype,$linkfield,$message); - } + $this->setValueForItemtype($itemtype, $linkfield, $id); break; -*/ + default: - if (method_exists($injectionClass,'getSpecificFieldValue')) { - $id = $injectionClass->getSpecificFieldValue($itemtype, $searchOption, $field, - $this->values); - $this->setValueForItemtype($itemtype, $linkfield, $id); + if (method_exists($injectionClass, 'getSpecificFieldValue')) { + $id = $injectionClass->getSpecificFieldValue( + $itemtype, $searchOption, $field, + $this->values + ); + $this->setValueForItemtype($itemtype, $linkfield, $id); } else { $this->setValueForItemtype($itemtype, $linkfield, $value); } - } } + } - - /** + /** * Add additional parameters needed for dropdown import * * @param itemtype dropdrown's itemtype @@ -651,6 +653,7 @@ private function getFieldValue($injectionClass, $itemtype, $searchOption, $field * @return an array with additional options to be added **/ private function addExternalDropdownParameters($itemtype) { + global $DB; $external = array(); @@ -663,8 +666,12 @@ private function addExternalDropdownParameters($itemtype) { case 'manufacturer' : if (intval($values[$field])>0) { $external[$addvalue] - = $DB->escape(Dropdown::getDropdownName('glpi_manufacturers', - $values[$field])); + = $DB->escape( + Dropdown::getDropdownName( + 'glpi_manufacturers', + $values[$field] + ) + ); break; } @@ -680,7 +687,7 @@ private function addExternalDropdownParameters($itemtype) { } - /** + /** * Find a user. Look for login OR firstname + lastname OR lastname + firstname * * @param value the user to look for @@ -689,6 +696,7 @@ private function addExternalDropdownParameters($itemtype) { * @return the user ID if found or '' **/ static private function findUser($value, $entity) { + global $DB; $sql = "SELECT `id` @@ -699,10 +707,10 @@ static private function findUser($value, $entity) { $result = $DB->query($sql); if ($DB->numrows($result)>0) { //check if user has right on the current entity - $ID = $DB->result($result,0,"id"); - $entities = Profile_User::getUserEntities($ID,true); + $ID = $DB->result($result, 0, "id"); + $entities = Profile_User::getUserEntities($ID, true); - if (in_array($entity,$entities)) { + if (in_array($entity, $entities)) { return $ID; } return self::DROPDOWN_EMPTY_VALUE; @@ -711,7 +719,7 @@ static private function findUser($value, $entity) { } - /** + /** * Find a user. Look for login OR firstname + lastname OR lastname + firstname * * @param value the user to look for @@ -720,6 +728,7 @@ static private function findUser($value, $entity) { * @return the user ID if found or '' */ static private function findContact($value, $entity) { + global $DB; $sql = "SELECT `id` @@ -738,7 +747,7 @@ static private function findContact($value, $entity) { } - /** + /** * Find id for a single type * * @param item the ComonDBTM item representing an itemtype @@ -749,6 +758,7 @@ static private function findContact($value, $entity) { * @return the id of the item found **/ static private function findSingle($item, $searchOption, $entity, $value) { + global $DB; $query = "SELECT `id` @@ -760,8 +770,10 @@ static private function findSingle($item, $searchOption, $entity, $value) { } if ($item->isEntityAssign()) { - $query .= getEntitiesRestrictRequest(" AND", $item->getTable(), 'entities_id', - $entity, $item->maybeRecursive()); + $query .= getEntitiesRestrictRequest( + " AND", $item->getTable(), 'entities_id', + $entity, $item->maybeRecursive() + ); } $query .= " AND `".$searchOption['field']."` = '$value'"; @@ -775,8 +787,7 @@ static private function findSingle($item, $searchOption, $entity, $value) { } } - /** - * + /** * Get values to inject for an itemtype * * @param the itemtype @@ -792,7 +803,7 @@ function getValuesForItemtype($itemtype) { } - /** + /** * Get values to inject for an itemtype * * @param the itemtype @@ -809,7 +820,7 @@ private function getValueByItemtypeAndName($itemtype, $field) { } - /** + /** * Unset a value to inject for an itemtype * * @param the itemtype @@ -818,13 +829,13 @@ private function getValueByItemtypeAndName($itemtype, $field) { **/ private function unsetValue($itemtype, $field) { - if ($this->getValueByItemtypeAndName($itemtype,$field)) { + if ($this->getValueByItemtypeAndName($itemtype, $field)) { unset($this->values[$itemtype][$field]); } } - /** + /** * Set values to inject for an itemtype * * @param itemtype @@ -848,7 +859,8 @@ private function setValueForItemtype($itemtype, $field, $value, $fromdb=false) { } } else if (($fromdb && $value && !$this->rights['overwrite_notempty_fields']) - || !$fromdb) { + || !$fromdb + ) { // Overwrite value in DB (from CSV) if allowed in the model option. $this->values[$itemtype][$field] = $value; } @@ -859,7 +871,7 @@ private function setValueForItemtype($itemtype, $field, $value, $fromdb=false) { } - /** + /** * Get a template name by giving his ID * * @param itemtype the objet's type @@ -868,6 +880,7 @@ private function setValueForItemtype($itemtype, $field, $value, $fromdb=false) { * @return name of the template or false is no template found **/ static private function getTemplateIDByName($itemtype, $name) { + global $DB; $item = new $itemtype(); $query = "SELECT `id` @@ -883,13 +896,13 @@ static private function getTemplateIDByName($itemtype, $name) { } - //--------------------------------------------------// - //----------- Reformat methods --------------------// - //------------------------------------------------// - //Several pass are needed to reformat data - //because dictionnaries need to be process in a specific order + //--------------------------------------------------// + //----------- Reformat methods --------------------// + //------------------------------------------------// + //Several pass are needed to reformat data + //because dictionnaries need to be process in a specific order - /** + /** * First pass of data reformat : check values like NULL or values coming from dropdown tables * * @return nothing @@ -905,23 +918,25 @@ private function reformatFirstPass() { foreach ($data as $field => $value) { if ($value && $value == "NULL") { - if (isset($option['datatype']) && self::isFieldADropdown($option['displaytype'])) - $this->values[$itemtype][$field] = self::EMPTY_VALUE; + if (isset($option['datatype']) && self::isFieldADropdown($option['displaytype'])) { + $this->values[$itemtype][$field] = self::EMPTY_VALUE; + } } } } } - /** + /** * Second pass of reformat : check if the itemtype needs specific reformat (like Software) * * @return nothing **/ private function reformatSecondPass() { + foreach ($this->values as $itemtype => $data) { $injectionClass = self::getInjectionClassInstance($itemtype); - if (method_exists($injectionClass,'reformat')) { + if (method_exists($injectionClass, 'reformat')) { //Specific reformat action is itemtype needs it $injectionClass->reformat($this->values); } @@ -929,10 +944,11 @@ private function reformatSecondPass() { } - /** + /** * Third pass of reformat : data, mac address & floats */ private function reformatThirdPass() { + global $CFG_GLPI; foreach ($this->values as $itemtype => $data) { @@ -944,35 +960,35 @@ private function reformatThirdPass() { foreach ($data as $field => $value) { //Get search option associated with the field - $option = self::findSearchOption($searchOptions,$field); + $option = self::findSearchOption($searchOptions, $field); // Check some types switch (isset($option['checktype']) ? $option['checktype'] : 'text') { case "date" : - //If the value is a date, try to reformat it if it's not the good type - //(dd-mm-yyyy instead of yyyy-mm-dd) - $date = self::reformatDate($value, $this->getDateFormat()); - $this->setValueForItemtype($itemtype, $field, $date); - break; + //If the value is a date, try to reformat it if it's not the good type + //(dd-mm-yyyy instead of yyyy-mm-dd) + $date = self::reformatDate($value, $this->getDateFormat()); + $this->setValueForItemtype($itemtype, $field, $date); + break; case "mac" : - $this->setValueForItemtype($itemtype, $field, self::reformatMacAddress($value)); - break; + $this->setValueForItemtype($itemtype, $field, self::reformatMacAddress($value)); + break; case "float" : - $float = self::reformatFloat($value, $this->getFloatFormat()); - $this->setValueForItemtype($itemtype, $field, $float); - break; + $float = self::reformatFloat($value, $this->getFloatFormat()); + $this->setValueForItemtype($itemtype, $field, $float); + break; default: - break; + break; } } } } - /** + /** * Perform field reformat (if needed) * Composed of 3 passes (one is optional, and depends on the itemtype to inject) * @@ -987,11 +1003,12 @@ private function reformat() { - /** + /** * Reformat float value. Input could be : * xxxx.xx * xx,xxx.xx * xxxx,xx + * * @param value : the float to reformat * @param the float format * @@ -1006,17 +1023,19 @@ static private function reformatFloat($value, $format) { //TODO : replace str_replace by a regex switch ($format) { case self::FLOAT_TYPE_COMMA : - $value = str_replace(array(" ", ","), - array("","."), - $value); + $value = str_replace( + array(" ", ","), + array("","."), + $value + ); break; case self::FLOAT_TYPE_DOT : - $value = str_replace(" ","", $value); + $value = str_replace(" ", "", $value); break; case self::FLOAT_TYPE_DOT_AND_COM : - $value = str_replace(",","", $value); + $value = str_replace(",", "", $value); break; } return $value; @@ -1024,7 +1043,7 @@ static private function reformatFloat($value, $format) { - /** + /** * Reformat date from dd-mm-yyyy to yyyy-mm-dd * * @param original_date the original date @@ -1038,32 +1057,38 @@ static private function reformatDate($original_date, $date_format) { } switch ($date_format) { case self::DATE_TYPE_YYYYMMDD : - $new_date = preg_replace('/(\d{4})[-\/](\d{1,2})[-\/](\d{1,2})/', - '\1-\2-\3', - $original_date); + $new_date = preg_replace( + '/(\d{4})[-\/](\d{1,2})[-\/](\d{1,2})/', + '\1-\2-\3', + $original_date + ); break; case self::DATE_TYPE_DDMMYYYY : - $new_date = preg_replace('/(\d{1,2})[-\/](\d{1,2})[-\/](\d{4})/', - '\3-\2-\1', - $original_date); + $new_date = preg_replace( + '/(\d{1,2})[-\/](\d{1,2})[-\/](\d{4})/', + '\3-\2-\1', + $original_date + ); break; case self::DATE_TYPE_MMDDYYYY : - $new_date = preg_replace('/(\d{1,2})[-\/](\d{1,2})[-\/](\d{4})/', - '\3-\1-\2', - $original_date); + $new_date = preg_replace( + '/(\d{1,2})[-\/](\d{1,2})[-\/](\d{4})/', + '\3-\1-\2', + $original_date + ); break; } - if (preg_match('/[0-9]{2,4}-[0-9]{1,2}-[0-9]{1,2}/',$new_date)) { + if (preg_match('/[0-9]{2,4}-[0-9]{1,2}-[0-9]{1,2}/', $new_date)) { return $new_date; } return $original_date; } - /** + /** * Reformat mac adress if mac doesn't contains : or - as seperator * * @param mac the original mac address @@ -1081,7 +1106,7 @@ static private function reformatMacAddress($mac) { $first = true; unset($results[0]); - foreach($results as $result) { + foreach ($results as $result) { $mac .= (!$first?":":"").$result; $first = false; } @@ -1090,11 +1115,11 @@ static private function reformatMacAddress($mac) { } - //--------------------------------------------------// - //----------- Check methods -----------------------// - //------------------------------------------------// + //--------------------------------------------------// + //----------- Check methods -----------------------// + //------------------------------------------------// - /** + /** * Check all data to be imported * * @return nothing @@ -1115,7 +1140,7 @@ private function check() { } //Get search option associated with the field - $option = self::findSearchOption($searchOptions,$field); + $option = self::findSearchOption($searchOptions, $field); if ($value == self::EMPTY_VALUE && $mandatory) { $this->results['status'] = self::FAILED; @@ -1124,15 +1149,17 @@ private function check() { $continue = false; } else { - $check_result = $this->checkType($injectionClass, $option, $field, $value, - $mandatory); + $check_result = $this->checkType( + $injectionClass, $option, $field, $value, + $mandatory + ); $this->results[self::ACTION_CHECK][] = array($check_result, - $field."='$value'"); + $field."='$value'"); if ($check_result != self::SUCCESS) { - $this->results[self::ACTION_CHECK]['status'] = self::FAILED; - $this->results['status'] = self::FAILED; - $continue = false; + $this->results[self::ACTION_CHECK]['status'] = self::FAILED; + $this->results['status'] = self::FAILED; + $continue = false; } } } @@ -1140,31 +1167,31 @@ private function check() { } - /** + /** * Is a value a float ? * * @param val the value to check * * @return true if it's a float, false otherwise */ - private function isFloat ($val) { + private function isFloat($val) { return is_numeric($val) && ($val == floatval($val)); } - /** + /** * Is a value an integer ? * * @param val the value to check * * @return true if it's an integer, false otherwise */ - private function isInteger ($val) { + private function isInteger($val) { return is_numeric($val) && ($val == intval($val)); } - /** + /** * Check one data * * @param the type of data waited @@ -1179,7 +1206,8 @@ private function checkType($injectionClass, $option, $field_name, $data, $mandat //If no data provided AND this mapping is not mandatory if (!$mandatory - && ($data == null || $data == "NULL" || $data == self::EMPTY_VALUE)) { + && ($data == null || $data == "NULL" || $data == self::EMPTY_VALUE) + ) { return self::SUCCESS; } @@ -1192,34 +1220,34 @@ private function checkType($injectionClass, $option, $field_name, $data, $mandat if (strlen($data) > 255) { return self::ERROR_FIELDSIZE_EXCEEDED; } - return self::SUCCESS; + return self::SUCCESS; case 'integer' : - return (self::isInteger($data) ? self::SUCCESS : self::TYPE_MISMATCH); + return (self::isInteger($data) ? self::SUCCESS : self::TYPE_MISMATCH); case 'decimal' : case 'float': - return (self::isFloat($data) ? self::SUCCESS : self::TYPE_MISMATCH); + return (self::isFloat($data) ? self::SUCCESS : self::TYPE_MISMATCH); case 'date' : - // Date is already "reformat" according to getDateFormat() - $pat = '/^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})$/'; - $res = preg_match($pat, $data, $regs); - return ($res ? self::SUCCESS : self::TYPE_MISMATCH); + // Date is already "reformat" according to getDateFormat() + $pat = '/^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})$/'; + $res = preg_match($pat, $data, $regs); + return ($res ? self::SUCCESS : self::TYPE_MISMATCH); case 'ip' : - preg_match("/([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/", $data, $regs); - return ((count($regs) > 0)?self::SUCCESS:self::TYPE_MISMATCH); + preg_match("/([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/", $data, $regs); + return ((count($regs) > 0)?self::SUCCESS:self::TYPE_MISMATCH); case 'mac' : - preg_match("/([0-9a-fA-F]{2}([:-]|$)){6}$/", $data, $regs); - return ((count($regs) > 0)?self::SUCCESS:self::TYPE_MISMATCH); + preg_match("/([0-9a-fA-F]{2}([:-]|$)){6}$/", $data, $regs); + return ((count($regs) > 0)?self::SUCCESS:self::TYPE_MISMATCH); case 'itemtype' : - return (class_exists($data)?self::SUCCESS:self::TYPE_MISMATCH); + return (class_exists($data)?self::SUCCESS:self::TYPE_MISMATCH); case 'bool' : - //If not numeric => type mismatch + //If not numeric => type mismatch if (!is_numeric($data)) { return self::TYPE_MISMATCH; } @@ -1230,12 +1258,12 @@ private function checkType($injectionClass, $option, $field_name, $data, $mandat } default : - //Not a standard check ? Try checks specific to the injection class - //Will return SUCCESS if it's not a specific check - if (method_exists($injectionClass,'checkType')) { + //Not a standard check ? Try checks specific to the injection class + //Will return SUCCESS if it's not a specific check + if (method_exists($injectionClass, 'checkType')) { return $injectionClass->checkType($field_name, $data, $mandatory); } - return self::SUCCESS; + return self::SUCCESS; } } @@ -1243,28 +1271,30 @@ private function checkType($injectionClass, $option, $field_name, $data, $mandat } - //--------------------------------------------------// - //------ Pre and post injection methods -----------// - //------------------------------------------------// + //--------------------------------------------------// + //------ Pre and post injection methods -----------// + //------------------------------------------------// - /** + /** * Add fields needed for all type injection * * @return nothing **/ private function addNecessaryFields() { - $this->setValueForItemtype($this->primary_type, 'entities_id', $this->entity); - if (method_exists($this->injectionClass,'addSpecificNeededFields')) { - $specific_fields = $this->injectionClass->addSpecificNeededFields($this->primary_type, - $this->values); - foreach ($specific_fields as $field => $value) { - $this->setValueForItemtype($this->primary_type, $field, $value); - } + + $this->setValueForItemtype($this->primary_type, 'entities_id', $this->entity); + if (method_exists($this->injectionClass, 'addSpecificNeededFields')) { + $specific_fields = $this->injectionClass->addSpecificNeededFields( + $this->primary_type, + $this->values + ); + foreach ($specific_fields as $field => $value) { + $this->setValueForItemtype($this->primary_type, $field, $value); + } } } - - /** + /** * Add fields needed to inject and itemtype * * @param injectionClass class which represents the object to inject @@ -1283,8 +1313,8 @@ private function addNeededFields($injectionClass, $itemtype) { //Add entities_id if itemtype can be assigned to an entity if ($injectionClass->isEntityAssign()) { - $entities_id = $this->getValueByItemtypeAndName($this->primary_type,'entities_id'); - $this->setValueForItemtype($itemtype,'entities_id',$entities_id); + $entities_id = $this->getValueByItemtypeAndName($this->primary_type, 'entities_id'); + $this->setValueForItemtype($itemtype, 'entities_id', $entities_id); } //Add is_recursive if itemtype can be assigned recursive @@ -1293,35 +1323,38 @@ private function addNeededFields($injectionClass, $itemtype) { $this->setValueForItemtype($itemtype, 'is_recursive', $recursive); } - if (method_exists($injectionClass,'addSpecificNeededFields')) { - $specific_fields = $injectionClass->addSpecificNeededFields($this->primary_type, - $this->values); + if (method_exists($injectionClass, 'addSpecificNeededFields')) { + $specific_fields = $injectionClass->addSpecificNeededFields( + $this->primary_type, + $this->values + ); foreach ($specific_fields as $field => $value) { - $this->setValueForItemtype($itemtype, $field, $value); + $this->setValueForItemtype($itemtype, $field, $value); } } } - /** + /** * Check value before processing import. Last change to stop import of data * * @return nothing **/ private function lastCheckBeforeProcess($injectionClass, $values) { + //Specific reformat action is itemtype needs it - if (method_exists($injectionClass,'lastCheck')) { + if (method_exists($injectionClass, 'lastCheck')) { return $injectionClass->lastCheck($this->values); } else { return true; } } - //--------------------------------------------------// - //-------- Add /Update/Delete methods -------------// - //------------------------------------------------// + //--------------------------------------------------// + //-------- Add /Update/Delete methods -------------// + //------------------------------------------------// - /** + /** * Process of inject data into GLPI * * @return an array which contains the injection results @@ -1359,7 +1392,7 @@ public function processAddOrUpdate() { $process = true; //No item found in DB - if($this->getValueByItemtypeAndName($this->primary_type, 'id') == self::ITEM_NOT_FOUND) { + if ($this->getValueByItemtypeAndName($this->primary_type, 'id') == self::ITEM_NOT_FOUND) { //Can add item ? $this->results['type'] = self::IMPORT_ADD; if (!$accepted) { @@ -1378,7 +1411,7 @@ public function processAddOrUpdate() { } else { //Item found in DB $this->results['type'] = self::IMPORT_UPDATE; $this->results[$this->primary_type] - = $this->getValueByItemtypeAndName($this->primary_type, 'id'); + = $this->getValueByItemtypeAndName($this->primary_type, 'id'); if ($this->rights['can_update']) { $add = false; @@ -1412,7 +1445,7 @@ public function processAddOrUpdate() { $this->addTemplateFields($this->primary_type); } $values = $this->getValuesForItemtype($this->primary_type); - $newID = $this->effectiveAddOrUpdate($this->injectionClass, $add, $item, $values); + $newID = $this->effectiveAddOrUpdate($this->injectionClass, $item, $values, $add); if (!$newID) { $this->results['status'] = self::WARNING; @@ -1445,7 +1478,7 @@ public function processAddOrUpdate() { } $values = $this->getValuesForItemtype($itemtype); if ($this->lastCheckBeforeProcess($injectionClass, $values)) { - $tmpID = $this->effectiveAddOrUpdate($injectionClass, $add, $item, $values); + $tmpID = $this->effectiveAddOrUpdate($injectionClass, $item, $values, $add); $this->processAfterInsertOrUpdate($injectionClass, $add); } } @@ -1457,17 +1490,17 @@ public function processAddOrUpdate() { } - /** + /** * Perform data injection into GLPI DB * * @param injectionClass class which represents the object to inject - * @param add true to insert an object, false to update an existing object * @param item the CommonDBTM object representing the itemtype to inject * @param values the values to inject + * @param add true to insert an object, false to update an existing object * * @return the id of the object added or updated **/ - private function effectiveAddOrUpdate($injectionClass, $add=true, $item, $values) { + private function effectiveAddOrUpdate($injectionClass, $item, $values, $add=true) { //Insert data using the standard add() method $toinject = array(); @@ -1485,11 +1518,12 @@ private function effectiveAddOrUpdate($injectionClass, $add=true, $item, $values } } - //logDebug("effectiveAddOrUpdate($add)", "Values:", $values, "ToInject:", $toinject); if (method_exists($injectionClass, 'customimport')) { - $newID = call_user_func(array($injectionClass, 'customimport'), $toinject, $add, - $this->rights); - } elseif ($item instanceof CommonDropdown && $add) { + $newID = call_user_func( + array($injectionClass, 'customimport'), $toinject, $add, + $this->rights + ); + } else if ($item instanceof CommonDropdown && $add) { $newID = $item->import($toinject); } else { @@ -1509,7 +1543,7 @@ private function effectiveAddOrUpdate($injectionClass, $add=true, $item, $values } - /** + /** * Add optional informations filled by the user * * @return nothing @@ -1524,8 +1558,10 @@ private function addOptionalInfos() { if ($field == 'templates_id') { $item = new $itemtype(); if ($item->getFromDB($value)) { - $this->setValueForItemtype($itemtype, 'template_name', - $item->fields['template_name']); + $this->setValueForItemtype( + $itemtype, 'template_name', + $item->fields['template_name'] + ); $this->setValueForItemtype($itemtype, '_oldID', $value); } } else { @@ -1536,22 +1572,26 @@ private function addOptionalInfos() { } } - /** + /** * If an optional info need more processing (for example password) - * @param itemtype being injected - * @param field the optional info field - * @param value the optional info value + * + * @param itemtype being injected + * @param field the optional info field + * @param value the optional info value * @return nothing */ protected function addSpecificOptionalInfos($itemtype, $field, $value) { + } - /** + /** * Process dictionnaries if needed - * @since 2.1.6 + * + * @since 2.1.6 * @return nothing */ protected function processDictionnariesIfNeeded() { + //If itemtype implements special process after type injection if (method_exists($this->injectionClass, 'processDictionnariesIfNeeded')) { //Invoke it @@ -1561,7 +1601,7 @@ protected function processDictionnariesIfNeeded() { } } - /** + /** * Manage fields tagged as relations * * @return nothing @@ -1577,13 +1617,16 @@ private function manageRelations() { //If it's a relation if (isset($option['displaytype']) && $option['displaytype'] == 'relation' - && isset($this->values[$itemtype][$option['linkfield']])) { + && isset($this->values[$itemtype][$option['linkfield']]) + ) { //Get the relation object associated with the field //Add a new array for the relation object $value = $this->getValueByItemtypeAndName($itemtype, $option['linkfield']); - $this->getFieldValue(null, $option['relationclass'], $option, $option['linkfield'], - $value, true); + $this->getFieldValue( + null, $option['relationclass'], $option, $option['linkfield'], + $value, true + ); //Remove the old option $this->unsetValue($itemtype, $option['linkfield']); @@ -1593,7 +1636,7 @@ private function manageRelations() { } - /** + /** * Function to check if the data to inject already exists in DB * * @param class which represents type to inject @@ -1602,6 +1645,7 @@ private function manageRelations() { * @return nothing **/ private function dataAlreadyInDB($injectionClass, $itemtype) { + global $DB; $where = ""; @@ -1638,10 +1682,10 @@ private function dataAlreadyInDB($injectionClass, $itemtype) { $item = new $itemtype(); //If it's a computer device if ($item instanceof CommonDevice) { - $sql.= " WHERE `designation` = '" . - $this->getValueByItemtypeAndName($itemtype, 'designation') . "'"; + $sql.= " WHERE `designation` = '" . + $this->getValueByItemtypeAndName($itemtype, 'designation') . "'"; - } elseif ($item instanceof CommonDBRelation) { + } else if ($item instanceof CommonDBRelation) { //Type is a relation : check it this relation still exists //Define the side of the relation to use @@ -1664,15 +1708,15 @@ private function dataAlreadyInDB($injectionClass, $itemtype) { } $where .= " AND `$source_id`='". - $this->getValueByItemtypeAndName($itemtype,$source_id)."'"; + $this->getValueByItemtypeAndName($itemtype, $source_id)."'"; if ($item->isField('itemtype')) { $where .= " AND `$source_itemtype`='". - $this->getValueByItemtypeAndName($itemtype, $source_itemtype)."'"; + $this->getValueByItemtypeAndName($itemtype, $source_itemtype)."'"; } $where .= " AND `".$destination_id."`='". - $this->getValueByItemtypeAndName($itemtype, $destination_id)."'"; + $this->getValueByItemtypeAndName($itemtype, $destination_id)."'"; $sql .= " WHERE 1 ".$where; } else { @@ -1693,15 +1737,19 @@ private function dataAlreadyInDB($injectionClass, $itemtype) { //Type can be recursive if ($injectionClass->maybeRecursive()) { - $where_entity = getEntitiesRestrictRequest(" AND", $injectionClass->getTable(), - "entities_id", - $this->getValueByItemtypeAndName($itemtype, - 'entities_id'), - true); + $where_entity = getEntitiesRestrictRequest( + " AND", $injectionClass->getTable(), + "entities_id", + $this->getValueByItemtypeAndName( + $itemtype, + 'entities_id' + ), + true + ); } else { //Type cannot be recursive $where_entity = " AND `entities_id` = '". - $this->getValueByItemtypeAndName($itemtype, 'entities_id')."'"; + $this->getValueByItemtypeAndName($itemtype, 'entities_id')."'"; } } else { //If no entity assignment for this itemtype @@ -1714,26 +1762,30 @@ private function dataAlreadyInDB($injectionClass, $itemtype) { if ($is_mandatory) { $option = self::findSearchOption($searchOptions, $field); $where .= " AND `" . $field . "`='". - $this->getValueByItemtypeAndName($itemtype, $field) . "'"; + $this->getValueByItemtypeAndName($itemtype, $field) . "'"; } } } else { //Table contains an itemtype field if ($injectionClass->isField('itemtype')) { - $where .= " AND `itemtype` = '".$this->getValueByItemtypeAndName($itemtype, - 'itemtype')."'"; + $where .= " AND `itemtype` = '".$this->getValueByItemtypeAndName( + $itemtype, + 'itemtype' + )."'"; } //Table contains an items_id field if ($injectionClass->isField('items_id')) { - $where .= " AND `items_id` = '".$this->getValueByItemtypeAndName($itemtype, - 'items_id')."'"; + $where .= " AND `items_id` = '".$this->getValueByItemtypeAndName( + $itemtype, + 'items_id' + )."'"; } } //Add additional parameters specific to this itemtype (or function checkPresent exists) - if (method_exists($injectionClass,'checkPresent')) { + if (method_exists($injectionClass, 'checkPresent')) { $where .= $injectionClass->checkPresent($this->values, $options); } $sql .= " WHERE 1 " . $where_entity . " " . $where; @@ -1755,7 +1807,7 @@ private function dataAlreadyInDB($injectionClass, $itemtype) { } - /** + /** * Add fields coming for a template to the values to be injected * * @param itemtype the itemtype to inject @@ -1770,28 +1822,33 @@ private function addTemplateFields($itemtype) { $template_id = $this->getValueByItemtypeAndName($itemtype, '_oldID'); if ($template->getFromDB($template_id) && $itemtype != 'Entity') { - unset ($template->fields["id"]); - unset ($template->fields["date_mod"]); - unset ($template->fields["is_template"]); - unset ($template->fields["entities_id"]); + unset($template->fields["id"]); + unset($template->fields["date_mod"]); + unset($template->fields["is_template"]); + unset($template->fields["entities_id"]); foreach ($template->fields as $key => $value) { if ($value != self::EMPTY_VALUE - && (!isset ($this->values[$itemtype][$key]) - || $this->values[$itemtype][$key] == self::EMPTY_VALUE - || $this->values[$itemtype][$key] == self::DROPDOWN_EMPTY_VALUE)) { + && (!isset($this->values[$itemtype][$key]) + || $this->values[$itemtype][$key] == self::EMPTY_VALUE + || $this->values[$itemtype][$key] == self::DROPDOWN_EMPTY_VALUE) + ) { $value = Toolbox::addslashes_deep($value); $this->setValueForItemtype($itemtype, $key, $value); } } if (isset($this->values[$itemtype]['name'])) { - $name = autoName($this->values[$itemtype]['name'], "name", true, $itemtype, - $this->values[$itemtype]['entities_id']); + $name = autoName( + $this->values[$itemtype]['name'], "name", true, $itemtype, + $this->values[$itemtype]['entities_id'] + ); $this->setValueForItemtype($itemtype, 'name', $name); } if (isset($this->values[$itemtype]['otherserial'])) { - $otherserial = autoName($this->values[$itemtype]['otherserial'], "otherserial", true, - $itemtype, $this->values[$itemtype]['entities_id']); + $otherserial = autoName( + $this->values[$itemtype]['otherserial'], "otherserial", true, + $itemtype, $this->values[$itemtype]['entities_id'] + ); $this->setValueForItemtype($itemtype, 'otherserial', $otherserial); } } @@ -1799,7 +1856,7 @@ private function addTemplateFields($itemtype) { } - /** + /** * Log event into the history * * @param device_type the type of the item to inject @@ -1819,12 +1876,12 @@ static function logAddOrUpdate($item, $add=true) { $changes[2] = __('Update from CSV file', 'datainjection'); } $changes[1] = ""; - Log::history ($item->fields['id'], get_class($item), $changes); + Log::history($item->fields['id'], get_class($item), $changes); } } - /** + /** * Get label associated with an injection action * * @param action code as defined in the head of this file @@ -1834,17 +1891,17 @@ static function logAddOrUpdate($item, $add=true) { static function getActionLabel($action) { $actions = array(self::IMPORT_ADD => __('Add'), - self::IMPORT_UPDATE => __('Update'), - self::IMPORT_DELETE => __('Delete')); + self::IMPORT_UPDATE => __('Update'), + self::IMPORT_DELETE => __('Delete')); if (isset($actions[$action])) { - return $actions[$action]; + return $actions[$action]; } - return ""; + return ""; } - /** + /** * Get label associated with an injection result * * @param action code as defined in the head of this file @@ -1904,18 +1961,19 @@ public static function getLogLabel($type) { return $message; } - /** + /** * Manage search options **/ - static function addToSearchOptions($type_searchOptions = array(), $options = array(), - $injectionClass) { + static function addToSearchOptions(array $type_searchOptions, array $options, + PluginDatainjectionInjectionInterface $injectionClass + ) { self::addTemplateSearchOptions($injectionClass, $type_searchOptions); //Add linkfield for theses fields : no massive action is allowed in the core, but they can be //imported using the commonlib $add_linkfield = array('comment' => 'comment', - 'notepad' => 'notepad'); + 'notepad' => 'notepad'); foreach ($type_searchOptions as $id => $tmp) { if (!is_array($tmp) || in_array($id, $options['ignore_fields'])) { @@ -1954,11 +2012,11 @@ static function addToSearchOptions($type_searchOptions = array(), $options = arr } } - return $type_searchOptions; + return $type_searchOptions; } - /** + /** * Add necessary search options for template management * * @param injectionClass the injection class to use @@ -1992,9 +2050,10 @@ static function addTemplateSearchOptions($injectionClass,&$tab) { } - /** + /** * If itemtype injection needs to process things after data is written in DB - * @param add true if an item is created, false if it's an update + * + * @param add true if an item is created, false if it's an update * @return nothing **/ private function processAfterInsertOrUpdate($injectionClass, $add = true) { @@ -2005,7 +2064,4 @@ private function processAfterInsertOrUpdate($injectionClass, $add = true) { $injectionClass->processAfterInsertOrUpdate($this->values, $add, $this->rights); } } - } - -?> diff --git a/inc/computer_iteminjection.class.php b/inc/computer_iteminjection.class.php index 407a46e0..28404f61 100644 --- a/inc/computer_iteminjection.class.php +++ b/inc/computer_iteminjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionComputer_ItemInjection extends Computer_Item - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -45,23 +46,26 @@ static function getTable() { static function getTypeName($nb=0) { + return __('Direct connections'); } function isPrimaryType() { + return false; } function connectedTo() { + global $CFG_GLPI; return $CFG_GLPI["directconnect_types"]; } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -97,7 +101,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -108,7 +112,7 @@ function addOrUpdateObject($values=array(), $options=array()) { } - /** + /** * @param $primary_type * @param $values **/ @@ -120,4 +124,3 @@ function addSpecificNeededFields($primary_type, $values) { } } -?> \ No newline at end of file diff --git a/inc/computer_softwarelicenseinjection.class.php b/inc/computer_softwarelicenseinjection.class.php index e1f03b02..74398f15 100644 --- a/inc/computer_softwarelicenseinjection.class.php +++ b/inc/computer_softwarelicenseinjection.class.php @@ -29,14 +29,16 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionComputer_SoftwareLicenseInjection extends Computer_SoftwareLicense - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTypeName($nb=0) { + return __('Computer'); } @@ -50,16 +52,18 @@ static function getTable() { function isPrimaryType() { + return false; } function connectedTo() { + return array('SoftwareLicense'); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -76,8 +80,10 @@ function getOptions($primary_type='') { $tab[111]['table'] = 'glpi_computers'; $tab[111]['field'] = 'serial'; $tab[111]['linkfield'] = 'serial'; - $tab[111]['name'] = sprintf(__('%1$s - %2$s'), self::getTypeName(), - __('Serial number')); + $tab[111]['name'] = sprintf( + __('%1$s - %2$s'), self::getTypeName(), + __('Serial number') + ); $tab[111]['injectable'] = true; $tab[111]['displaytype'] = 'dropdown'; $tab[111]['checktype'] = 'text'; @@ -86,8 +92,10 @@ function getOptions($primary_type='') { $tab[112]['table'] = 'glpi_computers'; $tab[112]['field'] = 'otherserial'; $tab[112]['linkfield'] = 'otherserial'; - $tab[112]['name'] = sprintf(__('%1$s - %2$s'), self::getTypeName(), - __('Inventory number')); + $tab[112]['name'] = sprintf( + __('%1$s - %2$s'), self::getTypeName(), + __('Inventory number') + ); $tab[112]['injectable'] = true; $tab[112]['displaytype'] = 'dropdown'; $tab[112]['checktype'] = 'text'; @@ -97,7 +105,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -111,11 +119,11 @@ function addOrUpdateObject($values=array(), $options=array()) { function addSpecificMandatoryFields() { return array('computers_id' => 1, - 'softwarelicenses_id' => 1); + 'softwarelicenses_id' => 1); } - /** + /** * @param $primary_type * @param $values **/ @@ -128,4 +136,3 @@ function addSpecificNeededFields($primary_type, $values) { } } -?> \ No newline at end of file diff --git a/inc/computer_softwareversioninjection.class.php b/inc/computer_softwareversioninjection.class.php index 14cf8b01..3dadba65 100644 --- a/inc/computer_softwareversioninjection.class.php +++ b/inc/computer_softwareversioninjection.class.php @@ -29,14 +29,16 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionComputer_SoftwareVersionInjection extends Computer_SoftwareVersion - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTypeName($nb=0) { + return __('Computer'); } @@ -49,16 +51,18 @@ static function getTable() { function isPrimaryType() { + return false; } function connectedTo() { + return array('Software', 'SoftwareVersion'); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -75,8 +79,10 @@ function getOptions($primary_type='') { $tab[111]['table'] = 'glpi_computers'; $tab[111]['field'] = 'serial'; $tab[111]['linkfield'] = 'serial'; - $tab[111]['name'] = sprintf(__('%1$s - %2$s'), self::getTypeName(), - __('Serial number')); + $tab[111]['name'] = sprintf( + __('%1$s - %2$s'), self::getTypeName(), + __('Serial number') + ); $tab[111]['injectable'] = true; $tab[111]['displaytype'] = 'dropdown'; $tab[111]['checktype'] = 'text'; @@ -85,8 +91,10 @@ function getOptions($primary_type='') { $tab[112]['table'] = 'glpi_computers'; $tab[112]['field'] = 'otherserial'; $tab[112]['linkfield'] = 'otherserial'; - $tab[112]['name'] = sprintf(__('%1$s - %2$s'), self::getTypeName(), - __('Inventory number')); + $tab[112]['name'] = sprintf( + __('%1$s - %2$s'), self::getTypeName(), + __('Inventory number') + ); $tab[112]['injectable'] = true; $tab[112]['displaytype'] = 'dropdown'; $tab[112]['checktype'] = 'text'; @@ -96,7 +104,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -110,16 +118,17 @@ function addOrUpdateObject($values=array(), $options=array()) { function addSpecificMandatoryFields() { return array('computers_id' => 1, - 'softwareversions_id' => 1); + 'softwareversions_id' => 1); } - /** + /** * @param $primary_type * @param $values **/ function addSpecificNeededFields($primary_type, $values) { + if (isset($values['SoftwareVersion'])) { $fields['softwareversions_id'] = $values['SoftwareVersion']['id']; } @@ -127,4 +136,3 @@ function addSpecificNeededFields($primary_type, $values) { } } -?> \ No newline at end of file diff --git a/inc/computerinjection.class.php b/inc/computerinjection.class.php index c3aa5eb8..14cd5d57 100644 --- a/inc/computerinjection.class.php +++ b/inc/computerinjection.class.php @@ -29,12 +29,13 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } /// Computer class class PluginDatainjectionComputerInjection extends Computer - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -46,16 +47,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -68,20 +71,20 @@ function getOptions($primary_type='') { //Remove some options because some fields cannot be imported $blacklist = PluginDatainjectionCommonInjectionLib::getBlacklistedOptions(get_parent_class($this)); $notimportable = array(10, 11, 12, 13, 14, 15, 19, 34, 35, 36, 39, 91, 92, 93, - 150, 151, 152, 153, 154, 155, 156, 160, 161, 162, 163, 164 ,165, 166); + 150, 151, 152, 153, 154, 155, 156, 160, 161, 162, 163, 164 ,165, 166); $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("dropdown" => array(3, 4, 23, 31, 32, 33, 40, - 41, 42, 45, 46, 49, 71), - "user" => array(24, 70), - "multiline_text" => array(16, 90)); + 41, 42, 45, 46, 49, 71), + "user" => array(24, 70), + "multiline_text" => array(16, 90)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -92,4 +95,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> diff --git a/inc/computermodelinjection.class.php b/inc/computermodelinjection.class.php index 8657a6c7..897572f3 100644 --- a/inc/computermodelinjection.class.php +++ b/inc/computermodelinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionComputerModelInjection extends ComputerModel - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -45,16 +46,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -73,7 +76,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -84,4 +87,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/computertypeinjection.class.php b/inc/computertypeinjection.class.php index a5e80f55..27593b0e 100644 --- a/inc/computertypeinjection.class.php +++ b/inc/computertypeinjection.class.php @@ -29,19 +29,22 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionComputerTypeInjection extends ComputerType - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ function isPrimaryType() { + return true; } function connectedTo() { + return array(); } @@ -54,7 +57,7 @@ static function getTable() { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -73,7 +76,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -84,4 +87,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> diff --git a/inc/consumableiteminjection.class.php b/inc/consumableiteminjection.class.php index 1c3f16ff..9c9fd8db 100644 --- a/inc/consumableiteminjection.class.php +++ b/inc/consumableiteminjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionConsumableItemInjection extends ConsumableItem - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -45,16 +46,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -76,24 +79,23 @@ function getOptions($primary_type='') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("dropdown" => array(3, 4, 23, 49), - "user" => array(24), - "multiline_text" => array(16, 90), - "dropdown_integer" => array(8)); + "user" => array(24), + "multiline_text" => array(16, 90), + "dropdown_integer" => array(8)); $options['checktype'] = array("integer" => array(8)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { - $lib = new PluginDatainjectionCommonInjectionLib($this,$values,$options); + $lib = new PluginDatainjectionCommonInjectionLib($this, $values, $options); $lib->processAddOrUpdate(); return $lib->getInjectionResults(); } } -?> \ No newline at end of file diff --git a/inc/contact_supplierinjection.class.php b/inc/contact_supplierinjection.class.php index 6e2630ed..384e538b 100644 --- a/inc/contact_supplierinjection.class.php +++ b/inc/contact_supplierinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionContact_SupplierInjection extends Contact_Supplier - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -45,16 +46,18 @@ static function getTable() { function isPrimaryType() { + return false; } function connectedTo() { + return array('Contact', 'Supplier'); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,16 +85,15 @@ function addOrUpdateObject($values=array(), $options=array()) { } - /** + /** * @param $primary_type * @param $values **/ function addSpecificNeededFields($primary_type,$values) { $fields[getForeignKeyFieldForTable(getTableForItemType($primary_type))] - = $values[$primary_type]['id']; + = $values[$primary_type]['id']; return $fields; } } -?> \ No newline at end of file diff --git a/inc/contactinjection.class.php b/inc/contactinjection.class.php index 488e69c5..c887f6b6 100644 --- a/inc/contactinjection.class.php +++ b/inc/contactinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionContactInjection extends Contact - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -45,16 +46,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array('Supplier'); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -68,14 +71,14 @@ function getOptions($primary_type='') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("dropdown" => array(8, 9), - "bool" => array(86), - "multiline_text" => array(16, 82, 90)); + "bool" => array(86), + "multiline_text" => array(16, 82, 90)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -86,4 +89,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/contacttypeinjection.class.php b/inc/contacttypeinjection.class.php index 8435c918..23d4d5a9 100644 --- a/inc/contacttypeinjection.class.php +++ b/inc/contacttypeinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionContactTypeInjection extends ContactType - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -72,7 +75,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -83,4 +86,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/contract_iteminjection.class.php b/inc/contract_iteminjection.class.php index 6e9283c5..f64dc2a7 100644 --- a/inc/contract_iteminjection.class.php +++ b/inc/contract_iteminjection.class.php @@ -29,7 +29,8 @@ ---------------------------------------------------------------------- */ class PluginDatainjectionContract_ItemInjection extends Contract_Item - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -40,23 +41,26 @@ static function getTable() { function isPrimaryType() { + return false; } function relationSide() { + return false; } function connectedTo() { + global $CFG_GLPI; return $CFG_GLPI["contract_types"]; } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -85,7 +89,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -96,7 +100,7 @@ function addOrUpdateObject($values=array(), $options=array()) { } - /** + /** * @param $primary_type * @param $values **/ @@ -108,4 +112,3 @@ function addSpecificNeededFields($primary_type, $values) { } } -?> \ No newline at end of file diff --git a/inc/contract_supplierinjection.class.php b/inc/contract_supplierinjection.class.php index 0e4ff6c2..abee5bfb 100644 --- a/inc/contract_supplierinjection.class.php +++ b/inc/contract_supplierinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionContract_SupplierInjection extends Contract_Supplier - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -45,16 +46,18 @@ static function getTable() { function isPrimaryType() { + return false; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -75,7 +78,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -86,14 +89,13 @@ function addOrUpdateObject($values=array(), $options=array()) { } - /** + /** * @param $primary_type * @param $values **/ function addSpecificNeededFields($primary_type, $values) { return array(getForeignKeyFieldForTable(getTableForItemType($primary_type)) - => $values[$primary_type]['id']); + => $values[$primary_type]['id']); } } -?> \ No newline at end of file diff --git a/inc/contractinjection.class.php b/inc/contractinjection.class.php index 6af905f3..fb29990e 100644 --- a/inc/contractinjection.class.php +++ b/inc/contractinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionContractInjection extends Contract - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -92,19 +95,19 @@ function getOptions($primary_type='') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("dropdown" => array(4), - "date" => array(5), - "dropdown_integer" => array(6, 7, 21), - "bool" => array(86), - "alert" => array(59), - "billing" => array(22), - "renewal" => array(23), - "multiline_text" => array(16 ,90)); + "date" => array(5), + "dropdown_integer" => array(6, 7, 21), + "bool" => array(86), + "alert" => array(59), + "billing" => array(22), + "renewal" => array(23), + "multiline_text" => array(16 ,90)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -115,7 +118,7 @@ function addOrUpdateObject($values=array(), $options=array()) { } - /** + /** * @param $info array * @param $option array **/ @@ -133,20 +136,38 @@ function showAdditionalInformation($info=array(),$option=array()) { break; case 'billing' : - Dropdown::showNumber($name, array('value' => 0, - 'min' => 12, - 'max' => 60, - 'step' => 12, - 'toadd' => array(0 => Dropdown::EMPTY_VALUE, - 1 => sprintf(_n('%d month', - '%d months', 1), 1), - 2 => sprintf(_n('%d month', - '%d months', 2), 2), - 3 => sprintf(_n('%d month', - '%d months', 3), 3), - 6 => sprintf(_n('%d month', - '%d months', 6), 6))), - array('unit' => 'month')); + Dropdown::showNumber( + $name, array('value' => 0, + 'min' => 12, + 'max' => 60, + 'step' => 12, + 'toadd' => array(0 => Dropdown::EMPTY_VALUE, + 1 => sprintf( + _n( + '%d month', + '%d months', 1 + ), 1 + ), + 2 => sprintf( + _n( + '%d month', + '%d months', 2 + ), 2 + ), + 3 => sprintf( + _n( + '%d month', + '%d months', 3 + ), 3 + ), + 6 => sprintf( + _n( + '%d month', + '%d months', 6 + ), 6 + ))), + array('unit' => 'month') + ); break; default: @@ -155,4 +176,3 @@ function showAdditionalInformation($info=array(),$option=array()) { } } -?> \ No newline at end of file diff --git a/inc/contracttypeinjection.class.php b/inc/contracttypeinjection.class.php index 661b8e58..501c92aa 100644 --- a/inc/contracttypeinjection.class.php +++ b/inc/contracttypeinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionContractTypeInjection extends ContractType - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -45,16 +46,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -72,7 +75,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -83,4 +86,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/data.class.php b/inc/data.class.php index e40808b0..8eadd33a 100644 --- a/inc/data.class.php +++ b/inc/data.class.php @@ -28,30 +28,34 @@ @since 2009 ---------------------------------------------------------------------- */ -class PluginDatainjectionData { +class PluginDatainjectionData +{ private $injectionData; function __construct() { + $injectionData = array(); } - /** + /** * @param $newData **/ function addToData($newData) { + $this->injectionData[] = $newData; } function getData() { + return $this->injectionData; } - /** + /** * @param $line_id **/ function getDataAtLine($line_id) { @@ -63,4 +67,3 @@ function getDataAtLine($line_id) { } } -?> diff --git a/inc/devicecaseinjection.class.php b/inc/devicecaseinjection.class.php index 5459d216..d51a9900 100644 --- a/inc/devicecaseinjection.class.php +++ b/inc/devicecaseinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionDeviceCaseInjection extends DeviceCase - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array("Computer"); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -66,13 +69,13 @@ function getOptions($primary_type='') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("multiline_text" => array(16), - "dropdown" => array(12, 23)); + "dropdown" => array(12, 23)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @param $values * @param $add (true by default) * @param $rights array @@ -84,10 +87,12 @@ function processAfterInsertOrUpdate($values, $add=true, $rights=array()) { $item = new $class(); $foreign = getForeignKeyFieldForTable(getTableForItemType(get_parent_class($this))); - if (!countElementsInTable($item->getTable(), - "`$foreign`='".$values[get_parent_class($this)]['id']."' + if (!countElementsInTable( + $item->getTable(), + "`$foreign`='".$values[get_parent_class($this)]['id']."' AND `itemtype`='Computer' - AND `items_id`='".$values['Computer']['id']."'")) { + AND `items_id`='".$values['Computer']['id']."'" + )) { $tmp[$foreign] = $values[get_parent_class($this)]['id']; $tmp['items_id'] = $values['Computer']['id']; $tmp['itemtype'] = 'Computer'; @@ -97,7 +102,7 @@ function processAfterInsertOrUpdate($values, $add=true, $rights=array()) { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -108,4 +113,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/devicecasetypeinjection.class.php b/inc/devicecasetypeinjection.class.php index e57d3ec4..4dfc7828 100644 --- a/inc/devicecasetypeinjection.class.php +++ b/inc/devicecasetypeinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionDeviceCaseTypeInjection extends DeviceCaseType - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,4 +85,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/devicecontrolinjection.class.php b/inc/devicecontrolinjection.class.php index 0776e531..df268dd2 100644 --- a/inc/devicecontrolinjection.class.php +++ b/inc/devicecontrolinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionDeviceControlInjection extends DeviceControl - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array("Computer"); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -66,14 +69,14 @@ function getOptions($primary_type='') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("multiline_text" => array(16), - "dropdown" => array(14, 23), - "bool" => array(12)); + "dropdown" => array(14, 23), + "bool" => array(12)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @param $values * @param $add (true by default) * @param $rights array @@ -86,10 +89,12 @@ function processAfterInsertOrUpdate($values, $add=true, $rights=array()) { $item = new $class(); $foreign = getForeignKeyFieldForTable(getTableForItemType(get_parent_class($this))); - if (!countElementsInTable($item->getTable(), - "`$foreign`='".$values[get_parent_class($this)]['id']."' + if (!countElementsInTable( + $item->getTable(), + "`$foreign`='".$values[get_parent_class($this)]['id']."' AND `itemtype`='Computer' - AND `items_id`='".$values['Computer']['id']."'")) { + AND `items_id`='".$values['Computer']['id']."'" + )) { $tmp[$foreign] = $values[get_parent_class($this)]['id']; $tmp['items_id'] = $values['Computer']['id']; $tmp['itemtype'] = 'Computer'; @@ -99,7 +104,7 @@ function processAfterInsertOrUpdate($values, $add=true, $rights=array()) { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -110,4 +115,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/devicedriveinjection.class.php b/inc/devicedriveinjection.class.php index e8cf2e8e..2690bb64 100644 --- a/inc/devicedriveinjection.class.php +++ b/inc/devicedriveinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionDeviceDriveInjection extends DeviceDrive - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array("Computer"); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -66,14 +69,14 @@ function getOptions($primary_type='') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("multiline_text" => array(16), - "dropdown" => array(14, 23), - "bool" => array(12)); + "dropdown" => array(14, 23), + "bool" => array(12)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @param $values * @param $add (true by default) * @param $rights array @@ -86,10 +89,12 @@ function processAfterInsertOrUpdate($values, $add=true, $rights=array()) { $item = new $class(); $foreign = getForeignKeyFieldForTable(getTableForItemType(get_parent_class($this))); - if (!countElementsInTable($item->getTable(), - "`$foreign`='".$values[get_parent_class($this)]['id']."' + if (!countElementsInTable( + $item->getTable(), + "`$foreign`='".$values[get_parent_class($this)]['id']."' AND `itemtype`='Computer' - AND `items_id`='".$values['Computer']['id']."'")) { + AND `items_id`='".$values['Computer']['id']."'" + )) { $tmp[$foreign] = $values[get_parent_class($this)]['id']; $tmp['items_id'] = $values['Computer']['id']; $tmp['itemtype'] = 'Computer'; @@ -100,7 +105,7 @@ function processAfterInsertOrUpdate($values, $add=true, $rights=array()) { - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -111,4 +116,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/deviceecasetypeinjection.class.php b/inc/deviceecasetypeinjection.class.php index e57d3ec4..4dfc7828 100644 --- a/inc/deviceecasetypeinjection.class.php +++ b/inc/deviceecasetypeinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionDeviceCaseTypeInjection extends DeviceCaseType - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,4 +85,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/deviceharddriveinjection.class.php b/inc/deviceharddriveinjection.class.php index ff17d988..53b35e2b 100644 --- a/inc/deviceharddriveinjection.class.php +++ b/inc/deviceharddriveinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionDeviceHardDriveInjection extends DeviceHardDrive - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array("Computer"); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -66,13 +69,13 @@ function getOptions($primary_type='') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("multiline_text" => array(16), - "dropdown" => array(14, 23)); + "dropdown" => array(14, 23)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @param $values * @param $add (true by default) * @param $rights array @@ -84,10 +87,12 @@ function processAfterInsertOrUpdate($values, $add=true, $rights=array()) { $item = new $class(); $foreign = getForeignKeyFieldForTable(getTableForItemType(get_parent_class($this))); - if (!countElementsInTable($item->getTable(), - "`$foreign`='".$values[get_parent_class($this)]['id']."' + if (!countElementsInTable( + $item->getTable(), + "`$foreign`='".$values[get_parent_class($this)]['id']."' AND `itemtype`='Computer' - AND `items_id`='".$values['Computer']['id']."'")) { + AND `items_id`='".$values['Computer']['id']."'" + )) { $tmp[$foreign] = $values[get_parent_class($this)]['id']; $tmp['items_id'] = $values['Computer']['id']; $tmp['itemtype'] = 'Computer'; @@ -97,7 +102,7 @@ function processAfterInsertOrUpdate($values, $add=true, $rights=array()) { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -108,4 +113,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/devicememoryinjection.class.php b/inc/devicememoryinjection.class.php index 2c87728f..e2f44a69 100644 --- a/inc/devicememoryinjection.class.php +++ b/inc/devicememoryinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionDeviceMemoryInjection extends DeviceMemory - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array("Computer"); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -66,13 +69,13 @@ function getOptions($primary_type='') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("multiline_text" => array(16), - "dropdown" => array(13, 23)); + "dropdown" => array(13, 23)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @param $values * @param $add (true by default) * @param $rights array @@ -91,7 +94,8 @@ function processAfterInsertOrUpdate($values, $add=true, $rights=array()) { if (!countElementsInTable($item->getTable(), $where)) { if (isset($values[get_parent_class($this)]['size']) - && ($values[get_parent_class($this)]['size'] > 0)) { + && ($values[get_parent_class($this)]['size'] > 0) + ) { $tmp['size'] = $values[get_parent_class($this)]['size']; } else { $tmp['size'] = 0; @@ -106,7 +110,7 @@ function processAfterInsertOrUpdate($values, $add=true, $rights=array()) { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -117,7 +121,7 @@ function addOrUpdateObject($values=array(), $options=array()) { } - /** + /** * @param $primary_type * @param $values **/ @@ -135,4 +139,3 @@ function addSpecificNeededFields($primary_type, $values) { } } -?> \ No newline at end of file diff --git a/inc/devicememorytypeinjection.class.php b/inc/devicememorytypeinjection.class.php index 8697f91b..84ba86ca 100644 --- a/inc/devicememorytypeinjection.class.php +++ b/inc/devicememorytypeinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionDeviceMemoryTypeInjection extends DeviceMemoryType - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,4 +85,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/devicemotherboardinjection.class.php b/inc/devicemotherboardinjection.class.php index b3ed88ab..14f02118 100644 --- a/inc/devicemotherboardinjection.class.php +++ b/inc/devicemotherboardinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionDeviceMotherboardInjection extends DeviceMotherboard - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array("Computer"); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -66,13 +69,13 @@ function getOptions($primary_type='') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("multiline_text" => array(16), - "dropdown" => array(23)); + "dropdown" => array(23)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @param $values * @param $add (true by default) * @param $rights array @@ -84,10 +87,12 @@ function processAfterInsertOrUpdate($values, $add=true, $rights=array()) { $item = new $class(); $foreign = getForeignKeyFieldForTable(getTableForItemType(get_parent_class($this))); - if (!countElementsInTable($item->getTable(), - "`$foreign`='".$values[get_parent_class($this)]['id']."' + if (!countElementsInTable( + $item->getTable(), + "`$foreign`='".$values[get_parent_class($this)]['id']."' AND `itemtype`='Computer' - AND `items_id`='".$values['Computer']['id']."'")) { + AND `items_id`='".$values['Computer']['id']."'" + )) { $tmp[$foreign] = $values[get_parent_class($this)]['id']; $tmp['items_id'] = $values['Computer']['id']; $tmp['itemtype'] = 'Computer'; @@ -97,7 +102,7 @@ function processAfterInsertOrUpdate($values, $add=true, $rights=array()) { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -108,4 +113,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/devicenetworkcardinjection.class.php b/inc/devicenetworkcardinjection.class.php index 86de8b45..bb3f5e15 100644 --- a/inc/devicenetworkcardinjection.class.php +++ b/inc/devicenetworkcardinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionDeviceNetworkCardInjection extends DeviceNetworkCard - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array("Computer"); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() */ function getOptions($primary_type='') { @@ -66,13 +69,13 @@ function getOptions($primary_type='') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("multiline_text" => array(16), - "dropdown" => array(23)); + "dropdown" => array(23)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @param $values * @param $add (true by default) * @param $rights array @@ -84,10 +87,12 @@ function processAfterInsertOrUpdate($values, $add=true, $rights=array()) { $item = new $class(); $foreign = getForeignKeyFieldForTable(getTableForItemType(get_parent_class($this))); - if (!countElementsInTable($item->getTable(), - "`$foreign`='".$values[get_parent_class($this)]['id']."' + if (!countElementsInTable( + $item->getTable(), + "`$foreign`='".$values[get_parent_class($this)]['id']."' AND `itemtype`='Computer' - AND `items_id`='".$values['Computer']['id']."'")) { + AND `items_id`='".$values['Computer']['id']."'" + )) { $tmp[$foreign] = $values[get_parent_class($this)]['id']; $tmp['items_id'] = $values['Computer']['id']; $tmp['itemtype'] = 'Computer'; @@ -97,7 +102,7 @@ function processAfterInsertOrUpdate($values, $add=true, $rights=array()) { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -108,4 +113,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/deviceprocessorinjection.class.php b/inc/deviceprocessorinjection.class.php index 8c29326f..77a27e69 100644 --- a/inc/deviceprocessorinjection.class.php +++ b/inc/deviceprocessorinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionDeviceProcessorInjection extends DeviceProcessor - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array("Computer"); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -66,13 +69,13 @@ function getOptions($primary_type='') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("multiline_text" => array(16), - "dropdown" => array(23)); + "dropdown" => array(23)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @param $values * @param $add (true by default) * @param $rights array @@ -91,7 +94,8 @@ function processAfterInsertOrUpdate($values, $add=true, $rights=array()) { if (!countElementsInTable($item->getTable(), $where)) { if (isset($values[get_parent_class($this)]['frequency']) - && ($values[get_parent_class($this)]['frequency'] > 0)) { + && ($values[get_parent_class($this)]['frequency'] > 0) + ) { $tmp['frequency'] = $values[get_parent_class($this)]['frequency']; } else { $tmp['frequency'] = 0; @@ -106,7 +110,7 @@ function processAfterInsertOrUpdate($values, $add=true, $rights=array()) { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -117,7 +121,7 @@ function addOrUpdateObject($values=array(), $options=array()) { } - /** + /** * @param $primary_type * @param $values **/ @@ -135,4 +139,3 @@ function addSpecificNeededFields($primary_type, $values) { } } -?> \ No newline at end of file diff --git a/inc/documentinjection.class.php b/inc/documentinjection.class.php index f954ef61..737f6373 100644 --- a/inc/documentinjection.class.php +++ b/inc/documentinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionDocumentInjection extends Document - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,25 +45,28 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { + return Search::getOptions(get_parent_class($this)); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -73,4 +77,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/documenttypeinjection.class.php b/inc/documenttypeinjection.class.php index a6685f6b..755752c4 100644 --- a/inc/documenttypeinjection.class.php +++ b/inc/documenttypeinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionDocumentTypeInjection extends DocumentType - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,4 +85,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/domaininjection.class.php b/inc/domaininjection.class.php index 3bdecc9c..2f0eb00c 100644 --- a/inc/domaininjection.class.php +++ b/inc/domaininjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionDomainInjection extends Domain - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,4 +85,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/dropdown.class.php b/inc/dropdown.class.php index 71681bd9..5a1eb01a 100644 --- a/inc/dropdown.class.php +++ b/inc/dropdown.class.php @@ -28,16 +28,17 @@ @since 2009 ---------------------------------------------------------------------- */ -class PluginDatainjectionDropdown { +class PluginDatainjectionDropdown +{ static function dateFormats() { $date_format[PluginDatainjectionCommonInjectionLib::DATE_TYPE_DDMMYYYY] - = __('dd-mm-yyyy', 'datainjection'); + = __('dd-mm-yyyy', 'datainjection'); $date_format[PluginDatainjectionCommonInjectionLib::DATE_TYPE_MMDDYYYY] - = __('mm-dd-yyyy', 'datainjection'); + = __('mm-dd-yyyy', 'datainjection'); $date_format[PluginDatainjectionCommonInjectionLib::DATE_TYPE_YYYYMMDD] - = __('yyyy-mm-dd', 'datainjection'); + = __('yyyy-mm-dd', 'datainjection'); return $date_format; } @@ -56,17 +57,17 @@ static function getDateFormat($date) { static function floatFormats() { $float_format[PluginDatainjectionCommonInjectionLib::FLOAT_TYPE_DOT] - = __('1 234.56', 'datainjection'); + = __('1 234.56', 'datainjection'); $float_format[PluginDatainjectionCommonInjectionLib::FLOAT_TYPE_COMMA] - = __('1 234,56', 'datainjection'); + = __('1 234,56', 'datainjection'); $float_format[PluginDatainjectionCommonInjectionLib::FLOAT_TYPE_DOT_AND_COM] - = __('1,234.56', 'datainjection'); + = __('1,234.56', 'datainjection'); return $float_format; } - /** + /** * @param $format **/ static function getFloatFormat($format) { @@ -85,15 +86,19 @@ static function statusLabels() { //$states[PluginDatainjectionModel::INITIAL_STEP] = __('Creation of the model on going', 'datainjection'); $states[PluginDatainjectionModel::FILE_STEP] = __('File to inject', 'datainjection'); $states[PluginDatainjectionModel::MAPPING_STEP] = __('Mappings', 'datainjection'); - $states[PluginDatainjectionModel::OTHERS_STEP] = __('Additional Information', - 'datainjection'); - $states[PluginDatainjectionModel::READY_TO_USE_STEP] = __('Model available for use', - 'datainjection'); + $states[PluginDatainjectionModel::OTHERS_STEP] = __( + 'Additional Information', + 'datainjection' + ); + $states[PluginDatainjectionModel::READY_TO_USE_STEP] = __( + 'Model available for use', + 'datainjection' + ); return $states; } - /** + /** * Return current status of the model * * @return nothing @@ -110,36 +115,40 @@ static function getStatusLabel($step) { static function dropdownFileEncoding() { - $values[PluginDatainjectionBackend::ENCODING_AUTO] = __('Automatic detection', - 'datainjection'); + $values[PluginDatainjectionBackend::ENCODING_AUTO] = __( + 'Automatic detection', + 'datainjection' + ); $values[PluginDatainjectionBackend::ENCODING_UFT8] = __('UTF-8', 'datainjection'); $values[PluginDatainjectionBackend::ENCODING_ISO8859_1] = __('ISO8859-1', 'datainjection'); - Dropdown::showFromArray('file_encoding', $values, - array('value' => PluginDatainjectionBackend::ENCODING_AUTO)); + Dropdown::showFromArray( + 'file_encoding', $values, + array('value' => PluginDatainjectionBackend::ENCODING_AUTO) + ); } static function portUnicityValues() { $values[PluginDatainjectionCommonInjectionLib::UNICITY_NETPORT_LOGICAL_NUMBER] - = __('Port number'); + = __('Port number'); $values[PluginDatainjectionCommonInjectionLib::UNICITY_NETPORT_NAME] - = __('Name'); + = __('Name'); $values[PluginDatainjectionCommonInjectionLib::UNICITY_NETPORT_MACADDRESS] - = __('Mac address'); + = __('Mac address'); $values[PluginDatainjectionCommonInjectionLib::UNICITY_NETPORT_LOGICAL_NUMBER_NAME] - = __('Port number')."+".__('Name'); + = __('Port number')."+".__('Name'); $values[PluginDatainjectionCommonInjectionLib::UNICITY_NETPORT_LOGICAL_NUMBER_MAC] - = __('Port number')."+".__('Mac address'); + = __('Port number')."+".__('Mac address'); $values[PluginDatainjectionCommonInjectionLib::UNICITY_NETPORT_LOGICAL_NUMBER_NAME_MAC] - = __('Port number')."+".__('Name')."+". - __('Mac address'); + = __('Port number')."+".__('Name')."+". + __('Mac address'); return $values; } - /** + /** * @param $value **/ static function getPortUnicityValues($value) { @@ -152,4 +161,3 @@ static function getPortUnicityValues($value) { } } -?> \ No newline at end of file diff --git a/inc/engine.class.php b/inc/engine.class.php index 1db61e35..bd2f790a 100644 --- a/inc/engine.class.php +++ b/inc/engine.class.php @@ -28,21 +28,22 @@ @since 2009 ---------------------------------------------------------------------- */ -class PluginDatainjectionEngine { - //Model informations +class PluginDatainjectionEngine +{ + //Model informations private $model; - //Current entity + //Current entity private $entity; - //Additional infos to be added + //Additional infos to be added private $infos = array(); - //Lines in error + //Lines in error private $error_lines = array(); - /** + /** * @param $model * @param $infos array * @param $entity (default 0) @@ -61,7 +62,7 @@ function __construct($model, $infos=array(), $entity=0) { } - /** + /** * Inject one line of data * * @param $line one line of data to import @@ -84,11 +85,12 @@ function injectLine($line, $index) { //Note : ignore values which are not mapped with a glpi's field $searchOptions = $injectionClass->getOptions($itemtype); - for ($i=0 ; $igetModel()->getMappingByRank($i); //If field is mapped with a value in glpi if (($mapping != null) - && ($mapping->getItemtype() != PluginDatainjectionInjectionType::NO_VALUE)) { + && ($mapping->getItemtype() != PluginDatainjectionInjectionType::NO_VALUE) + ) { $this->addValueToInject($fields_toinject, $searchOptions, $mapping, $line[$i], $several); } } @@ -109,37 +111,37 @@ function injectLine($line, $index) { //--------------- Set all needed options ------------------// //Check options $checks = array('ip' => true, - 'mac' => true, - 'integer' => true, - 'yes' => true, - 'bool' => true, - 'date' => $this->getModel()->getDateFormat(), - 'float' => $this->getModel()->getFloatFormat(), - 'string' => true, - 'right_r' => true, - 'right_rw' => true, - 'interface' => true, - 'auth_method' => true, - 'port_unicity' => $this->getModel()->getPortUnicity()); + 'mac' => true, + 'integer' => true, + 'yes' => true, + 'bool' => true, + 'date' => $this->getModel()->getDateFormat(), + 'float' => $this->getModel()->getFloatFormat(), + 'string' => true, + 'right_r' => true, + 'right_rw' => true, + 'interface' => true, + 'auth_method' => true, + 'port_unicity' => $this->getModel()->getPortUnicity()); //Rights options $rights = array('add_dropdown' => $this->getModel()->getCanAddDropdown(), - 'overwrite_notempty_fields' => $this->getModel()->getCanOverwriteIfNotEmpty(), - 'can_add' => $this->model->getBehaviorAdd(), - 'can_update' => $this->model->getBehaviorUpdate(), - 'can_delete' => false); + 'overwrite_notempty_fields' => $this->getModel()->getCanOverwriteIfNotEmpty(), + 'can_add' => $this->model->getBehaviorAdd(), + 'can_update' => $this->model->getBehaviorUpdate(), + 'can_delete' => false); //Field format options $formats = array('date_format' => $this->getModel()->getDateFormat(), - 'float_format' => $this->getModel()->getFloatFormat()); + 'float_format' => $this->getModel()->getFloatFormat()); //Check options : by default check all types $options = array('checks' => $checks, - 'entities_id' => $this->getEntity(), - 'rights' => $rights, - 'formats' => $formats, - 'mandatory_fields' => $mandatory_fields, - 'optional_data' => $optional_data); + 'entities_id' => $this->getEntity(), + 'rights' => $rights, + 'formats' => $formats, + 'mandatory_fields' => $mandatory_fields, + 'optional_data' => $optional_data); //Will manage add or update $results = $injectionClass->addOrUpdateObject($fields_toinject, $options); @@ -147,13 +149,13 @@ function injectLine($line, $index) { //Add injected line number to the result array $results['line'] = $index; if ($results['status'] != PluginDatainjectionCommonInjectionLib::SUCCESS) { - $this->error_lines[] = $line; + $this->error_lines[] = $line; } - return $results; + return $results; } - /** + /** * Add fields needed for injection * * @param $itemtype the itemtype to inject @@ -168,40 +170,44 @@ function addRequiredFields($itemtype, &$fields_toinject=array()) { } - /** + /** * Add a value to the fields to inject * - * @param $fields_toinject the fields - * @param $searchOptions options related to the itemtype to inject - * @param $mapping the mapping which matches the field - * @param $value the value for this field, as readed from the CSV file - * @param $several array of all fields which can be mapping more than one time + * @param $fields_toinject the fields + * @param $searchOptions options related to the itemtype to inject + * @param $mapping the mapping which matches the field + * @param $value the value for this field, as readed from the CSV file + * @param $several array of all fields which can be mapping more than one time * in the model * @return nothing **/ function addValueToInject(&$fields_toinject, $searchOptions, $mapping, $value, - $several = array()) { + $several = array() + ) { // Option will be found only for "main" type. - $option = PluginDatainjectionCommonInjectionLib::findSearchOption($searchOptions, - $mapping->getValue()); + $option = PluginDatainjectionCommonInjectionLib::findSearchOption( + $searchOptions, + $mapping->getValue() + ); $return_value = $value; if (($option['displaytype'] == 'multiline_text') && in_array($mapping->getValue(), $several) - && ($value != PluginDatainjectionCommonInjectionLib::EMPTY_VALUE)) { - $return_value = ''; + && ($value != PluginDatainjectionCommonInjectionLib::EMPTY_VALUE) + ) { + $return_value = ''; if (isset($fields_toinject[$mapping->getItemtype()][$mapping->getValue()])) { $return_value .= $fields_toinject[$mapping->getItemtype()][$mapping->getValue()]; } - $return_value .= $mapping->getMappingName()."=".$value."\n"; + $return_value .= $mapping->getMappingName()."=".$value."\n"; } - $fields_toinject[$mapping->getItemtype()][$mapping->getValue()] = $return_value; + $fields_toinject[$mapping->getItemtype()][$mapping->getValue()] = $return_value; } - /** + /** * Add additonal informations, as selected by the user which performs the CSV file import * * @return additional informations to inject @@ -211,30 +217,33 @@ function addAdditionalInformations() { $additional_infos = array(); foreach ($this->model->getInfos() as $info) { if (isset($this->infos[$info->getValue()]) - && PluginDatainjectionInfo::keepInfo($info, $this->infos[$info->getValue()])) { + && PluginDatainjectionInfo::keepInfo($info, $this->infos[$info->getValue()]) + ) { $additional_infos[$info->getInfosType()][$info->getValue()] - = $this->infos[$info->getValue()]; + = $this->infos[$info->getValue()]; } } return $additional_infos; } - //--------- Getters -------------------------// + //--------- Getters -------------------------// function getModel() { + return $this->model; } function getEntity() { + return $this->entity; } function getLinesInError() { + return $this->error_lines; } } -?> diff --git a/inc/entityinjection.class.php b/inc/entityinjection.class.php index 3533b3b2..6c274b8d 100644 --- a/inc/entityinjection.class.php +++ b/inc/entityinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionEntityInjection extends Entity - implements PluginDatainjectionInjectionInterface{ + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array('Document'); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -63,17 +66,17 @@ function getOptions($primary_type='') { //Remove some options because some fields cannot be imported $blacklist = PluginDatainjectionCommonInjectionLib::getBlacklistedOptions(get_parent_class($this)); $notimportable = array(14, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 42, 43, 44, 45, 47, 48, 49,50, 51, 52, 53, 54, 55, 91, 92, 93); + 42, 43, 44, 45, 47, 48, 49,50, 51, 52, 53, 54, 55, 91, 92, 93); $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("multiline_text" => array(3, 16, 17, 24), - "dropdown" => array(9)); + "dropdown" => array(9)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -84,7 +87,7 @@ function addOrUpdateObject($values=array(), $options=array()) { } - /** + /** * @param $input array * @param $add (true by default) * @param $rights array @@ -96,7 +99,7 @@ function customimport($input=array(), $add=true, $rights=array()) { } // Import a full tree from completename - $names = explode('>',$input['completename']); + $names = explode('>', $input['completename']); $fk = $this->getForeignKeyField(); $i = count($names); $parent = 0; @@ -125,22 +128,24 @@ function customimport($input=array(), $add=true, $rights=array()) { $tmp['entities_id'] = $parent; //Does the entity alread exists ? - $results = getAllDatasFromTable('glpi_entities', - "`name`='$name' AND `entities_id`='$parent'"); + $results = getAllDatasFromTable( + 'glpi_entities', + "`name`='$name' AND `entities_id`='$parent'" + ); //Entity doesn't exists => create it if (empty($results)) { - $parent = CommonDropdown::import($tmp); + $parent = CommonDropdown::import($tmp); } else { - //Entity already exists, use the ID as parent - $ent = array_pop($results); - $parent = $ent['id']; + //Entity already exists, use the ID as parent + $ent = array_pop($results); + $parent = $ent['id']; } } return $parent; } - /** + /** * @param $injectionClass * @param $values * @param $options @@ -150,16 +155,17 @@ function customDataAlreadyInDB($injectionClass, $values, $options) { if (!isset($values['completename'])) { return false; } - $results = getAllDatasFromTable('glpi_entities', - "`completename`='".$values['completename']."'"); + $results = getAllDatasFromTable( + 'glpi_entities', + "`completename`='".$values['completename']."'" + ); if (empty($results)) { - return false; + return false; } - $ent = array_pop($results); - return $ent['id']; + $ent = array_pop($results); + return $ent['id']; } } -?> \ No newline at end of file diff --git a/inc/filesystemtypeinjection.class.php b/inc/filesystemtypeinjection.class.php index aacf8ed2..c257cd02 100644 --- a/inc/filesystemtypeinjection.class.php +++ b/inc/filesystemtypeinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionFilesystemTypeInjection extends Filesystem - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,4 +85,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/group_userinjection.class.php b/inc/group_userinjection.class.php index 21551c00..188b7998 100644 --- a/inc/group_userinjection.class.php +++ b/inc/group_userinjection.class.php @@ -29,14 +29,16 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionGroup_UserInjection extends Group_User - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTypeName($nb=0) { + return sprintf(__('%1$s - %2$s'), __('Group'), __('User')); } @@ -49,17 +51,19 @@ static function getTable() { } function isPrimaryType() { + return false; } function connectedTo() { + //return array(); return array('Group'); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -78,13 +82,13 @@ function getOptions($primary_type='') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("bool" => array(3, 6, 7), - "dropdown" => array(4)); + "dropdown" => array(4)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -95,7 +99,7 @@ function addOrUpdateObject($values=array(), $options=array()) { } - /** + /** * @param $primary_type * @param $values **/ @@ -112,4 +116,3 @@ function addSpecificNeededFields($primary_type, $values) { } } -?> \ No newline at end of file diff --git a/inc/groupinjection.class.php b/inc/groupinjection.class.php index c938b8fe..8214218d 100644 --- a/inc/groupinjection.class.php +++ b/inc/groupinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionGroupInjection extends Group - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -66,13 +69,13 @@ function getOptions($primary_type='') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("bool" => array(11, 12, 13, 14 ,15, 17), - "multiline_text" => array(16)); + "multiline_text" => array(16)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -83,4 +86,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/info.class.php b/inc/info.class.php index ea7092da..681bc1cd 100644 --- a/inc/info.class.php +++ b/inc/info.class.php @@ -28,7 +28,8 @@ @since 2009 ---------------------------------------------------------------------- */ -class PluginDatainjectionInfo extends CommonDBTM { +class PluginDatainjectionInfo extends CommonDBTM +{ static $rightname = "plugin_datainjection_model"; @@ -41,30 +42,35 @@ function getEmpty() { function isMandatory() { + return $this->fields["is_mandatory"]; } function getInfosText() { + return $this->text; } function getValue() { + return $this->fields["value"]; } function getID() { + return $this->fields["id"]; } function getInfosType() { + return $this->fields["itemtype"]; } - /** + /** * @param $model PluginDatainjectionModel object * @param $canedit (false by default) **/ @@ -72,7 +78,7 @@ static function showAddInfo(PluginDatainjectionModel $model, $canedit=false) { if ($canedit) { echo ""; + Toolbox::getItemTypeFormURL(__CLASS__)."'>"; echo ""; echo ""; echo ""; @@ -88,10 +94,11 @@ static function showAddInfo(PluginDatainjectionModel $model, $canedit=false) { $info->fields['models_id'] = $model->fields['id']; $info->getEmpty(); - $rand = PluginDatainjectionInjectionType::dropdownLinkedTypes($info, - array('primary_type' - => $model->fields['itemtype']) - ); + $rand = PluginDatainjectionInjectionType::dropdownLinkedTypes( + $info, + array('primary_type' + => $model->fields['itemtype']) + ); echo ""; echo ""; echo ""; @@ -106,14 +113,14 @@ static function showAddInfo(PluginDatainjectionModel $model, $canedit=false) { echo "
    " . __('Tables', 'datainjection') . "
    "; Html::closeForm(); echo "
    "; - } + } } - /** - * + /** * Display additional information form from Model form + * * @param PluginDatainjectionModel $model */ static function showFormInfos(PluginDatainjectionModel $model) { @@ -150,10 +157,11 @@ static function showFormInfos(PluginDatainjectionModel $model) { echo ""; } echo ""; - $rand = PluginDatainjectionInjectionType::dropdownLinkedTypes($info, - array('primary_type' - => $model->fields['itemtype']) - ); + $rand = PluginDatainjectionInjectionType::dropdownLinkedTypes( + $info, + array('primary_type' + => $model->fields['itemtype']) + ); echo ""; echo ""; echo ""; @@ -175,11 +183,12 @@ static function showFormInfos(PluginDatainjectionModel $model) { } - /** + /** * @param $models_id * @param $infos array **/ static function manageInfos($models_id, $infos=array()) { + global $DB; $info = new self(); @@ -206,18 +215,22 @@ static function manageInfos($models_id, $infos=array()) { } } - $info->deleteByCriteria(array('models_id' => $models_id, - 'value' => PluginDatainjectionInjectionType::NO_VALUE)); + $info->deleteByCriteria( + array('models_id' => $models_id, + 'value' => PluginDatainjectionInjectionType::NO_VALUE) + ); } - /** + /** * @param $model PluginDatainjectionModel object **/ static function showAdditionalInformationsForm(PluginDatainjectionModel $model) { - $infos = getAllDatasFromTable('glpi_plugin_datainjection_infos', - "`models_id` = '". $model->getField('id')."'"); + $infos = getAllDatasFromTable( + 'glpi_plugin_datainjection_infos', + "`models_id` = '". $model->getField('id')."'" + ); $table = false; $modeltype = PluginDatainjectionModel::getInstance($model->getField('filetype')); @@ -225,20 +238,23 @@ static function showAdditionalInformationsForm(PluginDatainjectionModel $model) if (count($infos) || $modeltype->haveSample() - || $model->fields['comment']) { - echo ""; - echo "\n"; - $table = true; + || $model->fields['comment'] + ) { + echo "
    ".sprintf(__('%1$s (%2$s)'), - __('Complementary information', 'datainjection'), - __('Choose a file', 'datainjection')); - echo "
    "; + echo "\n"; + $table = true; } if ($modeltype->haveSample()) { - echo ""; - echo "\n"; + echo ""; + echo "\n"; } if ($model->fields['comment']) { echo ""; @@ -248,48 +264,52 @@ static function showAdditionalInformationsForm(PluginDatainjectionModel $model) $info = new PluginDatainjectionInfo(); foreach ($infos as $tmp) { - $info->fields = $tmp; - echo ""; - self::displayAdditionalInformation($info, - (isset($_SESSION['datainjection']['infos']) - ? $_SESSION['datainjection']['infos'] - : array())); - echo ""; + $info->fields = $tmp; + echo ""; + self::displayAdditionalInformation( + $info, + (isset($_SESSION['datainjection']['infos']) + ? $_SESSION['datainjection']['infos'] + : array()) + ); + echo ""; } } if ($table) { echo "
    ".sprintf( + __('%1$s (%2$s)'), + __('Complementary information', 'datainjection'), + __('Choose a file', 'datainjection') + ); + echo "
    "; - echo "".__('Download file sample', 'datainjection'); - echo "
    "; + echo "".__('Download file sample', 'datainjection'); + echo "

    "; } - $options['models_id'] = $model->getField('id'); - $options['confirm'] = 'process'; - PluginDatainjectionClientInjection::showUploadFileForm($options); + $options['models_id'] = $model->getField('id'); + $options['confirm'] = 'process'; + PluginDatainjectionClientInjection::showUploadFileForm($options); - //Store models_id in session for future usage - $_SESSION['datainjection']['models_id'] = $model->getField('id'); + //Store models_id in session for future usage + $_SESSION['datainjection']['models_id'] = $model->getField('id'); } - /** + /** * @param $info PluginDatainjectionInfo object * @param $values array */ static function displayAdditionalInformation(PluginDatainjectionInfo $info, $values=array()) { $injectionClass - = PluginDatainjectionCommonInjectionLib::getInjectionClassInstance($info->fields['itemtype']); + = PluginDatainjectionCommonInjectionLib::getInjectionClassInstance($info->fields['itemtype']); $option - = PluginDatainjectionCommonInjectionLib::findSearchOption($injectionClass->getOptions($info->fields['itemtype']), - $info->fields['value']); + = PluginDatainjectionCommonInjectionLib::findSearchOption( + $injectionClass->getOptions($info->fields['itemtype']), + $info->fields['value'] + ); if ($option) { - echo "".$option['name'].""; - self::showAdditionalInformation($info, $option, $injectionClass, $values); - echo ""; + echo "".$option['name'].""; + self::showAdditionalInformation($info, $option, $injectionClass, $values); + echo ""; } } - /** + /** * Display command additional informations * * @param info @@ -298,7 +318,7 @@ static function displayAdditionalInformation(PluginDatainjectionInfo $info, $val * * @return nothing **/ - static function showAdditionalInformation(PluginDatainjectionInfo $info, $option = array(), + static function showAdditionalInformation(PluginDatainjectionInfo $info, $option, $injectionClass, $values = array()) { $name = "info[".$option['linkfield']."]"; @@ -313,36 +333,40 @@ static function showAdditionalInformation(PluginDatainjectionInfo $info, $option case 'text' : case 'decimal' : if (empty($value)) { - $value = (isset($option['default'])?$option['default']:''); + $value = (isset($option['default'])?$option['default']:''); } echo ""; break; case 'dropdown' : if ($value == '') { - $value = 0; + $value = 0; } - Dropdown::show(getItemTypeForTable($option['table']), array('name' => $name, - 'value' => $value)); + Dropdown::show( + getItemTypeForTable($option['table']), array('name' => $name, + 'value' => $value) + ); break; case 'bool' : if ($value == '') { - $value = 0; + $value = 0; } Dropdown::showYesNo($name, $value); break; case 'user' : if ($value == '') { - $value = 0; + $value = 0; } - User::dropdown(array('name' => $name, - 'value' => $value)); + User::dropdown( + array('name' => $name, + 'value' => $value) + ); break; case 'date' : @@ -359,11 +383,13 @@ static function showAdditionalInformation(PluginDatainjectionInfo $info, $option $step = (isset($option['step'])?$option['step']:1); $default = (isset($option['-1'])?array(-1 => $option['-1']):array()); - Dropdown::showNumber($name, array('value' => $value, - 'min' => $minvalue, - 'max' => $maxvalue, - 'step' => $step, - 'toadd' => $default)); + Dropdown::showNumber( + $name, array('value' => $value, + 'min' => $minvalue, + 'max' => $maxvalue, + 'step' => $step, + 'toadd' => $default) + ); break; case 'template' : @@ -375,9 +401,9 @@ static function showAdditionalInformation(PluginDatainjectionInfo $info, $option break; default : - if (method_exists($injectionClass,'showAdditionalInformation')) { - //If type is not a standard type, must be treated by specific injection class - $injectionClass->showAdditionalInformation($info, $option); + if (method_exists($injectionClass, 'showAdditionalInformation')) { + //If type is not a standard type, must be treated by specific injection class + $injectionClass->showAdditionalInformation($info, $option); } } @@ -387,7 +413,7 @@ static function showAdditionalInformation(PluginDatainjectionInfo $info, $option } - /** + /** * @param $info PluginDatainjectionInfo object * @param $value **/ @@ -396,8 +422,10 @@ static function keepInfo(PluginDatainjectionInfo $info, $value) { $itemtype = $info->getInfosType(); $injectionClass = PluginDatainjectionCommonInjectionLib::getInjectionClassInstance($itemtype); $options = $injectionClass->getOptions($itemtype); - $option = PluginDatainjectionCommonInjectionLib::findSearchOption($options, - $info->getValue()); + $option = PluginDatainjectionCommonInjectionLib::findSearchOption( + $options, + $info->getValue() + ); if ($option) { switch ($option['displaytype']) { @@ -405,7 +433,7 @@ static function keepInfo(PluginDatainjectionInfo $info, $value) { case 'text' : case 'multiline_text' : if ($value != PluginDatainjectionCommonInjectionLib::EMPTY_VALUE) { - return true; + return true; } return false; @@ -421,11 +449,12 @@ static function keepInfo(PluginDatainjectionInfo $info, $value) { } - /** + /** * @param $name * @param $table **/ static function dropdownTemplates($name, $table) { + global $DB; $values = array(0 => Dropdown::EMPTY_VALUE); @@ -433,8 +462,8 @@ static function dropdownTemplates($name, $table) { $sql = "SELECT `id`, `template_name` FROM `".$table."` WHERE `is_template`=1 ". - getEntitiesRestrictRequest(' AND ', $table). - "ORDER BY `template_name`"; + getEntitiesRestrictRequest(' AND ', $table). + "ORDER BY `template_name`"; foreach ($DB->request($sql) as $data) { $values[$data['id']] = $data['template_name']; @@ -443,4 +472,3 @@ static function dropdownTemplates($name, $table) { } } -?> \ No newline at end of file diff --git a/inc/infocollection.class.php b/inc/infocollection.class.php index 2df63241..a6954304 100644 --- a/inc/infocollection.class.php +++ b/inc/infocollection.class.php @@ -28,24 +28,27 @@ @since 2009 ---------------------------------------------------------------------- */ -class PluginDatainjectionInfoCollection { +class PluginDatainjectionInfoCollection +{ - var $infosCollection; + var $infosCollection; function __construct() { + $this->infosCollection = array(); } - //---- Getter ----// + //---- Getter ----// - /** + /** * Load all the mappings for a specified model * * @param model_id the model ID **/ function load($models_id) { + global $DB; $query = "SELECT * @@ -60,14 +63,14 @@ function load($models_id) { } } - /** + /** * Return all the mappings for this model * * @return the list of all the mappings for this model **/ function getAllInfos() { + return $this->infosCollection; } } -?> \ No newline at end of file diff --git a/inc/infocominjection.class.php b/inc/infocominjection.class.php index ea30d032..ef979bbc 100644 --- a/inc/infocominjection.class.php +++ b/inc/infocominjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionInfocomInjection extends Infocom - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,18 +45,20 @@ static function getTable() { function isPrimaryType() { + return false; } function connectedTo() { + global $CFG_GLPI; return $CFG_GLPI["infocom_types"]; } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -106,18 +109,18 @@ function getOptions($primary_type='') { unset($options['ignore_fields'][$key]); $options['displaytype'] = array("date" => array(4, 5, 23, 24, 25, 27, 28), - "dropdown" => array(6, 9, 19), - "dropdown_integer" => array(6, 14), - "decimal" => array(8, 13, 17), - "sink_type" => array(15), - "alert" => array(22), - "multiline_text" => array(16)); + "dropdown" => array(6, 9, 19), + "dropdown_integer" => array(6, 14), + "decimal" => array(8, 13, 17), + "sink_type" => array(15), + "alert" => array(22), + "multiline_text" => array(16)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @param $info array * @param $option array **/ @@ -140,23 +143,24 @@ function showAdditionalInformation($info=array(), $option=array()) { } - /** + /** * @param $values array **/ function reformat(&$values=array()) { foreach (array('order_date', 'use_date', 'buy_date', 'warranty_date', 'delivery_date', - 'inventory_date') as $date) { + 'inventory_date') as $date) { if (isset($values['Infocom'][$date]) - && ($values['Infocom'][$date] == PluginDatainjectionCommonInjectionLib::EMPTY_VALUE)) { + && ($values['Infocom'][$date] == PluginDatainjectionCommonInjectionLib::EMPTY_VALUE) + ) { $values['Infocom'][$date] = "NULL"; } } } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -167,4 +171,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> diff --git a/inc/injectioninterface.class.php b/inc/injectioninterface.class.php index b2826cfd..d72bcef5 100644 --- a/inc/injectioninterface.class.php +++ b/inc/injectioninterface.class.php @@ -29,52 +29,53 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } /** * Interface to implement for each type to inject **/ -interface PluginDatainjectionInjectionInterface { +interface PluginDatainjectionInjectionInterface +{ - /** + /** * Tells datainjection is the type is a primary type or not * * @return a boolean **/ - function isPrimaryType(); + function isPrimaryType(); - /** + /** * Indicates to with other types it can be connected * * @return an array of GLPI types **/ - function connectedTo(); + function connectedTo(); - /** + /** * Function which calls getSearchOptions and add more parameters specific to display * * @param $primary_type (default '') * * @return an array of search options, as defined in each commondbtm object **/ - function getOptions($primary_type=''); + function getOptions($primary_type=''); - /** + /** * Manage display of additional informations * * @param $info array which contains the additional information values * * This method is optionnal ! Implement it if the itemtype to display special information **/ - //function showAdditionalInformation($info=array()); + //function showAdditionalInformation($info=array()); - /** + /** * Standard method to add an object into glpi * * @param $values array fields to add into glpi @@ -83,11 +84,11 @@ function getOptions($primary_type=''); * @return an array of IDs of newly created objects: * for example array(Computer=>1, Networkport=>10) **/ - function addOrUpdateObject($values=array(), $options=array()); + function addOrUpdateObject($values=array(), $options=array()); - /** + /** * Check values to inject * This method is optionnal ! Implement it if the itemtype need special checks * @@ -97,19 +98,19 @@ function addOrUpdateObject($values=array(), $options=array()); * * @return an array which indicates check status & errors **/ - //function checkType($field_name, $data, $mandatory); + //function checkType($field_name, $data, $mandatory); - /** + /** * Reformat data if itemtypes needs it * This method is optionnal ! Implement it if the itemtype need special reformat * * @param $values array **/ - //function reformat(&$values=array()); + //function reformat(&$values=array()); - /** + /** * Add itemtype specific checks to see if object is already in DB or not * * @param $fields_toinject array the fields to be injected into GLPI DB @@ -117,28 +118,27 @@ function addOrUpdateObject($values=array(), $options=array()); * * @return nothing **/ - //function checkPresent($fields_toinject=array(), $options=array()); + //function checkPresent($fields_toinject=array(), $options=array()); - /** + /** * Get value for a field (for example specific dropdowns for an itemtype) * This method is optionnal ! Implement it if the itemtype need special field values * * @param $itemtype * @param $searchOption - * @pram $field + * @pram $field * @param $value **/ - //function getSpecificFieldValue($itemtype, $searchOption, $field, $value); + //function getSpecificFieldValue($itemtype, $searchOption, $field, $value); - /** + /** * Add specific values to the object to inject * This method is optionnal ! Implement it if the itemtype need special reformat * * @param primary_type the primary_type to inject * @param fields_toinject all the fields that need to be injected **/ - //function addSpecificNeededFields($primary_type, $fields_toinject); + //function addSpecificNeededFields($primary_type, $fields_toinject); } -?> \ No newline at end of file diff --git a/inc/injectiontype.class.php b/inc/injectiontype.class.php index d3520c72..0c1c3d2c 100644 --- a/inc/injectiontype.class.php +++ b/inc/injectiontype.class.php @@ -30,10 +30,10 @@ class PluginDatainjectionInjectionType { - const NO_VALUE = 'none'; + const NO_VALUE = 'none'; - /** + /** * Return all injectable types * * @param $only_primary return only primary types (false by default) @@ -41,6 +41,7 @@ class PluginDatainjectionInjectionType { * @return an array which contains array(itemtype => itemtype name) **/ static function getItemtypes($only_primary=false) { + global $INJECTABLE_TYPES; getTypesToInject(); @@ -52,7 +53,8 @@ static function getItemtypes($only_primary=false) { if (class_exists($type) && (!$only_primary - || ($only_primary && $injectionclass->isPrimaryType()))) { + || ($only_primary && $injectionclass->isPrimaryType())) + ) { $instance = new $type(); //If user has no right to create an object of this type, do not display type in the list if (!$instance->canCreate()) { @@ -73,7 +75,7 @@ static function getItemtypes($only_primary=false) { } - /** + /** * Display a list of all importable types using datainjection plugin * * @param $value the selected value (default '') @@ -83,18 +85,21 @@ static function getItemtypes($only_primary=false) { **/ static function dropdown($value='', $only_primary=false) { - return Dropdown::showFromArray('itemtype', self::getItemtypes($only_primary), - array('value' => $value)); + return Dropdown::showFromArray( + 'itemtype', self::getItemtypes($only_primary), + array('value' => $value) + ); } - /** + /** * Get all types linked with a primary type * * @param $mapping_or_info * @param $options array **/ static function dropdownLinkedTypes($mapping_or_info, $options=array()) { + global $INJECTABLE_TYPES, $CFG_GLPI; getTypesToInject(); // populate $INJECTABLE_TYPES @@ -112,7 +117,8 @@ static function dropdownLinkedTypes($mapping_or_info, $options=array()) { $values = array(); if (($p['itemtype'] == self::NO_VALUE) - && ($mapping_or_info->fields['itemtype'] != self::NO_VALUE)) { + && ($mapping_or_info->fields['itemtype'] != self::NO_VALUE) + ) { $p['itemtype'] = $mapping_or_info->fields['itemtype']; } @@ -134,8 +140,10 @@ static function dropdownLinkedTypes($mapping_or_info, $options=array()) { } asort($values); - $rand = Dropdown::showFromArray("data[".$mappings_id."][itemtype]", - $values, array('value' => $p['itemtype'])); + $rand = Dropdown::showFromArray( + "data[".$mappings_id."][itemtype]", + $values, array('value' => $p['itemtype']) + ); $p['itemtype'] = '__VALUE__'; $url_field = $CFG_GLPI["root_doc"]."/plugins/datainjection/ajax/dropdownChooseField.php"; @@ -148,10 +156,11 @@ static function dropdownLinkedTypes($mapping_or_info, $options=array()) { } - /** + /** * @param $options array **/ static function dropdownFields($options = array()) { + global $CFG_GLPI; $used = array(); @@ -167,8 +176,10 @@ static function dropdownFields($options = array()) { } if ($p['need_decode']) { - $mapping_or_info = json_decode(Toolbox::stripslashes_deep($options['mapping_or_info']), - true); + $mapping_or_info = json_decode( + Toolbox::stripslashes_deep($options['mapping_or_info']), + true + ); } else { $mapping_or_info = $options['mapping_or_info']; } @@ -191,13 +202,15 @@ static function dropdownFields($options = array()) { //and if a linkfield is defined (meaning that the field can be updated) if (is_array($option) && isset($option['injectable']) - && ($option['injectable'] == PluginDatainjectionCommonInjectionLib::FIELD_INJECTABLE)) { + && ($option['injectable'] == PluginDatainjectionCommonInjectionLib::FIELD_INJECTABLE) + ) { $fields[$option['linkfield']] = $option['name']; if (($mapping_value == self::NO_VALUE) && ($p['called_by'] == 'PluginDatainjectionMapping') - && self::isEqual($option, $mapping_or_info)) { + && self::isEqual($option, $mapping_or_info) + ) { $mapping_value = $option['linkfield']; } @@ -207,19 +220,25 @@ static function dropdownFields($options = array()) { } asort($fields); - $rand = Dropdown::showFromArray("data[".$mapping_or_info['id']."][value]", $fields, - array('value' => $mapping_value, - 'used' => $used)); + $rand = Dropdown::showFromArray( + "data[".$mapping_or_info['id']."][value]", $fields, + array('value' => $mapping_value, + 'used' => $used) + ); $url = $CFG_GLPI["root_doc"]."/plugins/datainjection/ajax/dropdownMandatory.php"; - Ajax::updateItem("span_mandatory_".$mapping_or_info['id'], $url, $p, - "dropdown_data[".$mapping_or_info['id']."][value]$rand"); - Ajax::updateItemOnSelectEvent("dropdown_data[".$mapping_or_info['id']."][value]$rand", - "span_mandatory_".$mapping_or_info['id'], $url, $p); + Ajax::updateItem( + "span_mandatory_".$mapping_or_info['id'], $url, $p, + "dropdown_data[".$mapping_or_info['id']."][value]$rand" + ); + Ajax::updateItemOnSelectEvent( + "dropdown_data[".$mapping_or_info['id']."][value]$rand", + "span_mandatory_".$mapping_or_info['id'], $url, $p + ); } - /** + /** * Incidates if the name given corresponds to the current searchOption * * @param $option array the current searchOption (field definition) @@ -227,7 +246,7 @@ static function dropdownFields($options = array()) { * * @return boolean the value matches the searchOption or not **/ - static function isEqual($option=array(), $mapping) { + static function isEqual($option, $mapping) { $name = strtolower($mapping['name']); if (self::testBasicEqual(strtolower($mapping['name']), $option)) { @@ -235,7 +254,7 @@ static function isEqual($option=array(), $mapping) { } //Manage mappings begining with N° or n° - $new_name = preg_replace("/[n|N]°/",__('Lifelong'),$name); + $new_name = preg_replace("/[n|N]°/", __('Lifelong'), $name); if (self::testBasicEqual(strtolower($new_name), $option)) { return true; } @@ -249,34 +268,37 @@ static function isEqual($option=array(), $mapping) { } - /** + /** * @param $name * @param $option array **/ static function testBasicEqual($name, $option=array()) { - //Basic tests + //Basic tests if ((strtolower($option['field']) == $name) || (strtolower($option['name']) == $name) - || (strtolower($option['linkfield']) == $name)) { + || (strtolower($option['linkfield']) == $name) + ) { return true; } return false; } - /** + /** * @param $options array **/ static function showMandatoryCheckbox($options=array()) { //json adds more \ char than needed : when $options['mapping_or_info']['name'] contains a ' //json_decode fails to decode it ! - $options['mapping_or_info'] = str_replace("\\","", $options['mapping_or_info']); + $options['mapping_or_info'] = str_replace("\\", "", $options['mapping_or_info']); if ($options['need_decode']) { - $mapping_or_info = json_decode(Toolbox::stripslashes_deep($options['mapping_or_info']), - true); + $mapping_or_info = json_decode( + Toolbox::stripslashes_deep($options['mapping_or_info']), + true + ); } else { $mapping_or_info = $options['mapping_or_info']; } @@ -288,16 +310,18 @@ static function showMandatoryCheckbox($options=array()) { } if (($options['called_by'] == 'PluginDatainjectionInfo') - || ($options['primary_type'] == $options['itemtype'])) { + || ($options['primary_type'] == $options['itemtype']) + ) { echo ""; } } - /** + /** * @param $options array **/ static function getUsedMappingsOrInfos($options=array()) { + global $DB; $p['itemtype'] = self::NO_VALUE; @@ -311,15 +335,17 @@ static function getUsedMappingsOrInfos($options=array()) { } if ($p['need_decode']) { - $mapping_or_info = json_decode(Toolbox::stripslashes_deep($options['mapping_or_info']), - true); + $mapping_or_info = json_decode( + Toolbox::stripslashes_deep($options['mapping_or_info']), + true + ); } else { $mapping_or_info = $options['mapping_or_info']; } $used = array(); $table = (($p['called_by'] == 'PluginDatainjectionMapping') ?"glpi_plugin_datainjection_mappings" - :"glpi_plugin_datainjection_infos"); + :"glpi_plugin_datainjection_infos"); $datas = getAllDatasFromTable($table, "`models_id` = '".$mapping_or_info['models_id']."'"); @@ -333,7 +359,8 @@ static function getUsedMappingsOrInfos($options=array()) { && ($option['table'] == getItemTypeForTable($data['itemtype'])) && ($option['linkfield'] == $data['value']) && ($option['displaytype'] != 'multiline_text') - && ($mapping_or_info['value'] != $data['value'])) { + && ($mapping_or_info['value'] != $data['value']) + ) { $used[$option['linkfield']] = $option['linkfield']; break; @@ -346,4 +373,3 @@ static function getUsedMappingsOrInfos($options=array()) { } } -?> diff --git a/inc/interfacetypeinjection.class.php b/inc/interfacetypeinjection.class.php index 60bd9184..82a6cc36 100644 --- a/inc/interfacetypeinjection.class.php +++ b/inc/interfacetypeinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionInterfaceTypeInjection extends InterfaceType - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * Standard method to add an object into glpi * * @param $values array fields to add into glpi @@ -88,4 +91,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/itilcategoryinjection.class.php b/inc/itilcategoryinjection.class.php index 6f2bd4de..aa46109b 100644 --- a/inc/itilcategoryinjection.class.php +++ b/inc/itilcategoryinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionITILCategoryInjection extends ITILCategory - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -67,15 +70,15 @@ function getOptions($primary_type='') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("dropdown" => array(71, 72, 73), - "bool" => array(3, 74, 75, 76, 86), - "user" => array(70), - "multiline_text" => array(16)); + "bool" => array(3, 74, 75, 76, 86), + "user" => array(70), + "multiline_text" => array(16)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -86,4 +89,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/knowbaseitemcategoryinjection.class.php b/inc/knowbaseitemcategoryinjection.class.php index 9bbf9783..09257db6 100644 --- a/inc/knowbaseitemcategoryinjection.class.php +++ b/inc/knowbaseitemcategoryinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionKnowbaseItemCategoryInjection extends KnowbaseItemCategory - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -43,16 +44,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -70,7 +73,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -81,4 +84,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/knowbaseiteminjection.class.php b/inc/knowbaseiteminjection.class.php index 354cf205..f8354d72 100644 --- a/inc/knowbaseiteminjection.class.php +++ b/inc/knowbaseiteminjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionKnowbaseItemInjection extends KnowbaseItem - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -45,16 +46,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -70,16 +73,16 @@ function getOptions($primary_type='') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("dropdown" => array(4), - "date" => array(5), - "multiline_text" => array(6,7), - "bool" => array(8, 9, 86), - "user" => array(70)); + "date" => array(5), + "multiline_text" => array(6,7), + "bool" => array(8, 9, 86), + "user" => array(70)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -90,4 +93,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/locationinjection.class.php b/inc/locationinjection.class.php index 029bd228..f1a8e2f0 100644 --- a/inc/locationinjection.class.php +++ b/inc/locationinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionLocationInjection extends Location - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() */ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,4 +85,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/manufacturerinjection.class.php b/inc/manufacturerinjection.class.php index cde5bff0..cf859d9e 100644 --- a/inc/manufacturerinjection.class.php +++ b/inc/manufacturerinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionManufacturerInjection extends Manufacturer - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -45,16 +46,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() */ function getOptions($primary_type = '') { @@ -71,7 +74,7 @@ function getOptions($primary_type = '') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,4 +85,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/mapping.class.php b/inc/mapping.class.php index 49d7dfd0..50998c7c 100644 --- a/inc/mapping.class.php +++ b/inc/mapping.class.php @@ -28,11 +28,12 @@ @since 2009 ---------------------------------------------------------------------- */ -class PluginDatainjectionMapping extends CommonDBTM { +class PluginDatainjectionMapping extends CommonDBTM +{ static $rightname = "plugin_datainjection_model"; - /** + /** * @param $field * @param $value **/ @@ -48,42 +49,49 @@ function equal($field,$value) { return false; } - - + + function getMappingName() { + return $this->fields["name"]; } function getRank() { + return $this->fields["rank"]; } function isMandatory() { + return $this->fields["is_mandatory"]; } function getValue() { + return $this->fields["value"]; } function getID() { + return $this->fields["id"]; } function getItemtype() { + return $this->fields["itemtype"]; } - - /** + + /** * @param $model PluginDatainjectionModel object **/ static function showFormMappings(PluginDatainjectionModel $model) { + global $CFG_GLPI; $canedit = $model->can($model->fields['id'], UPDATE); @@ -102,10 +110,10 @@ static function showFormMappings(PluginDatainjectionModel $model) { echo ""; echo ""; } @@ -145,7 +153,7 @@ static function showFormMappings(PluginDatainjectionModel $model) { } - /** + /** * For multitext only ! Check it there's more than one value to inject in a field * * @param $models_id the model ID @@ -153,6 +161,7 @@ static function showFormMappings(PluginDatainjectionModel $model) { * @return true if more than one value to inject, false if not **/ static function getSeveralMappedField($models_id) { + global $DB; $several = array(); @@ -171,22 +180,22 @@ static function getSeveralMappedField($models_id) { } - /** + /** * @param $models_id **/ static function getMappingsSortedByRank($models_id) { - global $DB; - - $mappings = array(); - $query = "SELECT `name` - FROM `glpi_plugin_datainjection_mappings` - WHERE `models_id` = '".$models_id."' - ORDER BY `rank` ASC"; - foreach($DB->request($query) as $data) { - $mappings[] = $data['name']; - } - return $mappings; + + global $DB; + + $mappings = array(); + $query = "SELECT `name` + FROM `glpi_plugin_datainjection_mappings` + WHERE `models_id` = '".$models_id."' + ORDER BY `rank` ASC"; + foreach ($DB->request($query) as $data) { + $mappings[] = $data['name']; + } + return $mappings; } } -?> \ No newline at end of file diff --git a/inc/mappingcollection.class.php b/inc/mappingcollection.class.php index 9ef80293..eddcd3d8 100644 --- a/inc/mappingcollection.class.php +++ b/inc/mappingcollection.class.php @@ -27,24 +27,27 @@ @link http://www.glpi-project.org/ @since 2009 ---------------------------------------------------------------------- */ - -class PluginDatainjectionMappingCollection { + +class PluginDatainjectionMappingCollection +{ private $mappingCollection; function __construct() { + $this->mappingCollection = array(); } - //---- Getter ----// + //---- Getter ----// - /** + /** * Load all the mappings for a specified model * * @param model_ids the model ID **/ function load($models_id) { + global $DB; $sql = "SELECT * @@ -54,7 +57,7 @@ function load($models_id) { $this->mappingCollection = array(); - foreach ($data = $DB->request($sql) as $data) { + foreach ($data = $DB->request($sql) as $data) { // Addslashes to conform to value return by PluginDatainjectionBackendcsv::parseLine $data["name"] = addslashes($data["name"]); $mapping = new PluginDatainjectionMapping(); @@ -64,17 +67,18 @@ function load($models_id) { } - /** + /** * Return all the mappings for this model * * @return the list of all the mappings for this model **/ function getAllMappings() { + return $this->mappingCollection; } - /** + /** * Get a PluginDatainjectionMapping by giving the mapping name * * @param name @@ -82,11 +86,12 @@ function getAllMappings() { * @return the PluginDatainjectionMapping object associated or null **/ function getMappingByName($name) { + return $this->getMappingsByField("name", $name); } - /** + /** * Get a PluginDatainjectionMapping by giving the mapping rank * * @param rank @@ -94,11 +99,12 @@ function getMappingByName($name) { * @return the PluginDatainjectionMapping object associated or null **/ function getMappingByRank($rank) { + return $this->getMappingsByField("rank", $rank); } - /** + /** * Find a mapping by looking for a specific field * * @param field the field to look for @@ -117,9 +123,9 @@ function getMappingsByField($field, $value) { } - //---- Save ----// + //---- Save ----// - /** + /** * Save in database the model and all his associated mappings **/ function saveAllMappings() { @@ -134,39 +140,44 @@ function saveAllMappings() { } - //---- Delete ----// + //---- Delete ----// function deleteMappingsFromDB($model_id) { + $mapping = new PluginDatainjectionMapping(); $mapping->deleteByCriteria(array('models_id' => $model_id)); } - //---- Add ----// + //---- Add ----// - /** + /** * Add a new mapping to this model (don't write in to DB) * * @param mapping the new PluginDatainjectionMapping to add **/ function addNewMapping($mapping) { + $this->mappingCollection[] = $mapping; } - /** + /** * Replace all the mappings for a model + * * @param mappins the array of PluginDatainjectionMapping objects **/ function replaceMappings($mappings) { + $this->mappingCollection = $mappings; } - /** + /** * Check if at least one mapping is defined, and if one mandatory field */ static function checkMappings($models_id) { + } @@ -183,8 +194,8 @@ function getMandatoryMappings() { function getNumberOfMappings() { + return count($this->mappingCollection); } } -?> \ No newline at end of file diff --git a/inc/menu.class.php b/inc/menu.class.php index 3e5697a4..4e5ed328 100644 --- a/inc/menu.class.php +++ b/inc/menu.class.php @@ -27,21 +27,24 @@ @link http://www.glpi-project.org/ @since 2009 ---------------------------------------------------------------------- */ - -class PluginDatainjectionMenu extends CommonGLPI { + +class PluginDatainjectionMenu extends CommonGLPI +{ static $rightname = 'plugin_datainjection_use'; static function getMenuName() { + return __('File injection', 'datainjection'); } static function getMenuContent() { + global $CFG_GLPI; $menu = array(); $menu['title'] = self::getMenuName(); $menu['page'] = '/plugins/datainjection/front/clientinjection.form.php'; - + if (Session::haveRight(static::$rightname, READ)) { $image_model = ""; - $menu['options']['client']['title'] = self::getMenuName(); $menu['options']['client']['page'] = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false); $menu['options']['client']['links']['search'] = '/plugins/datainjection/front/clientinjection.form.php'; diff --git a/inc/model.class.php b/inc/model.class.php index 4a8f18cc..6e44473d 100644 --- a/inc/model.class.php +++ b/inc/model.class.php @@ -28,48 +28,50 @@ @since 2009 ---------------------------------------------------------------------- */ -class PluginDatainjectionModel extends CommonDBTM { +class PluginDatainjectionModel extends CommonDBTM +{ static $rightname = "plugin_datainjection_model"; - - //Store mappings informations + + //Store mappings informations private $mappings; - //Store backend used to collect informations + //Store backend used to collect informations private $backend; - //Store informations related to the model + //Store informations related to the model protected $infos; - //Do history (CommonDBTM) + //Do history (CommonDBTM) public $dohistory = true; - //Store specific backend parameters + //Store specific backend parameters public $specific_model; - //Data to inject + //Data to inject public $injectionData = false; - //Store field of type 'multline_text' several times mapped + //Store field of type 'multline_text' several times mapped public $severaltimes_mapped = array(); - //Private or public model - const MODEL_PRIVATE = 1; - const MODEL_PUBLIC = 0; + //Private or public model + const MODEL_PRIVATE = 1; + const MODEL_PUBLIC = 0; - //Step constants - const INITIAL_STEP = 1; - const FILE_STEP = 2; - const MAPPING_STEP = 3; - const OTHERS_STEP = 4; - const READY_TO_USE_STEP = 5; + //Step constants + const INITIAL_STEP = 1; + const FILE_STEP = 2; + const MAPPING_STEP = 3; + const OTHERS_STEP = 4; + const READY_TO_USE_STEP = 5; - const PROCESS = 0; - const CREATION = 1; + const PROCESS = 0; + const CREATION = 1; static function getTypeName($nb=0) { + return __('Model management', 'datainjection'); } @@ -87,7 +89,8 @@ function canViewItem() { } if (!$this->isPrivate() - && !Session::haveAccessToEntity($this->getEntityID(),$this->isRecursive())) { + && !Session::haveAccessToEntity($this->getEntityID(), $this->isRecursive()) + ) { return false; } @@ -98,12 +101,14 @@ function canViewItem() { function canCreateItem() { if ($this->isPrivate() - && ($this->fields['users_id'] != Session::getLoginUserID())) { + && ($this->fields['users_id'] != Session::getLoginUserID()) + ) { return false; } if (!$this->isPrivate() - && !Session::haveAccessToEntity($this->getEntityID())) { + && !Session::haveAccessToEntity($this->getEntityID()) + ) { return false; } @@ -111,96 +116,114 @@ function canCreateItem() { } - //Loading methods + //Loading methods function loadMappings() { + $this->mappings->load($this->fields['id']); } - //Loading methods + //Loading methods function loadInfos() { + $this->infos->load($this->fields['id']); } - //---- Getters -----// + //---- Getters -----// function getMandatoryMappings() { + return $this->mappings->getMandatoryMappings(); } - //---- Getters -----// + //---- Getters -----// function getMappings() { + return $this->mappings->getAllMappings(); } function getInfos() { + return $this->infos->getAllInfos(); } function getBackend() { + return $this->backend; } function getMappingByName($name) { + return $this->mappings->getMappingByName($name); } function getMappingByRank($rank) { + return $this->mappings->getMappingByRank($rank); } function getFiletype() { + return $this->fields["filetype"]; } function getBehaviorAdd() { + return $this->fields["behavior_add"]; } function getBehaviorUpdate() { + return $this->fields["behavior_update"]; } function getItemtype() { + return $this->fields["itemtype"]; } function getEntity() { + return $this->fields["entities_id"]; } function getCanAddDropdown() { + return $this->fields["can_add_dropdown"]; } function getCanOverwriteIfNotEmpty() { + return $this->fields["can_overwrite_if_not_empty"]; } function getDateFormat() { + return $this->fields["date_format"]; } function getFloatFormat() { + return $this->fields["float_format"]; } function getPortUnicity() { + return $this->fields["port_unicity"]; } @@ -215,30 +238,34 @@ function getNumberOfMappings() { function getSpecificModel() { + return $this->specific_model; } - /** + /** * @param $options array **/ static function dropdown($options=array()) { + global $CFG_GLPI; - $models = self::getModels(Session::getLoginUserID(), 'name', $_SESSION['glpiactive_entity'], - false); + $models = self::getModels( + Session::getLoginUserID(), 'name', $_SESSION['glpiactive_entity'], + false + ); $p = array('models_id' => '__VALUE__'); if (isset($_SESSION['datainjection']['models_id'])) { - $value = $_SESSION['datainjection']['models_id']; + $value = $_SESSION['datainjection']['models_id']; } else { - $value = 0; + $value = 0; } - $rand = mt_rand(); - echo "\n"; + $prev = -2; + echo "\n"; foreach ($models as $model) { if ($model['entities_id'] != $prev) { @@ -249,43 +276,46 @@ static function dropdown($options=array()) { if ($model['entities_id'] == -1) { echo "\n"; } else { - echo "\n"; + echo "\n"; } - $prev = $model['entities_id']; + $prev = $model['entities_id']; } if ($model['id'] == $value) { - $selected = "selected"; + $selected = "selected"; } else { $selected = ""; } if ($model['comment']) { - $comment = "title='".htmlentities($model['comment'], ENT_QUOTES, 'UTF-8')."'"; + $comment = "title='".htmlentities($model['comment'], ENT_QUOTES, 'UTF-8')."'"; } else { - $comment = ""; + $comment = ""; } - echo "\n"; + echo "\n"; } if ($prev >= -1) { echo ""; } - echo ""; + echo ""; - $url = $CFG_GLPI["root_doc"]."/plugins/datainjection/ajax/dropdownSelectModel.php"; - Ajax::updateItemOnSelectEvent("dropdown_models$rand", "span_injection", $url, $p); + $url = $CFG_GLPI["root_doc"]."/plugins/datainjection/ajax/dropdownSelectModel.php"; + Ajax::updateItemOnSelectEvent("dropdown_models$rand", "span_injection", $url, $p); } - /** + /** * @param $user_id * @param $order (default 'name') * @param $entity (default -1) * @param $all (false by default) **/ static function getModels($user_id, $order = "name", $entity = -1, $all = false) { + global $DB; $models = array (); @@ -300,24 +330,27 @@ static function getModels($user_id, $order = "name", $entity = -1, $all = false) } $query .= "(`is_private` = '" . self::MODEL_PUBLIC."'". - getEntitiesRestrictRequest(" AND", "glpi_plugin_datainjection_models", - "entities_id", $entity, true) . ") + getEntitiesRestrictRequest( + " AND", "glpi_plugin_datainjection_models", + "entities_id", $entity, true + ) . ") OR (`is_private` = '" . self::MODEL_PRIVATE."' AND `users_id` = '$user_id')) ORDER BY `is_private` DESC, `entities_id`, " . ($order == "`name`" ? "`name`" : $order); foreach ($DB->request($query) as $data) { if (self::checkRightOnModel($data['id']) - && class_exists($data['itemtype'])) { + && class_exists($data['itemtype']) + ) { $models[] = $data; } } - return $models; + return $models; } - //Standard functions + //Standard functions function getSearchOptions() { $tab = array(); @@ -372,8 +405,10 @@ function getSearchOptions() { $tab[9]['table'] = $this->getTable(); $tab[9]['field'] = 'perform_network_connection'; - $tab[9]['name'] = __('Try to establish network connection is possible', - 'datainjection'); + $tab[9]['name'] = __( + 'Try to establish network connection is possible', + 'datainjection' + ); $tab[9]['datatype'] = 'bool'; $tab[10]['table'] = $this->getTable(); @@ -414,7 +449,7 @@ function getSearchOptions() { } - /** + /** * @since version 2.3.0 * * @param $field @@ -443,7 +478,7 @@ static function getSpecificValueToDisplay($field, $values, array $options=array( } - /** + /** * @since version 2.3.0 * * @param $field @@ -460,23 +495,31 @@ static function getSpecificValueToSelect($field, $name='', $values='', array $op switch ($field) { case 'step': $options['value'] = $values[$field]; - return Dropdown::showFromArray($name, PluginDatainjectionDropdown::statusLabels(), - $options); + return Dropdown::showFromArray( + $name, PluginDatainjectionDropdown::statusLabels(), + $options + ); case 'port_unicity' : $options['value'] = $values[$field]; - return Dropdown::showFromArray($name, PluginDatainjectionDropdown::portUnicityValues(), - $options); + return Dropdown::showFromArray( + $name, PluginDatainjectionDropdown::portUnicityValues(), + $options + ); case 'float_format' : $options['value'] = $values[$field]; - return Dropdown::showFromArray($name, PluginDatainjectionDropdown::floatFormats(), - $options); + return Dropdown::showFromArray( + $name, PluginDatainjectionDropdown::floatFormats(), + $options + ); case 'date_format' : $options['value'] = $values[$field]; - return Dropdown::showFromArray($name, PluginDatainjectionDropdown::dateFormats(), - $options); + return Dropdown::showFromArray( + $name, PluginDatainjectionDropdown::dateFormats(), + $options + ); } return parent::getSpecificValueToSelect($field, $name, $values, $options); @@ -494,7 +537,7 @@ function showForm($ID, $options = array()) { } $this->initForm($ID, $options); - + if ($this->isNewID($ID)) { $this->showAdvancedForm($ID); } @@ -520,11 +563,11 @@ function showAdvancedForm($ID, $options = array()) { echo ""; echo ""; + ""; echo ""; echo ""; + __('Name').""; echo ""; @@ -532,8 +575,10 @@ function showAdvancedForm($ID, $options = array()) { echo ""; echo ""; echo ""; @@ -547,57 +592,63 @@ function showAdvancedForm($ID, $options = array()) { echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - - echo ""; - - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + echo ""; + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; if ($ID > 0) { $tmp = self::getInstance('csv'); @@ -617,7 +668,7 @@ function showValidationForm() { echo ""; echo ""; echo ""; @@ -628,7 +679,7 @@ function showValidationForm() { } - //Tabs management + //Tabs management function defineTabs($options = array()) { $tabs = array(); @@ -638,15 +689,15 @@ function defineTabs($options = array()) { } - //Tabs management + //Tabs management function getTabNameForItem(CommonGLPI $item, $withtemplate=0) { - + $canedit = Session::haveRight('plugin_datainjection_model', UPDATE); - + if (!$withtemplate) { switch ($item->getType()) { case __CLASS__ : - $tabs[1] = __('Model'); + $tabs[1] = __('Model'); if (!$this->isNewID($item->fields['id'])) { if ($canedit) { $tabs[3] = __('File to inject', 'datainjection'); @@ -661,10 +712,10 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate=0) { } } } - return $tabs; + return $tabs; default: - return ''; + return ''; } } } @@ -675,32 +726,32 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtempl if ($item->getType() == __CLASS__) { switch ($tabnum) { case 1 : - $item->showAdvancedForm($item->getID()); - break; + $item->showAdvancedForm($item->getID()); + break; case 3: - $options['confirm'] = 'creation'; - $options['models_id'] = $item->fields['id']; - $options['add_form'] = true; - $options['submit'] = __('Load this file', 'datainjection'); - PluginDatainjectionClientInjection::showUploadFileForm($options); - break; + $options['confirm'] = 'creation'; + $options['models_id'] = $item->fields['id']; + $options['add_form'] = true; + $options['submit'] = __('Load this file', 'datainjection'); + PluginDatainjectionClientInjection::showUploadFileForm($options); + break; case 4 : - PluginDatainjectionMapping::showFormMappings($item); - break; + PluginDatainjectionMapping::showFormMappings($item); + break; case 5: if ($item->fields['step'] > self::MAPPING_STEP) { PluginDatainjectionInfo::showFormInfos($item); } - break; + break; case 6: if ($item->fields['step'] > self::MAPPING_STEP) { $item->showValidationForm(); } - break; + break; } } return true; @@ -710,22 +761,22 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtempl function cleanDBonPurge() { $itemtypes = array("PluginDatainjectionModelcsv", "PluginDatainjectionMapping", - "PluginDatainjectionInfo"); + "PluginDatainjectionInfo"); foreach ($itemtypes as $itemtype) { - $item = new $itemtype(); - $item->deleteByCriteria(array("models_id" => $this->getID())); + $item = new $itemtype(); + $item->deleteByCriteria(array("models_id" => $this->getID())); } } - /** + /** * Clean all model which match some criteria * * @param $crit array of criteria (ex array('itemtype'=>'PluginAppliancesAppliance')) - * **/ static function clean($crit=array()) { + global $DB; $model = new self(); @@ -739,7 +790,7 @@ static function clean($crit=array()) { } - /** + /** * @param $models_id * @param $step **/ @@ -760,14 +811,20 @@ function prepareInputForAdd($input) { //If no behavior selected if (!isset($input['name']) || ($input['name'] == '')) { - Session::addMessageAfterRedirect(__('Please enter a name for the model', 'datainjection'), - true, ERROR, true); + Session::addMessageAfterRedirect( + __('Please enter a name for the model', 'datainjection'), + true, ERROR, true + ); return false; } if (!$input['behavior_add'] && !$input['behavior_update']) { - Session::addMessageAfterRedirect(__('Your model should allow import and/or update of data', - 'datainjection'), true, ERROR, true); + Session::addMessageAfterRedirect( + __( + 'Your model should allow import and/or update of data', + 'datainjection' + ), true, ERROR, true + ); return false; } @@ -788,8 +845,12 @@ function prepareInputForUpdate($input) { $input['is_recursive'] = 1; if (isset($input['users_id']) && ($input['users_id'] != $this->fields['users_id'])) { - Session::addMessageAfterRedirect(__('You are not the initial creator of this model', - 'datainjection'), true, ERROR, true); + Session::addMessageAfterRedirect( + __( + 'You are not the initial creator of this model', + 'datainjection' + ), true, ERROR, true + ); return false; } } @@ -797,7 +858,7 @@ function prepareInputForUpdate($input) { } - /** + /** * Get the backend implementation by type * * @param $type @@ -823,13 +884,13 @@ static function getInstanceByModelID($models_id) { } - /** + /** * @param $options array **/ function readUploadedFile($options=array()) { $file_encoding = (isset($options['file_encoding']) - ?$options['file_encoding'] :PluginDatainjectionBackend::ENCODING_AUTO); + ?$options['file_encoding'] :PluginDatainjectionBackend::ENCODING_AUTO); $webservice = (isset($options['webservice'])?$options['webservice']:false); $original_filename = (isset($options['original_filename'])?$options['original_filename']:false); $unique_filename = (isset($options['unique_filename'])?$options['unique_filename']:false); @@ -844,12 +905,14 @@ function readUploadedFile($options=array()) { //Get and store uploaded file $original_filename = $_FILES['filename']['name']; $temporary_uploaded_filename = stripslashes($_FILES["filename"]["tmp_name"]); - $unique_filename = tempnam (realpath(PLUGIN_DATAINJECTION_UPLOAD_DIR), "PWS"); + $unique_filename = tempnam(realpath(PLUGIN_DATAINJECTION_UPLOAD_DIR), "PWS"); if (!move_uploaded_file($temporary_uploaded_filename, $unique_filename)) { return array('status' => PluginDatainjectionCommonInjectionLib::FAILED, - 'message' => sprintf(__('Impossible to copy the file in %s', 'datainjection'), - realpath(PLUGIN_DATAINJECTION_UPLOAD_DIR))); + 'message' => sprintf( + __('Impossible to copy the file in %s', 'datainjection'), + realpath(PLUGIN_DATAINJECTION_UPLOAD_DIR) + )); } } @@ -862,11 +925,11 @@ function readUploadedFile($options=array()) { } //unlink($temporary_uniquefilename); return array('status' => ERROR, - 'message' => $message); + 'message' => $message); } else { //Initialise a new backend - $backend = PluginDatainjectionBackend::getInstance($this->fields['filetype']); + $backend = PluginDatainjectionBackend::getInstance($this->fields['filetype']); //Init backend with needed values $backend->init($unique_filename, $file_encoding); $backend->setHeaderPresent($this->specific_model->fields['is_header_present']); @@ -895,7 +958,7 @@ function readUploadedFile($options=array()) { } - /** + /** * Load specific model **/ function loadSpecificModel() { @@ -906,7 +969,7 @@ function loadSpecificModel() { } - /** + /** * Once file is uploaded, process it * * @param $options array of possible options: @@ -918,7 +981,7 @@ function loadSpecificModel() { function processUploadedFile($options=array()) { $file_encoding = (isset($options['file_encoding']) - ?$options['file_encoding'] :PluginDatainjectionBackend::ENCODING_AUTO); + ?$options['file_encoding'] :PluginDatainjectionBackend::ENCODING_AUTO); $mode = (isset($options['mode'])?$options['mode']:self::PROCESS); //Get model & model specific fields @@ -928,10 +991,16 @@ function processUploadedFile($options=array()) { if (!isset($options['webservice'])) { return false; } - return PluginWebservicesMethodCommon::Error($options['protocol'], - WEBSERVICES_ERROR_FAILED, - sprintf(__('Not data to import', - 'datainjection'))); + return PluginWebservicesMethodCommon::Error( + $options['protocol'], + WEBSERVICES_ERROR_FAILED, + sprintf( + __( + 'Not data to import', + 'datainjection' + ) + ) + ); } if ($mode == self::PROCESS) { @@ -941,7 +1010,7 @@ function processUploadedFile($options=array()) { } else { $check['status'] = PluginDatainjectionCommonInjectionLib::SUCCESS; } - //There's an error + //There's an error if ($check['status']!= PluginDatainjectionCommonInjectionLib::SUCCESS) { if ($mode == self::PROCESS) { @@ -949,9 +1018,11 @@ function processUploadedFile($options=array()) { Session::addMessageAfterRedirect($check['error_message'], true, ERROR); return false; } - return PluginWebservicesMethodCommon::Error($options['protocol'], - WEBSERVICES_ERROR_FAILED, - $check['error_message']); + return PluginWebservicesMethodCommon::Error( + $options['protocol'], + WEBSERVICES_ERROR_FAILED, + $check['error_message'] + ); } } @@ -965,8 +1036,10 @@ function processUploadedFile($options=array()) { $rank = 0; //Build the mappings list - foreach (PluginDatainjectionBackend::getHeader($this->injectionData, - $this->specific_model->isHeaderPresent()) as $data) { + foreach (PluginDatainjectionBackend::getHeader( + $this->injectionData, + $this->specific_model->isHeaderPresent() + ) as $data) { $mapping = new PluginDatainjectionMapping; $mapping->fields['models_id'] = $this->fields['id']; $mapping->fields['rank'] = $rank; @@ -990,7 +1063,7 @@ function processUploadedFile($options=array()) { } - /** + /** * Try to parse an input file * * @return true if the file is a CSV file @@ -1000,45 +1073,57 @@ function isFileCorrect() { $field_in_error = false; //Get CSV file first line - $header = PluginDatainjectionBackend::getHeader($this->injectionData, - $this->specific_model->isHeaderPresent()); + $header = PluginDatainjectionBackend::getHeader( + $this->injectionData, + $this->specific_model->isHeaderPresent() + ); //If file columns don't match number of mappings in DB $nb = count($this->getMappings()); if ($nb != count($header)) { - $error_message = __('The number of columns of the file is incorrect.', 'datainjection')."\n"; - $error_message .= sprintf(_n('%d awaited column', '%d awaited columns', $nb, 'datainjection'), - $nb)."\n"; - $error_message .= sprintf(_n('%d found column', '%d found columns', count($header), - 'datainjection'), - count($header)); - - return array('status' => PluginDatainjectionCommonInjectionLib::FAILED, - 'field_in_error' => false, - 'error_message' => $error_message); + $error_message = __('The number of columns of the file is incorrect.', 'datainjection')."\n"; + $error_message .= sprintf( + _n('%d awaited column', '%d awaited columns', $nb, 'datainjection'), + $nb + )."\n"; + $error_message .= sprintf( + _n( + '%d found column', '%d found columns', count($header), + 'datainjection' + ), + count($header) + ); + + return array('status' => PluginDatainjectionCommonInjectionLib::FAILED, + 'field_in_error' => false, + 'error_message' => $error_message); } - //If no header in the CSV file, exit method + //If no header in the CSV file, exit method if (!$this->specific_model->isHeaderPresent()) { - return array('status' => PluginDatainjectionCommonInjectionLib::SUCCESS, - 'field_in_error' => false, - 'error_message' => ''); + return array('status' => PluginDatainjectionCommonInjectionLib::SUCCESS, + 'field_in_error' => false, + 'error_message' => ''); } - $error = array('status' => PluginDatainjectionCommonInjectionLib::SUCCESS, - 'field_in_error' => false, - 'error_message' => ''); + $error = array('status' => PluginDatainjectionCommonInjectionLib::SUCCESS, + 'field_in_error' => false, + 'error_message' => ''); - //Check each mapping to be sure it has exactly the same name - foreach($this->getMappings() as $key => $mapping) { + //Check each mapping to be sure it has exactly the same name + foreach ($this->getMappings() as $key => $mapping) { if (!isset($header[$key])) { $error['status'] = PluginDatainjectionCommonInjectionLib::FAILED; $error['field_in_error'] = $key; } else { //If name of the mapping is not equal in the csv file header and in the DB - $name_from_file = trim(mb_strtoupper(stripslashes($header[$mapping->getRank()]) , - 'UTF-8')); + $name_from_file = trim( + mb_strtoupper( + stripslashes($header[$mapping->getRank()]), + 'UTF-8' + ) + ); $name_from_db = trim(mb_strtoupper(stripslashes($mapping->getName()), 'UTF-8')); if ($name_from_db != $name_from_file) { @@ -1046,23 +1131,27 @@ function isFileCorrect() { $error['error_message'] = __('At least one column is incorrect', 'datainjection'); } - $error['status'] = PluginDatainjectionCommonInjectionLib::FAILED; - $error['field_in_error'] = false; - - $error['error_message'] .= "
    ".sprintf(__('%1$s: %2$s'), - __('Into the file', 'datainjection'), - $name_from_file)."\n"; - $error['error_message'] .=sprintf(__('%1$s: %2$s'), - __('From the model', 'datainjection'), - $name_from_db); + $error['status'] = PluginDatainjectionCommonInjectionLib::FAILED; + $error['field_in_error'] = false; + + $error['error_message'] .= "
    ".sprintf( + __('%1$s: %2$s'), + __('Into the file', 'datainjection'), + $name_from_file + )."\n"; + $error['error_message'] .=sprintf( + __('%1$s: %2$s'), + __('From the model', 'datainjection'), + $name_from_db + ); } } } - return $error; + return $error; } - /** + /** * @param $fields **/ function checkMandatoryFields($fields) { @@ -1081,7 +1170,8 @@ function checkMandatoryFields($fields) { if (!isset($fields[$info->getValue()]) //Check if no value defined only when it's not a yes/no || ($tocheck && !$fields[$info->getValue()]) - || ($fields[$info->getValue()] == 'NULL')) { + || ($fields[$info->getValue()] == 'NULL') + ) { $check = false; break; } @@ -1091,7 +1181,7 @@ function checkMandatoryFields($fields) { } - /** + /** * Model is now ready to be used **/ function switchReadyToUse() { @@ -1105,14 +1195,15 @@ function switchReadyToUse() { function populateSeveraltimesMappedFields() { $this->severaltimes_mapped - = PluginDatainjectionMapping::getSeveralMappedField($this->fields['id']); + = PluginDatainjectionMapping::getSeveralMappedField($this->fields['id']); } - /** + /** * @param $models_id **/ static function checkRightOnModel($models_id) { + global $DB; $model = new self(); @@ -1154,7 +1245,7 @@ static function cleanSessionVariables() { } - /** + /** * @param $models_id **/ static function showPreviewMappings($models_id) { @@ -1173,7 +1264,7 @@ static function showPreviewMappings($models_id) { $nbmappings = count($mappings); echo ""; - foreach($mappings as $mapping) { + foreach ($mappings as $mapping) { echo""; } echo ""; @@ -1195,13 +1286,17 @@ static function showPreviewMappings($models_id) { } - /** + /** * @param $models_id **/ static function prepareLogResults($models_id) { - $results = Toolbox::stripslashes_deep(json_decode(PluginDatainjectionSession::getParam('results'), - true)); + $results = Toolbox::stripslashes_deep( + json_decode( + PluginDatainjectionSession::getParam('results'), + true + ) + ); $todisplay = array(); $model = new self(); $model->getFromDB($models_id); @@ -1209,59 +1304,61 @@ static function prepareLogResults($models_id) { if (!empty($results)) { foreach ($results as $result) { $tmp = array('line' => $result['line'], - 'status' => $result['status'], - 'check_sumnary' => PluginDatainjectionCommonInjectionLib::getLogLabel(PluginDatainjectionCommonInjectionLib::SUCCESS), - 'check_message' => PluginDatainjectionCommonInjectionLib::getLogLabel(PluginDatainjectionCommonInjectionLib::SUCCESS), - 'type' => __('Undetermined', 'datainjection'), - 'status_message' => PluginDatainjectionCommonInjectionLib::getLogLabel($result['status']), - 'itemtype' => $model->fields['itemtype'], - 'url' => '', - 'item' => ''); + 'status' => $result['status'], + 'check_sumnary' => PluginDatainjectionCommonInjectionLib::getLogLabel(PluginDatainjectionCommonInjectionLib::SUCCESS), + 'check_message' => PluginDatainjectionCommonInjectionLib::getLogLabel(PluginDatainjectionCommonInjectionLib::SUCCESS), + 'type' => __('Undetermined', 'datainjection'), + 'status_message' => PluginDatainjectionCommonInjectionLib::getLogLabel($result['status']), + 'itemtype' => $model->fields['itemtype'], + 'url' => '', + 'item' => ''); if (isset($result[PluginDatainjectionCommonInjectionLib::ACTION_CHECK])) { - $check_infos = $result[PluginDatainjectionCommonInjectionLib::ACTION_CHECK]; - $tmp['check_status'] = $check_infos['status']; - $tmp['check_sumnary'] = PluginDatainjectionCommonInjectionLib::getLogLabel($check_infos['status']); - $tmp['check_message'] = ''; - $first = true; + $check_infos = $result[PluginDatainjectionCommonInjectionLib::ACTION_CHECK]; + $tmp['check_status'] = $check_infos['status']; + $tmp['check_sumnary'] = PluginDatainjectionCommonInjectionLib::getLogLabel($check_infos['status']); + $tmp['check_message'] = ''; + $first = true; - foreach($check_infos as $key => $val) { + foreach ($check_infos as $key => $val) { if (($key !== 'status') - && ($val[0] != PluginDatainjectionCommonInjectionLib::SUCCESS)) { + && ($val[0] != PluginDatainjectionCommonInjectionLib::SUCCESS) + ) { $tmp['check_message'] .= ($first ? '' : "\n"). - sprintf(__('%1$s (%2$s)'), - PluginDatainjectionCommonInjectionLib::getLogLabel($val[0]), - $val[1]); + sprintf( + __('%1$s (%2$s)'), + PluginDatainjectionCommonInjectionLib::getLogLabel($val[0]), + $val[1] + ); $first = false; } } } - //Store the action type (add/update) + //Store the action type (add/update) if (isset($result['type'])) { - $tmp['type'] = PluginDatainjectionCommonInjectionLib::getActionLabel($result['type']); + $tmp['type'] = PluginDatainjectionCommonInjectionLib::getActionLabel($result['type']); } - if (isset($result[$model->fields['itemtype']])) { - $tmp['item'] = $result[$model->fields['itemtype']]; - $url = Toolbox::getItemTypeFormURL($model->fields['itemtype'])."?id=". - $result[$model->fields['itemtype']]; - $tmp['url'] = "".$result[$model->fields['itemtype']].""; + $tmp['item'] = $result[$model->fields['itemtype']]; + $url = Toolbox::getItemTypeFormURL($model->fields['itemtype'])."?id=". + $result[$model->fields['itemtype']]; + $tmp['url'] = "".$result[$model->fields['itemtype']].""; } if ($result['status'] == PluginDatainjectionCommonInjectionLib::SUCCESS) { - $todisplay[PluginDatainjectionCommonInjectionLib::SUCCESS][] = $tmp; + $todisplay[PluginDatainjectionCommonInjectionLib::SUCCESS][] = $tmp; } else { $todisplay[PluginDatainjectionCommonInjectionLib::FAILED][] = $tmp; } } } - return $todisplay; + return $todisplay; } - /** + /** * @param $models_id **/ static function showLogResults($models_id) { @@ -1275,7 +1372,7 @@ static function showLogResults($models_id) { echo "plus"; echo ""; echo ""; + __('Array of successful injections', 'datainjection').""; echo "\n"; echo "
    "; $url = $CFG_GLPI["root_doc"]. - "/plugins/datainjection/front/popup.php?popup=preview&models_id=". - $model->getID(); + "/plugins/datainjection/front/popup.php?popup=preview&models_id=". + $model->getID(); echo ""; + "'height=400, width=600, top=100, left=100, scrollbars=yes' );w.focus();\"/>"; echo __('See the file', 'datainjection').""; echo "
    ".self::getTypeName()."".PluginDatainjectionDropdown::getStatusLabel($this->fields['step']). - "
    ". - __('Name').""; Html::autocompletionTextField($this, "name"); echo "
    "; - Dropdown::showPrivatePublicSwitch($this->fields["is_private"], $this->fields["entities_id"], - $this->fields["is_recursive"]); + Dropdown::showPrivatePublicSwitch( + $this->fields["is_private"], $this->fields["entities_id"], + $this->fields["is_recursive"] + ); echo "
    "; if (($this->fields['step'] == '') || ($this->fields['step'] == self::INITIAL_STEP)) { - //Get only the primary types - PluginDatainjectionInjectionType::dropdown($this->fields['itemtype'], true); + //Get only the primary types + PluginDatainjectionInjectionType::dropdown($this->fields['itemtype'], true); } else { - $itemtype = new $this->fields['itemtype']; - echo $itemtype->getTypeName(); + $itemtype = new $this->fields['itemtype']; + echo $itemtype->getTypeName(); } - echo "
    ".__('Allow lines creation', 'datainjection').""; - Dropdown::showYesNo("behavior_add", $this->fields['behavior_add']); - echo "".__('Allow lines update', 'datainjection').""; - Dropdown::showYesNo("behavior_update", $this->fields['behavior_update']); - echo "
    ".__('Advanced options', 'datainjection'). - "
    ".__('Allow creation of dropdowns', 'datainjection').""; - Dropdown::showYesNo("can_add_dropdown", $this->fields['can_add_dropdown']); - echo "".__('Dates format', 'datainjection').""; - Dropdown::showFromArray('date_format', PluginDatainjectionDropdown::dateFormats(), - array('value' => $this->fields['date_format'])); - echo "
    ".__('Allow update of existing fields', 'datainjection').""; - Dropdown::showYesNo("can_overwrite_if_not_empty", $this->fields['can_overwrite_if_not_empty']); - echo "".__('Float format', 'datainjection').""; - Dropdown::showFromArray('float_format', PluginDatainjectionDropdown::floatFormats(), - array('value' => $this->fields['float_format'])); - echo "
    ".__('Try to establish network connection is possible', 'datainjection').""; - Dropdown::showYesNo("perform_network_connection", $this->fields['perform_network_connection']); - echo "".__('Port unicity criteria', 'datainjection').""; - Dropdown::showFromArray('port_unicity', PluginDatainjectionDropdown::portUnicityValues(), - array('value' => $this->fields['port_unicity'])); - echo "
    ".__('Allow lines creation', 'datainjection').""; + Dropdown::showYesNo("behavior_add", $this->fields['behavior_add']); + echo "".__('Allow lines update', 'datainjection').""; + Dropdown::showYesNo("behavior_update", $this->fields['behavior_update']); + echo "
    ".__('Advanced options', 'datainjection'). + "
    ".__('Allow creation of dropdowns', 'datainjection').""; + Dropdown::showYesNo("can_add_dropdown", $this->fields['can_add_dropdown']); + echo "".__('Dates format', 'datainjection').""; + Dropdown::showFromArray( + 'date_format', PluginDatainjectionDropdown::dateFormats(), + array('value' => $this->fields['date_format']) + ); + echo "
    ".__('Allow update of existing fields', 'datainjection').""; + Dropdown::showYesNo("can_overwrite_if_not_empty", $this->fields['can_overwrite_if_not_empty']); + echo "".__('Float format', 'datainjection').""; + Dropdown::showFromArray( + 'float_format', PluginDatainjectionDropdown::floatFormats(), + array('value' => $this->fields['float_format']) + ); + echo "
    ".__('Try to establish network connection is possible', 'datainjection').""; + Dropdown::showYesNo("perform_network_connection", $this->fields['perform_network_connection']); + echo "".__('Port unicity criteria', 'datainjection').""; + Dropdown::showFromArray( + 'port_unicity', PluginDatainjectionDropdown::portUnicityValues(), + array('value' => $this->fields['port_unicity']) + ); + echo "
    "; echo ""; + _sx('button', 'Validate the model', 'datainjection')."'>"; echo ""; echo "
    ".stripslashes($mapping->getMappingName())."
    ". - __('Array of successful injections', 'datainjection')."
    \n"; @@ -1305,7 +1402,7 @@ static function showLogResults($models_id) { echo "minus"; echo ""; echo "". - __('Array of unsuccessful injections', 'datainjection').""; + __('Array of unsuccessful injections', 'datainjection').""; echo "\n"; echo "\n"; @@ -1346,63 +1443,73 @@ static function exportAsPDF($models_id) { if (!empty($logresults)) { $pdf = new PluginPdfSimplePDF('a4', 'landscape'); - $pdf->setHeader(sprintf(__('%1$s (%2$s)'), - __('File injection report', 'datainjection') . ' - ' . - PluginDatainjectionSession::getParam('file_name') . '', - $model->getName())); + $pdf->setHeader( + sprintf( + __('%1$s (%2$s)'), + __('File injection report', 'datainjection') . ' - ' . + PluginDatainjectionSession::getParam('file_name') . '', + $model->getName() + ) + ); $pdf->newPage(); if (isset($logresults[PluginDatainjectionCommonInjectionLib::SUCCESS])) { - $pdf->setColumnsSize(100); - $pdf->displayTitle(''.__('Array of successful injections', 'datainjection').''); - $pdf->setColumnsSize(6,54,20,20); - $pdf->setColumnsAlign('center','center','center','center'); - $col0 = ''.__('Line', 'datainjection').''; - $col1 = ''.__('Data Import', 'datainjection').''; - $col2 = ''.__('Injection type', 'datainjection').''; - $col3 = ''.__('Object Identifier', 'datainjection').''; - $pdf->displayTitle($col0, $col1, $col2, $col3); - - $index = 0; + $pdf->setColumnsSize(100); + $pdf->displayTitle(''.__('Array of successful injections', 'datainjection').''); + $pdf->setColumnsSize(6, 54, 20, 20); + $pdf->setColumnsAlign('center', 'center', 'center', 'center'); + $col0 = ''.__('Line', 'datainjection').''; + $col1 = ''.__('Data Import', 'datainjection').''; + $col2 = ''.__('Injection type', 'datainjection').''; + $col3 = ''.__('Object Identifier', 'datainjection').''; + $pdf->displayTitle($col0, $col1, $col2, $col3); + + $index = 0; foreach ($logresults[PluginDatainjectionCommonInjectionLib::SUCCESS] as $result) { - $pdf->displayLine($result['line'], $result['status_message'], $result['type'], - $result['item']); + $pdf->displayLine( + $result['line'], $result['status_message'], $result['type'], + $result['item'] + ); } } if (isset($logresults[PluginDatainjectionCommonInjectionLib::FAILED])) { - $pdf->setColumnsSize(100); - $pdf->displayTitle(''.__('Array of unsuccessful injections', 'datainjection').''); - $pdf->setColumnsSize(6, 16, 38, 20, 20); - $pdf->setColumnsAlign('center','center','center','center','center'); - $col0 = ''.__('Line', 'datainjection').''; - $col1 = ''.__('Data check', 'datainjection').''; - $col2 = ''.__('Data Import', 'datainjection').''; - $col3 = ''.__('Injection type', 'datainjection').''; - $col4 = ''.__('Object Identifier', 'datainjection').''; - $pdf->displayTitle($col0, $col1, $col2, $col3, $col4); - - $index = 0; + $pdf->setColumnsSize(100); + $pdf->displayTitle(''.__('Array of unsuccessful injections', 'datainjection').''); + $pdf->setColumnsSize(6, 16, 38, 20, 20); + $pdf->setColumnsAlign('center', 'center', 'center', 'center', 'center'); + $col0 = ''.__('Line', 'datainjection').''; + $col1 = ''.__('Data check', 'datainjection').''; + $col2 = ''.__('Data Import', 'datainjection').''; + $col3 = ''.__('Injection type', 'datainjection').''; + $col4 = ''.__('Object Identifier', 'datainjection').''; + $pdf->displayTitle($col0, $col1, $col2, $col3, $col4); + + $index = 0; foreach ($logresults[PluginDatainjectionCommonInjectionLib::FAILED] as $result) { $pdf->setColumnsSize(6, 16, 38, 20, 20); $pdf->setColumnsAlign('center', 'center', 'center', 'center', 'center'); - $pdf->displayLine($result['line'], $result['check_sumnary'], - $result['status_message'], $result['type'], $result['item']); + $pdf->displayLine( + $result['line'], $result['check_sumnary'], + $result['status_message'], $result['type'], $result['item'] + ); if ($result['check_message']) { - $pdf->displayText(''.__('Data check', 'datainjection').' :', - $result['check_message'],1); + $pdf->displayText( + ''.__('Data check', 'datainjection').' :', + $result['check_message'], 1 + ); } } } - $pdf->render(); + $pdf->render(); } } function cleanData() { + $this->injectionData = array(); } } -?> diff --git a/inc/modelcsv.class.php b/inc/modelcsv.class.php index 23859bfe..364330bb 100644 --- a/inc/modelcsv.class.php +++ b/inc/modelcsv.class.php @@ -28,12 +28,13 @@ @since 2009 ---------------------------------------------------------------------- */ -class PluginDatainjectionModelcsv extends CommonDBChild { +class PluginDatainjectionModelcsv extends CommonDBChild +{ static $rightname = "plugin_datainjection_model"; - var $specific_fields; + var $specific_fields; - // From CommonDBChild + // From CommonDBChild static public $itemtype = 'PluginDatainjectionModel'; static public $items_id = 'models_id'; public $dohistory = true; @@ -46,30 +47,34 @@ function getEmpty() { } function init() { + } - //---- Getters -----// + //---- Getters -----// function getDelimiter() { + return $this->fields["delimiter"]; } function isHeaderPresent() { + return $this->fields["is_header_present"]; } - /** + /** * If a Sample could be generated **/ function haveSample() { + return $this->fields["is_header_present"]; } - /** + /** * Display Sample * * @param $model PluginDatainjectionModel object @@ -79,8 +84,12 @@ function showSample(PluginDatainjectionModel $model) { $headers = PluginDatainjectionMapping::getMappingsSortedByRank($model->fields['id']); $sample = '"'.implode('"'.$this->getDelimiter().'"', $headers)."\"\n"; - header('Content-disposition: attachment; filename="'.str_replace(' ', '_', - $model->getName()).'.csv"'); + header( + 'Content-disposition: attachment; filename="'.str_replace( + ' ', '_', + $model->getName() + ).'.csv"' + ); header('Content-Type: text/comma-separated-values'); header('Content-Transfer-Encoding: UTF-8'); header('Content-Length: '.mb_strlen($sample, 'UTF-8')); @@ -91,7 +100,7 @@ function showSample(PluginDatainjectionModel $model) { } - /** + /** * Check if filename ends with .csv * * @param $filename the filename @@ -99,11 +108,12 @@ function showSample(PluginDatainjectionModel $model) { * @return boolean true if name is correct, false is not **/ function checkFileName($filename) { + return ( !strstr(strtolower(substr($filename, strlen($filename)-4)), '.csv')); } - /** + /** * Get CSV's specific ID for a model * If row doesn't exists, it creates it * @@ -112,6 +122,7 @@ function checkFileName($filename) { * @return the ID of the row in glpi_plugin_datainjection_modelcsv **/ function getFromDBByModelID($models_id) { + global $DB; $query = "SELECT `id` @@ -137,7 +148,7 @@ function getFromDBByModelID($models_id) { } - /** + /** * @param $model PluginDatainjectionModel object * @param $options array **/ @@ -160,7 +171,7 @@ function showAdditionnalForm(PluginDatainjectionModel $model, $options=array()) } - /** + /** * @param $fields **/ function saveFields($fields) { @@ -175,4 +186,3 @@ function saveFields($fields) { } } -?> \ No newline at end of file diff --git a/inc/monitorinjection.class.php b/inc/monitorinjection.class.php index c335060a..f0a53622 100644 --- a/inc/monitorinjection.class.php +++ b/inc/monitorinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionMonitorInjection extends Monitor - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array('Computer', 'Document'); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -70,16 +73,16 @@ function getOptions($primary_type='') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("dropdown" => array(3, 4, 23, 31, 40, 49, 46, 71), - "user" => array(24, 70), - "float" => array(11), - "bool" => array(41, 42, 43, 44, 45, 46, 47, 48), - "multiline_text" => array(16, 90)); + "user" => array(24, 70), + "float" => array(11), + "bool" => array(41, 42, 43, 44, 45, 46, 47, 48), + "multiline_text" => array(16, 90)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -90,7 +93,7 @@ function addOrUpdateObject($values=array(), $options=array()) { } - /** + /** * @param $primary_type * @param $values **/ @@ -108,4 +111,3 @@ function addSpecificNeededFields($primary_type,$values) { } } -?> diff --git a/inc/monitormodelinjection.class.php b/inc/monitormodelinjection.class.php index 522ccf18..96e66fb7 100644 --- a/inc/monitormodelinjection.class.php +++ b/inc/monitormodelinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionMonitorModelInjection extends MonitorModel - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,4 +85,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/monitortypeinjection.class.php b/inc/monitortypeinjection.class.php index a4e55ece..de24f96f 100644 --- a/inc/monitortypeinjection.class.php +++ b/inc/monitortypeinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionMonitorTypeInjection extends MonitorType - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,4 +85,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/netpointinjection.class.php b/inc/netpointinjection.class.php index 8647c5e2..d4d1ef3c 100644 --- a/inc/netpointinjection.class.php +++ b/inc/netpointinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionNetpointInjection extends Netpoint - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array('Computer', 'NetworkEquipment', 'Peripheral', 'Phone'); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -70,13 +73,13 @@ function getOptions($primary_type='') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("dropdown" => array(3), - "multiline_text" => array(16)); + "multiline_text" => array(16)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -87,7 +90,7 @@ function addOrUpdateObject($values=array(), $options=array()) { } - /** + /** * @param $primary_type * @param $values **/ @@ -107,4 +110,3 @@ function addSpecificNeededFields($primary_type, $values) { } } -?> \ No newline at end of file diff --git a/inc/networkequipmentfirmwareinjection.class.php b/inc/networkequipmentfirmwareinjection.class.php index 2c4b0e10..116a2b08 100644 --- a/inc/networkequipmentfirmwareinjection.class.php +++ b/inc/networkequipmentfirmwareinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionNetworkEquipmentFirmwareInjection extends NetworkEquipmentFirmware - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,4 +85,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/networkequipmentinjection.class.php b/inc/networkequipmentinjection.class.php index 046dbda6..492f0469 100644 --- a/inc/networkequipmentinjection.class.php +++ b/inc/networkequipmentinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionNetworkEquipmentInjection extends NetworkEquipment - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -79,16 +82,16 @@ function getOptions($primary_type='') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("dropdown" => array(3, 4, 11, 23, 31, 32, 33, - 40, 49, 71), - "bool" => array(86), - "user" => array(24, 70), - "multiline_text" => array(16, 90)); + 40, 49, 71), + "bool" => array(86), + "user" => array(24, 70), + "multiline_text" => array(16, 90)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -99,7 +102,7 @@ function addOrUpdateObject($values=array(), $options=array()) { } - /** + /** * @param $values * @param $add (true by default) * @param $rights array @@ -107,7 +110,7 @@ function addOrUpdateObject($values=array(), $options=array()) { function processAfterInsertOrUpdate($values, $add=true, $rights=array()) { if (isset($values['NetworkEquipment']['nb_ports'])) { - for ($i=1 ; $i<=$values['NetworkEquipment']['nb_ports'] ; $i++) { + for ($i=1; $i<=$values['NetworkEquipment']['nb_ports']; $i++) { $input = array(); $netport = new NetworkPort(); $add = ""; @@ -127,4 +130,3 @@ function processAfterInsertOrUpdate($values, $add=true, $rights=array()) { } } -?> \ No newline at end of file diff --git a/inc/networkequipmentmodelinjection.class.php b/inc/networkequipmentmodelinjection.class.php index ee0bc5c1..66d84b1e 100644 --- a/inc/networkequipmentmodelinjection.class.php +++ b/inc/networkequipmentmodelinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionNetworkEquipmentModelInjection extends NetworkEquipmentModel - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,4 +85,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/networkequipmenttypeinjection.class.php b/inc/networkequipmenttypeinjection.class.php index 15fd7009..4b852054 100644 --- a/inc/networkequipmenttypeinjection.class.php +++ b/inc/networkequipmenttypeinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionNetworkequipmentTypeInjection extends NetworkEquipmentType - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,4 +85,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/networkinjection.class.php b/inc/networkinjection.class.php index ac4cd18c..9be19ffb 100644 --- a/inc/networkinjection.class.php +++ b/inc/networkinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionNetworkInjection extends Network - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -43,16 +44,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -70,7 +73,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -81,4 +84,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/networkinterfaceinjection.class.php b/inc/networkinterfaceinjection.class.php index fb7bf9d6..a2dcb789 100644 --- a/inc/networkinterfaceinjection.class.php +++ b/inc/networkinterfaceinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionNetworkInterfaceInjection extends NetworkInterface - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,4 +85,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/networknameinjection.class.php b/inc/networknameinjection.class.php index 2479a5d7..4f5ce30b 100644 --- a/inc/networknameinjection.class.php +++ b/inc/networknameinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionNetworkNameInjection extends NetworkName - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,17 +45,19 @@ static function getTable() { function isPrimaryType() { + return false; } function connectedTo() { + global $CFG_GLPI; return $CFG_GLPI["networkport_types"]; } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -72,7 +75,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -83,7 +86,7 @@ function addOrUpdateObject($values=array(), $options=array()) { } - /** + /** * @param $primary_type * @param $values **/ @@ -96,20 +99,23 @@ function addSpecificNeededFields($primary_type,$values) { } - /** + /** * @param $values * @param $add (true by default) * @param $rights array */ function processAfterInsertOrUpdate($values, $add=true, $rights=array()) { + global $DB; //Manage ip adresses if (isset($values['NetworkName']['ipaddresses_id'])) { - if (!countElementsInTable("glpi_ipaddresses", - "`items_id`='".$values['NetworkName']['id']."' + if (!countElementsInTable( + "glpi_ipaddresses", + "`items_id`='".$values['NetworkName']['id']."' AND `itemtype`='NetworkName' - AND `name`='".$values['NetworkName']['ipaddresses_id']."'")) { + AND `name`='".$values['NetworkName']['ipaddresses_id']."'" + )) { $ip = new IPAddress(); $tmp['items_id'] = $values['NetworkName']['id']; @@ -122,4 +128,3 @@ function processAfterInsertOrUpdate($values, $add=true, $rights=array()) { } } -?> \ No newline at end of file diff --git a/inc/networkport_vlaninjection.class.php b/inc/networkport_vlaninjection.class.php index 1beaa8a8..77de693b 100644 --- a/inc/networkport_vlaninjection.class.php +++ b/inc/networkport_vlaninjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionNetworkport_VlanInjection extends NetworkPort_Vlan - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return false; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,7 +85,7 @@ function addOrUpdateObject($values=array(), $options=array()) { } - /** + /** * @param $primary_type * @param $values **/ @@ -93,4 +96,3 @@ function addSpecificNeededFields($primary_type,$values) { } } -?> \ No newline at end of file diff --git a/inc/networkportinjection.class.php b/inc/networkportinjection.class.php index 0d3b3012..56843e93 100644 --- a/inc/networkportinjection.class.php +++ b/inc/networkportinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionNetworkportInjection extends NetworkPort - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,18 +45,20 @@ static function getTable() { function isPrimaryType() { + return false; } function connectedTo() { + global $CFG_GLPI; return $CFG_GLPI["networkport_types"]; } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -81,8 +84,10 @@ function getOptions($primary_type='') { $tab[52]['displaytype'] = 'text'; $tab[52]['checktype'] = 'text'; - $tab[53]['name'] = sprintf(__('%1$s: %2$s'), __('Connected to'), - __('Port MAC address', 'datainjection')); + $tab[53]['name'] = sprintf( + __('%1$s: %2$s'), __('Connected to'), + __('Port MAC address', 'datainjection') + ); $tab[53]['field'] = 'netmac'; $tab[53]['table'] = getTableForItemType('NetworkPort'); $tab[53]['linkfield'] = "netmac"; @@ -105,14 +110,14 @@ function getOptions($primary_type='') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("dropdown" => array(9), - "multiline_text" => array(16), - "instantiation_type" => array(87)); + "multiline_text" => array(16), + "instantiation_type" => array(87)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @param $primary_type * @param $values **/ @@ -127,7 +132,7 @@ function addSpecificNeededFields($primary_type,$values) { } - /** + /** * @param $info array * @param $option array **/ @@ -144,8 +149,10 @@ function showAdditionalInformation($info=array(), $option=array()) { $instantiations[$inst_type] = call_user_func(array($inst_type, 'getTypeName')); } } - Dropdown::showFromArray('instantiation_type', $instantiations, - array('value' => 'NetworkPortEthernet')); + Dropdown::showFromArray( + 'instantiation_type', $instantiations, + array('value' => 'NetworkPortEthernet') + ); break; default: @@ -154,7 +161,7 @@ function showAdditionalInformation($info=array(), $option=array()) { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -165,16 +172,17 @@ function addOrUpdateObject($values=array(), $options=array()) { } - /** + /** * @param $fields_toinject array * @param $options array **/ function checkPresent($fields_toinject=array(), $options=array()) { + return $this->getUnicityRequest($fields_toinject['NetworkPort'], $options['checks']); } - /** + /** * @param $fields_toinject * @param $options **/ @@ -210,7 +218,8 @@ function checkParameters($fields_toinject, $options) { $check_status = true; foreach ($fields_tocheck as $field) { if (!isset($fields_toinject[$field]) - || ($fields_toinject[$field] == PluginDatainjectionCommonInjectionLib::EMPTY_VALUE)) { + || ($fields_toinject[$field] == PluginDatainjectionCommonInjectionLib::EMPTY_VALUE) + ) { $check_status = false; } } @@ -219,7 +228,7 @@ function checkParameters($fields_toinject, $options) { } - /** + /** * Build where sql request to look for a network port * * @param $fields_toinject array the fields to insert into DB @@ -233,41 +242,41 @@ function getUnicityRequest($fields_toinject=array(), $options=array()) { switch ($options['port_unicity']) { case PluginDatainjectionCommonInjectionLib::UNICITY_NETPORT_LOGICAL_NUMBER : - $where .= " AND `logical_number` = '".(isset ($fields_toinject["logical_number"]) - ? $fields_toinject["logical_number"] : '')."'"; + $where .= " AND `logical_number` = '".(isset($fields_toinject["logical_number"]) + ? $fields_toinject["logical_number"] : '')."'"; break; case PluginDatainjectionCommonInjectionLib::UNICITY_NETPORT_LOGICAL_NUMBER_MAC : - $where .= " AND `logical_number` = '".(isset ($fields_toinject["logical_number"]) - ? $fields_toinject["logical_number"] : '')."' - AND `mac` = '".(isset ($fields_toinject["mac"]) - ? $fields_toinject["mac"] : '')."'"; + $where .= " AND `logical_number` = '".(isset($fields_toinject["logical_number"]) + ? $fields_toinject["logical_number"] : '')."' + AND `mac` = '".(isset($fields_toinject["mac"]) + ? $fields_toinject["mac"] : '')."'"; break; case PluginDatainjectionCommonInjectionLib::UNICITY_NETPORT_LOGICAL_NUMBER_NAME : - $where .= " AND `logical_number` = '".(isset ($fields_toinject["logical_number"]) - ? $fields_toinject["logical_number"] : '')."' - AND `name` = '".(isset ($fields_toinject["name"]) - ? $fields_toinject["name"] : '')."'"; + $where .= " AND `logical_number` = '".(isset($fields_toinject["logical_number"]) + ? $fields_toinject["logical_number"] : '')."' + AND `name` = '".(isset($fields_toinject["name"]) + ? $fields_toinject["name"] : '')."'"; break; case PluginDatainjectionCommonInjectionLib::UNICITY_NETPORT_LOGICAL_NUMBER_NAME_MAC : - $where .= " AND `logical_number` = '".(isset ($fields_toinject["logical_number"]) - ? $fields_toinject["logical_number"] : '')."' - AND `name` = '".(isset ($fields_toinject["name"]) - ? $fields_toinject["name"] : '')."' - AND `mac` = '".(isset ($fields_toinject["mac"]) - ? $fields_toinject["mac"] : '')."'"; + $where .= " AND `logical_number` = '".(isset($fields_toinject["logical_number"]) + ? $fields_toinject["logical_number"] : '')."' + AND `name` = '".(isset($fields_toinject["name"]) + ? $fields_toinject["name"] : '')."' + AND `mac` = '".(isset($fields_toinject["mac"]) + ? $fields_toinject["mac"] : '')."'"; break; case PluginDatainjectionCommonInjectionLib::UNICITY_NETPORT_MACADDRESS : - $where .= " AND `mac` = '".(isset ($fields_toinject["mac"]) - ? $fields_toinject["mac"] : '')."'"; + $where .= " AND `mac` = '".(isset($fields_toinject["mac"]) + ? $fields_toinject["mac"] : '')."'"; break; case PluginDatainjectionCommonInjectionLib::UNICITY_NETPORT_NAME : - $where .= " AND `name` = '".(isset ($fields_toinject["name"]) - ? $fields_toinject["name"] : '')."'"; + $where .= " AND `name` = '".(isset($fields_toinject["name"]) + ? $fields_toinject["name"] : '')."'"; break; } @@ -275,7 +284,7 @@ function getUnicityRequest($fields_toinject=array(), $options=array()) { } - /** + /** * Check if at least mac or ip is defined otherwise block import * * @param $values array the values to inject @@ -287,28 +296,30 @@ function lastCheck($values=array()) { if ((!isset($values['NetworkPort']['name']) || empty($values['NetworkPort']['name'])) && (!isset($values['NetworkPort']['mac']) || empty($values['NetworkPort']['mac'])) && (!isset($values['NetworkPort']['instantiation_type']) - || empty($values['NetworkPort']['instantiation_type']))) { + || empty($values['NetworkPort']['instantiation_type'])) + ) { return false; } return true; } - /** + /** * @param $values * @param $add (true by default) * @param $rights array **/ function processAfterInsertOrUpdate($values, $add=true, $rights=array()) { + global $DB; //Should the port be connected to another one ? - $use_name = (isset ($values['NetworkPort']["netname"]) - || !empty ($values['NetworkPort']["netname"])); - $use_logical_number = (isset ($values['NetworkPort']["netport"]) - || !empty ($values['NetworkPort']["netport"])); - $use_mac = (isset ($values['NetworkPort']["netmac"]) - || !empty ($values['NetworkPort']["netmac"])); + $use_name = (isset($values['NetworkPort']["netname"]) + || !empty($values['NetworkPort']["netname"])); + $use_logical_number = (isset($values['NetworkPort']["netport"]) + || !empty($values['NetworkPort']["netport"])); + $use_mac = (isset($values['NetworkPort']["netmac"]) + || !empty($values['NetworkPort']["netmac"])); if (!$use_name && !$use_logical_number && !$use_mac) { return false; @@ -328,7 +339,7 @@ function processAfterInsertOrUpdate($values, $add=true, $rights=array()) { if ($use_logical_number) { $sql .= " AND `glpi_networkports`.`logical_number` = '".$values['NetworkPort']["netport"]."'"; } - if ($use_mac){ + if ($use_mac) { $sql .= " AND `glpi_networkports`.`mac` = '".$values['NetworkPort']["netmac"]."'"; } $res = $DB->query($sql); @@ -350,4 +361,3 @@ function processAfterInsertOrUpdate($values, $add=true, $rights=array()) { } } -?> \ No newline at end of file diff --git a/inc/operatingsysteminjection.class.php b/inc/operatingsysteminjection.class.php index c684abf2..525d6f6d 100644 --- a/inc/operatingsysteminjection.class.php +++ b/inc/operatingsysteminjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionOperatingSystemInjection extends OperatingSystem - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,4 +85,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/operatingsystemservicepackinjection.class.php b/inc/operatingsystemservicepackinjection.class.php index e95a55ed..b5dfb93f 100644 --- a/inc/operatingsystemservicepackinjection.class.php +++ b/inc/operatingsystemservicepackinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionOperatingSystemServicePackInjection extends OperatingSystemServicePack - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,4 +85,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/operatingsystemversioninjection.class.php b/inc/operatingsystemversioninjection.class.php index 33462f38..ade83866 100644 --- a/inc/operatingsystemversioninjection.class.php +++ b/inc/operatingsystemversioninjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionOperatingSystemVersionInjection extends OperatingSystemVersion - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,4 +85,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/peripheralinjection.class.php b/inc/peripheralinjection.class.php index af6824dc..c9923ee3 100644 --- a/inc/peripheralinjection.class.php +++ b/inc/peripheralinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionPeripheralInjection extends Peripheral - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -43,16 +44,18 @@ static function getTable() { } function isPrimaryType() { + return true; } function connectedTo() { + return array('Computer', 'Document'); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -69,15 +72,15 @@ function getOptions($primary_type='') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("dropdown" => array(3, 4, 23, 31, 40, 49, 71), - "user" => array(24, 70), - "bool" => array(82), - "multiline_text" => array(16, 90)); + "user" => array(24, 70), + "bool" => array(82), + "multiline_text" => array(16, 90)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -88,7 +91,7 @@ function addOrUpdateObject($values=array(), $options=array()) { } - /** + /** * @param $primary_type * @param $values **/ @@ -106,4 +109,3 @@ function addSpecificNeededFields($primary_type, $values) { } } -?> diff --git a/inc/peripheralmodelinjection.class.php b/inc/peripheralmodelinjection.class.php index 117b8446..cc8458f8 100644 --- a/inc/peripheralmodelinjection.class.php +++ b/inc/peripheralmodelinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionPeripheralModelInjection extends PeripheralModel - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,4 +85,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/peripheraltypeinjection.class.php b/inc/peripheraltypeinjection.class.php index 225f6511..a20df733 100644 --- a/inc/peripheraltypeinjection.class.php +++ b/inc/peripheraltypeinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionPeripheralTypeInjection extends PeripheralType - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,4 +85,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/phoneinjection.class.php b/inc/phoneinjection.class.php index de497d42..1cfb26d5 100644 --- a/inc/phoneinjection.class.php +++ b/inc/phoneinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionPhoneInjection extends Phone - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array('Computer', 'Document'); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -67,15 +70,15 @@ function getOptions($primary_type='') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("dropdown" => array(3, 4, 23, 31, 40, 42, 49, 71), - "user" => array(24, 70), - "bool" => array(43, 44, 82), - "multiline_text" => array(16, 90)); + "user" => array(24, 70), + "bool" => array(43, 44, 82), + "multiline_text" => array(16, 90)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -86,7 +89,7 @@ function addOrUpdateObject($values=array(), $options=array()) { } - /** + /** * @param $primary_type * @param $values **/ @@ -104,4 +107,3 @@ function addSpecificNeededFields($primary_type, $values) { } } -?> diff --git a/inc/phonemodelinjection.class.php b/inc/phonemodelinjection.class.php index 44b32e2d..8500e80f 100644 --- a/inc/phonemodelinjection.class.php +++ b/inc/phonemodelinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionPhoneModelInjection extends PhoneModel - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,4 +85,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/phonepowersupplytypeinjection.class.php b/inc/phonepowersupplytypeinjection.class.php index b7bd1709..7f3324a5 100644 --- a/inc/phonepowersupplytypeinjection.class.php +++ b/inc/phonepowersupplytypeinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionPhonePowerSupplyTypeInjection extends PhonePowerSupply - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,4 +85,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/phonetypeinjection.class.php b/inc/phonetypeinjection.class.php index b13a1220..723de65a 100644 --- a/inc/phonetypeinjection.class.php +++ b/inc/phonetypeinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionPhoneTypeInjection extends PhoneType - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,4 +85,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/printerinjection.class.php b/inc/printerinjection.class.php index 0bcef8f1..1a2b06dd 100644 --- a/inc/printerinjection.class.php +++ b/inc/printerinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionPrinterInjection extends Printer - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array('Computer', 'Document'); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -70,9 +73,9 @@ function getOptions($primary_type='') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("dropdown" => array(3, 4, 23, 31, 32, 33, 40, 49, 71), - "bool" => array(42, 43, 44, 45, 46, 86), - "user" => array(24, 70), - "multiline_text" => array(16, 90)); + "bool" => array(42, 43, 44, 45, 46, 86), + "user" => array(24, 70), + "multiline_text" => array(16, 90)); $options['checktype'] = array("bool" => array(42, 43, 44, 45, 46, 86)); @@ -80,7 +83,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -91,12 +94,12 @@ function addOrUpdateObject($values=array(), $options=array()) { } - /** + /** * @param $primary_type * @param $values **/ function addSpecificNeededFields($primary_type,$values) { - + $fields = array(); if (isset($values[$primary_type]['is_global'])) { if (empty($values[$primary_type]['is_global'])) { @@ -109,7 +112,7 @@ function addSpecificNeededFields($primary_type,$values) { } - /** + /** * Play printers dictionnary * * @param $values @@ -117,41 +120,40 @@ function addSpecificNeededFields($primary_type,$values) { function processDictionnariesIfNeeded(&$values) { $matchings = array('name' => 'name', - 'manufacturer' => 'manufacturers_id', - 'comment' => 'comment'); + 'manufacturer' => 'manufacturers_id', + 'comment' => 'comment'); foreach ($matchings as $name => $value) { if (isset($values['Printer'][$value])) { $params[$name] = $values['Printer'][$value]; } else { - $params[$name] = ''; + $params[$name] = ''; } } - $rulecollection = new RuleDictionnaryPrinterCollection(); - $res_rule = $rulecollection->processAllRules($params, array(), array()); + $rulecollection = new RuleDictionnaryPrinterCollection(); + $res_rule = $rulecollection->processAllRules($params, array(), array()); if (!isset($res_rule['_no_rule_matches'])) { - //Printers dictionnary explicitly refuse import + //Printers dictionnary explicitly refuse import if (isset($res_rule['_ignore_import']) && $res_rule['_ignore_import']) { - return false; + return false; } if (isset($res_rule['is_global'])) { - $values['Printer']['is_global'] = $res_rule['is_global']; + $values['Printer']['is_global'] = $res_rule['is_global']; } if (isset($res_rule['name'])) { - $values['Printer']['name'] = $res_rule['name']; + $values['Printer']['name'] = $res_rule['name']; } if (isset($res_rule['supplier'])) { if (isset($values['supplier'])) { $values['Printer']['manufacturers_id'] - = Dropdown::getDropdownName('glpi_suppliers', $res_rule['supplier']); + = Dropdown::getDropdownName('glpi_suppliers', $res_rule['supplier']); } } } - return true; + return true; } } -?> diff --git a/inc/printermodelinjection.class.php b/inc/printermodelinjection.class.php index 1309ec11..fd80b625 100644 --- a/inc/printermodelinjection.class.php +++ b/inc/printermodelinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionPrinterModelInjection extends PrinterModel - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,4 +85,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/printertypeinjection.class.php b/inc/printertypeinjection.class.php index 81aed6f2..7a6c2ab4 100644 --- a/inc/printertypeinjection.class.php +++ b/inc/printertypeinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionPrinterTypeInjection extends PrinterType - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,4 +85,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/profile.class.php b/inc/profile.class.php index f57780a0..8d2e6074 100644 --- a/inc/profile.class.php +++ b/inc/profile.class.php @@ -28,31 +28,34 @@ @since 2009 ---------------------------------------------------------------------- */ -class PluginDatainjectionProfile extends Profile { +class PluginDatainjectionProfile extends Profile +{ static $rightname = "profile"; static function getAllRights() { + $rights = array( - array('itemtype' => 'PluginDatainjectionModel', - 'label' => __('Model management', 'datainjection'), - 'field' => 'plugin_datainjection_model'), - array('itemtype' => 'PluginDatainjectionModel', - 'label' => __('Injection of the file', 'datainjection'), - 'field' => 'plugin_datainjection_use', - 'rights' => array(READ => __('Read')))); + array('itemtype' => 'PluginDatainjectionModel', + 'label' => __('Model management', 'datainjection'), + 'field' => 'plugin_datainjection_model'), + array('itemtype' => 'PluginDatainjectionModel', + 'label' => __('Injection of the file', 'datainjection'), + 'field' => 'plugin_datainjection_use', + 'rights' => array(READ => __('Read')))); return $rights; } - - /** + + /** * Clean profiles_id from plugin's profile table * * @param $ID **/ function cleanProfiles($ID) { + global $DB; - $query = "DELETE FROM `glpi_profiles` - WHERE `profiles_id`='$ID' + $query = "DELETE FROM `glpi_profiles` + WHERE `profiles_id`='$ID' AND `name` LIKE '%plugin_datainjection%'"; $DB->query($query); } @@ -75,22 +78,26 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtempl $profile = new self(); $ID = $item->getField('id'); //In case there's no right datainjection for this profile, create it - self::addDefaultProfileInfos($item->getID(), - array('plugin_datainjection_model' => 0)); + self::addDefaultProfileInfos( + $item->getID(), + array('plugin_datainjection_model' => 0) + ); $profile->showForm($ID); } return true; } - - /** + /** * @param $profile **/ static function addDefaultProfileInfos($profiles_id, $rights) { + $profileRight = new ProfileRight(); foreach ($rights as $right => $value) { - if (!countElementsInTable('glpi_profilerights', - "`profiles_id`='$profiles_id' AND `name`='$right'")) { + if (!countElementsInTable( + 'glpi_profilerights', + "`profiles_id`='$profiles_id' AND `name`='$right'" + )) { $myright['profiles_id'] = $profiles_id; $myright['name'] = $right; $myright['rights'] = $value; @@ -102,24 +109,27 @@ static function addDefaultProfileInfos($profiles_id, $rights) { } } - /** + /** * @param $ID integer */ static function createFirstAccess($profiles_id) { - include_once(GLPI_ROOT."/plugins/datainjection/inc/profile.class.php"); + + include_once GLPI_ROOT."/plugins/datainjection/inc/profile.class.php"; foreach (self::getAllRights() as $right) { - self::addDefaultProfileInfos($profiles_id, - array('plugin_datainjection_model' => ALLSTANDARDRIGHT, - 'plugin_datainjection_use' => READ)); + self::addDefaultProfileInfos( + $profiles_id, + array('plugin_datainjection_model' => ALLSTANDARDRIGHT, + 'plugin_datainjection_use' => READ) + ); } } - static function migrateProfiles() { + global $DB; if (!TableExists('glpi_plugin_datainjection_profiles')) { return true; - } + } $profiles = getAllDatasFromTable('glpi_plugin_datainjection_profiles'); foreach ($profiles as $id => $profile) { @@ -129,15 +139,15 @@ static function migrateProfiles() { $id = $DB->result($result, 0, 'id'); switch ($profile['model']) { case 'r' : - $value = READ; - break; + $value = READ; + break; case 'w': - $value = ALLSTANDARDRIGHT; - break; + $value = ALLSTANDARDRIGHT; + break; case 0: default: $value = 0; - break; + break; } self::addDefaultProfileInfos($id, array('plugin_datainjection_model' => $value)); if ($value > 0) { @@ -148,7 +158,7 @@ static function migrateProfiles() { } } } - + /** * Show profile form * @@ -157,11 +167,12 @@ static function migrateProfiles() { * * @return nothing **/ - function showForm($profiles_id=0, $openform=TRUE, $closeform=TRUE) { + function showForm($profiles_id=0, $openform=true, $closeform=true) { echo "
    "; if (($canedit = Session::haveRightsOr(self::$rightname, array(CREATE, UPDATE, PURGE))) - && $openform) { + && $openform + ) { $profile = new Profile(); echo ""; } @@ -170,18 +181,21 @@ function showForm($profiles_id=0, $openform=TRUE, $closeform=TRUE) { $profile->getFromDB($profiles_id); $rights = self::getAllRights(); - $profile->displayRightsChoiceMatrix(self::getAllRights(), - array('canedit' => $canedit, - 'default_class' => 'tab_bg_2', - 'title' => __('General'))); + $profile->displayRightsChoiceMatrix( + self::getAllRights(), + array('canedit' => $canedit, + 'default_class' => 'tab_bg_2', + 'title' => __('General')) + ); if ($canedit - && $closeform) { - echo "
    "; - echo Html::hidden('id', array('value' => $profiles_id)); - echo Html::submit(_sx('button', 'Save'), array('name' => 'update')); - echo "
    \n"; - Html::closeForm(); + && $closeform + ) { + echo "
    "; + echo Html::hidden('id', array('value' => $profiles_id)); + echo Html::submit(_sx('button', 'Save'), array('name' => 'update')); + echo "
    \n"; + Html::closeForm(); } - echo "
    "; + echo ""; } } diff --git a/inc/profile_userinjection.class.php b/inc/profile_userinjection.class.php index 0e21596c..4a4ebb03 100644 --- a/inc/profile_userinjection.class.php +++ b/inc/profile_userinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionProfile_UserInjection extends Profile_User - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return false; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -80,7 +83,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -91,7 +94,7 @@ function addOrUpdateObject($values=array(), $options=array()) { } - /** + /** * @param $primary_type * @param $values **/ @@ -102,4 +105,3 @@ function addSpecificNeededFields($primary_type,$values) { } } -?> \ No newline at end of file diff --git a/inc/profileinjection.class.php b/inc/profileinjection.class.php index 6330fb1a..cc8a71b4 100644 --- a/inc/profileinjection.class.php +++ b/inc/profileinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionProfileInjection extends Profile - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,56 +45,59 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { + return Search::getOptions(get_parent_class($this)); } - /** + /** * @param $field_name * @param $data * @param $mandatory **/ function checkType($field_name, $data, $mandatory) { - switch($field_name) { + switch ($field_name) { case 'right_rw' : return (in_array($data, array('r', 'w')) - ?PluginDatainjectionCommonInjectionLib::SUCCESS - :PluginDatainjectionCommonInjectionLib::TYPE_MISMATCH); + ?PluginDatainjectionCommonInjectionLib::SUCCESS + :PluginDatainjectionCommonInjectionLib::TYPE_MISMATCH); case 'right_r' : return (($data=='r')?PluginDatainjectionCommonInjectionLib::SUCCESS - :PluginDatainjectionCommonInjectionLib::TYPE_MISMATCH); + :PluginDatainjectionCommonInjectionLib::TYPE_MISMATCH); case 'right_w' : return (($data=='w')?PluginDatainjectionCommonInjectionLib::SUCCESS - :PluginDatainjectionCommonInjectionLib::TYPE_MISMATCH); + :PluginDatainjectionCommonInjectionLib::TYPE_MISMATCH); case 'interface': return (in_array($data, array('helpdesk', 'central')) - ?PluginDatainjectionCommonInjectionLib::SUCCESS - :PluginDatainjectionCommonInjectionLib::TYPE_MISMATCH); + ?PluginDatainjectionCommonInjectionLib::SUCCESS + :PluginDatainjectionCommonInjectionLib::TYPE_MISMATCH); - default : + default: return PluginDatainjectionCommonInjectionLib::SUCCESS; } } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -104,4 +108,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/requesttypeinjection.class.php b/inc/requesttypeinjection.class.php index 6eb53e28..ab393c62 100644 --- a/inc/requesttypeinjection.class.php +++ b/inc/requesttypeinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionRequestTypeInjection extends RequestType - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -67,13 +70,13 @@ function getOptions($primary_type='') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("bool" => array(14, 15), - "multiline_text" => array(16)); + "multiline_text" => array(16)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -84,4 +87,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/session.class.php b/inc/session.class.php index e0b98300..e8fd10e9 100644 --- a/inc/session.class.php +++ b/inc/session.class.php @@ -28,9 +28,10 @@ @since 2009 ---------------------------------------------------------------------- */ - class PluginDatainjectionSession { +class PluginDatainjectionSession +{ - /** + /** * Get a parameter from the HTTP session * * @param $param the parameter to get @@ -50,7 +51,7 @@ static function getParam($param) { } - /** + /** * Set a parameter in the HTTP session * * @param $param the parameter @@ -70,7 +71,7 @@ static function setParam($param,$results) { } - /** + /** * Remove all parameters from the HTTP session * * @return nothing @@ -87,4 +88,3 @@ static function removeParams() { } } -?> \ No newline at end of file diff --git a/inc/softwareinjection.class.php b/inc/softwareinjection.class.php index e3085948..a1a12e82 100644 --- a/inc/softwareinjection.class.php +++ b/inc/softwareinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionSoftwareInjection extends Software - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -70,60 +73,56 @@ function getOptions($primary_type='') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("dropdown" => array(3, 23, 49, 62, 71), - "bool" => array(61, 86), - "user" => array(24, 70), - "multiline_text" => array(16, 90)); + "bool" => array(61, 86), + "user" => array(24, 70), + "multiline_text" => array(16, 90)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * Play software dictionnary * * @param $values **/ function processDictionnariesIfNeeded(&$values) { - $params['entities_id'] = $_SESSION['glpiactive_entity']; - $params['name'] = $values['Software']['name']; - if (isset($values['Software']['manufacturers_id'])) { - $params['manufacturer'] = $values['Software']['manufacturers_id']; - } else { - $params['manufacturer'] = ''; + $params['entities_id'] = $_SESSION['glpiactive_entity']; + $params['name'] = $values['Software']['name']; + if (isset($values['Software']['manufacturers_id'])) { + $params['manufacturer'] = $values['Software']['manufacturers_id']; + } else { + $params['manufacturer'] = ''; + } + $rulecollection = new RuleDictionnarySoftwareCollection(); + $res_rule = $rulecollection->processAllRules($params, array(), array()); + + if (!isset($res_rule['_no_rule_matches'])) { + //Software dictionnary explicitly refuse import + if (isset($res_rule['_ignore_import']) && $res_rule['_ignore_import']) { + return false; } - $rulecollection = new RuleDictionnarySoftwareCollection(); - $res_rule = $rulecollection->processAllRules($params, array(), array()); - - if (!isset($res_rule['_no_rule_matches'])) { - //Software dictionnary explicitly refuse import - if (isset($res_rule['_ignore_import']) && $res_rule['_ignore_import']) { - return false; - } - if (isset($res_rule['is_helpdesk_visible'])) { - $values['Software']['is_helpdesk_visible'] = $res_rule['is_helpdesk_visible']; - } - - if (isset($res_rule['version'])) { - $values['SoftwareVersion']['name'] = $res_rule['version']; - } - - if (isset($res_rule['name'])) { - $values['Software']['name'] = $res_rule['name']; - } - - if (isset($res_rule['supplier'])) { - if (isset($values['supplier'])) { - $values['Software']['manufacturers_id'] - = Dropdown::getDropdownName('glpi_suppliers', $res_rule['supplier']); - } + if (isset($res_rule['is_helpdesk_visible'])) { + $values['Software']['is_helpdesk_visible'] = $res_rule['is_helpdesk_visible']; + } + if (isset($res_rule['version'])) { + $values['SoftwareVersion']['name'] = $res_rule['version']; + } + if (isset($res_rule['name'])) { + $values['Software']['name'] = $res_rule['name']; + } + if (isset($res_rule['supplier'])) { + if (isset($values['supplier'])) { + $values['Software']['manufacturers_id'] + = Dropdown::getDropdownName('glpi_suppliers', $res_rule['supplier']); } } - return true; + } + return true; } - - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -134,4 +133,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/softwarelicenseinjection.class.php b/inc/softwarelicenseinjection.class.php index 85b58581..4c4d8f4f 100644 --- a/inc/softwarelicenseinjection.class.php +++ b/inc/softwarelicenseinjection.class.php @@ -29,12 +29,13 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } /// SoftwareLicense class class PluginDatainjectionSoftwareLicenseInjection extends SoftwareLicense - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -45,16 +46,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array('Software'); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -84,15 +87,15 @@ function getOptions($primary_type='') { unset($options['ignore_fields'][$key]); $options['displaytype'] = array("dropdown" => array(5, 6, 7, 110), - "date" => array(8), - "multiline_text" => array(16), - "software" => array(100)); + "date" => array(8), + "multiline_text" => array(16), + "software" => array(100)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @param $info array * @param $option array **/ @@ -102,15 +105,19 @@ function showAdditionalInformation($info=array(), $option=array()) { switch ($option['displaytype']) { case 'computer' : - Computer::dropdown(array('name' => $name, - 'entity' => $_SESSION['glpiactive_entity'], - 'entity_sons' => false)); + Computer::dropdown( + array('name' => $name, + 'entity' => $_SESSION['glpiactive_entity'], + 'entity_sons' => false) + ); break; case 'software' : - Software::dropdown(array('name' => $name, - 'entity' => $_SESSION['glpiactive_entity'], - 'entity_sons' => false)); + Software::dropdown( + array('name' => $name, + 'entity' => $_SESSION['glpiactive_entity'], + 'entity_sons' => false) + ); break; default : @@ -119,7 +126,7 @@ function showAdditionalInformation($info=array(), $option=array()) { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -130,10 +137,11 @@ function addOrUpdateObject($values=array(), $options=array()) { } - /** + /** * @param $fields_toinject array **/ function getValueForAdditionalMandatoryFields($fields_toinject=array()) { + global $DB; if (!isset($fields_toinject['SoftwareLicense']['softwares_id'])) { @@ -143,26 +151,28 @@ function getValueForAdditionalMandatoryFields($fields_toinject=array()) { $query = "SELECT `id` FROM `glpi_softwares` WHERE `name` = '".$fields_toinject['SoftwareLicense']['softwares_id']."'". - getEntitiesRestrictRequest(" AND", "glpi_softwares", "entities_id", - $fields_toinject['SoftwareLicense']['entities_id'], - true); + getEntitiesRestrictRequest( + " AND", "glpi_softwares", "entities_id", + $fields_toinject['SoftwareLicense']['entities_id'], + true + ); $result = $DB->query($query); if ($DB->numrows($result) > 0) { - $id = $DB->result($result,0,'id'); - //Add softwares_id to the array - $fields_toinject['SoftwareLicense']['softwares_id'] = $id; + $id = $DB->result($result, 0, 'id'); + //Add softwares_id to the array + $fields_toinject['SoftwareLicense']['softwares_id'] = $id; } else { - //Remove software id - unset($fields_toinject['SoftwareLicense']['softwares_id']); + //Remove software id + unset($fields_toinject['SoftwareLicense']['softwares_id']); } - return $fields_toinject; + return $fields_toinject; } - /** + /** * @param $primary_type * @param $values **/ @@ -176,7 +186,7 @@ function addSpecificNeededFields($primary_type, $values) { } - /** + /** * @param $fields_toinject array * @param $options array **/ @@ -190,4 +200,3 @@ function checkPresent($fields_toinject=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/softwarelicensetypeinjection.class.php b/inc/softwarelicensetypeinjection.class.php index bbd0807a..9abc0998 100644 --- a/inc/softwarelicensetypeinjection.class.php +++ b/inc/softwarelicensetypeinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionSoftwareLicenseTypeInjection extends SoftwareLicenseType - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,4 +85,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/softwareversioninjection.class.php b/inc/softwareversioninjection.class.php index 3d6f21b5..1229db75 100644 --- a/inc/softwareversioninjection.class.php +++ b/inc/softwareversioninjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionSoftwareVersionInjection extends SoftwareVersion - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array('Software'); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -79,16 +82,15 @@ function getOptions($primary_type='') { $key = array_search(2, $options['ignore_fields']); unset($options['ignore_fields'][$key]); - $options['displaytype'] = array("dropdown" => array(4,31), - "multiline_text" => array(16), - "software" => array(100)); + "multiline_text" => array(16), + "software" => array(100)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @param $info array * @param $option array **/ @@ -97,15 +99,19 @@ function showAdditionalInformation($info=array(), $option=array()) { $name = "info[".$option['linkfield']."]"; switch ($option['displaytype']) { case 'computer' : - Computer::dropdown(array('name' => $name, - 'entity' => $_SESSION['glpiactive_entity'], - 'entity_sons' => false)); + Computer::dropdown( + array('name' => $name, + 'entity' => $_SESSION['glpiactive_entity'], + 'entity_sons' => false) + ); break; case 'software' : - Software::dropdown(array('name' => $name, - 'entity' => $_SESSION['glpiactive_entity'], - 'entity_sons' => false)); + Software::dropdown( + array('name' => $name, + 'entity' => $_SESSION['glpiactive_entity'], + 'entity_sons' => false) + ); break; default : @@ -114,7 +120,7 @@ function showAdditionalInformation($info=array(), $option=array()) { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -125,10 +131,11 @@ function addOrUpdateObject($values=array(), $options=array()) { } - /** + /** * @param $fields_toinject array **/ function getValueForAdditionalMandatoryFields($fields_toinject=array()) { + global $DB; if (!isset($fields_toinject['SoftwareVersion']['softwares_id'])) { @@ -138,26 +145,28 @@ function getValueForAdditionalMandatoryFields($fields_toinject=array()) { $query = "SELECT `id` FROM `glpi_softwares` WHERE `name` = '".$fields_toinject['SoftwareVersion']['softwares_id']."'". - getEntitiesRestrictRequest(" AND", "glpi_softwares", "entities_id", - $fields_toinject['SoftwareVersion']['entities_id'], - true); + getEntitiesRestrictRequest( + " AND", "glpi_softwares", "entities_id", + $fields_toinject['SoftwareVersion']['entities_id'], + true + ); $result = $DB->query($query); if ($DB->numrows($result) > 0) { - $id = $DB->result($result,0,'id'); - //Add softwares_id to the array - $fields_toinject['SoftwareVersion']['softwares_id'] = $id; + $id = $DB->result($result, 0, 'id'); + //Add softwares_id to the array + $fields_toinject['SoftwareVersion']['softwares_id'] = $id; } else { - //Remove software name - unset($fields_toinject['SoftwareVersion']['softwares_id']); + //Remove software name + unset($fields_toinject['SoftwareVersion']['softwares_id']); } - return $fields_toinject; + return $fields_toinject; } - /** + /** * @param $primary_type * @param $values **/ @@ -171,7 +180,7 @@ function addSpecificNeededFields($primary_type, $values) { } - /** + /** * @param $fields_toinject array * @param $options array **/ @@ -185,4 +194,3 @@ function checkPresent($fields_toinject=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/solutiontemplateinjection.class.php b/inc/solutiontemplateinjection.class.php index b03756b0..73544200 100644 --- a/inc/solutiontemplateinjection.class.php +++ b/inc/solutiontemplateinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionSolutionTemplateInjection extends SolutionTemplate - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -66,14 +69,14 @@ function getOptions($primary_type='') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("multiline_text" => array(4, 16), - "dropdown" => array(3), - "bool" => array(86)); + "dropdown" => array(3), + "bool" => array(86)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -84,4 +87,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/solutiontypeinjection.class.php b/inc/solutiontypeinjection.class.php index a89f0ca0..b17e307c 100644 --- a/inc/solutiontypeinjection.class.php +++ b/inc/solutiontypeinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionSolutionTypeInjection extends SolutionType - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type = '') { @@ -67,13 +70,13 @@ function getOptions($primary_type = '') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("multiline_text" => array(16), - "bool" => array(86)); + "bool" => array(86)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -84,4 +87,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/stateinjection.class.php b/inc/stateinjection.class.php index e2cb943d..ad86841a 100644 --- a/inc/stateinjection.class.php +++ b/inc/stateinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionStateInjection extends State - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,4 +85,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/supplierinjection.class.php b/inc/supplierinjection.class.php index 314b4aef..99aac9b1 100644 --- a/inc/supplierinjection.class.php +++ b/inc/supplierinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionSupplierInjection extends Supplier - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -67,14 +70,14 @@ function getOptions($primary_type='') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("dropdown" => array(9), - "multiline_text" => array(3, 16, 90), - "bool" => array(86)); + "multiline_text" => array(3, 16, 90), + "bool" => array(86)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -85,4 +88,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/suppliertypeinjection.class.php b/inc/suppliertypeinjection.class.php index 870f69b2..6d36bfac 100644 --- a/inc/suppliertypeinjection.class.php +++ b/inc/suppliertypeinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionSupplierTypeInjection extends SupplierType - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,4 +85,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/taskcategoryinjection.class.php b/inc/taskcategoryinjection.class.php index d3443494..96349131 100644 --- a/inc/taskcategoryinjection.class.php +++ b/inc/taskcategoryinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionTaskCategoryInjection extends TaskCategory - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -67,13 +70,13 @@ function getOptions($primary_type='') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("bool" => array(86), - "multiline_text" => array(16)); + "multiline_text" => array(16)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -84,4 +87,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/userinjection.class.php b/inc/userinjection.class.php index 5de22d8d..dcf0876f 100644 --- a/inc/userinjection.class.php +++ b/inc/userinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionUserInjection extends User - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -91,7 +94,6 @@ function getOptions($primary_type='') { $tab[101]['relationclass'] = 'Profile_User'; $tab[101]['relationfield'] = $tab[101]['linkfield']; - //Remove some options because some fields cannot be imported $blacklist = PluginDatainjectionCommonInjectionLib::getBlacklistedOptions(get_parent_class($this)); $notimportable = array(13, 14, 15, 17, 20, 23, 30, 31, 60, 61, 77, 91, 92, 93); @@ -100,15 +102,15 @@ function getOptions($primary_type='') { //Add displaytype value $options['displaytype'] = array("dropdown" => array(3, 79, 81, 82), - "multiline_text" => array(16), - "bool" => array(8), - "password" => array(4)); + "multiline_text" => array(16), + "bool" => array(8), + "password" => array(4)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -119,7 +121,7 @@ function addOrUpdateObject($values=array(), $options=array()) { } - /** + /** * @param $primary_type * @param $values **/ @@ -134,22 +136,26 @@ function addSpecificNeededFields($primary_type, $values) { } - /** + /** * @param $values * @param $add (true by default) * @param $rights array */ function processAfterInsertOrUpdate($values, $add=true, $rights=array()) { + global $DB; //Manage user emails if (isset($values['User']['useremails_id']) && $rights['add_dropdown'] - && Session::haveRight('user', UPDATE)) { - - if (!countElementsInTable("glpi_useremails", - "`users_id`='".$values['User']['id']."' - AND `email`='".$values['User']['useremails_id']."'")) { + && Session::haveRight('user', UPDATE) + ) { + + if (!countElementsInTable( + "glpi_useremails", + "`users_id`='".$values['User']['id']."' + AND `email`='".$values['User']['useremails_id']."'" + )) { $useremail = new UserEmail(); $tmp['users_id'] = $values['User']['id']; $tmp['email'] = $values['User']['useremails_id']; @@ -170,7 +176,7 @@ function processAfterInsertOrUpdate($values, $add=true, $rights=array()) { } - /** + /** * @param unknown_type $itemtype * @param unknown_type $field * @param unknown_type $value @@ -184,4 +190,3 @@ protected function addSpecificOptionalInfos($itemtype, $field, $value) { } } -?> \ No newline at end of file diff --git a/inc/virtualmachinestateinjection.class.php b/inc/virtualmachinestateinjection.class.php index 1679a303..dfb59c28 100644 --- a/inc/virtualmachinestateinjection.class.php +++ b/inc/virtualmachinestateinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionVirtualMachineStateInjection extends VirtualMachineState - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,4 +85,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/virtualmachinesysteminjection.class.php b/inc/virtualmachinesysteminjection.class.php index 045505e9..5e7ff90d 100644 --- a/inc/virtualmachinesysteminjection.class.php +++ b/inc/virtualmachinesysteminjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionVirtualMachineSystemInjection extends VirtualMachineSystem - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,4 +85,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/virtualmachinetypeinjection.class.php b/inc/virtualmachinetypeinjection.class.php index 17151784..79ad91e2 100644 --- a/inc/virtualmachinetypeinjection.class.php +++ b/inc/virtualmachinetypeinjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionVirtualMachineTypeInjection extends VirtualMachineType - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -71,7 +74,7 @@ function getOptions($primary_type='') { } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -82,4 +85,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/vlaninjection.class.php b/inc/vlaninjection.class.php index 1d93f4c7..8e3d35c1 100644 --- a/inc/vlaninjection.class.php +++ b/inc/vlaninjection.class.php @@ -29,11 +29,12 @@ ---------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); + die("Sorry. You can't access directly to this file"); } class PluginDatainjectionVlanInjection extends Vlan - implements PluginDatainjectionInjectionInterface { + implements PluginDatainjectionInjectionInterface +{ static function getTable() { @@ -44,16 +45,18 @@ static function getTable() { function isPrimaryType() { + return true; } function connectedTo() { + return array(); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { @@ -67,13 +70,13 @@ function getOptions($primary_type='') { $options['ignore_fields'] = array_merge($blacklist, $notimportable); $options['displaytype'] = array("bool" => array(86), - "multiline_text" => array(16)); + "multiline_text" => array(16)); return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); } - /** + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values=array(), $options=array()) { @@ -84,4 +87,3 @@ function addOrUpdateObject($values=array(), $options=array()) { } } -?> \ No newline at end of file diff --git a/inc/webservice.class.php b/inc/webservice.class.php index 117a4d6f..76f51f7c 100644 --- a/inc/webservice.class.php +++ b/inc/webservice.class.php @@ -28,20 +28,21 @@ @since 2009 ---------------------------------------------------------------------- */ -class PluginDatainjectionWebservice { +class PluginDatainjectionWebservice +{ static function methodInject($params, $protocol) { - if (isset ($params['help'])) { + if (isset($params['help'])) { return array('uri' => 'string,mandatory', - 'base64' => 'string,optional', - 'additional' => 'array,optional', - 'models_id' => 'integer, mandatory', - 'entities_id'=> 'integer,mandatory', - 'mandatory' => 'array,optional', - 'uri' => 'uri,mandatory', - 'help' => 'bool,optional'); + 'base64' => 'string,optional', + 'additional' => 'array,optional', + 'models_id' => 'integer, mandatory', + 'entities_id'=> 'integer,mandatory', + 'mandatory' => 'array,optional', + 'uri' => 'uri,mandatory', + 'help' => 'bool,optional'); } $model = new PluginDatainjectionModel(); @@ -49,56 +50,80 @@ static function methodInject($params, $protocol) { //----------------------------------------------------------------- //-------------------------- Check parameters --------------------- //----------------------------------------------------------------- - if (!isset ($_SESSION['glpiID'])) { - return PluginWebservicesMethodCommon::Error($protocol, - WEBSERVICES_ERROR_NOTAUTHENTICATED); + if (!isset($_SESSION['glpiID'])) { + return PluginWebservicesMethodCommon::Error( + $protocol, + WEBSERVICES_ERROR_NOTAUTHENTICATED + ); } if (!isset($params['uri']) && !isset($params['base64'])) { - return PluginWebservicesMethodCommon::Error($protocol, - WEBSERVICES_ERROR_MISSINGPARAMETER, - '', 'uri or base64'); + return PluginWebservicesMethodCommon::Error( + $protocol, + WEBSERVICES_ERROR_MISSINGPARAMETER, + '', 'uri or base64' + ); } - if (!isset ($params['models_id'])) { - return PluginWebservicesMethodCommon::Error($protocol, - WEBSERVICES_ERROR_MISSINGPARAMETER, - 'models_id'); + if (!isset($params['models_id'])) { + return PluginWebservicesMethodCommon::Error( + $protocol, + WEBSERVICES_ERROR_MISSINGPARAMETER, + 'models_id' + ); } if (!$model->getFromDB($params['models_id'])) { - return PluginWebservicesMethodCommon::Error($protocol, WEBSERVICES_ERROR_NOTFOUND, - __('Model unknown', 'datainjection')); + return PluginWebservicesMethodCommon::Error( + $protocol, WEBSERVICES_ERROR_NOTFOUND, + __('Model unknown', 'datainjection') + ); } if (!$model->can($params['models_id'], READ)) { - return PluginWebservicesMethodCommon::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED, - __('You cannot access this model', - 'datainjection')); + return PluginWebservicesMethodCommon::Error( + $protocol, WEBSERVICES_ERROR_NOTALLOWED, + __( + 'You cannot access this model', + 'datainjection' + ) + ); } if ($model->fields['step'] < PluginDatainjectionModel::READY_TO_USE_STEP) { - return PluginWebservicesMethodCommon::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED, - __('You cannot access this model', - 'datainjection')); + return PluginWebservicesMethodCommon::Error( + $protocol, WEBSERVICES_ERROR_NOTALLOWED, + __( + 'You cannot access this model', + 'datainjection' + ) + ); } //Check entity - if (!isset ($params['entities_id'])) { - return PluginWebservicesMethodCommon::Error($protocol, - WEBSERVICES_ERROR_MISSINGPARAMETER, - 'entities_id'); + if (!isset($params['entities_id'])) { + return PluginWebservicesMethodCommon::Error( + $protocol, + WEBSERVICES_ERROR_MISSINGPARAMETER, + 'entities_id' + ); } $entities_id = $params['entities_id']; - if ($entities_id > 0 ) { + if ($entities_id > 0) { $entity = new Entity(); if (!$entity->getFromDB($entities_id)) { - return PluginWebservicesMethodCommon::Error($protocol, WEBSERVICES_ERROR_NOTFOUND, - __('Entity unknown', 'datainjection')); + return PluginWebservicesMethodCommon::Error( + $protocol, WEBSERVICES_ERROR_NOTFOUND, + __('Entity unknown', 'datainjection') + ); } if (!Session::haveAccessToEntity($entities_id)) { - return PluginWebservicesMethodCommon::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED, - __('You cannot access this entity', - 'datainjection')); + return PluginWebservicesMethodCommon::Error( + $protocol, WEBSERVICES_ERROR_NOTALLOWED, + __( + 'You cannot access this entity', + 'datainjection' + ) + ); } } @@ -111,40 +136,43 @@ static function methodInject($params, $protocol) { //Upload CSV file $document_name = basename($params['uri']); $filename = tempnam(PLUGIN_DATAINJECTION_UPLOAD_DIR, 'PWS'); - $response = PluginWebservicesMethodCommon::uploadDocument($params, $protocol, $filename, - $document_name); + $response = PluginWebservicesMethodCommon::uploadDocument( + $params, $protocol, $filename, + $document_name + ); if (PluginWebservicesMethodCommon::isError($protocol, $response)) { - return $response; + return $response; } - //Uploade successful : now perform import ! - $options = array('file_encoding' => PluginDatainjectionBackend::ENCODING_AUTO, //Detect automatically file encoding - 'webservice' => true, //Use webservice CSV file import - 'original_filename' => $params['uri'], //URI to the CSV file - 'unique_filename' => $filename, //Unique filename - 'mode' => PluginDatainjectionModel::PROCESS, - 'delete_file' => false, //Do not delete file once imported - 'protocol' => $protocol); //The Webservice protocol used - - $results = array(); - $response = $model->processUploadedFile($options); + //Uploade successful : now perform import ! + $options = array('file_encoding' => PluginDatainjectionBackend::ENCODING_AUTO, //Detect automatically file encoding + 'webservice' => true, //Use webservice CSV file import + 'original_filename' => $params['uri'], //URI to the CSV file + 'unique_filename' => $filename, //Unique filename + 'mode' => PluginDatainjectionModel::PROCESS, + 'delete_file' => false, //Do not delete file once imported + 'protocol' => $protocol); //The Webservice protocol used + + $results = array(); + $response = $model->processUploadedFile($options); if (!PluginWebservicesMethodCommon::isError($protocol, $response)) { $engine = new PluginDatainjectionEngine($model, $additional_infos, $params['entities_id']); //Remove first line if header is present $first = true; foreach ($model->injectionData->getData() as $id => $data) { if ($first - && $model->getSpecificModel()->isHeaderPresent()) { + && $model->getSpecificModel()->isHeaderPresent() + ) { $first = false; } else { $results[] = $engine->injectLine($data[0], $id); } } - $model->cleanData(); - return $results; + $model->cleanData(); + return $results; } - return $response; + return $response; } @@ -155,7 +183,7 @@ static function methodGetModel($params,$protocol) { } - static function methodListModels($params, $protocol) { + static function methodListModels($params, $protocol) { $params['itemtype'] = 'PluginDatainjectionModel'; return PluginWebservicesMethodInventaire::methodListObjects($params, $protocol); @@ -164,11 +192,11 @@ static function methodListModels($params, $protocol) { static function methodListItemtypes($params, $protocol) { - if (isset ($params['help'])) { + if (isset($params['help'])) { return array('help' => 'bool,optional'); } - if (!isset ($_SESSION['glpiID'])) { + if (!isset($_SESSION['glpiID'])) { return self::Error($protocol, WEBSERVICES_ERROR_NOTAUTHENTICATED); } @@ -176,4 +204,3 @@ static function methodListItemtypes($params, $protocol) { } } -?> diff --git a/javascript/datainjection.js b/javascript/datainjection.js index 81704b8b..bdab7c3d 100644 --- a/javascript/datainjection.js +++ b/javascript/datainjection.js @@ -3,7 +3,7 @@ function show_comments(cpt) { sel = document.getElementById('dropdown'); id = sel.selectedIndex; - for (i=0 ; iisActivated("datainjection")) { - Plugin::registerClass('PluginDatainjectionProfile', - array('addtabon' => array('Profile'))); + Plugin::registerClass( + 'PluginDatainjectionProfile', + ['addtabon' => ['Profile'] + ] + ); //If directory doesn't exists, create it if (!plugin_datainjection_checkDirectories()) { - @ mkdir(PLUGIN_DATAINJECTION_UPLOAD_DIR) - or die(sprintf(__('%1$s %2$s'), __("Can't create folder", 'datainjection'), - PLUGIN_DATAINJECTION_UPLOAD_DIR)); + @ mkdir(PLUGIN_DATAINJECTION_UPLOAD_DIR) + or die( + sprintf( + __('%1$s %2$s'), __("Can't create folder", 'datainjection'), + PLUGIN_DATAINJECTION_UPLOAD_DIR + ) + ); } if (Session::haveRight('plugin_datainjection_use', READ)) { - $PLUGIN_HOOKS["menu_toadd"]['datainjection'] = array('tools' => 'PluginDatainjectionMenu'); + $PLUGIN_HOOKS["menu_toadd"]['datainjection'] = ['tools' => 'PluginDatainjectionMenu']; } - $PLUGIN_HOOKS['pre_item_purge']['datainjection'] - = array('Profile' => array('PluginDatainjectionProfile', 'purgeProfiles')); + $PLUGIN_HOOKS['pre_item_purge']['datainjection'] + = ['Profile' => ['PluginDatainjectionProfile', 'purgeProfiles']]; - // Css file + // Css file if (strpos($_SERVER['REQUEST_URI'], "plugins/datainjection") !== false) { $PLUGIN_HOOKS['add_css']['datainjection'] = 'css/datainjection.css'; } - // Javascript file - $PLUGIN_HOOKS['add_javascript']['datainjection'] = 'javascript/datainjection.js'; + // Javascript file + $PLUGIN_HOOKS['add_javascript']['datainjection'] = 'javascript/datainjection.js'; - // Inbtegration with Webservices plugin - $PLUGIN_HOOKS['webservices']['datainjection'] = 'plugin_datainjection_registerMethods'; - $INJECTABLE_TYPES = array(); + // Inbtegration with Webservices plugin + $PLUGIN_HOOKS['webservices']['datainjection'] = 'plugin_datainjection_registerMethods'; + $INJECTABLE_TYPES = []; } } @@ -77,28 +85,31 @@ function plugin_init_datainjection() { function plugin_version_datainjection() { - return array('name' => __('File injection', 'datainjection'), - 'minGlpiVersion' => '0.85', - 'author' => 'Walid Nouh, Remi Collet, Nelly Mahu-Lasson, Xavier Caillaud', - 'homepage' => 'https://github.com/pluginsGLPI/datainjection', - 'license' => 'GPLv2+', - 'version' => '2.4.2' - ); + return ['name' => __('File injection', 'datainjection'), + 'minGlpiVersion' => '0.85', + 'author' => 'Walid Nouh, Remi Collet, Nelly Mahu-Lasson, Xavier Caillaud', + 'homepage' => 'https://github.com/pluginsGLPI/datainjection', + 'license' => 'GPLv2+', + 'version' => '2.4.2' + ]; } function plugin_datainjection_check_prerequisites() { - if (version_compare(GLPI_VERSION,'0.85','lt') || version_compare(GLPI_VERSION,'9.2','ge')) { + if (version_compare(GLPI_VERSION, '0.85', 'lt') + || version_compare(GLPI_VERSION, '9.2', 'ge') + ) { _e('This plugin requires GLPI 0.85 or higher', 'datainjection'); return false; } - return true; + return true; } function plugin_datainjection_check_config($verbose=false) { - return true; + + return true; } @@ -108,120 +119,121 @@ function plugin_datainjection_check_config($verbose=false) { * @return an array of injection class => plugin */ function getTypesToInject() { - global $INJECTABLE_TYPES,$PLUGIN_HOOKS; + + global $INJECTABLE_TYPES,$PLUGIN_HOOKS; if (count($INJECTABLE_TYPES)) { // already populated return; } - $INJECTABLE_TYPES = array('PluginDatainjectionCartridgeItemInjection' => 'datainjection', - 'PluginDatainjectionBudgetInjection' => 'datainjection', - 'PluginDatainjectionComputerInjection' => 'datainjection', - 'PluginDatainjectionComputer_ItemInjection' => 'datainjection', - 'PluginDatainjectionConsumableItemInjection' => 'datainjection', - 'PluginDatainjectionContactInjection' => 'datainjection', - 'PluginDatainjectionContact_SupplierInjection' => 'datainjection', - 'PluginDatainjectionContractInjection' => 'datainjection', - 'PluginDatainjectionContract_ItemInjection' => 'datainjection', - 'PluginDatainjectionContract_SupplierInjection' => 'datainjection', - //'PluginDatainjectionDocumentInjection' => 'datainjection', - 'PluginDatainjectionEntityInjection' => 'datainjection', - 'PluginDatainjectionGroupInjection' => 'datainjection', - 'PluginDatainjectionGroup_UserInjection' => 'datainjection', - 'PluginDatainjectionInfocomInjection' => 'datainjection', - 'PluginDatainjectionLocationInjection' => 'datainjection', - 'PluginDatainjectionStateInjection' => 'datainjection', - 'PluginDatainjectionManufacturerInjection' => 'datainjection', - 'PluginDatainjectionMonitorInjection' => 'datainjection', - 'PluginDatainjectionNetworkequipmentInjection' => 'datainjection', - 'PluginDatainjectionPeripheralInjection' => 'datainjection', - 'PluginDatainjectionPhoneInjection' => 'datainjection', - 'PluginDatainjectionPrinterInjection' => 'datainjection', - 'PluginDatainjectionProfileInjection' => 'datainjection', - 'PluginDatainjectionProfile_UserInjection' => 'datainjection', - 'PluginDatainjectionSoftwareInjection' => 'datainjection', - 'PluginDatainjectionComputer_SoftwareVersionInjection' => 'datainjection', - 'PluginDatainjectionComputer_SoftwareLicenseInjection' => 'datainjection', - 'PluginDatainjectionSoftwareLicenseInjection' => 'datainjection', - 'PluginDatainjectionSoftwareVersionInjection' => 'datainjection', - 'PluginDatainjectionSupplierInjection' => 'datainjection', - 'PluginDatainjectionUserInjection' => 'datainjection', - 'PluginDatainjectionNetworkportInjection' => 'datainjection', - 'PluginDatainjectionVlanInjection' => 'datainjection', - 'PluginDatainjectionNetworkport_VlanInjection' => 'datainjection', - 'PluginDatainjectionNetworkNameInjection' => 'datainjection', - 'PluginDatainjectionNetpointInjection' => 'datainjection', - 'PluginDatainjectionKnowbaseItemCategoryInjection' => 'datainjection', - 'PluginDatainjectionKnowbaseItemInjection' => 'datainjection', - 'PluginDatainjectionITILCategoryInjection' => 'datainjection', - 'PluginDatainjectionTaskCategoryInjection' => 'datainjection', - 'PluginDatainjectionSolutionTypeInjection' => 'datainjection', - 'PluginDatainjectionRequestTypeInjection' => 'datainjection', - 'PluginDatainjectionSolutionTemplateInjection' => 'datainjection', - 'PluginDatainjectionComputerTypeInjection' => 'datainjection', - 'PluginDatainjectionMonitorTypeInjection' => 'datainjection', - 'PluginDatainjectionNetworkEquipmentTypeInjection' => 'datainjection', - 'PluginDatainjectionPeripheralTypeInjection' => 'datainjection', - 'PluginDatainjectionPrinterTypeInjection' => 'datainjection', - 'PluginDatainjectionPhoneTypeInjection' => 'datainjection', - 'PluginDatainjectionSoftwareLicenseTypeInjection' => 'datainjection', - 'PluginDatainjectionContractTypeInjection' => 'datainjection', - 'PluginDatainjectionContactTypeInjection' => 'datainjection', - 'PluginDatainjectionSupplierTypeInjection' => 'datainjection', - 'PluginDatainjectionDeviceMemoryTypeInjection' => 'datainjection', - 'PluginDatainjectionInterfaceTypeInjection' => 'datainjection', - 'PluginDatainjectionPhonePowerSupplyTypeInjection' => 'datainjection', - 'PluginDatainjectionFilesystemTypeInjection' => 'datainjection', - 'PluginDatainjectionComputerModelInjection' => 'datainjection', - 'PluginDatainjectionMonitorModelInjection' => 'datainjection', - 'PluginDatainjectionPhoneModelInjection' => 'datainjection', - 'PluginDatainjectionPrinterModelInjection' => 'datainjection', - 'PluginDatainjectionPeripheralModelInjection' => 'datainjection', - 'PluginDatainjectionNetworkEquipmentModelInjection' => 'datainjection', - 'PluginDatainjectionNetworkEquipmentFirmwareInjection' => 'datainjection', - 'PluginDatainjectionVirtualMachineTypeInjection' => 'datainjection', - 'PluginDatainjectionVirtualMachineSystemInjection' => 'datainjection', - 'PluginDatainjectionVirtualMachineStateInjection' => 'datainjection', - 'PluginDatainjectionDocumentTypeInjection' => 'datainjection', - 'PluginDatainjectionAutoUpdateSystemInjection' => 'datainjection', - 'PluginDatainjectionOperatingSystemInjection' => 'datainjection', - 'PluginDatainjectionOperatingSystemVersionInjection' => 'datainjection', - 'PluginDatainjectionOperatingSystemServicePackInjection' => 'datainjection', - 'PluginDatainjectionNetworkInterfaceInjection' => 'datainjection', - 'PluginDatainjectionDomainInjection' => 'datainjection', - 'PluginDatainjectionNetworkInjection' => 'datainjection', - 'PluginDatainjectionDeviceCaseInjection' => 'datainjection', - 'PluginDatainjectionDeviceCaseTypeInjection' => 'datainjection', - 'PluginDatainjectionDeviceControlInjection' => 'datainjection', - 'PluginDatainjectionDeviceProcessorInjection' => 'datainjection', - 'PluginDatainjectionDeviceMemoryInjection' => 'datainjection', - 'PluginDatainjectionDeviceHardDriveInjection' => 'datainjection', - 'PluginDatainjectionDeviceMotherboardInjection' => 'datainjection', - 'PluginDatainjectionDeviceDriveInjection' => 'datainjection', - 'PluginDatainjectionDeviceNetworkCardInjection' => 'datainjection' - ); - //Add plugins - Plugin::doHook('plugin_datainjection_populate'); + $INJECTABLE_TYPES = ['PluginDatainjectionCartridgeItemInjection' => 'datainjection', + 'PluginDatainjectionBudgetInjection' => 'datainjection', + 'PluginDatainjectionComputerInjection' => 'datainjection', + 'PluginDatainjectionComputer_ItemInjection' => 'datainjection', + 'PluginDatainjectionConsumableItemInjection' => 'datainjection', + 'PluginDatainjectionContactInjection' => 'datainjection', + 'PluginDatainjectionContact_SupplierInjection' => 'datainjection', + 'PluginDatainjectionContractInjection' => 'datainjection', + 'PluginDatainjectionContract_ItemInjection' => 'datainjection', + 'PluginDatainjectionContract_SupplierInjection' => 'datainjection', + 'PluginDatainjectionEntityInjection' => 'datainjection', + 'PluginDatainjectionGroupInjection' => 'datainjection', + 'PluginDatainjectionGroup_UserInjection' => 'datainjection', + 'PluginDatainjectionInfocomInjection' => 'datainjection', + 'PluginDatainjectionLocationInjection' => 'datainjection', + 'PluginDatainjectionStateInjection' => 'datainjection', + 'PluginDatainjectionManufacturerInjection' => 'datainjection', + 'PluginDatainjectionMonitorInjection' => 'datainjection', + 'PluginDatainjectionNetworkequipmentInjection' => 'datainjection', + 'PluginDatainjectionPeripheralInjection' => 'datainjection', + 'PluginDatainjectionPhoneInjection' => 'datainjection', + 'PluginDatainjectionPrinterInjection' => 'datainjection', + 'PluginDatainjectionProfileInjection' => 'datainjection', + 'PluginDatainjectionProfile_UserInjection' => 'datainjection', + 'PluginDatainjectionSoftwareInjection' => 'datainjection', + 'PluginDatainjectionComputer_SoftwareVersionInjection' => 'datainjection', + 'PluginDatainjectionComputer_SoftwareLicenseInjection' => 'datainjection', + 'PluginDatainjectionSoftwareLicenseInjection' => 'datainjection', + 'PluginDatainjectionSoftwareVersionInjection' => 'datainjection', + 'PluginDatainjectionSupplierInjection' => 'datainjection', + 'PluginDatainjectionUserInjection' => 'datainjection', + 'PluginDatainjectionNetworkportInjection' => 'datainjection', + 'PluginDatainjectionVlanInjection' => 'datainjection', + 'PluginDatainjectionNetworkport_VlanInjection' => 'datainjection', + 'PluginDatainjectionNetworkNameInjection' => 'datainjection', + 'PluginDatainjectionNetpointInjection' => 'datainjection', + 'PluginDatainjectionKnowbaseItemCategoryInjection' => 'datainjection', + 'PluginDatainjectionKnowbaseItemInjection' => 'datainjection', + 'PluginDatainjectionITILCategoryInjection' => 'datainjection', + 'PluginDatainjectionTaskCategoryInjection' => 'datainjection', + 'PluginDatainjectionSolutionTypeInjection' => 'datainjection', + 'PluginDatainjectionRequestTypeInjection' => 'datainjection', + 'PluginDatainjectionSolutionTemplateInjection' => 'datainjection', + 'PluginDatainjectionComputerTypeInjection' => 'datainjection', + 'PluginDatainjectionMonitorTypeInjection' => 'datainjection', + 'PluginDatainjectionNetworkEquipmentTypeInjection' => 'datainjection', + 'PluginDatainjectionPeripheralTypeInjection' => 'datainjection', + 'PluginDatainjectionPrinterTypeInjection' => 'datainjection', + 'PluginDatainjectionPhoneTypeInjection' => 'datainjection', + 'PluginDatainjectionSoftwareLicenseTypeInjection' => 'datainjection', + 'PluginDatainjectionContractTypeInjection' => 'datainjection', + 'PluginDatainjectionContactTypeInjection' => 'datainjection', + 'PluginDatainjectionSupplierTypeInjection' => 'datainjection', + 'PluginDatainjectionDeviceMemoryTypeInjection' => 'datainjection', + 'PluginDatainjectionInterfaceTypeInjection' => 'datainjection', + 'PluginDatainjectionPhonePowerSupplyTypeInjection' => 'datainjection', + 'PluginDatainjectionFilesystemTypeInjection' => 'datainjection', + 'PluginDatainjectionComputerModelInjection' => 'datainjection', + 'PluginDatainjectionMonitorModelInjection' => 'datainjection', + 'PluginDatainjectionPhoneModelInjection' => 'datainjection', + 'PluginDatainjectionPrinterModelInjection' => 'datainjection', + 'PluginDatainjectionPeripheralModelInjection' => 'datainjection', + 'PluginDatainjectionNetworkEquipmentModelInjection' => 'datainjection', + 'PluginDatainjectionNetworkEquipmentFirmwareInjection' => 'datainjection', + 'PluginDatainjectionVirtualMachineTypeInjection' => 'datainjection', + 'PluginDatainjectionVirtualMachineSystemInjection' => 'datainjection', + 'PluginDatainjectionVirtualMachineStateInjection' => 'datainjection', + 'PluginDatainjectionDocumentTypeInjection' => 'datainjection', + 'PluginDatainjectionAutoUpdateSystemInjection' => 'datainjection', + 'PluginDatainjectionOperatingSystemInjection' => 'datainjection', + 'PluginDatainjectionOperatingSystemVersionInjection' => 'datainjection', + 'PluginDatainjectionOperatingSystemServicePackInjection' => 'datainjection', + 'PluginDatainjectionNetworkInterfaceInjection' => 'datainjection', + 'PluginDatainjectionDomainInjection' => 'datainjection', + 'PluginDatainjectionNetworkInjection' => 'datainjection', + 'PluginDatainjectionDeviceCaseInjection' => 'datainjection', + 'PluginDatainjectionDeviceCaseTypeInjection' => 'datainjection', + 'PluginDatainjectionDeviceControlInjection' => 'datainjection', + 'PluginDatainjectionDeviceProcessorInjection' => 'datainjection', + 'PluginDatainjectionDeviceMemoryInjection' => 'datainjection', + 'PluginDatainjectionDeviceHardDriveInjection' => 'datainjection', + 'PluginDatainjectionDeviceMotherboardInjection' => 'datainjection', + 'PluginDatainjectionDeviceDriveInjection' => 'datainjection', + 'PluginDatainjectionDeviceNetworkCardInjection' => 'datainjection' + ]; + //Add plugins + Plugin::doHook('plugin_datainjection_populate'); } function plugin_datainjection_migratetypes_datainjection($types) { - $types[996] = 'NetworkPort'; - $types[999] = 'NetworkPort'; - return $types; + $types[996] = 'NetworkPort'; + $types[999] = 'NetworkPort'; + return $types; } function plugin_datainjection_checkDirectories() { - $plugin = new Plugin(); + + $plugin = new Plugin(); if ($plugin->isInstalled('datainjection') - && (!file_exists(PLUGIN_DATAINJECTION_UPLOAD_DIR) - || !is_writable(PLUGIN_DATAINJECTION_UPLOAD_DIR))) { + && (!file_exists(PLUGIN_DATAINJECTION_UPLOAD_DIR) + || !is_writable(PLUGIN_DATAINJECTION_UPLOAD_DIR)) + ) { return false; } - return true; + return true; } -?> diff --git a/testwebservice.php b/testwebservice.php index 4dcc4103..89b614b0 100644 --- a/testwebservice.php +++ b/testwebservice.php @@ -38,9 +38,9 @@ $args = array(); if ($_SERVER['argc'] > 1) { - for ($i=1 ; $i \ No newline at end of file diff --git a/tools/move_to_po.php b/tools/move_to_po.php deleted file mode 100644 index 6557e4f7..00000000 --- a/tools/move_to_po.php +++ /dev/null @@ -1,308 +0,0 @@ -. - -------------------------------------------------------------------------- - @package datainjection - @author the datainjection plugin team - @copyright Copyright (c) 2010-2017 Datainjection plugin team - @license GPLv2+ - http://www.gnu.org/licenses/gpl.txt - @link https://github.com/pluginsGLPI/datainjection - @link http://www.glpi-project.org/ - @since 2009 - */ - -// ---------------------------------------------------------------------- -// Original Author of file: Julien Dombre -// Purpose of file: -// ---------------------------------------------------------------------- - -chdir(dirname($_SERVER["SCRIPT_FILENAME"])); - -if ($argv) { - for ($i=1 ; $i'.$sing_trans.' '.$current_string_plural.'->'.$plural_trans."\n"; - if (!strlen($sing_trans) || !strlen($plural_trans)) { -// echo "clean\n"; - $sing_trans = ''; - $plural_trans = ''; - } - $content = "msgstr[0] \"$sing_trans\"\n"; - $content .= "msgstr[1] \"$plural_trans\"\n"; - } - } else { - $content=''; - } - } - $context = ''; - } - // Standard replacement - $content = preg_replace('/charset=CHARSET/','charset=UTF-8',$content); - - if (preg_match('/Plural-Forms/',$content)) { - $content = "\"Plural-Forms: nplurals=2; plural=(n != 1)\\n\"\n"; - } - - if (fwrite($po, $content) === FALSE) { - echo "unable to write in po file"; - exit; - } - - } -} -fclose($pot); -fclose($po); - - -function search_in_dict($string, $context) { - global $REFLANG, $LANG; - - if ($context) { - $string = "$context/$string"; - } - - $ponctmatch = "([\.: \(\)]*)"; - $varmatch = "(%s)*"; - - if (preg_match("/$varmatch$ponctmatch(.*)$ponctmatch$varmatch$/U",$string,$reg)) { -// print_r($reg); - $left = $reg[1]; - $left .= $reg[2]; - $string = $reg[3]; - $right = $reg[4]; - if (isset($reg[5])) { - $right .= $reg[5]; - } - } - -// echo $left.' <- '.$string.' -> '.$right."\n"; - foreach ($REFLANG as $mod => $data) { - - foreach ($data as $key => $val) { - - if (!is_array($val)){ - if (!isset($LANG[$mod][$key])) { - continue; - } - - // Search same case with punc - if (strcmp($val,$left.$string.$right) === 0) { - return $LANG[$mod][$key]; - } - // Search same case with punc - if (strcasecmp($val,$left.$string.$right) === 0) { - return $LANG[$mod][$key]; - } - - // Search same case with left punc - if (strcmp($val,$left.$string) === 0) { - return $LANG[$mod][$key].$right; - } - // Search same case with left punc - if (strcasecmp($val,$left.$string) === 0) { - return $LANG[$mod][$key].$right; - } - - // Search same case with right punc - if (strcmp($val,$string.$right) === 0) { - return $left.$LANG[$mod][$key]; - } - // Search same case with right punc - if (strcasecmp($val,$string.$right) === 0) { - return $left.$LANG[$mod][$key]; - } - - // Search same case without punc - if (strcmp($val,$string) === 0) { - return $left.$LANG[$mod][$key].$right; - } - // Search non case sensitive - if (strcasecmp($val,$string) === 0) { - return $left.$LANG[$mod][$key].$right; - } - } else { - //toolbox::logdebug($val); - //toolbox::logdebug($key); - //toolbox::logdebug($mod); - foreach ($val as $k => $v) { - if (!isset($LANG[$mod][$key][$k])) { - continue; - } - - // Search same case with punc - if (strcmp($v,$left.$string.$right) === 0) { - return $LANG[$mod][$key][$k]; - } - // Search same case with punc - if (strcasecmp($v,$left.$string.$right) === 0) { - return $LANG[$mod][$key][$k]; - } - - // Search same case with left punc - if (strcmp($v,$left.$string) === 0) { - return $LANG[$mod][$key][$k].$right; - } - // Search same case with left punc - if (strcasecmp($v,$left.$string) === 0) { - return $LANG[$mod][$key][$k].$right; - } - - // Search same case with right punc - if (strcmp($v,$string.$right) === 0) { - return $left.$LANG[$mod][$key][$k]; - } - // Search same case with right punc - if (strcasecmp($v,$string.$right) === 0) { - return $left.$LANG[$mod][$key][$k]; - } - - // Search same case without punc - if (strcmp($v,$string) === 0) { - return $left.$LANG[$mod][$key][$k].$right; - } - // Search non case sensitive - if (strcasecmp($v,$string) === 0) { - return $left.$LANG[$mod][$key][$k].$right; - } - } - } - } - } - - return ""; -} -?> \ No newline at end of file From d6392a48a5b69ad53843af8fffdd70ef922a47ca Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Mon, 6 Feb 2017 16:20:44 +0100 Subject: [PATCH 11/27] Should work on GLPI 9.2 --- setup.php | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.php b/setup.php index d36eb2d0..9b6975bf 100644 --- a/setup.php +++ b/setup.php @@ -98,7 +98,6 @@ function plugin_version_datainjection() { function plugin_datainjection_check_prerequisites() { if (version_compare(GLPI_VERSION, '0.85', 'lt') - || version_compare(GLPI_VERSION, '9.2', 'ge') ) { _e('This plugin requires GLPI 0.85 or higher', 'datainjection'); return false; From c4417258ae6faca9f520620baa6c6b455a6dc07b Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Wed, 8 Feb 2017 14:32:27 +0100 Subject: [PATCH 12/27] Use external tools project --- .travis.yml | 63 +- RoboFile.php | 4 +- RoboFilePlugin.php | 142 ----- composer.json | 7 +- composer.lock | 1217 +++++++++++++++++++++++++++++++++++++ tools/extract_template.sh | 21 - tools/modify_headers.pl | 102 ---- tools/phpcs-rules.xml | 22 - tools/release | 680 --------------------- tools/update_mo.pl | 29 - tools/update_po.pl | 30 - 11 files changed, 1247 insertions(+), 1070 deletions(-) delete mode 100644 RoboFilePlugin.php create mode 100644 composer.lock delete mode 100755 tools/extract_template.sh delete mode 100755 tools/modify_headers.pl delete mode 100644 tools/phpcs-rules.xml delete mode 100755 tools/release delete mode 100644 tools/update_mo.pl delete mode 100644 tools/update_po.pl diff --git a/.travis.yml b/.travis.yml index ec7693e6..f2963c95 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,52 +1,39 @@ language: php +php: + - 5.5 + - 5.6 + - 7.0 + - 7.1 + - nightly -env: - - DB=mysql +#env: +# global: +# - DB=mysql +# matrix: +# - GLPIVER=9.1/bugfixes +# - GLPIVER=master before_script: - composer self-update - - if [[ ${TRAVIS_PHP_VERSION:0:3} == "5.4" ]]; then sed -e "s|.*"consolidation/robo".*$||" -i composer.json && composer update; fi - - composer install -o +# - git clone --depth=1 https://github.com/glpi-project/glpi -b $GLPIVER ../glpi && cd ../glpi +# - composer install --no-dev # - mysql -u root -e 'create database glpitest;' -# - php tools/cliinstall.php --lang=en_US --db=glpitest --user=root --tests +# - php tools/cliinstall.php --db=glpi-test --user=travis --tests +# - mv ../{LNAME} plugins/{LNAME} +# - cd plugins/{LNAME} + - composer install -o + script: + - vendor/bin/robo --no-interaction code:cs # - mysql -u root -e 'select version();' -# - phpunit --verbose - - vendor/bin/phpcs -p --ignore=vendor --ignore=js --standard=vendor/glpi-project/coding-standard/GlpiStandard/ . +# - ./vendor/bin/atoum -bf tests/bootstrap.php -d tests/units/ + matrix: - include: - - php: 5.4 - addons: - mariadb: 5.5 - - php: 5.5 - addons: - mariadb: 5.5 -# - php: 5.6 -# addons: -# mariadb: 5.5 -# - php: 5.6 -# addons: -# mariadb: 10.0 - - php: 5.6 - addons: - mariadb: 10.1 -# - php: 7.0 -# addons: -# mariadb: 10.0 - - php: 7.0 - addons: - mariadb: 10.1 -# - php: 7.1 -# addons: -# mariadb: 10.0 - - php: 7.1 - addons: - mariadb: 10.1 - - php: nightly - addons: - mariadb: 10.1 +# exclude: +# - php: 5.4 +# env: GLPIVER=master allow_failures: - php: nightly diff --git a/RoboFile.php b/RoboFile.php index 047d37ad..f6360f5a 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -5,9 +5,9 @@ * @see http://robo.li/ */ -require_once 'RoboFilePlugin.php'; +require_once 'vendor/autoload.php'; -class RoboFile extends RoboFilePlugin +class RoboFile extends Glpi\Tools\RoboFile { //Own plugin's robo stuff } diff --git a/RoboFilePlugin.php b/RoboFilePlugin.php deleted file mode 100644 index 9f017970..00000000 --- a/RoboFilePlugin.php +++ /dev/null @@ -1,142 +0,0 @@ -minifyCSS() - ->minifyJS(); - } - - /** - * Minify CSS stylesheets - * - * @return void - */ - public function minifyCSS() { - $css_dir = __DIR__ . '/css'; - if (is_dir($css_dir)) { - foreach (glob("$css_dir/*.css") as $css_file) { - if (!$this->endsWith($css_file, 'min.css')) { - $this->taskMinify($css_file) - ->to(str_replace('.css', '.min.css', $css_file)) - ->type('css') - ->run(); - } - } - } - return $this; - } - - /** - * Minify JavaScript files stylesheets - * - * @return void - */ - public function minifyJS() { - $js_dir = __DIR__ . '/js'; - if (is_dir($js_dir)) { - foreach (glob("$js_dir/*.js") as $js_file) { - if (!$this->endsWith($js_file, 'min.js')) { - $this->taskMinify($js_file) - ->to(str_replace('.js', '.min.js', $js_file)) - ->type('js') - ->run(); - } - } - } - return $this; - } - - /** - * Extract translatable strings - * - * @return void - */ - public function localesExtract() { - $this->_exec('tools/extract_template.sh'); - return $this; - } - - /** - * Push locales to transifex - * - * @return void - */ - public function localesPush() { - $this->_exec('tx push -s'); - return $this; - } - - /** - * Pull locales from transifex. - * - * @param integer $percent Completeness percentage - * - * @return void - */ - public function localesPull($percent = 70) { - $this->_exec('tx pull -a --minimum-perc=' .$percent); - return $this; - } - - /** - * Build MO files - * - * @return void - */ - public function localesMo() { - $this->_exec('./tools/release --compile-mo'); - return $this; - } - - /** - * Extract and send locales - * - * @return void - */ - public function localesSend() { - $this->localesExtract() - ->localesPush(); - return $this; - } - - /** - * Retrieve locales and generate mo files - * - * @param integer $percent Completeness percentage - * - * @return void - */ - public function localesGenerate($percent = 70) { - $this->localesPull($percent) - ->localesMo(); - return $this; - } - - /** - * Checks if a string ends with another string - * - * @param string $haystack Full string - * @param string $needle Ends string - * - * @return boolean - * @see http://stackoverflow.com/a/834355 - */ - private function endsWith($haystack, $needle) { - $length = strlen($needle); - if ($length == 0) { - return true; - } - - return (substr($haystack, -$length) === $needle); - } -} diff --git a/composer.json b/composer.json index d7815a6a..1ac36cb3 100644 --- a/composer.json +++ b/composer.json @@ -1,8 +1,7 @@ { + "minimum-stability": "dev", + "prefer-stable": true, "require-dev": { - "consolidation/robo": "dev-master@dev", - "patchwork/jsqueeze": "~1.0", - "natxet/CssMin": "~3.0", - "glpi-project/coding-standard": "0.5" + "glpi-project/tools": "^0.1.0" } } diff --git a/composer.lock b/composer.lock new file mode 100644 index 00000000..df8bdc91 --- /dev/null +++ b/composer.lock @@ -0,0 +1,1217 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "content-hash": "8a6db7f45e083d6f582cc8949facfebb", + "packages": [], + "packages-dev": [ + { + "name": "consolidation/annotated-command", + "version": "2.4.0", + "source": { + "type": "git", + "url": "https://github.com/consolidation/annotated-command.git", + "reference": "80afffd362bd1cf83bef60db690a8c50d8390803" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/consolidation/annotated-command/zipball/80afffd362bd1cf83bef60db690a8c50d8390803", + "reference": "80afffd362bd1cf83bef60db690a8c50d8390803", + "shasum": "" + }, + "require": { + "consolidation/output-formatters": "^3.1.5", + "php": ">=5.4.0", + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2", + "psr/log": "~1", + "symfony/console": "^2.8|~3", + "symfony/event-dispatcher": "^2.5|~3", + "symfony/finder": "^2.5|~3" + }, + "require-dev": { + "phpunit/phpunit": "4.*", + "satooshi/php-coveralls": "^1.0", + "squizlabs/php_codesniffer": "^2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Consolidation\\AnnotatedCommand\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Greg Anderson", + "email": "greg.1.anderson@greenknowe.org" + } + ], + "description": "Initialize Symfony Console commands from annotated command class methods.", + "time": "2017-02-04T06:13:54+00:00" + }, + { + "name": "consolidation/log", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/consolidation/log.git", + "reference": "74ba81b4edc585616747cc5c5309ce56fec41254" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/consolidation/log/zipball/74ba81b4edc585616747cc5c5309ce56fec41254", + "reference": "74ba81b4edc585616747cc5c5309ce56fec41254", + "shasum": "" + }, + "require": { + "php": ">=5.5.0", + "psr/log": "~1.0", + "symfony/console": "~2.5|~3.0" + }, + "require-dev": { + "phpunit/phpunit": "4.*", + "squizlabs/php_codesniffer": "2.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Consolidation\\Log\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Greg Anderson", + "email": "greg.1.anderson@greenknowe.org" + } + ], + "description": "Improved Psr-3 / Psr\\Log logger based on Symfony Console components.", + "time": "2016-03-23T23:46:42+00:00" + }, + { + "name": "consolidation/output-formatters", + "version": "3.1.7", + "source": { + "type": "git", + "url": "https://github.com/consolidation/output-formatters.git", + "reference": "da39a0f14d5aaaee06732bb7cef2aea1de056b40" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/consolidation/output-formatters/zipball/da39a0f14d5aaaee06732bb7cef2aea1de056b40", + "reference": "da39a0f14d5aaaee06732bb7cef2aea1de056b40", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "symfony/console": "~2.5|~3.0", + "symfony/finder": "~2.5|~3.0" + }, + "require-dev": { + "phpunit/phpunit": "4.*", + "satooshi/php-coveralls": "^1.0", + "squizlabs/php_codesniffer": "2.*", + "victorjonsson/markdowndocs": "^1.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Consolidation\\OutputFormatters\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Greg Anderson", + "email": "greg.1.anderson@greenknowe.org" + } + ], + "description": "Format text by applying transformations provided by plug-in formatters.", + "time": "2017-01-21T06:26:40+00:00" + }, + { + "name": "consolidation/robo", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/consolidation/Robo.git", + "reference": "cdc15c0059a1b2d5287910df678e8a73cbaa8ed6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/consolidation/Robo/zipball/cdc15c0059a1b2d5287910df678e8a73cbaa8ed6", + "reference": "cdc15c0059a1b2d5287910df678e8a73cbaa8ed6", + "shasum": "" + }, + "require": { + "consolidation/annotated-command": "^2.2", + "consolidation/log": "~1", + "consolidation/output-formatters": "^3.1.5", + "league/container": "^2.2", + "php": ">=5.5.0", + "symfony/console": "~2.8|~3.0", + "symfony/event-dispatcher": "~2.5|~3.0", + "symfony/filesystem": "~2.5|~3.0", + "symfony/finder": "~2.5|~3.0", + "symfony/process": "~2.5|~3.0" + }, + "replace": { + "codegyre/robo": "< 1.0" + }, + "require-dev": { + "codeception/aspect-mock": "~1", + "codeception/base": "^2.2.6", + "codeception/verify": "^0.3.2", + "henrikbjorn/lurker": "~1", + "natxet/cssmin": "~3", + "patchwork/jsqueeze": "~2", + "pear/archive_tar": "^1.4.2", + "phpunit/php-code-coverage": "~2|~4", + "satooshi/php-coveralls": "~1", + "squizlabs/php_codesniffer": "~2" + }, + "suggest": { + "henrikbjorn/lurker": "For monitoring filesystem changes in taskWatch", + "natxet/CssMin": "For minifying JS files in taskMinify", + "patchwork/jsqueeze": "For minifying JS files in taskMinify", + "pear/archive_tar": "Allows tar archives to be created and extracted in taskPack and taskExtract, respectively." + }, + "bin": [ + "robo" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "classmap": [ + "scripts/composer/ScriptHandler.php" + ], + "psr-4": { + "Robo\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Davert", + "email": "davert.php@resend.cc" + } + ], + "description": "Modern task runner", + "time": "2017-02-08T01:45:50+00:00" + }, + { + "name": "container-interop/container-interop", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/container-interop/container-interop.git", + "reference": "fc08354828f8fd3245f77a66b9e23a6bca48297e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/container-interop/container-interop/zipball/fc08354828f8fd3245f77a66b9e23a6bca48297e", + "reference": "fc08354828f8fd3245f77a66b9e23a6bca48297e", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "Interop\\Container\\": "src/Interop/Container/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Promoting the interoperability of container objects (DIC, SL, etc.)", + "time": "2014-12-30T15:22:37+00:00" + }, + { + "name": "glpi-project/coding-standard", + "version": "0.5", + "source": { + "type": "git", + "url": "https://github.com/glpi-project/coding-standard.git", + "reference": "e19495c896a01199a2fec2e65b7613310598cf96" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/glpi-project/coding-standard/zipball/e19495c896a01199a2fec2e65b7613310598cf96", + "reference": "e19495c896a01199a2fec2e65b7613310598cf96", + "shasum": "" + }, + "require": { + "squizlabs/php_codesniffer": "~2.0" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPLv3" + ], + "authors": [ + { + "name": "Teclib'", + "email": "contact@teclib.com", + "homepage": "https://teclib.com" + } + ], + "description": "GLPI PHP CodeSniffer Coding Standard", + "keywords": [ + "codesniffer", + "glpi", + "phpcs" + ], + "time": "2017-01-06T11:10:46+00:00" + }, + { + "name": "glpi-project/tools", + "version": "0.1.1", + "source": { + "type": "git", + "url": "https://github.com/glpi-project/tools.git", + "reference": "89083f6e71fac05190c7cc76a9c5afd8b1f421ef" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/glpi-project/tools/zipball/89083f6e71fac05190c7cc76a9c5afd8b1f421ef", + "reference": "89083f6e71fac05190c7cc76a9c5afd8b1f421ef", + "shasum": "" + }, + "require": { + "consolidation/robo": "dev-master@dev", + "glpi-project/coding-standard": "0.5", + "natxet/cssmin": "~3.0", + "patchwork/jsqueeze": "~1.0" + }, + "bin": [ + "tools/plugin-release", + "tools/extract_template.sh", + "tools/modify_headers.pl" + ], + "type": "library", + "autoload": { + "psr-4": { + "Glpi\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPLv3" + ], + "authors": [ + { + "name": "Teclib'", + "email": "glpi@teclib.com", + "homepage": "https://teclib.com" + } + ], + "description": "Various tools for GLPI and its plugins", + "keywords": [ + "glpi", + "plugins", + "tools" + ], + "time": "2017-02-08T08:20:09+00:00" + }, + { + "name": "league/container", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/container.git", + "reference": "c0e7d947b690891f700dc4967ead7bdb3d6708c1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/container/zipball/c0e7d947b690891f700dc4967ead7bdb3d6708c1", + "reference": "c0e7d947b690891f700dc4967ead7bdb3d6708c1", + "shasum": "" + }, + "require": { + "container-interop/container-interop": "^1.1", + "php": ">=5.4.0" + }, + "provide": { + "container-interop/container-interop-implementation": "^1.1" + }, + "replace": { + "orno/di": "~2.0" + }, + "require-dev": { + "phpunit/phpunit": "4.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev", + "dev-1.x": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "League\\Container\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Phil Bennett", + "email": "philipobenito@gmail.com", + "homepage": "http://www.philipobenito.com", + "role": "Developer" + } + ], + "description": "A fast and intuitive dependency injection container.", + "homepage": "https://github.com/thephpleague/container", + "keywords": [ + "container", + "dependency", + "di", + "injection", + "league", + "provider", + "service" + ], + "time": "2016-03-17T11:07:59+00:00" + }, + { + "name": "natxet/CssMin", + "version": "v3.0.4", + "source": { + "type": "git", + "url": "https://github.com/natxet/CssMin.git", + "reference": "92de3fe3ccb4f8298d31952490ef7d5395855c39" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/natxet/CssMin/zipball/92de3fe3ccb4f8298d31952490ef7d5395855c39", + "reference": "92de3fe3ccb4f8298d31952490ef7d5395855c39", + "shasum": "" + }, + "require": { + "php": ">=5.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Joe Scylla", + "email": "joe.scylla@gmail.com", + "homepage": "https://profiles.google.com/joe.scylla" + } + ], + "description": "Minifying CSS", + "homepage": "http://code.google.com/p/cssmin/", + "keywords": [ + "css", + "minify" + ], + "time": "2015-09-25T11:13:11+00:00" + }, + { + "name": "patchwork/jsqueeze", + "version": "v1.0.7", + "source": { + "type": "git", + "url": "https://github.com/tchwork/jsqueeze.git", + "reference": "f90a933213534b93e4ff3c2c3026ff7458f7721b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/tchwork/jsqueeze/zipball/f90a933213534b93e4ff3c2c3026ff7458f7721b", + "reference": "f90a933213534b93e4ff3c2c3026ff7458f7721b", + "shasum": "" + }, + "require": { + "php": ">=5.1.4" + }, + "type": "library", + "autoload": { + "psr-0": { + "JSqueeze": "class/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "(Apache-2.0 or GPL-2.0)" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + } + ], + "description": "Efficient JavaScript minification in PHP", + "homepage": "https://github.com/tchwork/jsqueeze", + "keywords": [ + "compression", + "javascript", + "minification" + ], + "time": "2015-03-25T10:11:08+00:00" + }, + { + "name": "phpdocumentor/reflection-common", + "version": "1.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/144c307535e82c8fdcaacbcfc1d6d8eeb896687c", + "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c", + "shasum": "" + }, + "require": { + "php": ">=5.5" + }, + "require-dev": { + "phpunit/phpunit": "^4.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "time": "2015-12-27T11:43:31+00:00" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "3.1.1", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/8331b5efe816ae05461b7ca1e721c01b46bafb3e", + "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e", + "shasum": "" + }, + "require": { + "php": ">=5.5", + "phpdocumentor/reflection-common": "^1.0@dev", + "phpdocumentor/type-resolver": "^0.2.0", + "webmozart/assert": "^1.0" + }, + "require-dev": { + "mockery/mockery": "^0.9.4", + "phpunit/phpunit": "^4.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "time": "2016-09-30T07:12:33+00:00" + }, + { + "name": "phpdocumentor/type-resolver", + "version": "0.2.1", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/TypeResolver.git", + "reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb", + "reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb", + "shasum": "" + }, + "require": { + "php": ">=5.5", + "phpdocumentor/reflection-common": "^1.0" + }, + "require-dev": { + "mockery/mockery": "^0.9.4", + "phpunit/phpunit": "^5.2||^4.8.24" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "time": "2016-11-25T06:54:22+00:00" + }, + { + "name": "psr/log", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2016-10-10T12:19:37+00:00" + }, + { + "name": "squizlabs/php_codesniffer", + "version": "2.8.0", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "86dd55a522238211f9f3631e3361703578941d9a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/86dd55a522238211f9f3631e3361703578941d9a", + "reference": "86dd55a522238211f9f3631e3361703578941d9a", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "bin": [ + "scripts/phpcs", + "scripts/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "autoload": { + "classmap": [ + "CodeSniffer.php", + "CodeSniffer/CLI.php", + "CodeSniffer/Exception.php", + "CodeSniffer/File.php", + "CodeSniffer/Fixer.php", + "CodeSniffer/Report.php", + "CodeSniffer/Reporting.php", + "CodeSniffer/Sniff.php", + "CodeSniffer/Tokens.php", + "CodeSniffer/Reports/", + "CodeSniffer/Tokenizers/", + "CodeSniffer/DocGenerators/", + "CodeSniffer/Standards/AbstractPatternSniff.php", + "CodeSniffer/Standards/AbstractScopeSniff.php", + "CodeSniffer/Standards/AbstractVariableSniff.php", + "CodeSniffer/Standards/IncorrectPatternException.php", + "CodeSniffer/Standards/Generic/Sniffs/", + "CodeSniffer/Standards/MySource/Sniffs/", + "CodeSniffer/Standards/PEAR/Sniffs/", + "CodeSniffer/Standards/PSR1/Sniffs/", + "CodeSniffer/Standards/PSR2/Sniffs/", + "CodeSniffer/Standards/Squiz/Sniffs/", + "CodeSniffer/Standards/Zend/Sniffs/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "http://www.squizlabs.com/php-codesniffer", + "keywords": [ + "phpcs", + "standards" + ], + "time": "2017-02-02T03:30:00+00:00" + }, + { + "name": "symfony/console", + "version": "v3.2.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "7a8405a9fc175f87fed8a3c40856b0d866d61936" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/7a8405a9fc175f87fed8a3c40856b0d866d61936", + "reference": "7a8405a9fc175f87fed8a3c40856b0d866d61936", + "shasum": "" + }, + "require": { + "php": ">=5.5.9", + "symfony/debug": "~2.8|~3.0", + "symfony/polyfill-mbstring": "~1.0" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/event-dispatcher": "~2.8|~3.0", + "symfony/filesystem": "~2.8|~3.0", + "symfony/process": "~2.8|~3.0" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/filesystem": "", + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "https://symfony.com", + "time": "2017-02-06T12:04:21+00:00" + }, + { + "name": "symfony/debug", + "version": "v3.2.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/debug.git", + "reference": "b4d9818f127c60ce21ed62c395da7df868dc8477" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/debug/zipball/b4d9818f127c60ce21ed62c395da7df868dc8477", + "reference": "b4d9818f127c60ce21ed62c395da7df868dc8477", + "shasum": "" + }, + "require": { + "php": ">=5.5.9", + "psr/log": "~1.0" + }, + "conflict": { + "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" + }, + "require-dev": { + "symfony/class-loader": "~2.8|~3.0", + "symfony/http-kernel": "~2.8|~3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Debug\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Debug Component", + "homepage": "https://symfony.com", + "time": "2017-01-28T02:37:08+00:00" + }, + { + "name": "symfony/event-dispatcher", + "version": "v3.2.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "9137eb3a3328e413212826d63eeeb0217836e2b6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/9137eb3a3328e413212826d63eeeb0217836e2b6", + "reference": "9137eb3a3328e413212826d63eeeb0217836e2b6", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~2.8|~3.0", + "symfony/dependency-injection": "~2.8|~3.0", + "symfony/expression-language": "~2.8|~3.0", + "symfony/stopwatch": "~2.8|~3.0" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\EventDispatcher\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony EventDispatcher Component", + "homepage": "https://symfony.com", + "time": "2017-01-02T20:32:22+00:00" + }, + { + "name": "symfony/filesystem", + "version": "v3.2.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "a0c6ef2dc78d33b58d91d3a49f49797a184d06f4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/a0c6ef2dc78d33b58d91d3a49f49797a184d06f4", + "reference": "a0c6ef2dc78d33b58d91d3a49f49797a184d06f4", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Filesystem Component", + "homepage": "https://symfony.com", + "time": "2017-01-08T20:47:33+00:00" + }, + { + "name": "symfony/finder", + "version": "v3.2.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "8c71141cae8e2957946b403cc71a67213c0380d6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/8c71141cae8e2957946b403cc71a67213c0380d6", + "reference": "8c71141cae8e2957946b403cc71a67213c0380d6", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Finder Component", + "homepage": "https://symfony.com", + "time": "2017-01-02T20:32:22+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/e79d363049d1c2128f133a2667e4f4190904f7f4", + "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "time": "2016-11-14T01:06:16+00:00" + }, + { + "name": "symfony/process", + "version": "v3.2.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/process.git", + "reference": "32646a7cf53f3956c76dcb5c82555224ae321858" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/process/zipball/32646a7cf53f3956c76dcb5c82555224ae321858", + "reference": "32646a7cf53f3956c76dcb5c82555224ae321858", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Process\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Process Component", + "homepage": "https://symfony.com", + "time": "2017-02-03T12:11:38+00:00" + }, + { + "name": "webmozart/assert", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/webmozart/assert.git", + "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozart/assert/zipball/2db61e59ff05fe5126d152bd0655c9ea113e550f", + "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.6", + "sebastian/version": "^1.0.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ], + "time": "2016-11-23T20:04:58+00:00" + } + ], + "aliases": [], + "minimum-stability": "dev", + "stability-flags": [], + "prefer-stable": true, + "prefer-lowest": false, + "platform": [], + "platform-dev": [] +} diff --git a/tools/extract_template.sh b/tools/extract_template.sh deleted file mode 100755 index 3a2b67b5..00000000 --- a/tools/extract_template.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -soft='GLPI - Datainjection plugin' -version='2.2.0' -email='glpi-translation@gna.org' -copyright='INDEPNET Development Team' - -#xgettext *.php */*.php -copyright-holder='$copyright' --package-name=$soft --package-version=$version --msgid-bugs-address=$email -o locales/en_GB.po -L PHP --from-code=UTF-8 --force-po -i --keyword=_n:1,2 --keyword=__ --keyword=_e - -# Only strings with domain specified are extracted (use Xt args of keyword param to set number of args needed) - -xgettext *.php */*.php --copyright-holder='Datainjection Development Team' --package-name='GLPI - Datainjection plugin' --package-version='2.3.0' -o locales/glpi.pot -L PHP --add-comments=TRANS --from-code=UTF-8 --force-po \ - --keyword=_n:1,2,4t --keyword=__s:1,2t --keyword=__:1,2t --keyword=_e:1,2t --keyword=_x:1c,2,3t \ - --keyword=_ex:1c,2,3t --keyword=_nx:1c,2,3,5t --keyword=_sx:1c,2,3t - -### for using tx : -##tx set --execute --auto-local -r GLPI_ocsinventoryng.glpi_ocsinventoryng-version-100 'locales/.po' --source-lang en --source-file locales/glpi.pot -## tx push -s -## tx pull -a - - diff --git a/tools/modify_headers.pl b/tools/modify_headers.pl deleted file mode 100755 index 71719e28..00000000 --- a/tools/modify_headers.pl +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/perl -#!/usr/bin/perl -w - -# ---------------------------------------------------------------------- -# GLPI - Gestionnaire Libre de Parc Informatique -# Copyright (C) 2003-2006 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, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# ------------------------------------------------------------------------ - - -do_dir(".."); - - -sub do_dir{ -local ($dir)=@_; -print "Entering $dir\n"; - -opendir(DIRHANDLE,$dir)||die "ERROR: can not read current directory\n"; -foreach (readdir(DIRHANDLE)){ - if ($_ ne '..' && $_ ne '.'){ - if (-d "$dir/$_"){ - if ($_ !~ m/.svn/i && $_ !~ m/CVS/i && $_ !~ m/lib/i){ - - do_dir("$dir/$_"); - } - } else { - if(!(-l "$dir/$_")){ - if ((index($_,".php",0)!=-1)||(index($_,".txt",0)!=-1)||(index($_,".css",0)!=-1)){ - do_file("$dir/$_"); - } - } - } - } -} -closedir DIRHANDLE; - -} - -sub do_file{ - local ($file)=@_; - print $file."\n"; - ### DELETE HEADERS - open(INIT_FILE,$file); - @lines=; - close(INIT_FILE); - - open(TMP_FILE,">/tmp/tmp_glpi.txt"); - - $status=''; - foreach (@lines){ - if ($_ =~ m/\*\//){ - $status="END"; - } - - if ($status =~ m/END/||$status !~ m/BEGIN/){ - print TMP_FILE $_; - } - - if ($status !~ m/END/){ - if ($_ =~ m/\/\*/){ - $status="BEGIN"; - ##### ADD NEW HEADERS - open(HEADER_FILE,"HEADER"); - @headers=; - foreach (@headers){ - print TMP_FILE $_; - } - close(HEADER_FILE) ; - - } - } - } - close(TMP_FILE); - - system("cp -f /tmp/tmp_glpi.txt $file"); - - - -} - - - diff --git a/tools/phpcs-rules.xml b/tools/phpcs-rules.xml deleted file mode 100644 index f3314a0e..00000000 --- a/tools/phpcs-rules.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/tools/release b/tools/release deleted file mode 100755 index 2f0b3ee7..00000000 --- a/tools/release +++ /dev/null @@ -1,680 +0,0 @@ -#!/usr/bin/python -# Adapted from Galette release script - -import os, sys, argparse, re, git, subprocess -import tarfile, shutil, gitdb, time, urllib2, json -from datetime import datetime -from termcolor import colored -from lxml import etree - -plugin_dir = os.path.dirname( - os.path.dirname(os.path.abspath(__file__)) -) -dist_dir = os.path.join( - plugin_dir, - 'dist' -) -verbose = False -tagrefs = None -force = False -commit = None -extra = None -sign = True -github = True -assume_yes = False -banned = [ - 'dist', - 'vendor', - '.git', - '.gitignore', - '.gh_token', - '.tx', - 'tools', - 'tests' -] -gh_orga = 'pluginsGLPI' -script_version = '1.0.0' - -def print_err(msg): - """ - Display colored error message - """ - print colored(msg, 'red', attrs=['bold']) - -def get_numeric_version(ver): - """ - Returns all numeric version - """ - return re.findall(r'\d+', ver) - -def valid_version(ver): - """ - Check if provided version is valid. - - Takes all digits in passed version, then reassemble them with dots - to check if it is the same as original given one. - """ - return '.'.join(get_numeric_version(ver)) == ver - -def incr_version(ver): - """ - Increment version number - """ - version = get_numeric_version(ver) - version[-1] = str(int(version[-1]) + 1) - return version - -def propose_version(): - """ - Propose new minor and major versions, - according to existing git tags - """ - last_major = '0' - last_minor = '0' - - for tagref in tagrefs: - if valid_version(tagref.name): - #last minor version is always the last one :) - if tagref.name > last_minor: - last_minor = tagref.name - - #last major version - if len(tagref.name) == 5 and tagref.name > last_major: - last_major = tagref.name - - if verbose: - print 'last minor: %s | last major %s' % (last_minor, last_major) - - #no version provided. propose one - new_minor = None - new_major = None - - if len(last_minor) == 5: - #if the latest is a major version - new_minor = last_minor + ('.1') - else: - new_minor = '.'.join(incr_version(last_minor)) - - new_major = '.'.join(incr_version(last_major)) - - print """Proposed versions: - minor: %s - major: %s - """ % (new_minor, new_major) - -def get_latest_version(): - """ - Look for latest version - """ - last = None - for tagref in tagrefs: - if valid_version(tagref.name): - #last created minor version is always the last one :) - if tagref.name > last: - last = tagref.name - - return last - -def is_existing_version(ver): - """ - Look specified version exists - """ - for tagref in tagrefs: - if valid_version(tagref.name): - if tagref.name == ver: - return True - return False - -def ask_user_confirm(msg): - """ - Ask user his confirmation - """ - if assume_yes: - return True - else: - while True: - sys.stdout.write(msg) - choice = raw_input().lower() - if choice == 'y' or choice == 'yes': - return True - elif choice == 'n' or choice == 'no': - return False - else: - print_err( - "Invalid input. Please enter 'yes' or 'no' (or 'y' or 'n')." - ) - -def get_rel_name(buildver): - """ - Build archive name from command line parameters - That would be used for git archiving prefix and archive name - """ - archive_name = None - - if commit and extra: - now = datetime.now() - archive_name = 'glpi-%s-%s-%s-%s-%s' % ( - plugin_name, - buildver, - extra, - now.strftime('%Y%m%d'), - commit - ) - else: - archive_name = 'glpi-%s-%s' % (plugin_name, buildver) - - return archive_name - -def _do_build(repo, ver): - """ - Proceed build - """ - exists = False - ascexists = False - rel_name = get_rel_name(ver) - archive_name = rel_name + '.tar.bz2' - archive = os.path.join( - dist_dir, - archive_name - ) - - if not force: - #first check if a version - local = False - ascLocal = False - - #check if a release exists upstream - #FIXME: this retrieve only publicated release, not drafts - url = 'https://api.github.com/repos/%s/%s/releases/tags/%s' % (gh_orga, plugin_name, ver) - - exists = False - gh_id = None - - try: - request = urllib2.Request(url) - handle = urllib2.urlopen(request) - contents = json.loads(handle.read()) - - for asset in contents['assets']: - if archive_name == asset['name']: - exists = True - gh_id = contents['id'] - break - except (urllib2.URLError, urllib2.HTTPError): - pass - - if exists: - #we know a release exists for this tag. Check if files have been uploaded yet - pass - - if not exists: - #also check from local repo - exists = os.path.exists(archive) - if exists: - local = True - - #also check from local repo - ascexists = os.path.exists( - os.path.join( - dist_dir, - archive_name + '.asc' - ) - ) - - if exists or ascexists: - msg = None - if exists: - loctxt = '' - if local: - loctxt = 'locally ' - msg = 'Relase %s already %sexists' % (rel_name, loctxt) - - if ascexists: - loctxt = '' - if ascLocal: - loctxt = ' locally' - if msg is not None: - msg += ' and has been %ssigned!' % loctxt - else: - msg += 'Release has been %ssigned!' % loctxt - - msg += '\n\nYou will *NOT* build another one :)' - print_err(msg) - else: - print 'Building %s...' % rel_name - - if verbose: - typestr = 'Tag' - typever = ver - - if commit and extra: - typestr = 'Commit' - typever = commit - - print 'Release name: %s, %s: %s, Dest: %s' % ( - rel_name, - typestr, - typever, - archive - ) - - paths = os.listdir(plugin_dir) - paths = list(set(paths) - set(banned)) - - if commit and extra: - print 'Archiving GIT commit %s' % commit - with open(archive, 'wb') as stream: - repo.archive(stream, commit, prefix=plugin_name+'/', path=paths) - else: - print 'Archiving GIT tag %s' % ver - with open(archive, 'wb') as stream: - repo.archive(stream, ver, prefix=plugin_name+'/', path=paths) - - print 'Adding vendor libraries' - prepare(plugin_name, archive) - - if sign: - do_sign(archive) - - if github: - create_gh_release(archive, gh_id, plugin_name, ver) - -def do_sign(archive): - sign_cmd = 'gpg --no-use-agent --detach-sign --armor %s' % archive - p1 = subprocess.Popen(sign_cmd, shell=True) - p1.communicate() - -def create_gh_release(archive, gh_id, plugin_name, ver): - with open(gh_cred_file, 'r') as fd: - token = fd.readline().strip() - - gh = github.Github(token) - gh_user = gh.get_user() - - for gh_repo in gh_user.get_repos(): - if gh_repo.full_name == '%s/%s' % (gh_orga, plugin_name): - break - - gh_release = None - - #check in all releases (including drafts) if nothing has been found yet - if gh_id is None: - for gh_rel in gh_repo.get_releases(): - if gh_rel.tag_name == ver: - gh_release = gh_rel - break - - #create release if it does not exists - if gh_id is None and gh_release is None: - is_prerelease = False if commit else True - gh_release = gh_repo.create_git_release( - ver, - 'GLPi %s %s' % (plugin_name, ver), - 'Automated release from release script', - True, - is_prerelease - ) - elif gh_id is not None: - gh_release = gh_repo.get_release(gh_id) - - #upload = ask_user_confirm( - # 'Do you want to upload archive %s? [yes/No] ' % archive - #) - - #if upload: - # do_upload(archive, gh_id, plugin_name, ver) - -#def do_upload(archive, gh_id, plugin_name, ver): - #from uritemplate import URITemplate - #import requests - #import mimetypes - - #Upload asset - #template = URITemplate(gh_release.upload_url) - - #headers = {'Content-Type': 'application/octet-stream', 'Authorization': 'token %s' % token} - #params = {'name': '%s-%s.tar.bz2' % (plugin_name, ver)} - #url = template.expand(params) - - ## Bad request :'( - #f = open('/var/www/webapps/glpi/plugins/order/dist/glpi-order-1.9.5.tar.bz2', 'rb') - #r = requests.post( - # url, - # data=f, - # headers=headers - #) - #print r.json() - #r.raise_for_status() - -def prepare(rel_name, archive): - """ - Add external libraries to the archive, if any - """ - - plugin = tarfile.open(archive, 'r') - src_dir = os.path.join(dist_dir, 'src') - if not os.path.exists(src_dir): - os.makedirs(src_dir) - plugin.extractall(path=src_dir) - plugin.close() - - build_dir = os.path.join(src_dir, plugin_name) - if os.path.exists(os.path.join(build_dir, 'composer.lock')): - composer = ['composer', 'install', '-o', '--no-dev'] - - if not verbose: - composer.insert(-1, '-q') - - p1 = subprocess.Popen( - composer, - cwd=build_dir - ) - p1.communicate() - - compile_mo(build_dir) - - minify(build_dir) - - plugin = tarfile.open(archive, 'w|bz2') - - for i in os.listdir(src_dir): - plugin.add( - os.path.join(src_dir, i), - arcname=rel_name - ) - - plugin.close() - shutil.rmtree(src_dir) - -def compile_mo(build_dir): - locales_dir = os.path.join(build_dir, 'locales') - if verbose: - print 'Locales dir: %s' % locales_dir - if os.path.exists(locales_dir): - for file in os.listdir(locales_dir): - if file.endswith('.po'): - if verbose: - print 'Compiling %s...' % file - p1 = subprocess.Popen( - ['msgfmt', file, '-o', file.replace('.po', '.mo')], - cwd=locales_dir - ) - p1.communicate() - -def minify(build_dir): - if os.path.exists(os.path.join(plugin_dir, 'vendor')): - robo = [os.path.join(plugin_dir, 'vendor', 'bin', 'robo'), 'minify'] - if not verbose: - robo.insert(-1, '-q') - - if verbose: - print robo - - p1 = subprocess.Popen( - robo, - cwd=build_dir - ) - p1.communicate() - elif verbose: - print_err("Robo.li is not installed; cannot minify!") - -def valid_commit(repo, c): - """ - Validate commit existance in repository - """ - global commit - - try: - dformat = '%a, %d %b %Y %H:%M' - repo_commit = repo.commit(c) - - commit = repo_commit.hexsha[:10] - print colored("""Commit informations: - Hash: %s - Author: %s - Authored date: %s - Commiter: %s - Commit date: %s - Message: %s""" % ( - commit, - repo_commit.author, - time.strftime(dformat, time.gmtime(repo_commit.authored_date)), - repo_commit.committer, - time.strftime(dformat, time.gmtime(repo_commit.committed_date)), - repo_commit.message - ), None, 'on_grey', attrs=['bold']) - return True - except gitdb.exc.BadObject: - return False - -def guess_plugin_name(): - """ - Tries to guess plugin name, ask user at last - """ - name = None - - filename = os.path.join( - os.path.dirname(os.path.abspath(__file__)), - 'extract_template.sh' - ) - - #try to get configured plugin name - if os.path.exists(filename): - with file(filename) as input: - for count, line in enumerate(input): - results = re.match(r"^NAME='(.+)'$", line) - if results: - name = results.group(1) - break - - if name is None: - #No configured name found. Let's use current directory name - name = os.path.split(plugin_dir)[-1] - - return name.lower() - -def check_version(buildver): - if verbose: - print 'Checking for version %s' % buildver - - filename = os.path.join( - plugin_dir, - 'setup.php' - ) - - found = None - #find version constant - if os.path.exists(filename): - with file(filename) as input: - for count, line in enumerate(input): - regexp = ".*('|\")PLUGIN_%s_VERSION('|\"), ('|\")(.+)('|\")" % plugin_name.upper() - results = re.match(regexp, line) - if results: - found = results.group(4) - break - - if not found == buildver: - print_err('Plugin version check has failed (%s but %s found)!' % (buildver, found)) - return False - - #check plugins website XML file - xmlfile = os.path.join(plugin_dir, '%s.xml' % plugin_name) - if not os.path.exists(xmlfile): - xmlfile = os.path.join(plugin_dir, 'plugin.xml') - if not os.path.exists(xmlfile): - xmlfile = None - - if xmlfile != None: - if verbose: - print 'XML file found in %s' % xmlfile - try: - xmldoc = etree.parse(xmlfile) - for version in xmldoc.getiterator('num'): - if version.text == buildver: - if verbose: - print '%s found in the XML file!' % buildver - return True - print_err('%s *NOT* found in the XML file %s' % (buildver, xmlfile)) - except etree.XMLSyntaxError as err: - print_err('%s is *NOT* XML valid!' % (xmlfile)) - if verbose: - print format(err) - return False - else: - print_err('Plugins website configuration file has not been found!') - return False - -def main(): - """ - Main method - """ - global verbose, tagrefs, force, extra, assume_yes, sign, plugin_name, github, gh_cred_file - - parser = argparse.ArgumentParser(description='GLPi plugins release script', version=script_version) - group = parser.add_mutually_exclusive_group() - group.add_argument( - '-r', - '--release', - help='Version to release' - ) - parser.add_argument( - '-g', - '--nogithub', - help="DO NOT Create github draft release", - action='store_false' - ) - parser.add_argument( - '-C', - '--check-only', - help="Only do chec, does not release anything", - action='store_true' - ) - group.add_argument( - '-p', - '--propose', - help='Calculate and propose next possible versions', - action='store_true' - ) - parser.add_argument( - '-c', - '--commit', - help='Specify commit to archive (-v required)' - ) - parser.add_argument( - '-e', - '--extra', - help='Extra version informations (-c required)' - ) - parser.add_argument( - '-m', - '--compile-mo', - help="Compile MO files from PO files (exclusive)", - action='store_true' - ) - parser.add_argument( - '-M', - '--minify', - help="Minify CSS ans JS files", - action='store_true' - ) - parser.add_argument( - '-S', - '--nosign', - help="Do not sign release tarball", - action="store_false" - ) - parser.add_argument( - '-Y', - '--assume-yes', - help='Assume YES to all questions. Be sure to understand what you are doing!', - action='store_true' - ) - parser.add_argument( - '-V', - '--verbose', - help='Be more verbose', - action="store_true" - ) - parser.add_argument('-f', action='store_true') - args = parser.parse_args() - - verbose=args.verbose - sign=args.nosign - github=args.nogithub - - if verbose: - print args - - if github: - import github - gh_cred_file = os.path.join(plugin_dir, '.gh_token') - if not os.path.exists(gh_cred_file): - print_err('GitHub credential file does not exists! Either create it or use the --nogithub option.') - sys.exit(1) - - plugin_name = guess_plugin_name() - - plugin_repo = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - repo = git.Repo(plugin_repo) - tagrefs = repo.tags - - if args.f == True: - force = ask_user_confirm( - 'Are you *REALLY* sure you mean -f when you typed -f? [yes/No] ' - ) - assume_yes=args.assume_yes - - if args.check_only: - print '*** Entering *check-only* mode ***' - - #check if dist_dir exists - if not os.path.exists(dist_dir): - os.makedirs(dist_dir) - - build = False - buildver = None - if args.compile_mo or args.minify: - if args.compile_mo: - compile_mo(plugin_repo) - if args.minify: - minify(plugin_repo) - elif (args.extra or args.commit) and (not args.extra or not args.commit or not args.release): - print_err('You have to specify --version --commit and --extra all together') - sys.exit(1) - elif args.commit and args.release and args.extra: - if valid_commit(repo, args.commit): - if verbose: - print 'Commit is valid' - build = True - buildver = args.release - extra = args.extra - else: - print_err('Invalid commit ref %s' % args.commit) - elif args.release: - if not valid_version(args.release): - print_err('%s is not a valid version number!' % args.release) - sys.exit(1) - else: - #check if specified version exists - if not is_existing_version(args.release): - print_err('%s does not exist!' % args.release) - else: - build = True - buildver = args.release - elif args.propose: - propose_version() - else: - buildver = get_latest_version() - if force: - build = True - else: - build = ask_user_confirm( - 'Do you want to build version %s? [Yes/no] ' % buildver - ) - - if build: - if check_version(buildver) and args.check_only == False: - _do_build(repo, buildver) - -if __name__ == "__main__": - main() diff --git a/tools/update_mo.pl b/tools/update_mo.pl deleted file mode 100644 index ed44da6f..00000000 --- a/tools/update_mo.pl +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/perl -#!/usr/bin/perl -w - -if (@ARGV!=0){ -print "USAGE update_mo.pl\n\n"; - -exit(); -} - - -opendir(DIRHANDLE,'locales')||die "ERROR: can not read current directory\n"; -foreach (readdir(DIRHANDLE)){ - if ($_ ne '..' && $_ ne '.'){ - - if(!(-l "$dir/$_")){ - if (index($_,".po",0)==length($_)-3) { - $lang=$_; - $lang=~s/\.po//; - - `msgfmt locales/$_ -o locales/$lang.mo`; - } - } - - } -} -closedir DIRHANDLE; - -# -# diff --git a/tools/update_po.pl b/tools/update_po.pl deleted file mode 100644 index cdd0d756..00000000 --- a/tools/update_po.pl +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/perl -#!/usr/bin/perl -w - -if (@ARGV!=2){ -print "USAGE update_po.pl transifex_login transifex_password\n\n"; - -exit(); -} -$user = $ARGV[0]; -$password = $ARGV[1]; - -opendir(DIRHANDLE,'locales')||die "ERROR: can not read current directory\n"; -foreach (readdir(DIRHANDLE)){ - if ($_ ne '..' && $_ ne '.'){ - - if(!(-l "$dir/$_")){ - if (index($_,".po",0)==length($_)-3) { - $lang=$_; - $lang=~s/\.po//; - - `wget --user=$user --password=$password --output-document=locales/$_ http://www.transifex.net/api/2/project/GLPI_datainjection/resource/glpi/translation/$lang/?file=$_`; - } - } - - } -} -closedir DIRHANDLE; - -# -# From e82292e043f098172836e84fdfc228f2b1ee2233 Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Wed, 8 Feb 2017 14:33:46 +0100 Subject: [PATCH 13/27] Rename javascript directory to js so files can be minified --- {javascript => js}/datainjection.js | 0 setup.php | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename {javascript => js}/datainjection.js (100%) diff --git a/javascript/datainjection.js b/js/datainjection.js similarity index 100% rename from javascript/datainjection.js rename to js/datainjection.js diff --git a/setup.php b/setup.php index 9b6975bf..c7455b58 100644 --- a/setup.php +++ b/setup.php @@ -73,7 +73,7 @@ function plugin_init_datainjection() { } // Javascript file - $PLUGIN_HOOKS['add_javascript']['datainjection'] = 'javascript/datainjection.js'; + $PLUGIN_HOOKS['add_javascript']['datainjection'] = 'js/datainjection.js'; // Inbtegration with Webservices plugin $PLUGIN_HOOKS['webservices']['datainjection'] = 'plugin_datainjection_registerMethods'; From 5ffcf0b61c69d2cfe3c9584f6a506c2ec629b5bb Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Wed, 24 May 2017 15:58:10 +0200 Subject: [PATCH 14/27] Fix doc link --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4f82b971..ff503146 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Data to be imported using the plugins are: ### Contributing * Open a ticket for each bug/feature so it can be discussed -* Follow [development guidelines](http://glpi-developer-documentation.readthedocs.io/en/latest/plugins.html) +* Follow [development guidelines](http://glpi-developer-documentation.readthedocs.io/en/latest/plugins/index.html) * Refer to [GitFlow](http://git-flow.readthedocs.io/) process for branching * Work on a new branch on your own fork * Open a PR that will be reviewed by a developer @@ -39,7 +39,7 @@ Les données pouvant-être injectées sont : ### Contribuer * Ouvrez un ticket pour chaque bogue/fonctionnalité que cela puisse être discuté -* Suivez [les règles de développement](http://glpi-developer-documentation.readthedocs.io/en/latest/plugins.html) +* Suivez [les règles de développement](http://glpi-developer-documentation.readthedocs.io/en/latest/plugins/index.html) * Référez-vous au processus [GitFlow](http://git-flow.readthedocs.io/) pour gérer les branches * Travaillez sur une nouvelle branche sur votre fork * Ouvrez une PR qui sera revue par un développeur From 0bb22b10ecb917e079e0daa8a2e1a7959e134539 Mon Sep 17 00:00:00 2001 From: Walid Date: Tue, 5 Sep 2017 14:13:18 +0200 Subject: [PATCH 15/27] First work on 9.2 compat --- hook.php | 29 +++++++++++++++++----------- inc/computermodelinjection.class.php | 6 +++--- inc/infocominjection.class.php | 11 ++++++----- setup.php | 19 +++++++++--------- 4 files changed, 37 insertions(+), 28 deletions(-) diff --git a/hook.php b/hook.php index 322a9289..8606b727 100644 --- a/hook.php +++ b/hook.php @@ -45,7 +45,6 @@ function plugin_datainjection_registerMethods() { function plugin_datainjection_install() { - global $DB; include_once GLPI_ROOT."/plugins/datainjection/inc/profile.class.php"; @@ -63,6 +62,7 @@ function plugin_datainjection_install() { `name` varchar(255) NOT NULL, `comment` text NULL, `date_mod` datetime NOT NULL default '0000-00-00 00:00:00', + `date_creation` datetime DEFAULT NULL, `filetype` varchar(255) NOT NULL default 'csv', `itemtype` varchar(255) NOT NULL default '', `entities_id` int(11) NOT NULL default '0', @@ -145,26 +145,26 @@ function plugin_datainjection_install() { Toolbox::deleteDir(GLPI_PLUGIN_DOC_DIR."/data_injection/"); } - if (TableExists("glpi_plugin_data_injection_models") - && !FieldExists("glpi_plugin_data_injection_models", "recursive") + if ($DB->tableExists("glpi_plugin_data_injection_models") + && !$DB->fieldExists("glpi_plugin_data_injection_models", "recursive") ) { // Update plugin_datainjection_update131_14(); } - if (TableExists("glpi_plugin_data_injection_models") - && !FieldExists("glpi_plugin_data_injection_models", "port_unicity") + if ($DB->tableExists("glpi_plugin_data_injection_models") + && !$DB->fieldExists("glpi_plugin_data_injection_models", "port_unicity") ) { $migration->addField('glpi_plugin_data_injection_models', 'port_unicity', 'bool'); $migration->executeMigration(); } - if (!TableExists("glpi_plugin_datainjection_models")) { + if (!$DB->tableExists("glpi_plugin_datainjection_models")) { plugin_datainjection_update15_170(); } - if (!TableExists("glpi_plugin_datainjection_modelcsvs")) { + if (!$DB->tableExists("glpi_plugin_datainjection_modelcsvs")) { plugin_datainjection_update170_20(); } @@ -174,6 +174,7 @@ function plugin_datainjection_install() { plugin_datainjection_upgrade23_240($migration); + plugin_datainjection_migration_24_250($migration); break; } @@ -182,7 +183,6 @@ function plugin_datainjection_install() { function plugin_datainjection_uninstall() { - global $DB; $tables = ["glpi_plugin_datainjection_models", @@ -193,7 +193,7 @@ function plugin_datainjection_uninstall() { "glpi_plugin_datainjection_profiles"]; foreach ($tables as $table) { - if (TableExists($table)) { + if ($DB->tableExists($table)) { $DB->queryOrDie("DROP TABLE IF EXISTS `".$table."`", $DB->error()); } } @@ -207,6 +207,12 @@ function plugin_datainjection_uninstall() { } +function plugin_datainjection_migration_24_250($migration) { + if ($migration->addField('glpi_plugin_data_injection_models', 'date_creation', 'datetime')) { + $migration->addKey('glpi_plugin_data_injection_models', 'date_creation'); + } +} + function plugin_datainjection_upgrade23_240($migration) { PluginDatainjectionProfile::migrateProfiles(); @@ -1035,13 +1041,14 @@ function plugin_datainjection_loadHook($hook_name, $params=array ()) { function plugin_datainjection_needUpdateOrInstall() { + global $DB; //Install plugin - if (!TableExists('glpi_plugin_datainjection_models')) { + if (!$DB->tableExists('glpi_plugin_datainjection_models')) { return 0; } - if (TableExists("glpi_plugin_datainjection_modelcsvs")) { + if ($DB->tableExists("glpi_plugin_datainjection_modelcsvs")) { return -1; } diff --git a/inc/computermodelinjection.class.php b/inc/computermodelinjection.class.php index 897572f3..3f4c0baa 100644 --- a/inc/computermodelinjection.class.php +++ b/inc/computermodelinjection.class.php @@ -53,7 +53,7 @@ function isPrimaryType() { function connectedTo() { - return array(); + return []; } @@ -66,7 +66,7 @@ function getOptions($primary_type='') { //Remove some options because some fields cannot be imported $blacklist = PluginDatainjectionCommonInjectionLib::getBlacklistedOptions(get_parent_class($this)); - $notimportable = array(); + $notimportable = []; $options['ignore_fields'] = array_merge($blacklist, $notimportable); @@ -79,7 +79,7 @@ function getOptions($primary_type='') { /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ - function addOrUpdateObject($values=array(), $options=array()) { + function addOrUpdateObject($values=[], $options=[]) { $lib = new PluginDatainjectionCommonInjectionLib($this, $values, $options); $lib->processAddOrUpdate(); diff --git a/inc/infocominjection.class.php b/inc/infocominjection.class.php index ef979bbc..6b34abf7 100644 --- a/inc/infocominjection.class.php +++ b/inc/infocominjection.class.php @@ -98,6 +98,7 @@ function getOptions($primary_type='') { $tab[25]['checktype'] = 'date'; $tab[27]['checktype'] = 'date'; $tab[28]['checktype'] = 'date'; + $tab[159]['checktype'] = 'date'; //Remove some options because some fields cannot be imported $blacklist = PluginDatainjectionCommonInjectionLib::getBlacklistedOptions(get_parent_class($this)); @@ -108,8 +109,8 @@ function getOptions($primary_type='') { $key = array_search(19, $options['ignore_fields']); unset($options['ignore_fields'][$key]); - $options['displaytype'] = array("date" => array(4, 5, 23, 24, 25, 27, 28), - "dropdown" => array(6, 9, 19), + $options['displaytype'] = array("date" => array(4, 5, 23, 24, 25, 27, 28, 159), + "dropdown" => array(6, 9, 19, 123), "dropdown_integer" => array(6, 14), "decimal" => array(8, 13, 17), "sink_type" => array(15), @@ -124,7 +125,7 @@ function getOptions($primary_type='') { * @param $info array * @param $option array **/ - function showAdditionalInformation($info=array(), $option=array()) { + function showAdditionalInformation($info=[], $option=[]) { $name = "info[".$option['linkfield']."]"; @@ -146,7 +147,7 @@ function showAdditionalInformation($info=array(), $option=array()) { /** * @param $values array **/ - function reformat(&$values=array()) { + function reformat(&$values=[]) { foreach (array('order_date', 'use_date', 'buy_date', 'warranty_date', 'delivery_date', 'inventory_date') as $date) { @@ -163,7 +164,7 @@ function reformat(&$values=array()) { /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ - function addOrUpdateObject($values=array(), $options=array()) { + function addOrUpdateObject($values=[], $options=[]) { $lib = new PluginDatainjectionCommonInjectionLib($this, $values, $options); $lib->processAddOrUpdate(); diff --git a/setup.php b/setup.php index c7455b58..d3dd7b24 100644 --- a/setup.php +++ b/setup.php @@ -85,29 +85,30 @@ function plugin_init_datainjection() { function plugin_version_datainjection() { - return ['name' => __('File injection', 'datainjection'), + return [ + 'name' => __('File injection', 'datainjection'), 'minGlpiVersion' => '0.85', 'author' => 'Walid Nouh, Remi Collet, Nelly Mahu-Lasson, Xavier Caillaud', 'homepage' => 'https://github.com/pluginsGLPI/datainjection', 'license' => 'GPLv2+', - 'version' => '2.4.2' + 'version' => '2.4.2', + 'requirements' => [ + 'glpi' => [ + 'min' => '9.2', + 'max' => '9.3', + 'dev' => 1 + ] + ] ]; } function plugin_datainjection_check_prerequisites() { - - if (version_compare(GLPI_VERSION, '0.85', 'lt') - ) { - _e('This plugin requires GLPI 0.85 or higher', 'datainjection'); - return false; - } return true; } function plugin_datainjection_check_config($verbose=false) { - return true; } From 25f4cb974e1975a9d0937bb82390cc26c4b9bfe7 Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Tue, 5 Sep 2017 16:10:38 +0200 Subject: [PATCH 16/27] Method signature --- inc/autoupdatesysteminjection.class.php | 2 +- inc/budgetinjection.class.php | 2 +- inc/cartridgeiteminjection.class.php | 2 +- inc/computer_iteminjection.class.php | 2 +- inc/computer_softwarelicenseinjection.class.php | 2 +- inc/computer_softwareversioninjection.class.php | 2 +- inc/computerinjection.class.php | 2 +- inc/computermodelinjection.class.php | 2 +- inc/computertypeinjection.class.php | 2 +- inc/consumableiteminjection.class.php | 2 +- inc/contact_supplierinjection.class.php | 2 +- inc/contactinjection.class.php | 2 +- inc/contacttypeinjection.class.php | 2 +- inc/contract_iteminjection.class.php | 2 +- inc/contract_supplierinjection.class.php | 2 +- inc/contractinjection.class.php | 2 +- inc/contracttypeinjection.class.php | 2 +- inc/devicecaseinjection.class.php | 2 +- inc/devicecasetypeinjection.class.php | 2 +- inc/devicecontrolinjection.class.php | 2 +- inc/devicedriveinjection.class.php | 2 +- inc/deviceecasetypeinjection.class.php | 2 +- inc/deviceharddriveinjection.class.php | 2 +- inc/devicememoryinjection.class.php | 2 +- inc/devicememorytypeinjection.class.php | 2 +- inc/devicemotherboardinjection.class.php | 2 +- inc/devicenetworkcardinjection.class.php | 2 +- inc/deviceprocessorinjection.class.php | 2 +- inc/documentinjection.class.php | 2 +- inc/documenttypeinjection.class.php | 2 +- inc/domaininjection.class.php | 2 +- inc/entityinjection.class.php | 2 +- inc/filesystemtypeinjection.class.php | 2 +- inc/group_userinjection.class.php | 2 +- inc/groupinjection.class.php | 2 +- inc/infocominjection.class.php | 2 +- inc/interfacetypeinjection.class.php | 2 +- inc/itilcategoryinjection.class.php | 2 +- inc/knowbaseitemcategoryinjection.class.php | 2 +- inc/knowbaseiteminjection.class.php | 2 +- inc/locationinjection.class.php | 2 +- inc/manufacturerinjection.class.php | 2 +- inc/monitorinjection.class.php | 2 +- inc/monitormodelinjection.class.php | 2 +- inc/monitortypeinjection.class.php | 2 +- inc/netpointinjection.class.php | 2 +- inc/networkequipmentfirmwareinjection.class.php | 2 +- inc/networkequipmentinjection.class.php | 2 +- inc/networkequipmentmodelinjection.class.php | 2 +- inc/networkequipmenttypeinjection.class.php | 2 +- inc/networkinjection.class.php | 2 +- inc/networkinterfaceinjection.class.php | 2 +- inc/networknameinjection.class.php | 2 +- inc/networkport_vlaninjection.class.php | 2 +- inc/networkportinjection.class.php | 2 +- inc/operatingsysteminjection.class.php | 2 +- inc/operatingsystemservicepackinjection.class.php | 2 +- inc/operatingsystemversioninjection.class.php | 2 +- inc/peripheralinjection.class.php | 2 +- inc/peripheralmodelinjection.class.php | 2 +- inc/peripheraltypeinjection.class.php | 2 +- inc/phoneinjection.class.php | 2 +- inc/phonemodelinjection.class.php | 2 +- inc/phonepowersupplytypeinjection.class.php | 2 +- inc/phonetypeinjection.class.php | 2 +- inc/printerinjection.class.php | 2 +- inc/printermodelinjection.class.php | 2 +- inc/printertypeinjection.class.php | 2 +- inc/profile_userinjection.class.php | 2 +- inc/profileinjection.class.php | 2 +- inc/requesttypeinjection.class.php | 2 +- inc/softwareinjection.class.php | 2 +- inc/softwarelicenseinjection.class.php | 2 +- inc/softwarelicensetypeinjection.class.php | 2 +- inc/softwareversioninjection.class.php | 2 +- inc/solutiontemplateinjection.class.php | 2 +- inc/solutiontypeinjection.class.php | 2 +- inc/stateinjection.class.php | 2 +- inc/supplierinjection.class.php | 2 +- inc/suppliertypeinjection.class.php | 2 +- inc/taskcategoryinjection.class.php | 2 +- inc/userinjection.class.php | 2 +- inc/virtualmachinestateinjection.class.php | 2 +- inc/virtualmachinesysteminjection.class.php | 2 +- inc/virtualmachinetypeinjection.class.php | 2 +- inc/vlaninjection.class.php | 2 +- 86 files changed, 86 insertions(+), 86 deletions(-) diff --git a/inc/autoupdatesysteminjection.class.php b/inc/autoupdatesysteminjection.class.php index c7a318b2..c5d4e808 100644 --- a/inc/autoupdatesysteminjection.class.php +++ b/inc/autoupdatesysteminjection.class.php @@ -36,7 +36,7 @@ class PluginDatainjectionAutoUpdateSystemInjection extends AutoUpdateSystem implements PluginDatainjectionInjectionInterface { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/budgetinjection.class.php b/inc/budgetinjection.class.php index 424aa87e..44a4b519 100644 --- a/inc/budgetinjection.class.php +++ b/inc/budgetinjection.class.php @@ -38,7 +38,7 @@ class PluginDatainjectionBudgetInjection extends Budget { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/cartridgeiteminjection.class.php b/inc/cartridgeiteminjection.class.php index 6a4377c5..5ca7ed1a 100644 --- a/inc/cartridgeiteminjection.class.php +++ b/inc/cartridgeiteminjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionCartridgeItemInjection extends CartridgeItem { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/computer_iteminjection.class.php b/inc/computer_iteminjection.class.php index 28404f61..f34386b2 100644 --- a/inc/computer_iteminjection.class.php +++ b/inc/computer_iteminjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionComputer_ItemInjection extends Computer_Item { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/computer_softwarelicenseinjection.class.php b/inc/computer_softwarelicenseinjection.class.php index 74398f15..bf0c4f00 100644 --- a/inc/computer_softwarelicenseinjection.class.php +++ b/inc/computer_softwarelicenseinjection.class.php @@ -43,7 +43,7 @@ static function getTypeName($nb=0) { } - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/computer_softwareversioninjection.class.php b/inc/computer_softwareversioninjection.class.php index 3dadba65..46d2fdd1 100644 --- a/inc/computer_softwareversioninjection.class.php +++ b/inc/computer_softwareversioninjection.class.php @@ -43,7 +43,7 @@ static function getTypeName($nb=0) { } - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/computerinjection.class.php b/inc/computerinjection.class.php index 14cd5d57..eede9af8 100644 --- a/inc/computerinjection.class.php +++ b/inc/computerinjection.class.php @@ -38,7 +38,7 @@ class PluginDatainjectionComputerInjection extends Computer { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/computermodelinjection.class.php b/inc/computermodelinjection.class.php index 3f4c0baa..777e96d1 100644 --- a/inc/computermodelinjection.class.php +++ b/inc/computermodelinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionComputerModelInjection extends ComputerModel { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/computertypeinjection.class.php b/inc/computertypeinjection.class.php index 27593b0e..d2265c5e 100644 --- a/inc/computertypeinjection.class.php +++ b/inc/computertypeinjection.class.php @@ -49,7 +49,7 @@ function connectedTo() { } - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/consumableiteminjection.class.php b/inc/consumableiteminjection.class.php index 9c9fd8db..7ddf2851 100644 --- a/inc/consumableiteminjection.class.php +++ b/inc/consumableiteminjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionConsumableItemInjection extends ConsumableItem { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/contact_supplierinjection.class.php b/inc/contact_supplierinjection.class.php index 384e538b..9453c6ed 100644 --- a/inc/contact_supplierinjection.class.php +++ b/inc/contact_supplierinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionContact_SupplierInjection extends Contact_Supplier { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/contactinjection.class.php b/inc/contactinjection.class.php index c887f6b6..027eb086 100644 --- a/inc/contactinjection.class.php +++ b/inc/contactinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionContactInjection extends Contact { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/contacttypeinjection.class.php b/inc/contacttypeinjection.class.php index 23d4d5a9..c1cddba0 100644 --- a/inc/contacttypeinjection.class.php +++ b/inc/contacttypeinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionContactTypeInjection extends ContactType { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/contract_iteminjection.class.php b/inc/contract_iteminjection.class.php index f64dc2a7..5e8e1bc5 100644 --- a/inc/contract_iteminjection.class.php +++ b/inc/contract_iteminjection.class.php @@ -33,7 +33,7 @@ class PluginDatainjectionContract_ItemInjection extends Contract_Item { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/contract_supplierinjection.class.php b/inc/contract_supplierinjection.class.php index abee5bfb..285f5332 100644 --- a/inc/contract_supplierinjection.class.php +++ b/inc/contract_supplierinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionContract_SupplierInjection extends Contract_Supplier { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/contractinjection.class.php b/inc/contractinjection.class.php index fb29990e..d6d3dcb3 100644 --- a/inc/contractinjection.class.php +++ b/inc/contractinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionContractInjection extends Contract { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/contracttypeinjection.class.php b/inc/contracttypeinjection.class.php index 501c92aa..307b158b 100644 --- a/inc/contracttypeinjection.class.php +++ b/inc/contracttypeinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionContractTypeInjection extends ContractType { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/devicecaseinjection.class.php b/inc/devicecaseinjection.class.php index d51a9900..d9374405 100644 --- a/inc/devicecaseinjection.class.php +++ b/inc/devicecaseinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionDeviceCaseInjection extends DeviceCase { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/devicecasetypeinjection.class.php b/inc/devicecasetypeinjection.class.php index 4dfc7828..1a951028 100644 --- a/inc/devicecasetypeinjection.class.php +++ b/inc/devicecasetypeinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionDeviceCaseTypeInjection extends DeviceCaseType { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/devicecontrolinjection.class.php b/inc/devicecontrolinjection.class.php index df268dd2..7f26eb66 100644 --- a/inc/devicecontrolinjection.class.php +++ b/inc/devicecontrolinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionDeviceControlInjection extends DeviceControl { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/devicedriveinjection.class.php b/inc/devicedriveinjection.class.php index 2690bb64..2a0e17ed 100644 --- a/inc/devicedriveinjection.class.php +++ b/inc/devicedriveinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionDeviceDriveInjection extends DeviceDrive { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/deviceecasetypeinjection.class.php b/inc/deviceecasetypeinjection.class.php index 4dfc7828..1a951028 100644 --- a/inc/deviceecasetypeinjection.class.php +++ b/inc/deviceecasetypeinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionDeviceCaseTypeInjection extends DeviceCaseType { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/deviceharddriveinjection.class.php b/inc/deviceharddriveinjection.class.php index 53b35e2b..e9b52e27 100644 --- a/inc/deviceharddriveinjection.class.php +++ b/inc/deviceharddriveinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionDeviceHardDriveInjection extends DeviceHardDrive { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/devicememoryinjection.class.php b/inc/devicememoryinjection.class.php index e2f44a69..21d0d927 100644 --- a/inc/devicememoryinjection.class.php +++ b/inc/devicememoryinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionDeviceMemoryInjection extends DeviceMemory { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/devicememorytypeinjection.class.php b/inc/devicememorytypeinjection.class.php index 84ba86ca..bb3f0b93 100644 --- a/inc/devicememorytypeinjection.class.php +++ b/inc/devicememorytypeinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionDeviceMemoryTypeInjection extends DeviceMemoryType { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/devicemotherboardinjection.class.php b/inc/devicemotherboardinjection.class.php index 14f02118..163366ac 100644 --- a/inc/devicemotherboardinjection.class.php +++ b/inc/devicemotherboardinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionDeviceMotherboardInjection extends DeviceMotherboard { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/devicenetworkcardinjection.class.php b/inc/devicenetworkcardinjection.class.php index bb3f5e15..f4811b8b 100644 --- a/inc/devicenetworkcardinjection.class.php +++ b/inc/devicenetworkcardinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionDeviceNetworkCardInjection extends DeviceNetworkCard { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/deviceprocessorinjection.class.php b/inc/deviceprocessorinjection.class.php index 77a27e69..4e6616ab 100644 --- a/inc/deviceprocessorinjection.class.php +++ b/inc/deviceprocessorinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionDeviceProcessorInjection extends DeviceProcessor { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/documentinjection.class.php b/inc/documentinjection.class.php index 737f6373..9169790b 100644 --- a/inc/documentinjection.class.php +++ b/inc/documentinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionDocumentInjection extends Document { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/documenttypeinjection.class.php b/inc/documenttypeinjection.class.php index 755752c4..57279e78 100644 --- a/inc/documenttypeinjection.class.php +++ b/inc/documenttypeinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionDocumentTypeInjection extends DocumentType { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/domaininjection.class.php b/inc/domaininjection.class.php index 2f0eb00c..44471892 100644 --- a/inc/domaininjection.class.php +++ b/inc/domaininjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionDomainInjection extends Domain { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/entityinjection.class.php b/inc/entityinjection.class.php index 6c274b8d..da3f8d2a 100644 --- a/inc/entityinjection.class.php +++ b/inc/entityinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionEntityInjection extends Entity { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/filesystemtypeinjection.class.php b/inc/filesystemtypeinjection.class.php index c257cd02..ae9f854a 100644 --- a/inc/filesystemtypeinjection.class.php +++ b/inc/filesystemtypeinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionFilesystemTypeInjection extends Filesystem { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/group_userinjection.class.php b/inc/group_userinjection.class.php index 188b7998..db59b0fb 100644 --- a/inc/group_userinjection.class.php +++ b/inc/group_userinjection.class.php @@ -43,7 +43,7 @@ static function getTypeName($nb=0) { } - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/groupinjection.class.php b/inc/groupinjection.class.php index 8214218d..f44c48c4 100644 --- a/inc/groupinjection.class.php +++ b/inc/groupinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionGroupInjection extends Group { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/infocominjection.class.php b/inc/infocominjection.class.php index 6b34abf7..ef3ab205 100644 --- a/inc/infocominjection.class.php +++ b/inc/infocominjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionInfocomInjection extends Infocom { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/interfacetypeinjection.class.php b/inc/interfacetypeinjection.class.php index 82a6cc36..bce112e6 100644 --- a/inc/interfacetypeinjection.class.php +++ b/inc/interfacetypeinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionInterfaceTypeInjection extends InterfaceType { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/itilcategoryinjection.class.php b/inc/itilcategoryinjection.class.php index aa46109b..29726c72 100644 --- a/inc/itilcategoryinjection.class.php +++ b/inc/itilcategoryinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionITILCategoryInjection extends ITILCategory { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/knowbaseitemcategoryinjection.class.php b/inc/knowbaseitemcategoryinjection.class.php index 09257db6..43a4ff1f 100644 --- a/inc/knowbaseitemcategoryinjection.class.php +++ b/inc/knowbaseitemcategoryinjection.class.php @@ -36,7 +36,7 @@ class PluginDatainjectionKnowbaseItemCategoryInjection extends KnowbaseItemCateg implements PluginDatainjectionInjectionInterface { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/knowbaseiteminjection.class.php b/inc/knowbaseiteminjection.class.php index f8354d72..acd03aad 100644 --- a/inc/knowbaseiteminjection.class.php +++ b/inc/knowbaseiteminjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionKnowbaseItemInjection extends KnowbaseItem { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/locationinjection.class.php b/inc/locationinjection.class.php index f1a8e2f0..343c5893 100644 --- a/inc/locationinjection.class.php +++ b/inc/locationinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionLocationInjection extends Location { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/manufacturerinjection.class.php b/inc/manufacturerinjection.class.php index cf859d9e..b92c4697 100644 --- a/inc/manufacturerinjection.class.php +++ b/inc/manufacturerinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionManufacturerInjection extends Manufacturer { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/monitorinjection.class.php b/inc/monitorinjection.class.php index f0a53622..6aa650a2 100644 --- a/inc/monitorinjection.class.php +++ b/inc/monitorinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionMonitorInjection extends Monitor { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/monitormodelinjection.class.php b/inc/monitormodelinjection.class.php index 96e66fb7..4854b774 100644 --- a/inc/monitormodelinjection.class.php +++ b/inc/monitormodelinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionMonitorModelInjection extends MonitorModel { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/monitortypeinjection.class.php b/inc/monitortypeinjection.class.php index de24f96f..96d7632e 100644 --- a/inc/monitortypeinjection.class.php +++ b/inc/monitortypeinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionMonitorTypeInjection extends MonitorType { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/netpointinjection.class.php b/inc/netpointinjection.class.php index d4d1ef3c..6c64ec10 100644 --- a/inc/netpointinjection.class.php +++ b/inc/netpointinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionNetpointInjection extends Netpoint { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/networkequipmentfirmwareinjection.class.php b/inc/networkequipmentfirmwareinjection.class.php index 116a2b08..2d7f96dd 100644 --- a/inc/networkequipmentfirmwareinjection.class.php +++ b/inc/networkequipmentfirmwareinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionNetworkEquipmentFirmwareInjection extends NetworkEquipm { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/networkequipmentinjection.class.php b/inc/networkequipmentinjection.class.php index 492f0469..ef02ee33 100644 --- a/inc/networkequipmentinjection.class.php +++ b/inc/networkequipmentinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionNetworkEquipmentInjection extends NetworkEquipment { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/networkequipmentmodelinjection.class.php b/inc/networkequipmentmodelinjection.class.php index 66d84b1e..f06eeb78 100644 --- a/inc/networkequipmentmodelinjection.class.php +++ b/inc/networkequipmentmodelinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionNetworkEquipmentModelInjection extends NetworkEquipment { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/networkequipmenttypeinjection.class.php b/inc/networkequipmenttypeinjection.class.php index 4b852054..1202ef03 100644 --- a/inc/networkequipmenttypeinjection.class.php +++ b/inc/networkequipmenttypeinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionNetworkequipmentTypeInjection extends NetworkEquipmentT { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/networkinjection.class.php b/inc/networkinjection.class.php index 9be19ffb..8f17d9b1 100644 --- a/inc/networkinjection.class.php +++ b/inc/networkinjection.class.php @@ -36,7 +36,7 @@ class PluginDatainjectionNetworkInjection extends Network implements PluginDatainjectionInjectionInterface { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/networkinterfaceinjection.class.php b/inc/networkinterfaceinjection.class.php index a2dcb789..f4221fba 100644 --- a/inc/networkinterfaceinjection.class.php +++ b/inc/networkinterfaceinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionNetworkInterfaceInjection extends NetworkInterface { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/networknameinjection.class.php b/inc/networknameinjection.class.php index 4f5ce30b..57eaf02c 100644 --- a/inc/networknameinjection.class.php +++ b/inc/networknameinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionNetworkNameInjection extends NetworkName { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/networkport_vlaninjection.class.php b/inc/networkport_vlaninjection.class.php index 77de693b..e06d9b91 100644 --- a/inc/networkport_vlaninjection.class.php +++ b/inc/networkport_vlaninjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionNetworkport_VlanInjection extends NetworkPort_Vlan { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/networkportinjection.class.php b/inc/networkportinjection.class.php index 56843e93..74a30bdd 100644 --- a/inc/networkportinjection.class.php +++ b/inc/networkportinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionNetworkportInjection extends NetworkPort { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/operatingsysteminjection.class.php b/inc/operatingsysteminjection.class.php index 525d6f6d..538c1c98 100644 --- a/inc/operatingsysteminjection.class.php +++ b/inc/operatingsysteminjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionOperatingSystemInjection extends OperatingSystem { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/operatingsystemservicepackinjection.class.php b/inc/operatingsystemservicepackinjection.class.php index b5dfb93f..3c3ee66f 100644 --- a/inc/operatingsystemservicepackinjection.class.php +++ b/inc/operatingsystemservicepackinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionOperatingSystemServicePackInjection extends OperatingSy { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/operatingsystemversioninjection.class.php b/inc/operatingsystemversioninjection.class.php index ade83866..a81df4dc 100644 --- a/inc/operatingsystemversioninjection.class.php +++ b/inc/operatingsystemversioninjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionOperatingSystemVersionInjection extends OperatingSystem { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/peripheralinjection.class.php b/inc/peripheralinjection.class.php index c9923ee3..e2ec30d0 100644 --- a/inc/peripheralinjection.class.php +++ b/inc/peripheralinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionPeripheralInjection extends Peripheral { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/peripheralmodelinjection.class.php b/inc/peripheralmodelinjection.class.php index cc8458f8..c4cf4541 100644 --- a/inc/peripheralmodelinjection.class.php +++ b/inc/peripheralmodelinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionPeripheralModelInjection extends PeripheralModel { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/peripheraltypeinjection.class.php b/inc/peripheraltypeinjection.class.php index a20df733..965fe358 100644 --- a/inc/peripheraltypeinjection.class.php +++ b/inc/peripheraltypeinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionPeripheralTypeInjection extends PeripheralType { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/phoneinjection.class.php b/inc/phoneinjection.class.php index 1cfb26d5..250e0d03 100644 --- a/inc/phoneinjection.class.php +++ b/inc/phoneinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionPhoneInjection extends Phone { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/phonemodelinjection.class.php b/inc/phonemodelinjection.class.php index 8500e80f..08d4c8e3 100644 --- a/inc/phonemodelinjection.class.php +++ b/inc/phonemodelinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionPhoneModelInjection extends PhoneModel { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/phonepowersupplytypeinjection.class.php b/inc/phonepowersupplytypeinjection.class.php index 7f3324a5..e46acabe 100644 --- a/inc/phonepowersupplytypeinjection.class.php +++ b/inc/phonepowersupplytypeinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionPhonePowerSupplyTypeInjection extends PhonePowerSupply { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/phonetypeinjection.class.php b/inc/phonetypeinjection.class.php index 723de65a..c6c77572 100644 --- a/inc/phonetypeinjection.class.php +++ b/inc/phonetypeinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionPhoneTypeInjection extends PhoneType { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/printerinjection.class.php b/inc/printerinjection.class.php index 1a2b06dd..e5aec94c 100644 --- a/inc/printerinjection.class.php +++ b/inc/printerinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionPrinterInjection extends Printer { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/printermodelinjection.class.php b/inc/printermodelinjection.class.php index fd80b625..6db83325 100644 --- a/inc/printermodelinjection.class.php +++ b/inc/printermodelinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionPrinterModelInjection extends PrinterModel { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/printertypeinjection.class.php b/inc/printertypeinjection.class.php index 7a6c2ab4..efaf1e17 100644 --- a/inc/printertypeinjection.class.php +++ b/inc/printertypeinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionPrinterTypeInjection extends PrinterType { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/profile_userinjection.class.php b/inc/profile_userinjection.class.php index 4a4ebb03..8d0ab792 100644 --- a/inc/profile_userinjection.class.php +++ b/inc/profile_userinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionProfile_UserInjection extends Profile_User { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/profileinjection.class.php b/inc/profileinjection.class.php index cc8a71b4..4d2e1538 100644 --- a/inc/profileinjection.class.php +++ b/inc/profileinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionProfileInjection extends Profile { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/requesttypeinjection.class.php b/inc/requesttypeinjection.class.php index ab393c62..87e6ad91 100644 --- a/inc/requesttypeinjection.class.php +++ b/inc/requesttypeinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionRequestTypeInjection extends RequestType { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/softwareinjection.class.php b/inc/softwareinjection.class.php index a1a12e82..1c1a6cd6 100644 --- a/inc/softwareinjection.class.php +++ b/inc/softwareinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionSoftwareInjection extends Software { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/softwarelicenseinjection.class.php b/inc/softwarelicenseinjection.class.php index 4c4d8f4f..875836d5 100644 --- a/inc/softwarelicenseinjection.class.php +++ b/inc/softwarelicenseinjection.class.php @@ -38,7 +38,7 @@ class PluginDatainjectionSoftwareLicenseInjection extends SoftwareLicense { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/softwarelicensetypeinjection.class.php b/inc/softwarelicensetypeinjection.class.php index 9abc0998..e6c2d164 100644 --- a/inc/softwarelicensetypeinjection.class.php +++ b/inc/softwarelicensetypeinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionSoftwareLicenseTypeInjection extends SoftwareLicenseTyp { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/softwareversioninjection.class.php b/inc/softwareversioninjection.class.php index 1229db75..31ba05fa 100644 --- a/inc/softwareversioninjection.class.php +++ b/inc/softwareversioninjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionSoftwareVersionInjection extends SoftwareVersion { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/solutiontemplateinjection.class.php b/inc/solutiontemplateinjection.class.php index 73544200..bff2ed8a 100644 --- a/inc/solutiontemplateinjection.class.php +++ b/inc/solutiontemplateinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionSolutionTemplateInjection extends SolutionTemplate { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/solutiontypeinjection.class.php b/inc/solutiontypeinjection.class.php index b17e307c..c8a52377 100644 --- a/inc/solutiontypeinjection.class.php +++ b/inc/solutiontypeinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionSolutionTypeInjection extends SolutionType { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/stateinjection.class.php b/inc/stateinjection.class.php index ad86841a..c9f194aa 100644 --- a/inc/stateinjection.class.php +++ b/inc/stateinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionStateInjection extends State { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/supplierinjection.class.php b/inc/supplierinjection.class.php index 99aac9b1..b12d9caf 100644 --- a/inc/supplierinjection.class.php +++ b/inc/supplierinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionSupplierInjection extends Supplier { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/suppliertypeinjection.class.php b/inc/suppliertypeinjection.class.php index 6d36bfac..59298434 100644 --- a/inc/suppliertypeinjection.class.php +++ b/inc/suppliertypeinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionSupplierTypeInjection extends SupplierType { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/taskcategoryinjection.class.php b/inc/taskcategoryinjection.class.php index 96349131..880f6e69 100644 --- a/inc/taskcategoryinjection.class.php +++ b/inc/taskcategoryinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionTaskCategoryInjection extends TaskCategory { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/userinjection.class.php b/inc/userinjection.class.php index dcf0876f..da566f5d 100644 --- a/inc/userinjection.class.php +++ b/inc/userinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionUserInjection extends User { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/virtualmachinestateinjection.class.php b/inc/virtualmachinestateinjection.class.php index dfb59c28..d3be1662 100644 --- a/inc/virtualmachinestateinjection.class.php +++ b/inc/virtualmachinestateinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionVirtualMachineStateInjection extends VirtualMachineStat { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/virtualmachinesysteminjection.class.php b/inc/virtualmachinesysteminjection.class.php index 5e7ff90d..8c560536 100644 --- a/inc/virtualmachinesysteminjection.class.php +++ b/inc/virtualmachinesysteminjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionVirtualMachineSystemInjection extends VirtualMachineSys { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/virtualmachinetypeinjection.class.php b/inc/virtualmachinetypeinjection.class.php index 79ad91e2..dcfaba28 100644 --- a/inc/virtualmachinetypeinjection.class.php +++ b/inc/virtualmachinetypeinjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionVirtualMachineTypeInjection extends VirtualMachineType { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); diff --git a/inc/vlaninjection.class.php b/inc/vlaninjection.class.php index 8e3d35c1..cdff2d8a 100644 --- a/inc/vlaninjection.class.php +++ b/inc/vlaninjection.class.php @@ -37,7 +37,7 @@ class PluginDatainjectionVlanInjection extends Vlan { - static function getTable() { + static function getTable($classname = null) { $parenttype = get_parent_class(); return $parenttype::getTable(); From 67f9754a328763112cb23dbffea15a0b8ad56efb Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Tue, 5 Sep 2017 16:10:58 +0200 Subject: [PATCH 17/27] Redo check prerequisites --- setup.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/setup.php b/setup.php index d3dd7b24..e4d513e5 100644 --- a/setup.php +++ b/setup.php @@ -91,11 +91,10 @@ function plugin_version_datainjection() { 'author' => 'Walid Nouh, Remi Collet, Nelly Mahu-Lasson, Xavier Caillaud', 'homepage' => 'https://github.com/pluginsGLPI/datainjection', 'license' => 'GPLv2+', - 'version' => '2.4.2', + 'version' => PLUGIN_DATAINJECTION_VERSION, 'requirements' => [ 'glpi' => [ 'min' => '9.2', - 'max' => '9.3', 'dev' => 1 ] ] @@ -104,6 +103,12 @@ function plugin_version_datainjection() { function plugin_datainjection_check_prerequisites() { + $version = rtrim(GLPI_VERSION, '-dev'); + if (version_compare($version, '9.2', 'lt')) { + echo "This plugin requires GLPI 9.2"; + return false; + } + return true; } From fa06d4b831324f8964d638a6422fc34b8ba2b167 Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Tue, 5 Sep 2017 16:11:16 +0200 Subject: [PATCH 18/27] NetworkEquipmentFirmware no longer exists --- setup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.php b/setup.php index e4d513e5..53855cce 100644 --- a/setup.php +++ b/setup.php @@ -195,7 +195,7 @@ function getTypesToInject() { 'PluginDatainjectionPrinterModelInjection' => 'datainjection', 'PluginDatainjectionPeripheralModelInjection' => 'datainjection', 'PluginDatainjectionNetworkEquipmentModelInjection' => 'datainjection', - 'PluginDatainjectionNetworkEquipmentFirmwareInjection' => 'datainjection', + //'PluginDatainjectionNetworkEquipmentFirmwareInjection' => 'datainjection', 'PluginDatainjectionVirtualMachineTypeInjection' => 'datainjection', 'PluginDatainjectionVirtualMachineSystemInjection' => 'datainjection', 'PluginDatainjectionVirtualMachineStateInjection' => 'datainjection', From 2b5c8425beead4c1fd35b81d3492750d03fb9046 Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Wed, 6 Sep 2017 09:38:00 +0200 Subject: [PATCH 19/27] Fix for new search options --- inc/commoninjectionlib.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/commoninjectionlib.class.php b/inc/commoninjectionlib.class.php index 466cc54c..f38eae1e 100644 --- a/inc/commoninjectionlib.class.php +++ b/inc/commoninjectionlib.class.php @@ -1976,7 +1976,7 @@ static function addToSearchOptions(array $type_searchOptions, array $options, 'notepad' => 'notepad'); foreach ($type_searchOptions as $id => $tmp) { - if (!is_array($tmp) || in_array($id, $options['ignore_fields'])) { + if (!is_array($tmp) || !isset($tmp['field']) || in_array($id, $options['ignore_fields'])) { unset($type_searchOptions[$id]); } else { From e86be1d3aee88a3852e825529ae57ade3ac5e80e Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Wed, 6 Sep 2017 09:38:15 +0200 Subject: [PATCH 20/27] Use same image as core for templates --- inc/menu.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/menu.class.php b/inc/menu.class.php index 4e5ed328..f76e3fc8 100644 --- a/inc/menu.class.php +++ b/inc/menu.class.php @@ -47,7 +47,7 @@ static function getMenuContent() { if (Session::haveRight(static::$rightname, READ)) { - $image_model = "".PluginDatainjectionModel::getTypeName().""; From f330b78d49b05c4c6fadf407d724df5632656fa4 Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Wed, 6 Sep 2017 10:11:49 +0200 Subject: [PATCH 21/27] Drop depreacted usage --- inc/clientinjection.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/clientinjection.class.php b/inc/clientinjection.class.php index 7934fd07..2b783cd2 100644 --- a/inc/clientinjection.class.php +++ b/inc/clientinjection.class.php @@ -371,10 +371,10 @@ static function showResultsForm(PluginDatainjectionModel $model) { echo ""; if ($ok) { echo ""; - _e('Injection successful', 'datainjection'); + echo __('Injection successful', 'datainjection'); } else { echo ""; - _e('Injection encounters errors', 'datainjection'); + echo __('Injection encounters errors', 'datainjection'); } echo ""; From c544b1143a2be66a9b0656e5221bc7ebf2aeb815 Mon Sep 17 00:00:00 2001 From: Walid Date: Wed, 31 Jan 2018 12:37:05 +0100 Subject: [PATCH 22/27] Inject OS infos --- hook.php | 17 +++- inc/commoninjectionlib.class.php | 2 +- inc/computerinjection.class.php | 9 +- inc/item_operatingsysteminjection.class.php | 94 +++++++++++++++++++ inc/networkequipmentinjection.class.php | 4 +- ...atingsystemarchitectureinjection.class.php | 87 +++++++++++++++++ inc/operatingsystemeditioninjection.class.php | 87 +++++++++++++++++ inc/operatingsystemkernelinjection.class.php | 87 +++++++++++++++++ ...tingsystemkernelversioninjection.class.php | 87 +++++++++++++++++ inc/profile.class.php | 3 +- setup.php | 6 +- 11 files changed, 475 insertions(+), 8 deletions(-) create mode 100644 inc/item_operatingsysteminjection.class.php create mode 100644 inc/operatingsystemarchitectureinjection.class.php create mode 100644 inc/operatingsystemeditioninjection.class.php create mode 100644 inc/operatingsystemkernelinjection.class.php create mode 100644 inc/operatingsystemkernelversioninjection.class.php diff --git a/hook.php b/hook.php index 8606b727..c4d676b0 100644 --- a/hook.php +++ b/hook.php @@ -48,12 +48,13 @@ function plugin_datainjection_install() { global $DB; include_once GLPI_ROOT."/plugins/datainjection/inc/profile.class.php"; - $migration = new Migration('2.3.0'); + $migration = new Migration('2.5.0'); switch (plugin_datainjection_needUpdateOrInstall()) { case -1 : plugin_datainjection_update220_230(); plugin_datainjection_upgrade23_240($migration); + plugin_datainjection_migration_24_250($migration); return true; case 0 : @@ -208,9 +209,23 @@ function plugin_datainjection_uninstall() { function plugin_datainjection_migration_24_250($migration) { + global $DB; if ($migration->addField('glpi_plugin_data_injection_models', 'date_creation', 'datetime')) { $migration->addKey('glpi_plugin_data_injection_models', 'date_creation'); } + + //Migrate OSes infos + //TODO use DB->update in 9.3 + $query = "UPDATE `glpi_plugin_datainjection_mappings` + SET `itemtype`='Item_OperatingSystem' + WHERE `itemtype`='Computer' + AND `value` IN ( + 'license_id', 'license_number', 'operatingsystemservicepacks_id', + 'operatingsystems_id', 'operatingsystemversions_id', + 'operatingsystemarchitectures_id', 'operatingsystemkernels_id', + 'operatingsystemkernelversions_id', 'operatingsystemeditions_id' + )"; + $DB->query($query); } function plugin_datainjection_upgrade23_240($migration) { diff --git a/inc/commoninjectionlib.class.php b/inc/commoninjectionlib.class.php index f38eae1e..129c0c6f 100644 --- a/inc/commoninjectionlib.class.php +++ b/inc/commoninjectionlib.class.php @@ -1360,7 +1360,7 @@ private function lastCheckBeforeProcess($injectionClass, $values) { * @return an array which contains the injection results **/ public function processAddOrUpdate() { - +Toolbox::logDebug($this->values); $process = false; $add = true; $accepted = false; diff --git a/inc/computerinjection.class.php b/inc/computerinjection.class.php index eede9af8..86407b9c 100644 --- a/inc/computerinjection.class.php +++ b/inc/computerinjection.class.php @@ -70,8 +70,13 @@ function getOptions($primary_type='') { //Remove some options because some fields cannot be imported $blacklist = PluginDatainjectionCommonInjectionLib::getBlacklistedOptions(get_parent_class($this)); - $notimportable = array(10, 11, 12, 13, 14, 15, 19, 34, 35, 36, 39, 91, 92, 93, - 150, 151, 152, 153, 154, 155, 156, 160, 161, 162, 163, 164 ,165, 166); + $notimportable = [ + 10, 11, 12, 13, 14, 15, 19, 34, 35, 36, 39, + //OS fields + 41, 43, 44, 45, 46, 48, 61, 63, 64, + 91, 92, 93, 150, 151, 152, 153, 154, 155, 156, 160, 161, 162, 163, + 164 ,165, 166 + ]; $options['ignore_fields'] = array_merge($blacklist, $notimportable); diff --git a/inc/item_operatingsysteminjection.class.php b/inc/item_operatingsysteminjection.class.php new file mode 100644 index 00000000..7d0e965f --- /dev/null +++ b/inc/item_operatingsysteminjection.class.php @@ -0,0 +1,94 @@ +. + -------------------------------------------------------------------------- + @package datainjection + @author the datainjection plugin team + @copyright Copyright (c) 2010-2017 Datainjection plugin team + @license GPLv2+ + http://www.gnu.org/licenses/gpl.txt + @link https://github.com/pluginsGLPI/datainjection + @link http://www.glpi-project.org/ + @since 2009 + ---------------------------------------------------------------------- */ + +if (!defined('GLPI_ROOT')) { + die("Sorry. You can't access directly to this file"); +} + +class PluginDatainjectionItem_OperatingsystemInjection extends Item_OperatingSystem + implements PluginDatainjectionInjectionInterface +{ + + + static function getTable($classname = null) { + + $parenttype = get_parent_class(); + return $parenttype::getTable(); + } + + function isPrimaryType() { + + return false; + } + + /** + * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() + **/ + function getOptions($primary_type='') { + + $tab = Item_OperatingSystem::getSearchOptionsToAddNew(get_parent_class($this)); + $searchoptions = []; + foreach ($tab as $option) { + if (is_numeric($option['id'])) { + if ($option['table'] != 'glpi_items_operatingsystems') { + $option['linkfield'] = getForeignKeyFieldForTable($option['table']); + } else { + $option['linkfield'] = $option['field']; + } + $searchoptions[$option['id']] = $option; + } + } + + $options['ignore_fields'] = []; + $options['displaytype'] = [ + "dropdown" => [ + 41, 45, 46, 48, 61, 63, 64 + ], + "text" => [43, 44] + ]; + return PluginDatainjectionCommonInjectionLib::addToSearchOptions($searchoptions, $options, $this); + } + + function connectedTo() { + + return array('Computer', 'NetworkEquipment'); + } + + + /** + * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() + **/ + function addOrUpdateObject($values=array(), $options=array()) { + + $lib = new PluginDatainjectionCommonInjectionLib($this, $values, $options); + $lib->processAddOrUpdate(); + return $lib->getInjectionResults(); + } +} diff --git a/inc/networkequipmentinjection.class.php b/inc/networkequipmentinjection.class.php index ef02ee33..366e1ee0 100644 --- a/inc/networkequipmentinjection.class.php +++ b/inc/networkequipmentinjection.class.php @@ -77,7 +77,9 @@ function getOptions($primary_type='') { //Remove some options because some fields cannot be imported $blacklist = PluginDatainjectionCommonInjectionLib::getBlacklistedOptions(get_parent_class($this)); - $notimportable = array(91, 92, 93); + $notimportable = [ + 41, 43, 44, 45, 46, 48, 61, 63, 64, 91, 92, 93 + ]; $options['ignore_fields'] = array_merge($blacklist, $notimportable); diff --git a/inc/operatingsystemarchitectureinjection.class.php b/inc/operatingsystemarchitectureinjection.class.php new file mode 100644 index 00000000..d145c7ee --- /dev/null +++ b/inc/operatingsystemarchitectureinjection.class.php @@ -0,0 +1,87 @@ +. + -------------------------------------------------------------------------- + @package datainjection + @author the datainjection plugin team + @copyright Copyright (c) 2010-2017 Datainjection plugin team + @license GPLv2+ + http://www.gnu.org/licenses/gpl.txt + @link https://github.com/pluginsGLPI/datainjection + @link http://www.glpi-project.org/ + @since 2009 + ---------------------------------------------------------------------- */ + +if (!defined('GLPI_ROOT')) { + die("Sorry. You can't access directly to this file"); +} + +class PluginDatainjectionOperatingSystemArchitectureInjection extends OperatingSystemArchitecture + implements PluginDatainjectionInjectionInterface +{ + + + static function getTable($classname = null) { + + $parenttype = get_parent_class(); + return $parenttype::getTable(); + } + + + function isPrimaryType() { + + return true; + } + + + function connectedTo() { + + return array(); + } + + + /** + * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() + **/ + function getOptions($primary_type='') { + + $tab = Search::getOptions(get_parent_class($this)); + + //Remove some options because some fields cannot be imported + $blacklist = PluginDatainjectionCommonInjectionLib::getBlacklistedOptions(get_parent_class($this)); + $notimportable = array(); + + $options['ignore_fields'] = array_merge($blacklist, $notimportable); + $options['displaytype'] = array("multiline_text" => array(16)); + + return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); + } + + + /** + * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() + **/ + function addOrUpdateObject($values=array(), $options=array()) { + + $lib = new PluginDatainjectionCommonInjectionLib($this, $values, $options); + $lib->processAddOrUpdate(); + return $lib->getInjectionResults(); + } + +} diff --git a/inc/operatingsystemeditioninjection.class.php b/inc/operatingsystemeditioninjection.class.php new file mode 100644 index 00000000..5e843b22 --- /dev/null +++ b/inc/operatingsystemeditioninjection.class.php @@ -0,0 +1,87 @@ +. + -------------------------------------------------------------------------- + @package datainjection + @author the datainjection plugin team + @copyright Copyright (c) 2010-2017 Datainjection plugin team + @license GPLv2+ + http://www.gnu.org/licenses/gpl.txt + @link https://github.com/pluginsGLPI/datainjection + @link http://www.glpi-project.org/ + @since 2009 + ---------------------------------------------------------------------- */ + +if (!defined('GLPI_ROOT')) { + die("Sorry. You can't access directly to this file"); +} + +class PluginDatainjectionOperatingSystemEditionInjection extends OperatingSystemEdition + implements PluginDatainjectionInjectionInterface +{ + + + static function getTable($classname = null) { + + $parenttype = get_parent_class(); + return $parenttype::getTable(); + } + + + function isPrimaryType() { + + return true; + } + + + function connectedTo() { + + return array('Computer'); + } + + + /** + * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() + **/ + function getOptions($primary_type='') { + + $tab = Search::getOptions(get_parent_class($this)); + + //Remove some options because some fields cannot be imported + $blacklist = PluginDatainjectionCommonInjectionLib::getBlacklistedOptions(get_parent_class($this)); + $notimportable = array(); + + $options['ignore_fields'] = array_merge($blacklist, $notimportable); + $options['displaytype'] = array("multiline_text" => array(16)); + + return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); + } + + + /** + * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() + **/ + function addOrUpdateObject($values=array(), $options=array()) { + + $lib = new PluginDatainjectionCommonInjectionLib($this, $values, $options); + $lib->processAddOrUpdate(); + return $lib->getInjectionResults(); + } + +} diff --git a/inc/operatingsystemkernelinjection.class.php b/inc/operatingsystemkernelinjection.class.php new file mode 100644 index 00000000..7272a9be --- /dev/null +++ b/inc/operatingsystemkernelinjection.class.php @@ -0,0 +1,87 @@ +. + -------------------------------------------------------------------------- + @package datainjection + @author the datainjection plugin team + @copyright Copyright (c) 2010-2017 Datainjection plugin team + @license GPLv2+ + http://www.gnu.org/licenses/gpl.txt + @link https://github.com/pluginsGLPI/datainjection + @link http://www.glpi-project.org/ + @since 2009 + ---------------------------------------------------------------------- */ + +if (!defined('GLPI_ROOT')) { + die("Sorry. You can't access directly to this file"); +} + +class PluginDatainjectionOperatingSystemKernelInjection extends OperatingSystemKernel + implements PluginDatainjectionInjectionInterface +{ + + + static function getTable($classname = null) { + + $parenttype = get_parent_class(); + return $parenttype::getTable(); + } + + + function isPrimaryType() { + + return true; + } + + + function connectedTo() { + + return array(); + } + + + /** + * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() + **/ + function getOptions($primary_type='') { + + $tab = Search::getOptions(get_parent_class($this)); + + //Remove some options because some fields cannot be imported + $blacklist = PluginDatainjectionCommonInjectionLib::getBlacklistedOptions(get_parent_class($this)); + $notimportable = array(); + + $options['ignore_fields'] = array_merge($blacklist, $notimportable); + $options['displaytype'] = array("multiline_text" => array(16)); + + return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); + } + + + /** + * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() + **/ + function addOrUpdateObject($values=array(), $options=array()) { + + $lib = new PluginDatainjectionCommonInjectionLib($this, $values, $options); + $lib->processAddOrUpdate(); + return $lib->getInjectionResults(); + } + +} diff --git a/inc/operatingsystemkernelversioninjection.class.php b/inc/operatingsystemkernelversioninjection.class.php new file mode 100644 index 00000000..d4091145 --- /dev/null +++ b/inc/operatingsystemkernelversioninjection.class.php @@ -0,0 +1,87 @@ +. + -------------------------------------------------------------------------- + @package datainjection + @author the datainjection plugin team + @copyright Copyright (c) 2010-2017 Datainjection plugin team + @license GPLv2+ + http://www.gnu.org/licenses/gpl.txt + @link https://github.com/pluginsGLPI/datainjection + @link http://www.glpi-project.org/ + @since 2009 + ---------------------------------------------------------------------- */ + +if (!defined('GLPI_ROOT')) { + die("Sorry. You can't access directly to this file"); +} + +class PluginDatainjectionOperatingSystemKernelVersionInjection extends OperatingSystemKernelVersion + implements PluginDatainjectionInjectionInterface +{ + + + static function getTable($classname = null) { + + $parenttype = get_parent_class(); + return $parenttype::getTable(); + } + + + function isPrimaryType() { + + return true; + } + + + function connectedTo() { + + return array(); + } + + + /** + * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() + **/ + function getOptions($primary_type='') { + + $tab = Search::getOptions(get_parent_class($this)); + + //Remove some options because some fields cannot be imported + $blacklist = PluginDatainjectionCommonInjectionLib::getBlacklistedOptions(get_parent_class($this)); + $notimportable = array(); + + $options['ignore_fields'] = array_merge($blacklist, $notimportable); + $options['displaytype'] = array("multiline_text" => array(16)); + + return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this); + } + + + /** + * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() + **/ + function addOrUpdateObject($values=array(), $options=array()) { + + $lib = new PluginDatainjectionCommonInjectionLib($this, $values, $options); + $lib->processAddOrUpdate(); + return $lib->getInjectionResults(); + } + +} diff --git a/inc/profile.class.php b/inc/profile.class.php index 8d2e6074..5576f315 100644 --- a/inc/profile.class.php +++ b/inc/profile.class.php @@ -125,9 +125,8 @@ static function createFirstAccess($profiles_id) { } static function migrateProfiles() { - global $DB; - if (!TableExists('glpi_plugin_datainjection_profiles')) { + if (!$DB->tableExists('glpi_plugin_datainjection_profiles')) { return true; } diff --git a/setup.php b/setup.php index 53855cce..49bea56e 100644 --- a/setup.php +++ b/setup.php @@ -28,7 +28,7 @@ @since 2009 ---------------------------------------------------------------------- */ -define ('PLUGIN_DATAINJECTION_VERSION', '2.4.3'); +define ('PLUGIN_DATAINJECTION_VERSION', '2.5.0'); if (!defined("PLUGIN_DATAINJECTION_UPLOAD_DIR")) { define("PLUGIN_DATAINJECTION_UPLOAD_DIR", GLPI_PLUGIN_DOC_DIR."/datainjection/"); @@ -204,6 +204,10 @@ function getTypesToInject() { 'PluginDatainjectionOperatingSystemInjection' => 'datainjection', 'PluginDatainjectionOperatingSystemVersionInjection' => 'datainjection', 'PluginDatainjectionOperatingSystemServicePackInjection' => 'datainjection', + 'PluginDatainjectionOperatingSystemKernelInjection' => 'datainjection', + 'PluginDatainjectionOperatingSystemKernelVersionInjection'=> 'datainjection', + 'PluginDatainjectionOperatingSystemEditionInjection' => 'datainjection', + 'PluginDatainjectionItem_OperatingSystemInjection' => 'datainjection', 'PluginDatainjectionNetworkInterfaceInjection' => 'datainjection', 'PluginDatainjectionDomainInjection' => 'datainjection', 'PluginDatainjectionNetworkInjection' => 'datainjection', From b5c84933dcb18fbaf34ee0fd3fd21e966f58da9a Mon Sep 17 00:00:00 2001 From: Walid Date: Wed, 31 Jan 2018 12:42:15 +0100 Subject: [PATCH 23/27] CS & remove logDebug --- inc/commoninjectionlib.class.php | 1 - inc/item_operatingsysteminjection.class.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/inc/commoninjectionlib.class.php b/inc/commoninjectionlib.class.php index 129c0c6f..f9ac49df 100644 --- a/inc/commoninjectionlib.class.php +++ b/inc/commoninjectionlib.class.php @@ -1360,7 +1360,6 @@ private function lastCheckBeforeProcess($injectionClass, $values) { * @return an array which contains the injection results **/ public function processAddOrUpdate() { -Toolbox::logDebug($this->values); $process = false; $add = true; $accepted = false; diff --git a/inc/item_operatingsysteminjection.class.php b/inc/item_operatingsysteminjection.class.php index 7d0e965f..d86e627a 100644 --- a/inc/item_operatingsysteminjection.class.php +++ b/inc/item_operatingsysteminjection.class.php @@ -74,7 +74,7 @@ function getOptions($primary_type='') { "text" => [43, 44] ]; return PluginDatainjectionCommonInjectionLib::addToSearchOptions($searchoptions, $options, $this); - } + } function connectedTo() { From bffe3b8e6b880d06aca69038f2c27086293db5a5 Mon Sep 17 00:00:00 2001 From: amma35 Date: Fri, 9 Dec 2016 14:20:16 +0100 Subject: [PATCH 24/27] Inject notepads --- inc/commoninjectionlib.class.php | 7 +- inc/documentinjection.class.php | 1 - inc/notepadinjection.class.php | 111 +++++++++++++++++++++++++++++++ setup.php | 3 +- 4 files changed, 118 insertions(+), 4 deletions(-) create mode 100644 inc/notepadinjection.class.php diff --git a/inc/commoninjectionlib.class.php b/inc/commoninjectionlib.class.php index f9ac49df..28d4675c 100644 --- a/inc/commoninjectionlib.class.php +++ b/inc/commoninjectionlib.class.php @@ -1364,7 +1364,8 @@ public function processAddOrUpdate() { $add = true; $accepted = false; - // logDebug("processAddOrUpdate(), start with", $this->values); + $this->values = Toolbox::stripslashes_deep($this->values); + //Toolbox::logDebug("processAddOrUpdate(), start with", $this->values); // Initial value, will be change when problem $this->results['status'] = self::SUCCESS; @@ -1517,6 +1518,8 @@ private function effectiveAddOrUpdate($injectionClass, $item, $values, $add=true } } + $toinject = Toolbox::addslashes_deep($toinject); + if (method_exists($injectionClass, 'customimport')) { $newID = call_user_func( array($injectionClass, 'customimport'), $toinject, $add, @@ -1832,7 +1835,7 @@ private function addTemplateFields($itemtype) { || $this->values[$itemtype][$key] == self::EMPTY_VALUE || $this->values[$itemtype][$key] == self::DROPDOWN_EMPTY_VALUE) ) { - $value = Toolbox::addslashes_deep($value); + //$value = Toolbox::addslashes_deep($value); $this->setValueForItemtype($itemtype, $key, $value); } } diff --git a/inc/documentinjection.class.php b/inc/documentinjection.class.php index 9169790b..218cf5a2 100644 --- a/inc/documentinjection.class.php +++ b/inc/documentinjection.class.php @@ -60,7 +60,6 @@ function connectedTo() { * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type='') { - return Search::getOptions(get_parent_class($this)); } diff --git a/inc/notepadinjection.class.php b/inc/notepadinjection.class.php new file mode 100644 index 00000000..20853439 --- /dev/null +++ b/inc/notepadinjection.class.php @@ -0,0 +1,111 @@ +. + -------------------------------------------------------------------------- + @package datainjection + @author the datainjection plugin team + @copyright Copyright (c) 2010-2013 Datainjection plugin team + @license GPLv2+ + http://www.gnu.org/licenses/gpl.txt + @link https://forge.indepnet.net/projects/datainjection + @link http://www.glpi-project.org/ + @since 2009 + ---------------------------------------------------------------------- */ + +if (!defined('GLPI_ROOT')) { + die("Sorry. You can't access directly to this file"); +} + +class PluginDatainjectionNotepadInjection extends Notepad + implements PluginDatainjectionInjectionInterface { + + + static function getTable($classname = NULL) { + + $parenttype = get_parent_class(); + return $parenttype::getTable(); + + } + + function isPrimaryType() { + return false; + } + + + function connectedTo() { + return array('Computer', 'NetworkEquipment', 'Printer'); + } + + function customDataAlreadyInDB($injectionClass, $values, $options) { + //Do not manage updating notes: only creation + return false; + } + + /** + * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() + **/ + function getOptions($primary_type='') { + + $tab = Notepad::getSearchOptionsToAddNew(); + $searchoptions = []; + foreach ($tab as $option) { + if (is_numeric($option['id'])) { + if ($option['table'] != 'glpi_notepads') { + $option['linkfield'] = getForeignKeyFieldForTable($option['table']); + } else { + $option['linkfield'] = $option['field']; + } + $searchoptions[$option['id']] = $option; + } + } + + $options['ignore_fields'] = [201, 203, 204]; + $options['displaytype'] = [ + "multiline_text" => [200], + "dropdown" => [202] + + ]; + + return PluginDatainjectionCommonInjectionLib::addToSearchOptions($searchoptions, $options, $this); + } + + + /** + * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() + **/ + function addOrUpdateObject($values=array(), $options=array()) { + + $lib = new PluginDatainjectionCommonInjectionLib($this, $values, $options); + $lib->processAddOrUpdate(); + return $lib->getInjectionResults(); + } + + + /** + * @param $primary_type + * @param $values + **/ + function addSpecificNeededFields($primary_type, $values) { + + $fields['items_id'] = $values[$primary_type]['id']; + $fields['itemtype'] = $primary_type; + return $fields; + } + +} diff --git a/setup.php b/setup.php index 49bea56e..355893b9 100644 --- a/setup.php +++ b/setup.php @@ -132,9 +132,10 @@ function getTypesToInject() { return; } - $INJECTABLE_TYPES = ['PluginDatainjectionCartridgeItemInjection' => 'datainjection', + $INJECTABLE_TYPES = ['PluginDatainjectionCartridgeItemInjection' => 'datainjection', 'PluginDatainjectionBudgetInjection' => 'datainjection', 'PluginDatainjectionComputerInjection' => 'datainjection', + 'PluginDatainjectionNotepadInjection' => 'datainjection', 'PluginDatainjectionComputer_ItemInjection' => 'datainjection', 'PluginDatainjectionConsumableItemInjection' => 'datainjection', 'PluginDatainjectionContactInjection' => 'datainjection', From 4c3b7d9db5f9ab1a1383d7863b04865f7668596e Mon Sep 17 00:00:00 2001 From: Walid Date: Wed, 31 Jan 2018 14:59:55 +0100 Subject: [PATCH 25/27] Fix CS --- inc/notepadinjection.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/notepadinjection.class.php b/inc/notepadinjection.class.php index 20853439..3fd69cba 100644 --- a/inc/notepadinjection.class.php +++ b/inc/notepadinjection.class.php @@ -56,7 +56,7 @@ function customDataAlreadyInDB($injectionClass, $values, $options) { //Do not manage updating notes: only creation return false; } - + /** * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ From 2cb6722c390e9fd4fa5c0fc03cada41d33785a29 Mon Sep 17 00:00:00 2001 From: Walid Date: Wed, 31 Jan 2018 15:29:09 +0100 Subject: [PATCH 26/27] Update XML file --- datainjection.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/datainjection.xml b/datainjection.xml index 1c3ce0cc..1002343d 100644 --- a/datainjection.xml +++ b/datainjection.xml @@ -25,6 +25,10 @@ Xavier Caillaud + + 2.5.0 + 9.2 + 2.4.3 0.85 From 00bca2b261e58ec29e25c0d5a1d7ea30922f36ae Mon Sep 17 00:00:00 2001 From: Walid Date: Wed, 31 Jan 2018 15:37:23 +0100 Subject: [PATCH 27/27] Minimum version is 9.2 --- setup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.php b/setup.php index 355893b9..fa3bc776 100644 --- a/setup.php +++ b/setup.php @@ -87,7 +87,7 @@ function plugin_version_datainjection() { return [ 'name' => __('File injection', 'datainjection'), - 'minGlpiVersion' => '0.85', + 'minGlpiVersion' => '9.2', 'author' => 'Walid Nouh, Remi Collet, Nelly Mahu-Lasson, Xavier Caillaud', 'homepage' => 'https://github.com/pluginsGLPI/datainjection', 'license' => 'GPLv2+',