Skip to content

Commit

Permalink
fix deprecated Condition should be an array
Browse files Browse the repository at this point in the history
  • Loading branch information
amma35 committed Aug 9, 2018
1 parent c736d72 commit d615ac6
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 19 deletions.
26 changes: 18 additions & 8 deletions inc/closeticket.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
Expand Down Expand Up @@ -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 "<div class='center'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th>" . __('No historical') . "</th></tr>";
Expand All @@ -316,7 +323,7 @@ static function showList($item, $canedit) {
$doc = new Document();
echo "<div class='center'>";
// 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);
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions inc/profile.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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']]);
}
}
Expand Down
4 changes: 2 additions & 2 deletions inc/urgencyticket.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']));
}
Expand Down
18 changes: 12 additions & 6 deletions inc/waitingticket.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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 "<div class='center'>";
Expand All @@ -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 "<tr class='tab_bg_2'>";
echo "<td>";
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d615ac6

Please sign in to comment.