function removecats2($cat_id, $option) { global $mainframe; $database =& JFactory::getDBO(); $row = new mtCats($database); $row->load($cat_id[0]); $cat_parent = $row->getParent(); if (!is_array($cat_id) || count($cat_id) < 1) { echo "<script> alert('" . JText::_('Select an item to delete') . "'); window.history.go(-1);</script>\n"; exit; } if (count($cat_id)) { $totalcats = 0; $totallinks = 0; foreach ($cat_id as $cid) { $row->load($cid); $totalcats += $row->cat_cats + 1; $totallinks += $row->cat_links; $row->deleteCats($cid); } # Update Cat & Link count smartCountUpdate($cat_parent, $totallinks * -1, $totalcats * -1); } $returntask = JRequest::getCmd('returntask', '', 'post'); if ($returntask != '') { $mainframe->redirect("index2.php?option={$option}&task={$returntask}"); } else { $mainframe->redirect("index2.php?option={$option}&task=listcats&cat_id=" . $cat_parent); } }