diff --git a/composer.lock b/composer.lock
index de54be1..2ddd4ce 100644
--- a/composer.lock
+++ b/composer.lock
@@ -971,16 +971,16 @@
},
{
"name": "phpstan/phpstan",
- "version": "2.1.8",
+ "version": "2.1.10",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
- "reference": "f9adff3b87c03b12cc7e46a30a524648e497758f"
+ "reference": "051a3b6b9b80df4ba3a7f801a8b53ad7d8f1c15f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpstan/phpstan/zipball/f9adff3b87c03b12cc7e46a30a524648e497758f",
- "reference": "f9adff3b87c03b12cc7e46a30a524648e497758f",
+ "url": "https://api.github.com/repos/phpstan/phpstan/zipball/051a3b6b9b80df4ba3a7f801a8b53ad7d8f1c15f",
+ "reference": "051a3b6b9b80df4ba3a7f801a8b53ad7d8f1c15f",
"shasum": ""
},
"require": {
@@ -1025,7 +1025,7 @@
"type": "github"
}
],
- "time": "2025-03-09T09:30:48+00:00"
+ "time": "2025-03-23T14:57:55+00:00"
},
{
"name": "phpstan/phpstan-deprecation-rules",
diff --git a/front/config.form.php b/front/config.form.php
index b8db3fe..9645c2b 100644
--- a/front/config.form.php
+++ b/front/config.form.php
@@ -43,5 +43,9 @@
Html::back();
}
+
+/** @var array $CFG_GLPI */
+global $CFG_GLPI;
+
Html::redirect($CFG_GLPI['root_doc'] . '/front/config.form.php?forcetab=' .
urlencode('PluginPdfConfig$1'));
diff --git a/front/export.massive.php b/front/export.massive.php
index 0373b58..ee15b60 100644
--- a/front/export.massive.php
+++ b/front/export.massive.php
@@ -40,6 +40,9 @@
$tab_id = unserialize($_SESSION['plugin_pdf']['tab_id']);
unset($_SESSION['plugin_pdf']['tab_id']);
+/** @var \DBmysql $DB */
+global $DB;
+
$result = $DB->request(
'glpi_plugin_pdf_preferences',
['SELECT' => 'tabref',
diff --git a/front/preference.form.php b/front/preference.form.php
index 67794f6..46e4ccc 100644
--- a/front/preference.form.php
+++ b/front/preference.form.php
@@ -32,24 +32,27 @@
include_once('../../../inc/includes.php');
+/** @var \DBmysql $DB */
+global $DB;
+
//Save user preferences
if (isset($_POST['plugin_pdf_user_preferences_save'])
&& isset($_POST['plugin_pdf_inventory_type'])) {
- $DB->query("DELETE
+ $DB->doQuery("DELETE
FROM `glpi_plugin_pdf_preferences`
WHERE `users_id` ='" . $_SESSION['glpiID'] . "'
AND `itemtype`='" . $_POST['plugin_pdf_inventory_type'] . "'");
if (isset($_POST['item'])) {
foreach ($_POST['item'] as $key => $val) {
- $DB->query("INSERT INTO `glpi_plugin_pdf_preferences`
+ $DB->doQuery("INSERT INTO `glpi_plugin_pdf_preferences`
(`id` ,`users_id` ,`itemtype` ,`tabref`)
VALUES (NULL , '" . $_SESSION['glpiID'] . "',
'" . $_POST['plugin_pdf_inventory_type'] . "', '$key')");
}
}
if (isset($_POST['page']) && $_POST['page']) {
- $DB->query("INSERT INTO `glpi_plugin_pdf_preferences`
+ $DB->doQuery("INSERT INTO `glpi_plugin_pdf_preferences`
(`id` ,`users_id` ,`itemtype` ,`tabref`)
VALUES (NULL , '" . $_SESSION['glpiID'] . "',
'" . $_POST['plugin_pdf_inventory_type'] . "', 'landscape')");
diff --git a/inc/appliance.class.php b/inc/appliance.class.php
index 0e99812..ce0e287 100644
--- a/inc/appliance.class.php
+++ b/inc/appliance.class.php
@@ -66,27 +66,29 @@ public function defineAllTabsPDF($options = [])
**/
public static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGLPI $item, $tab)
{
- switch ($tab) {
- case 'Appliance_Item$1':
- $plugin = new Plugin();
- if (
- $plugin->isActivated('appliances')
- && class_exists('PluginAppliancesAppliance_Item')
- ) {
- PluginAppliancesAppliance_Item::pdfForAppliance($pdf, $item);
- } else {
- self::pdfForAppliance($pdf, $item);
- }
- break;
+ if ($item instanceof Appliance) {
+ switch ($tab) {
+ case 'Appliance_Item$1':
+ $plugin = new Plugin();
+ if (
+ $plugin->isActivated('appliances')
+ && class_exists('PluginAppliancesAppliance_Item')
+ ) {
+ PluginAppliancesAppliance_Item::pdfForAppliance($pdf, $item);
+ } else {
+ self::pdfForAppliance($pdf, $item);
+ }
+ break;
- case 'PluginAppliancesOptvalue$1':
- if (class_exists('PluginAppliancesOptvalue')) {
- PluginAppliancesOptvalue::pdfForAppliance($pdf, $item);
- }
- break;
+ case 'PluginAppliancesOptvalue$1':
+ if (class_exists('PluginAppliancesOptvalue')) {
+ PluginAppliancesOptvalue::pdfForAppliance($pdf, $item);
+ }
+ break;
- default:
- return false;
+ default:
+ return false;
+ }
}
return true;
@@ -283,49 +285,48 @@ public static function pdfForAppliance(PluginPdfSimplePDF $pdf, Appliance $appli
}
$query['ORDER'] = ['glpi_entities.completename', $item->getTable() . '.' . $column];
- if ($result_linked = $DB->request($query)) {
- if (count($result_linked)) {
- foreach ($result_linked as $id => $data) {
- if (!$item->getFromDB($data['id'])) {
- continue;
- }
-
- if ($type == 'Ticket') {
- $data['name'] = sprintf(__('%1$s %2$s'), __('Ticket'), $data['id']);
- }
- if ($type == 'KnowbaseItem') {
- $data['name'] = $data['question'];
- }
- $name = $data['name'];
- if ($_SESSION['glpiis_ids_visible'] || empty($data['name'])) {
- $name = sprintf(__('%1$s (%2$s)'), $name, $data['id']);
- }
-
- if (Session::isMultiEntitiesMode()) {
- $pdf->setColumnsSize(12, 27, 25, 18, 18);
- $pdf->displayLine(
- $item->getTypeName(1),
- $name,
- Dropdown::getDropdownName(
- 'glpi_entities',
- $data['entities_id'],
- ),
- (isset($data['serial']) ? $data['serial'] : '-'),
- (isset($data['otherserial']) ? $data['otherserial'] : '-'),
- );
- } else {
- $pdf->setColumnsSize(25, 31, 22, 22);
- $pdf->displayTitle(
- $item->getTypeName(1),
- $name,
- (isset($data['serial']) ? $data['serial'] : '-'),
- (isset($data['otherserial']) ? $data['otherserial'] : '-'),
- );
- }
-
- if (!empty($data['IDD'])) {
- self::showList_relation($pdf, $data['IDD']);
- }
+ $result_linked = $DB->request($query);
+ if (count($result_linked)) {
+ foreach ($result_linked as $id => $data) {
+ if (!$item->getFromDB($data['id'])) {
+ continue;
+ }
+
+ if ($type == 'Ticket') {
+ $data['name'] = sprintf(__('%1$s %2$s'), __('Ticket'), $data['id']);
+ }
+ if ($type == 'KnowbaseItem') {
+ $data['name'] = $data['question'];
+ }
+ $name = $data['name'];
+ if (empty($data['name'])) {
+ $name = sprintf(__('%1$s (%2$s)'), $name, $data['id']);
+ }
+
+ if (Session::isMultiEntitiesMode()) {
+ $pdf->setColumnsSize(12, 27, 25, 18, 18);
+ $pdf->displayLine(
+ $item->getTypeName(1),
+ $name,
+ Dropdown::getDropdownName(
+ 'glpi_entities',
+ $data['entities_id'],
+ ),
+ (isset($data['serial']) ? $data['serial'] : '-'),
+ (isset($data['otherserial']) ? $data['otherserial'] : '-'),
+ );
+ } else {
+ $pdf->setColumnsSize(25, 31, 22, 22);
+ $pdf->displayTitle(
+ $item->getTypeName(1),
+ $name,
+ (isset($data['serial']) ? $data['serial'] : '-'),
+ (isset($data['otherserial']) ? $data['otherserial'] : '-'),
+ );
+ }
+
+ if (!empty($data['IDD'])) {
+ self::showList_relation($pdf, $data['IDD']);
}
}
}
@@ -425,7 +426,7 @@ public static function showList_PDF($pdf, $ID, $appliancesID)
));
}
- public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonGLPI $item)
+ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
{
/** @var DBmysql $DB */
global $DB;
diff --git a/inc/cartridge.class.php b/inc/cartridge.class.php
index 7927319..467e541 100644
--- a/inc/cartridge.class.php
+++ b/inc/cartridge.class.php
@@ -134,25 +134,24 @@ public static function pdfForPrinter(PluginPdfSimplePDF $pdf, Printer $p, $old =
$col1 = $data['id'];
$col2 = sprintf(__('%1$s - %2$s'), $data['type'], $data['ref']);
+ $col6 = $data['pages'];
+ $col7 = '';
$tmp_dbeg = explode('-', $data['date_in']);
$tmp_dend = explode('-', $data['date_use']);
- $stock_time_tmp = mktime(0, 0, 0, $tmp_dend[1], $tmp_dend[2], $tmp_dend[0])
- - mktime(0, 0, 0, $tmp_dbeg[1], $tmp_dbeg[2], $tmp_dbeg[0]);
+ $stock_time_tmp = mktime(0, 0, 0, (int) $tmp_dend[1], (int) $tmp_dend[2], (int) $tmp_dend[0])
+ - mktime(0, 0, 0, (int) $tmp_dbeg[1], (int) $tmp_dbeg[2], (int) $tmp_dbeg[0]);
$stock_time += $stock_time_tmp;
if ($old) {
$tmp_dbeg = explode('-', $data['date_use']);
$tmp_dend = explode('-', $data['date_out']);
- $use_time_tmp = mktime(0, 0, 0, $tmp_dend[1], $tmp_dend[2], $tmp_dend[0])
- - mktime(0, 0, 0, $tmp_dbeg[1], $tmp_dbeg[2], $tmp_dbeg[0]);
+ $use_time_tmp = mktime(0, 0, 0, (int) $tmp_dend[1], (int) $tmp_dend[2], (int) $tmp_dend[0])
+ - mktime(0, 0, 0, (int) $tmp_dbeg[1], (int) $tmp_dbeg[2], (int) $tmp_dbeg[0]);
$use_time += $use_time_tmp;
- $col6 = $data['pages'];
- $col7 = '';
-
if ($pages < $data['pages']) {
$pages_printed += $data['pages'] - $pages;
$nb_pages_printed++;
@@ -195,12 +194,12 @@ public static function pdfForPrinter(PluginPdfSimplePDF $pdf, Printer $p, $old =
'' . sprintf(
__('%1$s: %2$s'),
__('Average time in stock') . '',
- sprintf(_n('%d month', '%d months', $time_stock), $time_stock),
+ sprintf(_n('%d month', '%d months', (int) $time_stock), $time_stock),
),
'' . sprintf(
__('%1$s: %2$s'),
__('Average time in use') . '',
- sprintf(_n('%d month', '%d months', $time_use), $time_use),
+ sprintf(_n('%d month', '%d months', (int) $time_use), $time_use),
),
'' . sprintf(
__('%1$s: %2$s'),
@@ -328,16 +327,16 @@ public static function pdfForCartridgeItem(PluginPdfSimplePDF $pdf, CartridgeIte
if (!is_null($date_use)) {
$tmp_dbeg = explode('-', $data['date_in']);
$tmp_dend = explode('-', $data['date_use']);
- $stock_time_tmp = mktime(0, 0, 0, $tmp_dend[1], $tmp_dend[2], $tmp_dend[0])
- - mktime(0, 0, 0, $tmp_dbeg[1], $tmp_dbeg[2], $tmp_dbeg[0]);
+ $stock_time_tmp = mktime(0, 0, 0, (int) $tmp_dend[1], (int) $tmp_dend[2], (int) $tmp_dend[0])
+ - mktime(0, 0, 0, (int) $tmp_dbeg[1], (int) $tmp_dbeg[2], (int) $tmp_dbeg[0]);
$stock_time += $stock_time_tmp;
}
$pdfpages = '';
if ($state == 'old') {
$tmp_dbeg = explode('-', $data['date_use']);
$tmp_dend = explode('-', $data['date_out']);
- $use_time_tmp = mktime(0, 0, 0, $tmp_dend[1], $tmp_dend[2], $tmp_dend[0])
- - mktime(0, 0, 0, $tmp_dbeg[1], $tmp_dbeg[2], $tmp_dbeg[0]);
+ $use_time_tmp = mktime(0, 0, 0, (int) $tmp_dend[1], (int) $tmp_dend[2], (int) $tmp_dend[0])
+ - mktime(0, 0, 0, (int) $tmp_dbeg[1], (int) $tmp_dbeg[2], (int) $tmp_dbeg[0]);
$use_time += $use_time_tmp;
// Get initial counter page
@@ -365,7 +364,7 @@ public static function pdfForCartridgeItem(PluginPdfSimplePDF $pdf, CartridgeIte
);
}
- if (($state == 'old') && ($number > 0)) {
+ if ($state == 'old') {
if ($nb_pages_printed == 0) {
$nb_pages_printed = 1;
}
diff --git a/inc/cartridgeitem.class.php b/inc/cartridgeitem.class.php
index bd82546..af2a596 100644
--- a/inc/cartridgeitem.class.php
+++ b/inc/cartridgeitem.class.php
@@ -125,19 +125,21 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, CartridgeItem $cartitem)
public static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGLPI $item, $tab)
{
- switch ($tab) {
- case 'Cartridge$1':
- PluginPdfCartridge::pdfForCartridgeItem($pdf, $item, 'new');
- PluginPdfCartridge::pdfForCartridgeItem($pdf, $item, 'used');
- PluginPdfCartridge::pdfForCartridgeItem($pdf, $item, 'old');
- break;
-
- case 'CartridgeItem_PrinterModel$1':
- self::pdfForPrinterModel($pdf, $item);
- break;
-
- default:
- return false;
+ if ($item instanceof CartridgeItem) {
+ switch ($tab) {
+ case 'Cartridge$1':
+ PluginPdfCartridge::pdfForCartridgeItem($pdf, $item, 'new');
+ PluginPdfCartridge::pdfForCartridgeItem($pdf, $item, 'used');
+ PluginPdfCartridge::pdfForCartridgeItem($pdf, $item, 'old');
+ break;
+
+ case 'CartridgeItem_PrinterModel$1':
+ self::pdfForPrinterModel($pdf, $item);
+ break;
+
+ default:
+ return false;
+ }
}
return true;
@@ -152,6 +154,7 @@ public static function pdfForPrinterModel(PluginPdfSimplePDF $pdf, CartridgeItem
$iterator = CartridgeItem_PrinterModel::getListForItem($item);
$number = count($iterator);
+ $datas = [];
foreach ($iterator as $data) {
$datas[$data['linkid']] = $data;
@@ -160,7 +163,7 @@ public static function pdfForPrinterModel(PluginPdfSimplePDF $pdf, CartridgeItem
$pdf->setColumnsSize(100);
$title = '' . _n('Printer model', 'Printer models', $number) . '';
if (!$number) {
- $pdf->displayTitle(_('No printel model associated', 'pdf'));
+ $pdf->displayTitle(__('No printel model associated', 'pdf'));
} else {
if ($number > $_SESSION['glpilist_limit']) {
$title = sprintf(__('%1$s: %2$s'), $title, $_SESSION['glpilist_limit'] . ' / ' . $number);
diff --git a/inc/change.class.php b/inc/change.class.php
index 31b9660..d8405c6 100644
--- a/inc/change.class.php
+++ b/inc/change.class.php
@@ -192,6 +192,7 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Change $job)
$groups[] = Dropdown::getDropdownName('glpi_groups', $d['groups_id']);
}
if (count($groups)) {
+ $groups = array_filter($groups, 'is_string');
$listgroups = implode(', ', $groups);
}
$pdf->displayText($requestergroup, $listgroups, 1);
@@ -227,6 +228,7 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Change $job)
$groups[] = Dropdown::getDropdownName('glpi_groups', $d['groups_id']);
}
if (count($groups)) {
+ $groups = array_filter($groups, 'is_string');
$listgroups = implode(', ', $groups);
}
$pdf->displayText($watchergroup, $listgroups, 1);
@@ -266,6 +268,7 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Change $job)
$groups[] = Dropdown::getDropdownName('glpi_groups', $d['groups_id']);
}
if (count($groups)) {
+ $groups = array_filter($groups, 'is_string');
$listgroups = implode(', ', $groups);
}
$pdf->displayText($assigngroup, $listgroups, 1);
@@ -374,7 +377,7 @@ public static function pdfStat(PluginPdfSimplePDF $pdf, Change $job)
$pdf->setColumnsSize(50, 50);
if (isset($job->fields['takeintoaccount_delay_stat']) > 0) {
if ($job->fields['takeintoaccount_delay_stat'] > 0) {
- $accountdelay = Toolbox::stripTags(Html::timestampToString($job->fields['takeintoaccount_delay_stat'], 0));
+ $accountdelay = Toolbox::stripTags(Html::timestampToString($job->fields['takeintoaccount_delay_stat'], false));
}
$pdf->displayLine(
__('Take into account'),
@@ -387,7 +390,7 @@ public static function pdfStat(PluginPdfSimplePDF $pdf, Change $job)
if ($job->fields['solve_delay_stat'] > 0) {
$pdf->displayLine(
__('Resolution'),
- Toolbox::stripTags(Html::timestampToString($job->fields['solve_delay_stat'], 0)),
+ Toolbox::stripTags(Html::timestampToString($job->fields['solve_delay_stat'], false)),
);
}
}
@@ -395,14 +398,14 @@ public static function pdfStat(PluginPdfSimplePDF $pdf, Change $job)
if ($job->fields['close_delay_stat'] > 0) {
$pdf->displayLine(
__('Closing'),
- Toolbox::stripTags(Html::timestampToString($job->fields['close_delay_stat'], 0)),
+ Toolbox::stripTags(Html::timestampToString($job->fields['close_delay_stat'], false)),
);
}
}
if ($job->fields['waiting_duration'] > 0) {
$pdf->displayLine(
__('Pending'),
- Toolbox::stripTags(Html::timestampToString($job->fields['waiting_duration'], 0)),
+ Toolbox::stripTags(Html::timestampToString($job->fields['waiting_duration'], false)),
);
}
@@ -428,66 +431,68 @@ public static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGL
{
$private = isset($_REQUEST['item']['_private_']);
- switch ($tab) {
- case '_private_':
- // nothing to export, just a flag
- break;
-
- case 'Change$main':
- self::pdfMain($pdf, $item);
- PluginPdfItilFollowup::pdfForItem($pdf, $item, $private);
- PluginPdfChangeTask::pdfForChange($pdf, $item, $private);
- if (Session::haveRight('document', READ)) {
- PluginPdfDocument::pdfForItem($pdf, $item);
- }
- PluginPdfITILSolution::pdfForItem($pdf, $item);
- self::pdfPlan($pdf, $item);
- self::pdfAnalysis($pdf, $item);
- break;
-
- case 'Change$1':
- self::pdfAnalysis($pdf, $item);
- break;
-
- case 'Change$3':
- self::pdfPlan($pdf, $item);
- break;
-
- case 'Change$4':
- self::pdfStat($pdf, $item);
- break;
-
- case 'Change$5':
- PluginPdfItilFollowup::pdfForItem($pdf, $item, $private);
- PluginPdfChangeTask::pdfForChange($pdf, $item, $private);
- if (Session::haveRight('document', READ)) {
- PluginPdfDocument::pdfForItem($pdf, $item);
- }
- PluginPdfITILSolution::pdfForItem($pdf, $item);
- break;
-
- case 'ChangeValidation$1':
- PluginPdfChangeValidation::pdfForChange($pdf, $item);
- break;
-
- case 'ChangeCost$1':
- PluginPdfCommonItilCost::pdfForItem($pdf, $item);
- break;
-
- case 'Change_Problem$1':
- PluginPdfChange_Problem::pdfForChange($pdf, $item);
- break;
-
- case 'Change_Ticket$1':
- PluginPdfChange_Ticket::pdfForChange($pdf, $item);
- break;
-
- case 'Change_Item$1':
- PluginPdfChange_Item::pdfForChange($pdf, $item);
- break;
-
- default:
- return false;
+ if ($item instanceof Change) {
+ switch ($tab) {
+ case '_private_':
+ // nothing to export, just a flag
+ break;
+
+ case 'Change$main':
+ self::pdfMain($pdf, $item);
+ PluginPdfItilFollowup::pdfForItem($pdf, $item, $private);
+ PluginPdfChangeTask::pdfForChange($pdf, $item);
+ if (Session::haveRight('document', READ)) {
+ PluginPdfDocument::pdfForItem($pdf, $item);
+ }
+ PluginPdfITILSolution::pdfForItem($pdf, $item);
+ self::pdfPlan($pdf, $item);
+ self::pdfAnalysis($pdf, $item);
+ break;
+
+ case 'Change$1':
+ self::pdfAnalysis($pdf, $item);
+ break;
+
+ case 'Change$3':
+ self::pdfPlan($pdf, $item);
+ break;
+
+ case 'Change$4':
+ self::pdfStat($pdf, $item);
+ break;
+
+ case 'Change$5':
+ PluginPdfItilFollowup::pdfForItem($pdf, $item, $private);
+ PluginPdfChangeTask::pdfForChange($pdf, $item);
+ if (Session::haveRight('document', READ)) {
+ PluginPdfDocument::pdfForItem($pdf, $item);
+ }
+ PluginPdfITILSolution::pdfForItem($pdf, $item);
+ break;
+
+ case 'ChangeValidation$1':
+ PluginPdfChangeValidation::pdfForChange($pdf, $item);
+ break;
+
+ case 'ChangeCost$1':
+ PluginPdfCommonItilCost::pdfForItem($pdf, $item);
+ break;
+
+ case 'Change_Problem$1':
+ PluginPdfChange_Problem::pdfForChange($pdf, $item);
+ break;
+
+ case 'Change_Ticket$1':
+ PluginPdfChange_Ticket::pdfForChange($pdf, $item);
+ break;
+
+ case 'Change_Item$1':
+ PluginPdfChange_Item::pdfForChange($pdf, $item);
+ break;
+
+ default:
+ return false;
+ }
}
return true;
diff --git a/inc/change_item.class.php b/inc/change_item.class.php
index dc79da5..befcdd5 100644
--- a/inc/change_item.class.php
+++ b/inc/change_item.class.php
@@ -193,6 +193,8 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item, $tr
break;
}
+ $SELECT = '';
+ $FROM = '';
if (count($_SESSION['glpiactiveentities']) > 1) {
$SELECT = ', `glpi_entities`.`completename` AS entityname,
`glpi_changes`.`entities_id` AS entityID ';
diff --git a/inc/changetask.class.php b/inc/changetask.class.php
index 46707d0..0527618 100644
--- a/inc/changetask.class.php
+++ b/inc/changetask.class.php
@@ -114,7 +114,7 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $job)
$pdf->displayLine(
'' . Toolbox::stripTags($lib),
Html::convDateTime($data['date']),
- Html::timestampToString($data['actiontime'], 0),
+ Html::timestampToString($data['actiontime'], false),
Toolbox::stripTags($dbu->getUserName($data['users_id'])),
Toolbox::stripTags($planification),
1,
diff --git a/inc/common.class.php b/inc/common.class.php
index a24cce2..a6ee457 100644
--- a/inc/common.class.php
+++ b/inc/common.class.php
@@ -40,7 +40,12 @@ abstract class PluginPdfCommon extends CommonGLPI
/**
* Constructor, should intialize $this->obj property
**/
- public function __construct(CommonGLPI $obj = null) {}
+ public function __construct(CommonGLPI $obj = null)
+ {
+ if ($obj) {
+ $this->obj = $obj;
+ }
+ }
/**
* Add standard define tab
@@ -49,7 +54,7 @@ public function __construct(CommonGLPI $obj = null) {}
* @param $ong array defined tab array
* @param $options array of options (for withtemplate)
*
- * @return void (set the tab array)
+ * @return CommonGLPI (set the tab array)
**/
final public function addStandardTab($itemtype, &$ong, $options)
{
@@ -60,7 +65,7 @@ final public function addStandardTab($itemtype, &$ong, $options)
$withtemplate = $options['withtemplate'];
}
- if (!is_integer($itemtype)
+ if (!is_numeric($itemtype)
&& ($obj = $dbu->getItemForItemtype($itemtype))) {
if (method_exists($itemtype, 'displayTabContentForPDF')
&& !($obj instanceof PluginPdfCommon)) {
@@ -76,6 +81,7 @@ final public function addStandardTab($itemtype, &$ong, $options)
}
}
}
+ return $this;
}
/**
@@ -116,7 +122,7 @@ public function defineAllTabsPDF($options = [])
public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
{
if (Session::haveRight('plugin_pdf', READ)) {
- if (!isset($withtemplate) || empty($withtemplate)) {
+ if (empty($withtemplate)) {
return __('Print to pdf', 'pdf');
}
}
@@ -133,7 +139,7 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
* @param $item CommonGLPI object for which the tab need to be displayed
* @param $tab string tab number
*
- * @return true if display done (else will search for another handler)
+ * @return bool true if display done (else will search for another handler)
**/
public static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGLPI $item, $tab)
{
@@ -149,111 +155,113 @@ public static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGL
* @param $item CommonGLPI object for which the tab need to be displayed
* @param $tab string tab number
*
- * @return true if display done (else will search for another handler)
+ * @return bool true if display done (else will search for another handler)
**/
final public static function displayCommonTabForPDF(PluginPdfSimplePDF $pdf, CommonGLPI $item, $tab)
{
- switch ($tab) {
- case $item->getType() . '$main':
- $item::pdfMain($pdf, $item);
- break;
-
- case 'Notepad$1':
- if (Session::haveRight($item::$rightname, READNOTE)) {
- self::pdfNote($pdf, $item);
- }
- break;
+ if ($item instanceof CommonDBTM) {
+ switch ($tab) {
+ case $item->getType() . '$main':
+ $item::pdfMain($pdf, $item); // @phpstan-ignore-line - Call to an undefined static method CommonGLPI::pdfMain()
+ break;
+
+ case 'Notepad$1':
+ if (Session::haveRight($item::$rightname, READNOTE)) {
+ self::pdfNote($pdf, $item);
+ }
+ break;
- case 'Document_Item$1':
- if (Session::haveRight('document', READ)) {
- PluginPdfDocument::pdfForItem($pdf, $item);
- }
- break;
+ case 'Document_Item$1':
+ if (Session::haveRight('document', READ)) {
+ PluginPdfDocument::pdfForItem($pdf, $item);
+ }
+ break;
- case 'NetworkPort$1':
- PluginPdfNetworkPort::pdfForItem($pdf, $item);
- break;
+ case 'NetworkPort$1':
+ PluginPdfNetworkPort::pdfForItem($pdf, $item);
+ break;
- case 'Infocom$1':
- if (Session::haveRight('infocom', READ)) {
- PluginPdfInfocom::pdfForItem($pdf, $item);
- }
- break;
+ case 'Infocom$1':
+ if (Session::haveRight('infocom', READ)) {
+ PluginPdfInfocom::pdfForItem($pdf, $item);
+ }
+ break;
- case 'Contract_Item$1':
- if (Session::haveRight('contract', READ)) {
- PluginPdfContract_Item::pdfForItem($pdf, $item);
- }
- break;
+ case 'Contract_Item$1':
+ if (Session::haveRight('contract', READ)) {
+ PluginPdfContract_Item::pdfForItem($pdf, $item);
+ }
+ break;
- case 'Ticket$1':
- if (Ticket::canView()) {
- PluginPdfItem_Ticket::pdfForItem($pdf, $item);
- }
- break;
+ case 'Ticket$1':
+ if (Ticket::canView()) {
+ PluginPdfItem_Ticket::pdfForItem($pdf, $item);
+ }
+ break;
- case 'Item_Problem$1':
- if (Problem::canView()) {
- PluginPdfItem_Problem::pdfForItem($pdf, $item);
- }
- break;
+ case 'Item_Problem$1':
+ if (Problem::canView()) {
+ PluginPdfItem_Problem::pdfForItem($pdf, $item);
+ }
+ break;
- case 'Change_Item$1':
- if (Change::canView()) {
- PluginPdfChange_Item::pdfForItem($pdf, $item);
- }
- break;
+ case 'Change_Item$1':
+ if (Change::canView()) {
+ PluginPdfChange_Item::pdfForItem($pdf, $item);
+ }
+ break;
- case 'ManualLink$1':
- if (Session::haveRight('link', READ)) {
- PluginPdfLink::pdfForItem($pdf, $item);
- }
- break;
+ case 'ManualLink$1':
+ if (Session::haveRight('link', READ)) {
+ PluginPdfLink::pdfForItem($pdf, $item);
+ }
+ break;
- case 'Reservation$1':
- if (Session::haveRight('reservation', READ)) {
- PluginPdfReservation::pdfForItem($pdf, $item);
- }
- break;
+ case 'Reservation$1':
+ if (Session::haveRight('reservation', READ)) {
+ PluginPdfReservation::pdfForItem($pdf, $item);
+ }
+ break;
- case 'Log$1':
- PluginPdfLog::pdfForItem($pdf, $item);
- break;
+ case 'Log$1':
+ PluginPdfLog::pdfForItem($pdf, $item);
+ break;
- case 'KnowbaseItem_Item$1':
- if (KnowbaseItem::canView()) {
- PluginPdfItem_Knowbaseitem::pdfForItem($pdf, $item);
- }
- break;
+ case 'KnowbaseItem_Item$1':
+ if (KnowbaseItem::canView()) {
+ PluginPdfItem_Knowbaseitem::pdfForItem($pdf, $item);
+ }
+ break;
- case 'Item_Devices$1':
- if (Session::haveRight('device', READ)) {
- PluginPdfItem_Device::pdfForItem($pdf, $item);
- }
- break;
+ case 'Item_Devices$1':
+ if (Session::haveRight('device', READ)) {
+ PluginPdfItem_Device::pdfForItem($pdf, $item);
+ }
+ break;
- case 'Item_Disk$1':
- PluginPdfItem_Disk::pdfForItem($pdf, $item);
- break;
+ case 'Item_Disk$1':
+ PluginPdfItem_Disk::pdfForItem($pdf, $item);
+ break;
- case 'Computer_Item$1':
- PluginPdfComputer_Item::pdfForItem($pdf, $item);
- break;
+ case 'Computer_Item$1':
+ PluginPdfComputer_Item::pdfForItem($pdf, $item);
+ break;
- case 'Item_SoftwareVersion$1':
- PluginPdfItem_SoftwareVersion::pdfForItem($pdf, $item);
- break;
+ case 'Item_SoftwareVersion$1':
+ PluginPdfItem_SoftwareVersion::pdfForItem($pdf, $item);
+ break;
- case 'Domain_Item$1':
- PluginPdfDomain_Item::pdfForItem($pdf, $item);
- break;
+ case 'Domain_Item$1':
+ PluginPdfDomain_Item::pdfForItem($pdf, $item);
+ break;
- case 'Item_OperatingSystem$1':
- PluginPdfItem_OperatingSystem::pdfForItem($pdf, $item);
- break;
+ case 'Item_OperatingSystem$1':
+ PluginPdfItem_OperatingSystem::pdfForItem($pdf, $item);
+ break;
- default:
- return false;
+ default:
+ return false;
+ }
}
return true;
@@ -343,9 +351,6 @@ public static function pdfNote(PluginPdfSimplePDF $pdf, CommonDBTM $item)
if (!empty($note['content']) && ($tot < $_SESSION['glpilist_limit'])) {
$id = 'note' . $note['id'] . $rand;
$content = $note['content'];
- if (empty($content)) {
- $content = NOT_AVAILABLE;
- }
$pdf->displayText('', $content, 5);
$tot++;
}
@@ -386,7 +391,7 @@ final public function generatePDF($tab_id, $tabs, $page = 0, $render = true)
// Default set
$tabnum = (isset($data[1]) ? $data[1] : 1);
- if (!is_integer($itemtype)
+ if (!is_numeric($itemtype)
&& ($itemtype != 'empty')) {
if ($itemtype == 'Item_Devices') {
$PluginPdfComputer = new PluginPdfComputer();
@@ -608,6 +613,7 @@ public static function processMassiveActionsForOneItemtype(
) {
switch ($ma->getAction()) {
case 'DoIt':
+ $tab_id = [];
foreach ($ids as $key => $val) {
if ($val) {
$tab_id[] = $key;
diff --git a/inc/computer.class.php b/inc/computer.class.php
index 19b5a54..0020194 100644
--- a/inc/computer.class.php
+++ b/inc/computer.class.php
@@ -186,21 +186,23 @@ public static function pdfOperatingSystem(PluginPdfSimplePDF $pdf, Computer $com
public static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGLPI $item, $tab)
{
- switch ($tab) {
- case 'ComputerVirtualMachine$1':
- PluginPdfComputerVirtualMachine::pdfForComputer($pdf, $item);
- break;
-
- case 'ComputerAntivirus$1':
- PluginPdfComputerAntivirus::pdfForComputer($pdf, $item);
- break;
-
- case 'Computer_Item$1':
- PluginPdfComputer_Item::pdfForComputer($pdf, $item);
- break;
-
- default:
- return false;
+ if ($item instanceof Computer) {
+ switch ($tab) {
+ case 'ComputerVirtualMachine$1':
+ PluginPdfComputerVirtualMachine::pdfForComputer($pdf, $item);
+ break;
+
+ case 'ComputerAntivirus$1':
+ PluginPdfComputerAntivirus::pdfForComputer($pdf, $item);
+ break;
+
+ case 'Computer_Item$1':
+ PluginPdfComputer_Item::pdfForComputer($pdf, $item);
+ break;
+
+ default:
+ return false;
+ }
}
return true;
diff --git a/inc/computer_item.class.php b/inc/computer_item.class.php
index 4bdb318..a57f48a 100644
--- a/inc/computer_item.class.php
+++ b/inc/computer_item.class.php
@@ -183,91 +183,90 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$pdf->setColumnsSize(100);
$title = '' . __('Direct connections') . '';
- if ($result = $DB->request(
+ $result = $DB->request(
'glpi_computers_items',
['items_id' => $ID,
'itemtype' => $type],
- )) {
- $resultnum = count($result);
+ );
+ $resultnum = count($result);
- if (!$resultnum) {
- $pdf->displayTitle(sprintf(__('%1$s: %2$s'), $title, __('No item to display')));
- } else {
- $pdf->displayTitle($title);
+ if (!$resultnum) {
+ $pdf->displayTitle(sprintf(__('%1$s: %2$s'), $title, __('No item to display')));
+ } else {
+ $pdf->displayTitle($title);
- foreach ($result as $row) {
- $tID = $row['computers_id'];
- $connID = $row['id'];
- $comp->getFromDB($tID);
- $info->getFromDBforDevice('Computer', $tID) || $info->getEmpty();
+ foreach ($result as $row) {
+ $tID = $row['computers_id'];
+ $connID = $row['id'];
+ $comp->getFromDB($tID);
+ $info->getFromDBforDevice('Computer', $tID) || $info->getEmpty();
- $line1 = (isset($comp->fields['name']) ? $comp->fields['name'] : '(' . $comp->fields['id'] . ')');
- if (isset($comp->fields['states_id'])) {
- $line1 = sprintf(
- __('%1$s - %2$s'),
- $line1,
- sprintf(
- __('%1$s: %2$s'),
- '' . __('Status') . '',
- Toolbox::stripTags(Dropdown::getDropdownName(
- 'glpi_states',
- $comp->fields['states_id'],
- )),
- ),
- );
- }
- if (isset($comp->fields['serial'])) {
- $line1 = sprintf(
- __('%1$s - %2$s'),
- $line1,
- sprintf(
- __('%1$s: %2$s'),
- '' . __('Serial number') . '',
- $comp->fields['serial'],
- ),
- );
- }
+ $line1 = (isset($comp->fields['name']) ? $comp->fields['name'] : '(' . $comp->fields['id'] . ')');
+ if (isset($comp->fields['states_id'])) {
+ $line1 = sprintf(
+ __('%1$s - %2$s'),
+ $line1,
+ sprintf(
+ __('%1$s: %2$s'),
+ '' . __('Status') . '',
+ Toolbox::stripTags(Dropdown::getDropdownName(
+ 'glpi_states',
+ $comp->fields['states_id'],
+ )),
+ ),
+ );
+ }
+ if (isset($comp->fields['serial'])) {
+ $line1 = sprintf(
+ __('%1$s - %2$s'),
+ $line1,
+ sprintf(
+ __('%1$s: %2$s'),
+ '' . __('Serial number') . '',
+ $comp->fields['serial'],
+ ),
+ );
+ }
- if (isset($comp->fields['otherserial'])) {
- $line1 = sprintf(
- __('%1$s - %2$s'),
- $line1,
- sprintf(
- __('%1$s: %2$s'),
- '' . __('Inventory number') . '',
- $item->getField('otherserial'),
- ),
- );
- }
- $line2 = '';
- if ($info->fields['immo_number']) {
- $line2 = sprintf(
- __('%1$s - %2$s'),
- $line2,
- sprintf(
- __('%1$s: %2$s'),
- '' . __('Immobilization number') . '',
- $info->fields['immo_number'],
- ),
- );
- }
- if ($line2) {
- $pdf->displayText(
- '' . sprintf(__('%1$s: %2$s'), __('Computer') . '', ''),
- $line1 . "\n" . $line2,
- 2,
- );
- } else {
- $pdf->displayText(
- '' . sprintf(__('%1$s: %2$s'), __('Computer') . '', ''),
- $line1,
- 1,
- );
- }
- }// each device of current type
- } // No row
- } // Result
+ if (isset($comp->fields['otherserial'])) {
+ $line1 = sprintf(
+ __('%1$s - %2$s'),
+ $line1,
+ sprintf(
+ __('%1$s: %2$s'),
+ '' . __('Inventory number') . '',
+ $item->getField('otherserial'),
+ ),
+ );
+ }
+ $line2 = '';
+ if ($info->fields['immo_number']) {
+ $line2 = sprintf(
+ __('%1$s - %2$s'),
+ $line2,
+ sprintf(
+ __('%1$s: %2$s'),
+ '' . __('Immobilization number') . '',
+ $info->fields['immo_number'],
+ ),
+ );
+ }
+ if ($line2) {
+ $pdf->displayText(
+ '' . sprintf(__('%1$s: %2$s'), __('Computer') . '', ''),
+ $line1 . "\n" . $line2,
+ 2,
+ );
+ } else {
+ $pdf->displayText(
+ '' . sprintf(__('%1$s: %2$s'), __('Computer') . '', ''),
+ $line1,
+ 1,
+ );
+ }
+ }// each device of current type
+ } // No row
$pdf->displaySpace();
}
}
diff --git a/inc/computer_softwarelicense.class.php b/inc/computer_softwarelicense.class.php
index 638fce8..60fc5e2 100644
--- a/inc/computer_softwarelicense.class.php
+++ b/inc/computer_softwarelicense.class.php
@@ -105,9 +105,8 @@ public static function pdfForLicenseByComputer(PluginPdfSimplePDF $pdf, Software
+ $dbu->getEntitiesRestrictCriteria('glpi_computers')];
$number = 0;
- if ($result = $DB->request($query)) {
- $number = count($result);
- }
+ $result = $DB->request($query);
+ $number = count($result);
$pdf->setColumnsSize(100);
$pdf->setColumnsAlign('center');
@@ -185,7 +184,7 @@ public static function pdfForLicenseByComputer(PluginPdfSimplePDF $pdf, Software
}
foreach ($result as $data) {
$compname = $data['compname'];
- if (empty($compname) || $_SESSION['glpiis_ids_visible']) {
+ if (empty($compname)) {
$compname = sprintf(__('%1$s (%2$s)'), $compname, $data['cID']);
}
$entname = (empty($data['entity']) ? __('Root entity') : $data['entity']);
diff --git a/inc/computer_softwareversion.class.php b/inc/computer_softwareversion.class.php
index 2844bb8..c0b1bdd 100644
--- a/inc/computer_softwareversion.class.php
+++ b/inc/computer_softwareversion.class.php
@@ -74,10 +74,9 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
}
$total = 0;
- if ($result = $DB->request($query_number)) {
- foreach ($result as $row) {
- $total = $row['cpt'];
- }
+ $result = $DB->request($query_number);
+ foreach ($result as $row) {
+ $total = $row['cpt'];
}
$query = "SELECT DISTINCT `glpi_computers_softwareversions`.*,
@@ -118,8 +117,8 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$pdf->setColumnsSize(100);
- if (($result = $DB->request($query))
- && (($number = count($result)) > 0)) {
+ $result = $DB->request($query);
+ if (($number = count($result)) > 0) {
if ($number == $total) {
$pdf->displayTitle('' . sprintf(
__('%1$s: %2$s'),
@@ -149,7 +148,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
foreach ($result as $data) {
$compname = $data['compname'];
- if (empty($compname) || $_SESSION['glpiis_ids_visible']) {
+ if (empty($compname)) {
$compname = sprintf(__('%1$s (%2$s)'), $compname, $data['cID']);
}
$lics = Item_SoftwareLicense::GetLicenseForInstallation(
@@ -220,7 +219,7 @@ public static function pdfForVersionByEntity(PluginPdfSimplePDF $pdf, SoftwareVe
$lig = $tot = 0;
if (in_array(0, $_SESSION['glpiactiveentities'])) {
- $nb = Item_SoftwareVersion::countForVersion('Computer', $softwareversions_id, 0);
+ $nb = Item_SoftwareVersion::countForVersion($softwareversions_id, '0');
if ($nb > 0) {
$pdf->displayLine(__('Root entity'), $nb);
$tot += $nb;
@@ -233,7 +232,7 @@ public static function pdfForVersionByEntity(PluginPdfSimplePDF $pdf, SoftwareVe
'ORDER' => 'completename'];
foreach ($DB->request($sql) as $ID => $data) {
- $nb = Item_SoftwareVersion::countForVersion('Computer', $softwareversions_id, $ID);
+ $nb = Item_SoftwareVersion::countForVersion($softwareversions_id, $ID);
if ($nb > 0) {
$pdf->displayLine($data['completename'], $nb);
$tot += $nb;
diff --git a/inc/config.class.php b/inc/config.class.php
index c523802..720b0b6 100644
--- a/inc/config.class.php
+++ b/inc/config.class.php
@@ -82,7 +82,7 @@ public static function getTypeName($nb = 0)
return __('Setup');
}
- public function getName($with_comment = 0)
+ public function getName($params = [])
{
return __('Print to pdf', 'pdf');
}
@@ -364,6 +364,7 @@ public static function formatNumber($value)
$config = new Config();
+ $language = '';
foreach ($config->find(['context' => 'core',
'name' => 'language']) as $row) {
$language = $row['value'];
diff --git a/inc/consumableitem.class.php b/inc/consumableitem.class.php
index c0928f1..58a5b3a 100644
--- a/inc/consumableitem.class.php
+++ b/inc/consumableitem.class.php
@@ -122,14 +122,16 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, ConsumableItem $consitem
public static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGLPI $item, $tab)
{
- switch ($tab) {
- case 'Consumable$1':
- self::pdfForConsumableItem($pdf, $item, false);
- self::pdfForConsumableItem($pdf, $item, true);
- break;
-
- default:
- return false;
+ if ($item instanceof ConsumableItem) {
+ switch ($tab) {
+ case 'Consumable$1':
+ self::pdfForConsumableItem($pdf, $item, false);
+ self::pdfForConsumableItem($pdf, $item, true);
+ break;
+
+ default:
+ return false;
+ }
}
return true;
@@ -218,6 +220,7 @@ public static function pdfForConsumableItem(PluginPdfSimplePDF $pdf, ConsumableI
$pdf->setColumnsSize(10, 45, 45);
$pdf->displayLine($data['id'], Consumable::getStatus($data['id']), $date_in);
} else {
+ $name = '';
if ($item = getItemForItemtype($data['itemtype'])) {
if ($item->getFromDB($data['items_id'])) {
$name = $item->getNameID();
diff --git a/inc/contract.class.php b/inc/contract.class.php
index 783a73d..40c66ef 100644
--- a/inc/contract.class.php
+++ b/inc/contract.class.php
@@ -184,17 +184,19 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Contract $contract)
public static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGLPI $item, $tab)
{
- switch ($tab) {
- case 'ContractCost$1':
- PluginPdfContract::pdfCost($pdf, $item);
- break;
+ if ($item instanceof Contract) {
+ switch ($tab) {
+ case 'ContractCost$1':
+ PluginPdfContract::pdfCost($pdf, $item);
+ break;
- case 'Contract_Item$1':
- PluginPdfContract_Item::pdfForContract($pdf, $item);
- break;
+ case 'Contract_Item$1':
+ PluginPdfContract_Item::pdfForContract($pdf, $item);
+ break;
- default:
- return false;
+ default:
+ return false;
+ }
}
return true;
diff --git a/inc/contract_item.class.php b/inc/contract_item.class.php
index 41f6251..2d13e88 100644
--- a/inc/contract_item.class.php
+++ b/inc/contract_item.class.php
@@ -234,8 +234,7 @@ public static function pdfForContract(PluginPdfSimplePDF $pdf, Contract $contrac
} else {
$name = $objdata['name'];
}
- if ($_SESSION['glpiis_ids_visible']
- || empty($data['name'])) {
+ if (empty($data['name'])) {
$name = sprintf(__('%1$s (%2$s)'), $name, $objdata['id']);
}
diff --git a/inc/group.class.php b/inc/group.class.php
index f03b235..5bf83a2 100644
--- a/inc/group.class.php
+++ b/inc/group.class.php
@@ -293,29 +293,31 @@ public static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGL
$tree = isset($_REQUEST['item']['_tree']);
$user = isset($_REQUEST['item']['_user']);
- switch ($tab) {
- case 'Group$1':
- self::pdfItems($pdf, $item, false, $tree, $user);
- break;
-
- case 'Group$2':
- self::pdfItems($pdf, $item, true, $tree, $user);
- break;
-
- case 'Group$3':
- self::pdfLdapForm($pdf, $item);
- break;
-
- case 'Group$4':
- self::pdfChildren($pdf, $item);
- break;
-
- case 'Group_User$1':
- PluginPdfGroup_User::pdfForGroup($pdf, $item, $tree);
- break;
-
- default:
- return false;
+ if ($item instanceof Group) {
+ switch ($tab) {
+ case 'Group$1':
+ self::pdfItems($pdf, $item, false, $tree, $user);
+ break;
+
+ case 'Group$2':
+ self::pdfItems($pdf, $item, true, $tree, $user);
+ break;
+
+ case 'Group$3':
+ self::pdfLdapForm($pdf, $item);
+ break;
+
+ case 'Group$4':
+ self::pdfChildren($pdf, $item);
+ break;
+
+ case 'Group_User$1':
+ PluginPdfGroup_User::pdfForGroup($pdf, $item, $tree);
+ break;
+
+ default:
+ return false;
+ }
}
return true;
diff --git a/inc/infocom.class.php b/inc/infocom.class.php
index b5c2337..0be5606 100644
--- a/inc/infocom.class.php
+++ b/inc/infocom.class.php
@@ -208,6 +208,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
);
$currency = PluginPdfConfig::getInstance();
+ $sym = '';
foreach ($PDF_DEVICES as $option => $value) {
if ($currency->fields['currency'] == $option) {
@@ -220,7 +221,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
__('TCO (value + tracking cost)') . '',
sprintf(
__('%1$s %2$s'),
- Toolbox::stripTags(Infocom::showTco(
+ Toolbox::stripTags((string) Infocom::showTco(
$item->getField('ticket_tco'),
$ic->fields['value'],
)),
@@ -232,7 +233,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
__('Monthly TCO') . '',
sprintf(
__('%1$s %2$s'),
- Toolbox::stripTags(Infocom::showTco(
+ Toolbox::stripTags((string) Infocom::showTco(
$item->getField('ticket_tco'),
$ic->fields['value'],
$ic->fields['buy_date'],
diff --git a/inc/item_device.class.php b/inc/item_device.class.php
index 2751651..0ab2568 100644
--- a/inc/item_device.class.php
+++ b/inc/item_device.class.php
@@ -99,7 +99,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, $item)
&& !empty($device->fields[$label['name']])) {
if (($label['type'] == 'dropdownValue')
&& ($device->fields[$label['name']] != 0)) {
- if (!isset($value) || empty($value)) {
+ if (empty($value)) {
$table = getTableNameForForeignKeyField($label['name']);
$value = Dropdown::getDropdownName(
$table,
@@ -112,7 +112,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, $item)
Toolbox::stripTags($value) . ' ',
);
} else {
- if (!isset($value) || empty($value)) {
+ if (empty($value)) {
$value = $device->fields[$label['name']];
}
if ($label['type'] == 'bool') {
diff --git a/inc/item_problem.class.php b/inc/item_problem.class.php
index dc97b9a..be76ac4 100644
--- a/inc/item_problem.class.php
+++ b/inc/item_problem.class.php
@@ -61,6 +61,7 @@ public static function pdfForProblem(PluginPdfSimplePDF $pdf, Problem $problem)
);
$number = count($result);
+ $totalnb = 0;
$pdf->setColumnsSize(100);
$title = '' . _n('Item', 'Items', 2) . '';
@@ -79,7 +80,6 @@ public static function pdfForProblem(PluginPdfSimplePDF $pdf, Problem $problem)
__('Inventory number') . '',
);
- $totalnb = 0;
foreach ($result as $row) {
$itemtype = $row['itemtype'];
if (!($item = $dbu->getItemForItemtype($itemtype))) {
@@ -192,6 +192,8 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item, $tr
break;
}
+ $SELECT = '';
+ $FROM = '';
if (count($_SESSION['glpiactiveentities']) > 1) {
$SELECT = ', `glpi_entities`.`completename` AS entityname,
`glpi_problems`.`entities_id` AS entityID ';
diff --git a/inc/item_softwarelicense.class.php b/inc/item_softwarelicense.class.php
index 14cd3e0..25f4fce 100644
--- a/inc/item_softwarelicense.class.php
+++ b/inc/item_softwarelicense.class.php
@@ -106,9 +106,8 @@ public static function pdfForLicenseByComputer(PluginPdfSimplePDF $pdf, Software
+ $dbu->getEntitiesRestrictCriteria('glpi_computers')];
$number = 0;
- if ($result = $DB->request($query)) {
- $number = count($result);
- }
+ $result = $DB->request($query);
+ $number = count($result);
$pdf->setColumnsSize(100);
$pdf->setColumnsAlign('center');
@@ -187,7 +186,7 @@ public static function pdfForLicenseByComputer(PluginPdfSimplePDF $pdf, Software
}
foreach ($result as $data) {
$compname = $data['compname'];
- if (empty($compname) || $_SESSION['glpiis_ids_visible']) {
+ if (empty($compname)) {
$compname = sprintf(__('%1$s (%2$s)'), $compname, $data['cID']);
}
$entname = (empty($data['entity']) ? __('Root entity') : $data['entity']);
diff --git a/inc/item_softwareversion.class.php b/inc/item_softwareversion.class.php
index 3145e27..5ea5197 100644
--- a/inc/item_softwareversion.class.php
+++ b/inc/item_softwareversion.class.php
@@ -60,6 +60,7 @@ public static function pdfForSoftware(PluginPdfSimplePDF $pdf, CommonDBTM $item)
}
$item_version_table = 'glpi_items_softwareversions';
+ $queries = [];
foreach ($CFG_GLPI['software_types'] as $itemtype) {
$canshowitems[$itemtype] = $itemtype::canView();
$itemtable = $itemtype::getTable();
@@ -285,7 +286,7 @@ public static function pdfForVersionByEntity(PluginPdfSimplePDF $pdf, SoftwareVe
$lig = $tot = 0;
if (in_array(0, $_SESSION['glpiactiveentities'])) {
- $nb = Item_SoftwareVersion::countForVersion($softwareversions_id, 0);
+ $nb = Item_SoftwareVersion::countForVersion($softwareversions_id, '0');
if ($nb > 0) {
$pdf->displayLine(__('Root entity'), $nb);
$tot += $nb;
diff --git a/inc/item_ticket.class.php b/inc/item_ticket.class.php
index 7d62437..f259b3b 100644
--- a/inc/item_ticket.class.php
+++ b/inc/item_ticket.class.php
@@ -216,6 +216,8 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item, $tr
$order = '`glpi_tickets`.`date_mod` DESC';
}
+ $SELECT = '';
+ $FROM = '';
if (count($_SESSION['glpiactiveentities']) > 1) {
$SELECT = ', `glpi_entities`.`completename` AS entityname,
`glpi_tickets`.`entities_id` AS entityID ';
diff --git a/inc/itilfollowup.class.php b/inc/itilfollowup.class.php
index e018bb6..4ce0ee3 100644
--- a/inc/itilfollowup.class.php
+++ b/inc/itilfollowup.class.php
@@ -110,7 +110,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item, $pr
foreach ($res as $img) {
$docimg = new Document();
- $docimg->getFromDB($img[2]);
+ $docimg->getFromDB((int) $img[2]);
$path = '
';
$content = str_replace($img[0], $path, $content);
diff --git a/inc/itilsolution.class.php b/inc/itilsolution.class.php
index ec0f6ff..6d829c6 100644
--- a/inc/itilsolution.class.php
+++ b/inc/itilsolution.class.php
@@ -78,18 +78,17 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
foreach ($res as $img) {
$docimg = new Document();
- $docimg->getFromDB($img[2]);
+ $docimg->getFromDB((int) $img[2]);
$path = '
';
$sol = str_replace($img[0], $path, $sol);
}
+ $text = $textapprove = '';
if ($row['status'] == 3) {
$text = __('Soluce approved on ', 'pdf');
} elseif ($row['status'] == 4) {
$text = __('Soluce refused on ', 'pdf');
- } else {
- $text = $textapprove = '';
}
if (isset($row['date_approval']) || !empty($row['users_id_approval'])) {
$textapprove = '
' .
diff --git a/inc/knowbaseitem.class.php b/inc/knowbaseitem.class.php
index dbe1e03..5447797 100644
--- a/inc/knowbaseitem.class.php
+++ b/inc/knowbaseitem.class.php
@@ -126,17 +126,19 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, KnowbaseItem $item)
public static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGLPI $item, $tab)
{
- switch ($tab) {
- case 'KnowbaseItem$1':
- self::pdfMain($pdf, $item);
- break;
+ if ($item instanceof KnowbaseItem) {
+ switch ($tab) {
+ case 'KnowbaseItem$1':
+ self::pdfMain($pdf, $item);
+ break;
- case 'KnowbaseItem$2':
- self::pdfCible($pdf, $item);
- break;
+ case 'KnowbaseItem$2':
+ self::pdfCible($pdf, $item);
+ break;
- default:
- return false;
+ default:
+ return false;
+ }
}
return true;
@@ -200,6 +202,7 @@ public static function pdfCible(PluginPdfSimplePDF $pdf, KnowbaseItem $item)
$recursive = '(' . __('R') . ')';
}
$names = Dropdown::getDropdownName('glpi_profiles', $data['profiles_id']);
+ $profilename = '';
if ($data['entities_id'] >= 0) {
$profilename = sprintf(
__('%1$s / %2$s'),
@@ -225,6 +228,7 @@ public static function pdfCible(PluginPdfSimplePDF $pdf, KnowbaseItem $item)
$recursive = '(' . __('R') . ')';
}
$names = Dropdown::getDropdownName('glpi_groups', $data['groups_id']);
+ $groupname = '';
if ($data['entities_id'] >= 0) {
$groupname = sprintf(
__('%1$s / %2$s'),
diff --git a/inc/monitor.class.php b/inc/monitor.class.php
index d195519..68f75c8 100644
--- a/inc/monitor.class.php
+++ b/inc/monitor.class.php
@@ -106,7 +106,5 @@ public static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGL
default:
return false;
}
-
- return true;
}
}
diff --git a/inc/networkequipment.class.php b/inc/networkequipment.class.php
index c22804c..8048631 100644
--- a/inc/networkequipment.class.php
+++ b/inc/networkequipment.class.php
@@ -108,7 +108,5 @@ public static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGL
default:
return false;
}
-
- return true;
}
}
diff --git a/inc/networkport.class.php b/inc/networkport.class.php
index fb80fbd..d95825d 100644
--- a/inc/networkport.class.php
+++ b/inc/networkport.class.php
@@ -51,136 +51,135 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$type = get_class($item);
$pdf->setColumnsSize(100);
- if ($result = $DB->request(
+ $result = $DB->request(
'glpi_networkports',
['SELECT' => ['id', 'name', 'logical_number'],
'WHERE' => ['items_id' => $ID,
'itemtype' => $type],
'ORDER' => ['name', 'logical_number']],
- )) {
- $nb_connect = count($result);
-
- $title = '' . _n('Network port', 'Network ports', $nb_connect) . '';
- if (!$nb_connect) {
- $pdf->displayTitle('' . __('No network port found') . '');
+ );
+ $nb_connect = count($result);
+
+ $title = '' . _n('Network port', 'Network ports', $nb_connect) . '';
+ if (!$nb_connect) {
+ $pdf->displayTitle('' . __('No network port found') . '');
+ } else {
+ if ($nb_connect > $_SESSION['glpilist_limit']) {
+ $title = sprintf(__('%1$s: %2$s'), $title, $_SESSION['glpilist_limit'] . ' / ' . $nb_connect);
} else {
- if ($nb_connect > $_SESSION['glpilist_limit']) {
- $title = sprintf(__('%1$s: %2$s'), $title, $_SESSION['glpilist_limit'] . ' / ' . $nb_connect);
- } else {
- $title = sprintf(__('%1$s: %2$d'), $title, $nb_connect);
+ $title = sprintf(__('%1$s: %2$d'), $title, $nb_connect);
+ }
+ $pdf->displayTitle($title);
+
+ foreach ($result as $devid) {
+ $netport = new NetworkPort();
+ $netport->getfromDB(current($devid));
+ $instantiation_type = $netport->fields['instantiation_type'];
+ $instname = call_user_func([$instantiation_type, 'getTypeName']);
+ $pdf->displayTitle('' . $instname . '');
+
+ $pdf->displayLine('' . sprintf(
+ __('%1$s: %2$s'),
+ '#',
+ $netport->fields['logical_number'],
+ ));
+
+ $pdf->displayLine('' . sprintf(
+ __('%1$s: %2$s'),
+ __('Name') . '',
+ $netport->fields['name'],
+ ));
+
+ $contact = new NetworkPort();
+ $netport2 = new NetworkPort();
+
+ $add = __('Not connected.');
+ if ($cid = $contact->getContact($netport->fields['id'])) {
+ if ($netport2->getFromDB($cid)
+ && ($device2 = $dbu->getItemForItemtype($netport2->fields['itemtype']))) {
+ if ($device2->getFromDB($netport2->fields['items_id'])) {
+ $add = $netport2->getName() . ' ' . __('on') . ' ' .
+ $device2->getName() . ' (' . $device2->getTypeName() . ')';
+ }
+ }
}
- $pdf->displayTitle($title);
-
- foreach ($result as $devid) {
- $netport = new NetworkPort();
- $netport->getfromDB(current($devid));
- $instantiation_type = $netport->fields['instantiation_type'];
- $instname = call_user_func([$instantiation_type, 'getTypeName']);
- $pdf->displayTitle('' . $instname . '');
-
- $pdf->displayLine('' . sprintf(
- __('%1$s: %2$s'),
- '#',
- $netport->fields['logical_number'],
- ));
+ if ($instantiation_type == 'NetworkPortEthernet') {
$pdf->displayLine('' . sprintf(
__('%1$s: %2$s'),
- __('Name') . '',
- $netport->fields['name'],
+ __('Connected to') . '',
+ $add,
));
+ $netportethernet = new NetworkPortEthernet();
+ $speed = $type = '';
- $contact = new NetworkPort();
- $netport2 = new NetworkPort();
-
- $add = __('Not connected.');
- if ($cid = $contact->getContact($netport->fields['id'])) {
- if ($netport2->getFromDB($cid)
- && ($device2 = $dbu->getItemForItemtype($netport2->fields['itemtype']))) {
- if ($device2->getFromDB($netport2->fields['items_id'])) {
- $add = $netport2->getName() . ' ' . __('on') . ' ' .
- $device2->getName() . ' (' . $device2->getTypeName() . ')';
- }
- }
+ if ($netportethernet->getFromDBByCrit(['networkports_id' => $netport->fields['id']])) {
+ $speed = NetworkPortEthernet::getPortSpeed($netportethernet->fields['speed']);
+ $type = NetworkPortEthernet::getPortTypeName($netportethernet->fields['type']);
}
-
- if ($instantiation_type == 'NetworkPortEthernet') {
- $pdf->displayLine('' . sprintf(
+ $pdf->displayLine(
+ '' . sprintf(__('%1$s: %2$s'), __('Ethernet port speed') . '', $speed),
+ );
+ $pdf->displayLine(
+ '' . sprintf(__('%1$s: %2$s'), __('Ethernet port type') . '', $type),
+ );
+
+ $netpoint = new Socket();
+ $outlet = '';
+ if (isset($netportethernet->fields['networkports_id'])
+ && $netpoint->getFromDBByCrit(['networkports_id' => $netportethernet->fields['networkports_id']])) {
+ $outlet = $netpoint->fields['name'];
+ }
+ $pdf->displayLine(
+ '' . sprintf(
__('%1$s: %2$s'),
- __('Connected to') . '',
- $add,
- ));
- $netportethernet = new NetworkPortEthernet();
- $speed = $type = '';
-
- if ($netportethernet->getFromDBByCrit(['networkports_id' => $netport->fields['id']])) {
- $speed = NetworkPortEthernet::getPortSpeed($netportethernet->fields['speed']);
- $type = NetworkPortEthernet::getPortTypeName($netportethernet->fields['type']);
- }
- $pdf->displayLine(
- '' . sprintf(__('%1$s: %2$s'), __('Ethernet port speed') . '', $speed),
- );
- $pdf->displayLine(
- '' . sprintf(__('%1$s: %2$s'), __('Ethernet port type') . '', $type),
- );
-
- $netpoint = new Socket();
- $outlet = '';
- if (isset($netportethernet->fields['networkports_id'])
- && $netpoint->getFromDBByCrit(['networkports_id' => $netportethernet->fields['networkports_id']])) {
- $outlet = $netpoint->fields['name'];
- }
- $pdf->displayLine(
- '' . sprintf(
+ __('Network outlet') . '',
+ $outlet,
+ ),
+ );
+ }
+ $pdf->displayLine('' . sprintf(
+ __('%1$s: %2$s'),
+ __('MAC') . '',
+ $netport->fields['mac'],
+ ));
+
+ $sqlip = ['LEFT JOIN' => ['glpi_networknames'
+ => ['FKEY' => ['glpi_ipaddresses' => 'items_id',
+ 'glpi_networknames' => 'id'],
+ ['glpi_ipaddresses.entities_id'
+ => $_SESSION['glpiactive_entity']]]],
+ 'WHERE' => ['glpi_networknames.items_id' => $netport->fields['id']]];
+
+ $ipname = '';
+ $ip = new IPAddress();
+ if ($ip->getFromDBByRequest($sqlip)) {
+ $ipname = $ip->fields['name'];
+
+ $pdf->displayLine('' . sprintf(__('%1$s: %2$s'), __('ip') . '', $ipname));
+
+ $sql = ['SELECT' => 'glpi_ipaddresses_ipnetworks.ipnetworks_id',
+ 'FROM' => 'glpi_ipaddresses_ipnetworks',
+ 'LEFT JOIN' => ['glpi_ipnetworks'
+ => ['FKEY' => ['glpi_ipaddresses_ipnetworks' => 'ipnetworks_id',
+ 'glpi_ipnetworks' => 'id']]],
+ 'WHERE' => ['glpi_ipaddresses_ipnetworks.ipaddresses_id' => $ip->getID()]
+ + $dbu->getEntitiesRestrictCriteria('glpi_ipnetworks')];
+
+ $res = $DB->request($sql);
+ foreach ($res as $row) {
+ $ipnetwork = new IPNetwork();
+ if ($ipnetwork->getFromDB($row['ipnetworks_id'])) {
+ $pdf->displayLine('' . sprintf(
__('%1$s: %2$s'),
- __('Network outlet') . '',
- $outlet,
- ),
- );
- }
- $pdf->displayLine('' . sprintf(
- __('%1$s: %2$s'),
- __('MAC') . '',
- $netport->fields['mac'],
- ));
-
- $sqlip = ['LEFT JOIN' => ['glpi_networknames'
- => ['FKEY' => ['glpi_ipaddresses' => 'items_id',
- 'glpi_networknames' => 'id'],
- ['glpi_ipaddresses.entities_id'
- => $_SESSION['glpiactive_entity']]]],
- 'WHERE' => ['glpi_networknames.items_id' => $netport->fields['id']]];
-
- $ipname = '';
- $ip = new IPAddress();
- if ($ip->getFromDBByRequest($sqlip)) {
- $ipname = $ip->fields['name'];
-
- $pdf->displayLine('' . sprintf(__('%1$s: %2$s'), __('ip') . '', $ipname));
-
- $sql = ['SELECT' => 'glpi_ipaddresses_ipnetworks.ipnetworks_id',
- 'FROM' => 'glpi_ipaddresses_ipnetworks',
- 'LEFT JOIN' => ['glpi_ipnetworks'
- => ['FKEY' => ['glpi_ipaddresses_ipnetworks' => 'ipnetworks_id',
- 'glpi_ipnetworks' => 'id']]],
- 'WHERE' => ['glpi_ipaddresses_ipnetworks.ipaddresses_id' => $ip->getID()]
- + $dbu->getEntitiesRestrictCriteria('glpi_ipnetworks')];
-
- $res = $DB->request($sql);
- foreach ($res as $row) {
- $ipnetwork = new IPNetwork();
- if ($ipnetwork->getFromDB($row['ipnetworks_id'])) {
- $pdf->displayLine('' . sprintf(
- __('%1$s: %2$s'),
- __('IP network') . '',
- $ipnetwork->fields['completename'],
- ));
- }
+ __('IP network') . '',
+ $ipnetwork->fields['completename'],
+ ));
}
}
- } // each port
- } // Found
- } // Query
+ }
+ } // each port
+ } // Found
$pdf->displaySpace();
}
}
diff --git a/inc/peripheral.class.php b/inc/peripheral.class.php
index 6b1483f..b8d5e6a 100644
--- a/inc/peripheral.class.php
+++ b/inc/peripheral.class.php
@@ -83,7 +83,5 @@ public static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGL
default:
return false;
}
-
- return true;
}
}
diff --git a/inc/phone.class.php b/inc/phone.class.php
index 66878da..e524e0d 100644
--- a/inc/phone.class.php
+++ b/inc/phone.class.php
@@ -117,7 +117,5 @@ public static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGL
default:
return false;
}
-
- return true;
}
}
diff --git a/inc/printer.class.php b/inc/printer.class.php
index 6d0b1e2..7e52e1a 100644
--- a/inc/printer.class.php
+++ b/inc/printer.class.php
@@ -156,14 +156,16 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Printer $printer)
public static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGLPI $item, $tab)
{
- switch ($tab) {
- case 'Cartridge$1':
- PluginPdfCartridge::pdfForPrinter($pdf, $item, false);
- PluginPdfCartridge::pdfForPrinter($pdf, $item, true);
- break;
-
- default:
- return false;
+ if ($item instanceof Printer) {
+ switch ($tab) {
+ case 'Cartridge$1':
+ PluginPdfCartridge::pdfForPrinter($pdf, $item, false);
+ PluginPdfCartridge::pdfForPrinter($pdf, $item, true);
+ break;
+
+ default:
+ return false;
+ }
}
return true;
diff --git a/inc/problem.class.php b/inc/problem.class.php
index 331dba8..0aa6b86 100644
--- a/inc/problem.class.php
+++ b/inc/problem.class.php
@@ -189,6 +189,7 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Problem $job)
$groups[] = Dropdown::getDropdownName('glpi_groups', $d['groups_id']);
}
if (count($groups)) {
+ $groups = array_filter($groups, 'is_string');
$listgroups = implode(', ', $groups);
}
$pdf->displayText($requestergroup, $listgroups, 1);
@@ -224,6 +225,7 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Problem $job)
$groups[] = Dropdown::getDropdownName('glpi_groups', $d['groups_id']);
}
if (count($groups)) {
+ $groups = array_filter($groups, 'is_string');
$listgroups = implode(', ', $groups);
}
$pdf->displayText($watchergroup, $listgroups, 1);
@@ -392,7 +394,7 @@ public static function pdfStat(PluginPdfSimplePDF $pdf, Problem $job)
$pdf->displayLine(sprintf(
__('%1$s: %2$s'),
__('Solution'),
- Toolbox::stripTags(Html::timestampToString($job->fields['solve_delay_stat'], 0)),
+ Toolbox::stripTags(Html::timestampToString($job->fields['solve_delay_stat'], false)),
));
}
}
@@ -401,7 +403,7 @@ public static function pdfStat(PluginPdfSimplePDF $pdf, Problem $job)
$pdf->displayLine(sprintf(
__('%1$s: %2$s'),
__('Closing'),
- Toolbox::stripTags(Html::timestampToString($job->fields['close_delay_stat'], 0)),
+ Toolbox::stripTags(Html::timestampToString($job->fields['close_delay_stat'], false)),
));
}
}
@@ -409,7 +411,7 @@ public static function pdfStat(PluginPdfSimplePDF $pdf, Problem $job)
$pdf->displayLine(sprintf(
__('%1$s: %2$s'),
__('Pending'),
- Toolbox::stripTags(Html::timestampToString($job->fields['waiting_duration'], 0)),
+ Toolbox::stripTags(Html::timestampToString($job->fields['waiting_duration'], false)),
));
}
@@ -434,56 +436,58 @@ public static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGL
{
$private = isset($_REQUEST['item']['_private_']);
- switch ($tab) {
- case '_private_':
- // nothing to export, just a flag
- break;
-
- case 'Problem$main':
- self::pdfMain($pdf, $item);
- PluginPdfItilFollowup::pdfForItem($pdf, $item, $private);
- PluginPdfProblemTask::pdfForProblem($pdf, $item, $private);
- if (Session::haveRight('document', READ)) {
- PluginPdfDocument::pdfForItem($pdf, $item);
- }
- PluginPdfITILSolution::pdfForItem($pdf, $item);
- break;
-
- case 'Problem$1':
- self::pdfAnalysis($pdf, $item);
- break;
-
- case 'Change_Problem$1':
- PluginPdfChange_Problem::pdfForProblem($pdf, $item);
- break;
-
- case 'Problem_Ticket$1':
- PluginPdfProblem_Ticket::pdfForProblem($pdf, $item);
- break;
-
- case 'Problem$5':
- PluginPdfItilFollowup::pdfForItem($pdf, $item, $private);
- PluginPdfProblemTask::pdfForProblem($pdf, $item);
- if (Session::haveRight('document', READ)) {
- PluginPdfDocument::pdfForItem($pdf, $item);
- }
- PluginPdfITILSolution::pdfForItem($pdf, $item);
- break;
-
- case 'Item_Problem$1':
- PluginPdfItem_Problem::pdfForProblem($pdf, $item);
- break;
-
- case 'Problem$4':
- self::pdfStat($pdf, $item);
- break;
-
- case 'ProblemCost$1':
- PluginPdfCommonItilCost::pdfForItem($pdf, $item);
- break;
-
- default:
- return false;
+ if ($item instanceof Problem) {
+ switch ($tab) {
+ case '_private_':
+ // nothing to export, just a flag
+ break;
+
+ case 'Problem$main':
+ self::pdfMain($pdf, $item);
+ PluginPdfItilFollowup::pdfForItem($pdf, $item, $private);
+ PluginPdfProblemTask::pdfForProblem($pdf, $item);
+ if (Session::haveRight('document', READ)) {
+ PluginPdfDocument::pdfForItem($pdf, $item);
+ }
+ PluginPdfITILSolution::pdfForItem($pdf, $item);
+ break;
+
+ case 'Problem$1':
+ self::pdfAnalysis($pdf, $item);
+ break;
+
+ case 'Change_Problem$1':
+ PluginPdfChange_Problem::pdfForProblem($pdf, $item);
+ break;
+
+ case 'Problem_Ticket$1':
+ PluginPdfProblem_Ticket::pdfForProblem($pdf, $item);
+ break;
+
+ case 'Problem$5':
+ PluginPdfItilFollowup::pdfForItem($pdf, $item, $private);
+ PluginPdfProblemTask::pdfForProblem($pdf, $item);
+ if (Session::haveRight('document', READ)) {
+ PluginPdfDocument::pdfForItem($pdf, $item);
+ }
+ PluginPdfITILSolution::pdfForItem($pdf, $item);
+ break;
+
+ case 'Item_Problem$1':
+ PluginPdfItem_Problem::pdfForProblem($pdf, $item);
+ break;
+
+ case 'Problem$4':
+ self::pdfStat($pdf, $item);
+ break;
+
+ case 'ProblemCost$1':
+ PluginPdfCommonItilCost::pdfForItem($pdf, $item);
+ break;
+
+ default:
+ return false;
+ }
}
return true;
diff --git a/inc/problem_ticket.class.php b/inc/problem_ticket.class.php
index 93faf1f..1ede75e 100644
--- a/inc/problem_ticket.class.php
+++ b/inc/problem_ticket.class.php
@@ -68,7 +68,7 @@ public static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $ticket)
$used = [];
$pdf->setColumnsSize(100);
- $title = '' . __('Problem', 'Problems', $number) . '';
+ $title = '' . _n('Problem', 'Problems', $number) . '';
if (!$number) {
$pdf->displayTitle(sprintf(__('%1$s: %2$s'), $title, __('No item to display')));
} else {
@@ -307,7 +307,7 @@ public static function pdfForProblem(PluginPdfSimplePDF $pdf, Problem $problem)
$used = [];
$pdf->setColumnsSize(100);
- $title = '' . __('Ticket', 'Tickets', 2) . '';
+ $title = '' . _n('Ticket', 'Tickets', 2) . '';
if (!$number) {
$pdf->displayTitle(sprintf(__('%1$s: %2$s'), $title, __('No item to display')));
} else {
diff --git a/inc/problemtask.class.php b/inc/problemtask.class.php
index 1c3cae5..5628cf4 100755
--- a/inc/problemtask.class.php
+++ b/inc/problemtask.class.php
@@ -121,7 +121,7 @@ public static function pdfForProblem(PluginPdfSimplePDF $pdf, Problem $job)
$pdf->displayLine(
'' . Toolbox::stripTags($lib),
Html::convDateTime($data['date']),
- Html::timestampToString($data['actiontime'], 0),
+ Html::timestampToString($data['actiontime'], false),
Toolbox::stripTags($dbu->getUserName($data['users_id'])),
Toolbox::stripTags($planification),
1,
diff --git a/inc/profile.class.php b/inc/profile.class.php
index e5c6124..8f40a86 100644
--- a/inc/profile.class.php
+++ b/inc/profile.class.php
@@ -99,7 +99,7 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0)
{
- if ($item->getType() == 'Profile') {
+ if ($item instanceof \Profile) {
$prof = new self();
$ID = $item->getField('id');
$prof->showForm($ID);
diff --git a/inc/reservation.class.php b/inc/reservation.class.php
index b601a3f..ddbbf7d 100644
--- a/inc/reservation.class.php
+++ b/inc/reservation.class.php
@@ -156,6 +156,7 @@ public static function pdfForUser(PluginPdfSimplePDF $pdf, User $user)
$pdf->setColumnsSize(100);
$now = $_SESSION['glpi_currenttime'];
+ $name = '';
// Print reservation in progress
$query = ['SELECT' => ['begin', 'end', 'items_id', 'glpi_reservationitems.entities_id',
diff --git a/inc/simplepdf.class.php b/inc/simplepdf.class.php
index f3387bf..175f25d 100644
--- a/inc/simplepdf.class.php
+++ b/inc/simplepdf.class.php
@@ -49,8 +49,7 @@ class PluginPdfSimplePDF
// Page management
private $width;
private $height;
- private $start_tab;
- private $header = '';
+ private $header = ''; // @phpstan-ignore-line - $header is never read, only written.
// Columns management
private $cols = [];
@@ -169,7 +168,7 @@ public function newPage()
/**
* Configure the width and number of colums
*
- * @param list of size in % of the page width
+ * param list of size in % of the page width
**/
public function setColumnsSize()
{
@@ -192,7 +191,7 @@ public function setColumnsSize()
/**
* Configure the width and number of colums
*
- * @param list of alignment
+ * param list of alignment
**/
public function setColumnsAlign()
{
@@ -301,7 +300,7 @@ private function displayInternal($gray, $padd, $defalign, $miny, $msgs)
/**
* display a Title row, centered with dark background
*
- * @param list of strings, one string per column
+ * param list of strings, one string per column
**/
public function displayTitle()
{
@@ -311,7 +310,7 @@ public function displayTitle()
/**
* display a nomal row, default to left, with light background
*
- * @param list of strings, one string per column
+ * param list of strings, one string per column
**/
public function displayLine()
{
diff --git a/inc/software.class.php b/inc/software.class.php
index f565388..0aed64e 100644
--- a/inc/software.class.php
+++ b/inc/software.class.php
@@ -158,26 +158,28 @@ public function defineAllTabsPDF($options = [])
public static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGLPI $item, $tab)
{
- switch ($tab) {
- case 'SoftwareVersion$1':
- PluginPdfSoftwareVersion::pdfForSoftware($pdf, $item);
- break;
-
- case 'SoftwareLicense$1':
- $infocom = isset($_REQUEST['item']['Infocom$1']);
- PluginPdfSoftwareLicense::pdfForSoftware($pdf, $item, $infocom);
- break;
-
- case 'Item_SoftwareVersion$1':
- PluginPdfItem_SoftwareVersion::pdfForSoftware($pdf, $item);
- break;
-
- case 'Domain_Item$1':
- PluginPdfDomain_Item::pdfForItem($pdf, $item);
- break;
-
- default:
- return false;
+ if ($item instanceof Software) {
+ switch ($tab) {
+ case 'SoftwareVersion$1':
+ PluginPdfSoftwareVersion::pdfForSoftware($pdf, $item);
+ break;
+
+ case 'SoftwareLicense$1':
+ $infocom = isset($_REQUEST['item']['Infocom$1']);
+ PluginPdfSoftwareLicense::pdfForSoftware($pdf, $item, $infocom);
+ break;
+
+ case 'Item_SoftwareVersion$1':
+ PluginPdfItem_SoftwareVersion::pdfForSoftware($pdf, $item);
+ break;
+
+ case 'Domain_Item$1':
+ PluginPdfDomain_Item::pdfForItem($pdf, $item);
+ break;
+
+ default:
+ return false;
+ }
}
return true;
diff --git a/inc/softwarelicense.class.php b/inc/softwarelicense.class.php
index 1855f60..e1d5337 100644
--- a/inc/softwarelicense.class.php
+++ b/inc/softwarelicense.class.php
@@ -233,23 +233,25 @@ public static function pdfForSoftware(PluginPdfSimplePDF $pdf, Software $softwar
public static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGLPI $item, $tab)
{
- switch ($tab) {
- case '_main_':
- $cpt = !(isset($_REQUEST['item']['Item_SoftwareLicense$1'])
- || isset($_REQUEST['item']['Item_SoftwareLicense$2']));
- self::pdfMain($pdf, $item, true, $cpt);
- break;
+ if ($item instanceof SoftwareLicense) {
+ switch ($tab) {
+ case '_main_':
+ $cpt = !(isset($_REQUEST['item']['Item_SoftwareLicense$1'])
+ || isset($_REQUEST['item']['Item_SoftwareLicense$2']));
+ self::pdfMain($pdf, $item, true, $cpt);
+ break;
- case 'Item_SoftwareLicense$1':
- PluginPdfItem_SoftwareLicense::pdfForLicenseByEntity($pdf, $item);
- break;
+ case 'Item_SoftwareLicense$1':
+ PluginPdfItem_SoftwareLicense::pdfForLicenseByEntity($pdf, $item);
+ break;
- case 'Item_SoftwareLicense$2':
- PluginPdfItem_SoftwareLicense::pdfForLicenseByComputer($pdf, $item);
- break;
+ case 'Item_SoftwareLicense$2':
+ PluginPdfItem_SoftwareLicense::pdfForLicenseByComputer($pdf, $item);
+ break;
- default:
- return false;
+ default:
+ return false;
+ }
}
return true;
diff --git a/inc/softwareversion.class.php b/inc/softwareversion.class.php
index ffdf290..69cf2c0 100644
--- a/inc/softwareversion.class.php
+++ b/inc/softwareversion.class.php
@@ -150,17 +150,19 @@ public static function pdfForSoftware(PluginPdfSimplePDF $pdf, Software $item)
public static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGLPI $item, $tab)
{
- switch ($tab) {
- case 'Item_SoftwareVersion$1':
- PluginPdfItem_SoftwareVersion::pdfForVersionByEntity($pdf, $item);
- break;
-
- case 'Item_SoftwareVersion$2':
- PluginPdfItem_SoftwareVersion::pdfForSoftware($pdf, $item);
- break;
-
- default:
- return false;
+ if ($item instanceof SoftwareVersion) {
+ switch ($tab) {
+ case 'Item_SoftwareVersion$1':
+ PluginPdfItem_SoftwareVersion::pdfForVersionByEntity($pdf, $item);
+ break;
+
+ case 'Item_SoftwareVersion$2':
+ PluginPdfItem_SoftwareVersion::pdfForSoftware($pdf, $item);
+ break;
+
+ default:
+ return false;
+ }
}
return true;
diff --git a/inc/ticket.class.php b/inc/ticket.class.php
index 2623792..ff97a91 100644
--- a/inc/ticket.class.php
+++ b/inc/ticket.class.php
@@ -294,9 +294,6 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Ticket $job)
$tmp .= ' (';
$first = true;
if ($user->fields['phone']) {
- if (!$first) {
- $tmp .= ' - ';
- }
$tmp .= sprintf(__('%1$s: %2$s'), __('Phone'), $user->fields['phone']);
$first = false;
}
@@ -355,6 +352,7 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Ticket $job)
$groups[] = Dropdown::getDropdownName('glpi_groups', $d['groups_id']);
}
if (count($groups)) {
+ $groups = array_filter($groups, 'is_string');
$listgroups = implode(', ', $groups);
}
$pdf->displayText($requestergroup, $listgroups, 1);
@@ -390,6 +388,7 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Ticket $job)
$groups[] = Dropdown::getDropdownName('glpi_groups', $d['groups_id']);
}
if (count($groups)) {
+ $groups = array_filter($groups, 'is_string');
$listgroups = implode(', ', $groups);
}
$pdf->displayText($watchergroup, $listgroups, 1);
@@ -429,6 +428,7 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Ticket $job)
$groups[] = Dropdown::getDropdownName('glpi_groups', $d['groups_id']);
}
if (count($groups)) {
+ $groups = array_filter($groups, 'is_string');
$listgroups = implode(', ', $groups);
}
$pdf->displayText($assigngroup, $listgroups, 1);
@@ -465,7 +465,7 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Ticket $job)
foreach ($res as $img) {
$docimg = new Document();
- $docimg->getFromDB($img[2]);
+ $docimg->getFromDB((int) $img[2]);
$path = '
';
$content = str_replace($img[0], $path, $content);
@@ -479,7 +479,7 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Ticket $job)
// Linked tickets
$tickets = Ticket_Ticket::getLinkedTicketsTo($ID);
- if (is_array($tickets) && count($tickets)) {
+ if (count($tickets)) {
$ticket = new Ticket();
$pdf->displayLine('' . sprintf(
__('%1$s: %2$s') . '',
@@ -561,7 +561,7 @@ public static function pdfStat(PluginPdfSimplePDF $pdf, Ticket $job)
if ($job->fields['takeintoaccount_delay_stat'] > 0) {
$pdf->displayLine(
__('Take into account'),
- Toolbox::stripTags(Html::timestampToString($job->fields['takeintoaccount_delay_stat'], 0)),
+ Toolbox::stripTags(Html::timestampToString($job->fields['takeintoaccount_delay_stat'], false)),
);
}
@@ -570,7 +570,7 @@ public static function pdfStat(PluginPdfSimplePDF $pdf, Ticket $job)
if ($job->fields['solve_delay_stat'] > 0) {
$pdf->displayLine(
__('Solution'),
- Toolbox::stripTags(Html::timestampToString($job->fields['solve_delay_stat'], 0)),
+ Toolbox::stripTags(Html::timestampToString($job->fields['solve_delay_stat'], false)),
);
}
}
@@ -578,14 +578,14 @@ public static function pdfStat(PluginPdfSimplePDF $pdf, Ticket $job)
if ($job->fields['close_delay_stat'] > 0) {
$pdf->displayLine(
__('Closing'),
- Toolbox::stripTags(Html::timestampToString($job->fields['close_delay_stat'], 1)),
+ Toolbox::stripTags(Html::timestampToString($job->fields['close_delay_stat'], true)),
);
}
}
if ($job->fields['waiting_duration'] > 0) {
$pdf->displayLine(
__('Pending'),
- Toolbox::stripTags(Html::timestampToString($job->fields['waiting_duration'], 0)),
+ Toolbox::stripTags(Html::timestampToString($job->fields['waiting_duration'], false)),
);
}
@@ -615,60 +615,62 @@ public static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGL
{
$private = isset($_REQUEST['item']['_private_']);
- switch ($tab) {
- case '_private_':
- // nothing to export, just a flag
- break;
-
- case '_inforequester_':
- break;
-
- case 'Ticket$main': // 0.90+
- self::pdfMain($pdf, $item);
- PluginPdfItilFollowup::pdfForItem($pdf, $item, $private);
- PluginPdfTicketTask::pdfForTicket($pdf, $item, $private);
- if (Session::haveRight('document', READ)) {
- PluginPdfDocument::pdfForItem($pdf, $item);
- }
- PluginPdfITILSolution::pdfForItem($pdf, $item);
- break;
+ if ($item instanceof Ticket) {
+ switch ($tab) {
+ case '_private_':
+ // nothing to export, just a flag
+ break;
+
+ case '_inforequester_':
+ break;
+
+ case 'Ticket$main': // 0.90+
+ self::pdfMain($pdf, $item);
+ PluginPdfItilFollowup::pdfForItem($pdf, $item, $private);
+ PluginPdfTicketTask::pdfForTicket($pdf, $item, $private);
+ if (Session::haveRight('document', READ)) {
+ PluginPdfDocument::pdfForItem($pdf, $item);
+ }
+ PluginPdfITILSolution::pdfForItem($pdf, $item);
+ break;
- case 'TicketValidation$1': // 0.85
- PluginPdfTicketValidation::pdfForTicket($pdf, $item);
- break;
+ case 'TicketValidation$1': // 0.85
+ PluginPdfTicketValidation::pdfForTicket($pdf, $item);
+ break;
- case 'TicketCost$1':
- PluginPdfCommonItilCost::pdfForItem($pdf, $item);
- break;
+ case 'TicketCost$1':
+ PluginPdfCommonItilCost::pdfForItem($pdf, $item);
+ break;
- case 'Ticket$3':
- PluginPdfTicketSatisfaction::pdfForTicket($pdf, $item);
- break;
+ case 'Ticket$3':
+ PluginPdfTicketSatisfaction::pdfForTicket($pdf, $item);
+ break;
- case 'Problem_Ticket$1':
- PluginPdfProblem_Ticket::pdfForTicket($pdf, $item);
- break;
+ case 'Problem_Ticket$1':
+ PluginPdfProblem_Ticket::pdfForTicket($pdf, $item);
+ break;
- case 'Ticket$4':
- self::pdfStat($pdf, $item);
- break;
+ case 'Ticket$4':
+ self::pdfStat($pdf, $item);
+ break;
- case 'Item_Ticket$1':
- PluginPdfItem_Ticket::pdfForTicket($pdf, $item);
- break;
+ case 'Item_Ticket$1':
+ PluginPdfItem_Ticket::pdfForTicket($pdf, $item);
+ break;
- case 'Change_Ticket$1':
- if (Change::canView()) {
- PluginPdfChange_Ticket::pdfForTicket($pdf, $item);
- }
- break;
+ case 'Change_Ticket$1':
+ if (Change::canView()) {
+ PluginPdfChange_Ticket::pdfForTicket($pdf, $item);
+ }
+ break;
- case 'Ticket_Contract$1':
- PluginPdfTicket_Contract::pdfForTicket($pdf, $item);
- break;
+ case 'Ticket_Contract$1':
+ PluginPdfTicket_Contract::pdfForTicket($pdf, $item);
+ break;
- default:
- return false;
+ default:
+ return false;
+ }
}
return true;
diff --git a/inc/tickettask.class.php b/inc/tickettask.class.php
index 8b4b8d5..57ad8a4 100644
--- a/inc/tickettask.class.php
+++ b/inc/tickettask.class.php
@@ -142,7 +142,7 @@ public static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $job, $priva
$pdf->displayLine(
'' . Toolbox::stripTags($lib),
Html::convDateTime($data['date']),
- Html::timestampToString($data['actiontime'], 0),
+ Html::timestampToString($data['actiontime'], false),
Toolbox::stripTags($dbu->getUserName($data['users_id'])),
$planification,
);
@@ -153,7 +153,7 @@ public static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $job, $priva
foreach ($res as $img) {
$docimg = new Document();
- $docimg->getFromDB($img[2]);
+ $docimg->getFromDB((int) $img[2]);
$path = '
';
$content = str_replace($img[0], $path, $content);
diff --git a/inc/user.class.php b/inc/user.class.php
index fde5235..b8aa49e 100644
--- a/inc/user.class.php
+++ b/inc/user.class.php
@@ -330,7 +330,7 @@ public static function pdfItems(PluginPdfSimplePDF $pdf, User $user, $tech)
$query['WHERE']['is_deleted'] = 0;
}
- $result = $DB->request($query, true);
+ $result = $DB->request($query);
$type_name = $item->getTypeName();
@@ -408,21 +408,23 @@ public static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGL
$tree = isset($_REQUEST['item']['_tree']);
$user = isset($_REQUEST['item']['_user']);
- switch ($tab) {
- case 'User$1':
- self::pdfItems($pdf, $item, false);
- break;
+ if ($item instanceof User) {
+ switch ($tab) {
+ case 'User$1':
+ self::pdfItems($pdf, $item, false);
+ break;
- case 'User$2':
- self::pdfItems($pdf, $item, true);
- break;
+ case 'User$2':
+ self::pdfItems($pdf, $item, true);
+ break;
- case 'Reservation$1':
- PluginPdfReservation::pdfForUser($pdf, $item);
- break;
+ case 'Reservation$1':
+ PluginPdfReservation::pdfForUser($pdf, $item);
+ break;
- default:
- return false;
+ default:
+ return false;
+ }
}
return true;
diff --git a/phpstan.neon b/phpstan.neon
index de8ee41..1a1e4a6 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -1,7 +1,7 @@
parameters:
parallel:
maximumNumberOfProcesses: 2
- level: 0
+ level: 5
bootstrapFiles:
- ../../inc/based_config.php
paths:
@@ -18,5 +18,6 @@ parameters:
- ../../stubs/glpi_constants.php
ignoreErrors:
- '#Call to static method Error\(\) on an unknown class PluginWebservicesMethodCommon#'
+ - '#Constant WEBSERVICES_ERROR_[A-Z]+ not found#'
rules:
- GlpiProject\Tools\PHPStan\Rules\GlobalVarTypeRule
diff --git a/tools/move_to_po.php b/tools/move_to_po.php
index 2d6e983..2c28b44 100755
--- a/tools/move_to_po.php
+++ b/tools/move_to_po.php
@@ -37,18 +37,16 @@
chdir(dirname($_SERVER['SCRIPT_FILENAME']));
-if ($argv) {
- for ($i = 1 ; $i < count($argv) ; $i++) {
- //To be able to use = in search filters, enter \= instead in command line
- //Replace the \= by ° not to match the split function
- $arg = str_replace('\=', '°', $argv[$i]);
- $it = explode('=', $arg);
- $it[0] = preg_replace('/^--/', '', $it[0]);
-
- //Replace the ° by = the find the good filter
- $it = str_replace('°', '=', $it);
- $_GET[$it[0]] = $it[1];
- }
+for ($i = 1 ; $i < count($argv) ; $i++) {
+ //To be able to use = in search filters, enter \= instead in command line
+ //Replace the \= by ° not to match the split function
+ $arg = str_replace('\=', '°', $argv[$i]);
+ $it = explode('=', $arg);
+ $it[0] = preg_replace('/^--/', '', $it[0]);
+
+ //Replace the ° by = the find the good filter
+ $it = str_replace('°', '=', $it);
+ $_GET[$it[0]] = $it[1];
}
if (!isset($_GET['lang'])) {
@@ -63,6 +61,8 @@
exit();
}
include(GLPI_ROOT . '/locales/en_GB.php');
+/** @var array $LANG */
+global $LANG;
$REFLANG = $LANG;
$lf = fopen(GLPI_ROOT . '/locales/' . $_GET['lang'] . '.php', 'r');
@@ -86,7 +86,10 @@
print "Unable to read glpi.pot file\n";
exit();
}
+$current_string = '';
$current_string_plural = '';
+$sing_trans = '';
+$plural_trans = '';
$pot = fopen(GLPI_ROOT . '/locales/glpi.pot', 'r');
$po = fopen(GLPI_ROOT . '/locales/' . $_GET['lang'] . '.po', 'w+');
@@ -200,6 +203,8 @@ function search_in_dict($string, $context)
$ponctmatch = "([\.: \(\)]*)";
$varmatch = '(%s)*';
+ $left = '';
+ $right = '';
if (preg_match("/$varmatch$ponctmatch(.*)$ponctmatch$varmatch$/U", $string, $reg)) {
// print_r($reg);