Exemplo n.º 1
0
function approve_cats($cat_id, $publish = 0, $option)
{
    global $mainframe;
    $database =& JFactory::getDBO();
    $mtCats = new mtCats($database);
    if (!is_array($cat_id) || count($cat_id) < 1) {
        echo "<script> alert('" . JText::_('Select an item to approve') . "'); window.history.go(-1);</script>\n";
        exit;
    }
    if (count($cat_id)) {
        foreach ($cat_id as $cid) {
            $mtCats->load($cid);
            $mtCats->approveCat();
            $mtCats->publishCat($publish);
            if ($mtCats->lft == 0 && $mtCats->rgt == 0) {
                $mtCats->updateLftRgt();
            }
            $mtCats->updateCatCount(1);
        }
    }
    $mainframe->redirect("index2.php?option={$option}&task=listpending_cats", sprintf(JText::_('Cats have been aprroved'), count($cat_id)));
}