Exemple #1
0
/**
* Saves the catefory after an edit form submit
* @param database A database connector object
* @param string The name of the category section
*/
function saveSection($option, $scope)
{
    global $database;
    $row = new mosSection($database);
    if (!$row->bind($_POST)) {
        echo "<script> alert('" . $row->getErrorMsg() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    if (!$row->check()) {
        echo "<script> alert('" . $row->getErrorMsg() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    if ($oldtitle = mosGetParam($_POST, 'oldtitle', null)) {
        if ($oldtitle != $row->title) {
            $database->setQuery("UPDATE #__menu SET name='{$row->title}' WHERE name='{$oldtitle}' AND type='content_section'");
            $database->query();
        }
    }
    if (!$row->store()) {
        echo "<script> alert('" . $row->getErrorMsg() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    $row->checkin();
    $row->updateOrder("scope='{$row->scope}'");
    mosRedirect('index2.php?option=' . $option . '&scope=' . $scope);
}