Commit d4b6adca authored by Cédric Anne's avatar Cédric Anne
Browse files

Specific changes

parent 75b2190c
......@@ -593,7 +593,8 @@ class Budget extends CommonDropdown{
"</td></tr>";
} else if ($nb) {
for ($prem=true; $data = $iterator->next(); $prem=false) {
for ($prem=true; $iterator->valid(); $prem=false) {
$data = $iterator->current();
$name = NOT_AVAILABLE;
if ($item->getFromDB($data["id"])) {
if ($item instanceof Item_Devices) {
......@@ -625,6 +626,7 @@ class Budget extends CommonDropdown{
:"-");
echo "</td></tr>";
$iterator->next();
}
}
$num += $nb;
......
......@@ -1396,7 +1396,7 @@ class Change extends CommonITILObject {
'rows' => []
];
$i = 0;
while ($i < $displayed_row_count && ($data = $iterator->next())) {
foreach ($iterator as $data) {
$change = new self();
$rand = mt_rand();
$row = [
......@@ -1458,8 +1458,12 @@ class Change extends CommonITILObject {
]
];
}
$i++;
$twig_params['rows'][] = $row;
$i++;
if ($i == $displayed_row_count) {
break;
}
}
TemplateRenderer::getInstance()->display('components/table.html.twig', $twig_params);
}
......
......@@ -1517,9 +1517,13 @@ abstract class CommonITILTask extends CommonDBTM implements CalDAVCompatibleItem
echo "<th>".__('Description')."</th>";
echo "</tr>";
$i = 0;
while ($i < $displayed_row_count && ($data = $iterator->next())) {
foreach ($iterator as $data) {
self::showVeryShort($data['id'], $itemtype);
$i++;
if ($i == $displayed_row_count) {
break;
}
}
echo "</table>";
}
......
......@@ -251,7 +251,7 @@ class GLPIKey {
['NOT' => [$column => null]],
]);
while ($success && $row = $iterator->next()) {
foreach ($iterator as $row) {
$value = (string)$row[$column];
if ($old_key === false) {
$pass = Toolbox::sodiumEncrypt(Toolbox::sodiumDecrypt($value, $sodium_key));
......@@ -263,6 +263,10 @@ class GLPIKey {
[$field => $pass],
['id' => $row['id']]
);
if (!$success) {
break;
}
}
}
......
......@@ -850,7 +850,8 @@ JAVASCRIPT;
$data['userfirstname'], $linkUser)."</td>";
echo "</tr>\n";
} while ($data = $iterator->next());
$iterator->next();
} while ($data = $iterator->current());
echo $header_begin.$header_bottom.$header_end;
echo "</table>\n";
if ($canedit) {
......
......@@ -773,7 +773,8 @@ class Item_SoftwareVersion extends CommonDBRelation {
echo "<td>".Html::convDate($data['date_install'])."</td>";
echo "</tr>\n";
} while ($data = $iterator->next());
$iterator->next();
} while ($data = $iterator->current());
echo $header_begin.$header_bottom.$header_end;
......@@ -1026,7 +1027,7 @@ class Item_SoftwareVersion extends CommonDBRelation {
$header_end .= "</tr>\n";
echo $header_begin.$header_top.$header_end;
for ($row=0; $data = $iterator->next(); $row++) {
for ($row=0; $data = $iterator->current(); $row++) {
if (($row >= $start) && ($row < ($start + $_SESSION['glpilist_limit']))) {
$licids = self::softwareByCategory($data, $itemtype, $items_id, $withtemplate,
......@@ -1041,6 +1042,7 @@ class Item_SoftwareVersion extends CommonDBRelation {
Session::addToNavigateListItems('SoftwareLicense', $licid);
$installed[] = $licid;
}
$iterator->next();
}
echo $header_begin.$header_bottom.$header_end;
......
......@@ -1757,8 +1757,7 @@ class MailCollector extends CommonDBTM {
if (count($iterator) > 0) {
$mc = new self();
while (($max > 0)
&& ($data = $iterator->next())) {
foreach ($iterator as $data) {
$mc->maxfetch_emails = $max;
$task->log("Collect mails from ".$data["name"]." (".$data["host"].")\n");
......@@ -1768,6 +1767,10 @@ class MailCollector extends CommonDBTM {
$task->log("$message\n");
$max -= $mc->fetch_emails;
if ($max === 0) {
break;
}
}
}
......
......@@ -954,7 +954,7 @@ class NetworkPort extends CommonDBChild {
count($vlans)
);
} else {
while ($row = $vlans->next()) {
foreach ($vlans as $row) {
$output .= $row['name'];
if (!empty($row['tag'])) {
$output .= ' [' . $row['tag'] . ']';
......@@ -997,7 +997,7 @@ class NetworkPort extends CommonDBChild {
]);
$list_ports = [];
while ($hrow = $hub_ports->next()) {
foreach ($hub_ports as $hrow) {
$npo = NetworkPort::getContact($hrow['id']);
$list_ports[] = $npo;
}
......@@ -1029,7 +1029,7 @@ class NetworkPort extends CommonDBChild {
count($hub_equipments)
) . '</div>';
} else {
while ($hrow = $hub_equipments->next()) {
foreach ($hub_equipments as $hrow) {
$hub = new Unmanaged();
$hub->getFromDB($hrow['id']);
$hub->fields['mac'] = $hrow['mac'];
......
......@@ -984,7 +984,7 @@ class Problem extends CommonITILObject {
];
$i = 0;
while ($i < $displayed_row_count && ($data = $iterator->next())) {
foreach ($iterator as $data) {
$problem = new self();
$rand = mt_rand();
$row = [
......@@ -1046,8 +1046,12 @@ class Problem extends CommonITILObject {
]
];
}
$i++;
$twig_params['rows'][] = $row;
$i++;
if ($i == $displayed_row_count) {
break;
}
}
TemplateRenderer::getInstance()->display('components/table.html.twig', $twig_params);
}
......
......@@ -339,7 +339,8 @@ class SoftwareVersion extends CommonDBChild {
echo "<th>".__('Comments')."</th>";
echo "</tr>\n";
for ($tot = $nb = 0; $data = $iterator->next(); $tot += $nb) {
$tot = 0;
foreach ($iterator as $data) {
Session::addToNavigateListItems('SoftwareVersion', $data['id']);
$nb = Item_SoftwareVersion::countForVersion($data['id']);
......@@ -352,6 +353,8 @@ class SoftwareVersion extends CommonDBChild {
echo "</td>";
echo "<td class='numeric'>$nb</td>";
echo "<td>".nl2br($data['comment'])."</td></tr>\n";
$tot += $nb;
}
echo "<tr class='tab_bg_1 noHover'><td class='right b' colspan='3'>".__('Total')."</td>";
......
......@@ -1434,10 +1434,10 @@ class Stat extends CommonGLPI {
$start = 0;
}
for ($i=$start; ($i<$numrows) && ($i<$end_display); $i++) {
$i = $start;
foreach ($iterator as $data) {
$item_num = 1;
// Get data and increment loop variables
$data = $iterator->next();
if (!($item = getItemForItemtype($data["itemtype"]))) {
continue;
}
......@@ -1459,6 +1459,11 @@ class Stat extends CommonGLPI {
"class='center'"." ".($item->isDeleted()?" class='deleted' "
:""));
}
$i++;
if ($i == $end_display) {
break;
}
}
echo Search::showFooter($output_type);
......
......@@ -4939,7 +4939,7 @@ JAVASCRIPT;
];
$i = 0;
while ($i < $displayed_row_count && ($data = $iterator->next())) {
foreach ($iterator as $data) {
$showprivate = false;
if (Session::haveRight('followup', ITILFollowup::SEEPRIVATE)) {
$showprivate = true;
......@@ -5021,8 +5021,12 @@ JAVASCRIPT;
]
];
}
$i++;
$twig_params['rows'][] = $row;
$i++;
if ($i == $displayed_row_count) {
break;
}
}
$output = TemplateRenderer::getInstance()->render('components/table.html.twig', $twig_params);
if ($display) {
......
......@@ -1920,8 +1920,7 @@ class Transfer extends CommonDBTM {
$canbetransfer = true;
$types_iterator = Certificate_Item::getDistinctTypes($item_ID);
while (($data_type = $types_iterator->next())
&& $canbetransfer) {
foreach ($types_iterator as $data_type) {
$dtype = $data_type['itemtype'];
if (isset($this->needtobe_transfer[$dtype]) && count($this->needtobe_transfer[$dtype])) {
......@@ -1943,6 +1942,9 @@ class Transfer extends CommonDBTM {
$canbetransfer = false;
}
if (!$canbetransfer) {
break;
}
}
// Yes : transfer
......@@ -2097,8 +2099,7 @@ class Transfer extends CommonDBTM {
$canbetransfer = true;
$types_iterator = Contract_Item::getDistinctTypes($item_ID);
while (($data_type = $types_iterator->next())
&& $canbetransfer) {
foreach ($types_iterator as $data_type) {
$dtype = $data_type['itemtype'];
if (isset($this->needtobe_transfer[$dtype]) && count($this->needtobe_transfer[$dtype])) {
......@@ -2120,6 +2121,9 @@ class Transfer extends CommonDBTM {
$canbetransfer = false;
}
if (!$canbetransfer) {
break;
}
}
// Yes : transfer
......@@ -2273,8 +2277,7 @@ class Transfer extends CommonDBTM {
$canbetransfer = true;
$types_iterator = Document_Item::getDistinctTypes($item_ID);
while (($data_type = $types_iterator->next())
&& $canbetransfer) {
foreach ($types_iterator as $data_type) {
$dtype = $data_type['itemtype'];
if (isset($this->needtobe_transfer[$dtype])) {
// No items to transfer -> exists links
......@@ -2304,6 +2307,10 @@ class Transfer extends CommonDBTM {
}
}
if (!$canbetransfer) {
break;
}
}
// Yes : transfer
......@@ -3446,8 +3453,7 @@ class Transfer extends CommonDBTM {
'WHERE' => [$fk => $item_ID]
]);
while (($data_type = $type_iterator->next())
&& $canbetransfer) {
foreach ($type_iterator as $data_type) {
$dtype = $data_type['itemtype'];
if (isset($this->needtobe_transfer[$dtype]) && count($this->needtobe_transfer[$dtype])) {
......@@ -3474,6 +3480,9 @@ class Transfer extends CommonDBTM {
$canbetransfer = false;
}
if (!$canbetransfer) {
break;
}
}
// Yes : transfer
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment