diff --git a/README.md b/README.md index 4d98108..852cdac 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,13 @@ # manageentities Plugin manageentities pour GLPI +Ce plugin est sur Transifex - Aidez-nous à le traduire : +https://www.transifex.com/tsmr/GLPI_manageentities/ + +This plugin is on Transifex - Help us to translate : +https://www.transifex.com/tsmr/GLPI_manageentities/ + + Ce plugin vous permet de gérer vos entités. Lier des documents, contacts, contrats. De plus vous pouvez créer des rapports d'interventions, et faire le suivi contrat de vos entités. * Pour une entité donnée, vous définissez diff --git a/ajax/addelements.listener.php b/ajax/addelements.listener.php index 41983eb..23b6a2d 100644 --- a/ajax/addelements.listener.php +++ b/ajax/addelements.listener.php @@ -1,32 +1,28 @@ . - -------------------------------------------------------------------------- - */ - + along with manageentities. If not, see . + -------------------------------------------------------------------------- +*/ include('../../../inc/includes.php'); Html::header_nocache(); @@ -347,7 +343,8 @@ if (isset($_POST['selected_template']) && $_POST['selected_template'] > 0) { $idTemplate = $_POST['selected_template']; $template = new Contract(); - $template->getFromDBByQuery("WHERE id=" . $idTemplate . " AND is_template=1"); + $template->getFromDBByCrit(['users_id' => $idTemplate, + 'is_template' => 1]); $oldContract = $pModel->getContract(); $oldContract->fields = $template->fields; @@ -514,5 +511,3 @@ default : break; } - -?> diff --git a/ajax/cri.php b/ajax/cri.php index 56801b3..5e53685 100644 --- a/ajax/cri.php +++ b/ajax/cri.php @@ -1,32 +1,28 @@ . - -------------------------------------------------------------------------- - */ - + along with manageentities. If not, see . + -------------------------------------------------------------------------- +*/ include('../../../inc/includes.php'); Html::header_nocache(); @@ -153,5 +149,3 @@ } break; } - -?> diff --git a/ajax/criprice.php b/ajax/criprice.php index 48940d0..5f0df9c 100644 --- a/ajax/criprice.php +++ b/ajax/criprice.php @@ -1,32 +1,28 @@ . - -------------------------------------------------------------------------- - */ - + along with manageentities. If not, see . + -------------------------------------------------------------------------- +*/ include('../../../inc/includes.php'); Html::header_nocache(); @@ -38,5 +34,3 @@ $criprice->showSelectPriceDropdown($_POST['critypes_id'], $_POST['entities_id']); break; } - -?> diff --git a/ajax/dropdownContract.php b/ajax/dropdownContract.php index de3accc..8857196 100644 --- a/ajax/dropdownContract.php +++ b/ajax/dropdownContract.php @@ -1,30 +1,30 @@ . - -------------------------------------------------------------------------- + You should have received a copy of the GNU General Public License + along with Manageentities. If not, see . + -------------------------------------------------------------------------- */ include('../../../inc/includes.php'); @@ -65,5 +65,4 @@ 'value' => $contractdays_id, 'condition' => $restrict, 'width' => $_POST['width'])); -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/ajax/getDropdownNumber.php b/ajax/getDropdownNumber.php index 0e7f383..5be6d71 100644 --- a/ajax/getDropdownNumber.php +++ b/ajax/getDropdownNumber.php @@ -1,32 +1,42 @@ . + along with GLPI. If not, see . -------------------------------------------------------------------------- */ +/** @file + * @brief + * @since version 0.85 + */ + +// Direct access to file include('../../../inc/includes.php'); header("Content-Type: text/html; charset=UTF-8"); Html::header_nocache(); @@ -121,5 +131,4 @@ $ret['results'] = $datas; $ret['count'] = $count; echo json_encode($ret); -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/ajax/interventionskateholderactions.php b/ajax/interventionskateholderactions.php index 43ec5fc..ed80e84 100644 --- a/ajax/interventionskateholderactions.php +++ b/ajax/interventionskateholderactions.php @@ -1,32 +1,33 @@ . - -------------------------------------------------------------------------- + You should have received a copy of the GNU General Public License + along with Manageentities. If not, see . + -------------------------------------------------------------------------- */ + include('../../../inc/includes.php'); header("Content-Type: text/html; charset=UTF-8"); Html::header_nocache(); @@ -44,7 +45,8 @@ $idContractdays = $_POST['contractdays_id']; $nbDays = $_POST['nb_days']; - $interventionSkateholder->getFromDBByQuery("WHERE `users_id`=" . $idUser . " AND `plugin_manageentities_contractdays_id`=" . $idContractdays); + $interventionSkateholder->getFromDBByCrit(['users_id' => $idUser, + 'plugin_manageentities_contractdays_id' => $idContractdays]); if (isset($interventionSkateholder->fields['id']) && $interventionSkateholder->fields['id'] > 0) { $interventionSkateholder->fields['number_affected_days'] += $_POST['nb_days']; diff --git a/ajax/linkactions.php b/ajax/linkactions.php index b696f8f..6ae529f 100644 --- a/ajax/linkactions.php +++ b/ajax/linkactions.php @@ -1,30 +1,30 @@ . - -------------------------------------------------------------------------- + You should have received a copy of the GNU General Public License + along with Manageentities. If not, see . + -------------------------------------------------------------------------- */ include("../../../inc/includes.php"); diff --git a/ajax/loadscripts.php b/ajax/loadscripts.php index 152f72b..08e17d9 100644 --- a/ajax/loadscripts.php +++ b/ajax/loadscripts.php @@ -1,30 +1,28 @@ . - -------------------------------------------------------------------------- + You should have received a copy of the GNU General Public License + along with Manageentities. If not, see . + -------------------------------------------------------------------------- */ include('../../../inc/includes.php'); @@ -40,13 +38,11 @@ && Session::haveRight("task", CommonITILTask::ADDALLITEM) && strpos($_SERVER['HTTP_REFERER'], "ticket.form.php") !== false && strpos($_SERVER['HTTP_REFERER'], 'id=') !== false - && $_SESSION['glpiactiveprofile']['interface'] == "central" + && Session::getCurrentInterface() == "central" && Session::haveRight("plugin_manageentities", READ)) { echo ""; } break; } -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/ajax/tickettask.php b/ajax/tickettask.php index 3216801..40e3a81 100644 --- a/ajax/tickettask.php +++ b/ajax/tickettask.php @@ -1,32 +1,28 @@ . - -------------------------------------------------------------------------- - */ - + along with manageentities. If not, see . + -------------------------------------------------------------------------- +*/ include('../../../inc/includes.php'); Html::header_nocache(); @@ -81,5 +77,3 @@ break; } } - -?> diff --git a/ajax/viewsubitem.php b/ajax/viewsubitem.php index b6edb61..6726f9f 100644 --- a/ajax/viewsubitem.php +++ b/ajax/viewsubitem.php @@ -1,32 +1,28 @@ . - -------------------------------------------------------------------------- - */ - + along with manageentities. If not, see . + -------------------------------------------------------------------------- +*/ include('../../../inc/includes.php'); header("Content-Type: text/html; charset=UTF-8"); Html::header_nocache(); @@ -40,8 +36,9 @@ exit(); } -if (($item = getItemForItemtype($_POST['type'])) - && ($parent = getItemForItemtype($_POST['parenttype']))) { +$dbu = new DbUtils(); +if (($item = $dbu->getItemForItemtype($_POST['type'])) + && ($parent = $dbu->getItemForItemtype($_POST['parenttype']))) { if (isset($_POST[$parent->getForeignKeyField()]) && isset($_POST["id"]) && $parent->getFromDB($_POST[$parent->getForeignKeyField()])) { @@ -52,5 +49,4 @@ } } -Html::ajaxFooter(); -?> \ No newline at end of file +Html::ajaxFooter(); \ No newline at end of file diff --git a/common/commonGLPIModel.class.php b/common/commonGLPIModel.class.php index c608fdc..04e0b05 100644 --- a/common/commonGLPIModel.class.php +++ b/common/commonGLPIModel.class.php @@ -1,11 +1,10 @@ CommonGLPIErrors::ERROR_ADD, // In case of an - * error when trying to insert a new entity CommonGLPIErrors::ERROR_CONTRACT => CommonGLPIErrors::ERROR_UPDATE, - * // In case of an error when trying to update a contract CommonGLPIErrors::ERROR_PERIOD => array - * (CommonGLPIErrors::ERROR_UPDATE => 2), // In case of an error when trying to update the period - * // identified by the - * id number 2 + * CommonGLPIErrors::ERROR_ENTITY => CommonGLPIErrors::ERROR_ADD, + * // In case of an error when trying to insert a new entity CommonGLPIErrors::ERROR_CONTRACT => + * CommonGLPIErrors::ERROR_UPDATE, // In case of an error when trying to + * update a contract CommonGLPIErrors::ERROR_PERIOD => array (CommonGLPIErrors::ERROR_UPDATE + * => 2), // In case of an error when trying to update the period + * // + * identified by the id number 2 * ) * * @@ -188,7 +189,8 @@ public function isOnError($error, $type, $opt = null) { * @param CommonGLPIError $id : the error to add * @param CommonGLPIError $type : the type of error to add * @param boolean $val : the value (true for an error, otherwise false) - * @param int $opt : if set, used to specified an error on a special element identified by the id $opt + * @param int $opt : if set, used to specified an error on a special element + * identified by the id $opt */ public function addError($id, $type, $val, $opt = null) { $this->errors = array(); @@ -206,7 +208,8 @@ public function addError($id, $type, $val, $opt = null) { * * @param CommonGLPIError $id : the error to delete * @param CommonGLPIError $type : the error type to delete - * @param int $opt : if set, delete the error of the special element identified by the id $opt + * @param int $opt : if set, delete the error of the special element identified by + * the id $opt */ public function deleteError($id, $type, $opt = null) { if (isset($this->errors[$id][$type])) { @@ -276,7 +279,8 @@ public function getMessages() { /** * This function allows to set the array of messages of the model. - * Moreover this function store the new array of messages in session using the function serializeInSession() + * Moreover this function store the new array of messages in session using the function + * serializeInSession() * * @param array $value : the array of messages */ diff --git a/common/commonGLPIView.class.php b/common/commonGLPIView.class.php index 113254e..23b495f 100644 --- a/common/commonGLPIView.class.php +++ b/common/commonGLPIView.class.php @@ -1,11 +1,10 @@ . - -------------------------------------------------------------------------- + ------------------------------------------------------------------------- + Manageentities plugin for GLPI + Copyright (C) 2003-2012 by the Manageentities Development Team. + + https://forge.indepnet.net/projects/manageentities + ------------------------------------------------------------------------- + + LICENSE + + This file is part of Manageentities. + + Manageentities 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. + + Manageentities 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 Manageentities. If not, see . + -------------------------------------------------------------------------- */ function ReadMap($enc) @@ -310,9 +310,9 @@ function CheckTTF($file) } /******************************************************************************* -* $fontfile : chemin du fichier TTF (ou chaîne vide si pas d'incorporation) * +* $fontfile : chemin du fichier TTF (ou cha�ne vide si pas d'incorporation) * * $afmfile : chemin du fichier AFM * -* $enc : encodage (ou chaîne vide si la police est symbolique) * +* $enc : encodage (ou cha�ne vide si la police est symbolique) * * $patch : patch optionnel pour l'encodage * * $type : type de la police si $fontfile est vide * *******************************************************************************/ diff --git a/fpdf/fpdf.php b/fpdf/fpdf.php index 33c1efd..8d757a2 100644 --- a/fpdf/fpdf.php +++ b/fpdf/fpdf.php @@ -923,7 +923,7 @@ function Image($file,$x,$y,$w=0,$h=0,$type='',$link='') $type=substr($file,$pos+1); } $type=Toolbox::strtolower($type); - $mqr=Toolbox::get_magic_quotes_runtime(); + $mqr=get_magic_quotes_runtime(); ini_set("magic_quotes_runtime",0); if ($type=='jpg' || $type=='jpeg') $info=$this->_parsejpg($file); @@ -1178,7 +1178,7 @@ function _putfonts() $this->_out('<>'); $this->_out('endobj'); } - $mqr=Toolbox::get_magic_quotes_runtime(); + $mqr=get_magic_quotes_runtime(); ini_set("magic_quotes_runtime",0); foreach($this->FontFiles as $file=>$info) { @@ -1289,7 +1289,7 @@ function _putimages() { $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; reset($this->images); - while(list($file,$info)=each($this->images)) + foreach($this->images as $file => $info) { $this->_newobj(); $this->images[$file]['n']=$this->n; diff --git a/front/addelements.form.php b/front/addelements.form.php index 055f365..35b4a3d 100644 --- a/front/addelements.form.php +++ b/front/addelements.form.php @@ -1,11 +1,10 @@

"; echo "" . __("You don't have permission to perform this action.") . ""; Html::footer(); -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/front/company.form.php b/front/company.form.php index 7aac778..ad5f3e8 100644 --- a/front/company.form.php +++ b/front/company.form.php @@ -1,11 +1,10 @@ display($_GET); Html::footer(); -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/front/company.php b/front/company.php index 269dc75..9cb0cfa 100644 --- a/front/company.php +++ b/front/company.php @@ -3,14 +3,14 @@ * @version $Id: HEADER 15930 2011-10-30 15:47:55Z tsmr $ ------------------------------------------------------------------------- Manageentities plugin for GLPI - Copyright (C) 2014-2017 by the Manageentities Development Team. + Copyright (C) 2003-2011 by the manageentities Development Team. - https://github.com/InfotelGLPI/manageentities + https://forge.indepnet.net/projects/manageentities ------------------------------------------------------------------------- LICENSE - - This file is part of Manageentities. + + This file is part of manageentities. Manageentities is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -41,6 +41,4 @@ Html::displayRightError(); } -Html::footer(); - -?> \ No newline at end of file +Html::footer(); \ No newline at end of file diff --git a/front/config.form.php b/front/config.form.php index d24a561..710b263 100644 --- a/front/config.form.php +++ b/front/config.form.php @@ -1,32 +1,31 @@ . - -------------------------------------------------------------------------- + You should have received a copy of the GNU General Public License + along with Manageentities. If not, see . + -------------------------------------------------------------------------- */ - include('../../../inc/includes.php'); $plugin = new Plugin(); @@ -65,5 +64,4 @@ echo "warning

"; echo "" . __('Please activate the plugin', 'manageentities') . ""; Html::footer(); -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/front/contract.form.php b/front/contract.form.php index 53415c5..29e58f6 100644 --- a/front/contract.form.php +++ b/front/contract.form.php @@ -1,11 +1,10 @@ display($_GET); Html::footer(); -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/front/contractday.form.php b/front/contractday.form.php index cb44e78..c817226 100644 --- a/front/contractday.form.php +++ b/front/contractday.form.php @@ -1,11 +1,10 @@ display($_GET); } Html::footer(); -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/front/contractday.php b/front/contractday.php index b5aae79..ae1f801 100644 --- a/front/contractday.php +++ b/front/contractday.php @@ -3,14 +3,14 @@ * @version $Id: HEADER 15930 2011-10-30 15:47:55Z tsmr $ ------------------------------------------------------------------------- Manageentities plugin for GLPI - Copyright (C) 2014-2017 by the Manageentities Development Team. + Copyright (C) 2003-2011 by the manageentities Development Team. - https://github.com/InfotelGLPI/manageentities + https://forge.indepnet.net/projects/manageentities ------------------------------------------------------------------------- LICENSE - - This file is part of Manageentities. + + This file is part of manageentities. Manageentities is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -41,6 +41,4 @@ Html::displayRightError(); } -Html::footer(); - -?> \ No newline at end of file +Html::footer(); \ No newline at end of file diff --git a/front/contractstate.form.php b/front/contractstate.form.php index 114b645..6e24b85 100644 --- a/front/contractstate.form.php +++ b/front/contractstate.form.php @@ -1,11 +1,10 @@ \ No newline at end of file +include(GLPI_ROOT . "/front/dropdown.common.form.php"); \ No newline at end of file diff --git a/front/contractstate.php b/front/contractstate.php index 1ad39bc..19371d9 100644 --- a/front/contractstate.php +++ b/front/contractstate.php @@ -1,11 +1,10 @@ \ No newline at end of file +include(GLPI_ROOT . "/front/dropdown.common.php"); \ No newline at end of file diff --git a/front/cri.form.php b/front/cri.form.php index 60f4afd..1a1e71c 100644 --- a/front/cri.form.php +++ b/front/cri.form.php @@ -1,11 +1,10 @@ . -------------------------------------------------------------------------- - */ +// */ include('../../../inc/includes.php'); @@ -75,6 +74,4 @@ $PluginManageentitiesCri->showForm($_GET["job"], array('action' => $_GET["action"])); } -Html::popFooter(); - -?> \ No newline at end of file +Html::popFooter(); \ No newline at end of file diff --git a/front/cri.send.php b/front/cri.send.php index b8c8ddf..fecc722 100644 --- a/front/cri.send.php +++ b/front/cri.send.php @@ -1,30 +1,30 @@ . - -------------------------------------------------------------------------- + You should have received a copy of the GNU General Public License + along with Manageentities. If not, see . + -------------------------------------------------------------------------- */ include('../../../inc/includes.php'); @@ -57,5 +57,4 @@ } else { Html::displayErrorAndDie(__('Invalid filename'), true); } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/front/cridetail.form.php b/front/cridetail.form.php index 0b708e4..812a0c7 100644 --- a/front/cridetail.form.php +++ b/front/cridetail.form.php @@ -1,11 +1,10 @@ . -------------------------------------------------------------------------- - */ +// */ include('../../../inc/includes.php'); @@ -42,7 +41,7 @@ $cri->checkGlobal(READ); -if ($_SESSION['glpiactiveprofile']['interface'] == 'central') { +if (Session::getCurrentInterface() == 'central') { Html::header(__('Entities portal', 'manageentities'), '', "management", "pluginmanageentitiesentity"); } else { Html::helpHeader(__('Entities portal', 'manageentities')); @@ -50,11 +49,8 @@ $cri->display($_GET); -if ($_SESSION['glpiactiveprofile']['interface'] == 'central') { +if (Session::getCurrentInterface() == 'central') { Html::footer(); } else { Html::helpFooter(); -} - - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/front/criprice.form.php b/front/criprice.form.php index 885d7e5..b95ea11 100644 --- a/front/criprice.form.php +++ b/front/criprice.form.php @@ -1,32 +1,31 @@ . - -------------------------------------------------------------------------- + You should have received a copy of the GNU General Public License + along with Manageentities. If not, see . + -------------------------------------------------------------------------- */ - include('../../../inc/includes.php'); if (Session::haveRight("plugin_manageentities", UPDATE)) { @@ -57,6 +56,4 @@ echo "warning

"; echo "" . __("You don't have permission to perform this action.") . ""; Html::footer(); -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/front/critype.form.php b/front/critype.form.php index 7e08fb8..860a6de 100644 --- a/front/critype.form.php +++ b/front/critype.form.php @@ -1,11 +1,10 @@ \ No newline at end of file +include(GLPI_ROOT . "/front/dropdown.common.form.php"); \ No newline at end of file diff --git a/front/critype.php b/front/critype.php index 7714b82..468a38f 100644 --- a/front/critype.php +++ b/front/critype.php @@ -1,11 +1,10 @@ \ No newline at end of file +include(GLPI_ROOT . "/front/dropdown.common.php"); \ No newline at end of file diff --git a/front/entity.form.php b/front/entity.form.php index 2c8c0fe..6243517 100644 --- a/front/entity.form.php +++ b/front/entity.form.php @@ -1,30 +1,30 @@ . - -------------------------------------------------------------------------- + You should have received a copy of the GNU General Public License + along with Manageentities. If not, see . + -------------------------------------------------------------------------- */ include('../../../inc/includes.php'); @@ -47,6 +47,4 @@ Html::redirect($CFG_GLPI["root_doc"] . "/front/entity.form.php?id=" . $_POST["entities_id"] . "&s&forcetab=EntityData$1"); -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/front/entity.php b/front/entity.php index cbac558..899b3a4 100644 --- a/front/entity.php +++ b/front/entity.php @@ -1,30 +1,30 @@ . - -------------------------------------------------------------------------- + You should have received a copy of the GNU General Public License + along with Manageentities. If not, see . + -------------------------------------------------------------------------- */ include('../../../inc/includes.php'); @@ -37,7 +37,7 @@ if (!isset($_POST["entities_id"])) $_POST["entities_id"] = ""; -if ($_SESSION['glpiactiveprofile']['interface'] == 'central') { +if (Session::getCurrentInterface() == 'central') { Html::header(__('Entities portal', 'manageentities'), '', "management", "pluginmanageentitiesentity"); } else { Html::helpHeader(__('Entities portal', 'manageentities')); @@ -101,7 +101,7 @@ Html::redirect($CFG_GLPI["root_doc"] . "/plugins/manageentities/front/entity.php?active_entity=" . $_POST["entities_id"] . ""); } else { - if ($_SESSION['glpiactiveprofile']['interface'] == 'central') { + if (Session::getCurrentInterface() == 'central') { $dateYear = date("Y-m-d", mktime(0, 0, 0, date("m"), 1, date("Y") - 1)); } else { $dateYear = date("Y-m-d", mktime(0, 0, 0, date("m"), 1, date("Y") - 10)); @@ -139,9 +139,8 @@ Html::displayRightError(); } -if ($_SESSION['glpiactiveprofile']['interface'] == 'central') { +if (Session::getCurrentInterface() == 'central') { Html::footer(); } else { Html::helpFooter(); -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/front/preference.form.php b/front/preference.form.php index cf74cfd..1d9922d 100644 --- a/front/preference.form.php +++ b/front/preference.form.php @@ -1,11 +1,10 @@ update($_POST); Html::back(); -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/front/report.form.php b/front/report.form.php index 95e8f68..ec2d533 100644 --- a/front/report.form.php +++ b/front/report.form.php @@ -1,11 +1,10 @@ . -------------------------------------------------------------------------- - */ +*/ include('../../../inc/includes.php'); @@ -111,6 +110,4 @@ Html::displayRightError(); } -Html::footer(); - -?> \ No newline at end of file +Html::footer(); \ No newline at end of file diff --git a/front/report_moving.form.php b/front/report_moving.form.php index e7bb0ec..ea9b5b8 100644 --- a/front/report_moving.form.php +++ b/front/report_moving.form.php @@ -1,11 +1,10 @@ . -------------------------------------------------------------------------- - */ +*/ include('../../../inc/includes.php'); @@ -131,6 +130,4 @@ Html::displayRightError(); } -Html::footer(); - -?> \ No newline at end of file +Html::footer(); \ No newline at end of file diff --git a/front/report_occupation.form.php b/front/report_occupation.form.php index 68c30ee..4601d1b 100644 --- a/front/report_occupation.form.php +++ b/front/report_occupation.form.php @@ -1,11 +1,10 @@ . -------------------------------------------------------------------------- - */ +*/ include('../../../inc/includes.php'); @@ -50,7 +49,7 @@ $_POST["date1"] = $_POST["date2"]; $_POST["date2"] = $tmp; } - +$dbu = new DbUtils(); Report::title(); $PluginManageentitiesEntity = new PluginManageentitiesEntity(); if ($PluginManageentitiesEntity->canView() || Session::haveRight("config", UPDATE)) { @@ -68,7 +67,7 @@ $users = $user->find("`is_deleted` = 0 AND `entities_id` IN (" . implode(',', $_SESSION['glpiactiveentities']) . ")"); $techs = array(); foreach ($users as $data) { - $techs[$data['id']] = getUserName($data['id']); + $techs[$data['id']] = $dbu->getUserName($data['id']); } echo ""; @@ -104,12 +103,12 @@ Html::showDateField("date2", ['value' => $_POST["date2"]]); echo ""; //stats Users - + $dbu = new DbUtils(); $user = new User(); $users = $user->find("`is_deleted` = 0 AND `entities_id` IN (" . implode(',', $_SESSION['glpiactiveentities']) . ")"); $techs = array(); foreach ($users as $data) { - $techs[$data['id']] = getUserName($data['id']); + $techs[$data['id']] = $dbu->getUserName($data['id']); } echo ""; @@ -128,6 +127,4 @@ Html::displayRightError(); } -Html::footer(); - -?> \ No newline at end of file +Html::footer(); \ No newline at end of file diff --git a/front/taskcategory.form.php b/front/taskcategory.form.php index 99cfe03..c846776 100644 --- a/front/taskcategory.form.php +++ b/front/taskcategory.form.php @@ -1,11 +1,10 @@ . -------------------------------------------------------------------------- - */ +// */ include('../../../inc/includes.php'); @@ -37,6 +36,4 @@ if (isset ($_POST['update'])) { $taskCategory->update($_POST); Html::back(); -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/hook.php b/hook.php index 16e825f..d1a683b 100644 --- a/hook.php +++ b/hook.php @@ -1,11 +1,10 @@ tableExists("glpi_plugin_manageentities_critypes")) { - $DB->runFile(GLPI_ROOT . "/plugins/manageentities/install/sql/empty-2.1.5.sql"); + $DB->runFile(GLPI_ROOT . "/plugins/manageentities/install/sql/empty-3.0.0.sql"); $query = "INSERT INTO `glpi_plugin_manageentities_critypes` ( `id`, `name`) VALUES ('1', '" . __('Urgent intervention', 'manageentities') . "');"; @@ -160,7 +160,7 @@ function plugin_manageentities_install() { foreach ($index as $oldname => $newnames) { foreach ($newnames as $table) { - if (isIndex($table, $oldname)) { + if ($dbu->isIndex($table, $oldname)) { $query = "ALTER TABLE `$table` DROP INDEX `$oldname`;"; $result = $DB->query($query); } @@ -321,15 +321,33 @@ function plugin_manageentities_forceGroupBy($type) { } function plugin_manageentities_giveItem($type, $ID, $data, $num) { + global $DB; $searchopt =& Search::getOptions($type); $table = $searchopt[$ID]["table"]; $field = $searchopt[$ID]["field"]; - switch ($type) { case 'PluginManageentitiesCriType': switch ($table . '.' . $field) { case "glpi_plugin_manageentities_criprices.price" : + // $manageentitiesCritypes = new PluginManageentitiesCriType(); + // $manageentitiesCritypes->getFromDBByCrit(["id = $table.plugin_manageentities_critypes_id + // AND entities_id IN IN ('" . implode("','", $_SESSION["glpiactiveentities"]) . "')"]); + + $query = "SELECT * + FROM $table + WHERE id = $table.plugin_manageentities_critypes_id + AND entities_id IN ('" . implode("','", $_SESSION["glpiactiveentities"]) . "')"; + + $result = $DB->query($query); + if ($DB->numrows($result)) { + while ($datas = $DB->fetch_assoc($result)) { + $data["ITEM_4"] = $datas['price']; + } + } else { + $data["ITEM_4"] = 0; + } + $out = Html::formatnumber($data["ITEM_$num"], 2); return $out; break; @@ -402,7 +420,7 @@ function plugin_item_transfer_manageentities($parm) { $contract->getFromDB($parm['id']); $pluginContract = new PluginManageentitiesContract(); $old_entity = ''; - $restrict = "`glpi_plugin_manageentities_contracts`.`contracts_id` = '" . $parm['id'] . "'"; + $restrict = ["`glpi_plugin_manageentities_contracts`.`contracts_id`" => $parm['id']]; $allPluginContracts = $dbu->getAllDataFromTable('glpi_plugin_manageentities_contracts', $restrict); if (!empty($allPluginContracts)) { foreach ($allPluginContracts as $onePluginContract) { @@ -415,14 +433,14 @@ function plugin_item_transfer_manageentities($parm) { } $contractDay = new PluginManageentitiesContractDay(); - $condition = "`glpi_plugin_manageentities_contractdays`.`contracts_id` = '" . $parm['id'] . "'"; + $condition = ["`glpi_plugin_manageentities_contractdays`.`contracts_id`" => $parm['id']]; $allPluginContractDays = $dbu->getAllDataFromTable('glpi_plugin_manageentities_contractdays', $condition); if (!empty($allPluginContractDays)) { foreach ($allPluginContractDays as $onePluginContractDays) { $criPrice = new PluginManageentitiesCriPrice(); - $cond = "`glpi_plugin_manageentities_criprices`.`entities_id` = '" . $old_entity . "' - AND `glpi_plugin_manageentities_criprices`.`plugin_manageentities_critypes_id` = '" . - $onePluginContractDays['plugin_manageentities_critypes_id'] . "'"; + $cond = ["`glpi_plugin_manageentities_criprices`.`entities_id`" => $old_entity, + "`glpi_plugin_manageentities_criprices`.`plugin_manageentities_critypes_id`" => + $onePluginContractDays['plugin_manageentities_critypes_id']]; $allPrices = $dbu->getAllDataFromTable('glpi_plugin_manageentities_criprices', $cond); if (!empty($allPrices)) { foreach ($allPrices as $onePrice) { @@ -444,14 +462,14 @@ function plugin_item_transfer_manageentities($parm) { } $criDetail = new PluginManageentitiesCriDetail(); - $restr = "`glpi_plugin_manageentities_cridetails`.`contracts_id` = '" . $parm['id'] . "'"; + $restr = ["`glpi_plugin_manageentities_cridetails`.`contracts_id`" => $parm['id']]; $allPluginCriDetails = $dbu->getAllDataFromTable('glpi_plugin_manageentities_cridetails', $restr); if (!empty($allPluginCriDetails)) { foreach ($allPluginCriDetails as $onePluginCriDetail) { $criPrice = new PluginManageentitiesCriPrice(); - $cond = "`glpi_plugin_manageentities_criprices`.`entities_id` = '" . $old_entity . "' - AND `glpi_plugin_manageentities_criprices`.`plugin_manageentities_critypes_id` = '" . - $onePluginCriDetail['plugin_manageentities_critypes_id'] . "'"; + $cond = ["`glpi_plugin_manageentities_criprices`.`entities_id`" => $old_entity, + "`glpi_plugin_manageentities_criprices`.`plugin_manageentities_critypes_id`" => + $onePluginCriDetail['plugin_manageentities_critypes_id']]; $allPrices = $dbu->getAllDataFromTable('glpi_plugin_manageentities_criprices', $cond); if (!empty($allPrices)) { foreach ($allPrices as $onePrice) { @@ -610,6 +628,4 @@ function plugin_manageentities_displayConfigItem($type, $ID, $data, $num) { break; } return ""; -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/inc/addelementsmodel.class.php b/inc/addelementsmodel.class.php index 093aadd..a20f2c1 100644 --- a/inc/addelementsmodel.class.php +++ b/inc/addelementsmodel.class.php @@ -1,32 +1,31 @@ . - -------------------------------------------------------------------------- + You should have received a copy of the GNU General Public License + along with Manageentities. If not, see . + -------------------------------------------------------------------------- */ - if (!defined('GLPI_ROOT')) { die("Sorry. You can't access directly to this file"); } @@ -711,8 +710,9 @@ public function addInterventionToBase($pView, $idIntervention = -1) { if ($price != null && $intervention->fields['id'] <= 0) { $cprice = new PluginManageentitiesCriPrice(); $cprice->getEmpty(); - $query = "WHERE `entities_id`=" . $intervention->fields['entities_id'] . " AND `plugin_manageentities_critypes_id`=" . $intervention->fields['plugin_manageentities_critypes_id']; - $cprice->getFromDBByQuery($query); + $cprice->getFromDBByCrit(['entities_id' => $intervention->fields['entities_id'], + 'plugin_manageentities_critypes_id' => $intervention->fields['plugin_manageentities_critypes_id']]); + if (isset($cprice->fields['id']) && $cprice->fields['id'] > 0) { $typeInsert = DBOperation::UPDATE; } else { @@ -893,10 +893,8 @@ public function addCripriceToBase($pView, $tabIdIntervention, $typeIntervention) } public function deleteContractManagementType($pView) { - $restrict = "`glpi_plugin_manageentities_contracts`.`entities_id` = '" . - $_POST['entities_id'] . "' - AND `glpi_plugin_manageentities_contracts`.`contracts_id` = '" . - $_POST['contracts_id'] . "'"; + $restrict = ["`glpi_plugin_manageentities_contracts`.`entities_id`" => $_POST['entities_id'], + "`glpi_plugin_manageentities_contracts`.`contracts_id`" => $_POST['contracts_id']]; $dbu = new DbUtils(); $pluginContracts = $dbu->getAllDataFromTable("glpi_plugin_manageentities_contracts", $restrict); @@ -921,7 +919,8 @@ public function deleteContractManagementType($pView) { } public function getQueryForDFContract($item) { - $ID = $item->getField('id'); + $dbu = new DbUtils(); + $ID = $item->getField('id'); if ($item->isNewID($ID)) { return false; @@ -976,7 +975,7 @@ public function getQueryForDFContract($item) { AND `glpi_documents_items`.`itemtype` = '" . $item->getType() . "' "; if (Session::getLoginUserID()) { - $query .= getEntitiesRestrictRequest(" AND", "glpi_documents", '', '', true); + $query .= $dbu->getEntitiesRestrictRequest(" AND", "glpi_documents", '', '', true); } else { // Anonymous access from FAQ $query .= " AND `glpi_documents`.`entities_id`= '0' "; @@ -1006,8 +1005,7 @@ private function manageMEntitiesContacts($contact, $typeInsert, $pView) { break; case DBOperation::UPDATE: - $mEntitiesContact->getFromDBByQuery("WHERE `contacts_id`=" . $contact->fields['id']); - + $mEntitiesContact->getFromDBByCrit(['contacts_id' => $contact->fields['id']]); $mEntitiesContact->fields['contacts_id'] = $contact->fields['id']; $mEntitiesContact->fields['entities_id'] = $contact->fields['entities_id']; @@ -1023,7 +1021,8 @@ private function manageMEntitiesContacts($contact, $typeInsert, $pView) { case 'update-allothers': $dbu = new DbUtils(); - $condition = "`entities_id`=" . $contact->fields['entities_id'] . " AND `contacts_id` != " . $contact->fields['id']; + $condition = ["`entities_id`" => $contact->fields['entities_id'], + 'NOT' => ["`contacts_id`" => $contact->fields['id']]]; $contacts = $dbu->getAllDataFromTable(PluginManageentitiesContact::getTable(), $condition); if (sizeof($contacts) > 0) { @@ -1037,7 +1036,8 @@ private function manageMEntitiesContacts($contact, $typeInsert, $pView) { break; case 'update--force-false': - $mEntitiesContact->getFromDBByQuery("WHERE `entities_id`=" . $contact->fields['entities_id'] . " AND `contacts_id`=" . $contact->fields['id']); + $mEntitiesContact->getFromDBByCrit(['contacts_id' => $contact->fields['id'], + 'entities_id' => $contact->fields['entities_id']]); $mEntitiesContact->fields['is_default'] = 0; $this->persistData($mEntitiesContact, DBOperation::UPDATE); break; @@ -1053,8 +1053,7 @@ private function persistData(&$object, $typeInsert) { if ($object->getType() == Entity::getType()) { $tmpObj = clone $object; $tmpObj->getEmpty(); - $tmpObj->getFromDBByQuery("WHERE `name`='" . $object->fields['name'] . "'"); - + $tmpObj->getFromDBByCrit(['name' => $object->fields['name']]); if (isset($tmpObj->fields['id']) && $tmpObj->fields['id'] > 0) { return array(Status::NOT_ADDED => false, 'cause' => Errors::ERROR_NAME_EXIST); } @@ -1096,17 +1095,17 @@ public function storeDatasInSession($type, $object) { switch ($type) { case ElementType::ENTITY: - $object->fields['name'] = Html::cleanInputText(isset($_POST['new_entity_name']) ? $_POST['new_entity_name'] : ""); - $object->fields['comment'] = Html::cleanInputText(isset($_POST['new_entity_comment']) ? $_POST['new_entity_comment'] : ""); - $object->fields['phonenumber'] = Html::cleanInputText(isset($_POST['new_entity_phone']) ? $_POST['new_entity_phone'] : ""); - $object->fields['fax'] = Html::cleanInputText(isset($_POST['new_entity_fax']) ? $_POST['new_entity_fax'] : ""); - $object->fields['website'] = Html::cleanInputText(isset($_POST['new_entity_website']) ? $_POST['new_entity_website'] : ""); - $object->fields['email'] = Html::cleanInputText(isset($_POST['new_entity_email']) ? $_POST['new_entity_email'] : ""); - $object->fields['postcode'] = Html::cleanInputText(isset($_POST['new_entity_postcode']) ? $_POST['new_entity_postcode'] : ""); - $object->fields['state'] = Html::cleanInputText(isset($_POST['new_entity_state']) ? $_POST['new_entity_state'] : ""); - $object->fields['country'] = Html::cleanInputText(isset($_POST['new_entity_country']) ? $_POST['new_entity_country'] : ""); - $object->fields['town'] = Html::cleanInputText(isset($_POST['new_entity_city']) ? $_POST['new_entity_city'] : ""); - $object->fields['address'] = Html::cleanInputText(isset($_POST['new_entity_address']) ? $_POST['new_entity_address'] : ""); + $object->fields['name'] = isset($_POST['new_entity_name']) ? $_POST['new_entity_name'] : ""; + $object->fields['comment'] = isset($_POST['new_entity_comment']) ? $_POST['new_entity_comment'] : ""; + $object->fields['phonenumber'] = isset($_POST['new_entity_phone']) ? $_POST['new_entity_phone'] : ""; + $object->fields['fax'] = isset($_POST['new_entity_fax']) ? $_POST['new_entity_fax'] : ""; + $object->fields['website'] = isset($_POST['new_entity_website']) ? $_POST['new_entity_website'] : ""; + $object->fields['email'] = isset($_POST['new_entity_email']) ? $_POST['new_entity_email'] : ""; + $object->fields['postcode'] = isset($_POST['new_entity_postcode']) ? $_POST['new_entity_postcode'] : ""; + $object->fields['state'] = isset($_POST['new_entity_state']) ? $_POST['new_entity_state'] : ""; + $object->fields['country'] = isset($_POST['new_entity_country']) ? $_POST['new_entity_country'] : ""; + $object->fields['town'] = isset($_POST['new_entity_city']) ? $_POST['new_entity_city'] : ""; + $object->fields['address'] = isset($_POST['new_entity_address']) ? $_POST['new_entity_address'] : ""; $object->fields['entities_id'] = isset($_POST['new_entity_entities_id']) ? $_POST['new_entity_entities_id'] : ""; $this->setEntity($object); @@ -1282,9 +1281,9 @@ public function storeDatasInSession($type, $object) { public function getCriPriceFromType($post) { $criPrice = new PluginManageentitiesCriPrice(); - $criPrice->getFromDBByQuery("WHERE plugin_manageentities_critypes_id=" . $post['new_criprice_critype'] . " AND entities_id=" . $post['entities_id'] . - " AND plugin_manageentities_contractdays_id=" . $post['plugin_manageentities_contractdays_id']); - + $criPrice->getFromDBByCrit(['plugin_manageentities_critypes_id' => $post['new_criprice_critype'], + 'entities_id' => $post['entities_id'], + 'plugin_manageentities_contractdays_id' => $post['plugin_manageentities_contractdays_id']]); if (isset($criPrice->fields['id']) && $criPrice->fields['id'] > 0) { return $criPrice; } else { @@ -1303,8 +1302,8 @@ function isDateFormatOK($date, $format = 'd-m-Y') { public function getCripriceFromDB($critypeId, $entitiesId) { $cprice = new PluginManageentitiesCriPrice(); - $query = "WHERE `entities_id`=" . $entitiesId . " AND `plugin_manageentities_critypes_id`=" . $critypeId; - $cprice->getFromDBByQuery($query); + $cprice->getFromDBByCrit(['entities_id' => $entitiesId, + 'plugin_manageentities_critypes_id' => $critypeId]); if (isset($cprice->fields['id']) && $cprice->fields['id'] > 0) { return $cprice; } else { @@ -1338,7 +1337,7 @@ public function deleteError($id, $type, $opt = null) { public function getIconSrcFromExtension($ext) { $docType = new DocumentType(); - $docType->getFromDBByQuery("WHERE `ext` LIKE '" . $ext . "'"); + $docType->getFromDBByCrit(['ext' => $ext]); if (isset($docType->fields['id']) && $docType->fields['id'] > 0) { return $docType->fields['icon']; } else { @@ -1528,6 +1527,4 @@ static public function getType() { return "PluginManageentitiesAddElementsModel"; } -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/inc/addelementsview.class.php b/inc/addelementsview.class.php index 3a95105..11a501b 100644 --- a/inc/addelementsview.class.php +++ b/inc/addelementsview.class.php @@ -1,32 +1,31 @@ . - -------------------------------------------------------------------------- + You should have received a copy of the GNU General Public License + along with Manageentities. If not, see . + -------------------------------------------------------------------------- */ - if (!defined('GLPI_ROOT')) { die("Sorry. You can't access directly to this file"); } @@ -174,14 +173,17 @@ public function showForm() { } /** - * L'id�e globale, c'est que chacun des param�tres de la fonction initJSFunctions contient au minimum : + * L'id�e globale, c'est que chacun des param�tres de la fonction initJSFunctions contient au + * minimum : * - ['listId'] : la liste des id des diff�rents input o� les donn�es � sauvegarder sont * - ['idDivAjax'] : l'id de la div o� les r�sultats du traitement seront affich�s - * - ['params'] : diff�rent param�tres (dont le 'action' qui d�finit quel traitement doit �tre + * - ['params'] : diff�rent param�tres (dont le 'action' qui d�finit quel traitement doit + * �tre * effectu� depuis le controlleur) * * Pour contact et intervention, il contiennent en plus : - * - ['paramsAddNewContact'] : l'action / l'id de la div sont diff�rentes d'un ajout de contact / intervention + * - ['paramsAddNewContact'] : l'action / l'id de la div sont diff�rentes d'un ajout de + * contact / intervention * * @param $entityContent * @param $contactContent @@ -385,12 +387,12 @@ public function showFormAddEntity() { echo "" . __("As child of") . ""; echo ""; - - $condition = getEntitiesRestrictRequest("", "glpi_entities", "", "", true); - $idEntityChild = Dropdown::show(getItemTypeForTable(Entity::getTable()), array( + $dbu = new DbUtils(); + $condition = $dbu->getEntitiesRestrictRequest("", "glpi_entities", "", "", true); + $idEntityChild = Dropdown::show($dbu->getItemTypeForTable(Entity::getTable()), array( 'value' => $currentEntity->fields [$field ['name']], 'name' => $field ['name'], - 'used' => ($ID > 0 ? getSonsOf($currentEntity->getTable(), $ID) : array()), + 'used' => ($ID > 0 ? $dbu->getSonsOf($currentEntity->getTable(), $ID) : array()), 'condition' => $condition )); @@ -514,6 +516,7 @@ public function showFormAddContact($idContact = 0) { $contacts = $this->pModel->getContacts(); $currentContact = $contacts[$idContact]; + $dbu = new DbUtils(); // Onchange for img purpose echo "
"; - $condition = getEntitiesRestrictRequest("", "glpi_entities"); + $condition = $dbu->getEntitiesRestrictRequest("", "glpi_entities"); - $idDpEntity = Dropdown::show(getItemTypeForTable(Entity::getTable()), array( + $idDpEntity = Dropdown::show($dbu->getItemTypeForTable(Entity::getTable()), array( 'name' => 'contact_entities_id', 'value' => isset($currentContact->fields['entities_id']) ? $currentContact->fields ['entities_id'] : 0, 'emptylabel' => __("New entity", "manageentities"), @@ -779,7 +782,7 @@ public function showFormAddContract() { echo ""; // Liste des templates - $query = "`is_template`=1"; + $query = ["`is_template`" => 1]; $dbu = new DbUtils(); $listTemplate = $dbu->getAllDataFromTable($currentContract->getTable(), $query, false, "name ASC"); $listOptions = array("-1" => __("Blank Template")); @@ -810,14 +813,14 @@ public function showFormAddContract() { echo ""; echo "
getEntitiesRestrictRequest("", "glpi_entities"); if (isset($currentContract->fields['entities_id']) && isset($this->pModel->getEntity()->fields['id']) && $this->pModel->getEntity()->fields['id'] > 0 && $currentContract->fields['entities_id'] == $this->pModel->getEntity()->fields['id'] || ((!isset($currentContract->fields['entities_id']) || $currentContract->fields['entities_id'] == "") && isset($this->pModel->getEntity()->fields['id']) && $this->pModel->getEntity()->fields['id'] > 0)) { echo " style='visibility:hidden;' "; } echo " >"; - $idDpEntity = Dropdown::show(getItemTypeForTable($this->pModel->getEntity()->getTable()), array( + $idDpEntity = Dropdown::show($dbu->getItemTypeForTable($this->pModel->getEntity()->getTable()), array( 'name' => 'contract_entities_id', 'value' => isset($currentContract->fields['entities_id']) ? $currentContract->fields ['entities_id'] : 0, 'emptylabel' => __("New entity", "manageentities"), @@ -1193,6 +1196,7 @@ public function showFormAddPDFcontract() { } private function initFormAddPDFContract() { + $dbu = new DbUtils(); $this->pModel = PluginManageentitiesAddElementsModel::getInstance(); echo "