From d615ac672795745cdd1234740a190ac34d70661d Mon Sep 17 00:00:00 2001 From: amma35 Date: Thu, 9 Aug 2018 11:19:17 +0200 Subject: [PATCH] fix deprecated Condition should be an array --- inc/closeticket.class.php | 26 ++++++++++++++++++-------- inc/profile.class.php | 6 +++--- inc/urgencyticket.class.php | 4 ++-- inc/waitingticket.class.php | 18 ++++++++++++------ 4 files changed, 35 insertions(+), 19 deletions(-) diff --git a/inc/closeticket.class.php b/inc/closeticket.class.php index 2d572b8bc3..56bc8bff2f 100644 --- a/inc/closeticket.class.php +++ b/inc/closeticket.class.php @@ -70,7 +70,12 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { if ($item->getType() == 'Ticket' && $item->fields['status'] == Ticket::CLOSED && $config->closeInformations()) { - + if ($_SESSION['glpishow_count_on_tabs']) { + $dbu = new DbUtils(); + return self::createTabEntry(__('Close ticket informations', 'moreticket'), + $dbu->countElementsInTable($this->getTable(), + ["tickets_id" => $item->getID()])); + } return __('Close ticket informations', 'moreticket'); } } @@ -303,9 +308,11 @@ static function showList($item, $canedit) { // Get close informations $data = self::getCloseTicketFromDB($item->getField('id'), ['start' => $start, - 'limit' => $_SESSION['glpilist_limit']]); - - if (!count($data)) { + 'limit' => $_SESSION['glpilist_limit']]); + $dbu = new DbUtils(); + $number = $dbu->countElementsInTable("glpi_plugin_moreticket_closetickets", + ['tickets_id' => $item->getField('id')]); + if ($number == 0) { echo "
"; echo ""; echo ""; @@ -316,7 +323,7 @@ static function showList($item, $canedit) { $doc = new Document(); echo "
"; // Display the pager - Html::printAjaxPager(__('Close ticket informations', 'moreticket'), $start, count($data)); + Html::printAjaxPager(__('Close ticket informations', 'moreticket'), $start, $number); if ($canedit) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); @@ -384,9 +391,12 @@ static function showList($item, $canedit) { */ static function getCloseTicketFromDB($tickets_id, $options = []) { $dbu = new DbUtils(); - $data = $dbu->getAllDataFromTable("glpi_plugin_moreticket_closetickets", 'tickets_id = ' . $tickets_id, - false, - '`date` DESC LIMIT ' . intval($options['start']) . "," . intval($options['limit'])); + $data = $dbu->getAllDataFromTable("glpi_plugin_moreticket_closetickets", + ['tickets_id' => $tickets_id]+ + ['ORDER' => 'date DESC']+ + ['START' => (int)$options['start']]+ + ['LIMIT' => (int)$options['limit']], + false); return $data; } diff --git a/inc/profile.class.php b/inc/profile.class.php index fa6a4f6356..f3fc599467 100644 --- a/inc/profile.class.php +++ b/inc/profile.class.php @@ -96,11 +96,11 @@ static function addDefaultProfileInfos($profiles_id, $rights, $drop_existing = f $profileRight = new ProfileRight(); foreach ($rights as $right => $value) { if ($dbu->countElementsInTable('glpi_profilerights', - "`profiles_id`='$profiles_id' AND `name`='$right'") && $drop_existing) { + ["profiles_id" => $profiles_id, "name" => $right]) && $drop_existing) { $profileRight->deleteByCriteria(['profiles_id' => $profiles_id, 'name' => $right]); } if (!$dbu->countElementsInTable('glpi_profilerights', - "`profiles_id`='$profiles_id' AND `name`='$right'")) { + ["profiles_id" => $profiles_id, "name" => $right])) { $myright['profiles_id'] = $profiles_id; $myright['name'] = $right; $myright['rights'] = $value; @@ -255,7 +255,7 @@ static function initProfile() { //Add new rights in glpi_profilerights table foreach ($profile->getAllRights(true) as $data) { if ($dbu->countElementsInTable("glpi_profilerights", - "`name` = '" . $data['field'] . "'") == 0) { + ["name" => $data['field']]) == 0) { ProfileRight::addProfileRights([$data['field']]); } } diff --git a/inc/urgencyticket.class.php b/inc/urgencyticket.class.php index 3815413f78..f64c90cc96 100644 --- a/inc/urgencyticket.class.php +++ b/inc/urgencyticket.class.php @@ -174,10 +174,10 @@ static function getUrgencyTicketFromDB($tickets_id, $options = []) { $dbu = new DbUtils(); if (sizeof($options) == 0) { $data_Urgency = $dbu->getAllDataFromTable("glpi_plugin_moreticket_urgencytickets", - '`tickets_id` = ' . $tickets_id); + ['tickets_id' => $tickets_id]); } else { $data_Urgency = $dbu->getAllDataFromTable("glpi_plugin_moreticket_urgencytickets", - 'tickets_id = ' . $tickets_id, + ['tickets_id' => $tickets_id], false, ' LIMIT ' . intval($options['start']) . "," . intval($options['limit'])); } diff --git a/inc/waitingticket.class.php b/inc/waitingticket.class.php index 8d3ad2e7e6..ef3003d64f 100644 --- a/inc/waitingticket.class.php +++ b/inc/waitingticket.class.php @@ -83,7 +83,7 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { $dbu = new DbUtils(); return self::createTabEntry(self::getTypeName(2), $dbu->countElementsInTable($this->getTable(), - "`tickets_id` = '" . $item->getID() . "'")); + ["tickets_id" => $item->getID()])); } return self::getTypeName(2); } @@ -371,7 +371,7 @@ static function showForTicket($item) { // Total Number of events $dbu = new DbUtils(); $number = $dbu->countElementsInTable("glpi_plugin_moreticket_waitingtickets", - "`tickets_id`='" . $item->getField('id') . "'"); + ["tickets_id" =>$item->getField('id')]); if ($number < 1) { echo "
"; @@ -395,7 +395,7 @@ static function showForTicket($item) { foreach (self::getWaitingTicketFromDB($item->getField('id'), ['start' => $start, - 'limit' => $_SESSION['glpilist_limit']]) as $waitingTicket) { + 'limit' => $_SESSION['glpilist_limit']]) as $waitingTicket) { echo "
"; echo "
" . __('No historical') . "
"; @@ -440,10 +440,16 @@ static function getWaitingTicketFromDB($tickets_id, $options = []) { $dbu = new DbUtils(); if (sizeof($options) == 0) { - $data_WaitingType = $dbu->getAllDataFromTable("glpi_plugin_moreticket_waitingtickets", - '`tickets_id` = ' . $tickets_id .' AND `date_suspension` IN (SELECT max(`date_suspension`) - FROM `glpi_plugin_moreticket_waitingtickets` WHERE `tickets_id` = ' . $tickets_id . ') + $iterator = $DB->request("glpi_plugin_moreticket_waitingtickets", + '`tickets_id` = ' . $tickets_id .' + AND `date_suspension` IN (SELECT max(`date_suspension`) + FROM `glpi_plugin_moreticket_waitingtickets` + WHERE `tickets_id` = ' . $tickets_id . ') AND (UNIX_TIMESTAMP(`date_end_suspension`) = 0 OR UNIX_TIMESTAMP(`date_end_suspension`) IS NULL)'); + $data_WaitingType = []; + while ($row = $iterator->next()) { + $data_WaitingType[$row['id']] = $row; + } } else { $iterator = $DB->request("glpi_plugin_moreticket_waitingtickets", "tickets_id = $tickets_id